]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
Merge branch 'CSPACE-5564-REM-A' into CSPACE-5564-REM-B
authorRichard Millet <remillet@berkeley.edu>
Mon, 4 Feb 2013 17:01:32 +0000 (09:01 -0800)
committerRichard Millet <remillet@berkeley.edu>
Mon, 4 Feb 2013 17:01:32 +0000 (09:01 -0800)
Conflicts:
services/authentication/service/src/main/java/org/collectionspace/authentication/spring/SpringAuthNContext.java

1  2 
services/authentication/service/src/main/java/org/collectionspace/authentication/spring/SpringAuthNContext.java
services/build.xml
services/report/client/src/main/java/org/collectionspace/services/client/ReportClient.java
services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java

index 17b59baa635777d23a28f20f3666349790238688,9094773f6344ce074a3193c8555164184be3cf45..29a29f6967badd9823e724a109690c629697db65
@@@ -43,8 -46,14 +46,14 @@@ final public class SpringAuthNContext e
      //private static final String SUBJECT_CONTEXT_KEY = "javax.security.auth.Subject.container";
  
      public String getUserId() {
+       String result = ANONYMOUS_USER;
+       
          Authentication authToken = SecurityContextHolder.getContext().getAuthentication();
-         return authToken.getName();
+         if (authToken != null) {
+               result = authToken.getName();
 -        }
++    }
+         
+         return result;
      }
  
      /**
  
      @Override
      public String getCurrentTenantId() {
-         //FIXME assumption in 1.0: each user is associated with a single tenant
+       String result = ANONYMOUS_TENANT_ID;
+       
+       String userId = getUserId();
+       if (userId.equals(ANONYMOUS_USER) == false && userId.equals(SPRING_ADMIN_USER) == false) {
 -              String[] tenantIds = getTenantIds();
 -              if (tenantIds.length < 1) {
 -                  throw new IllegalStateException("No tenant associated with user=" + getUserId());
 -              }
 +        String[] tenantIds = getTenantIds();
 +        if (tenantIds.length < 1) {
 +            throw new IllegalStateException("No tenant associated with user=" + getUserId());
 +        }
-         return getTenantIds()[0];
+               result = getTenantIds()[0];
 -      }
++    }
+       
+       return result;
      }
  
      public CSpaceTenant[] getTenants() {
  
      @Override
      public String getCurrentTenantName() {
-         //FIXME assumption in 1.0: each user is associated with a single tenant
+       String result = ANONYMOUS_TENANT_NAME;
+       
+       if (getUserId().equals(ANONYMOUS_USER) == false) {
 -              CSpaceTenant[] tenants = getTenants();
 -              if (tenants.length < 1) {
 -                  throw new IllegalStateException("No tenant associated with user=" + getUserId());
 -              }
 +        CSpaceTenant[] tenants = getTenants();
 +        if (tenants.length < 1) {
 +            throw new IllegalStateException("No tenant associated with user=" + getUserId());
 +        }
-         return getTenants()[0].getName();
+               result = getTenants()[0].getName();
 -      }
++    }
+       
+       return result;
      }
  
      public Subject getSubject() {
Simple merge
index 95e3f4923bc8bd3e97e728333a0d06d0d08a8dc6,d3628e85b9f0bff99ccf5ae46cccf58d9815a66d..c0bb1cac96a4eadace1bf75e8394ac7f41011b78
@@@ -225,19 -225,14 +230,18 @@@ public class ReportDocumentModelHandle
                
        }
  
-     private Response buildReportResponse(String reportCSID, 
-               HashMap<String, Object> params, String reportFileName, String outputMimeType)
+     private InputStream buildReportResult(String reportCSID, 
+               HashMap<String, Object> params, String reportFileName, String outputMimeType, StringBuffer outReportFileName)
                                throws Exception {
                Connection conn = null;
-               Response response = null;
+               InputStream result = null;
+               
        try {
 -                      String fullPath = ServiceMain.getInstance().getServerRootDir() +
 +              String fileNameBase = Tools.getFilenameBase(reportFileName);
 +              String compiledReportFilename = fileNameBase+ReportClient.COMPILED_REPORT_EXTENSION;
 +              String reportDescriptionFilename = fileNameBase+ReportClient.REPORT_DECSRIPTION_EXTENSION;
 +              
 +                      String basePath = ServiceMain.getInstance().getServerRootDir() +
                                                                File.separator + ConfigReader.CSPACE_DIR_NAME + 
                                                                File.separator + REPORTS_FOLDER +
                                                                // File.separator + tenantName +
                                exporter = new JRCsvExporter();
                                exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, "\t");
                                outputFilename = outputFilename+".csv";
 +                      } else if(outputMimeType.equals(ReportClient.MSWORD_MIME_TYPE)  // Understand msword as docx
 +                                      || outputMimeType.equals(ReportClient.OPEN_DOCX_MIME_TYPE)) {
 +                              exporter = new JRDocxExporter();
 +                              outputFilename = outputFilename+".docx";
 +                      } else if(outputMimeType.equals(ReportClient.MSEXCEL_MIME_TYPE) // Understand msexcel as xlsx
 +                                      || outputMimeType.equals(ReportClient.OPEN_XLSX_MIME_TYPE)) {
 +                              exporter = new JRXlsxExporter();
 +                              outputFilename = outputFilename+".xlsx";
 +                      } else if(outputMimeType.equals(ReportClient.MSPPT_MIME_TYPE)   // Understand msppt as xlsx
 +                                      || outputMimeType.equals(ReportClient.OPEN_PPTX_MIME_TYPE)) {
 +                              exporter = new JRPptxExporter();
 +                              outputFilename = outputFilename+".pptx";
 +                      } else {
 +                              logger.error("Reporting: unsupported output MIME type - defaulting to PDF");
 +                              exporter = new JRPdfExporter();
 +                              outputFilename = outputFilename+"-default-to.pdf";
                        }
+                       outReportFileName.append(outputFilename); // Set the out going param to the report's final file name
                // fill the report
                        JasperPrint jasperPrint = JasperFillManager.fillReport(fileStream, params,conn);