aslsocial/src/main/java/org/gcube/applicationsupportlayer/social/SocialPortalBridge.java

64 lines
1.7 KiB
Java

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.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Dec 2012
*
* superclass for social portal bridge
*/
public abstract class SocialPortalBridge {
protected static GCUBEClientLog _log = new GCUBEClientLog(SocialPortalBridge.class);
protected ASLSession aslSession;
//unique instance
private static DatabookStore store;
/**
*
* @param session
*/
public SocialPortalBridge(ASLSession session) {
this.aslSession = session;
}
/**
*
* @return the unique instance of the store
*/
public static synchronized DatabookStore getStoreInstance() {
if (store == null) {
store = new DBCassandraAstyanaxImpl();
}
return store;
}
protected String getScopeByOrganizationId(String vreid) {
GroupManager gm = new LiferayGroupManager();
try {
return gm.getScope(vreid);
} catch (Exception e) {
_log.error("Could not find a scope for this VREid: " + vreid);
return null;
}
}
/**
* Escape an html string. Escaping data received from the client helps to
* prevent cross-site script vulnerabilities.
*
* @param html the html string to escape
* @return the escaped string
*/
protected String escapeHtml(String html) {
if (html == null) {
return null;
}
return html.replaceAll("&", "&amp;").replaceAll("<", "&lt;")
.replaceAll(">", "&gt;");
}
}