added editing of ApplicationProfile of News Feed too
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/vre-deploy@92700 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
20259dfc81
commit
4d29d36713
|
@ -139,8 +139,15 @@ import com.liferay.portal.theme.ThemeDisplay;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class VREDeployerServiceImpl extends RemoteServiceServlet implements VredeployerService {
|
public class VREDeployerServiceImpl extends RemoteServiceServlet implements VredeployerService {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(VREDeployerServiceImpl.class);
|
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 = "/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";
|
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.");
|
log.info("--- CREATED LAYOUTS AND COMMUNITY OK, updating Calendar Application Profile.");
|
||||||
String vreScope = getScopeByOrganizationId(""+vreCreated.getOrganizationId());
|
String vreScope = getScopeByOrganizationId(""+vreCreated.getOrganizationId());
|
||||||
String vreUrl = "/group/"+vreCreated.getName().toLowerCase()+"/calendar";
|
String vreUrl = "/group/"+vreCreated.getName().toLowerCase();
|
||||||
updateCalendarApplicationProfile(vreScope, vreUrl);
|
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");
|
log.info("--- creating VRE Group Folder");
|
||||||
createVRESharedGroupFolder(vreCreated, designer, manager, description);
|
createVRESharedGroupFolder(vreCreated, designer, manager, description);
|
||||||
|
@ -773,17 +781,18 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
return convertServiceDeployReport(report);
|
return convertServiceDeployReport(report);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* update the ApplicationProfile of the calendar for this scope
|
* update the ApplicationProfile of the appid for this scope
|
||||||
* @param vreScope
|
* @param appId the portlet class name as indicated in the generic resource published at root level
|
||||||
* @param vreURL
|
* @param vreScope the scope to add
|
||||||
|
* @param vreURL the absolute URL of the portlet
|
||||||
*/
|
*/
|
||||||
private void updateCalendarApplicationProfile(String vreScope, String vreURL) {
|
private void updateApplicationProfile(String appId, String vreScope, String vreURL) {
|
||||||
String appId = "org.gcube.portal.calendarwrapper.GCubeCalendarHandler";
|
|
||||||
|
|
||||||
String currScope = ScopeProvider.instance.get();
|
String currScope = ScopeProvider.instance.get();
|
||||||
String scopeToQuery = PortalContext.getConfiguration().getInfrastructureName();
|
String scopeToQuery = PortalContext.getConfiguration().getInfrastructureName();
|
||||||
ScopeProvider.instance.set("/"+scopeToQuery);
|
ScopeProvider.instance.set("/"+scopeToQuery);
|
||||||
|
|
||||||
|
String endpoint2Add = "<EndPoint><Scope>"+vreScope+"</Scope><URL>"+vreURL+"</URL></EndPoint>";
|
||||||
|
|
||||||
SimpleQuery query = queryFor(GenericResource.class);
|
SimpleQuery query = queryFor(GenericResource.class);
|
||||||
query.addCondition("$resource/Profile/SecondaryType/text() eq 'ApplicationProfile'");
|
query.addCondition("$resource/Profile/SecondaryType/text() eq 'ApplicationProfile'");
|
||||||
|
@ -793,19 +802,27 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
||||||
//
|
//
|
||||||
List<GenericResource> list = client.submit(query);
|
List<GenericResource> list = client.submit(query);
|
||||||
if (list == null || list.isEmpty()) {
|
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 <Body><AppId> = " + 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>"+appId+"</AppId><ThumbnailURL>No thumbnail</ThumbnailURL>"+endpoint2Add);
|
||||||
|
RegistryPublisher rp=RegistryPublisherFactory.create();
|
||||||
|
rp.create(toCreate);
|
||||||
|
log.info("Creation of ApplicationProfile for " + appId + " OK!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericResource gr = list.get(0);
|
GenericResource gr = list.get(0);
|
||||||
log.debug("updating " + gr.profile().name());
|
log.debug("updating ApplicationProfile for " + gr.profile().name());
|
||||||
|
|
||||||
String endpoint = "<EndPoint><Scope>"+vreScope+"</Scope><URL>"+vreURL+"</URL></EndPoint>";
|
|
||||||
Node fragmentNode;
|
Node fragmentNode;
|
||||||
try {
|
try {
|
||||||
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
Element elem = gr.profile().body();
|
Element elem = gr.profile().body();
|
||||||
System.out.println("QUI ");
|
fragmentNode = docBuilder.parse(new InputSource(new StringReader(endpoint2Add))).getDocumentElement();
|
||||||
fragmentNode = docBuilder.parse(new InputSource(new StringReader(endpoint))).getDocumentElement();
|
|
||||||
fragmentNode = elem.getOwnerDocument().importNode(fragmentNode, true);
|
fragmentNode = elem.getOwnerDocument().importNode(fragmentNode, true);
|
||||||
elem.appendChild(fragmentNode);
|
elem.appendChild(fragmentNode);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in New Issue