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;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
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.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.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.DatabookStore;
|
||||
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 {
|
||||
|
||||
GCUBEClientLog log = new GCUBEClientLog(AslNewsManager.class);
|
||||
|
||||
private ASLSession session;
|
||||
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
|
||||
*/
|
||||
public AslNewsManager(ASLSession session, Class<?> applicationClass) {
|
||||
this.session = session;
|
||||
super(session);
|
||||
this.application = getProfileFromInfrastrucure(applicationClass);
|
||||
}
|
||||
/**
|
||||
|
@ -65,7 +53,7 @@ public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
|||
" eq '" + applicationClass.getName() + "'" +
|
||||
"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)
|
||||
throw new ApplicationDataNotFoundException("Your application is not registered in the infrastructure");
|
||||
else {
|
||||
|
@ -81,7 +69,7 @@ public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
|||
if (currValue != null && currValue.size() > 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()");
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
|
@ -98,7 +86,7 @@ public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
|||
}
|
||||
|
||||
} 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();
|
||||
return null;
|
||||
}
|
||||
|
@ -116,7 +104,7 @@ public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
|||
FeedType.PUBLISH,
|
||||
application.getName(),
|
||||
new Date(),
|
||||
getScopeByOrganizationId(""+session.getGroupId()),
|
||||
getScopeByOrganizationId(""+aslSession.getGroupId()),
|
||||
"",
|
||||
"",
|
||||
descToAdd,
|
||||
|
@ -128,7 +116,7 @@ public class AslNewsManager extends SocialPortalBridge implements NewsManager {
|
|||
"linkDescription",
|
||||
"linkHost");
|
||||
|
||||
return store.saveAppFeed(toShare);
|
||||
return getStoreInstance().saveAppFeed(toShare);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package org.gcube.applicationsupportlayer.social;
|
||||
|
||||
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.Feed;
|
||||
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
|
||||
*/
|
||||
public class AslNotificationManager extends SocialPortalBridge implements NotificationManager {
|
||||
GCUBEClientLog log = new GCUBEClientLog(AslNotificationManager.class);
|
||||
|
||||
private ASLSession session;
|
||||
|
||||
public AslNotificationManager(ASLSession session) {
|
||||
this.session = session;
|
||||
super(session);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.applicationsupportlayer.social;
|
||||
|
||||
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;
|
||||
|
@ -14,11 +15,20 @@ import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
|
|||
*/
|
||||
public abstract class SocialPortalBridge {
|
||||
|
||||
private GCUBEClientLog _log = new GCUBEClientLog(SocialPortalBridge.class);
|
||||
protected DatabookStore store;
|
||||
protected static GCUBEClientLog _log = new GCUBEClientLog(SocialPortalBridge.class);
|
||||
protected ASLSession aslSession;
|
||||
//unique instance
|
||||
private static DatabookStore store;
|
||||
|
||||
public SocialPortalBridge() {
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue