add rootFolderId as parameter
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portal/ws-synchronized-module-library@165493 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
634ca52339
commit
a41af18f23
|
@ -11,7 +11,7 @@ import java.io.Serializable;
|
||||||
* Feb 8, 2018
|
* Feb 8, 2018
|
||||||
*/
|
*/
|
||||||
public class ThSynchFolderConfiguration implements Serializable{
|
public class ThSynchFolderConfiguration implements Serializable{
|
||||||
|
|
||||||
/** The Constant serialVersionUID. */
|
/** The Constant serialVersionUID. */
|
||||||
private static final long serialVersionUID = -5807533629170443212L;
|
private static final long serialVersionUID = -5807533629170443212L;
|
||||||
|
|
||||||
|
@ -23,30 +23,50 @@ public class ThSynchFolderConfiguration implements Serializable{
|
||||||
|
|
||||||
/** The target token. */
|
/** The target token. */
|
||||||
private String targetToken;
|
private String targetToken;
|
||||||
|
|
||||||
/** The to create catalog name. */
|
/** The to create catalog name. */
|
||||||
private String toCreateCatalogName;
|
private String toCreateCatalogName;
|
||||||
|
|
||||||
/** The remote persistence. */
|
/** The remote persistence. */
|
||||||
private String remotePersistence="thredds";
|
private String remotePersistence="thredds";
|
||||||
|
|
||||||
|
private String rootFolderId;
|
||||||
|
|
||||||
|
|
||||||
public ThSynchFolderConfiguration() {
|
public ThSynchFolderConfiguration() {
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
public ThSynchFolderConfiguration(String remotePath, String filter, String targetToken, String toCreateCatalogName,
|
public ThSynchFolderConfiguration(String remotePath, String filter, String targetToken, String toCreateCatalogName,
|
||||||
String remotePersistence) {
|
String remotePersistence, String rootFolderId) {
|
||||||
super();
|
super();
|
||||||
this.remotePath = remotePath;
|
this.remotePath = remotePath;
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.targetToken = targetToken;
|
this.targetToken = targetToken;
|
||||||
this.toCreateCatalogName = toCreateCatalogName;
|
this.toCreateCatalogName = toCreateCatalogName;
|
||||||
this.remotePersistence = remotePersistence;
|
this.remotePersistence = remotePersistence;
|
||||||
|
this.rootFolderId = rootFolderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the rootFolderId
|
||||||
|
*/
|
||||||
|
public String getRootFolderId() {
|
||||||
|
|
||||||
|
return rootFolderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param rootFolderId the rootFolderId to set
|
||||||
|
*/
|
||||||
|
public void setRootFolderId(String rootFolderId) {
|
||||||
|
|
||||||
|
this.rootFolderId = rootFolderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getRemotePath() {
|
public String getRemotePath() {
|
||||||
return remotePath;
|
return remotePath;
|
||||||
|
@ -115,23 +135,28 @@ public class ThSynchFolderConfiguration implements Serializable{
|
||||||
this.remotePersistence = remotePersistence;
|
this.remotePersistence = remotePersistence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("ThSynchFolderConfiguration [remotePath=");
|
builder.append("ThSynchFolderConfiguration [remotePath=");
|
||||||
builder.append(remotePath);
|
builder.append(remotePath);
|
||||||
builder.append(", filter=");
|
builder.append(", filter=");
|
||||||
builder.append(filter);
|
builder.append(filter);
|
||||||
builder.append(", targetToken=");
|
builder.append(", targetToken=");
|
||||||
builder.append(targetToken!=null && targetToken.length()>3?targetToken.substring(0,targetToken.length()-3):"");
|
builder.append(targetToken);
|
||||||
builder.append(", toCreateCatalogName=");
|
builder.append(", toCreateCatalogName=");
|
||||||
builder.append(toCreateCatalogName);
|
builder.append(toCreateCatalogName);
|
||||||
builder.append(", remotePersistence=");
|
builder.append(", remotePersistence=");
|
||||||
builder.append(remotePersistence);
|
builder.append(remotePersistence);
|
||||||
|
builder.append(", rootFolderId=");
|
||||||
|
builder.append(rootFolderId);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,9 @@ public class ThreddsConverter {
|
||||||
|
|
||||||
String filter = t.getFilter()!=null && !t.getFilter().isEmpty()?t.getFilter():THREDDS_FILTER_NC_NCML_ASC;
|
String filter = t.getFilter()!=null && !t.getFilter().isEmpty()?t.getFilter():THREDDS_FILTER_NC_NCML_ASC;
|
||||||
|
|
||||||
return new SynchFolderConfiguration(t.getRemotePath(), filter, t.getTargetToken(), t.getToCreateCatalogName());
|
// return new SynchFolderConfiguration(t.getRemotePath(), filter, t.getTargetToken(), t.getToCreateCatalogName());
|
||||||
|
|
||||||
|
return new SynchFolderConfiguration(t.getRemotePath(), filter, t.getTargetToken(), t.getToCreateCatalogName(), t.getRootFolderId());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,6 +102,7 @@ public class ThreddsConverter {
|
||||||
mySync.setRemotePersistence(t.getRemotePersistence());
|
mySync.setRemotePersistence(t.getRemotePersistence());
|
||||||
mySync.setTargetToken(t.getTargetToken());
|
mySync.setTargetToken(t.getTargetToken());
|
||||||
mySync.setToCreateCatalogName(t.getToCreateCatalogName());
|
mySync.setToCreateCatalogName(t.getToCreateCatalogName());
|
||||||
|
mySync.setRootFolderId(t.getRootFolderId());
|
||||||
return mySync;
|
return mySync;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.util.concurrent.Semaphore;
|
|
||||||
|
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||||
|
@ -36,56 +35,56 @@ import org.gcube.usecases.ws.thredds.model.SynchFolderConfiguration;
|
||||||
* Feb 7, 2018
|
* Feb 7, 2018
|
||||||
*/
|
*/
|
||||||
public class TestWsThreddsEngine {
|
public class TestWsThreddsEngine {
|
||||||
|
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps";
|
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps";
|
||||||
public static String TEST_USER = "francesco.mangiacrapa";
|
public static String TEST_USER = "francesco.mangiacrapa";
|
||||||
|
|
||||||
public static String TEST_FOLDER_ID = "";
|
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 ProcessNotFoundException, InternalErrorException, WorkspaceInteractionException, InternalException, WorkspaceFolderNotFoundException, ItemNotFoundException, InsufficientPrivilegesException, ItemAlreadyExistException, HomeNotFoundException, UserNotFoundException, MalformedURLException, IOException {
|
||||||
|
|
||||||
// GET ENGINE : SINGLETON INSTANCE
|
// GET ENGINE : SINGLETON INSTANCE
|
||||||
SyncEngine engine=SyncEngine.get();
|
SyncEngine engine=SyncEngine.get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Workspace ws = HomeLibrary
|
Workspace ws = HomeLibrary
|
||||||
.getHomeManagerFactory()
|
.getHomeManagerFactory()
|
||||||
.getHomeManager()
|
.getHomeManager()
|
||||||
.getHome(TEST_USER)
|
.getHome(TEST_USER)
|
||||||
.getWorkspace();
|
.getWorkspace();
|
||||||
|
|
||||||
|
|
||||||
//TEST INFO...
|
//TEST INFO...
|
||||||
//TestCommons.setScope();
|
//TestCommons.setScope();
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
ScopeProvider.instance.set(scope.toString());
|
ScopeProvider.instance.set(scope.toString());
|
||||||
WorkspaceFolder folder=(WorkspaceFolder) ws.getItem(TEST_FOLDER_ID);
|
WorkspaceFolder folder=(WorkspaceFolder) ws.getItem(TEST_FOLDER_ID);
|
||||||
|
|
||||||
// FOLDER CONFIGURATION BEAN
|
// FOLDER CONFIGURATION BEAN
|
||||||
//SynchFolderConfiguration config=TestCommons.getSynchConfig();
|
//SynchFolderConfiguration config=TestCommons.getSynchConfig();
|
||||||
|
|
||||||
String filter = "";
|
String filter = "";
|
||||||
String remotePersistence = "";
|
String remotePersistence = "";
|
||||||
String remotePath = "";
|
String remotePath = "";
|
||||||
String targetToken = "";
|
String targetToken = "";
|
||||||
SynchFolderConfiguration config = new SynchFolderConfiguration(remotePath, filter, targetToken, remotePersistence);
|
SynchFolderConfiguration config = new SynchFolderConfiguration(remotePath, filter, targetToken, remotePersistence, folder.getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//try to clean it up, first..
|
//try to clean it up, first..
|
||||||
System.out.println("Cleaning it up..");
|
System.out.println("Cleaning it up..");
|
||||||
engine.unsetSynchronizedFolder(folder.getId(), false);
|
engine.unsetSynchronizedFolder(folder.getId(), false);
|
||||||
}catch(WorkspaceNotSynchedException e) {
|
}catch(WorkspaceNotSynchedException e) {
|
||||||
// it was already cleared
|
// it was already cleared
|
||||||
}catch(WorkspaceLockedException e) {
|
}catch(WorkspaceLockedException e) {
|
||||||
engine.forceUnlock(folder.getId());
|
engine.forceUnlock(folder.getId());
|
||||||
engine.unsetSynchronizedFolder(folder.getId(), false);
|
engine.unsetSynchronizedFolder(folder.getId(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// WHEN OPENING A FOLDER, INVOKE CHECK TO UPDATE SYNCH STATUS
|
// WHEN OPENING A FOLDER, INVOKE CHECK TO UPDATE SYNCH STATUS
|
||||||
engine.check(folder.getId(), false);
|
engine.check(folder.getId(), false);
|
||||||
}catch(WorkspaceNotSynchedException e) {
|
}catch(WorkspaceNotSynchedException e) {
|
||||||
System.out.println("Folder not synched, configurin it..");
|
System.out.println("Folder not synched, configurin it..");
|
||||||
|
@ -94,37 +93,37 @@ public class TestWsThreddsEngine {
|
||||||
System.out.println("Workspace locked, going to force unlock.."); // MAINLY FOR TEST PURPOSES, OR WHEN SOMETHIGN GOES WRONG.. USE CAUTIOUSLY
|
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(folder.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// INVOKE SYNCHRONIZATION ON FOLDER
|
// INVOKE SYNCHRONIZATION ON FOLDER
|
||||||
ProcessDescriptor descriptor=engine.doSync(folder.getId());
|
ProcessDescriptor descriptor=engine.doSync(folder.getId());
|
||||||
|
|
||||||
System.out.println("Obtained descriptor : "+descriptor);
|
System.out.println("Obtained descriptor : "+descriptor);
|
||||||
|
|
||||||
|
|
||||||
SyncOperationCallBack syncCall = new SyncOperationCallBack() {
|
SyncOperationCallBack syncCall = new SyncOperationCallBack() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStep(ProcessStatus status, ProcessDescriptor descriptor) {
|
public void onStep(ProcessStatus status, ProcessDescriptor descriptor) {
|
||||||
System.out.println("ON STEP : "+status+" "+descriptor);
|
System.out.println("ON STEP : "+status+" "+descriptor);
|
||||||
System.out.println("LOG : \n"+ status.getLogBuilder().toString());
|
System.out.println("LOG : \n"+ status.getLogBuilder().toString());
|
||||||
if(status.getStatus().equals(ProcessStatus.Status.COMPLETED)) {
|
if(status.getStatus().equals(ProcessStatus.Status.COMPLETED)) {
|
||||||
|
|
||||||
//COMPLETED FARE REMOVE DALLA MAPPA
|
//COMPLETED FARE REMOVE DALLA MAPPA
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// REGISTER CALLBACK TO MONITOR PROGRESS
|
// REGISTER CALLBACK TO MONITOR PROGRESS
|
||||||
engine.registerCallBack(folder.getId(), syncCall);
|
engine.registerCallBack(folder.getId(), syncCall);
|
||||||
|
|
||||||
|
|
||||||
engine.check(folder.getId(), true);
|
engine.check(folder.getId(), true);
|
||||||
|
|
||||||
|
|
||||||
// INVOKE WHEN PORTAL SHUTS DOWN TO FREE RESOURCES AND STOP SYNC PROCESSES
|
// INVOKE WHEN PORTAL SHUTS DOWN TO FREE RESOURCES AND STOP SYNC PROCESSES
|
||||||
engine.shutDown();
|
engine.shutDown();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue