changeset 4:9b408c9b05ab

Integration with LGServices.
author "jurzua <jurzua@mpiwg-berlin.mpg.de>"
date Thu, 07 May 2015 14:56:46 +0200
parents 65774fc878b7
children dd9adfc73390
files DVN-web/.classpath DVN-web/docs/readme.txt DVN-web/src/main/java/de/mpiwg/monographs/servlet/GetAllUsers.java DVN-web/src/main/java/de/mpiwg/monographs/servlet/MonographUtils.java DVN-web/src/main/java/de/mpiwg/monographs/servlet/SaveResource.java DVN-web/src/main/java/edu/harvard/iq/dvn/core/study/StudyFileEditBean.java DVN-web/src/main/java/edu/harvard/iq/dvn/core/study/StudyFileServiceBean.java DVN-web/src/main/webapp/WEB-INF/web.xml
diffstat 8 files changed, 202 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/DVN-web/.classpath	Tue Mar 10 15:47:07 2015 +0100
+++ b/DVN-web/.classpath	Thu May 07 14:56:46 2015 +0200
@@ -29,16 +29,8 @@
   <classpathentry kind="var" path="M2_REPO/org/apache/abdera/abdera-parser/1.1.1/abdera-parser-1.1.1.jar" sourcepath="M2_REPO/org/apache/abdera/abdera-parser/1.1.1/abdera-parser-1.1.1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/abdera/abdera-core/1.1.1/abdera-core-1.1.1.jar" sourcepath="M2_REPO/org/apache/abdera/abdera-core/1.1.1/abdera-core-1.1.1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/abdera/abdera-i18n/1.1.1/abdera-i18n-1.1.1.jar" sourcepath="M2_REPO/org/apache/abdera/abdera-i18n/1.1.1/abdera-i18n-1.1.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-activation_1.0.2_spec/1.1/geronimo-activation_1.0.2_spec-1.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3.jar" sourcepath="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" sourcepath="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/ws/commons/axiom/axiom-impl/1.2.10/axiom-impl-1.2.10.jar" sourcepath="M2_REPO/org/apache/ws/commons/axiom/axiom-impl/1.2.10/axiom-impl-1.2.10-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/ws/commons/axiom/axiom-api/1.2.10/axiom-api-1.2.10.jar" sourcepath="M2_REPO/org/apache/ws/commons/axiom/axiom-api/1.2.10/axiom-api-1.2.10-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jaxen/jaxen/1.1.1/jaxen-1.1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar" sourcepath="M2_REPO/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.3.02/xml-apis-1.3.02.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1.jar" sourcepath="M2_REPO/org/apache/geronimo/specs/geronimo-stax-api_1.0_spec/1.0.1/geronimo-stax-api_1.0_spec-1.0.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/wstx-asl/3.2.6/wstx-asl-3.2.6.jar" sourcepath="M2_REPO/org/codehaus/woodstox/wstx-asl/3.2.6/wstx-asl-3.2.6-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/abdera/abdera-extensions-json/1.0/abdera-extensions-json-1.0.jar" sourcepath="M2_REPO/org/apache/abdera/abdera-extensions-json/1.0/abdera-extensions-json-1.0-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/abdera/abdera-server/1.0/abdera-server-1.0.jar" sourcepath="M2_REPO/org/apache/abdera/abdera-server/1.0/abdera-server-1.0-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/abdera/abdera-extensions-main/1.0/abdera-extensions-main-1.0.jar" sourcepath="M2_REPO/org/apache/abdera/abdera-extensions-main/1.0/abdera-extensions-main-1.0-sources.jar"/>
