update
This commit is contained in:
parent
7aff397939
commit
74b78a1e5d
|
@ -16,7 +16,6 @@
|
|||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
|
|
|
@ -4,8 +4,9 @@ public class Constants {
|
|||
|
||||
public static final String enchriptedPrefix = "E_";
|
||||
public static final String versionPrefix = "_v";
|
||||
public static final String mongoStorageConstant = "gcube-mongo";
|
||||
public static final String MONGO_STORAGE = "gcube-mongo";
|
||||
|
||||
public static final String s3StorageConstant = "gcube-s3";
|
||||
public static final String DEFAULT_MINIO_STORAGE = "default-gcube-minio";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,11 +9,13 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class Metadata {
|
||||
|
||||
@MapAttribute(excludeStartWith="jcr:")
|
||||
|
|
|
@ -44,5 +44,5 @@ public class NodeConstants {
|
|||
public static final String OWNERNODETYPE = "nthl:user";
|
||||
public static final String GENERICFILETYPE = "nthl:externalFile";
|
||||
public static final String CONTENTFILETYPE = "nthl:file";
|
||||
public static final String PAYLOADBACKENDTYPE = "nthl:payloadbackend";
|
||||
public static final String PAYLOADBACKENDTYPE = "nthl:payloadBackend";
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@ package org.gcube.common.storagehub.model.items;
|
|||
|
||||
import static org.gcube.common.storagehub.model.NodeConstants.PAYLOADBACKEND;
|
||||
|
||||
import org.gcube.common.storagehub.model.annotations.Attribute;
|
||||
import org.gcube.common.storagehub.model.Constants;
|
||||
import org.gcube.common.storagehub.model.annotations.NodeAttribute;
|
||||
import org.gcube.common.storagehub.model.annotations.RootNode;
|
||||
import org.gcube.common.storagehub.model.items.nodes.PayloadBackend;
|
||||
|
||||
|
@ -16,7 +17,7 @@ import lombok.Setter;
|
|||
@RootNode("nthl:workspaceItem")
|
||||
public class FolderItem extends Item {
|
||||
|
||||
@Attribute(PAYLOADBACKEND)
|
||||
PayloadBackend backend;
|
||||
@NodeAttribute(value= PAYLOADBACKEND)
|
||||
PayloadBackend backend = new PayloadBackend(Constants.DEFAULT_MINIO_STORAGE, null);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,20 +7,24 @@ import static org.gcube.common.storagehub.model.NodeConstants.CONTENTID;
|
|||
import static org.gcube.common.storagehub.model.NodeConstants.CONTENTMYMETYPE;
|
||||
import static org.gcube.common.storagehub.model.NodeConstants.CONTENTREMOTEPATH;
|
||||
import static org.gcube.common.storagehub.model.NodeConstants.CONTENTSIZE;
|
||||
import static org.gcube.common.storagehub.model.NodeConstants.STORAGENAME;
|
||||
import static org.gcube.common.storagehub.model.NodeConstants.PAYLOADBACKEND;
|
||||
|
||||
import org.gcube.common.storagehub.model.Constants;
|
||||
import org.gcube.common.storagehub.model.annotations.Attribute;
|
||||
import org.gcube.common.storagehub.model.annotations.AttributeRootNode;
|
||||
import org.gcube.common.storagehub.model.annotations.NodeAttribute;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@AttributeRootNode(CONTENTFILETYPE)
|
||||
public class Content {
|
||||
|
||||
|
@ -38,7 +42,14 @@ public class Content {
|
|||
|
||||
@Attribute(CONTENTID)
|
||||
String storageId;
|
||||
|
||||
@NodeAttribute(value= PAYLOADBACKEND)
|
||||
PayloadBackend payloadBackend;
|
||||
|
||||
@Attribute(value= STORAGENAME, defaultValue = Constants.mongoStorageConstant)
|
||||
String managedBy;
|
||||
public PayloadBackend getPayloadBackend(){
|
||||
if(payloadBackend == null)
|
||||
return new PayloadBackend(Constants.MONGO_STORAGE, null);
|
||||
else return payloadBackend;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,23 +1,48 @@
|
|||
package org.gcube.common.storagehub.model.items.nodes;
|
||||
|
||||
import static org.gcube.common.storagehub.model.NodeConstants.*;
|
||||
import static org.gcube.common.storagehub.model.NodeConstants.PARAMETERS;
|
||||
import static org.gcube.common.storagehub.model.NodeConstants.PAYLOADBACKENDTYPE;
|
||||
import static org.gcube.common.storagehub.model.NodeConstants.STORAGENAME;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.storagehub.model.Metadata;
|
||||
import org.gcube.common.storagehub.model.annotations.Attribute;
|
||||
import org.gcube.common.storagehub.model.annotations.AttributeRootNode;
|
||||
import org.gcube.common.storagehub.model.annotations.NodeAttribute;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@AttributeRootNode(PAYLOADBACKENDTYPE)
|
||||
public class PayloadBackend {
|
||||
|
||||
@Attribute(STORAGENAME)
|
||||
String storageName;
|
||||
@Attribute(value= STORAGENAME)
|
||||
private String storageName;
|
||||
|
||||
@JsonIgnore
|
||||
@NodeAttribute(value=PARAMETERS)
|
||||
Metadata parameters = new Metadata();
|
||||
private Metadata parameters = new Metadata();
|
||||
|
||||
public String getStorageName() {
|
||||
return storageName;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Map<String, Object> getParameters(){
|
||||
if (parameters ==null || parameters.getMap() == null )
|
||||
return Collections.emptyMap();
|
||||
else return parameters.getMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.common.storagehub.model.storages;
|
||||
|
||||
import org.gcube.common.storagehub.model.items.nodes.PayloadBackend;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -15,5 +17,5 @@ public class MetaInfo {
|
|||
|
||||
String remotePath;
|
||||
|
||||
String managedBy;
|
||||
PayloadBackend payloadBackend;
|
||||
}
|
||||
|
|
|
@ -3,24 +3,64 @@ package org.gcube.common.storagehub.model.storages;
|
|||
import java.io.InputStream;
|
||||
|
||||
import org.gcube.common.storagehub.model.items.nodes.Content;
|
||||
import org.gcube.common.storagehub.model.items.nodes.PayloadBackend;
|
||||
|
||||
public interface StorageBackend {
|
||||
public abstract class StorageBackend {
|
||||
|
||||
String getName();
|
||||
private PayloadBackend payloadConfiguration;
|
||||
|
||||
MetaInfo onCopy(Content content, String newParentPath, String newName);
|
||||
public StorageBackend(PayloadBackend payloadConfiguration) {
|
||||
this.payloadConfiguration = payloadConfiguration;
|
||||
}
|
||||
|
||||
MetaInfo onMove(Content content, String newParentPath);
|
||||
|
||||
void onDelete(Content content);
|
||||
public PayloadBackend getPayloadConfiguration() {
|
||||
return payloadConfiguration;
|
||||
}
|
||||
|
||||
public abstract MetaInfo onCopy(Content content, String newParentPath, String newName);
|
||||
|
||||
MetaInfo upload(InputStream stream, String relativePath, String name);
|
||||
public abstract MetaInfo onMove(Content content, String newParentPath);
|
||||
|
||||
InputStream download(Content item);
|
||||
public abstract void onDelete(Content content);
|
||||
|
||||
public abstract MetaInfo upload(InputStream stream, String relativePath, String name);
|
||||
|
||||
public abstract MetaInfo upload(InputStream stream, String relativePath, String name, Long size);
|
||||
|
||||
public abstract InputStream download(Content item);
|
||||
|
||||
@Deprecated
|
||||
String getTotalSizeStored();
|
||||
public abstract String getTotalSizeStored();
|
||||
@Deprecated
|
||||
String getTotalItemsCount();
|
||||
public abstract String getTotalItemsCount();
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((payloadConfiguration == null) ? 0 : payloadConfiguration.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
StorageBackend other = (StorageBackend) obj;
|
||||
if (payloadConfiguration == null) {
|
||||
if (other.payloadConfiguration != null)
|
||||
return false;
|
||||
} else if (!payloadConfiguration.equals(other.payloadConfiguration))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package org.gcube.common.storagehub.model.storages;
|
||||
|
||||
import org.gcube.common.storagehub.model.Metadata;
|
||||
import org.gcube.common.storagehub.model.exceptions.InvalidCallParameters;
|
||||
import org.gcube.common.storagehub.model.items.nodes.PayloadBackend;
|
||||
|
||||
public interface StorageBackendFactory {
|
||||
|
||||
String getName();
|
||||
|
||||
StorageBackend create(Metadata parameter) throws InvalidCallParameters;
|
||||
StorageBackend create(PayloadBackend payloadConfiguration) throws InvalidCallParameters;
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue