58 lines
1.6 KiB
Java
58 lines
1.6 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
|
|
*
|
|
* use to notify users from within your application
|
|
*/
|
|
public abstract class SocialPortalBridge {
|
|
|
|
protected static GCUBEClientLog _log = new GCUBEClientLog(SocialPortalBridge.class);
|
|
protected ASLSession aslSession;
|
|
//unique instance
|
|
private static DatabookStore store;
|
|
|
|
public SocialPortalBridge(ASLSession session) {
|
|
this.aslSession = session;
|
|
}
|
|
|
|
public static synchronized DatabookStore getStoreInstance() {
|
|
if (store == null) {
|
|
store = new DBCassandraAstyanaxImpl();
|
|
}
|
|
return store;
|
|
}
|
|
|
|
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
|
|
*/
|
|
String escapeHtml(String html) {
|
|
if (html == null) {
|
|
return null;
|
|
}
|
|
return html.replaceAll("&", "&").replaceAll("<", "<")
|
|
.replaceAll(">", ">");
|
|
}
|
|
}
|