diff --git a/pom.xml b/pom.xml
index acc5951..3873d42 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,6 +70,17 @@
aslvre
[5.0.0-SNAPSHOT, 6.0.0-SNAPSHOT)
+
+ org.gcube.applicationsupportlayer
+ aslsocial
+ provided
+
+
+ org.gcube.common
+ home-library
+ [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)
+ provided
+
org.gcube.portlets.user
gcube-widgets
diff --git a/src/main/java/org/gcube/portlets/admin/vredefinition/server/VREDefinitionServiceImpl.java b/src/main/java/org/gcube/portlets/admin/vredefinition/server/VREDefinitionServiceImpl.java
index 7df8f8b..dfeb824 100644
--- a/src/main/java/org/gcube/portlets/admin/vredefinition/server/VREDefinitionServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/admin/vredefinition/server/VREDefinitionServiceImpl.java
@@ -15,6 +15,13 @@ import org.gcube.application.framework.accesslogger.library.impl.AccessLogger;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.application.framework.vremanagement.vremanagement.impl.VREGeneratorEvo;
+import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
+import org.gcube.applicationsupportlayer.social.NotificationsManager;
+import org.gcube.common.homelibrary.home.HomeLibrary;
+import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
+import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
+import org.gcube.common.homelibrary.home.workspace.Workspace;
+import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.admin.vredefinition.client.VREDefinitionService;
import org.gcube.portlets.admin.vredefinition.client.model.VREFunctionalityModel;
@@ -45,7 +52,7 @@ public class VREDefinitionServiceImpl extends RemoteServiceServlet implements VR
private static final long serialVersionUID = -7565518362225100485L;
private static final Logger _log = LoggerFactory.getLogger(VREDefinitionServiceImpl.class);
-
+
private static final String DESIGNER = "Designer";
private static final String MANAGER = "Manager";
private static final String DESCRIPTION = "DESCRIPTION";
@@ -134,7 +141,7 @@ public class VREDefinitionServiceImpl extends RemoteServiceServlet implements VR
}
-
+
public Map isEditMode() {
System.out.println("\n\n\n********************* isEditMode()");
String reeditType = (String) getASLSession().getAttribute(REEDIT_TYPE_ATTRIBUTE);
@@ -142,14 +149,14 @@ public class VREDefinitionServiceImpl extends RemoteServiceServlet implements VR
session.setAttribute(VRE_DEFINER_GENERATOR_ATTRIBUTE, null);
if(reeditType != null && reeditType.equals(EDIT_MODE)) {
-
+
String vreid = (String) session.getAttribute(VRE_GENERATOR_ATTRIBUTE);
if(vreid==null){
session.setAttribute(VRE_DEFINER_GENERATOR_ATTRIBUTE, null);
} else {
VREGeneratorEvo vreGenerator = new VREGeneratorEvo(session, vreid);
session.setAttribute(VRE_DEFINER_GENERATOR_ATTRIBUTE, vreGenerator);
-
+
}
session.setAttribute(REEDIT_TYPE_ATTRIBUTE, null);
@@ -257,7 +264,7 @@ public class VREDefinitionServiceImpl extends RemoteServiceServlet implements VR
return toReturn;
}
-
+
public Map getVRE() throws VREDefinitionException {
HashMap toReturn = new HashMap();
@@ -314,11 +321,11 @@ public class VREDefinitionServiceImpl extends RemoteServiceServlet implements VR
}
try {
-
- String fullName = um.getUserByScreenName(username).getFullname();
- toReturn.put("Designer", fullName+" ("+username+")");
-
+ String fullName = um.getUserByScreenName(username).getFullname();
+ toReturn.put("Designer", fullName+" ("+username+")");
+
+
VREDescriptionBean vre = getVREInSession();
if(vre!= null) {
toReturn.put("vreName",vre.getName());
@@ -364,30 +371,42 @@ public class VREDefinitionServiceImpl extends RemoteServiceServlet implements VR
}
return ret;
}
-
+
private String extractUserName(String toExtract) {
int openBracket = toExtract.indexOf("(")+1;
int closeBracket = toExtract.indexOf(")");
return toExtract.substring(openBracket, closeBracket);
}
+
public String setVRE(VREDescriptionBean bean, String[] functionalityIDs, HashMap> funcToExternalResources)
throws VREDefinitionException {
+ String completeDesigner = bean.getDesigner();
bean.setDesigner(extractUserName(bean.getDesigner()));
- bean.setManager(extractUserName(bean.getManager()));
-
+ String managerUserName = extractUserName(bean.getManager());
+ bean.setManager(managerUserName);
+
setVREDescription(bean);
setFunctionality(functionalityIDs, funcToExternalResources);
try {
getVREGenerator().setVREtoPendingState();
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
+
+ getASLSession().setAttribute(VRE_DEFINER_GENERATOR_ATTRIBUTE, null);
+ Workspace workspace = HomeLibrary.getUserWorkspace(getASLSession().getUsername());
+ ArrayList toSend = new ArrayList();
+ toSend.add(managerUserName);
+ String subject = "New VRE Definition requires your approval";
+ String body = "Dear Manager, \n\n" + completeDesigner + " has created a VRE Definition indicating you as VRE Manager on " + getASLSession().getScope();
+ body+=".\n\nThe VRE Name is: " + bean.getName() +", the VRE Description is: " + bean.getDescription()+".";
+ workspace.getWorkspaceMessageManager().sendMessageToPortalLogins(subject, body, new ArrayList(), toSend);
+ NotificationsManager nnm = new ApplicationNotificationsManager(getASLSession());
+ if (nnm.notifyMessageReceived(managerUserName, subject))
+ _log.trace("Sending VRE Definition create notification: " + subject + " OK");
+
+ } catch (Exception e) {
e.printStackTrace();
}
-
- getASLSession().setAttribute(VRE_DEFINER_GENERATOR_ATTRIBUTE, null);
-
AccessLogger log = AccessLogger.getAccessLogger();
CreatedVRELogEntry logEntry = new CreatedVRELogEntry(bean.getName(), "unknown", bean.getDesigner(), bean.getManager());
log.logEntry(getASLSession().getUsername(), getASLSession().getScopeName(), logEntry);