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;
@ -371,23 +378,35 @@ public class VREDefinitionServiceImpl extends RemoteServiceServlet implements VR
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
e.printStackTrace();
}
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();
}
AccessLogger log = AccessLogger.getAccessLogger();
CreatedVRELogEntry logEntry = new CreatedVRELogEntry(bean.getName(), "unknown", bean.getDesigner(), bean.getManager());
log.logEntry(getASLSession().getUsername(), getASLSession().getScopeName(), logEntry);