diff --git a/source/java/org/alfresco/rest/api/Sites.java b/source/java/org/alfresco/rest/api/Sites.java index 826d21ad77..a543647927 100644 --- a/source/java/org/alfresco/rest/api/Sites.java +++ b/source/java/org/alfresco/rest/api/Sites.java @@ -42,7 +42,7 @@ public interface Sites void deleteSite(String siteId, Parameters parameters); Site createSite(Site site, Parameters parameters); Site updateSite(String siteId, SiteUpdate site, Parameters parameters); - + /** * people//sites/ * @@ -63,19 +63,19 @@ public interface Sites void addFavouriteSite(String personId, FavouriteSite favouriteSite); void removeFavouriteSite(String personId, String siteId); CollectionWithPagingInfo getFavouriteSites(String personId, Parameters parameters); - + String getSiteRole(String siteId); String getSiteRole(String siteId, String personId); String PARAM_PERMANENT = "permanent"; - String PARAM_SKIP_ADDTOFAVORITES = "skipAddToFavorites"; - String PARAM_SKIP_SURF_CONFIGURATION = "skipConfiguration"; - - String PARAM_SITE_ID = "id"; - String PARAM_SITE_TITLE = "title"; - String PARAM_SITE_DESCRIPTION = "description"; + String PARAM_SKIP_ADDTOFAVORITES = "skipAddToFavorites"; + String PARAM_SKIP_SURF_CONFIGURATION = "skipConfiguration"; - String PARAM_SITE_ROLE = "role"; + String PARAM_SITE_ID = "id"; + String PARAM_SITE_TITLE = "title"; + String PARAM_SITE_DESCRIPTION = "description"; + + String PARAM_SITE_ROLE = "role"; String PARAM_VISIBILITY = "visibility"; String PARAM_PRESET = "preset"; } diff --git a/source/java/org/alfresco/rest/api/model/Site.java b/source/java/org/alfresco/rest/api/model/Site.java index 39a7f21e20..893fb5fa32 100644 --- a/source/java/org/alfresco/rest/api/model/Site.java +++ b/source/java/org/alfresco/rest/api/model/Site.java @@ -26,7 +26,6 @@ package org.alfresco.rest.api.model; import org.alfresco.rest.framework.resource.UniqueId; -import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteVisibility; @@ -38,80 +37,80 @@ import org.alfresco.service.cmr.site.SiteVisibility; */ public class Site implements Comparable { - public static final String ROLE = "role"; + public static final String ROLE = "role"; - protected String id; // site id (aka short name) - protected String guid; // site nodeId - protected String title; - protected String description; - protected SiteVisibility visibility; + protected String id; // site id (aka short name) + protected String guid; // site nodeId + protected String title; + protected String description; + protected SiteVisibility visibility; protected String preset; - protected String role; + protected String role; - public Site() - { - } - - public Site(SiteInfo siteInfo, String role) - { - if(siteInfo == null) - { - throw new IllegalArgumentException("Must provide siteInfo"); - } - this.id = siteInfo.getShortName(); - this.guid = siteInfo.getNodeRef().getId(); - this.title = siteInfo.getTitle(); - this.description = siteInfo.getDescription(); - this.visibility = siteInfo.getVisibility(); + public Site() + { + } + + public Site(SiteInfo siteInfo, String role) + { + if (siteInfo == null) + { + throw new IllegalArgumentException("Must provide siteInfo"); + } + this.id = siteInfo.getShortName(); + this.guid = siteInfo.getNodeRef().getId(); + this.title = siteInfo.getTitle(); + this.description = siteInfo.getDescription(); + this.visibility = siteInfo.getVisibility(); this.preset = siteInfo.getSitePreset(); - this.role = role; - } + this.role = role; + } - @UniqueId - public String getId() - { - return id; - } - - public void setId(String id) - { - this.id = id; - } - - public String getGuid() - { - return guid; - } + @UniqueId + public String getId() + { + return id; + } - public void setGuid(String guid) - { - this.guid = guid; - } + public void setId(String id) + { + this.id = id; + } - public String getTitle() - { - return title; - } + public String getGuid() + { + return guid; + } + + public void setGuid(String guid) + { + this.guid = guid; + } + + public String getTitle() + { + return title; + } public void setTitle(String title) { this.title = title; } - public String getDescription() - { - return description; - } + public String getDescription() + { + return description; + } public void setDescription(String description) { this.description = description; } - public SiteVisibility getVisibility() - { - return visibility; - } + public SiteVisibility getVisibility() + { + return visibility; + } public void setVisibility(SiteVisibility visibility) { @@ -122,7 +121,7 @@ public class Site implements Comparable { return preset; } - + public void setPreset(String preset) { this.preset = preset; @@ -138,50 +137,49 @@ public class Site implements Comparable this.role = role; } - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - Site other = (Site) obj; - return id.equals(other.id); - } - - @Override - public int compareTo(Site site) - { - return id.compareTo(site.getId()); - } + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + + if (obj == null) + { + return false; + } + + if (getClass() != obj.getClass()) + { + return false; + } + + Site other = (Site) obj; + return id.equals(other.id); + } @Override - public int hashCode() + public int compareTo(Site site) { - final int prime = 31; - int result = 1; - result = prime * result - + ((id == null) ? 0 : id.hashCode()); - return result; - } + return id.compareTo(site.getId()); + } - @Override - public String toString() - { - return "Site [id=" + id + ", guid=" + guid + ", title=" + title - + ", description=" + description + ", visibility=" + visibility - + "]"; - } + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + + ((id == null) ? 0 : id.hashCode()); + return result; + } + @Override + public String toString() + { + return "Site [id=" + id + ", guid=" + guid + ", title=" + title + + ", description=" + description + ", visibility=" + visibility + + "]"; + } } \ No newline at end of file diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/Site.java b/source/test-java/org/alfresco/rest/api/tests/client/data/Site.java index 316da16288..fc9493319b 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/data/Site.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/Site.java @@ -29,27 +29,27 @@ import org.json.simple.JSONObject; public interface Site extends JSONAble { - Boolean getCreated(); + Boolean getCreated(); Site withCreated(Boolean created); - String getGuid(); + String getGuid(); Site withGuid(String guid); - String getNetworkId(); + String getNetworkId(); Site withNetworkId(String networkId); - Boolean isCreated(); - String getSiteId(); + Boolean isCreated(); + String getSiteId(); Site withSiteId(String siteId); - String getTitle(); + String getTitle(); Site withTitle(String title); - String getDescription(); + String getDescription(); Site withDescription(String description); - String getVisibility(); + String getVisibility(); Site withVisibility(String visibility); String getPreset(); Site withPreset(String preset); - String getType(); + String getType(); Site withType(String type); - SiteRole getRole(); + SiteRole getRole(); Site withRole(SiteRole role); - void expected(Object o); - JSONObject toJSON(); + void expected(Object o); + JSONObject toJSON(); } diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/SiteImpl.java b/source/test-java/org/alfresco/rest/api/tests/client/data/SiteImpl.java index 9ade2cfd38..d8aeda0f9d 100644 --- a/source/test-java/org/alfresco/rest/api/tests/client/data/SiteImpl.java +++ b/source/test-java/org/alfresco/rest/api/tests/client/data/SiteImpl.java @@ -40,90 +40,90 @@ import org.json.simple.JSONObject; public class SiteImpl implements Serializable, Site, Comparable, ExpectedComparison { - private static final long serialVersionUID = -3774392026234649419L; + private static final long serialVersionUID = -3774392026234649419L; - public static final String FIELD_SITE_ID = "siteId"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_HAS_MEMBERS = "hasMembers"; + public static final String FIELD_SITE_ID = "siteId"; + public static final String FIELD_CREATED = "created"; + public static final String FIELD_HAS_MEMBERS = "hasMembers"; protected Boolean created = false; - protected String networkId; - protected String siteId; - protected String guid; - protected String title; - protected String description; - protected SiteRole role; - protected String visibility; // one of (PUBLIC,MODERATED,PRIVATE), defaults to PUBLIC + protected String networkId; + protected String siteId; + protected String guid; + protected String title; + protected String description; + protected SiteRole role; + protected String visibility; // one of (PUBLIC,MODERATED,PRIVATE), defaults to PUBLIC protected String preset; - protected String type; - + protected String type; + public SiteImpl() { } - public SiteImpl(String title, String visibility) - { - if (title == null) - { - throw new java.lang.IllegalArgumentException(); - } + public SiteImpl(String title, String visibility) + { + if (title == null) + { + throw new java.lang.IllegalArgumentException(); + } + + if (visibility == null) + { + throw new java.lang.IllegalArgumentException(); + } + this.title = title; + this.visibility = visibility; + } - if (visibility == null) - { - throw new java.lang.IllegalArgumentException(); - } - this.title = title; - this.visibility = visibility; - } - public SiteImpl(String networkId, String siteId, String guid) { - if (siteId == null) - { - throw new java.lang.IllegalArgumentException(); - } + if (siteId == null) + { + throw new java.lang.IllegalArgumentException(); + } - if (guid == null) - { - throw new java.lang.IllegalArgumentException(); - } - this.networkId = networkId; - this.siteId = siteId; - this.guid = guid; + if (guid == null) + { + throw new java.lang.IllegalArgumentException(); + } + this.networkId = networkId; + this.siteId = siteId; + this.guid = guid; } public SiteImpl(SiteInfo siteInfo, SiteRole siteRole, Boolean created) { - this.siteId = siteInfo.getShortName(); - this.description = siteInfo.getDescription(); - this.title = siteInfo.getTitle(); - this.visibility = siteInfo.getVisibility().toString(); - this.created = created; - this.guid = siteInfo.getNodeRef().getId(); + this.siteId = siteInfo.getShortName(); + this.description = siteInfo.getDescription(); + this.title = siteInfo.getTitle(); + this.visibility = siteInfo.getVisibility().toString(); + this.created = created; + this.guid = siteInfo.getNodeRef().getId(); } - public SiteImpl(String siteId, String title, String description, String visibility) - { - super(); - this.siteId = siteId; - this.title = title; - this.description = description; - this.visibility = visibility; - } + public SiteImpl(String siteId, String title, String description, String visibility) + { + super(); + this.siteId = siteId; + this.title = title; + this.description = description; + this.visibility = visibility; + } - public SiteImpl(String networkId, String siteId, String guid, String title, String description, - String visibility, String type, SiteRole siteRole) - { - super(); - this.networkId = networkId; - this.siteId = siteId; - this.title = title; - this.description = description; - this.visibility = visibility; - this.type = type; - this.role = siteRole; - this.guid = guid; - } + public SiteImpl(String networkId, String siteId, String guid, String title, String description, + String visibility, String type, SiteRole siteRole) + { + super(); + this.networkId = networkId; + this.siteId = siteId; + this.title = title; + this.description = description; + this.visibility = visibility; + this.type = type; + this.role = siteRole; + this.guid = guid; + } @Override public Site withCreated(Boolean created) @@ -195,191 +195,191 @@ public class SiteImpl implements Serializable, Site, Comparable, Expec return this; } - @Override - public void expected(Object o) - { - assertTrue(o instanceof SiteImpl); - - SiteImpl site = (SiteImpl)o; - - AssertUtil.assertEquals("siteId", getSiteId(), site.getSiteId()); - AssertUtil.assertEquals("guid", getGuid(), site.getGuid()); - AssertUtil.assertEquals("title", getTitle(), site.getTitle()); - AssertUtil.assertEquals("description", getDescription(), site.getDescription()); - AssertUtil.assertEquals("visibility", getVisibility(), site.getVisibility()); - AssertUtil.assertEquals("role", getRole(), site.getRole()); - } - - - public Boolean getCreated() - { - return created; - } + @Override + public void expected(Object o) + { + assertTrue(o instanceof SiteImpl); - public String getGuid() - { - return guid; - } + SiteImpl site = (SiteImpl)o; - public String getNetworkId() - { - return networkId; - } + AssertUtil.assertEquals("siteId", getSiteId(), site.getSiteId()); + AssertUtil.assertEquals("guid", getGuid(), site.getGuid()); + AssertUtil.assertEquals("title", getTitle(), site.getTitle()); + AssertUtil.assertEquals("description", getDescription(), site.getDescription()); + AssertUtil.assertEquals("visibility", getVisibility(), site.getVisibility()); + AssertUtil.assertEquals("role", getRole(), site.getRole()); + } - public Boolean isCreated() - { - return created; - } - public void setCreated(Boolean created) - { - this.created = created; - } + public Boolean getCreated() + { + return created; + } - public String getSiteId() - { - return siteId; - } - - public String getTitle() - { - return title; - } - - public String getDescription() - { - return description; - } - - public String getVisibility() - { - return visibility; - } + public String getGuid() + { + return guid; + } + + public String getNetworkId() + { + return networkId; + } + + public Boolean isCreated() + { + return created; + } + + public void setCreated(Boolean created) + { + this.created = created; + } + + public String getSiteId() + { + return siteId; + } + + public String getTitle() + { + return title; + } + + public String getDescription() + { + return description; + } + + public String getVisibility() + { + return visibility; + } public String getPreset() { return preset; } - public String getType() - { - return type; - } + public String getType() + { + return type; + } - public void setNetworkId(String networkId) - { - this.networkId = networkId; - } + public void setNetworkId(String networkId) + { + this.networkId = networkId; + } - public void setSiteId(String siteId) - { - this.siteId = siteId; - } - - public void setGuid(String guid) - { - this.guid = guid; - } + public void setSiteId(String siteId) + { + this.siteId = siteId; + } - public void setTitle(String title) - { - this.title = title; - } + public void setGuid(String guid) + { + this.guid = guid; + } - public void setDescription(String description) - { - this.description = description; - } + public void setTitle(String title) + { + this.title = title; + } - public void setVisibility(String visibility) - { - this.visibility = visibility; - } + public void setDescription(String description) + { + this.description = description; + } + + public void setVisibility(String visibility) + { + this.visibility = visibility; + } public void setPreset(String preset) { this.preset = preset; } - public void setType(String type) - { - this.type = type; - } + public void setType(String type) + { + this.type = type; + } - public static Site parseSite(JSONObject jsonObject) - { - if (jsonObject == null) - { - return null; - } + public static Site parseSite(JSONObject jsonObject) + { + if (jsonObject == null) + { + return null; + } - String id = (String)jsonObject.get("id"); - String guid = (String)jsonObject.get("guid"); - String title = (String)jsonObject.get("title"); - String description = (String)jsonObject.get("description"); - String visibility = (String)jsonObject.get("visibility"); - String roleStr = (String)jsonObject.get("role"); - SiteRole role = null; - if(roleStr != null) - { - role = SiteRole.valueOf(roleStr); - } - SiteImpl site = new SiteImpl(null, id, guid, title, description, visibility, "st:site", role); - return site; - } - - public static ListResponse parseSites(JSONObject jsonObject) - { - List sites = new ArrayList(); + String id = (String)jsonObject.get("id"); + String guid = (String)jsonObject.get("guid"); + String title = (String)jsonObject.get("title"); + String description = (String)jsonObject.get("description"); + String visibility = (String)jsonObject.get("visibility"); + String roleStr = (String)jsonObject.get("role"); + SiteRole role = null; + if(roleStr != null) + { + role = SiteRole.valueOf(roleStr); + } + SiteImpl site = new SiteImpl(null, id, guid, title, description, visibility, "st:site", role); + return site; + } - JSONObject jsonList = (JSONObject)jsonObject.get("list"); - assertNotNull(jsonList); + public static ListResponse parseSites(JSONObject jsonObject) + { + List sites = new ArrayList(); - JSONArray jsonEntries = (JSONArray)jsonList.get("entries"); - assertNotNull(jsonEntries); + JSONObject jsonList = (JSONObject)jsonObject.get("list"); + assertNotNull(jsonList); - for(int i = 0; i < jsonEntries.size(); i++) - { - JSONObject jsonEntry = (JSONObject)jsonEntries.get(i); - JSONObject entry = (JSONObject)jsonEntry.get("entry"); - sites.add(parseSite(entry)); - } + JSONArray jsonEntries = (JSONArray)jsonList.get("entries"); + assertNotNull(jsonEntries); - ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList); + for(int i = 0; i < jsonEntries.size(); i++) + { + JSONObject jsonEntry = (JSONObject)jsonEntries.get(i); + JSONObject entry = (JSONObject)jsonEntry.get("entry"); + sites.add(parseSite(entry)); + } - ListResponse resp = new ListResponse(paging, sites); - return resp; - } - - @Override - public SiteRole getRole() - { - return role; - } + ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList); - public void setRole(SiteRole role) - { - this.role = role; - } - - @Override - public String toString() - { - return "Site [created=" + created + ", networkId=" + networkId - + ", siteId=" + siteId + ", guid=" + guid + ", title=" + title - + ", description=" + description + ", role=" + role - + ", visibility=" + visibility + ", type=" + type + "]"; - } + ListResponse resp = new ListResponse(paging, sites); + return resp; + } - @SuppressWarnings("unchecked") - public JSONObject toJSON() - { - JSONObject siteJson = new JSONObject(); - if (getSiteId() != null) + @Override + public SiteRole getRole() + { + return role; + } + + public void setRole(SiteRole role) + { + this.role = role; + } + + @Override + public String toString() + { + return "Site [created=" + created + ", networkId=" + networkId + + ", siteId=" + siteId + ", guid=" + guid + ", title=" + title + + ", description=" + description + ", role=" + role + + ", visibility=" + visibility + ", type=" + type + "]"; + } + + @SuppressWarnings("unchecked") + public JSONObject toJSON() + { + JSONObject siteJson = new JSONObject(); + if (getSiteId() != null) { siteJson.put("id", getSiteId()); } - if (getGuid() != null) + if (getGuid() != null) { siteJson.put("guid", getGuid()); } @@ -399,48 +399,48 @@ public class SiteImpl implements Serializable, Site, Comparable, Expec { siteJson.put("preset", getPreset()); } - return siteJson; - } + return siteJson; + } - @Override - public int compareTo(SiteImpl site) - { - return siteId.compareTo(site.getSiteId()); - } + @Override + public int compareTo(SiteImpl site) + { + return siteId.compareTo(site.getSiteId()); + } - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result - + ((networkId == null) ? 0 : networkId.hashCode()); - result = prime * result + ((siteId == null) ? 0 : siteId.hashCode()); - return result; - } + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + + ((networkId == null) ? 0 : networkId.hashCode()); + result = prime * result + ((siteId == null) ? 0 : siteId.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; - SiteImpl other = (SiteImpl) obj; - if (networkId == null) - { - if (other.networkId != null) - return false; - } else if (!networkId.equals(other.networkId)) - return false; - if (siteId == null) - { - if (other.siteId != null) - return false; - } else if (!siteId.equals(other.siteId)) - return false; - return true; - } + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SiteImpl other = (SiteImpl) obj; + if (networkId == null) + { + if (other.networkId != null) + return false; + } else if (!networkId.equals(other.networkId)) + return false; + if (siteId == null) + { + if (other.siteId != null) + return false; + } else if (!siteId.equals(other.siteId)) + return false; + return true; + } }