test on container added
This commit is contained in:
parent
d0a7197c5c
commit
3a7aa8b8e3
|
@ -0,0 +1,3 @@
|
||||||
|
nodeType to remove on new import from a backup:
|
||||||
|
externalUrl
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[node]
|
[node]
|
||||||
mode = online
|
mode = offline
|
||||||
hostname = dlib29.isti.cnr.it
|
hostname = dlib29.isti.cnr.it
|
||||||
protocol= http
|
protocol= http
|
||||||
port = 8080
|
port = 8080
|
||||||
|
@ -13,12 +13,7 @@ SmartGearsDistributionBundle = UnBundled
|
||||||
|
|
||||||
[site]
|
[site]
|
||||||
country = it
|
country = it
|
||||||
location = rome
|
location = pisa
|
||||||
|
|
||||||
[proxy]
|
|
||||||
protocol = https
|
|
||||||
hostname = workspace-repository.dev.d4science.org
|
|
||||||
port = 443
|
|
||||||
|
|
||||||
[authorization]
|
[authorization]
|
||||||
factory = org.gcube.smartgears.security.defaults.DefaultAuthorizationProviderFactory
|
factory = org.gcube.smartgears.security.defaults.DefaultAuthorizationProviderFactory
|
||||||
|
|
|
@ -1,62 +1,11 @@
|
||||||
<configuration scan="true" debug="false">
|
<configuration scan="true" debug="false">
|
||||||
|
|
||||||
<appender name="FILE"
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>/smartgears-distribution/ghn.log</file>
|
|
||||||
<append>true</append>
|
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
</pattern>
|
|
||||||
</encoder>
|
</encoder>
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<fileNamePattern>/smartgears-distribution/ghn.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<maxHistory>30</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<appender name="ACCOUNT_FILE"
|
|
||||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>/smartgears-distribution/accounting.log</file>
|
|
||||||
<append>true</append>
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n
|
|
||||||
</pattern>
|
|
||||||
</encoder>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<fileNamePattern>/smartgears-distribution/accounting.%d{yyyy-MM-dd}.log
|
|
||||||
</fileNamePattern>
|
|
||||||
<maxHistory>30</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="ACCESS_FILE"
|
|
||||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>/smartgears-distribution/access.log</file>
|
|
||||||
<append>true</append>
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n
|
|
||||||
</pattern>
|
|
||||||
</encoder>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<fileNamePattern>/smartgears-distribution/access.%d{yyyy-MM-dd}.log
|
|
||||||
</fileNamePattern>
|
|
||||||
<maxHistory>30</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
|
|
||||||
<logger name="org.gcube.data.publishing" level="ERROR">
|
|
||||||
<appender-ref ref="ACCOUNT_FILE" />
|
|
||||||
</logger>
|
|
||||||
<logger name="org.gcube.documentstore" level="ERROR">
|
|
||||||
<appender-ref ref="ACCOUNT_FILE" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<logger name="org.gcube.smartgears.handlers.application.request"
|
|
||||||
level="INFO">
|
|
||||||
<appender-ref ref="ACCESS_FILE" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<logger name="org.gcube" level="INFO" />
|
<logger name="org.gcube" level="INFO" />
|
||||||
<logger name="org.gcube.smartgears" level="TRACE" />
|
<logger name="org.gcube.smartgears" level="TRACE" />
|
||||||
<logger name="org.gcube.smartgears.handlers" level="TRACE"/>
|
<logger name="org.gcube.smartgears.handlers" level="TRACE"/>
|
||||||
|
@ -67,6 +16,6 @@
|
||||||
<logger name="org.gcube.data.access" level="TRACE" />
|
<logger name="org.gcube.data.access" level="TRACE" />
|
||||||
|
|
||||||
<root level="WARN">
|
<root level="WARN">
|
||||||
<appender-ref ref="FILE" />
|
<appender-ref ref="STDOUT" />
|
||||||
</root>
|
</root>
|
||||||
</configuration>
|
</configuration>
|
|
@ -3,7 +3,7 @@ default.key=SHUBTEST
|
||||||
default.secret=wJalrXUtnFEMI/K7MDENG/bPxRfiCY
|
default.secret=wJalrXUtnFEMI/K7MDENG/bPxRfiCY
|
||||||
default.url=https://localhost:9000/
|
default.url=https://localhost:9000/
|
||||||
default.createBucket=true
|
default.createBucket=true
|
||||||
volatile.bucketName=storagehub-dev
|
volatile.bucketName=storagehub-volatile-dev
|
||||||
volatile.key=SHUBTEST
|
volatile.key=SHUBTEST
|
||||||
volatile.secret=wJalrXUtnFEMI/K7MDENG/bPxRfiCY
|
volatile.secret=wJalrXUtnFEMI/K7MDENG/bPxRfiCY
|
||||||
volatile.url=https://localhost:9000/
|
volatile.url=https://localhost:9000/
|
||||||
|
|
|
@ -41,10 +41,11 @@ public class ClassHandler {
|
||||||
Set<Class<?>> classesAnnotated = reflection.getTypesAnnotatedWith(RootNode.class);
|
Set<Class<?>> classesAnnotated = reflection.getTypesAnnotatedWith(RootNode.class);
|
||||||
for (Class<?> clazz: classesAnnotated ){
|
for (Class<?> clazz: classesAnnotated ){
|
||||||
if (RootItem.class.isAssignableFrom(clazz) && clazz.isAnnotationPresent(RootNode.class)) {
|
if (RootItem.class.isAssignableFrom(clazz) && clazz.isAnnotationPresent(RootNode.class)) {
|
||||||
String value = clazz.getAnnotation(RootNode.class).value();
|
String[] values = clazz.getAnnotation(RootNode.class).value();
|
||||||
log.debug("loading class {} with value {} ", clazz, value );
|
log.debug("loading class {} with values {} ", clazz, values );
|
||||||
|
for (String value: values)
|
||||||
classMap.put(value, (Class<? extends RootItem>) clazz);
|
classMap.put(value, (Class<? extends RootItem>) clazz);
|
||||||
typeMap.put((Class<? extends RootItem>) clazz, value);
|
typeMap.put((Class<? extends RootItem>) clazz, values[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,14 +41,19 @@ public class GroupHandler {
|
||||||
String folderName = group.getPrincipal().getName();
|
String folderName = group.getPrincipal().getName();
|
||||||
Node folder = getFolderNodeRelatedToGroup(session, folderName);
|
Node folder = getFolderNodeRelatedToGroup(session, folderName);
|
||||||
|
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
NodeIterator ni = folder.getSharedSet();
|
NodeIterator ni = folder.getSharedSet();
|
||||||
while (ni.hasNext()) {
|
while (ni.hasNext()) {
|
||||||
Node node = ni.nextNode();
|
Node node = ni.nextNode();
|
||||||
if (node.getPath().startsWith(pathUtil.getWorkspacePath(user.getPrincipal().getName()).toPath())) {
|
if (node.getPath().startsWith(pathUtil.getVREsPath(userId, session).toPath())) {
|
||||||
node.removeShare();
|
node.removeShare();
|
||||||
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!found)
|
||||||
|
log.warn("sharing not removed for user {} ",userId);
|
||||||
|
|
||||||
return group.removeMember(user);
|
return group.removeMember(user);
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,8 @@ public class Item2NodeConverter {
|
||||||
public <F extends AbstractFileItem> void replaceContent(Node node, F item, ItemAction action){
|
public <F extends AbstractFileItem> void replaceContent(Node node, F item, ItemAction action){
|
||||||
try {
|
try {
|
||||||
|
|
||||||
node.setPrimaryType(item.getClass().getAnnotation(RootNode.class).value());
|
String primaryType = item.getClass().getAnnotation(RootNode.class).value()[0];
|
||||||
|
node.setPrimaryType(primaryType);
|
||||||
Node contentNode = node.getNode(NodeConstants.CONTENT_NAME);
|
Node contentNode = node.getNode(NodeConstants.CONTENT_NAME);
|
||||||
contentNode.setPrimaryType(item.getContent().getClass().getAnnotation(AttributeRootNode.class).value());
|
contentNode.setPrimaryType(item.getContent().getClass().getAnnotation(AttributeRootNode.class).value());
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,10 @@ import java.util.UUID;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.jcr.Node;
|
import javax.jcr.Node;
|
||||||
|
import javax.jcr.Session;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.DefaultValue;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
@ -79,7 +81,8 @@ public class ScriptManager {
|
||||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public ScriptStatus run( @FormDataParam("name") String name,
|
public ScriptStatus run( @FormDataParam("name") String name,
|
||||||
@FormDataParam("asynch") Boolean asynch,
|
@FormDataParam("asynch") @DefaultValue("false") Boolean asynch,
|
||||||
|
@FormDataParam("writeResult") @DefaultValue("false") Boolean writeResult ,
|
||||||
@FormDataParam("destinationFolderId") String destinationFolderId,
|
@FormDataParam("destinationFolderId") String destinationFolderId,
|
||||||
@FormDataParam("file") InputStream stream,
|
@FormDataParam("file") InputStream stream,
|
||||||
@FormDataParam("file") FormDataContentDisposition fileDetail) {
|
@FormDataParam("file") FormDataContentDisposition fileDetail) {
|
||||||
|
@ -87,7 +90,7 @@ public class ScriptManager {
|
||||||
InnerMethodName.instance.set("executeScript");
|
InnerMethodName.instance.set("executeScript");
|
||||||
ScriptClassLoader scriptClassLoader = new ScriptClassLoader(Thread.currentThread().getContextClassLoader());
|
ScriptClassLoader scriptClassLoader = new ScriptClassLoader(Thread.currentThread().getContextClassLoader());
|
||||||
Class<?> scriptClass = uploadClass(stream, scriptClassLoader, fileDetail.getFileName().replace(".class", ""));
|
Class<?> scriptClass = uploadClass(stream, scriptClassLoader, fileDetail.getFileName().replace(".class", ""));
|
||||||
return run(scriptClass, name, destinationFolderId, asynch!=null? asynch : false);
|
return internalRun(scriptClass, name, destinationFolderId, asynch, writeResult);
|
||||||
}catch(Throwable e) {
|
}catch(Throwable e) {
|
||||||
log.error("error executing script {}", name,e);
|
log.error("error executing script {}", name,e);
|
||||||
throw new WebApplicationException("error loading class",e);
|
throw new WebApplicationException("error loading class",e);
|
||||||
|
@ -125,16 +128,27 @@ public class ScriptManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScriptStatus run(Class<?> clazz, String name, String destinationFolderId, boolean asynch) throws Throwable {
|
private ScriptStatus internalRun(Class<?> clazz, String name, String destinationFolderId, boolean asynch, boolean writeResult) throws Throwable {
|
||||||
String login = SecretManagerProvider.instance.get().getOwner().getId();
|
String login = SecretManagerProvider.instance.get().getOwner().getId();
|
||||||
log.info("script {} called by {}", clazz.getSimpleName(), login);
|
log.info("script {} called by {}", clazz.getSimpleName(), login);
|
||||||
JackrabbitSession ses = null;
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
String resultPath= null;
|
||||||
|
Node parentNode = null;
|
||||||
|
|
||||||
|
if (writeResult) {
|
||||||
|
JackrabbitSession ses = null;
|
||||||
try {
|
try {
|
||||||
ses = (JackrabbitSession) repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
ses = (JackrabbitSession) repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
||||||
|
|
||||||
String parentId = destinationFolderId!=null ? destinationFolderId : ses.getNode(pathUtil.getWorkspacePath(login).toPath()).getIdentifier();
|
String parentId = destinationFolderId!=null ? destinationFolderId : ses.getNode(pathUtil.getWorkspacePath(login).toPath()).getIdentifier();
|
||||||
Node parentNode = ses.getNodeByIdentifier(parentId);
|
parentNode = ses.getNodeByIdentifier(parentId);
|
||||||
|
resultPath = Paths.append(Paths.getPath(parentNode.getPath()), name).toPath();
|
||||||
|
}finally {
|
||||||
|
if (ses!=null)
|
||||||
|
ses.logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (AbstractScript.class.isAssignableFrom(clazz)) {
|
if (AbstractScript.class.isAssignableFrom(clazz)) {
|
||||||
AbstractScript scriptInstance = (AbstractScript) clazz.newInstance();
|
AbstractScript scriptInstance = (AbstractScript) clazz.newInstance();
|
||||||
|
@ -142,11 +156,11 @@ public class ScriptManager {
|
||||||
ApplicationContext appContext = ContextProvider.get();
|
ApplicationContext appContext = ContextProvider.get();
|
||||||
String serverHost = appContext.container().configuration().hostname();
|
String serverHost = appContext.container().configuration().hostname();
|
||||||
|
|
||||||
String resultPath = Paths.append(Paths.getPath(parentNode.getPath()), name).toPath();
|
|
||||||
String runningId = UUID.randomUUID().toString();
|
String runningId = UUID.randomUUID().toString();
|
||||||
ScriptStatus status = new ScriptStatus(runningId, resultPath, serverHost);
|
ScriptStatus status = new ScriptStatus(runningId, resultPath, serverHost);
|
||||||
|
|
||||||
RealRun realRun = new RealRun(ses, scriptInstance, login, parentNode, name, true, status);
|
RealRun realRun = new RealRun(scriptInstance, login, parentNode, name, writeResult, status);
|
||||||
if (asynch) {
|
if (asynch) {
|
||||||
scriptStatusMap.put(runningId, status);
|
scriptStatusMap.put(runningId, status);
|
||||||
new Thread(AuthorizedTasks.bind(realRun)).start();
|
new Thread(AuthorizedTasks.bind(realRun)).start();
|
||||||
|
@ -161,8 +175,6 @@ public class ScriptManager {
|
||||||
|
|
||||||
|
|
||||||
}catch (Throwable e) {
|
}catch (Throwable e) {
|
||||||
if (ses !=null && ses.isLive())
|
|
||||||
ses.logout();
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +184,6 @@ public class ScriptManager {
|
||||||
|
|
||||||
class RealRun implements Runnable{
|
class RealRun implements Runnable{
|
||||||
|
|
||||||
private JackrabbitSession ses;
|
|
||||||
AbstractScript instance;
|
AbstractScript instance;
|
||||||
String login;
|
String login;
|
||||||
Node parentNode;
|
Node parentNode;
|
||||||
|
@ -180,9 +191,8 @@ public class ScriptManager {
|
||||||
boolean writeResult = true;
|
boolean writeResult = true;
|
||||||
ScriptStatus status;
|
ScriptStatus status;
|
||||||
|
|
||||||
public RealRun(JackrabbitSession ses, AbstractScript instance, String login, Node parentNode, String name, boolean writeResult, ScriptStatus status) {
|
public RealRun(AbstractScript instance, String login, Node parentNode, String name, boolean writeResult, ScriptStatus status) {
|
||||||
super();
|
super();
|
||||||
this.ses = ses;
|
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
this.login = login;
|
this.login = login;
|
||||||
this.parentNode = parentNode;
|
this.parentNode = parentNode;
|
||||||
|
@ -194,10 +204,12 @@ public class ScriptManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try{
|
|
||||||
String result ="";
|
String result ="";
|
||||||
try {
|
try {
|
||||||
result = instance.run(ses, null, scriptUtil);
|
JackrabbitSession executeSession = null;
|
||||||
|
try {
|
||||||
|
executeSession = (JackrabbitSession) repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
||||||
|
result = instance.run(executeSession, null, scriptUtil);
|
||||||
status.setSuccess();
|
status.setSuccess();
|
||||||
}catch(Throwable t) {
|
}catch(Throwable t) {
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
|
@ -206,23 +218,30 @@ public class ScriptManager {
|
||||||
status.setFailed(sw.toString());
|
status.setFailed(sw.toString());
|
||||||
result+= "\n"+sw.toString();
|
result+= "\n"+sw.toString();
|
||||||
log.warn("error executing script {}",instance.getClass().getSimpleName(), t);
|
log.warn("error executing script {}",instance.getClass().getSimpleName(), t);
|
||||||
|
}finally {
|
||||||
|
if (executeSession !=null && executeSession.isLive())
|
||||||
|
executeSession.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.writeResult) {
|
||||||
|
Session writeSession = null;
|
||||||
try( InputStream stream = new ByteArrayInputStream(result.getBytes())){
|
try( InputStream stream = new ByteArrayInputStream(result.getBytes())){
|
||||||
|
writeSession = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
||||||
ItemsParameterBuilder<FileCreationParameters> builder = FileCreationParameters.builder().name(name).description("result of script execution "+name)
|
ItemsParameterBuilder<FileCreationParameters> builder = FileCreationParameters.builder().name(name).description("result of script execution "+name)
|
||||||
.stream(stream).on(parentNode.getIdentifier()).with(ses).author(login);
|
.stream(stream).on(parentNode.getIdentifier()).with(writeSession).author(login);
|
||||||
itemHandler.create(builder.build());
|
itemHandler.create(builder.build());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("error saving script result {} in the Workspace",name, e);
|
log.error("error saving script result {} in the Workspace",name, e);
|
||||||
}
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (ses!=null)
|
if (writeSession!=null)
|
||||||
ses.logout();
|
writeSession.logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
log.error("unexpected error executing script {}",instance.getClass().getSimpleName(),e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ScriptClassLoader extends ClassLoader{
|
class ScriptClassLoader extends ClassLoader{
|
||||||
|
@ -237,3 +256,6 @@ public class ScriptManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
[nthl:readersSet] > nt:base
|
[nthl:readersSet] > nt:base
|
||||||
+ * (nthl:accountingEntryRead)
|
+ * (nthl:accountingEntryRead)
|
||||||
|
|
||||||
[nthl:workspaceItem] > mix:referenceable, mix:title, mix:lastModified, nt:hierarchyNode, mix:lockable
|
[nthl:workspaceItem] > mix:referenceable, mix:title, mix:lastModified, nt:hierarchyNode, mix:lockable, mix:shareable
|
||||||
- hl:portalLogin (String)
|
- hl:portalLogin (String)
|
||||||
- hl:lastAction (String) mandatory
|
- hl:lastAction (String) mandatory
|
||||||
- hl:oldRemotePath (String)
|
- hl:oldRemotePath (String)
|
||||||
|
@ -165,20 +165,6 @@
|
||||||
+ * (nthl:itemSentRequest)
|
+ * (nthl:itemSentRequest)
|
||||||
= nthl:itemSentRequest
|
= nthl:itemSentRequest
|
||||||
|
|
||||||
[nthl:folderBulkCreator] > nt:base
|
|
||||||
- hl:folderId (String) mandatory
|
|
||||||
- hl:status (Long)
|
|
||||||
= '0'
|
|
||||||
mandatory autocreated
|
|
||||||
- hl:failures (Long)
|
|
||||||
= '0'
|
|
||||||
mandatory autocreated
|
|
||||||
- hl:requests (Long) mandatory
|
|
||||||
|
|
||||||
[nthl:rootFolderBulkCreator] > nt:folder
|
|
||||||
+ * (nthl:folderBulkCreator)
|
|
||||||
= nthl:folderBulkCreator
|
|
||||||
|
|
||||||
[nthl:workspaceLeafItemContent] > nt:base
|
[nthl:workspaceLeafItemContent] > nt:base
|
||||||
|
|
||||||
[nthl:payloadBackend] > nt:base
|
[nthl:payloadBackend] > nt:base
|
||||||
|
@ -187,7 +173,7 @@
|
||||||
= nt:unstructured
|
= nt:unstructured
|
||||||
autocreated
|
autocreated
|
||||||
|
|
||||||
[nthl:file] > nt:resource
|
[nthl:file] > nt:resource , mix:versionable
|
||||||
- hl:size (long)
|
- hl:size (long)
|
||||||
- hl:remotePath (String)
|
- hl:remotePath (String)
|
||||||
- hl:storageId (String)
|
- hl:storageId (String)
|
||||||
|
@ -218,6 +204,84 @@
|
||||||
- hl:title (string)
|
- hl:title (string)
|
||||||
- hl:producer (string)
|
- hl:producer (string)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[nthl:externalFile] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:externalImage] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:externalPdf] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:externalLink] > nthl:workspaceLeafItem
|
||||||
|
- hl:value (String) mandatory
|
||||||
|
|
||||||
|
// DUPLICATED, MUST BE CLEANED
|
||||||
|
[nthl:ExternalLink] > nthl:workspaceLeafItem
|
||||||
|
- hl:value (String) mandatory
|
||||||
|
|
||||||
|
[nthl:gCubeItem] > nthl:workspaceItem
|
||||||
|
- hl:scopes (String) mandatory multiple
|
||||||
|
- hl:creator (String) mandatory
|
||||||
|
- hl:itemType (String) mandatory
|
||||||
|
- hl:properties (String)
|
||||||
|
- hl:isShared (Boolean)
|
||||||
|
- hl:sharedRootId (String)
|
||||||
|
+ hl:property (nt:unstructured)
|
||||||
|
= nt:unstructured
|
||||||
|
autocreated
|
||||||
|
|
||||||
|
[nthl:trashItem] > nthl:workspaceItem
|
||||||
|
- hl:name (String)
|
||||||
|
- hl:deletedBy (String)
|
||||||
|
- hl:originalParentId (String)
|
||||||
|
- hl:deletedFrom (String)
|
||||||
|
- hl:deletedTime (Date)
|
||||||
|
- hl:mimeType (String)
|
||||||
|
- hl:length (String)
|
||||||
|
- hl:isFolder (Boolean)
|
||||||
|
|
||||||
|
+ * (nthl:workspaceItem)
|
||||||
|
|
||||||
|
|
||||||
|
// TO REMOVE
|
||||||
|
[nthl:externalUrl] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:query] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:aquamapsItem] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:timeSeriesItem] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:report] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:reportTemplate] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:workflowReport] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:workflowTemplate] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:gCubeMetadata] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:gCubeDocument] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:gCubeDocumentLink] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:gCubeImageDocumentLink] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:gCubePDFDocumentLink] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:gCubeImageDocument] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:gCubePDFDocument] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:gCubeURLDocument] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:gCubeAnnotation] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:externalResourceLink] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
|
[nthl:tabularDataLink] > nthl:workspaceLeafItem
|
||||||
|
|
||||||
[nthl:documentAlternativeLink] > nt:base
|
[nthl:documentAlternativeLink] > nt:base
|
||||||
- hl:parentUri (String) mandatory
|
- hl:parentUri (String) mandatory
|
||||||
- hl:uri (String) mandatory
|
- hl:uri (String) mandatory
|
||||||
|
@ -317,69 +381,17 @@
|
||||||
- hl:query (String) mandatory
|
- hl:query (String) mandatory
|
||||||
- hl:folderId (String)
|
- hl:folderId (String)
|
||||||
|
|
||||||
[nthl:externalFile] > nthl:workspaceLeafItem
|
[nthl:folderBulkCreator] > nt:base
|
||||||
|
- hl:folderId (String) mandatory
|
||||||
|
- hl:status (Long)
|
||||||
|
= '0'
|
||||||
|
mandatory autocreated
|
||||||
|
- hl:failures (Long)
|
||||||
|
= '0'
|
||||||
|
mandatory autocreated
|
||||||
|
- hl:requests (Long) mandatory
|
||||||
|
|
||||||
[nthl:externalImage] > nthl:workspaceLeafItem
|
[nthl:rootFolderBulkCreator] > nt:folder
|
||||||
|
+ * (nthl:folderBulkCreator)
|
||||||
|
= nthl:folderBulkCreator
|
||||||
|
|
||||||
[nthl:externalPdf] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:externalUrl] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:query] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:aquamapsItem] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:timeSeriesItem] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:report] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:reportTemplate] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:workflowReport] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:workflowTemplate] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:gCubeMetadata] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:gCubeDocument] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:gCubeDocumentLink] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:gCubeImageDocumentLink] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:gCubePDFDocumentLink] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:gCubeImageDocument] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:gCubePDFDocument] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:gCubeURLDocument] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:gCubeAnnotation] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:externalResourceLink] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:tabularDataLink] > nthl:workspaceLeafItem
|
|
||||||
|
|
||||||
[nthl:gCubeItem] > nthl:workspaceItem
|
|
||||||
- hl:scopes (String) mandatory multiple
|
|
||||||
- hl:creator (String) mandatory
|
|
||||||
- hl:itemType (String) mandatory
|
|
||||||
- hl:properties (String)
|
|
||||||
- hl:isShared (Boolean)
|
|
||||||
- hl:sharedRootId (String)
|
|
||||||
+ hl:property (nt:unstructured)
|
|
||||||
= nt:unstructured
|
|
||||||
autocreated
|
|
||||||
|
|
||||||
[nthl:trashItem] > nthl:workspaceItem
|
|
||||||
- hl:name (String)
|
|
||||||
- hl:deletedBy (String)
|
|
||||||
- hl:originalParentId (String)
|
|
||||||
- hl:deletedFrom (String)
|
|
||||||
- hl:deletedTime (Date)
|
|
||||||
- hl:mimeType (String)
|
|
||||||
- hl:length (String)
|
|
||||||
- hl:isFolder (Boolean)
|
|
||||||
|
|
||||||
+ * (nthl:workspaceItem)
|
|
|
@ -1,11 +1,24 @@
|
||||||
package org.gcube.data.access.fs.external;
|
package org.gcube.data.access.fs.external;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||||
import org.gcube.common.security.secrets.CredentialSecret;
|
import org.gcube.common.security.secrets.CredentialSecret;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
||||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||||
|
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||||
|
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||||
|
import org.gcube.common.storagehub.model.items.SharedFolder;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -17,8 +30,13 @@ public class CreateUsers {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(CreateUsers.class);
|
private static Logger log = LoggerFactory.getLogger(CreateUsers.class);
|
||||||
|
|
||||||
|
private String user ="lucio.lelii";
|
||||||
|
private String user2 ="pippo.test";
|
||||||
|
private String vreWA ="vre-write-all";
|
||||||
|
private String vreRO ="vre-read-only";
|
||||||
|
private String vreWO ="vre-write-owner";
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
public static void before() throws Exception{
|
public static void before() throws Exception{
|
||||||
String address = "localhost";
|
String address = "localhost";
|
||||||
int port = 8081;
|
int port = 8081;
|
||||||
|
@ -26,17 +44,157 @@ public class CreateUsers {
|
||||||
client = new StorageHubClient(storagehubUri);
|
client = new StorageHubClient(storagehubUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Before
|
||||||
public void setSecret() {
|
public void setSecret() {
|
||||||
CredentialSecret secret = new CredentialSecret("sg4-test-client", "a156a7db-3b32-4cd5-b27b-2488e0e01698", "/gcube");
|
CredentialSecret secret = new CredentialSecret("sg4-test-client", "a156a7db-3b32-4cd5-b27b-2488e0e01698", "/gcube");
|
||||||
SecretManagerProvider.instance.set(secret);
|
SecretManagerProvider.instance.set(secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createAccountforManging() throws Exception{
|
||||||
|
client.createUserAccount("service-account-sg4-test-client");
|
||||||
|
client.getVreFolderManager(vreWA).addUser("service-account-sg4-test-client");
|
||||||
|
client.getVreFolderManager(vreRO).addUser("service-account-sg4-test-client");
|
||||||
|
client.getVreFolderManager(vreWO).addUser("service-account-sg4-test-client");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getUserRootId() throws Exception{
|
||||||
|
client.impersonate(user);
|
||||||
|
System.out.println(client.getWSRoot().getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getBearerToken() {
|
||||||
|
System.out.println(SecretManagerProvider.instance.get().getHTTPAuthorizationHeaders());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createUser() throws Exception{
|
public void createUser() throws Exception{
|
||||||
|
client.createUserAccount(user);
|
||||||
|
}
|
||||||
|
|
||||||
//client.createUserAccount("lucio.lelii");
|
@Test
|
||||||
client.impersonate("lucio.lelii");
|
public void removeUserFromGroup() throws Exception{
|
||||||
client.getWSRoot();
|
client.getVreFolderManager(vreWA).removeAdmin(user);
|
||||||
|
client.getVreFolderManager(vreWA).removeUser(user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addUserToVREs() throws Exception{
|
||||||
|
client.getVreFolderManager(vreWA).createVRE(AccessType.WRITE_ALL, user);
|
||||||
|
client.getVreFolderManager(vreWA).setAdmin(user);
|
||||||
|
client.getVreFolderManager(vreRO).createVRE(AccessType.READ_ONLY, user);
|
||||||
|
client.getVreFolderManager(vreRO).setAdmin(user);
|
||||||
|
client.getVreFolderManager(vreWO).createVRE(AccessType.WRITE_OWNER, user);
|
||||||
|
client.getVreFolderManager(vreWO).setAdmin(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createUser2() throws Exception{
|
||||||
|
client.impersonate(user);
|
||||||
|
client.createUserAccount(user2);
|
||||||
|
client.getVreFolderManager(vreWA).addUser(user2);
|
||||||
|
client.getVreFolderManager(vreRO).addUser(user2);
|
||||||
|
client.getVreFolderManager(vreWO).addUser(user2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void printVREFoldersAdmin() throws StorageHubException{
|
||||||
|
List<FolderContainer> vreFolders = client.getVREFolders().getContainers().stream().map(c -> ((FolderContainer) c)).collect(Collectors.toList());
|
||||||
|
for (FolderContainer fc : vreFolders) {
|
||||||
|
System.out.println(fc.get().getTitle());
|
||||||
|
System.out.println(fc.getAcls());
|
||||||
|
System.out.println(client.getVreFolderManager(fc.get().getTitle()).getAdmins());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getVREs() throws Exception{
|
||||||
|
client.impersonate(user);
|
||||||
|
client.getVREFolders().getItems().stream().map(i -> ((SharedFolder) i)).forEach(s -> System.out.println(s.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWsRoot() throws Exception{
|
||||||
|
client.impersonate(user);
|
||||||
|
client.getWSRoot().list().getItems().forEach(i -> System.out.println(i.getId()+" "+i.getTitle()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void download() throws Exception{
|
||||||
|
client.impersonate(user);
|
||||||
|
try ( InputStream is = client.open("5b5236d2-ec88-49f2-a2c5-04ecf8284191").asFile().download().getStream()){
|
||||||
|
String text = new BufferedReader(
|
||||||
|
new InputStreamReader(is, StandardCharsets.UTF_8))
|
||||||
|
.lines()
|
||||||
|
.collect(Collectors.joining("\n"));
|
||||||
|
System.out.println(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void uploadFile() {
|
||||||
|
client.impersonate(user);
|
||||||
|
try (InputStream is = CreateUsers.class.getResourceAsStream("/test1.jpg")){
|
||||||
|
client.getWSRoot().uploadFile(is, "test1.jpg", "a test");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private FolderContainer retrieveVREbyName(String name) throws StorageHubException {
|
||||||
|
List<FolderContainer> vreFolders = client.getVREFolders().getContainers().stream().map(c -> ((FolderContainer) c)).collect(Collectors.toList());
|
||||||
|
return vreFolders.stream().filter(c -> ((SharedFolder)c.get()).getDisplayName().equals(name)).findFirst().get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void uploadFileToVREWriteAll() throws StorageHubException{
|
||||||
|
client.impersonate(user2);
|
||||||
|
try (InputStream is = CreateUsers.class.getResourceAsStream("/test1.jpg")){
|
||||||
|
retrieveVREbyName(vreWA).uploadFile(is, "test1.jpg", "a test");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = StorageHubException.class)
|
||||||
|
public void uploadFileToVREReadOnly() throws StorageHubException{
|
||||||
|
client.impersonate(user2);
|
||||||
|
try (InputStream is = CreateUsers.class.getResourceAsStream("/test1.jpg")){
|
||||||
|
retrieveVREbyName(vreRO).uploadFile(is, "test1.jpg", "a test");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void uploadFileToVREReadOnlyAdmin() throws StorageHubException{
|
||||||
|
client.impersonate(user);
|
||||||
|
try (InputStream is = CreateUsers.class.getResourceAsStream("/test1.jpg")){
|
||||||
|
retrieveVREbyName(vreRO).uploadFile(is, "test1.jpg", "a test");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void uploadFileToVREWriteOwner() throws StorageHubException{
|
||||||
|
client.impersonate(user2);
|
||||||
|
try (InputStream is = CreateUsers.class.getResourceAsStream("/test1.jpg")){
|
||||||
|
retrieveVREbyName(vreWO).uploadFile(is, "test1.jpg", "a test");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void removeUser() throws Exception{
|
||||||
|
client.deleteUserAccount(user);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 65 KiB |
Loading…
Reference in New Issue