1.0.0
This commit is contained in:
parent
aa5147bb48
commit
37ca2485af
36
.classpath
36
.classpath
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" 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">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
|
@ -1,5 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
@ -2,7 +2,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for org.gcube.spatial.data.sdi-service
|
||||
|
||||
## [v1.4.2-SNAPSHOT] 2020-05-15
|
||||
## [v1.0.0-SNAPSHOT] 2020-05-15
|
||||
|
||||
|
||||
|
||||
### Fixes
|
||||
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -8,7 +8,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.spatial.data</groupId>
|
||||
<artifactId>ws-thredds</artifactId>
|
||||
<version>0.2.3-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>ws-thredds</name>
|
||||
<description>prototype of WS integration with data-transfer for Thredds pubblication</description>
|
||||
|
||||
|
|
|
@ -59,14 +59,15 @@ public class Process {
|
|||
private CompletionCallback callback=null;
|
||||
|
||||
public Process(String folderId,CompletionCallback callback) throws WorkspaceInteractionException, InternalException {
|
||||
log.debug("Created Process with id {} ",processId);
|
||||
String operator=Security.getToken();
|
||||
log.debug("Created Process with id {}, operator {} ",processId,operator);
|
||||
// this.folderId=folderId;
|
||||
manager=new WorkspaceFolderManager(folderId);
|
||||
manager.lock(processId);
|
||||
SynchFolderConfiguration folderConfig=manager.getSynchConfiguration();
|
||||
|
||||
try {
|
||||
descriptor=new ProcessDescriptor(folderId, manager.getTheFolder().get().getPath(),System.currentTimeMillis(),processId,folderConfig);
|
||||
descriptor=new ProcessDescriptor(folderId, manager.getTheFolder().get().getPath(),System.currentTimeMillis(),processId,operator,folderConfig);
|
||||
}catch(Exception e) {
|
||||
throw new WorkspaceInteractionException("Unable to read path from folder "+folderId,e);
|
||||
}
|
||||
|
@ -225,7 +226,7 @@ public class Process {
|
|||
}
|
||||
|
||||
String relativePath=toScanFolder.get().getMetadata().getMap().get(Constants.WorkspaceProperties.REMOTE_PATH)+"";
|
||||
ThreddsController folderController=new ThreddsController(relativePath,config.getTargetToken());
|
||||
ThreddsController folderController=new ThreddsController(relativePath,ownerProcess.getDescriptor().getOperator());
|
||||
|
||||
RemoteFileDescriptor folderDesc=null;
|
||||
try{
|
||||
|
@ -305,7 +306,7 @@ public class Process {
|
|||
}catch(ItemNotFoundException e) {
|
||||
log.info("Creating folder {} under {} ",item,folderPath);
|
||||
folder=toScanFolder.newFolder(item, "Imported from thredds");
|
||||
WorkspaceUtils.initProperties(folder,relativePath+"/"+item , config.getFilter(), config.getTargetToken(),config.getToCreateCatalogName(),config.getValidateMetadata(),config.getRootFolderId());
|
||||
WorkspaceUtils.initProperties(folder,relativePath+"/"+item , config.getFilter(), ownerProcess.getDescriptor().getOperator(),config.getToCreateCatalogName(),config.getValidateMetadata(),config.getRootFolderId());
|
||||
generateRequests(ownerProcess, service, folder);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ public class ProcessDescriptor implements Cloneable{
|
|||
private long launchTime;
|
||||
private String processId;
|
||||
|
||||
private String operator;
|
||||
|
||||
private SynchFolderConfiguration synchConfiguration;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package org.gcube.usecases.ws.thredds.engine.impl;
|
||||
|
||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||
|
||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class Security {
|
||||
|
||||
public static String getCurrentScope(){
|
||||
try{
|
||||
String token=SecurityTokenProvider.instance.get();
|
||||
log.debug("Token is : "+token);
|
||||
if(token==null) throw new Exception("Security Token is null");
|
||||
AuthorizationEntry entry = authorizationService().get(token);
|
||||
return entry.getContext();
|
||||
}catch(Exception e ){
|
||||
log.debug("Unable to resolve token, checking scope provider..",e);
|
||||
return ScopeProvider.instance.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getContext(String token) throws ObjectNotFound, Exception {
|
||||
log.debug("Resolving token {} ",token);
|
||||
AuthorizationEntry entry = authorizationService().get(token);
|
||||
return entry.getContext();
|
||||
}
|
||||
|
||||
public static String getToken() {
|
||||
return SecurityTokenProvider.instance.get();
|
||||
}
|
||||
|
||||
|
||||
public static String getCurrentCaller(){
|
||||
try{
|
||||
String token=SecurityTokenProvider.instance.get();
|
||||
log.debug("Token is : "+token);
|
||||
if(token==null) throw new Exception("Security Token is null");
|
||||
AuthorizationEntry entry = authorizationService().get(token);
|
||||
return entry.getClientInfo().getId();
|
||||
}catch(Exception e ){
|
||||
log.debug("Unable to resolve token, checking scope provider..",e);
|
||||
return "Unidentified data-transfer user";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -138,6 +138,11 @@ public class SynchEngineImpl implements SyncEngine{
|
|||
if (!manager.isSynched()) throw new WorkspaceNotSynchedException("Folder "+folderId+" is not configured for synchronization.");
|
||||
if(manager.isLocked()) throw new WorkspaceLockedException("Folder "+folderId+"is locked by an external process.");
|
||||
if(!manager.isRoot()) throw new WorkspaceFolderNotRootException("Unable to launch synch operation. Folder "+folderId+" is not root configuration");
|
||||
|
||||
//TODO check context
|
||||
//TODO set operating context
|
||||
// if(manager.getSynchConfiguration().get)
|
||||
|
||||
Process toLaunch=new Process(folderId,completionCallback);
|
||||
localProcesses.put(folderId, toLaunch);
|
||||
initializationExecutor.submit(new ProcessInitializationThread(toLaunch,synchronizationExecutor));
|
||||
|
|
|
@ -51,9 +51,27 @@ public class WorkspaceFolderManager {
|
|||
|
||||
private StorageHubClient sc;
|
||||
|
||||
|
||||
private String operator=null;
|
||||
|
||||
private String getToken() {
|
||||
if(operator==null) {
|
||||
log.warn("******************Using config operator**********");
|
||||
return config.getTargetToken();
|
||||
}
|
||||
else return operator;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public WorkspaceFolderManager(String folderId) throws WorkspaceInteractionException {
|
||||
try{
|
||||
// ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome().getWorkspace();
|
||||
String operator=Security.getToken();
|
||||
log.debug("Setting operator "+operator);
|
||||
this.operator=operator;
|
||||
|
||||
sc=WorkspaceUtils.getClient();
|
||||
theFolder=sc.open(folderId).asFolder();
|
||||
this.folderId=folderId;
|
||||
|
@ -70,7 +88,7 @@ public class WorkspaceFolderManager {
|
|||
public ThreddsController getThreddsController() throws WorkspaceNotSynchedException, WorkspaceInteractionException, InternalException {
|
||||
if(threddsController==null) {
|
||||
SynchFolderConfiguration config=getSynchConfiguration();
|
||||
threddsController=new ThreddsController(config.getRemotePath(),config.getTargetToken());
|
||||
threddsController=new ThreddsController(config.getRemotePath(),getToken());
|
||||
}
|
||||
return threddsController;
|
||||
}
|
||||
|
@ -79,7 +97,7 @@ public class WorkspaceFolderManager {
|
|||
try {
|
||||
FolderContainer root=sc.open(getSynchConfiguration().getRootFolderId()).asFolder();
|
||||
SynchFolderConfiguration rootConfig=WorkspaceUtils.loadConfiguration(root);
|
||||
return new ThreddsController(rootConfig.getRemotePath(),rootConfig.getTargetToken());
|
||||
return new ThreddsController(rootConfig.getRemotePath(),getToken());
|
||||
}catch(StorageHubException e) {
|
||||
throw new WorkspaceInteractionException(e);
|
||||
}
|
||||
|
@ -116,7 +134,7 @@ public class WorkspaceFolderManager {
|
|||
|
||||
SynchFolderConfiguration config=getSynchConfiguration();
|
||||
try{
|
||||
checkFolder(theFolder,recursively,config,null,theFolder.getId(),WorkspaceUtils.safelyGetLastUpdate(theFolder.get()));
|
||||
checkFolder(theFolder,recursively,config,null,theFolder.getId(),WorkspaceUtils.safelyGetLastUpdate(theFolder.get()),getToken());
|
||||
return new SyncFolderDescriptor(this.folderId,this.theFolder.get().getPath(),config);
|
||||
}catch(StorageHubException e) {
|
||||
throw new WorkspaceInteractionException(e);
|
||||
|
@ -151,7 +169,7 @@ public class WorkspaceFolderManager {
|
|||
try {
|
||||
String catalogName=toSet.getToCreateCatalogName();
|
||||
|
||||
ThreddsController controller= new ThreddsController(toSet.getRemotePath(),toSet.getTargetToken());
|
||||
ThreddsController controller= new ThreddsController(toSet.getRemotePath(),getToken());
|
||||
if(!controller.existsThreddsFile(null)) {
|
||||
log.info("Folder not found, creating it..");
|
||||
controller.createEmptyFolder(null);
|
||||
|
@ -241,7 +259,7 @@ public class WorkspaceFolderManager {
|
|||
|
||||
|
||||
|
||||
private static void checkFolder(FolderContainer folder,boolean recursive, SynchFolderConfiguration rootConfig, String relativePathFromRootFolder, String rootFolderId,Date lastUpdatedRoutine) throws StorageHubException, InternalException {
|
||||
private static void checkFolder(FolderContainer folder,boolean recursive, SynchFolderConfiguration rootConfig, String relativePathFromRootFolder, String rootFolderId,Date lastUpdatedRoutine, String toUseToken) throws StorageHubException, InternalException {
|
||||
// Check folder configuration
|
||||
log.trace("Checking folder {} ",folder.get().getPath());
|
||||
log.debug("Configuration is {}, relativePath is {} ",rootConfig,relativePathFromRootFolder);
|
||||
|
@ -252,7 +270,7 @@ public class WorkspaceFolderManager {
|
|||
|
||||
|
||||
|
||||
ThreddsController controller=new ThreddsController(currentRemotePath, rootConfig.getTargetToken());
|
||||
ThreddsController controller=new ThreddsController(currentRemotePath, toUseToken);
|
||||
|
||||
|
||||
HashSet<String> currentFolderExistingItem=new HashSet<String>();
|
||||
|
@ -269,7 +287,7 @@ public class WorkspaceFolderManager {
|
|||
String itemRemotePath=currentRemotePath+"/"+itemName;
|
||||
if(item.getType().equals(ContainerType.FOLDER)) {
|
||||
if(recursive)
|
||||
checkFolder((FolderContainer) item,recursive,rootConfig,itemRelativePath,rootFolderId,lastUpdatedRoutine);
|
||||
checkFolder((FolderContainer) item,recursive,rootConfig,itemRelativePath,rootFolderId,lastUpdatedRoutine,toUseToken);
|
||||
else WorkspaceUtils.initProperties(item, itemRemotePath, rootConfig.getFilter(), rootConfig.getTargetToken(),rootConfig.getToCreateCatalogName(),rootConfig.getValidateMetadata(),rootFolderId);
|
||||
}else if(rootConfig.matchesFilter(itemName)) {
|
||||
if(!WorkspaceUtils.isConfigured(item.get()))
|
||||
|
|
|
@ -73,7 +73,7 @@ public class SynchronizationThread implements Runnable {
|
|||
FolderContainer parentFolder=client.open(parentFolderItem.getId()).asFolder();
|
||||
checkCancelledProcess();
|
||||
SynchFolderConfiguration synchConfig=WorkspaceUtils.loadConfiguration(parentFolder);
|
||||
ThreddsController controller=new ThreddsController(synchConfig.getRemotePath(), synchConfig.getTargetToken());
|
||||
ThreddsController controller=new ThreddsController(synchConfig.getRemotePath(), theRequest.getProcess().getDescriptor().getOperator());
|
||||
|
||||
if(theRequest instanceof TransferToThreddsRequest) {
|
||||
TransferToThreddsRequest request=(TransferToThreddsRequest) theRequest;
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.gcube.usecases.ws.thredds.faults;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class GenericWebException extends Exception{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5200927893712698886L;
|
||||
|
||||
private String remoteMessage=null;
|
||||
|
||||
private Integer responseHTTPCode=0;
|
||||
|
||||
public GenericWebException() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public GenericWebException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public GenericWebException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public GenericWebException(String message) {
|
||||
super(message);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public GenericWebException(Throwable cause) {
|
||||
super(cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue