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

48 lines
1.3 KiB
Java
Raw Normal View History

package org.gcube.applicationsupportlayer.social;
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 {
private GCUBEClientLog _log = new GCUBEClientLog(SocialPortalBridge.class);
protected DatabookStore store;
public SocialPortalBridge() {
store = new DBCassandraAstyanaxImpl();
}
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("&", "&amp;").replaceAll("<", "&lt;")
.replaceAll(">", "&gt;");
}
}