diff --git a/pom.xml b/pom.xml
index 3aeab00..dc3b4fb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,7 @@
gwt-user
provided
+
com.sencha.gxt
gxt
@@ -117,17 +118,23 @@
provided
+
+ org.gcube.applicationsupportlayer
+ accesslogger
+ provided
+
+
-
-
-
-
-
+
+
+
+
+
diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java
index 9530d6d..aece6b3 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java
@@ -1,13 +1,19 @@
package org.gcube.portlets.user.workspace.server;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
+import java.util.Properties;
import java.util.concurrent.TimeUnit;
+import javax.servlet.ServletContext;
+
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.homelibrary.home.Home;
@@ -130,7 +136,19 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
protected PropertySpecialFolderReader getPropertySpecialFolderReader() {
- return WsUtil.getPropertySpecialFolderReader(this.getThreadLocalRequest().getSession());
+ String absolutePathProperty = getSpecialFolderPath();
+ return WsUtil.getPropertySpecialFolderReader(this.getThreadLocalRequest().getSession(),absolutePathProperty);
+ }
+
+ /**
+ *
+ * @param type the type to look for
+ * @return the Category if there is correspodance, null otherwise
+ */
+ private String getSpecialFolderPath() {
+ ServletContext servletContext = getServletContext();
+ String contextPath = servletContext.getRealPath(File.separator);
+ return contextPath + File.separator +"conf" + File.separator + ConstantsExplorer.SPECIALFOLDERNAMEPROPERTIESFILE;
}
@@ -308,6 +326,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
return sfReader.getSpecialFolderName();
}
+
@Override
public List getFolderChildrenForFileGrid(FileModel folder) throws Exception, SessionExpiredException {
diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java
index 07bbeb0..65d26f9 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java
@@ -3,6 +3,8 @@
*/
package org.gcube.portlets.user.workspace.server.util;
+import java.io.FileInputStream;
+
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
@@ -23,6 +25,7 @@ import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameter;
import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
+import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
@@ -45,6 +48,7 @@ public class WsUtil {
public static final String WORKSPACE_SCOPE_UTIL = "WORKSPACE_SCOPE_UTIL";
public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
public static final String URI_RESOLVER_SERVICE = "URI_RESOLVER_SERVICE";
+ public static final String PROPERTY_SPECIAL_FOLDER = "PROPERTY_SPECIAL_FOLDER";
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //IN DEV
// public static final String TEST_SCOPE = "/gcube/devsec";
@@ -353,10 +357,33 @@ public class WsUtil {
}
}catch (Exception e) {
- logger.error("an error occurred in instancing uri resolver ",e);
+ logger.error("an error occurred instancing URI Resolver ",e);
}
return uriResolver;
}
+ /**
+ * @param session
+ * @return
+ */
+ public static PropertySpecialFolderReader getPropertySpecialFolderReader(HttpSession httpSession, String pathProperty) {
+ ASLSession session = getAslSession(httpSession);
+
+ PropertySpecialFolderReader psFolderReader = null;
+ try{
+ psFolderReader = (PropertySpecialFolderReader) session.getAttribute(WsUtil.PROPERTY_SPECIAL_FOLDER);
+
+ if(psFolderReader==null){
+ psFolderReader = new PropertySpecialFolderReader(pathProperty);
+ session.setAttribute(PROPERTY_SPECIAL_FOLDER, psFolderReader);
+ }
+
+ }catch (Exception e) {
+ logger.error("an error occurred instancing PropertySpecialFolderReader ",e);
+ }
+
+ return psFolderReader;
+ }
+
}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/resource/PropertySpecialFolderReader.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/resource/PropertySpecialFolderReader.java
index e257fdc..14f0427 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/server/util/resource/PropertySpecialFolderReader.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/resource/PropertySpecialFolderReader.java
@@ -5,8 +5,6 @@ package org.gcube.portlets.user.workspace.server.util.resource;
import java.io.File;
import java.io.FileInputStream;
-import java.io.InputStream;
-import java.net.URL;
import java.util.Properties;
import org.apache.log4j.Logger;
@@ -23,29 +21,31 @@ public class PropertySpecialFolderReader {
protected static Logger logger = Logger.getLogger(PropertySpecialFolderReader.class);
protected String specialFolderName = "";
- public PropertySpecialFolderReader() throws PropertyFileReadingErrorException {
+ public PropertySpecialFolderReader(String absolutePath) throws PropertyFileReadingErrorException {
try{
- logger.info("Instancing new PropertySpecialFolderReader..");
+ logger.info("Instancing new PropertySpecialFolderReader with path: "+absolutePath);
// URL resource = PropertySpecialFolderReader.class.getResource(ConstantsExplorer.SPECIALFOLDERNAMEPROPERTIESFILE);
// File file = new File(resource.toURI());
// FileInputStream input = new FileInputStream(file);
- InputStream input = PropertySpecialFolderReader.class.getResourceAsStream(ConstantsExplorer.SPECIALFOLDERNAMEPROPERTIESFILE);
-
+// InputStream input = PropertySpecialFolderReader.class.getResourceAsStream(ConstantsExplorer.SPECIALFOLDERNAMEPROPERTIESFILE);
+ File propsFile = new File(absolutePath);
+ if(!propsFile.exists()){
+ throw new Exception("File not found in path: "+absolutePath);
+ }
+ FileInputStream fis = new FileInputStream(propsFile);
Properties properties = new Properties();
- properties.load(input);
+ properties.load(fis);
specialFolderName = properties.getProperty(ConstantsExplorer.SPECIALFOLDERNAME);
logger.info("PropertySpecialFolderReader read for key: "+ConstantsExplorer.SPECIALFOLDERNAME + " value: "+specialFolderName);
-
}catch (Exception e) {
logger.error("Error on loading property to read special folder name: ",e);
throw new PropertyFileReadingErrorException("Error on reading property file: "+ConstantsExplorer.SPECIALFOLDERNAMEPROPERTIESFILE);
}
}
-
public String getSpecialFolderName() {
return specialFolderName;
}
@@ -55,15 +55,15 @@ public class PropertySpecialFolderReader {
}
- public static void main(String[] args) {
-
- try {
- new PropertySpecialFolderReader();
-
- } catch (PropertyFileReadingErrorException e) {
- e.printStackTrace();
- }
- }
+// public static void main(String[] args) {
+//
+// try {
+//// new PropertySpecialFolderReader();
+//
+// } catch (PropertyFileReadingErrorException e) {
+// e.printStackTrace();
+// }
+// }
}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/resource/specialfoldername.properties b/src/main/java/org/gcube/portlets/user/workspace/server/util/resource/specialfoldername.properties
deleted file mode 100644
index 205d234..0000000
--- a/src/main/java/org/gcube/portlets/user/workspace/server/util/resource/specialfoldername.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-#Property file - Special Folder Name
-#2014-05-03
-SPECIALFOLDERNAME=myspecialfolder
\ No newline at end of file