added notification to the manager

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/vre-definition@82478 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-10-04 15:04:01 +00:00
parent fbcf5d3ed6
commit 9b8c6ee117
2 changed files with 47 additions and 17 deletions

11
pom.xml
View File

@ -70,6 +70,17 @@
<artifactId>aslvre</artifactId>
<version>[5.0.0-SNAPSHOT, 6.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId>

View File

@ -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<String,Object> 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<String, Object> getVRE() throws VREDefinitionException {
HashMap<String, Object> toReturn = new HashMap<String,Object>();
@ -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<String, List<ExternalResourceModel>> 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<String> toSend = new ArrayList<String>();
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<String>(), 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);