should be ok

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/vre-deploy@82502 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-10-04 16:40:33 +00:00
parent 461dd3ed59
commit bdc3e6274f
2 changed files with 60 additions and 19 deletions

12
pom.xml
View File

@ -69,6 +69,17 @@
<artifactId>aslvre</artifactId> <artifactId>aslvre</artifactId>
<version>[5.0.0-SNAPSHOT, 6.0.0-SNAPSHOT)</version> <version>[5.0.0-SNAPSHOT, 6.0.0-SNAPSHOT)</version>
</dependency> </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> <dependency>
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId> <artifactId>gcube-widgets</artifactId>
@ -83,6 +94,7 @@
<groupId>org.gcube.core</groupId> <groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId> <artifactId>common-scope-maps</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.vremanagement</groupId> <groupId>org.gcube.vremanagement</groupId>

View File

@ -29,6 +29,10 @@ import javax.xml.transform.stream.StreamSource;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager; import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.application.framework.vremanagement.vremanagement.impl.VREGeneratorEvo; 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.workspace.Workspace;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil; import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portal.custom.communitymanager.PortletsIdManager; import org.gcube.portal.custom.communitymanager.PortletsIdManager;
import org.gcube.portal.custom.communitymanager.ThemesIdManager; import org.gcube.portal.custom.communitymanager.ThemesIdManager;
@ -163,7 +167,7 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
*/ */
private ASLSession getASLSession() { private ASLSession getASLSession() {
log.info("getVREGeneratorEvo getASLSession() : "); log.info("getVREGeneratorEvo getASLSession() : ");
HttpSession session = this.getThreadLocalRequest().getSession(); HttpSession session = this.getThreadLocalRequest().getSession();
String username = (String) session.getAttribute(ScopeHelper.USERNAME_ATTRIBUTE); String username = (String) session.getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
if (username == null) { if (username == null) {
username = "massimiliano.assante"; username = "massimiliano.assante";
@ -616,18 +620,18 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
// AccessLogger log = AccessLogger.getAccessLogger(); // AccessLogger log = AccessLogger.getAccessLogger();
// CreatedVRELogEntry logEntry; // CreatedVRELogEntry logEntry;
// try { // try {
// logEntry = new CreatedVRELogEntry( // logEntry = new CreatedVRELogEntry(
// vreGenerator.getVREModel().name(), // vreGenerator.getVREModel().name(),
// vreGenerator.getVREepr(), // vreGenerator.getVREepr(),
// vreGenerator.getVREModel().designer(), // vreGenerator.getVREModel().designer(),
// vreGenerator.getVREModel().manager()); // vreGenerator.getVREModel().manager());
// log.logEntry(getASLSession().getUsername(), getASLSession().getScopeName(), logEntry); // log.logEntry(getASLSession().getUsername(), getASLSession().getScopeName(), logEntry);
// } catch (RemoteException e) { // } catch (RemoteException e) {
// e.printStackTrace(); // e.printStackTrace();
// } // }
return true; return true;
} }
@ -670,15 +674,38 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
} }
if (report.getStatus() == Status.Finished) { if (report.getStatus() == Status.Finished) {
System.out.println("--- Create VRE COMPLETED, CREATING LAYOUTS AND COMMUNITY ... "); log.info("--- Create VRE COMPLETED, CREATING LAYOUTS AND COMMUNITY ... ");
String name = ""; String name = "";
try { try {
name = vreGenerator.getVREModel().name(); name = vreGenerator.getVREModel().name();
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
} }
createCommunityAndLayout(name); if (createCommunityAndLayout(name)) {
System.out.println("--- CREATed LAYOUTS AND COMMUNITY ---"); log.info("--- CREATED LAYOUTS AND COMMUNITY --- OK, sending Message to designer.");
try {
String designer = (String) getASLSession().getAttribute(DESIGNER);
String manager = (String) getASLSession().getAttribute(MANAGER);
UserManager um = new LiferayUserManager();
UserModel userDesigner = um.getUserByScreenName(designer);
UserModel userManager = um.getUserByScreenName(manager);
Workspace workspace = HomeLibrary.getUserWorkspace(getASLSession().getUsername());
ArrayList<String> toSend = new ArrayList<String>();
toSend.add(designer);
String subject = "VRE Definition approved and deployed";
String body = "Dear "+userDesigner.getFirstname()+", \n\n" + userManager.getFullname() + " has approved the deployment of the Virtual Research Environment you requested: " + name +".";
body+=".\n\nThis VRE has been deployed successfully and is already available for you on this portal. Please, check your Virtual Research Environments list.";
workspace.getWorkspaceMessageManager().sendMessageToPortalLogins(subject, body, new ArrayList<String>(), toSend);
NotificationsManager nnm = new ApplicationNotificationsManager(getASLSession());
if (nnm.notifyMessageReceived(designer, subject))
log.trace("Sending VRE Definition create notification: " + subject + " OK");
} catch (Exception e) {
}
} else
log.error("--- DANGER DANGER DANGER!!!!! -> CREATED LAYOUTS AND COMMUNITY WITH ERRORS");
} }
else else
setDeployingStatusOn(); setDeployingStatusOn();
@ -854,11 +881,11 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
/** /**
* Creates the community and its layout in Liferay * Creates the community and its layout in Liferay
*/ */
private void createCommunityAndLayout(String vreName) { private boolean createCommunityAndLayout(String vreName) {
if (vreExists(vreName)) { if (vreExists(vreName)) {
System.out.println("VRE Exists already"); System.out.println("VRE Exists already");
return; return false;
} }
@ -919,7 +946,9 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false;
} }
return true;
} }
/** /**
* Create a Regular Manager Role for the community * Create a Regular Manager Role for the community
@ -1000,7 +1029,7 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
InputSource inputSource = new InputSource(reader); InputSource inputSource = new InputSource(reader);
log.debug("***** --- Reading **** "); log.debug("***** --- Reading **** ");
try { try {
document = builder.parse(inputSource); document = builder.parse(inputSource);