diff --git a/src/main/java/org/gcube/portlets/admin/vredeployer/server/VREDeployerServiceImpl.java b/src/main/java/org/gcube/portlets/admin/vredeployer/server/VREDeployerServiceImpl.java
index a4a4a9e..f7a9f11 100644
--- a/src/main/java/org/gcube/portlets/admin/vredeployer/server/VREDeployerServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/admin/vredeployer/server/VREDeployerServiceImpl.java
@@ -139,8 +139,15 @@ import com.liferay.portal.theme.ThemeDisplay;
*/
@SuppressWarnings("serial")
public class VREDeployerServiceImpl extends RemoteServiceServlet implements VredeployerService {
-
+
private static final Logger log = LoggerFactory.getLogger(VREDeployerServiceImpl.class);
+
+ /**
+ * during the vre phase creation we need to update the Application Profile of Calendar and News feed
+ */
+ private static final String CALENDAR_APPID = "org.gcube.portal.calendarwrapper.GCubeCalendarHandler";
+ private static final String NEWS_FEED_APPID = "org.gcube.portlets.user.newsfeed.server.NewsServiceImpl";
+
protected static final String ORGANIZATION_DEFAULT_LOGO = "/org/gcube/portal/custom/communitymanager/resources/default_logo.png";
protected static final String ORGANIZATION_DEFAULT_LOGO_URL = "http://ftp.d4science.org/apps/profiles/d4slogo.png";
@@ -725,8 +732,9 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
log.info("--- CREATED LAYOUTS AND COMMUNITY OK, updating Calendar Application Profile.");
String vreScope = getScopeByOrganizationId(""+vreCreated.getOrganizationId());
- String vreUrl = "/group/"+vreCreated.getName().toLowerCase()+"/calendar";
- updateCalendarApplicationProfile(vreScope, vreUrl);
+ String vreUrl = "/group/"+vreCreated.getName().toLowerCase();
+ updateApplicationProfile(CALENDAR_APPID, vreScope, vreUrl+"/calendar");
+ updateApplicationProfile(NEWS_FEED_APPID, vreScope, vreUrl); //assumes it is deployed in the home of the VRE
log.info("--- creating VRE Group Folder");
createVRESharedGroupFolder(vreCreated, designer, manager, description);
@@ -773,17 +781,18 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
return convertServiceDeployReport(report);
}
/**
- * update the ApplicationProfile of the calendar for this scope
- * @param vreScope
- * @param vreURL
+ * update the ApplicationProfile of the appid for this scope
+ * @param appId the portlet class name as indicated in the generic resource published at root level
+ * @param vreScope the scope to add
+ * @param vreURL the absolute URL of the portlet
*/
- private void updateCalendarApplicationProfile(String vreScope, String vreURL) {
- String appId = "org.gcube.portal.calendarwrapper.GCubeCalendarHandler";
+ private void updateApplicationProfile(String appId, String vreScope, String vreURL) {
String currScope = ScopeProvider.instance.get();
String scopeToQuery = PortalContext.getConfiguration().getInfrastructureName();
ScopeProvider.instance.set("/"+scopeToQuery);
+ String endpoint2Add = ""+vreScope+""+vreURL+"";
SimpleQuery query = queryFor(GenericResource.class);
query.addCondition("$resource/Profile/SecondaryType/text() eq 'ApplicationProfile'");
@@ -793,19 +802,27 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
//
List list = client.submit(query);
if (list == null || list.isEmpty()) {
- log.error("Cannot retrieve the IS profile for resource: ");
+ log.warn("Cannot retrieve the ApplicationProfile from IS for generic resource havin = " + appId);
+ log.info("Triggering Creation of ApplicationProfile for " + appId);
+ GenericResource toCreate = new GenericResource();
+ toCreate.newProfile().name("Application Profile for " + appId);
+ toCreate.profile().type("ApplicationProfile");
+ toCreate.profile().description("Application Profile description for " + appId);
+ toCreate.profile().newBody(""+appId+"No thumbnail"+endpoint2Add);
+ RegistryPublisher rp=RegistryPublisherFactory.create();
+ rp.create(toCreate);
+ log.info("Creation of ApplicationProfile for " + appId + " OK!");
return;
}
+
GenericResource gr = list.get(0);
- log.debug("updating " + gr.profile().name());
+ log.debug("updating ApplicationProfile for " + gr.profile().name());
- String endpoint = ""+vreScope+""+vreURL+"";
Node fragmentNode;
try {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Element elem = gr.profile().body();
- System.out.println("QUI ");
- fragmentNode = docBuilder.parse(new InputSource(new StringReader(endpoint))).getDocumentElement();
+ fragmentNode = docBuilder.parse(new InputSource(new StringReader(endpoint2Add))).getDocumentElement();
fragmentNode = elem.getOwnerDocument().importNode(fragmentNode, true);
elem.appendChild(fragmentNode);
} catch (Exception e) {