From 3fad462d885365f2b98f9d2e3c131245a00c2e08 Mon Sep 17 00:00:00 2001 From: "lucio.lelii" Date: Fri, 15 Oct 2021 13:14:45 +0200 Subject: [PATCH] moved part of types and jcr node name to constants --- pom.xml | 2 +- .../common/storagehub/model/Constants.java | 3 ++ .../storagehub/model/NodeConstants.java | 32 +++++++++++++++++++ .../model/annotations/Attribute.java | 1 + .../model/items/ExternalFolder.java | 4 +-- .../model/items/GenericFileItem.java | 6 ++-- .../common/storagehub/model/items/Item.java | 30 ++++++++++------- .../storagehub/model/items/SharedFolder.java | 12 +++---- .../storagehub/model/items/nodes/Content.java | 29 ++++++++++------- .../storagehub/model/items/nodes/Owner.java | 8 ++--- .../storagehub/model/messages/Message.java | 4 +-- 11 files changed, 90 insertions(+), 41 deletions(-) diff --git a/pom.xml b/pom.xml index 0daadfb..14bfbec 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ org.gcube.common storagehub-model - 1.1.1 + 2.0.0-SNAPSHOT storagehub-model diff --git a/src/main/java/org/gcube/common/storagehub/model/Constants.java b/src/main/java/org/gcube/common/storagehub/model/Constants.java index 07c1155..6520195 100644 --- a/src/main/java/org/gcube/common/storagehub/model/Constants.java +++ b/src/main/java/org/gcube/common/storagehub/model/Constants.java @@ -4,5 +4,8 @@ public class Constants { public static final String enchriptedPrefix = "E_"; public static final String versionPrefix = "_v"; + public static final String mongoStorageConstant = "gcube-mongo"; + + } diff --git a/src/main/java/org/gcube/common/storagehub/model/NodeConstants.java b/src/main/java/org/gcube/common/storagehub/model/NodeConstants.java index 67a7f07..1003f2f 100644 --- a/src/main/java/org/gcube/common/storagehub/model/NodeConstants.java +++ b/src/main/java/org/gcube/common/storagehub/model/NodeConstants.java @@ -10,4 +10,36 @@ public class NodeConstants { public static final String USERS_NAME ="hl:users"; public static final String EXTERNALREPOSITORY_NAME ="hl:externalRepository"; public static final String PROPERTY_NAME ="hl:property"; + + + public static final String PUBLIC = "hl:isPublic"; + public static final String TITLE ="jcr:title"; + public static final String DESCRIPTION = "jcr:description"; + public static final String LASTMODIFIEDBY = "jcr:lastModifiedBy"; + public static final String LASTMODIFIEDTIME = "jcr:lastModified"; + public static final String CREATEDTIME = "jcr:created"; + public static final String PORTALLOGIN = "hl:portalLogin"; + public static final String LASTACTION = "hl:lastAction"; + public static final String HIDDEN = "hl:hidden"; + + public static final String EXTERNALFOLDERPLUGIN ="hl:pluginName"; + public static final String SHAREDFOLDERPRIVILEGE = "hl:privilege"; + public static final String VREFOLDERCHECK = "hl:isVreFolder"; + public static final String DISPLAYNAME = "hl:displayName"; + + public static final String UNIQUEID = "hl:uuid"; + + public static final String CONTENTSIZE = "hl:size"; + public static final String CONTENTDATA ="jcr:data"; + public static final String CONTENTREMOTEPATH = "hl:remotePath"; + public static final String CONTENTMYMETYPE = "jcr:mimeType"; + public static final String CONTENTID = "hl:storageId"; + public static final String STORAGENAME = "hl:storageName"; + + //TYPE + public static final String SHAREDFOLDERTYPE = "nthl:workspaceSharedItem"; + public static final String MESSAGETYPE = "nthl:itemSentRequest"; + public static final String OWNERNODETYPE = "nthl:user"; + public static final String GENERICFILETYPE = "nthl:externalFile"; + public static final String CONTENTFILETYPE = "nthl:file"; } diff --git a/src/main/java/org/gcube/common/storagehub/model/annotations/Attribute.java b/src/main/java/org/gcube/common/storagehub/model/annotations/Attribute.java index 82bc849..5a4e6ce 100644 --- a/src/main/java/org/gcube/common/storagehub/model/annotations/Attribute.java +++ b/src/main/java/org/gcube/common/storagehub/model/annotations/Attribute.java @@ -11,4 +11,5 @@ public @interface Attribute { String value(); boolean isReadOnly() default false; + String defaultValue() default ""; } diff --git a/src/main/java/org/gcube/common/storagehub/model/items/ExternalFolder.java b/src/main/java/org/gcube/common/storagehub/model/items/ExternalFolder.java index 2c00e01..a504e98 100644 --- a/src/main/java/org/gcube/common/storagehub/model/items/ExternalFolder.java +++ b/src/main/java/org/gcube/common/storagehub/model/items/ExternalFolder.java @@ -1,6 +1,6 @@ package org.gcube.common.storagehub.model.items; -import static org.gcube.common.storagehub.model.NodeConstants.PARAMETERS_NAME; +import static org.gcube.common.storagehub.model.NodeConstants.*; import org.gcube.common.storagehub.model.Metadata; import org.gcube.common.storagehub.model.annotations.Attribute; @@ -19,7 +19,7 @@ import lombok.Setter; @RootNode("nthl:externalFolder") public class ExternalFolder extends FolderItem { - @Attribute("hl:pluginName") + @Attribute(EXTERNALFOLDERPLUGIN) String managedBy; @JsonIgnore diff --git a/src/main/java/org/gcube/common/storagehub/model/items/GenericFileItem.java b/src/main/java/org/gcube/common/storagehub/model/items/GenericFileItem.java index 5ec2eea..0749132 100644 --- a/src/main/java/org/gcube/common/storagehub/model/items/GenericFileItem.java +++ b/src/main/java/org/gcube/common/storagehub/model/items/GenericFileItem.java @@ -1,6 +1,6 @@ package org.gcube.common.storagehub.model.items; -import org.gcube.common.storagehub.model.NodeConstants; +import static org.gcube.common.storagehub.model.NodeConstants.*; import org.gcube.common.storagehub.model.annotations.NodeAttribute; import org.gcube.common.storagehub.model.annotations.RootNode; import org.gcube.common.storagehub.model.items.nodes.Content; @@ -14,12 +14,12 @@ import lombok.Setter; @AllArgsConstructor @Getter @Setter -@RootNode("nthl:externalFile") +@RootNode(GENERICFILETYPE) public class GenericFileItem extends AbstractFileItem{ - @NodeAttribute(value =NodeConstants.CONTENT_NAME) + @NodeAttribute(value =CONTENT_NAME) Content content; } diff --git a/src/main/java/org/gcube/common/storagehub/model/items/Item.java b/src/main/java/org/gcube/common/storagehub/model/items/Item.java index 7a5c88a..d0a06f3 100644 --- a/src/main/java/org/gcube/common/storagehub/model/items/Item.java +++ b/src/main/java/org/gcube/common/storagehub/model/items/Item.java @@ -1,8 +1,17 @@ package org.gcube.common.storagehub.model.items; import static org.gcube.common.storagehub.model.NodeConstants.ACCOUNTING_NAME; +import static org.gcube.common.storagehub.model.NodeConstants.CREATEDTIME; +import static org.gcube.common.storagehub.model.NodeConstants.DESCRIPTION; +import static org.gcube.common.storagehub.model.NodeConstants.HIDDEN; +import static org.gcube.common.storagehub.model.NodeConstants.LASTACTION; +import static org.gcube.common.storagehub.model.NodeConstants.LASTMODIFIEDBY; +import static org.gcube.common.storagehub.model.NodeConstants.LASTMODIFIEDTIME; import static org.gcube.common.storagehub.model.NodeConstants.METADATA_NAME; import static org.gcube.common.storagehub.model.NodeConstants.OWNER_NAME; +import static org.gcube.common.storagehub.model.NodeConstants.PORTALLOGIN; +import static org.gcube.common.storagehub.model.NodeConstants.PUBLIC; +import static org.gcube.common.storagehub.model.NodeConstants.TITLE; import java.util.Calendar; @@ -13,7 +22,6 @@ import org.gcube.common.storagehub.model.items.nodes.Accounting; import org.gcube.common.storagehub.model.items.nodes.Owner; import org.gcube.common.storagehub.model.types.ItemAction; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Getter; @@ -28,39 +36,37 @@ public class Item extends RootItem{ boolean trashed; - //TODO: remove on next release - @JsonIgnore boolean externalManaged = false; boolean shared; boolean locked; - @Attribute("hl:isPublic") + @Attribute(PUBLIC) boolean publicItem; - @Attribute(value ="jcr:title") + @Attribute(TITLE) String title; - @Attribute("jcr:description") + @Attribute(DESCRIPTION) String description; - @Attribute("jcr:lastModifiedBy") + @Attribute(LASTMODIFIEDBY) String lastModifiedBy; - @Attribute("jcr:lastModified") + @Attribute(LASTMODIFIEDTIME) Calendar lastModificationTime; - @Attribute(value = "jcr:created", isReadOnly=true) + @Attribute(value = CREATEDTIME, isReadOnly=true) Calendar creationTime; - @Attribute("hl:portalLogin") + @Attribute(PORTALLOGIN) String owner; - @Attribute("hl:lastAction") + @Attribute(LASTACTION) ItemAction lastAction; - @Attribute("hl:hidden") + @Attribute(HIDDEN) boolean hidden; @NodeAttribute(value=OWNER_NAME, isReadOnly=true) diff --git a/src/main/java/org/gcube/common/storagehub/model/items/SharedFolder.java b/src/main/java/org/gcube/common/storagehub/model/items/SharedFolder.java index c5b0799..68244ba 100644 --- a/src/main/java/org/gcube/common/storagehub/model/items/SharedFolder.java +++ b/src/main/java/org/gcube/common/storagehub/model/items/SharedFolder.java @@ -5,7 +5,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import org.gcube.common.storagehub.model.Metadata; -import org.gcube.common.storagehub.model.NodeConstants; +import static org.gcube.common.storagehub.model.NodeConstants.*; import org.gcube.common.storagehub.model.annotations.Attribute; import org.gcube.common.storagehub.model.annotations.NodeAttribute; import org.gcube.common.storagehub.model.annotations.RootNode; @@ -13,19 +13,19 @@ import org.gcube.common.storagehub.model.annotations.RootNode; @NoArgsConstructor @Getter @Setter -@RootNode("nthl:workspaceSharedItem") +@RootNode(SHAREDFOLDERTYPE) public class SharedFolder extends FolderItem { - @Attribute("hl:privilege") + @Attribute(SHAREDFOLDERPRIVILEGE) String privilege; - @Attribute("hl:isVreFolder") + @Attribute(VREFOLDERCHECK) boolean vreFolder; - @Attribute("hl:displayName") + @Attribute(DISPLAYNAME) String displayName; - @NodeAttribute(NodeConstants.USERS_NAME) + @NodeAttribute(USERS_NAME) Metadata users; /* @NodeAttribute("hl:members") diff --git a/src/main/java/org/gcube/common/storagehub/model/items/nodes/Content.java b/src/main/java/org/gcube/common/storagehub/model/items/nodes/Content.java index 26235ea..0168f4a 100644 --- a/src/main/java/org/gcube/common/storagehub/model/items/nodes/Content.java +++ b/src/main/java/org/gcube/common/storagehub/model/items/nodes/Content.java @@ -1,37 +1,44 @@ package org.gcube.common.storagehub.model.items.nodes; + + +import static org.gcube.common.storagehub.model.NodeConstants.CONTENTDATA; +import static org.gcube.common.storagehub.model.NodeConstants.CONTENTFILETYPE; +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 org.gcube.common.storagehub.model.Constants; import org.gcube.common.storagehub.model.annotations.Attribute; import org.gcube.common.storagehub.model.annotations.AttributeRootNode; -import com.fasterxml.jackson.annotation.JsonIgnore; - import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; - @Getter @Setter @NoArgsConstructor @AllArgsConstructor -@AttributeRootNode(value="nthl:file") +@AttributeRootNode(CONTENTFILETYPE) public class Content { - @Attribute("hl:size") + @Attribute(CONTENTSIZE) Long size; - @Attribute("jcr:data") + @Attribute(CONTENTDATA) String data; - @Attribute("hl:remotePath") + @Attribute(CONTENTREMOTEPATH) String remotePath; - @Attribute("jcr:mimeType") + @Attribute(CONTENTMYMETYPE) String mimeType; - @Attribute("hl:storageId") + @Attribute(CONTENTID) String storageId; - @JsonIgnore - @Attribute("hl:storageName") + @Attribute(value= STORAGENAME, defaultValue = Constants.mongoStorageConstant) String managedBy; } diff --git a/src/main/java/org/gcube/common/storagehub/model/items/nodes/Owner.java b/src/main/java/org/gcube/common/storagehub/model/items/nodes/Owner.java index cf97c56..9ed8172 100644 --- a/src/main/java/org/gcube/common/storagehub/model/items/nodes/Owner.java +++ b/src/main/java/org/gcube/common/storagehub/model/items/nodes/Owner.java @@ -2,7 +2,7 @@ package org.gcube.common.storagehub.model.items.nodes; import org.gcube.common.storagehub.model.annotations.Attribute; import org.gcube.common.storagehub.model.annotations.AttributeRootNode; - +import static org.gcube.common.storagehub.model.NodeConstants.*; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -12,12 +12,12 @@ import lombok.Setter; @Setter @NoArgsConstructor @AllArgsConstructor -@AttributeRootNode(value="nthl:user") +@AttributeRootNode(OWNERNODETYPE) public class Owner { - @Attribute("hl:portalLogin") + @Attribute(PORTALLOGIN) String userName; - @Attribute("hl:uuid") + @Attribute(UNIQUEID) String userId; } diff --git a/src/main/java/org/gcube/common/storagehub/model/messages/Message.java b/src/main/java/org/gcube/common/storagehub/model/messages/Message.java index 4866aee..4d85e6f 100644 --- a/src/main/java/org/gcube/common/storagehub/model/messages/Message.java +++ b/src/main/java/org/gcube/common/storagehub/model/messages/Message.java @@ -1,6 +1,6 @@ package org.gcube.common.storagehub.model.messages; -import static org.gcube.common.storagehub.model.NodeConstants.OWNER_NAME; +import static org.gcube.common.storagehub.model.NodeConstants.*; import java.util.Calendar; @@ -17,7 +17,7 @@ import lombok.Setter; @Getter @Setter @NoArgsConstructor -@RootNode("nthl:itemSentRequest") +@RootNode(MESSAGETYPE) public class Message extends RootItem{ boolean withAttachments;