@@ -123,16 +115,12 @@
   <classpathentry kind="var" path="M2_REPO/net/tanesha/recaptcha4j/recaptcha4j/0.0.7/recaptcha4j-0.0.7.jar" sourcepath="M2_REPO/net/tanesha/recaptcha4j/recaptcha4j/0.0.7/recaptcha4j-0.0.7-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/net/sourceforge/jexcelapi/jxl/2.6.9-java_1_4/jxl-2.6.9-java_1_4.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/swordapp/server/sword2-server/1.0-classes/sword2-server-1.0-classes.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.0.2/geronimo-activation_1.1_spec-1.0.2.jar" sourcepath="M2_REPO/org/apache/geronimo/specs/geronimo-activation_1.1_spec/1.0.2/geronimo-activation_1.1_spec-1.0.2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.6/geronimo-javamail_1.4_spec-1.6.jar" sourcepath="M2_REPO/org/apache/geronimo/specs/geronimo-javamail_1.4_spec/1.6/geronimo-javamail_1.4_spec-1.6-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/axiom/axiom-api/1.2.10/axiom-api-1.2.10.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/axiom/axiom-impl/1.2.10/axiom-impl-1.2.10.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-compress/1.5/commons-compress-1.5.jar" sourcepath="M2_REPO/org/apache/commons/commons-compress/1.5/commons-compress-1.5-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/tukaani/xz/1.2/xz-1.2.jar" sourcepath="M2_REPO/org/tukaani/xz/1.2/xz-1.2-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.jar" sourcepath="M2_REPO/commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/xom/xom/1.1/xom-1.1.jar" sourcepath="M2_REPO/xom/xom/1.1/xom-1.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xalan/xalan/2.7.0/xalan-2.7.0.jar" sourcepath="M2_REPO/xalan/xalan/2.7.0/xalan-2.7.0-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/edu/ucsb/nceas/ezid/ezid/0.9.0/ezid-0.9.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/commons/codec/commons-codec/1.6/commons-codec-1.6.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/http/client/fluent/fluent-hc/4.2.5/fluent-hc-4.2.5.jar"/>
--- a/DVN-web/docs/readme.txt	Tue Mar 10 15:47:07 2015 +0100
+++ b/DVN-web/docs/readme.txt	Thu May 07 14:56:46 2015 +0200
@@ -51,7 +51,7 @@
 
 
 
-curl --form upload=@pom.xml --form user=networkAdmin --form password=networkAdmin --form studyId=hdl:TEST/10001 http://localhost/dvn/saveResource
+curl --form upload=@pom.xml --form user=networkAdmin --form password=networkAdmin --form studyId=hdl:TEST/10002 http://localhost/dvn/saveResource
 
 GET USER
 http://localhost/dvn/getUser?user=jurzua&password=221082
--- a/DVN-web/src/main/java/de/mpiwg/monographs/servlet/GetAllUsers.java	Tue Mar 10 15:47:07 2015 +0100
+++ b/DVN-web/src/main/java/de/mpiwg/monographs/servlet/GetAllUsers.java	Thu May 07 14:56:46 2015 +0200
@@ -36,11 +36,8 @@
 			jsonResponse.put("state", "ok");
 			jsonResponse.put("users", array);
 		} catch (JSONException e) {
-			// TODO Auto-generated catch block
 			e.printStackTrace();
-		}	
-		
-			
+		}		
 		
 		java.io.PrintWriter out = response.getWriter();
 		out.print(jsonResponse);
--- a/DVN-web/src/main/java/de/mpiwg/monographs/servlet/MonographUtils.java	Tue Mar 10 15:47:07 2015 +0100
+++ b/DVN-web/src/main/java/de/mpiwg/monographs/servlet/MonographUtils.java	Thu May 07 14:56:46 2015 +0200
@@ -7,12 +7,60 @@
 import edu.harvard.iq.dvn.core.admin.UserGroup;
 import edu.harvard.iq.dvn.core.admin.VDCUser;
 import edu.harvard.iq.dvn.core.study.FileMetadata;
+import edu.harvard.iq.dvn.core.study.Metadata;
 import edu.harvard.iq.dvn.core.study.Study;
 import edu.harvard.iq.dvn.core.study.StudyVersion;
 import edu.harvard.iq.dvn.core.vdc.VDCGroup;
