RootVO name retrieve moved to config class

This commit is contained in:
Mauro Mugnaini 2020-07-09 15:42:34 +02:00
parent fd9ed393a0
commit 75559aace1
1 changed files with 1 additions and 24 deletions

View File

@ -1,20 +1,16 @@
package org.gcube.portal.event.publisher.lr62;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Map;
import org.gcube.event.publisher.Event;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.model.User;
import com.liferay.portal.util.PortalUtil;
public class PortalEvent extends Event {
@ -24,37 +20,18 @@ public class PortalEvent extends Event {
protected static final UserManager USER_MANAGER = new LiferayUserManager();
private static String rootVOName;
public static final String TYPE = "portal";
public static final String USER_ENTRY = "user";
public static final String GROUP_ENTRY = "group";
public static final String ROLE_ENTRY = "role";
static {
try {
rootVOName = new LiferayGroupManager().getRootVOName();
} catch (Exception e) {
log.warn("Cannot get root VO name, using hostname");
try {
rootVOName = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e1) {
log.error("Cannot get localhost name", e);
rootVOName = PortalUtil.getComputerName();
}
}
}
public PortalEvent(String name) {
this(name, null);
}
public PortalEvent(String name, Map<String, String> data) {
super(name, TYPE, getRootVOName(), data);
}
protected static String getRootVOName() {
return rootVOName;
super(name, TYPE, EventPublisherConfiguration.getConfiguration().getRootVOName(), data);
}
public void setUser(User user) throws UserManagementSystemException, UserRetrievalFault {