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")
|
||||
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 = "<EndPoint><Scope>"+vreScope+"</Scope><URL>"+vreURL+"</URL></EndPoint>";
|
||||
|
||||
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<GenericResource> 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 <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;
|
||||
}
|
||||
|
||||
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;
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue