moved a SHUB

updated pom version at 1.1.0
Task #17348 Migrate ws-thredds-sync components to SHUB

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/ws-thredds-sync-widget@181402 82a268e6-3cf1-43bd-a215-b396298e98cf
pull/1/head
Francesco Mangiacrapa 5 years ago
parent eb01b1fb21
commit da7900cc05

@ -11,11 +11,13 @@
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">

@ -5,4 +5,5 @@ org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

@ -1,5 +1,13 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-widgets.ws-thredds-sync-widget.1-0-0"
<Changeset
component="org.gcube.portlets-widgets.ws-thredds-sync-widget.1-1-0"
date="${buildDate}">
<Change>
[Task #17348] Migrate ws-thredds-sync components to SHUB
</Change>
</Changeset>
<Changeset
component="org.gcube.portlets-widgets.ws-thredds-sync-widget.1-0-0"
date="2018-03-16">
<Change>First Release</Change>
</Changeset>

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -12,7 +13,7 @@
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>ws-thredds-sync-widget</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<name>ws-thredds-sync-widget</name>
<description>
gCube ws-thredds-sync-widget is a widget to use and interact with ws-thredds facility in order to syncronize the Workspace folders with Thredds Reporitory folders
@ -100,6 +101,11 @@
<version>[2.0.0-SNAPSHOT, 3-0-0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-wrapper</artifactId>
<version>[0.0.1-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
</dependency>
<!-- LOGGER -->

@ -2,7 +2,6 @@ package org.gcube.portlets.widgets.wsthreddssync.server;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import org.apache.commons.lang.StringUtils;
import org.gcube.common.authorization.library.AuthorizationEntry;
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor;
@ -15,17 +14,18 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO: Auto-generated Javadoc
/**
* The Class BeanConverter.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 16, 2018
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Aug 2, 2019
*/
public class BeanConverter {
private static Logger logger = LoggerFactory.getLogger(BeanConverter.class);
/**
* To ws thredds folder config.
*
@ -33,7 +33,8 @@ public class BeanConverter {
* @param theStatus the the status
* @return the ws thredds synch folder descriptor
*/
public static WsThreddsSynchFolderDescriptor toWsThreddsFolderConfig(ThSyncFolderDescriptor t, Sync_Status theStatus) {
public static WsThreddsSynchFolderDescriptor toWsThreddsFolderConfig(ThSyncFolderDescriptor t,
Sync_Status theStatus) {
if (t == null)
return null;
@ -57,8 +58,6 @@ public class BeanConverter {
}
}
return ws;
}
@ -78,8 +77,6 @@ public class BeanConverter {
}
/**
* To gcube scope.
*
@ -91,19 +88,21 @@ public class BeanConverter {
if (scopeName == null)
return null;
int count = StringUtils.countMatches(scopeName, "/");
if(count==1)
return GcubeScopeType.ROOT;
else if(count==2)
return GcubeScopeType.VO;
else if(count==3)
return GcubeScopeType.VRE;
String[] components=scopeName.split("/");
return null;
if (components.length<2 || components.length>4)
throw new IllegalArgumentException("scope "+scopeName+" is malformed");
if(components.length>3) {
return GcubeScopeType.VRE;
}
else if (components.length>2) {
return GcubeScopeType.VO;
}
else {
return GcubeScopeType.ROOT;
}
}
/**
* To th synch folder configuration.
@ -113,7 +112,8 @@ public class BeanConverter {
* @param targetScopeUserToken the target scope user token
* @return the th synch folder configuration
*/
public static ThSynchFolderConfiguration toThSynchFolderConfiguration(WsThreddsSynchFolderConfiguration t, String rootFolderId, String targetScopeUserToken) {
public static ThSynchFolderConfiguration toThSynchFolderConfiguration(WsThreddsSynchFolderConfiguration t,
String rootFolderId, String targetScopeUserToken) {
if (t == null)
return null;

@ -5,13 +5,16 @@ package org.gcube.portlets.widgets.wsthreddssync.server;
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.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.scope.api.ScopeProvider;
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
//import org.gcube.portlets.user.workspace.server.util.WsUtil;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -59,27 +62,38 @@ public class WsUtil {
return PortalContext.getConfiguration().getCurrentUser(httpServletRequest)==null;
}
/**
* Gets the workspace.
* Gets the workspace from storage hub.
*
* @param httpServletRequest the http servlet request
* @return the workspace
* @throws InternalErrorException the internal error exception
* @throws HomeNotFoundException the home not found exception
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
* @return the workspace from storage hub
* @throws Exception the exception
*/
public static Workspace getWorkspace(HttpServletRequest httpServletRequest) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
{
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);
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(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);
Workspace workspace = HomeLibrary.getUserWorkspace(user.getUsername());
return workspace;
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);
}
}
}

@ -1,33 +1,25 @@
package org.gcube.portlets.widgets.wsthreddssync.shared;
import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
// TODO: Auto-generated Javadoc
/**
* The Class GcubeVRE.
* The Class GcubeScope.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 14, 2018
* Aug 2, 2019
*/
public class GcubeScope implements Serializable, IsSerializable, Comparable<GcubeScope> {
/**
*
*/
private static final long serialVersionUID = -6427520549519606384L;
private GcubeScopeType scopeType;
private String scopeTitle;
private String scopeName;
/**
@ -52,8 +44,9 @@ public class GcubeScope implements Serializable, IsSerializable, Comparable<Gcub
this.scopeType = scopeType;
}
/**
* Gets the scope type.
*
* @return the scopeType
*/
public GcubeScopeType getScopeType() {
@ -61,8 +54,9 @@ public class GcubeScope implements Serializable, IsSerializable, Comparable<Gcub
return scopeType;
}
/**
* Gets the scope title.
*
* @return the scopeTitle
*/
public String getScopeTitle() {
@ -70,8 +64,9 @@ public class GcubeScope implements Serializable, IsSerializable, Comparable<Gcub
return scopeTitle;
}
/**
* Gets the scope name.
*
* @return the scopeName
*/
public String getScopeName() {
@ -79,8 +74,9 @@ public class GcubeScope implements Serializable, IsSerializable, Comparable<Gcub
return scopeName;
}
/**
* Sets the scope type.
*
* @param scopeType the scopeType to set
*/
public void setScopeType(GcubeScopeType scopeType) {
@ -88,8 +84,9 @@ public class GcubeScope implements Serializable, IsSerializable, Comparable<Gcub
this.scopeType = scopeType;
}
/**
* Sets the scope title.
*
* @param scopeTitle the scopeTitle to set
*/
public void setScopeTitle(String scopeTitle) {
@ -97,8 +94,9 @@ public class GcubeScope implements Serializable, IsSerializable, Comparable<Gcub
this.scopeTitle = scopeTitle;
}
/**
* Sets the scope name.
*
* @param scopeName the scopeName to set
*/
public void setScopeName(String scopeName) {
@ -106,7 +104,9 @@ public class GcubeScope implements Serializable, IsSerializable, Comparable<Gcub
this.scopeName = scopeName;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
@ -119,7 +119,9 @@ public class GcubeScope implements Serializable, IsSerializable, Comparable<Gcub
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
@ -136,5 +138,4 @@ public class GcubeScope implements Serializable, IsSerializable, Comparable<Gcub
return builder.toString();
}
}

@ -1,26 +1,8 @@
package org.gcube.portlets.widgets.wsthreddssync;
import java.io.IOException;
import java.net.MalformedURLException;
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.exceptions.UserNotFoundException;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.usecases.ws.thredds.SyncEngine;
import org.gcube.usecases.ws.thredds.engine.impl.ProcessDescriptor;
import org.gcube.usecases.ws.thredds.engine.impl.ProcessStatus;
import org.gcube.usecases.ws.thredds.faults.InternalException;
import org.gcube.usecases.ws.thredds.faults.ProcessNotFoundException;
import org.gcube.usecases.ws.thredds.faults.WorkspaceInteractionException;
import org.gcube.usecases.ws.thredds.faults.WorkspaceLockedException;
import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException;
import org.gcube.usecases.ws.thredds.model.SyncOperationCallBack;
@ -42,26 +24,12 @@ public class TestWsThreddsEngine {
public static String TEST_FOLDER_ID = "";
public static void main(String[] args) throws ProcessNotFoundException, InternalErrorException, WorkspaceInteractionException, InternalException, WorkspaceFolderNotFoundException, ItemNotFoundException, InsufficientPrivilegesException, ItemAlreadyExistException, HomeNotFoundException, UserNotFoundException, MalformedURLException, IOException {
public static void main(String[] args) throws Exception {
// GET ENGINE : SINGLETON INSTANCE
SyncEngine engine=SyncEngine.get();
Workspace ws = HomeLibrary
.getHomeManagerFactory()
.getHomeManager()
.getHome(TEST_USER)
.getWorkspace();
//TEST INFO...
//TestCommons.setScope();
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
ScopeProvider.instance.set(scope.toString());
WorkspaceFolder folder=(WorkspaceFolder) ws.getItem(TEST_FOLDER_ID);
// FOLDER CONFIGURATION BEAN
//SynchFolderConfiguration config=TestCommons.getSynchConfig();
@ -69,33 +37,33 @@ public class TestWsThreddsEngine {
String remotePersistence = "";
String remotePath = "";
String targetToken = "";
SynchFolderConfiguration config = new SynchFolderConfiguration(remotePath, filter, targetToken, remotePersistence, folder.getId());
SynchFolderConfiguration config = new SynchFolderConfiguration(remotePath, filter, targetToken, remotePersistence, TEST_FOLDER_ID);
try {
//try to clean it up, first..
System.out.println("Cleaning it up..");
engine.unsetSynchronizedFolder(folder.getId(), false);
engine.unsetSynchronizedFolder(TEST_FOLDER_ID, false);
}catch(WorkspaceNotSynchedException e) {
// it was already cleared
}catch(WorkspaceLockedException e) {
engine.forceUnlock(folder.getId());
engine.unsetSynchronizedFolder(folder.getId(), false);
engine.forceUnlock(TEST_FOLDER_ID);
engine.unsetSynchronizedFolder(TEST_FOLDER_ID, false);
}
try {
// WHEN OPENING A FOLDER, INVOKE CHECK TO UPDATE SYNCH STATUS
engine.check(folder.getId(), false);
engine.check(TEST_FOLDER_ID, false);
}catch(WorkspaceNotSynchedException e) {
System.out.println("Folder not synched, configurin it..");
engine.setSynchronizedFolder(config, folder.getId());
engine.setSynchronizedFolder(config, TEST_FOLDER_ID);
}catch(WorkspaceLockedException e) {
System.out.println("Workspace locked, going to force unlock.."); // MAINLY FOR TEST PURPOSES, OR WHEN SOMETHIGN GOES WRONG.. USE CAUTIOUSLY
engine.forceUnlock(folder.getId());
engine.forceUnlock(TEST_FOLDER_ID);
}
// INVOKE SYNCHRONIZATION ON FOLDER
ProcessDescriptor descriptor=engine.doSync(folder.getId());
ProcessDescriptor descriptor=engine.doSync(TEST_FOLDER_ID);
System.out.println("Obtained descriptor : "+descriptor);
@ -115,10 +83,10 @@ public class TestWsThreddsEngine {
};
// REGISTER CALLBACK TO MONITOR PROGRESS
engine.registerCallBack(folder.getId(), syncCall);
engine.registerCallBack(TEST_FOLDER_ID, syncCall);
engine.check(folder.getId(), true);
engine.check(TEST_FOLDER_ID, true);
// INVOKE WHEN PORTAL SHUTS DOWN TO FREE RESOURCES AND STOP SYNC PROCESSES

@ -1,10 +1,12 @@
package org.gcube.portlets.widgets.wsthreddssync;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.workspace.Properties;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
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.common.storagehubwrapper.shared.tohl.Properties;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
public class TestWsThreddsQuery {
@ -13,7 +15,7 @@ public class TestWsThreddsQuery {
static String scope = "/gcube/devsec";
static String username = "francesco.mangiacrapa";
// NextNeext Francesco's Token
static String token = "89257623-0570-4fbe-a15b-458bb84f4902-98187548";
static String token = "TOKEN";
public static final String WS_SYNCH_SYNCH_STATUS = "WS-SYNCH.SYNCH-STATUS";
public static void main(String[] args) {
@ -27,15 +29,15 @@ public class TestWsThreddsQuery {
try {
ScopeProvider.instance.set(scope);
Workspace workspace = HomeLibrary.getUserWorkspace(username);
WorkspaceFolder folder = (WorkspaceFolder) workspace.getItem(folderId);
Properties properties = folder.getProperties();
StorageHubWrapper shWrapper = new StorageHubWrapper(scope, token, false, false, true);
Workspace workspace = shWrapper.getWorkspace();
Map<String, Object> metadata = workspace.getMetadata(folderId);
if (properties == null || properties.getProperties() == null || properties.getProperties().size() == 0) {
if (metadata == null || metadata.isEmpty()) {
throw new ItemNotSynched("No properties to read");
}
String wsSyncStatus = properties.getProperties().get(WS_SYNCH_SYNCH_STATUS);
String wsSyncStatus = (String) metadata.get(WS_SYNCH_SYNCH_STATUS);
System.out.println("Current: " + WS_SYNCH_SYNCH_STATUS + " has value: " + wsSyncStatus);
//System.out.println("isSynched: " + isSynched);

@ -5,18 +5,16 @@ package org.gcube.portlets.widgets.wsthreddssync;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
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.Properties;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
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.portlets.widgets.wsthreddssync.server.SyncronizeWithThredds;
import org.gcube.usecases.ws.thredds.Constants;
@ -39,6 +37,9 @@ public class UnSyncThreddsFolders {
private static List<String> lstErrorItem = new ArrayList<String>();
private static long totalAttempts = 0;
static String scope = "/gcube/devsec";
static String token = "TOKEN";
public static SyncronizeWithThredds syncService = new SyncronizeWithThredds();
@ -51,13 +52,11 @@ public class UnSyncThreddsFolders {
* @throws HomeNotFoundException the home not found exception
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
*/
public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
{
public static Workspace getWorkspace() throws Exception{
System.out.println("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
ScopeProvider.instance.set(DEFAULT_SCOPE);
Workspace workspace = HomeLibrary.getUserWorkspace(TEST_USER);
return workspace;
ScopeProvider.instance.set(scope);
StorageHubWrapper shWrapper = new StorageHubWrapper(scope, token, false, false, true);
return shWrapper.getWorkspace();
}
@ -69,7 +68,7 @@ public class UnSyncThreddsFolders {
* @throws InternalErrorException the internal error exception
* @throws HomeNotFoundException the home not found exception
*/
public static void main(String[] args) throws WorkspaceFolderNotFoundException, InternalErrorException, HomeNotFoundException {
public static void main(String[] args) throws Exception {
Workspace ws = getWorkspace();
unsycFirstLevel(ws, ws.getRoot().getId(), false);
@ -103,8 +102,9 @@ public class UnSyncThreddsFolders {
* @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){
public static void unsycFirstLevel(Workspace ws, String itemId, boolean depthUnsync) throws Exception{
WorkspaceItem item;
try {
@ -113,7 +113,7 @@ public class UnSyncThreddsFolders {
if(item.isFolder()){
List<? extends WorkspaceItem> children = item.getChildren();
List<? extends WorkspaceItem> children = ws.getChildren(item.getId());
for (WorkspaceItem workspaceItem : children) {
if(depthUnsync)
unsycFirstLevel(ws, workspaceItem.getId(), depthUnsync);
@ -153,7 +153,8 @@ public class UnSyncThreddsFolders {
//Boolean unsynched = syncService.doUnSync(workspaceItem.getId(), false, DEFAULT_SCOPE, TEST_USER_TOKEN);
ScopeProvider.instance.set(DEFAULT_SCOPE);
SecurityTokenProvider.instance.set(TEST_USER_TOKEN);
cleanItem(workspaceItem);
Workspace ws = getWorkspace();
cleanItem(workspaceItem, ws);
totalAttempts++;
// if(unsynched)
// lstUnSynchedItem.add(workspaceItem.getId());
@ -163,25 +164,24 @@ public class UnSyncThreddsFolders {
}catch(Exception e){
e.printStackTrace();
try {
lstErrorItem.add(workspaceItem.getId());
}
catch (InternalErrorException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
static void cleanItem(WorkspaceItem item) throws InternalErrorException {
Properties props=item.getProperties();
if(props.hasProperty(Constants.WorkspaceProperties.TBS)) {
static void cleanItem(WorkspaceItem item, Workspace ws) throws Exception {
Map<String, Object> props = ws.getMetadata(item.getId());
if(props.containsKey(Constants.WorkspaceProperties.TBS)) {
if(item.isFolder()) {
props.addProperties(Constants.cleanedFolderPropertiesMap);
for(WorkspaceItem child : ((WorkspaceFolder)item).getChildren())
cleanItem(child);
}else props.addProperties(Constants.cleanedItemPropertiesMap);
//props.addProperties(Constants.cleanedFolderPropertiesMap);
ws.updateMetadata(item.getId(), Constants.cleanedFolderPropertiesMap);
List<? extends WorkspaceItem> children = ws.getChildren(item.getId());
for(WorkspaceItem child : children)
cleanItem(child, ws);
}else {
ws.updateMetadata(item.getId(), Constants.cleanedFolderPropertiesMap);
}
}
}

Loading…
Cancel
Save