Project

General

Profile

« Previous | Next » 

Revision 3502

Added by barteau about 17 years ago

Grant the public read access to the data files, if it was done for the metadata file. Also cleaned-up some debug statements.

View differences:

src/edu/ucsb/nceas/metacat/clientview/ClientViewHelper.java
70 70
        
71 71
        host = request.getHeader("host");
72 72
        context = request.getContextPath();
73
        //metacatPath = String.format(metacatPath, host, context);
74 73
        tmp = metacatPath.replaceFirst("%1s", host);
75 74
        metacatPath = tmp.replaceFirst("%2s", context);
76 75
        metacatClient = (MetacatClient) MetacatFactory.createMetacatConnection(metacatPath);
......
102 101
                    clientViewBean.setQformat(request.getParameter("qformat"));
103 102
                }
104 103
            }
104
            
105 105
            //*** END: manual bind params to bean.
106 106
            if (action != null) {
107 107
                try {
......
159 159
                        message = handleDocIdSelect();
160 160
                        clientViewBean.setMessage(ClientView.SELECT_MESSAGE, message);
161 161
                    } else if (action.equals("Download")) {
162
                        System.out.println("ClientViewHelper.clientRequest: action = " + action);
163 162
                        download(clientViewBean, response);
164 163
                    }
165 164
                    
......
266 265
        HashMap                     paramsMap, dataDocIDs;
267 266
        StringBuffer                fileName;
268 267
        boolean                     sendIt;
268
        Iterator                    iterIt;
269 269
        
270 270
        //*** Get the First file, which should be the metadata file.
271 271
        paramsMap = new HashMap();
......
288 288
                
289 289
                fileInfo = parseFileInfo(fileName.toString());
290 290
                dataDocIDs.put(nextDocId, fileInfo);
291
                
291 292
                //*** Upload the data file to metacat.
292 293
                getMetacatClient().upload(nextDocId, fileName.toString(), inputStream, Integer.MAX_VALUE);
293 294
                
......
312 313
                result = "MetaCat Package Inserted:  the Document Identifier is " + metaDocId;
313 314
                reader.close();
314 315
                
315
                //*** One last detail...grant the public read access.
316
                if (paramsMap.containsKey("publicAccess"))
316
                //*** Grant the public read access to the meta file.
317
                if (paramsMap.containsKey("publicAccess")) {
317 318
                    getMetacatClient().setAccess(metaDocId, "public", "read", "allow", "allowFirst");
319
                    //*** Grant the public read access to the data files.
320
                    iterIt = dataDocIDs.keySet().iterator();
321
                    while(iterIt.hasNext()) {
322
                        getMetacatClient().setAccess((String) iterIt.next(), "public", "read", "allow", "allowFirst");
323
                    }
324
                }
318 325
            }
319
            
320 326
        } else {
321 327
            result = "The first file must be an XML Metadata file.  Files not uploaded.";
322 328
        }
......
392 398
                        ClientFgdcHelper.updateFileNameAndType(getMetadataDoc().getDocumentElement(), newDocId, fileInfo);
393 399
                        //*** Upload the data file to metacat.
394 400
                        result = getMetacatClient().upload(newDocId, fNm, inputStream, Integer.MAX_VALUE);
395
                        System.out.println("ClientViewHelper.handleFileUpdate: upload returned " + result);
396 401
                        
397
                        
398 402
                        //*** Upload the metadata file to metacat.
399 403
                        xPathQuery = ClientFgdcHelper.XPATH_QUERY_TEMPLATE.replaceFirst("%1s", metadataDocId);
400 404
                        newDocId = updateMetadataDoc(metadataDocId, xPathQuery, null);
......
459 463
                parmName = part.getName();
460 464
                value = ((ParamPart) part).getStringValue();
461 465
                paramsMap.put(parmName, value);
462
                System.out.println("ClientViewHelper.getNextInputStream: parmName = " + parmName + "  value = " + value);
463 466
                
464 467
            } else if (part.isFile()) {
465 468
                fnam = ((FilePart) part).getFileName();
......
467 470
                    //*** File name is passed back via StringBuffer fileName param.
468 471
                    fileName.append(fnam);
469 472
                    result = ((FilePart) part).getInputStream();
470
                    System.out.println("ClientViewHelper.getNextInputStream: fileName = " + fileName + "  inputStream = " + result.toString());
471 473
                    break;
472 474
                }
473 475
            }
......
486 488
                parmName = part.getName();
487 489
                value = ((ParamPart) part).getStringValue();
488 490
                paramsMap.put(parmName, value);
489
                System.out.println("ClientViewHelper.getNextInputStream: parmName = " + parmName + "  value = " + value);
490 491
            }
491 492
        }
492 493
    }
......
860 861
                        args.put(docId, "docid");
861 862
                        args.put("xml", "qformat");
862 863
                    }
863
                    System.out.println("ClientViewHelper.download: docId = " + docId + "  metaId= " + metaId + "\npth = " + pth + "\nfNm = " + fNm);
864 864
                } else {
865 865
                    //*** TODO: EML -  this is just some basic code to start with.
866 866
                    if (docId.equals(metaId)) {

Also available in: Unified diff