mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
119837 jvonka: FileFolder API - fix build (BCK) & api tests - as agreed, for now split test client api models from server-side impl - rename existing Node/Document/Folder to FavouriteNode/Document/Folder (for backwards compat') git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126372 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -36,7 +36,6 @@ import org.alfresco.service.namespace.QName;
|
|||||||
* @author janv
|
* @author janv
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class Document extends Node
|
public class Document extends Node
|
||||||
{
|
{
|
||||||
public Document() {
|
public Document() {
|
||||||
@@ -59,6 +58,18 @@ public class Document extends Node
|
|||||||
this.isFolder = false;
|
this.isFolder = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ContentInfo getContent()
|
||||||
|
{
|
||||||
|
return contentInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setContent(ContentInfo contentInfoIn)
|
||||||
|
{
|
||||||
|
contentInfo = contentInfoIn;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -33,7 +33,6 @@ import org.alfresco.service.namespace.QName;
|
|||||||
* @author steveglover
|
* @author steveglover
|
||||||
* @author janv
|
* @author janv
|
||||||
*/
|
*/
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class Folder extends Node
|
public class Folder extends Node
|
||||||
{
|
{
|
||||||
public Folder()
|
public Folder()
|
||||||
@@ -53,6 +52,11 @@ public class Folder extends Node
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setContent(ContentInfo contentInfo)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
@@ -24,12 +24,12 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.rest.framework.resource.UniqueId;
|
||||||
|
import org.alfresco.rest.framework.resource.content.*;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
|
||||||
import org.alfresco.service.cmr.security.NoSuchPersonException;
|
import org.alfresco.service.cmr.security.NoSuchPersonException;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
@@ -43,7 +43,6 @@ import org.apache.chemistry.opencmis.commons.data.PropertyData;
|
|||||||
* @author Gethin James
|
* @author Gethin James
|
||||||
* @author janv
|
* @author janv
|
||||||
*/
|
*/
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class Node implements Comparable<Node>
|
public class Node implements Comparable<Node>
|
||||||
{
|
{
|
||||||
protected NodeRef nodeRef;
|
protected NodeRef nodeRef;
|
||||||
@@ -137,34 +136,15 @@ public class Node implements Comparable<Node>
|
|||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNodeRefAsString(NodeRef nRef) {
|
@UniqueId
|
||||||
return (nRef != null ? nRef.getId() : null);
|
public NodeRef getNodeRef()
|
||||||
}
|
|
||||||
|
|
||||||
private NodeRef getStringAsNodeRef(String nRefString) {
|
|
||||||
if (nRefString == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ! NodeRef.isNodeRef(nRefString))
|
|
||||||
{
|
|
||||||
return new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nRefString);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new NodeRef(nRefString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId()
|
|
||||||
{
|
{
|
||||||
return getNodeRefAsString(this.nodeRef);
|
return nodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id)
|
public void setNodeRef(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
this.nodeRef = getStringAsNodeRef(id);
|
this.nodeRef = nodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreatedAt()
|
public Date getCreatedAt()
|
||||||
@@ -236,14 +216,14 @@ public class Node implements Comparable<Node>
|
|||||||
this.aspectNames = aspectNames;
|
this.aspectNames = aspectNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParentId()
|
public NodeRef getParentId()
|
||||||
{
|
{
|
||||||
return getNodeRefAsString(parentNodeRef);
|
return parentNodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentId(String parentId)
|
public void setParentId(NodeRef parentNodeRef)
|
||||||
{
|
{
|
||||||
this.parentNodeRef = getStringAsNodeRef(parentId);
|
this.parentNodeRef = parentNodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getIsFolder()
|
public Boolean getIsFolder()
|
||||||
@@ -279,13 +259,13 @@ public class Node implements Comparable<Node>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Node node = (Node)other;
|
Node node = (Node)other;
|
||||||
return EqualsHelper.nullSafeEquals(getId(), node.getId());
|
return EqualsHelper.nullSafeEquals(getNodeRef(), node.getNodeRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Node node)
|
public int compareTo(Node node)
|
||||||
{
|
{
|
||||||
return getId().toString().compareTo(node.getId().toString());
|
return getNodeRef().toString().compareTo(node.getNodeRef().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -297,18 +277,18 @@ public class Node implements Comparable<Node>
|
|||||||
+ modifiedByUser + ", pathInfo =" + pathInfo +"]";
|
+ modifiedByUser + ", pathInfo =" + pathInfo +"]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// here to allow POST /nodes/{id}/children when creating empty file with specified content.mimeType
|
||||||
protected ContentInfo contentInfo;
|
protected ContentInfo contentInfo;
|
||||||
|
|
||||||
public ContentInfo getContent()
|
|
||||||
{
|
|
||||||
return contentInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContent(ContentInfo contentInfo)
|
public void setContent(ContentInfo contentInfo)
|
||||||
{
|
{
|
||||||
this.contentInfo = contentInfo;
|
this.contentInfo = contentInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ContentInfo getContent()
|
||||||
|
{
|
||||||
|
return this.contentInfo;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO for backwards compat' - set explicitly when needed (ie. favourites) (note: we could choose to have separate old Node/NodeImpl etc)
|
// TODO for backwards compat' - set explicitly when needed (ie. favourites) (note: we could choose to have separate old Node/NodeImpl etc)
|
||||||
|
|
||||||
@@ -326,12 +306,11 @@ public class Node implements Comparable<Node>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated note: used when creating (via POST) favourite target
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public void setGuid(NodeRef guid)
|
public void setGuid(NodeRef guid)
|
||||||
{
|
{
|
||||||
this.guid = guid;
|
this.guid = guid;
|
||||||
setId(guid.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -34,13 +34,13 @@ import org.alfresco.repo.model.Repository;
|
|||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.rest.api.Nodes;
|
import org.alfresco.rest.api.Nodes;
|
||||||
import org.alfresco.rest.api.model.ContentInfo;
|
import org.alfresco.rest.api.tests.client.data.ContentInfo;
|
||||||
import org.alfresco.rest.api.model.Document;
|
import org.alfresco.rest.api.tests.client.data.Document;
|
||||||
import org.alfresco.rest.api.model.Folder;
|
import org.alfresco.rest.api.tests.client.data.Folder;
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.tests.client.data.Node;
|
||||||
import org.alfresco.rest.api.model.PathInfo;
|
import org.alfresco.rest.api.tests.client.data.PathInfo;
|
||||||
import org.alfresco.rest.api.model.PathInfo.ElementInfo;
|
import org.alfresco.rest.api.tests.client.data.PathInfo.ElementInfo;
|
||||||
import org.alfresco.rest.api.model.UserInfo;
|
import org.alfresco.rest.api.tests.client.data.UserInfo;
|
||||||
import org.alfresco.rest.api.nodes.NodesEntityResource;
|
import org.alfresco.rest.api.nodes.NodesEntityResource;
|
||||||
import org.alfresco.rest.api.tests.RepoService.TestNetwork;
|
import org.alfresco.rest.api.tests.RepoService.TestNetwork;
|
||||||
import org.alfresco.rest.api.tests.RepoService.TestPerson;
|
import org.alfresco.rest.api.tests.RepoService.TestPerson;
|
||||||
@@ -92,6 +92,7 @@ import java.util.UUID;
|
|||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author Jamal Kaabi-Mofrad
|
* @author Jamal Kaabi-Mofrad
|
||||||
|
* @author janv
|
||||||
*/
|
*/
|
||||||
public class NodeApiTest extends AbstractBaseApiTest
|
public class NodeApiTest extends AbstractBaseApiTest
|
||||||
{
|
{
|
||||||
|
@@ -76,9 +76,9 @@ import org.alfresco.rest.api.impl.node.ratings.RatingScheme;
|
|||||||
import org.alfresco.rest.api.tests.client.data.Activity;
|
import org.alfresco.rest.api.tests.client.data.Activity;
|
||||||
import org.alfresco.rest.api.tests.client.data.Comment;
|
import org.alfresco.rest.api.tests.client.data.Comment;
|
||||||
import org.alfresco.rest.api.tests.client.data.Company;
|
import org.alfresco.rest.api.tests.client.data.Company;
|
||||||
import org.alfresco.rest.api.tests.client.data.Document;
|
import org.alfresco.rest.api.tests.client.data.FavouriteDocument;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.FavouriteFolder;
|
||||||
import org.alfresco.rest.api.tests.client.data.FavouriteSite;
|
import org.alfresco.rest.api.tests.client.data.FavouriteSite;
|
||||||
import org.alfresco.rest.api.tests.client.data.Folder;
|
|
||||||
import org.alfresco.rest.api.tests.client.data.MemberOfSite;
|
import org.alfresco.rest.api.tests.client.data.MemberOfSite;
|
||||||
import org.alfresco.rest.api.tests.client.data.NetworkImpl;
|
import org.alfresco.rest.api.tests.client.data.NetworkImpl;
|
||||||
import org.alfresco.rest.api.tests.client.data.NodeRating;
|
import org.alfresco.rest.api.tests.client.data.NodeRating;
|
||||||
@@ -917,20 +917,20 @@ public class RepoService
|
|||||||
return wrapProperties;
|
return wrapProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Document getDocument(String networkId, final NodeRef nodeRef)
|
public FavouriteDocument getDocument(String networkId, final NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
return TenantUtil.runAsSystemTenant(new TenantRunAsWork<Document>()
|
return TenantUtil.runAsSystemTenant(new TenantRunAsWork<FavouriteDocument>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Document doWork() throws Exception
|
public FavouriteDocument doWork() throws Exception
|
||||||
{
|
{
|
||||||
Document document = null;
|
FavouriteDocument document = null;
|
||||||
|
|
||||||
QName type = nodeService.getType(nodeRef);
|
QName type = nodeService.getType(nodeRef);
|
||||||
if(dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT))
|
if(dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT))
|
||||||
{
|
{
|
||||||
Properties properties = getProperties(nodeRef);
|
Properties properties = getProperties(nodeRef);
|
||||||
document = Document.getDocument(nodeRef.getId(), nodeRef.getId(), properties);
|
document = FavouriteDocument.getDocument(nodeRef.getId(), nodeRef.getId(), properties);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -942,20 +942,20 @@ public class RepoService
|
|||||||
}, networkId);
|
}, networkId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Folder getFolder(String networkId, final NodeRef nodeRef)
|
public FavouriteFolder getFolder(String networkId, final NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
return TenantUtil.runAsSystemTenant(new TenantRunAsWork<Folder>()
|
return TenantUtil.runAsSystemTenant(new TenantRunAsWork<FavouriteFolder>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Folder doWork() throws Exception
|
public FavouriteFolder doWork() throws Exception
|
||||||
{
|
{
|
||||||
Folder folder = null;
|
FavouriteFolder folder = null;
|
||||||
|
|
||||||
QName type = nodeService.getType(nodeRef);
|
QName type = nodeService.getType(nodeRef);
|
||||||
if(dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER))
|
if(dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER))
|
||||||
{
|
{
|
||||||
Properties properties = getProperties(nodeRef);
|
Properties properties = getProperties(nodeRef);
|
||||||
folder = Folder.getFolder(nodeRef.getId(), nodeRef.getId(), properties);
|
folder = FavouriteFolder.getFolder(nodeRef.getId(), nodeRef.getId(), properties);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -33,11 +33,11 @@ import org.alfresco.rest.api.tests.client.PublicApiClient.SiteMembershipRequests
|
|||||||
import org.alfresco.rest.api.tests.client.PublicApiException;
|
import org.alfresco.rest.api.tests.client.PublicApiException;
|
||||||
import org.alfresco.rest.api.tests.client.RequestContext;
|
import org.alfresco.rest.api.tests.client.RequestContext;
|
||||||
import org.alfresco.rest.api.tests.client.data.Comment;
|
import org.alfresco.rest.api.tests.client.data.Comment;
|
||||||
import org.alfresco.rest.api.tests.client.data.Document;
|
|
||||||
import org.alfresco.rest.api.tests.client.data.Favourite;
|
import org.alfresco.rest.api.tests.client.data.Favourite;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.FavouriteDocument;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.FavouriteFolder;
|
||||||
import org.alfresco.rest.api.tests.client.data.FavouritesTarget;
|
import org.alfresco.rest.api.tests.client.data.FavouritesTarget;
|
||||||
import org.alfresco.rest.api.tests.client.data.FileFavouriteTarget;
|
import org.alfresco.rest.api.tests.client.data.FileFavouriteTarget;
|
||||||
import org.alfresco.rest.api.tests.client.data.Folder;
|
|
||||||
import org.alfresco.rest.api.tests.client.data.FolderFavouriteTarget;
|
import org.alfresco.rest.api.tests.client.data.FolderFavouriteTarget;
|
||||||
import org.alfresco.rest.api.tests.client.data.InvalidFavouriteTarget;
|
import org.alfresco.rest.api.tests.client.data.InvalidFavouriteTarget;
|
||||||
import org.alfresco.rest.api.tests.client.data.JSONAble;
|
import org.alfresco.rest.api.tests.client.data.JSONAble;
|
||||||
@@ -472,7 +472,7 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
|
|
||||||
private Favourite makeFolderFavourite(String targetGuid) throws ParseException
|
private Favourite makeFolderFavourite(String targetGuid) throws ParseException
|
||||||
{
|
{
|
||||||
Folder folder = new Folder(targetGuid);
|
FavouriteFolder folder = new FavouriteFolder(targetGuid);
|
||||||
FolderFavouriteTarget target = new FolderFavouriteTarget(folder);
|
FolderFavouriteTarget target = new FolderFavouriteTarget(folder);
|
||||||
Date creationData = new Date();
|
Date creationData = new Date();
|
||||||
Favourite favourite = new Favourite(creationData, null, target);
|
Favourite favourite = new Favourite(creationData, null, target);
|
||||||
@@ -481,7 +481,7 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
|
|
||||||
private Favourite makeFileFavourite(String targetGuid) throws ParseException
|
private Favourite makeFileFavourite(String targetGuid) throws ParseException
|
||||||
{
|
{
|
||||||
Document document = new Document(targetGuid);
|
FavouriteDocument document = new FavouriteDocument(targetGuid);
|
||||||
FileFavouriteTarget target = new FileFavouriteTarget(document);
|
FileFavouriteTarget target = new FileFavouriteTarget(document);
|
||||||
Date creationData = new Date();
|
Date creationData = new Date();
|
||||||
Favourite favourite = new Favourite(creationData, null, target);
|
Favourite favourite = new Favourite(creationData, null, target);
|
||||||
@@ -584,7 +584,7 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
||||||
|
|
||||||
String siteGuid = person1PublicSites.get(0).getGuid();
|
String siteGuid = person1PublicSites.get(0).getGuid();
|
||||||
Document document = new Document(siteGuid);
|
FavouriteDocument document = new FavouriteDocument(siteGuid);
|
||||||
Favourite favourite = makeFileFavourite(document.getGuid());
|
Favourite favourite = makeFileFavourite(document.getGuid());
|
||||||
Favourite ret = favouritesProxy.createFavourite(person10Id, favourite);
|
Favourite ret = favouritesProxy.createFavourite(person10Id, favourite);
|
||||||
favourite.expected(ret);
|
favourite.expected(ret);
|
||||||
@@ -601,7 +601,7 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
||||||
|
|
||||||
String siteGuid = person1PublicSites.get(0).getGuid();
|
String siteGuid = person1PublicSites.get(0).getGuid();
|
||||||
Folder folder = new Folder(siteGuid);
|
FavouriteFolder folder = new FavouriteFolder(siteGuid);
|
||||||
Favourite favourite = makeFolderFavourite(folder.getGuid());
|
Favourite favourite = makeFolderFavourite(folder.getGuid());
|
||||||
Favourite ret = favouritesProxy.createFavourite(person10Id, favourite);
|
Favourite ret = favouritesProxy.createFavourite(person10Id, favourite);
|
||||||
favourite.expected(ret);
|
favourite.expected(ret);
|
||||||
@@ -618,7 +618,7 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
{
|
{
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
||||||
|
|
||||||
Folder folder = new Folder(person1PublicDocs.get(0).getId());
|
FavouriteFolder folder = new FavouriteFolder(person1PublicDocs.get(0).getId());
|
||||||
Favourite favourite = makeFolderFavourite(folder.getGuid());
|
Favourite favourite = makeFolderFavourite(folder.getGuid());
|
||||||
Favourite ret = favouritesProxy.createFavourite(person10Id, favourite);
|
Favourite ret = favouritesProxy.createFavourite(person10Id, favourite);
|
||||||
favourite.expected(ret);
|
favourite.expected(ret);
|
||||||
@@ -635,7 +635,7 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
{
|
{
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
||||||
|
|
||||||
Document document = new Document(person1PublicFolders.get(0).getId());
|
FavouriteDocument document = new FavouriteDocument(person1PublicFolders.get(0).getId());
|
||||||
Favourite favourite = makeFileFavourite(document.getGuid());
|
Favourite favourite = makeFileFavourite(document.getGuid());
|
||||||
Favourite ret = favouritesProxy.createFavourite(person10Id, favourite);
|
Favourite ret = favouritesProxy.createFavourite(person10Id, favourite);
|
||||||
favourite.expected(ret);
|
favourite.expected(ret);
|
||||||
@@ -655,8 +655,8 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
||||||
|
|
||||||
Document document = new Document(person1PublicDocs.get(0).getId());
|
FavouriteDocument document = new FavouriteDocument(person1PublicDocs.get(0).getId());
|
||||||
Favourite favourite = makeFileFavourite(document.getGuid());
|
Favourite favourite = makeFileFavourite(document.getGuid());
|
||||||
favouritesProxy.createFavourite(person11Id, favourite);
|
favouritesProxy.createFavourite(person11Id, favourite);
|
||||||
|
|
||||||
@@ -751,8 +751,8 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
||||||
|
|
||||||
Document document = new Document(GUID.generate());
|
FavouriteDocument document = new FavouriteDocument(GUID.generate());
|
||||||
Favourite favourite = makeFileFavourite(document.getGuid());
|
Favourite favourite = makeFileFavourite(document.getGuid());
|
||||||
favouritesProxy.createFavourite(person10Id, favourite);
|
favouritesProxy.createFavourite(person10Id, favourite);
|
||||||
|
|
||||||
@@ -771,8 +771,8 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person10Id));
|
||||||
|
|
||||||
Folder folder = new Folder(GUID.generate());
|
FavouriteFolder folder = new FavouriteFolder(GUID.generate());
|
||||||
Favourite favourite = makeFolderFavourite(folder.getGuid());
|
Favourite favourite = makeFolderFavourite(folder.getGuid());
|
||||||
favouritesProxy.createFavourite(person10Id, favourite);
|
favouritesProxy.createFavourite(person10Id, favourite);
|
||||||
|
|
||||||
@@ -826,7 +826,7 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
|
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
Document document = new Document(person1PublicDocs.get(0).getId());
|
FavouriteDocument document = new FavouriteDocument(person1PublicDocs.get(0).getId());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -859,8 +859,8 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
{
|
{
|
||||||
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
|
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
Folder folder = new Folder(person1PublicFolders.get(0).getId());
|
FavouriteFolder folder = new FavouriteFolder(person1PublicFolders.get(0).getId());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -929,11 +929,11 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
log("cloud-2467");
|
log("cloud-2467");
|
||||||
|
|
||||||
Favourite siteFavourite1 = makeSiteFavourite(person1PublicSites.get(0));
|
Favourite siteFavourite1 = makeSiteFavourite(person1PublicSites.get(0));
|
||||||
|
|
||||||
Document document = repoService.getDocument(network1.getId(), person1PublicDocs.get(0));
|
FavouriteDocument document = repoService.getDocument(network1.getId(), person1PublicDocs.get(0));
|
||||||
Favourite fileFavourite1 = makeFileFavourite(document.getGuid());
|
Favourite fileFavourite1 = makeFileFavourite(document.getGuid());
|
||||||
|
|
||||||
Folder folder = repoService.getFolder(network1.getId(), person1PublicFolders.get(0));
|
FavouriteFolder folder = repoService.getFolder(network1.getId(), person1PublicFolders.get(0));
|
||||||
Favourite folderFavourite1 = makeFolderFavourite(folder.getGuid());
|
Favourite folderFavourite1 = makeFolderFavourite(folder.getGuid());
|
||||||
|
|
||||||
Favourite siteFavourite2 = makeSiteFavourite(person1PublicSites.get(1));
|
Favourite siteFavourite2 = makeSiteFavourite(person1PublicSites.get(1));
|
||||||
@@ -1062,7 +1062,7 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
{
|
{
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person21Id));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person21Id));
|
||||||
|
|
||||||
Document document1 = new Document(person1PrivateDocs.get(0).getId());
|
FavouriteDocument document1 = new FavouriteDocument(person1PrivateDocs.get(0).getId());
|
||||||
Favourite favourite = makeFileFavourite(document1.getGuid());
|
Favourite favourite = makeFileFavourite(document1.getGuid());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1094,7 +1094,7 @@ public class TestFavourites extends EnterpriseTestApi
|
|||||||
{
|
{
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person21Id));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person21Id));
|
||||||
|
|
||||||
Folder folder1 = new Folder(person1PrivateFolders.get(0).getId());
|
FavouriteFolder folder1 = new FavouriteFolder(person1PrivateFolders.get(0).getId());
|
||||||
Favourite favourite = makeFolderFavourite(folder1.getGuid());
|
Favourite favourite = makeFolderFavourite(folder1.getGuid());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@@ -0,0 +1,39 @@
|
|||||||
|
package org.alfresco.rest.api.tests.client.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representation of content info (initially for client tests for File Folder API)
|
||||||
|
*
|
||||||
|
* @author janv
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ContentInfo
|
||||||
|
{
|
||||||
|
private String mimeType;
|
||||||
|
private String mimeTypeName;
|
||||||
|
private long sizeInBytes;
|
||||||
|
private String encoding;
|
||||||
|
|
||||||
|
public ContentInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMimeType() {
|
||||||
|
return mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMimeType(String mimeType) {
|
||||||
|
this.mimeType = mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMimeTypeName() {
|
||||||
|
return mimeTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSizeInBytes() {
|
||||||
|
return sizeInBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEncoding() {
|
||||||
|
return encoding;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,160 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package org.alfresco.rest.api.tests.client.data;
|
package org.alfresco.rest.api.tests.client.data;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
|
||||||
import org.alfresco.rest.api.tests.PublicApiDateFormat;
|
|
||||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
|
||||||
import org.apache.chemistry.opencmis.commons.data.Properties;
|
|
||||||
import org.apache.chemistry.opencmis.commons.data.PropertyData;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of a document node.
|
* Representation of a document node (initially for client tests for File Folder API)
|
||||||
*
|
*
|
||||||
* @author steveglover
|
* @author janv
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Document extends Node implements ExpectedComparison, JSONAble
|
public class Document extends Node
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = -5890002728061039516L;
|
private ContentInfo content;
|
||||||
|
|
||||||
private String mimeType;
|
public Document() {
|
||||||
private BigInteger sizeInBytes;
|
super();
|
||||||
private String versionLabel;
|
}
|
||||||
|
|
||||||
/**
|
public ContentInfo getContent()
|
||||||
* For POSTs
|
{
|
||||||
* @param guid String
|
return content;
|
||||||
*/
|
}
|
||||||
public Document(String guid)
|
|
||||||
{
|
|
||||||
super(guid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Document(String id, String guid)
|
public void setContent(ContentInfo content)
|
||||||
{
|
{
|
||||||
super(id, guid);
|
this.content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public Document(String id, String guid, Map<String, Serializable> properties)
|
|
||||||
// {
|
|
||||||
// super(id, guid, properties);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static Document getDocument(String id, String guid, Properties props)
|
|
||||||
{
|
|
||||||
Document document = new Document(id, guid);
|
|
||||||
|
|
||||||
Map<String, PropertyData<?>> properties = props.getProperties();
|
|
||||||
document.setName((String)properties.get(PropertyIds.NAME).getFirstValue());
|
|
||||||
document.setTitle((String)properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue());
|
|
||||||
document.setCreatedBy((String)properties.get(PropertyIds.CREATED_BY).getFirstValue());
|
|
||||||
document.setModifiedBy((String)properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue());
|
|
||||||
GregorianCalendar modifiedAt = (GregorianCalendar)properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
|
|
||||||
document.setModifiedAt(modifiedAt.getTime());
|
|
||||||
GregorianCalendar createdAt = (GregorianCalendar)properties.get(PropertyIds.CREATION_DATE).getFirstValue();
|
|
||||||
document.setCreatedAt(createdAt.getTime());
|
|
||||||
//document.setDescription((String)props.get(PropertyIds.DE).getFirstValue());
|
|
||||||
document.setMimeType((String)properties.get(PropertyIds.CONTENT_STREAM_MIME_TYPE).getFirstValue());
|
|
||||||
document.setSizeInBytes((BigInteger)properties.get(PropertyIds.CONTENT_STREAM_LENGTH).getFirstValue());
|
|
||||||
document.setVersionLabel((String)properties.get(PropertyIds.VERSION_LABEL).getFirstValue());
|
|
||||||
return document;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMimeType()
|
|
||||||
{
|
|
||||||
return mimeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigInteger getSizeInBytes()
|
|
||||||
{
|
|
||||||
return sizeInBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVersionLabel()
|
|
||||||
{
|
|
||||||
return versionLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMimeType(String mimeType)
|
|
||||||
{
|
|
||||||
this.mimeType = mimeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSizeInBytes(BigInteger sizeInBytes)
|
|
||||||
{
|
|
||||||
this.sizeInBytes = sizeInBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVersionLabel(String versionLabel)
|
|
||||||
{
|
|
||||||
this.versionLabel = versionLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONObject toJSON()
|
|
||||||
{
|
|
||||||
JSONObject json = super.toJSON();
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void expected(Object o)
|
|
||||||
{
|
|
||||||
super.expected(o);
|
|
||||||
|
|
||||||
assertTrue(o instanceof Document);
|
|
||||||
|
|
||||||
Document other = (Document)o;
|
|
||||||
|
|
||||||
AssertUtil.assertEquals("mimeType", mimeType, other.getMimeType());
|
|
||||||
AssertUtil.assertEquals("sizeInBytes", sizeInBytes, other.getSizeInBytes());
|
|
||||||
AssertUtil.assertEquals("versionLabel", versionLabel, other.getVersionLabel());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Document parseDocument(JSONObject jsonObject) throws ParseException
|
|
||||||
{
|
|
||||||
String id = (String)jsonObject.get("id");
|
|
||||||
String guid = (String)jsonObject.get("guid");
|
|
||||||
String name = (String)jsonObject.get("name");
|
|
||||||
String title = (String)jsonObject.get("title");
|
|
||||||
String description = (String)jsonObject.get("description");
|
|
||||||
Date createdAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("createdAt"));
|
|
||||||
Date modifiedAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("modifiedAt"));
|
|
||||||
String createdBy = (String)jsonObject.get("createdBy");
|
|
||||||
String modifiedBy = (String)jsonObject.get("modifiedBy");
|
|
||||||
String mimeType = (String)jsonObject.get("mimeType");
|
|
||||||
Long sizeInBytes = (Long)jsonObject.get("sizeInBytes");
|
|
||||||
String versionLabel = (String)jsonObject.get("versionLabel");
|
|
||||||
|
|
||||||
Document document = new Document(id, guid);
|
|
||||||
document.setName(name);
|
|
||||||
document.setTitle(title);
|
|
||||||
document.setCreatedBy(createdBy);
|
|
||||||
document.setModifiedBy(modifiedBy);
|
|
||||||
document.setModifiedAt(modifiedAt);
|
|
||||||
document.setCreatedAt(createdAt);
|
|
||||||
document.setDescription(description);
|
|
||||||
document.setMimeType(mimeType);
|
|
||||||
document.setSizeInBytes(BigInteger.valueOf(sizeInBytes));
|
|
||||||
document.setVersionLabel(versionLabel);
|
|
||||||
return document;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "Document [mimeType=" + mimeType + ", sizeInBytes="
|
|
||||||
+ sizeInBytes + ", versionLabel=" + versionLabel + ", nodeId="
|
|
||||||
+ nodeId + ", guid=" + guid + ", name=" + name + ", title="
|
|
||||||
+ title + ", description=" + description + ", createdAt="
|
|
||||||
+ createdAt + ", modifiedAt=" + modifiedAt + ", createdBy="
|
|
||||||
+ createdBy + ", modifiedBy=" + modifiedBy + "]";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -140,14 +140,14 @@ public class Favourite implements Serializable, ExpectedComparison, Comparable<F
|
|||||||
else if(jsonObject.containsKey("file"))
|
else if(jsonObject.containsKey("file"))
|
||||||
{
|
{
|
||||||
JSONObject documentJSON = (JSONObject)jsonObject.get("file");
|
JSONObject documentJSON = (JSONObject)jsonObject.get("file");
|
||||||
Document document = Document.parseDocument(documentJSON);
|
FavouriteDocument document = FavouriteDocument.parseDocument(documentJSON);
|
||||||
ret = new FileFavouriteTarget(document);
|
ret = new FileFavouriteTarget(document);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(jsonObject.containsKey("folder"))
|
else if(jsonObject.containsKey("folder"))
|
||||||
{
|
{
|
||||||
JSONObject folderJSON = (JSONObject)jsonObject.get("folder");
|
JSONObject folderJSON = (JSONObject)jsonObject.get("folder");
|
||||||
Folder folder = Folder.parseFolder(folderJSON);
|
FavouriteFolder folder = FavouriteFolder.parseFolder(folderJSON);
|
||||||
ret = new FolderFavouriteTarget(folder);
|
ret = new FolderFavouriteTarget(folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,160 @@
|
|||||||
|
package org.alfresco.rest.api.tests.client.data;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.rest.api.tests.PublicApiDateFormat;
|
||||||
|
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||||
|
import org.apache.chemistry.opencmis.commons.data.Properties;
|
||||||
|
import org.apache.chemistry.opencmis.commons.data.PropertyData;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representation of a document node (as returned by Favourites API)
|
||||||
|
*
|
||||||
|
* @author steveglover
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FavouriteDocument extends FavouriteNode implements ExpectedComparison, JSONAble
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = -5890002728061039516L;
|
||||||
|
|
||||||
|
private String mimeType;
|
||||||
|
private BigInteger sizeInBytes;
|
||||||
|
private String versionLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For POSTs
|
||||||
|
* @param guid String
|
||||||
|
*/
|
||||||
|
public FavouriteDocument(String guid)
|
||||||
|
{
|
||||||
|
super(guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FavouriteDocument(String id, String guid)
|
||||||
|
{
|
||||||
|
super(id, guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public Document(String id, String guid, Map<String, Serializable> properties)
|
||||||
|
// {
|
||||||
|
// super(id, guid, properties);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static FavouriteDocument getDocument(String id, String guid, Properties props)
|
||||||
|
{
|
||||||
|
FavouriteDocument document = new FavouriteDocument(id, guid);
|
||||||
|
|
||||||
|
Map<String, PropertyData<?>> properties = props.getProperties();
|
||||||
|
document.setName((String)properties.get(PropertyIds.NAME).getFirstValue());
|
||||||
|
document.setTitle((String)properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue());
|
||||||
|
document.setCreatedBy((String)properties.get(PropertyIds.CREATED_BY).getFirstValue());
|
||||||
|
document.setModifiedBy((String)properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue());
|
||||||
|
GregorianCalendar modifiedAt = (GregorianCalendar)properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
|
||||||
|
document.setModifiedAt(modifiedAt.getTime());
|
||||||
|
GregorianCalendar createdAt = (GregorianCalendar)properties.get(PropertyIds.CREATION_DATE).getFirstValue();
|
||||||
|
document.setCreatedAt(createdAt.getTime());
|
||||||
|
//document.setDescription((String)props.get(PropertyIds.DE).getFirstValue());
|
||||||
|
document.setMimeType((String)properties.get(PropertyIds.CONTENT_STREAM_MIME_TYPE).getFirstValue());
|
||||||
|
document.setSizeInBytes((BigInteger)properties.get(PropertyIds.CONTENT_STREAM_LENGTH).getFirstValue());
|
||||||
|
document.setVersionLabel((String)properties.get(PropertyIds.VERSION_LABEL).getFirstValue());
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMimeType()
|
||||||
|
{
|
||||||
|
return mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigInteger getSizeInBytes()
|
||||||
|
{
|
||||||
|
return sizeInBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersionLabel()
|
||||||
|
{
|
||||||
|
return versionLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMimeType(String mimeType)
|
||||||
|
{
|
||||||
|
this.mimeType = mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSizeInBytes(BigInteger sizeInBytes)
|
||||||
|
{
|
||||||
|
this.sizeInBytes = sizeInBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersionLabel(String versionLabel)
|
||||||
|
{
|
||||||
|
this.versionLabel = versionLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject toJSON()
|
||||||
|
{
|
||||||
|
JSONObject json = super.toJSON();
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void expected(Object o)
|
||||||
|
{
|
||||||
|
super.expected(o);
|
||||||
|
|
||||||
|
assertTrue(o instanceof FavouriteDocument);
|
||||||
|
|
||||||
|
FavouriteDocument other = (FavouriteDocument)o;
|
||||||
|
|
||||||
|
AssertUtil.assertEquals("mimeType", mimeType, other.getMimeType());
|
||||||
|
AssertUtil.assertEquals("sizeInBytes", sizeInBytes, other.getSizeInBytes());
|
||||||
|
AssertUtil.assertEquals("versionLabel", versionLabel, other.getVersionLabel());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FavouriteDocument parseDocument(JSONObject jsonObject) throws ParseException
|
||||||
|
{
|
||||||
|
String id = (String)jsonObject.get("id");
|
||||||
|
String guid = (String)jsonObject.get("guid");
|
||||||
|
String name = (String)jsonObject.get("name");
|
||||||
|
String title = (String)jsonObject.get("title");
|
||||||
|
String description = (String)jsonObject.get("description");
|
||||||
|
Date createdAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("createdAt"));
|
||||||
|
Date modifiedAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("modifiedAt"));
|
||||||
|
String createdBy = (String)jsonObject.get("createdBy");
|
||||||
|
String modifiedBy = (String)jsonObject.get("modifiedBy");
|
||||||
|
String mimeType = (String)jsonObject.get("mimeType");
|
||||||
|
Long sizeInBytes = (Long)jsonObject.get("sizeInBytes");
|
||||||
|
String versionLabel = (String)jsonObject.get("versionLabel");
|
||||||
|
|
||||||
|
FavouriteDocument document = new FavouriteDocument(id, guid);
|
||||||
|
document.setName(name);
|
||||||
|
document.setTitle(title);
|
||||||
|
document.setCreatedBy(createdBy);
|
||||||
|
document.setModifiedBy(modifiedBy);
|
||||||
|
document.setModifiedAt(modifiedAt);
|
||||||
|
document.setCreatedAt(createdAt);
|
||||||
|
document.setDescription(description);
|
||||||
|
document.setMimeType(mimeType);
|
||||||
|
document.setSizeInBytes(BigInteger.valueOf(sizeInBytes));
|
||||||
|
document.setVersionLabel(versionLabel);
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "FavouriteDocument [mimeType=" + mimeType + ", sizeInBytes="
|
||||||
|
+ sizeInBytes + ", versionLabel=" + versionLabel + ", nodeId="
|
||||||
|
+ nodeId + ", guid=" + guid + ", name=" + name + ", title="
|
||||||
|
+ title + ", description=" + description + ", createdAt="
|
||||||
|
+ createdAt + ", modifiedAt=" + modifiedAt + ", createdBy="
|
||||||
|
+ createdBy + ", modifiedBy=" + modifiedBy + "]";
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,105 @@
|
|||||||
|
package org.alfresco.rest.api.tests.client.data;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.rest.api.tests.PublicApiDateFormat;
|
||||||
|
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||||
|
import org.apache.chemistry.opencmis.commons.data.Properties;
|
||||||
|
import org.apache.chemistry.opencmis.commons.data.PropertyData;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representation of a folder node (as returned by Favourites API)
|
||||||
|
*
|
||||||
|
* @author steveglover
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FavouriteFolder extends FavouriteNode implements ExpectedComparison, JSONAble
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 5020819866533183524L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For POSTs
|
||||||
|
* @param guid String
|
||||||
|
*/
|
||||||
|
public FavouriteFolder(String guid)
|
||||||
|
{
|
||||||
|
super(guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FavouriteFolder(String id, String guid)
|
||||||
|
{
|
||||||
|
super(id, guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public Folder(String id, String guid, Map<String, Serializable> properties)
|
||||||
|
// {
|
||||||
|
// super(id, guid, properties);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static FavouriteFolder getFolder(String id, String guid, Properties props)
|
||||||
|
{
|
||||||
|
FavouriteFolder folder = new FavouriteFolder(id, guid);
|
||||||
|
|
||||||
|
Map<String, PropertyData<?>> properties = props.getProperties();
|
||||||
|
folder.setName((String)properties.get(PropertyIds.NAME).getFirstValue());
|
||||||
|
folder.setTitle((String)properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue());
|
||||||
|
folder.setCreatedBy((String)properties.get(PropertyIds.CREATED_BY).getFirstValue());
|
||||||
|
folder.setModifiedBy((String)properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue());
|
||||||
|
GregorianCalendar modifiedAt = (GregorianCalendar)properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
|
||||||
|
folder.setModifiedAt(modifiedAt.getTime());
|
||||||
|
GregorianCalendar createdAt = (GregorianCalendar)properties.get(PropertyIds.CREATION_DATE).getFirstValue();
|
||||||
|
folder.setCreatedAt(createdAt.getTime());
|
||||||
|
//document.setDescription((String)props.get(PropertyIds.DE).getFirstValue());
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject toJSON()
|
||||||
|
{
|
||||||
|
JSONObject json = super.toJSON();
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FavouriteFolder parseFolder(JSONObject jsonObject) throws ParseException
|
||||||
|
{
|
||||||
|
String id = (String)jsonObject.get("id");
|
||||||
|
String guid = (String)jsonObject.get("guid");
|
||||||
|
String name = (String)jsonObject.get("name");
|
||||||
|
String title = (String)jsonObject.get("title");
|
||||||
|
String description = (String)jsonObject.get("description");
|
||||||
|
Date createdAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("createdAt"));
|
||||||
|
Date modifiedAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("modifiedAt"));
|
||||||
|
String createdBy = (String)jsonObject.get("createdBy");
|
||||||
|
String modifiedBy = (String)jsonObject.get("modifiedBy");
|
||||||
|
|
||||||
|
FavouriteFolder folder = new FavouriteFolder(id, guid);
|
||||||
|
folder.setName(name);
|
||||||
|
folder.setTitle(title);
|
||||||
|
folder.setCreatedBy(createdBy);
|
||||||
|
folder.setModifiedBy(modifiedBy);
|
||||||
|
folder.setModifiedAt(modifiedAt);
|
||||||
|
folder.setCreatedAt(createdAt);
|
||||||
|
folder.setDescription(description);
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void expected(Object o)
|
||||||
|
{
|
||||||
|
super.expected(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Folder [nodeId=" + nodeId + ", guid=" + guid + ", name=" + name
|
||||||
|
+ ", title=" + title + ", description=" + description
|
||||||
|
+ ", createdAt=" + createdAt + ", modifiedAt=" + modifiedAt
|
||||||
|
+ ", createdBy=" + createdBy + ", modifiedBy=" + modifiedBy
|
||||||
|
+ "]";
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,217 @@
|
|||||||
|
package org.alfresco.rest.api.tests.client.data;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alfresco API - Favourite node representation.
|
||||||
|
*
|
||||||
|
* @author steveglover
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FavouriteNode implements Serializable, ExpectedComparison
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = -6881545732441221372L;
|
||||||
|
|
||||||
|
protected String nodeId;
|
||||||
|
protected String guid;
|
||||||
|
protected String name;
|
||||||
|
protected String title;
|
||||||
|
protected String description;
|
||||||
|
protected Date createdAt;
|
||||||
|
protected Date modifiedAt;
|
||||||
|
protected String createdBy;
|
||||||
|
protected String modifiedBy;
|
||||||
|
|
||||||
|
public FavouriteNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For POSTs
|
||||||
|
*
|
||||||
|
* @param guid String
|
||||||
|
*/
|
||||||
|
public FavouriteNode(String guid)
|
||||||
|
{
|
||||||
|
this.guid = guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FavouriteNode(String id, String guid)
|
||||||
|
{
|
||||||
|
this.nodeId = id;
|
||||||
|
this.guid = guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGuid(String guid)
|
||||||
|
{
|
||||||
|
this.guid = guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGuid()
|
||||||
|
{
|
||||||
|
return guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRawNodeId()
|
||||||
|
{
|
||||||
|
return nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNodeId()
|
||||||
|
{
|
||||||
|
return nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFolder()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle()
|
||||||
|
{
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription()
|
||||||
|
{
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description)
|
||||||
|
{
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreatedAt()
|
||||||
|
{
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Date createdAt)
|
||||||
|
{
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getModifiedAt()
|
||||||
|
{
|
||||||
|
return modifiedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifiedAt(Date modifiedAt)
|
||||||
|
{
|
||||||
|
this.modifiedAt = modifiedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatedBy()
|
||||||
|
{
|
||||||
|
return createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedBy(String createdBy)
|
||||||
|
{
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModifiedBy()
|
||||||
|
{
|
||||||
|
return modifiedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifiedBy(String modifiedBy)
|
||||||
|
{
|
||||||
|
this.modifiedBy = modifiedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeId(String nodeId)
|
||||||
|
{
|
||||||
|
this.nodeId = nodeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((nodeId == null) ? 0 : nodeId.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;
|
||||||
|
FavouriteNode other = (FavouriteNode) obj;
|
||||||
|
if (nodeId == null)
|
||||||
|
{
|
||||||
|
if (other.nodeId != null)
|
||||||
|
return false;
|
||||||
|
} else if (!nodeId.equals(other.nodeId))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public JSONObject toJSON()
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("guid", getGuid());
|
||||||
|
json.put("id", getNodeId());
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void expected(Object o)
|
||||||
|
{
|
||||||
|
assertTrue(o instanceof FavouriteNode);
|
||||||
|
|
||||||
|
FavouriteNode other = (FavouriteNode) o;
|
||||||
|
|
||||||
|
AssertUtil.assertEquals("id", nodeId, other.getNodeId());
|
||||||
|
AssertUtil.assertEquals("guid", guid, other.getGuid());
|
||||||
|
AssertUtil.assertEquals("name", name, other.getName());
|
||||||
|
AssertUtil.assertEquals("title", title, other.getTitle());
|
||||||
|
AssertUtil.assertEquals("description", description, other.getDescription());
|
||||||
|
AssertUtil.assertEquals("createdAt", createdAt, other.getCreatedAt());
|
||||||
|
if(modifiedAt != null)
|
||||||
|
{
|
||||||
|
assertTrue(modifiedAt.before(other.getModifiedAt()) || modifiedAt.equals(other.getModifiedAt()));
|
||||||
|
}
|
||||||
|
AssertUtil.assertEquals("createdBy", createdBy, other.getCreatedBy());
|
||||||
|
AssertUtil.assertEquals("modifiedBy", modifiedBy, other.getModifiedBy());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Node [nodeId=" + nodeId + ", guid=" + guid + ", name=" + name
|
||||||
|
+ ", title=" + title + ", description=" + description
|
||||||
|
+ ", createdAt=" + createdAt + ", modifiedAt=" + modifiedAt
|
||||||
|
+ ", createdBy=" + createdBy + ", modifiedBy=" + modifiedBy
|
||||||
|
+ "]";
|
||||||
|
}
|
||||||
|
}
|
@@ -6,15 +6,15 @@ import org.json.simple.JSONObject;
|
|||||||
|
|
||||||
public class FileFavouriteTarget implements FavouritesTarget
|
public class FileFavouriteTarget implements FavouritesTarget
|
||||||
{
|
{
|
||||||
private Document document;
|
private FavouriteDocument document;
|
||||||
|
|
||||||
public FileFavouriteTarget(Document document)
|
public FileFavouriteTarget(FavouriteDocument document)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.document = document;
|
this.document = document;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Document getDocument()
|
public FavouriteDocument getDocument()
|
||||||
{
|
{
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
@@ -1,105 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package org.alfresco.rest.api.tests.client.data;
|
package org.alfresco.rest.api.tests.client.data;
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
|
||||||
import org.alfresco.rest.api.tests.PublicApiDateFormat;
|
|
||||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
|
||||||
import org.apache.chemistry.opencmis.commons.data.Properties;
|
|
||||||
import org.apache.chemistry.opencmis.commons.data.PropertyData;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of a folder node.
|
* Representation of a folder node (initially for client tests for File Folder API)
|
||||||
*
|
|
||||||
* @author steveglover
|
|
||||||
*
|
*
|
||||||
|
* @author janv
|
||||||
*/
|
*/
|
||||||
public class Folder extends Node implements ExpectedComparison, JSONAble
|
public class Folder extends Node
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 5020819866533183524L;
|
public Folder()
|
||||||
|
{
|
||||||
/**
|
super();
|
||||||
* For POSTs
|
}
|
||||||
* @param guid String
|
|
||||||
*/
|
|
||||||
public Folder(String guid)
|
|
||||||
{
|
|
||||||
super(guid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Folder(String id, String guid)
|
|
||||||
{
|
|
||||||
super(id, guid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// public Folder(String id, String guid, Map<String, Serializable> properties)
|
|
||||||
// {
|
|
||||||
// super(id, guid, properties);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static Folder getFolder(String id, String guid, Properties props)
|
|
||||||
{
|
|
||||||
Folder folder = new Folder(id, guid);
|
|
||||||
|
|
||||||
Map<String, PropertyData<?>> properties = props.getProperties();
|
|
||||||
folder.setName((String)properties.get(PropertyIds.NAME).getFirstValue());
|
|
||||||
folder.setTitle((String)properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue());
|
|
||||||
folder.setCreatedBy((String)properties.get(PropertyIds.CREATED_BY).getFirstValue());
|
|
||||||
folder.setModifiedBy((String)properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue());
|
|
||||||
GregorianCalendar modifiedAt = (GregorianCalendar)properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
|
|
||||||
folder.setModifiedAt(modifiedAt.getTime());
|
|
||||||
GregorianCalendar createdAt = (GregorianCalendar)properties.get(PropertyIds.CREATION_DATE).getFirstValue();
|
|
||||||
folder.setCreatedAt(createdAt.getTime());
|
|
||||||
//document.setDescription((String)props.get(PropertyIds.DE).getFirstValue());
|
|
||||||
return folder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONObject toJSON()
|
|
||||||
{
|
|
||||||
JSONObject json = super.toJSON();
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Folder parseFolder(JSONObject jsonObject) throws ParseException
|
|
||||||
{
|
|
||||||
String id = (String)jsonObject.get("id");
|
|
||||||
String guid = (String)jsonObject.get("guid");
|
|
||||||
String name = (String)jsonObject.get("name");
|
|
||||||
String title = (String)jsonObject.get("title");
|
|
||||||
String description = (String)jsonObject.get("description");
|
|
||||||
Date createdAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("createdAt"));
|
|
||||||
Date modifiedAt = PublicApiDateFormat.getDateFormat().parse((String)jsonObject.get("modifiedAt"));
|
|
||||||
String createdBy = (String)jsonObject.get("createdBy");
|
|
||||||
String modifiedBy = (String)jsonObject.get("modifiedBy");
|
|
||||||
|
|
||||||
Folder folder = new Folder(id, guid);
|
|
||||||
folder.setName(name);
|
|
||||||
folder.setTitle(title);
|
|
||||||
folder.setCreatedBy(createdBy);
|
|
||||||
folder.setModifiedBy(modifiedBy);
|
|
||||||
folder.setModifiedAt(modifiedAt);
|
|
||||||
folder.setCreatedAt(createdAt);
|
|
||||||
folder.setDescription(description);
|
|
||||||
return folder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void expected(Object o)
|
|
||||||
{
|
|
||||||
super.expected(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "Folder [nodeId=" + nodeId + ", guid=" + guid + ", name=" + name
|
|
||||||
+ ", title=" + title + ", description=" + description
|
|
||||||
+ ", createdAt=" + createdAt + ", modifiedAt=" + modifiedAt
|
|
||||||
+ ", createdBy=" + createdBy + ", modifiedBy=" + modifiedBy
|
|
||||||
+ "]";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -6,15 +6,15 @@ import org.json.simple.JSONObject;
|
|||||||
|
|
||||||
public class FolderFavouriteTarget implements FavouritesTarget
|
public class FolderFavouriteTarget implements FavouritesTarget
|
||||||
{
|
{
|
||||||
private Folder folder;
|
private FavouriteFolder folder;
|
||||||
|
|
||||||
public FolderFavouriteTarget(Folder folder)
|
public FolderFavouriteTarget(FavouriteFolder folder)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Folder getFolder()
|
public FavouriteFolder getFolder()
|
||||||
{
|
{
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
@@ -1,217 +1,159 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package org.alfresco.rest.api.tests.client.data;
|
package org.alfresco.rest.api.tests.client.data;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import org.json.simple.JSONObject;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alfresco API (non-CMIS) node representation.
|
* Representation of a node (for client tests for File Folder API)
|
||||||
*
|
|
||||||
* @author steveglover
|
|
||||||
*
|
*
|
||||||
|
* @author janv
|
||||||
*/
|
*/
|
||||||
public class Node implements Serializable, ExpectedComparison
|
public class Node
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = -6881545732441221372L;
|
protected String id;
|
||||||
|
protected String name;
|
||||||
|
|
||||||
protected String nodeId;
|
protected Date createdAt;
|
||||||
protected String guid;
|
protected Date modifiedAt;
|
||||||
protected String name;
|
protected UserInfo createdByUser;
|
||||||
protected String title;
|
protected UserInfo modifiedByUser;
|
||||||
protected String description;
|
|
||||||
protected Date createdAt;
|
|
||||||
protected Date modifiedAt;
|
|
||||||
protected String createdBy;
|
|
||||||
protected String modifiedBy;
|
|
||||||
|
|
||||||
public Node()
|
protected Boolean isFolder;
|
||||||
{
|
protected Boolean isLink;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
protected String parentId;
|
||||||
* For POSTs
|
protected PathInfo path;
|
||||||
*
|
protected String nodeType;
|
||||||
* @param guid String
|
|
||||||
*/
|
|
||||||
public Node(String guid)
|
|
||||||
{
|
|
||||||
this.guid = guid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Node(String id, String guid)
|
protected List<String> aspectNames;
|
||||||
{
|
|
||||||
this.nodeId = id;
|
|
||||||
this.guid = guid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGuid(String guid)
|
protected Map<String, Object> properties;
|
||||||
{
|
|
||||||
this.guid = guid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGuid()
|
public Node()
|
||||||
{
|
{
|
||||||
return guid;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getRawNodeId()
|
public String getId()
|
||||||
{
|
{
|
||||||
return nodeId;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNodeId()
|
public String getName()
|
||||||
{
|
{
|
||||||
return nodeId;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFolder()
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
return false;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name)
|
public Date getCreatedAt()
|
||||||
{
|
{
|
||||||
this.name = name;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle()
|
public Date getModifiedAt()
|
||||||
{
|
{
|
||||||
return title;
|
return modifiedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title)
|
public UserInfo getCreatedByUser()
|
||||||
{
|
{
|
||||||
this.title = title;
|
return createdByUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public UserInfo getModifiedByUser()
|
||||||
{
|
{
|
||||||
return description;
|
return modifiedByUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description)
|
public Boolean getIsFolder()
|
||||||
{
|
{
|
||||||
this.description = description;
|
return isFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreatedAt()
|
public void setIsFolder(Boolean folder)
|
||||||
{
|
{
|
||||||
return createdAt;
|
isFolder = folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreatedAt(Date createdAt)
|
public Boolean getIsLink()
|
||||||
{
|
{
|
||||||
this.createdAt = createdAt;
|
return isLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getModifiedAt()
|
public void setIsLink(Boolean link)
|
||||||
{
|
{
|
||||||
return modifiedAt;
|
isLink = link;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModifiedAt(Date modifiedAt)
|
public String getParentId()
|
||||||
{
|
{
|
||||||
this.modifiedAt = modifiedAt;
|
return parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCreatedBy()
|
public void setParentId(String parentId)
|
||||||
{
|
{
|
||||||
return createdBy;
|
this.parentId = parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreatedBy(String createdBy)
|
public PathInfo getPath()
|
||||||
{
|
{
|
||||||
this.createdBy = createdBy;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModifiedBy()
|
public void setPath(PathInfo path)
|
||||||
{
|
{
|
||||||
return modifiedBy;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModifiedBy(String modifiedBy)
|
public String getNodeType()
|
||||||
{
|
{
|
||||||
this.modifiedBy = modifiedBy;
|
return nodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNodeId(String nodeId)
|
public void setNodeType(String nodeType)
|
||||||
{
|
{
|
||||||
this.nodeId = nodeId;
|
this.nodeType = nodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public List<String> getAspectNames()
|
||||||
public int hashCode()
|
{
|
||||||
{
|
return aspectNames;
|
||||||
final int prime = 31;
|
}
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void setAspectNames(List<String> aspectNames)
|
||||||
public boolean equals(Object obj)
|
{
|
||||||
{
|
this.aspectNames = aspectNames;
|
||||||
if (this == obj)
|
}
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
Node other = (Node) obj;
|
|
||||||
if (nodeId == null)
|
|
||||||
{
|
|
||||||
if (other.nodeId != null)
|
|
||||||
return false;
|
|
||||||
} else if (!nodeId.equals(other.nodeId))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
public Map<String, Object> getProperties()
|
||||||
public JSONObject toJSON()
|
{
|
||||||
{
|
return properties;
|
||||||
JSONObject json = new JSONObject();
|
}
|
||||||
json.put("guid", getGuid());
|
|
||||||
json.put("id", getNodeId());
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void setProperties(Map<String, Object> properties)
|
||||||
public void expected(Object o)
|
{
|
||||||
{
|
this.properties = properties;
|
||||||
assertTrue(o instanceof Node);
|
}
|
||||||
|
}
|
||||||
Node other = (Node) o;
|
|
||||||
|
|
||||||
AssertUtil.assertEquals("id", nodeId, other.getNodeId());
|
|
||||||
AssertUtil.assertEquals("guid", guid, other.getGuid());
|
|
||||||
AssertUtil.assertEquals("name", name, other.getName());
|
|
||||||
AssertUtil.assertEquals("title", title, other.getTitle());
|
|
||||||
AssertUtil.assertEquals("description", description, other.getDescription());
|
|
||||||
AssertUtil.assertEquals("createdAt", createdAt, other.getCreatedAt());
|
|
||||||
if(modifiedAt != null)
|
|
||||||
{
|
|
||||||
assertTrue(modifiedAt.before(other.getModifiedAt()) || modifiedAt.equals(other.getModifiedAt()));
|
|
||||||
}
|
|
||||||
AssertUtil.assertEquals("createdBy", createdBy, other.getCreatedBy());
|
|
||||||
AssertUtil.assertEquals("modifiedBy", modifiedBy, other.getModifiedBy());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "Node [nodeId=" + nodeId + ", guid=" + guid + ", name=" + name
|
|
||||||
+ ", title=" + title + ", description=" + description
|
|
||||||
+ ", createdAt=" + createdAt + ", modifiedAt=" + modifiedAt
|
|
||||||
+ ", createdBy=" + createdBy + ", modifiedBy=" + modifiedBy
|
|
||||||
+ "]";
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,57 @@
|
|||||||
|
|
||||||
|
package org.alfresco.rest.api.tests.client.data;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representation of a path info (initially for client tests for File Folder API)
|
||||||
|
*
|
||||||
|
* @author janv
|
||||||
|
*/
|
||||||
|
public class PathInfo
|
||||||
|
{
|
||||||
|
private String name;
|
||||||
|
private Boolean isComplete;
|
||||||
|
private List<ElementInfo> elements;
|
||||||
|
|
||||||
|
public PathInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIsComplete()
|
||||||
|
{
|
||||||
|
return isComplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ElementInfo> getElements()
|
||||||
|
{
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ElementInfo
|
||||||
|
{
|
||||||
|
private NodeRef id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public ElementInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeRef getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.rest.api.tests.client.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representation of a user info (initially for client tests for File Folder API)
|
||||||
|
*
|
||||||
|
* @author janv
|
||||||
|
*/
|
||||||
|
public class UserInfo
|
||||||
|
{
|
||||||
|
private String userName;
|
||||||
|
private String displayName;
|
||||||
|
|
||||||
|
public UserInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayName()
|
||||||
|
{
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName()
|
||||||
|
{
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
}
|
@@ -49,6 +49,7 @@ import org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse;
|
|||||||
import org.alfresco.rest.api.tests.client.PublicApiException;
|
import org.alfresco.rest.api.tests.client.PublicApiException;
|
||||||
import org.alfresco.rest.api.tests.client.RequestContext;
|
import org.alfresco.rest.api.tests.client.RequestContext;
|
||||||
import org.alfresco.rest.api.tests.client.data.Document;
|
import org.alfresco.rest.api.tests.client.data.Document;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.FavouriteDocument;
|
||||||
import org.alfresco.rest.api.tests.client.data.MemberOfSite;
|
import org.alfresco.rest.api.tests.client.data.MemberOfSite;
|
||||||
import org.alfresco.rest.api.tests.client.data.SiteRole;
|
import org.alfresco.rest.api.tests.client.data.SiteRole;
|
||||||
import org.alfresco.rest.workflow.api.model.ProcessInfo;
|
import org.alfresco.rest.workflow.api.model.ProcessInfo;
|
||||||
@@ -378,7 +379,7 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi
|
|||||||
final ActivitiScriptNode packageScriptNode = (ActivitiScriptNode) variables.get("bpm_package");
|
final ActivitiScriptNode packageScriptNode = (ActivitiScriptNode) variables.get("bpm_package");
|
||||||
assertNotNull(packageScriptNode);
|
assertNotNull(packageScriptNode);
|
||||||
|
|
||||||
final Map<String, Document> documentMap = new HashMap<String, Document>();
|
final Map<String, FavouriteDocument> documentMap = new HashMap<>();
|
||||||
|
|
||||||
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>()
|
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>()
|
||||||
{
|
{
|
||||||
@@ -388,7 +389,7 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi
|
|||||||
List<ChildAssociationRef> documentList = nodeService.getChildAssocs(packageScriptNode.getNodeRef());
|
List<ChildAssociationRef> documentList = nodeService.getChildAssocs(packageScriptNode.getNodeRef());
|
||||||
for (ChildAssociationRef childAssociationRef : documentList)
|
for (ChildAssociationRef childAssociationRef : documentList)
|
||||||
{
|
{
|
||||||
Document doc = getTestFixture().getRepoService().getDocument(requestContext.getNetworkId(), childAssociationRef.getChildRef());
|
FavouriteDocument doc = getTestFixture().getRepoService().getDocument(requestContext.getNetworkId(), childAssociationRef.getChildRef());
|
||||||
documentMap.put(doc.getName(), doc);
|
documentMap.put(doc.getName(), doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +409,7 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi
|
|||||||
|
|
||||||
assertEquals(2, documentMap.size());
|
assertEquals(2, documentMap.size());
|
||||||
assertTrue(documentMap.containsKey("Test Doc1"));
|
assertTrue(documentMap.containsKey("Test Doc1"));
|
||||||
Document doc = documentMap.get("Test Doc1");
|
FavouriteDocument doc = documentMap.get("Test Doc1");
|
||||||
assertEquals("Test Doc1", doc.getName());
|
assertEquals("Test Doc1", doc.getName());
|
||||||
assertEquals("Test Doc1 Title", doc.getTitle());
|
assertEquals("Test Doc1 Title", doc.getTitle());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user