refactored, moved session instance into superclass
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@62151 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
41c789dfb2
commit
e7e121addd
|
@ -1,23 +1,14 @@
|
||||||
package org.gcube.applicationsupportlayer.social;
|
package org.gcube.applicationsupportlayer.social;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
import org.gcube.common.core.contexts.GHNContext;
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
import org.gcube.common.core.informationsystem.ISException;
|
|
||||||
import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
|
||||||
import org.gcube.common.core.informationsystem.client.ISClient;
|
import org.gcube.common.core.informationsystem.client.ISClient;
|
||||||
import org.gcube.common.core.informationsystem.client.XMLResult;
|
import org.gcube.common.core.informationsystem.client.XMLResult;
|
||||||
import org.gcube.common.core.informationsystem.client.ISClient.ISMalformedQueryException;
|
|
||||||
import org.gcube.common.core.informationsystem.client.ISClient.ISUnsupportedQueryException;
|
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
|
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
|
|
||||||
import org.gcube.common.core.resources.GCUBEGenericResource;
|
|
||||||
import org.gcube.common.core.scope.GCUBEScope;
|
|
||||||
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
|
||||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
||||||
import org.gcube.portal.databook.server.DatabookStore;
|
import org.gcube.portal.databook.server.DatabookStore;
|
||||||
import org.gcube.portal.databook.shared.Application;
|
import org.gcube.portal.databook.shared.Application;
|
||||||
|
@ -35,17 +26,14 @@ import org.gcube.portlets.user.homelibrary.home.data.application.ApplicationData
|
||||||
*/
|
*/
|
||||||
public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
||||||
|
|
||||||
GCUBEClientLog log = new GCUBEClientLog(AslNewsManager.class);
|
|
||||||
|
|
||||||
private ASLSession session;
|
|
||||||
private Application application;
|
private Application application;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param session the ASLSession instance
|
* @param aslSession the ASLSession instance
|
||||||
* @param applicationClass your servlet class name will be used ad unique identifier for your application
|
* @param applicationClass your servlet class name will be used ad unique identifier for your application
|
||||||
*/
|
*/
|
||||||
public AslNewsManager(ASLSession session, Class<?> applicationClass) {
|
public AslNewsManager(ASLSession session, Class<?> applicationClass) {
|
||||||
this.session = session;
|
super(session);
|
||||||
this.application = getProfileFromInfrastrucure(applicationClass);
|
this.application = getProfileFromInfrastrucure(applicationClass);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +53,7 @@ public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
||||||
" eq '" + applicationClass.getName() + "'" +
|
" eq '" + applicationClass.getName() + "'" +
|
||||||
"return $profile");
|
"return $profile");
|
||||||
|
|
||||||
List<XMLResult> appProfile = client.execute(query, session.getScope().getInfrastructure());
|
List<XMLResult> appProfile = client.execute(query, aslSession.getScope().getInfrastructure());
|
||||||
if (appProfile == null || appProfile.size() == 0)
|
if (appProfile == null || appProfile.size() == 0)
|
||||||
throw new ApplicationDataNotFoundException("Your application is not registered in the infrastructure");
|
throw new ApplicationDataNotFoundException("Your application is not registered in the infrastructure");
|
||||||
else {
|
else {
|
||||||
|
@ -81,7 +69,7 @@ public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
||||||
if (currValue != null && currValue.size() > 0) {
|
if (currValue != null && currValue.size() > 0) {
|
||||||
toReturn.setDescription(currValue.get(0));
|
toReturn.setDescription(currValue.get(0));
|
||||||
}
|
}
|
||||||
else log.warn("No Description exists for " + toReturn.getName());
|
else _log.warn("No Description exists for " + toReturn.getName());
|
||||||
|
|
||||||
currValue = node.evaluate("/Resource/Profile/Body/AppId/text()");
|
currValue = node.evaluate("/Resource/Profile/Body/AppId/text()");
|
||||||
if (currValue != null && currValue.size() > 0) {
|
if (currValue != null && currValue.size() > 0) {
|
||||||
|
@ -98,7 +86,7 @@ public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error while trying to fetch application profile from the infrastructure");
|
_log.error("Error while trying to fetch application profile from the infrastructure");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +104,7 @@ public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
||||||
FeedType.PUBLISH,
|
FeedType.PUBLISH,
|
||||||
application.getName(),
|
application.getName(),
|
||||||
new Date(),
|
new Date(),
|
||||||
getScopeByOrganizationId(""+session.getGroupId()),
|
getScopeByOrganizationId(""+aslSession.getGroupId()),
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
descToAdd,
|
descToAdd,
|
||||||
|
@ -128,7 +116,7 @@ public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
||||||
"linkDescription",
|
"linkDescription",
|
||||||
"linkHost");
|
"linkHost");
|
||||||
|
|
||||||
return store.saveAppFeed(toShare);
|
return getStoreInstance().saveAppFeed(toShare);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package org.gcube.applicationsupportlayer.social;
|
package org.gcube.applicationsupportlayer.social;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
|
||||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
|
||||||
import org.gcube.portal.databook.server.DatabookStore;
|
|
||||||
import org.gcube.portal.databook.shared.Comment;
|
import org.gcube.portal.databook.shared.Comment;
|
||||||
import org.gcube.portal.databook.shared.Feed;
|
import org.gcube.portal.databook.shared.Feed;
|
||||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
|
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
|
@ -17,12 +14,9 @@ import org.gcube.portlets.user.homelibrary.home.workspace.sharing.WorkspaceMessa
|
||||||
* use to notify users from within your application
|
* use to notify users from within your application
|
||||||
*/
|
*/
|
||||||
public class AslNotificationManager extends SocialPortalBridge implements NotificationManager {
|
public class AslNotificationManager extends SocialPortalBridge implements NotificationManager {
|
||||||
GCUBEClientLog log = new GCUBEClientLog(AslNotificationManager.class);
|
|
||||||
|
|
||||||
private ASLSession session;
|
|
||||||
|
|
||||||
public AslNotificationManager(ASLSession session) {
|
public AslNotificationManager(ASLSession session) {
|
||||||
this.session = session;
|
super(session);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.applicationsupportlayer.social;
|
package org.gcube.applicationsupportlayer.social;
|
||||||
|
|
||||||
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
||||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
||||||
import org.gcube.portal.databook.server.DatabookStore;
|
import org.gcube.portal.databook.server.DatabookStore;
|
||||||
|
@ -13,14 +14,23 @@ import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
|
||||||
* use to notify users from within your application
|
* use to notify users from within your application
|
||||||
*/
|
*/
|
||||||
public abstract class SocialPortalBridge {
|
public abstract class SocialPortalBridge {
|
||||||
|
|
||||||
private GCUBEClientLog _log = new GCUBEClientLog(SocialPortalBridge.class);
|
protected static GCUBEClientLog _log = new GCUBEClientLog(SocialPortalBridge.class);
|
||||||
protected DatabookStore store;
|
protected ASLSession aslSession;
|
||||||
|
//unique instance
|
||||||
public SocialPortalBridge() {
|
private static DatabookStore store;
|
||||||
store = new DBCassandraAstyanaxImpl();
|
|
||||||
|
public SocialPortalBridge(ASLSession session) {
|
||||||
|
this.aslSession = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static synchronized DatabookStore getStoreInstance() {
|
||||||
|
if (store == null) {
|
||||||
|
store = new DBCassandraAstyanaxImpl();
|
||||||
|
}
|
||||||
|
return store;
|
||||||
|
}
|
||||||
|
|
||||||
String getScopeByOrganizationId(String vreid) {
|
String getScopeByOrganizationId(String vreid) {
|
||||||
GroupManager gm = new LiferayGroupManager();
|
GroupManager gm = new LiferayGroupManager();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue