*/\r
package gr.ebs.gss.server.domain;\r
\r
+import gr.ebs.gss.server.domain.dto.FileHeaderDTO;\r
import gr.ebs.gss.server.domain.dto.FolderDTO;\r
\r
import java.io.Serializable;\r
import javax.persistence.ManyToOne;\r
import javax.persistence.OneToMany;\r
import javax.persistence.OrderBy;\r
+import javax.persistence.PrePersist;\r
+import javax.persistence.PreUpdate;\r
import javax.persistence.Version;\r
\r
+import org.hibernate.annotations.Cache;\r
+import org.hibernate.annotations.CacheConcurrencyStrategy;\r
+\r
/**\r
* The structure of a folder on the GSS service.\r
*/\r
@Entity\r
+@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)\r
public final class Folder implements Serializable{\r
\r
/**\r
*/\r
@Column(columnDefinition=" boolean DEFAULT false")\r
private boolean deleted=false;\r
+\r
+ /**\r
+ * Can this folder be read by anyone?\r
+ * XXX: the columnDefinition is postgres specific, if deployment database is changed this shall be changed too\r
+ */\r
+ @Column(columnDefinition=" boolean DEFAULT false")\r
+ private boolean readForAll=false;\r
+ \r
+ @Column(columnDefinition=" boolean DEFAULT false")\r
+ private Boolean shared;\r
+\r
/**\r
* Retrieve the ID.\r
*\r
f.setOwner(owner.getDTO());\r
f.setAuditInfo(auditInfo.getDTO());\r
f.setDeleted(deleted);\r
+ f.setReadForAll(readForAll);\r
+ f.setShared(getShared());\r
if (parent != null)\r
f.setParent(parent.getDTO(0));\r
for (Folder subfolder : subfolders)\r
}\r
}\r
\r
+ /**\r
+ * Modify the readForAll.\r
+ *\r
+ * @param newReadForAll the readForAll to set\r
+ */\r
+ public void setReadForAll(boolean newReadForAll) {\r
+ readForAll = newReadForAll;\r
+ }\r
+\r
+ /**\r
+ * Retrieve the readForAll.\r
+ *\r
+ * @return the readForAll\r
+ */\r
+ public boolean isReadForAll() {\r
+ return readForAll;\r
+ }\r
+ \r
+ /**\r
+ * Retrieve the shared.\r
+ *\r
+ * @return the shared\r
+ */\r
+ public Boolean getShared() {\r
+ if(shared==null)\r
+ return false;\r
+ return shared;\r
+ }\r
+ \r
+ \r
+ /**\r
+ * Modify the shared.\r
+ *\r
+ * @param shared the shared to set\r
+ */\r
+ public void setShared(Boolean shared) {\r
+ this.shared = shared;\r
+ }\r
+ \r
+ @PrePersist\r
+ @PreUpdate\r
+ private void fixSharedFlag(){\r
+ if(isReadForAll()||getPermissions().size()>1)\r
+ shared=true;\r
+ else\r
+ shared=false;\r
+ }\r
+\r
+ /**\r
+ * Retrieve the URI for this resource, relative to the REST API root URI.\r
+ * This unique identifier can be used to refer to the resource from\r
+ * various GSS clients.\r
+ *\r
+ * @return the URI\r
+ */\r
+ public String getURI() {\r
+ return owner.getUsername() + FileHeader.PATH_FILES + getPath();\r
+ }\r
+\r
+\r
}\r