task_21379 #3
34
pom.xml
34
pom.xml
|
@ -62,19 +62,6 @@
|
||||||
<artifactId>gwt-bootstrap</artifactId>
|
<artifactId>gwt-bootstrap</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- PORTAL MANAGER -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.common.portal</groupId>
|
|
||||||
<artifactId>portal-manager</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.liferay.portal</groupId>
|
|
||||||
<artifactId>portal-service</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- User Management Core -->
|
<!-- User Management Core -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.dvos</groupId>
|
<groupId>org.gcube.dvos</groupId>
|
||||||
|
@ -92,22 +79,21 @@
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>oidc-library-portal</artifactId>
|
<artifactId>oidc-library-portal</artifactId>
|
||||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||||
<scope>compile</scope>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- PORTAL MANAGER -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common.portal</groupId>
|
||||||
|
<artifactId>portal-manager</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>com.liferay.portal</groupId>
|
||||||
<artifactId>authorization-client</artifactId>
|
<artifactId>portal-service</artifactId>
|
||||||
<version>[2.0.0, 3-0-0-SNAPSHOT)</version>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
<artifactId>storagehub-client-wrapper</artifactId>
|
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- LOGGER -->
|
<!-- LOGGER -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
|
|
@ -10,15 +10,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
//import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
//import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
|
||||||
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|
||||||
//import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
//import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
|
||||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
|
||||||
import org.gcube.portlets.widgets.wsthreddssync.shared.GatewayRolesThredds;
|
import org.gcube.portlets.widgets.wsthreddssync.shared.GatewayRolesThredds;
|
||||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||||
|
@ -39,17 +31,13 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
/**
|
/**
|
||||||
* The Class WsUtil.
|
* The Class WsUtil.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Nov 25, 2016
|
||||||
* Nov 25, 2016
|
|
||||||
*/
|
*/
|
||||||
public class WsUtil {
|
public class WsUtil {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** The logger. */
|
/** The logger. */
|
||||||
private static Logger logger = LoggerFactory.getLogger(WsUtil.class);
|
private static Logger logger = LoggerFactory.getLogger(WsUtil.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is within portal.
|
* Checks if is within portal.
|
||||||
*
|
*
|
||||||
|
@ -59,14 +47,12 @@ public class WsUtil {
|
||||||
try {
|
try {
|
||||||
UserLocalServiceUtil.getService();
|
UserLocalServiceUtil.getService();
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
logger.trace("Development Mode ON");
|
logger.trace("Development Mode ON");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is session expired.
|
* Checks if is session expired.
|
||||||
*
|
*
|
||||||
|
@ -80,41 +66,8 @@ public class WsUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the workspace from storage hub.
|
* Gets the list of Scopes (Root-VO, VOs and VREs) for user and the Thredds
|
||||||
*
|
* roles that user has in them.
|
||||||
* @param httpServletRequest the http servlet request
|
|
||||||
* @return the workspace from storage hub
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
|
||||||
public Workspace getWorkspaceFromStorageHub(HttpServletRequest httpServletRequest) throws Exception {
|
|
||||||
logger.trace("Get Workspace");
|
|
||||||
// String scope = PortalContext.getConfiguration().getCurrentScope(httpServletRequest);
|
|
||||||
|
|
||||||
GCubeUser user = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
String scope = PortalContext.getConfiguration().getCurrentScope(httpServletRequest);
|
|
||||||
user = PortalContext.getConfiguration().getCurrentUser(httpServletRequest);
|
|
||||||
if (user == null || user.getUsername().isEmpty())
|
|
||||||
throw new Exception("Session expired");
|
|
||||||
|
|
||||||
ScopeProvider.instance.set(scope);
|
|
||||||
logger.trace("Scope provider instancied at: "+scope);
|
|
||||||
|
|
||||||
logger.debug("Getting " + StorageHubWrapper.class.getSimpleName() + " for user: " + user.getUsername()
|
|
||||||
+ " by using the scope: " + scope);
|
|
||||||
|
|
||||||
String token = PortalContext.getConfiguration().getCurrentUserToken(scope, user.getUsername());
|
|
||||||
StorageHubWrapper shWrapper = new StorageHubWrapper(scope, token, false, false, true);
|
|
||||||
return shWrapper.getWorkspace();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Error on getting the Workspace via SHUB wrapper", e);
|
|
||||||
throw new Exception("Error on gettig the Workspace for userId: " + user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the list of Scopes (Root-VO, VOs and VREs) for user and the Thredds roles that user has in them.
|
|
||||||
*
|
*
|
||||||
* @param user the user
|
* @param user the user
|
||||||
* @return the VREs and Thredds roles for a given user
|
* @return the VREs and Thredds roles for a given user
|
||||||
|
@ -146,7 +99,6 @@ public class WsUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the (highest) thredds role for the user in the scope
|
* Gets the (highest) thredds role for the user in the scope
|
||||||
*
|
*
|
||||||
|
@ -156,7 +108,8 @@ public class WsUtil {
|
||||||
*/
|
*/
|
||||||
public static GatewayRolesThredds getThreddsRoleFor(GCubeUser user, GCubeGroup scope) {
|
public static GatewayRolesThredds getThreddsRoleFor(GCubeUser user, GCubeGroup scope) {
|
||||||
if (user == null || scope == null) {
|
if (user == null || scope == null) {
|
||||||
logger.warn("called getThreddsRoleFor with invalid parameter user: "+user+", in the scope: "+scope, ", returning null");
|
logger.warn("called getThreddsRoleFor with invalid parameter user: " + user + ", in the scope: " + scope,
|
||||||
|
", returning null");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +127,8 @@ public class WsUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("For user: "+user.getUsername()+" in the scope: "+scope.getGroupName()+" read the role/s: " + threddsRoles);
|
logger.info("For user: " + user.getUsername() + " in the scope: " + scope.getGroupName()
|
||||||
|
+ " read the role/s: " + threddsRoles);
|
||||||
|
|
||||||
GatewayRolesThredds toReturn = null;
|
GatewayRolesThredds toReturn = null;
|
||||||
if (threddsRoles.contains(GatewayRolesThredds.DATA_MANAGER))
|
if (threddsRoles.contains(GatewayRolesThredds.DATA_MANAGER))
|
||||||
|
@ -190,5 +144,4 @@ public class WsUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
package org.gcube.portlets.widgets.wsthreddssync;
|
package org.gcube.portlets.widgets.wsthreddssync;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
|
||||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
|
||||||
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
|
||||||
|
|
||||||
public class TestWsThreddsQuery {
|
public class TestWsThreddsQuery {
|
||||||
|
|
||||||
final static String folderId = "61ea6d91-4b09-43ec-91c4-b2fdb9b8c538";
|
final static String folderId = "61ea6d91-4b09-43ec-91c4-b2fdb9b8c538";
|
||||||
|
@ -14,21 +7,20 @@ public class TestWsThreddsQuery {
|
||||||
static String username = "francesco.mangiacrapa";
|
static String username = "francesco.mangiacrapa";
|
||||||
// NextNeext Francesco's Token
|
// NextNeext Francesco's Token
|
||||||
static String token = "TOKEN";
|
static String token = "TOKEN";
|
||||||
public static final String WS_SYNCH_SYNCH_STATUS = "WS-SYNCH.SYNCH-STATUS";
|
|
||||||
|
|
||||||
|
/*
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
isItemSynched();
|
isItemSynched();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void isItemSynched() {
|
public static void isItemSynched() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ScopeProvider.instance.set(scope);
|
ScopeProvider.instance.set(scope);
|
||||||
|
|
||||||
StorageHubWrapper shWrapper = new StorageHubWrapper(scope, token, false, false, true);
|
|
||||||
Workspace workspace = shWrapper.getWorkspace();
|
|
||||||
Map<String, Object> metadata = workspace.getMetadata(folderId);
|
Map<String, Object> metadata = workspace.getMetadata(folderId);
|
||||||
|
|
||||||
if (metadata == null || metadata.isEmpty()) {
|
if (metadata == null || metadata.isEmpty()) {
|
||||||
|
@ -45,5 +37,6 @@ public class TestWsThreddsQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,6 @@ package org.gcube.portlets.widgets.wsthreddssync;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
|
||||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException;
|
|
||||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor;
|
|
||||||
import org.gcube.portlets.widgets.wsthreddssync.server.SyncronizeWithThredds;
|
import org.gcube.portlets.widgets.wsthreddssync.server.SyncronizeWithThredds;
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,21 +34,6 @@ public class UnSyncThreddsFolders {
|
||||||
public static SyncronizeWithThredds syncService = new SyncronizeWithThredds();
|
public static SyncronizeWithThredds syncService = new SyncronizeWithThredds();
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the workspace.
|
|
||||||
*
|
|
||||||
* @return the workspace
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
* @throws HomeNotFoundException the home not found exception
|
|
||||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
|
||||||
*/
|
|
||||||
public static Workspace getWorkspace() throws Exception{
|
|
||||||
|
|
||||||
ScopeProvider.instance.set(scope);
|
|
||||||
StorageHubWrapper shWrapper = new StorageHubWrapper(scope, token, false, false, true);
|
|
||||||
return shWrapper.getWorkspace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main method.
|
* The main method.
|
||||||
|
@ -67,9 +43,9 @@ public class UnSyncThreddsFolders {
|
||||||
* @throws InternalErrorException the internal error exception
|
* @throws InternalErrorException the internal error exception
|
||||||
* @throws HomeNotFoundException the home not found exception
|
* @throws HomeNotFoundException the home not found exception
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
Workspace ws = getWorkspace();
|
|
||||||
unsycFirstLevel(ws, ws.getRoot().getId(), false);
|
unsycFirstLevel(ws, ws.getRoot().getId(), false);
|
||||||
|
|
||||||
System.out.println("UnSync completed");
|
System.out.println("UnSync completed");
|
||||||
|
@ -95,14 +71,6 @@ public class UnSyncThreddsFolders {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unsyc first level.
|
|
||||||
*
|
|
||||||
* @param ws the ws
|
|
||||||
* @param itemId the item id
|
|
||||||
* @param depthUnsync the depth unsync
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static void unsycFirstLevel(Workspace ws, String itemId, boolean depthUnsync) throws Exception{
|
public static void unsycFirstLevel(Workspace ws, String itemId, boolean depthUnsync) throws Exception{
|
||||||
|
|
||||||
WorkspaceItem item;
|
WorkspaceItem item;
|
||||||
|
@ -134,11 +102,6 @@ public class UnSyncThreddsFolders {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unsyn folder.
|
|
||||||
*
|
|
||||||
* @param workspaceItem the workspace item
|
|
||||||
*/
|
|
||||||
public static void unsynFolder(WorkspaceItem workspaceItem) {
|
public static void unsynFolder(WorkspaceItem workspaceItem) {
|
||||||
|
|
||||||
if(workspaceItem==null)
|
if(workspaceItem==null)
|
||||||
|
@ -183,6 +146,7 @@ public class UnSyncThreddsFolders {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue