added handler for special folder name

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@92708 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-03-05 17:28:49 +00:00
parent 59c0b2af0a
commit 493beb0ab1
5 changed files with 78 additions and 28 deletions

17
pom.xml
View File

@ -60,6 +60,7 @@
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sencha.gxt</groupId>
<artifactId>gxt</artifactId>
@ -117,17 +118,23 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>accesslogger</artifactId>
<scope>provided</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.apache.directory.studio</groupId> -->
<!-- <artifactId>org.apache.commons.io</artifactId> -->
<!-- <version>2.1</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>commons-io</groupId> -->
<!-- <artifactId>commons-io</artifactId> -->
<!-- <version>2.4</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>commons-io</groupId> -->
<!-- <artifactId>commons-io</artifactId> -->
<!-- <version>2.4</version> -->
<!-- </dependency> -->
<!-- HOME LIBRARY -->
<dependency>

View File

@ -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<FileGridModel> getFolderChildrenForFileGrid(FileModel folder) throws Exception, SessionExpiredException {

View File

@ -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;
}
}

View File

@ -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();
// }
// }
}

View File

@ -1,3 +0,0 @@
#Property file - Special Folder Name
#2014-05-03
SPECIALFOLDERNAME=myspecialfolder