This commit is contained in:
Francesco Mangiacrapa 2013-02-14 14:06:34 +00:00
parent 07a4935ca7
commit f5b92be19f
8 changed files with 122 additions and 29 deletions

View File

@ -151,6 +151,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
}
public GWTWorkspaceServiceAsync getRpcWorkspaceService() {
return rpcWorkspaceService;
}
@ -203,6 +204,23 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void onCreateSharedFolder(CreateSharedFolderEvent createSharedFolderEvent) {
rpcWorkspaceService.readFromApplicationProfile("aaa", "bbb", new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(Void result) {
// TODO Auto-generated method stub
}
});
final FileModel sourceFileModel = createSharedFolderEvent.getFileSourceModel();

View File

@ -111,6 +111,8 @@ public interface GWTWorkspaceService extends RemoteService{
public boolean unSharedFolderByFolderSharedId(String folderSharedId) throws Exception;
public List<FileModel> getListParentsByItemIdentifier(String itemIdentifier) throws Exception;
void readFromApplicationProfile(String name, String value) throws Exception;
// public ArrayList<List<FileModel>> getChildrenListsByParentsIdentifier(String itemIdentifier) throws Exception;

View File

@ -116,6 +116,9 @@ public interface GWTWorkspaceServiceAsync {
void getListParentsByItemIdentifier(String itemIdentifier,
AsyncCallback<List<FileModel>> callback);
void readFromApplicationProfile(String name, String value,
AsyncCallback<Void> callback);
// void getListParentsByItemIdentifier(String itemIdentifier,AsyncCallback<ArrayList<String>> callback);

View File

@ -1432,18 +1432,9 @@ public class GWTWorkspaceBuilder {
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
for(User user: listUsers){
listContactsModel.add(new InfoContactModel(user.getId(), user.getPortalLogin(), user.getPortalLogin()));
}
// //THIS IS A TEST
// listContactsModel.add(new InfoContactModel("Federico.Test", "Federico.Test", "Federico de Faveri"));
// listContactsModel.add(new InfoContactModel("Antonio.Test", "Antonio.Test", "Antonio Gioia"));
// listContactsModel.add(new InfoContactModel("Fabio.Test", "Fabio.Test", "Fabio Sinibaldi"));
// listContactsModel.add(new InfoContactModel(Util.TEST_USER, Util.TEST_USER, Util.TEST_USER));
// listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante"));
return listContactsModel;
}

View File

@ -1,14 +1,19 @@
package org.gcube.portlets.user.workspace.server;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletContext;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.applicationsupportlayer.social.SocialPortalBridge;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
@ -74,8 +79,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
return Util.getNotificationProducer(Util.getAslSession(this.getThreadLocalRequest().getSession()));
}
protected String getUserId(){
return Util.getUserId(this.getThreadLocalRequest().getSession());
protected boolean isTestMode(){
return Util.isTestMode(Util.getAslSession(this.getThreadLocalRequest().getSession()));
}
@Override
@ -747,6 +752,52 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
}
@Override
public void readFromApplicationProfile(String name, String value) throws Exception {
try{
ASLSession session = Util.getAslSession(this.getThreadLocalRequest().getSession());
Properties prop = new Properties();
try {
ServletContext servletContext = getServletContext();
System.out.println("context-path: "+servletContext.getRealPath(""));
System.out.println("context-path th: "+this.getThreadLocalRequest().getContextPath());
System.out.println("context-path cp: "+this.getServletContext().getContextPath());
// load a properties file from class path, inside static method
prop.load(servletContext.getResourceAsStream("portletClassName.properties"));
// get the property value and print it out
System.out.println(prop.getProperty("idreport"));
System.out.println(prop.getProperty("idtemplate"));
} catch (IOException ex) {
ex.printStackTrace();
}
// SocialPortalBridge spb = new SocialPortalBridge(session,)
//
// ASLSession session = Util.getAslSession(this.getThreadLocalRequest().getSession());
// session.setAttribute(name, value);
// workspaceLogger.trace("set value in session with name: "+name+", value: "+value);
// workspaceLogger.debug("WS Session Id = " + session.getExternalSessionID());
//// System.out.println("set value in session with name: "+name+", value: "+value);
} catch (Exception e) {
workspaceLogger.error("setValueInSession", e);
throw new Exception(e.getMessage());
}
}
@Override
public void setValueInSession(String name, String value) throws Exception {
@ -803,20 +854,30 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
logger.info("get all contacts");
// WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace
// workspace.getAllScope();
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
if(isTestMode()){
System.out.println("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS");
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
// //TEST USERS
listContactsModel.add(new InfoContactModel("Federico.Test", "Federico.Test", "Federico de Faveri"));
listContactsModel.add(new InfoContactModel("Antonio.Test", "Antonio.Test", "Antonio Gioia"));
listContactsModel.add(new InfoContactModel("Fabio.Test", "Fabio.Test", "Fabio Sinibaldi"));
listContactsModel.add(new InfoContactModel(Util.TEST_USER, Util.TEST_USER, Util.TEST_USER));
listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante"));
return listContactsModel;
}
return builder.buildGXTListContactsModel(workspace.getHome().getHomeManager().getUsers()); //TODO passare list items
} catch (Exception e) {
workspaceLogger.error("Error in server get all contacts ", e);
// workspaceLogger.trace("Error in server get all contacts " + e.getMessage());
//GWT can't serialize all exceptions
throw new Exception(e.getMessage());
}
}
@ -1398,10 +1459,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
NotificationsProducer np = getNotificationProducer();
List<InfoContactModel> contacts = getListUserSharedByFolderSharedId(folderSharedId);
// //TODO REMOVE THIS
// contacts = new ArrayList<InfoContactModel>();
// contacts.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
if(isTestMode()){
contacts = new ArrayList<InfoContactModel>();
contacts.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
}
np.notifyFolderUnSharing(contacts, wsFolder);
}