+import edu.harvard.iq.dvn.core.web.study.StudyUI;
+import edu.harvard.iq.dvn.core.vdc.VDC;
 
 public class MonographUtils {
 	
+	public static JSONObject jsonStudyUI(StudyUI studyUI){
+		JSONObject json = null;
+		
+		if(studyUI != null){
+			try {
+				json = jsonStudy(studyUI.getStudy());
+				json.put("metadata", jsonMetadata(studyUI.getMetadata()));
+				
+				String status =
+						(studyUI.getStudy().getLatestVersion().isDraft()) ? 
+								"Draft" : 
+								((studyUI.getStudy().getLatestVersion().isInReview()) ? 
+										"In Review" :(studyUI.getStudy().getLatestVersion().isReleased()) ? 
+												"Released" : "Deaccessioned");
+				json.put("status", status);
+				
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+		return json;
+	}
+	
+	public static JSONObject jsonMetadata(Metadata meta){
+		JSONObject json = new JSONObject();
+		
+		try {
+			
+			json.put("accessToSources", meta.getAccessToSources());
+			json.put("actionsToMinimizeLoss", meta.getActionsToMinimizeLoss());
+			json.put("authorsStr", meta.getAuthorsStr());
+			json.put("availabilityStatus", meta.getAvailabilityStatus());
+			json.put("citationRequirements", meta.getCitationRequirements());
+			json.put("subTitle", meta.getSubTitle());
+			json.put("title", meta.getTitle());
+			
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		
+		
+		
+		return json;
+	}
+	
 	public static JSONObject jsonStudy(Study study){
 		JSONObject json = new JSONObject();
 		
@@ -26,8 +74,15 @@
 				json.put("protocol", study.getProtocol());
 				json.put("version", study.getVersion());
 				json.put("studyId", study.getStudyId());
+				json.put("createTime", study.getCreateTime());
 				json.put("numberOfDownloads", study.getNumberOfDownloads());
 				
+				JSONObject owner = jsonVDC(study.getOwner());
+				json.put("owner", owner);
+				
+				JSONObject creator = jsonVDCUser(study.getCreator());
+				json.put("creator", creator);
+				
 				JSONArray array0 = new JSONArray();
 				for(VDCUser user :  study.getAllowedUsers()){
 					array0.put(jsonVDCUser(user));
@@ -42,6 +97,27 @@
 		
 		return json;
 	}
+	
+	public static JSONObject jsonVDC(VDC vdc){
+		JSONObject json = new JSONObject();
+		
+		try {
+			
+			json.put("name", vdc.getName());
+			json.put("aboutThis", vdc.getAboutThisDataverse());
+			json.put("visibility", vdc.getVisibility());
+			json.put("version", vdc.getVersion());
+			json.put("parentSite", vdc.getParentSite());
+			json.put("logo", vdc.getLogo());
+			json.put("header", vdc.getHeader());
+			json.put("alias", vdc.getAlias());
+			
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		
+		return json;
+	}
 
 	public static JSONObject jsonVDCUser(VDCUser user){
 		JSONObject json = new JSONObject();
--- a/DVN-web/src/main/java/de/mpiwg/monographs/servlet/SaveResource.java	Tue Mar 10 15:47:07 2015 +0100
+++ b/DVN-web/src/main/java/de/mpiwg/monographs/servlet/SaveResource.java	Thu May 07 14:56:46 2015 +0200
@@ -28,6 +28,7 @@
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.commons.lang.StringUtils;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.swordapp.server.AuthCredentials;
@@ -57,10 +58,10 @@
 	private static final long serialVersionUID = 1L;
 
 
-	private static final String TMP_DIR = "/home/jurzua/glassfish3/glassfish/domains/domain1/config/files/temp/monographs/";
+	private static final String TMP_DIR = "/gazetteer-server/tmp/";
 
 
-	private int maxFileSize = 50 * 1024;
+	private int maxFileSize = 100 * 1024;
 	private int maxMemSize = 4 * 1024;
 
 	private static final Logger logger = Logger.getLogger("monographs.SaveResource");
@@ -82,53 +83,69 @@
 	}
 
 	@Override
-	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
-			IOException {
+	protected void doPost(HttpServletRequest request, HttpServletResponse response) {
 
-		logger.info("SaveResource");
-		
-		response.setContentType("application/json");
-		JSONObject jsonResponse = new JSONObject();
+		try {
+			response.setContentType("application/json");
+			JSONObject jsonResponse = new JSONObject();
+
+			File file = getFile(request, response);
 
-		File file = getFile(request, response);
+			if (file != null && file.length() > 0) {
+				String studyGlobalId = params.get("studyId");
+				String user = params.get("user");
+				String password = params.get("password");
+				//String fileLabel = params.get("fileLabel");
 
-		if (file != null) {
-			String studyGlobalId = params.get("studyId");
-			String user = params.get("user");
-			String password = params.get("password");
-			AuthCredentials authCredentials = new AuthCredentials(user, password, null);
+				if(StringUtils.isNotEmpty(studyGlobalId) && 
+						StringUtils.isNotEmpty(user) &&
+						StringUtils.isNotEmpty(password)/* &&
+						StringUtils.isNotEmpty(fileLabel)*/){
+					AuthCredentials authCredentials = new AuthCredentials(user, password, null);
 
-			try {
-				List<StudyFileEditBean> list = saveFile(file, studyGlobalId, authCredentials);
-				
-				JSONObject fileMetatdata = new JSONObject();
-				fileMetatdata.put("id", list.get(0).getFileMetadata().getId());
-				fileMetatdata.put("label", list.get(0).getFileMetadata().getLabel());
-				fileMetatdata.put("version", list.get(0).getFileMetadata().getVersion());
-				fileMetatdata.put("description", list.get(0).getFileMetadata().getDescription());
-				
-				
-				jsonResponse.put("fileMetadata", fileMetatdata);
-				
-			} catch (Exception e) {
-				logger.log(Level.SEVERE, "Error!!!!!!", e);
-				error(jsonResponse, e);
+					try {
+						List<StudyFileEditBean> list = saveFile(file, studyGlobalId, authCredentials/*, fileLabel*/);
+						
+						JSONObject fileMetatdata = new JSONObject();
+						fileMetatdata.put("id", list.get(0).getFileMetadata().getId());
+						fileMetatdata.put("label", list.get(0).getFileMetadata().getLabel());
+						fileMetatdata.put("version", list.get(0).getFileMetadata().getVersion());
+						fileMetatdata.put("description", list.get(0).getFileMetadata().getDescription());
+						
+						
+						jsonResponse.put("fileMetadata", fileMetatdata);
+						jsonResponse.put("status", "ok");
+						
+					} catch (Exception e) {
+						logger.log(Level.SEVERE, "Error!!!!!!", e);
+						error(jsonResponse, e);
+					}				
+				}else{
+					jsonResponse.put("status", "error");
+					jsonResponse.put("error", "The parameters studyId, user and password.");
+					jsonResponse.put("studyId", studyGlobalId);
+					jsonResponse.put("user", user);
+					jsonResponse.put("password", password);
+					//jsonResponse.put("fileLabel", fileLabel);
+				}
+
+			}else if(file == null){
+				jsonResponse.put("status", "error");
+				jsonResponse.put("message", "No file found in the request.");
+			}else {
+				jsonResponse.put("status", "error");
+				jsonResponse.put("message", "A file has been found as parameter, however it was empty. Check the temporal folder configured in Dataverse. " + TMP_DIR);
 			}
-		}else{
-			try {
-				jsonResponse.put("error", "No file found in the request.");
-			} catch (JSONException e) {
-				logger.log(Level.SEVERE, e.getMessage());
-				error(jsonResponse, e);
-			}
+			
+			java.io.PrintWriter out = response.getWriter();
+			out.print(jsonResponse);
+			out.flush();
+		} catch (Exception e) {	
+			e.printStackTrace();
 		}
-		java.io.PrintWriter out = response.getWriter();
-		out.print(jsonResponse);
-		out.flush();
 	}
 
 	private File getFile(HttpServletRequest request, HttpServletResponse response) throws IOException {
-
 		File file = null;
 		boolean isMultipart = ServletFileUpload.isMultipartContent(request);		
 		
@@ -143,7 +160,7 @@
 			ServletFileUpload upload = new ServletFileUpload(factory);
 			// maximum file size to be uploaded.
 			upload.setSizeMax(maxFileSize);
-
+			StringBuilder sb = new StringBuilder();
 			try {
 				// Parse the request to get file items.
 				List fileItems = upload.parseRequest(request);
@@ -154,9 +171,13 @@
 				while (i.hasNext()) {
 					FileItem fi = (FileItem) i.next();
 					
+					sb.append(fi.getFieldName());
+					
 					if(fi.isFormField()){
+						sb.append(" is Field");
 						params.put(fi.getFieldName(), fi.getString());
 					} else {
+						sb.append(" is FILE ***");
 						// Get the uploaded file parameters
 						String fileName = fi.getName();
 						// Write the file
@@ -166,20 +187,25 @@
 							file = new File(TMP_DIR + fileName.substring(fileName.lastIndexOf("\\") + 1));
 						}
 						fi.write(file);
+						sb.append(" Size: " + file.length());
 					}
+					sb.append("\n");
 				}
 
 			} catch (Exception ex) {
 				ex.printStackTrace();
 			}
+			
+			sb.append((file == null) ? "File is null" : "File Size=" + file.length() + ".\nWhen the file is empty, maybe the tmp folder is wrong configured.\nTMP_DIR: " + TMP_DIR);
+			logger.log(Level.INFO, "getFile Information:\n" + sb.toString());
+			
 			return file;	
 		}
 		
 		return null;
 	}
 
-	private List<StudyFileEditBean> saveFile(File file, String studyGlobalId, AuthCredentials authCredentials) throws SwordAuthException,
-			SwordServerException, SwordError, IOException {
+	private List<StudyFileEditBean> saveFile(File file, String studyGlobalId, AuthCredentials authCredentials/*, String fileLabel*/) throws Exception {
 		VDCUser vdcUser = swordAuth.auth(authCredentials);
 
 		Study study = getStudy(studyGlobalId);
@@ -187,19 +213,29 @@
 		try {
 			List<StudyFileEditBean> files = getFileList(file, study);
 			studyFileService.addFiles(study.getLatestVersion(), files, vdcUser);
-			System.out.println("AAAA");
 			return files;
 		} catch (EJBException ex) {
 			throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "Unable to add file(s) to study: " + ex.getMessage());
 		}
 	}
 
-	public List<StudyFileEditBean> getFileList(File file, Study study) throws IOException {
+	public List<StudyFileEditBean> getFileList(File uploadedInputFile, Study study) throws Exception {
 		List<StudyFileEditBean> fbList = new ArrayList<StudyFileEditBean>();
 
-		if (file.length() != 0) {
-			StudyFileEditBean tempFileBean = new StudyFileEditBean(file, studyService.generateFileSystemNameSequence(),
-					study);
+		if (uploadedInputFile.length() != 0) {
+			
+			File dir = new File(uploadedInputFile.getParentFile(), study.getId().toString() );
+            if ( !dir.exists() ) {
+                dir.mkdir();
+            }
+            File file = FileUtil.createTempFile(dir, uploadedInputFile.getName());
+            if (!uploadedInputFile.renameTo(file)) {
+                // in windows environment, rename doesn't work, so we will copy the file instead
+                FileUtil.copyFile(uploadedInputFile, file);	
+                uploadedInputFile.delete();
+            }
+			
+			StudyFileEditBean tempFileBean = new StudyFileEditBean(file, studyService.generateFileSystemNameSequence(), study);
 			tempFileBean.setSizeFormatted(file.length());
 			fbList.add(tempFileBean);
 		}
--- a/DVN-web/src/main/java/edu/harvard/iq/dvn/core/study/StudyFileEditBean.java	Tue Mar 10 15:47:07 2015 +0100
+++ b/DVN-web/src/main/java/edu/harvard/iq/dvn/core/study/StudyFileEditBean.java	Thu May 07 14:56:46 2015 +0200
@@ -68,9 +68,18 @@
     public StudyFileEditBean(File file, String fileSystemName, Study study) throws IOException {
         this(file,fileSystemName,study,false);
     }
-
+    
     public StudyFileEditBean(File file, String fileSystemName, Study study, boolean asOtherMaterial) throws IOException {
 
+    	StringBuilder sb = new StringBuilder();
+    	sb.append("\n### StudyFileEditBean Information ###\n");
+    	sb.append("\tfileSystemName: " + fileSystemName + "\n");
+    	sb.append("\tstudy: " + study.getGlobalId() + "\n");
+    	sb.append("\tfile: " + file.getAbsolutePath() + "\n");
+    	sb.append("-----------------------------------------\n\n");
+    	
+    	dbgLog.log(Level.INFO, sb.toString());
+    	
         dbgLog.fine("***** within StudyFileEditBean: constructor: start *****");
         dbgLog.fine("reached before studyFile constructor");
 
--- a/DVN-web/src/main/java/edu/harvard/iq/dvn/core/study/StudyFileServiceBean.java	Tue Mar 10 15:47:07 2015 +0100
+++ b/DVN-web/src/main/java/edu/harvard/iq/dvn/core/study/StudyFileServiceBean.java	Thu May 07 14:56:46 2015 +0200
@@ -31,6 +31,7 @@
 import edu.harvard.iq.dvn.core.web.util.MD5Checksum;
 import edu.harvard.iq.dvn.ingest.dsb.DSBIngestMessage;
 import edu.harvard.iq.dvn.ingest.dsb.DSBWrapper;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileInputStream;
@@ -41,7 +42,9 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.annotation.Resource;
 import javax.ejb.EJB;
 import javax.ejb.EJBException;
@@ -58,7 +61,9 @@
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 import javax.persistence.Query;
+
 import org.apache.commons.io.FileUtils;
+
 import java.util.zip.*;
 
 /**
@@ -370,6 +375,7 @@
         List otherFiles = new ArrayList();
 
         Iterator iter = newFiles.iterator();
+        StringBuilder sb = new StringBuilder("\n ******************************* step 1: divide the files, based on subsettable or not\n");
         while (iter.hasNext()) {
             StudyFileEditBean fileBean = (StudyFileEditBean) iter.next();
             // Note that for the "special" OtherFiles we want to utilize the 
@@ -378,14 +384,17 @@
             // - L.A.
             if (fileBean.getStudyFile().isSubsettable() || fileBean.getStudyFile() instanceof SpecialOtherFile) {
                 subsettableFiles.add(fileBean);
+                sb.append("\tsubsettableFiles.add(fileBean): " + fileBean.getOriginalFileName() + "\n");
             } else {
                 otherFiles.add(fileBean);
                 // also add to study, so that it will be flushed for the ids
                 fileBean.getStudyFile().setStudy(study);
                 study.getStudyFiles().add(fileBean.getStudyFile());
+                sb.append("\totherFiles.add(fileBean): " + fileBean.getOriginalFileName() + "\n");
 
             }
         }
+        logger.log(Level.INFO, sb.toString());
 
         if (otherFiles.size()>0) {
              // Only persist the studyVersion we are adding a file that doesn't need to be ingested (non-subsettable)
@@ -404,6 +413,7 @@
         }
 
         // step 2: iterate through nonsubsettable files, moving from temp to new location
+        sb = new StringBuilder("\n ******************************* step 2: iterate through nonsubsettable files, moving from temp to new location *******************************/m");
         File newDir = FileUtil.getStudyFileDir(study);
         iter = otherFiles.iterator();
         while (iter.hasNext()) {
@@ -420,14 +430,19 @@
 
                 em.persist(fileBean.getStudyFile());
                 em.persist(fileBean.getFileMetadata());
-
+                sb.append("\t##### em.persist OK\n");
+                sb.append("\ttempFile: " + tempFile.getAbsolutePath() + "\n");
+                sb.append("\tnewLocationFile: " + newLocationFile.getAbsolutePath() + "\n");
+                
             } catch (IOException ex) {
                 throw new EJBException(ex);
             }
             f.setMd5(md5Checksum.CalculateMD5(f.getFileSystemLocation()));
         }
+        logger.log(Level.INFO, sb.toString());
 
         // step 3: iterate through subsettable files, sending a message via JMS
+        logger.log(Level.INFO, "\n step 3: iterate through subsettable files, sending a message via JMS \n");
         if (subsettableFiles.size() > 0) {
             QueueConnection conn = null;
             QueueSession session = null;
@@ -489,7 +504,7 @@
 
         if (!otherFiles.isEmpty()) {
             studyService.saveStudyVersion(studyVersion, user.getId());
-           
+            logger.log(Level.INFO, "\n ******************************* saveStudyVersion OK!!! \n\n\n ----------------------------------------------------------------------------------------------------");
         }
 
        
@@ -646,7 +661,7 @@
                         } else if (fileBean.getControlCardType().equals("ddi")) {
                             f.setOriginalFileType("application/x-dvn-tabddi-zip");
                         } else {
-                            logger.info("WARNING: unknown control card-based Ingest type? -- "+fileBean.getControlCardType());
+                            logger.log(Level.INFO, "WARNING: unknown control card-based Ingest type? -- "+fileBean.getControlCardType());
                             f.setOriginalFileType(originalFileType);
                         }
                         f.setMd5(md5Checksum.CalculateMD5(tempOriginalFile.getAbsolutePath()));
--- a/DVN-web/src/main/webapp/WEB-INF/web.xml	Tue Mar 10 15:47:07 2015 +0100
+++ b/DVN-web/src/main/webapp/WEB-INF/web.xml	Thu May 07 14:56:46 2015 +0200
@@ -540,5 +540,16 @@
    	<servlet>
        <servlet-name>de.mpiwg.monographs.servlet.GetAllUsers</servlet-name>
        <servlet-class>de.mpiwg.monographs.servlet.GetAllUsers</servlet-class>
-	</servlet>	
+	</servlet>
+	
+	<!-- GetStudies -->
+	<servlet-mapping>
+        <servlet-name>de.mpiwg.monographs.servlet.GetStudies</servlet-name>
+        <url-pattern>/getStudies</url-pattern>
+    </servlet-mapping>
+   	<servlet>
+       <servlet-name>de.mpiwg.monographs.servlet.GetStudies</servlet-name>
+       <servlet-class>de.mpiwg.monographs.servlet.GetStudies</servlet-class>
+	</servlet>
+		
 </web-app>