View File

@ -66,13 +66,13 @@ public class NotificationsProducer {
for (InfoContactModel infoContactModel : listContacts) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getId().compareTo(userId)!=0){
// if(infoContactModel.getId().compareTo(userId)!=0){
logger.trace("Send notify folder sharing for user "+infoContactModel.getId());
boolean notify = notificationsMng.notifyFolderSharing(infoContactModel.getId(), sharedFolder);
if(!notify)
logger.error("An error occured when notify user: "+infoContactModel.getId());
}
// }
}catch (Exception e) {
logger.error("An error occured in notifyFolderSharing ", e);
e.printStackTrace();
@ -93,6 +93,7 @@ public class NotificationsProducer {
*/
public void notifyFolderUnSharing(final List<InfoContactModel> listContacts, final WorkspaceFolder sharedFolder) {
new Thread() {
@Override
public void run() {
@ -103,7 +104,7 @@ public class NotificationsProducer {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getId().compareTo(userId)!=0){
// if(infoContactModel.getId().compareTo(userId)!=0){
logger.trace("Send notify folder un share user "+infoContactModel.getId());
System.out.println("Send notify folder un share user "+infoContactModel.getId());
@ -112,7 +113,7 @@ public class NotificationsProducer {
if(!notify)
logger.error("An error occured when notify user: "+infoContactModel.getId());
}
// }
}catch (Exception e) {
logger.error("An error occured in notifyFolderSharing ", e);
e.printStackTrace();

View File

@ -0,0 +1,2 @@
idtemplate=template
idreport=report

View File

@ -33,6 +33,7 @@ public class Util {
public static final String WORKSPACEBUILDER_ATTRIBUTE = "WORKSPACEBUILDER";
public static final String NOTIFICATION_MANAGER = "NOTIFICATIONMANAGER";
public static final String NOTIFICATION_PRODUCER = "NOTIFICATIONMANAGER";
public static final String WS_RUN_IN_TEST_MODE = "WS_RUN_IN_TEST_MODE";
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.wsmail.server.WsMailServiceImpl"; //IN DEV
@ -57,18 +58,31 @@ public class Util {
if (user == null) {
defaultLogger.error("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND");
System.out.println("http session id "+sessionID);
//for test only
httpSession.setAttribute(USERNAME_ATTRIBUTE, TEST_USER);
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, TEST_USER);
session.setScope(TEST_SCOPE);
session.setUserAvatarId(TEST_USER + "Avatar");
session.setUserFullName(TEST_USER_FULL_NAME);
session.setAttribute(WS_RUN_IN_TEST_MODE, true);
return session;
}
return SessionManager.getInstance().getASLSession(sessionID, user);
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user);
session.setAttribute(WS_RUN_IN_TEST_MODE, false);
return session;
}
public static boolean isTestMode(ASLSession session){
Boolean test = (Boolean) session.getAttribute(WS_RUN_IN_TEST_MODE);
if(test == null || test==true)
return true;
return false;
}
public static Workspace getWorkspace(final HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException