Minor - re-formatting only (fix tabs to spaces)

- noted via REPO-1390

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@131866 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2016-10-28 14:35:42 +00:00
parent 96953c1bb7
commit 0e7a674d41
4 changed files with 374 additions and 376 deletions

View File

@@ -42,7 +42,7 @@ public interface Sites
void deleteSite(String siteId, Parameters parameters); void deleteSite(String siteId, Parameters parameters);
Site createSite(Site site, Parameters parameters); Site createSite(Site site, Parameters parameters);
Site updateSite(String siteId, SiteUpdate site, Parameters parameters); Site updateSite(String siteId, SiteUpdate site, Parameters parameters);
/** /**
* people/<personId>/sites/<siteId> * people/<personId>/sites/<siteId>
* *
@@ -63,19 +63,19 @@ public interface Sites
void addFavouriteSite(String personId, FavouriteSite favouriteSite); void addFavouriteSite(String personId, FavouriteSite favouriteSite);
void removeFavouriteSite(String personId, String siteId); void removeFavouriteSite(String personId, String siteId);
CollectionWithPagingInfo<FavouriteSite> getFavouriteSites(String personId, Parameters parameters); CollectionWithPagingInfo<FavouriteSite> getFavouriteSites(String personId, Parameters parameters);
String getSiteRole(String siteId); String getSiteRole(String siteId);
String getSiteRole(String siteId, String personId); String getSiteRole(String siteId, String personId);
String PARAM_PERMANENT = "permanent"; String PARAM_PERMANENT = "permanent";
String PARAM_SKIP_ADDTOFAVORITES = "skipAddToFavorites"; String PARAM_SKIP_ADDTOFAVORITES = "skipAddToFavorites";
String PARAM_SKIP_SURF_CONFIGURATION = "skipConfiguration"; String PARAM_SKIP_SURF_CONFIGURATION = "skipConfiguration";
String PARAM_SITE_ID = "id";
String PARAM_SITE_TITLE = "title";
String PARAM_SITE_DESCRIPTION = "description";
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_VISIBILITY = "visibility";
String PARAM_PRESET = "preset"; String PARAM_PRESET = "preset";
} }

View File

@@ -26,7 +26,6 @@
package org.alfresco.rest.api.model; package org.alfresco.rest.api.model;
import org.alfresco.rest.framework.resource.UniqueId; 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.SiteInfo;
import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.service.cmr.site.SiteVisibility;
@@ -38,80 +37,80 @@ import org.alfresco.service.cmr.site.SiteVisibility;
*/ */
public class Site implements Comparable<Site> public class Site implements Comparable<Site>
{ {
public static final String ROLE = "role"; public static final String ROLE = "role";
protected String id; // site id (aka short name) protected String id; // site id (aka short name)
protected String guid; // site nodeId protected String guid; // site nodeId
protected String title; protected String title;
protected String description; protected String description;
protected SiteVisibility visibility; protected SiteVisibility visibility;
protected String preset; protected String preset;
protected String role; protected String role;
public Site() public Site()
{ {
} }
public Site(SiteInfo siteInfo, String role) public Site(SiteInfo siteInfo, String role)
{ {
if(siteInfo == null) if (siteInfo == null)
{ {
throw new IllegalArgumentException("Must provide siteInfo"); throw new IllegalArgumentException("Must provide siteInfo");
} }
this.id = siteInfo.getShortName(); this.id = siteInfo.getShortName();
this.guid = siteInfo.getNodeRef().getId(); this.guid = siteInfo.getNodeRef().getId();
this.title = siteInfo.getTitle(); this.title = siteInfo.getTitle();
this.description = siteInfo.getDescription(); this.description = siteInfo.getDescription();
this.visibility = siteInfo.getVisibility(); this.visibility = siteInfo.getVisibility();
this.preset = siteInfo.getSitePreset(); this.preset = siteInfo.getSitePreset();
this.role = role; this.role = role;
} }
@UniqueId @UniqueId
public String getId() public String getId()
{ {
return id; return id;
} }
public void setId(String id)
{
this.id = id;
}
public String getGuid()
{
return guid;
}
public void setGuid(String guid) public void setId(String id)
{ {
this.guid = guid; this.id = id;
} }
public String getTitle() public String getGuid()
{ {
return title; return guid;
} }
public void setGuid(String guid)
{
this.guid = guid;
}
public String getTitle()
{
return title;
}
public void setTitle(String title) public void setTitle(String title)
{ {
this.title = title; this.title = title;
} }
public String getDescription() public String getDescription()
{ {
return description; return description;
} }
public void setDescription(String description) public void setDescription(String description)
{ {
this.description = description; this.description = description;
} }
public SiteVisibility getVisibility() public SiteVisibility getVisibility()
{ {
return visibility; return visibility;
} }
public void setVisibility(SiteVisibility visibility) public void setVisibility(SiteVisibility visibility)
{ {
@@ -122,7 +121,7 @@ public class Site implements Comparable<Site>
{ {
return preset; return preset;
} }
public void setPreset(String preset) public void setPreset(String preset)
{ {
this.preset = preset; this.preset = preset;
@@ -138,50 +137,49 @@ public class Site implements Comparable<Site>
this.role = role; this.role = role;
} }
@Override @Override
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if (this == obj) if (this == obj)
{ {
return true; return true;
} }
if (obj == null) if (obj == null)
{ {
return false; return false;
} }
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
{ {
return false; return false;
} }
Site other = (Site) obj; Site other = (Site) obj;
return id.equals(other.id); return id.equals(other.id);
} }
@Override
public int compareTo(Site site)
{
return id.compareTo(site.getId());
}
@Override @Override
public int hashCode() public int compareTo(Site site)
{ {
final int prime = 31; return id.compareTo(site.getId());
int result = 1; }
result = prime * result
+ ((id == null) ? 0 : id.hashCode());
return result;
}
@Override @Override
public String toString() public int hashCode()
{ {
return "Site [id=" + id + ", guid=" + guid + ", title=" + title final int prime = 31;
+ ", description=" + description + ", visibility=" + visibility 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
+ "]";
}
} }

View File

@@ -29,27 +29,27 @@ import org.json.simple.JSONObject;
public interface Site extends JSONAble public interface Site extends JSONAble
{ {
Boolean getCreated(); Boolean getCreated();
Site withCreated(Boolean created); Site withCreated(Boolean created);
String getGuid(); String getGuid();
Site withGuid(String guid); Site withGuid(String guid);
String getNetworkId(); String getNetworkId();
Site withNetworkId(String networkId); Site withNetworkId(String networkId);
Boolean isCreated(); Boolean isCreated();
String getSiteId(); String getSiteId();
Site withSiteId(String siteId); Site withSiteId(String siteId);
String getTitle(); String getTitle();
Site withTitle(String title); Site withTitle(String title);
String getDescription(); String getDescription();
Site withDescription(String description); Site withDescription(String description);
String getVisibility(); String getVisibility();
Site withVisibility(String visibility); Site withVisibility(String visibility);
String getPreset(); String getPreset();
Site withPreset(String preset); Site withPreset(String preset);
String getType(); String getType();
Site withType(String type); Site withType(String type);
SiteRole getRole(); SiteRole getRole();
Site withRole(SiteRole role); Site withRole(SiteRole role);
void expected(Object o); void expected(Object o);
JSONObject toJSON(); JSONObject toJSON();
} }

View File

@@ -40,90 +40,90 @@ import org.json.simple.JSONObject;
public class SiteImpl implements Serializable, Site, Comparable<SiteImpl>, ExpectedComparison public class SiteImpl implements Serializable, Site, Comparable<SiteImpl>, 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_SITE_ID = "siteId";
public static final String FIELD_CREATED = "created"; public static final String FIELD_CREATED = "created";
public static final String FIELD_HAS_MEMBERS = "hasMembers"; public static final String FIELD_HAS_MEMBERS = "hasMembers";
protected Boolean created = false; protected Boolean created = false;
protected String networkId; protected String networkId;
protected String siteId; protected String siteId;
protected String guid; protected String guid;
protected String title; protected String title;
protected String description; protected String description;
protected SiteRole role; protected SiteRole role;
protected String visibility; // one of (PUBLIC,MODERATED,PRIVATE), defaults to PUBLIC protected String visibility; // one of (PUBLIC,MODERATED,PRIVATE), defaults to PUBLIC
protected String preset; protected String preset;
protected String type; protected String type;
public SiteImpl() public SiteImpl()
{ {
} }
public SiteImpl(String title, String visibility) public SiteImpl(String title, String visibility)
{ {
if (title == null) if (title == null)
{ {
throw new java.lang.IllegalArgumentException(); 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) public SiteImpl(String networkId, String siteId, String guid)
{ {
if (siteId == null) if (siteId == null)
{ {
throw new java.lang.IllegalArgumentException(); throw new java.lang.IllegalArgumentException();
} }
if (guid == null) if (guid == null)
{ {
throw new java.lang.IllegalArgumentException(); throw new java.lang.IllegalArgumentException();
} }
this.networkId = networkId; this.networkId = networkId;
this.siteId = siteId; this.siteId = siteId;
this.guid = guid; this.guid = guid;
} }
public SiteImpl(SiteInfo siteInfo, SiteRole siteRole, Boolean created) public SiteImpl(SiteInfo siteInfo, SiteRole siteRole, Boolean created)
{ {
this.siteId = siteInfo.getShortName(); this.siteId = siteInfo.getShortName();
this.description = siteInfo.getDescription(); this.description = siteInfo.getDescription();
this.title = siteInfo.getTitle(); this.title = siteInfo.getTitle();
this.visibility = siteInfo.getVisibility().toString(); this.visibility = siteInfo.getVisibility().toString();
this.created = created; this.created = created;
this.guid = siteInfo.getNodeRef().getId(); this.guid = siteInfo.getNodeRef().getId();
} }
public SiteImpl(String siteId, String title, String description, String visibility) public SiteImpl(String siteId, String title, String description, String visibility)
{ {
super(); super();
this.siteId = siteId; this.siteId = siteId;
this.title = title; this.title = title;
this.description = description; this.description = description;
this.visibility = visibility; this.visibility = visibility;
} }
public SiteImpl(String networkId, String siteId, String guid, String title, String description, public SiteImpl(String networkId, String siteId, String guid, String title, String description,
String visibility, String type, SiteRole siteRole) String visibility, String type, SiteRole siteRole)
{ {
super(); super();
this.networkId = networkId; this.networkId = networkId;
this.siteId = siteId; this.siteId = siteId;
this.title = title; this.title = title;
this.description = description; this.description = description;
this.visibility = visibility; this.visibility = visibility;
this.type = type; this.type = type;
this.role = siteRole; this.role = siteRole;
this.guid = guid; this.guid = guid;
} }
@Override @Override
public Site withCreated(Boolean created) public Site withCreated(Boolean created)
@@ -195,191 +195,191 @@ public class SiteImpl implements Serializable, Site, Comparable<SiteImpl>, Expec
return this; return this;
} }
@Override @Override
public void expected(Object o) public void expected(Object o)
{ {
assertTrue(o instanceof SiteImpl); 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;
}
public String getGuid() SiteImpl site = (SiteImpl)o;
{
return guid;
}
public String getNetworkId() AssertUtil.assertEquals("siteId", getSiteId(), site.getSiteId());
{ AssertUtil.assertEquals("guid", getGuid(), site.getGuid());
return networkId; 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) public Boolean getCreated()
{ {
this.created = created; return created;
} }
public String getSiteId() public String getGuid()
{ {
return siteId; return guid;
} }
public String getTitle() public String getNetworkId()
{ {
return title; return networkId;
} }
public String getDescription() public Boolean isCreated()
{ {
return description; return created;
} }
public String getVisibility() public void setCreated(Boolean created)
{ {
return visibility; 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() public String getPreset()
{ {
return preset; return preset;
} }
public String getType() public String getType()
{ {
return type; return type;
} }
public void setNetworkId(String networkId) public void setNetworkId(String networkId)
{ {
this.networkId = networkId; this.networkId = networkId;
} }
public void setSiteId(String siteId) public void setSiteId(String siteId)
{ {
this.siteId = siteId; this.siteId = siteId;
} }
public void setGuid(String guid)
{
this.guid = guid;
}
public void setTitle(String title) public void setGuid(String guid)
{ {
this.title = title; this.guid = guid;
} }
public void setDescription(String description) public void setTitle(String title)
{ {
this.description = description; this.title = title;
} }
public void setVisibility(String visibility) public void setDescription(String description)
{ {
this.visibility = visibility; this.description = description;
} }
public void setVisibility(String visibility)
{
this.visibility = visibility;
}
public void setPreset(String preset) public void setPreset(String preset)
{ {
this.preset = preset; this.preset = preset;
} }
public void setType(String type) public void setType(String type)
{ {
this.type = type; this.type = type;
} }
public static Site parseSite(JSONObject jsonObject) public static Site parseSite(JSONObject jsonObject)
{ {
if (jsonObject == null) if (jsonObject == null)
{ {
return null; return null;
} }
String id = (String)jsonObject.get("id"); String id = (String)jsonObject.get("id");
String guid = (String)jsonObject.get("guid"); String guid = (String)jsonObject.get("guid");
String title = (String)jsonObject.get("title"); String title = (String)jsonObject.get("title");
String description = (String)jsonObject.get("description"); String description = (String)jsonObject.get("description");
String visibility = (String)jsonObject.get("visibility"); String visibility = (String)jsonObject.get("visibility");
String roleStr = (String)jsonObject.get("role"); String roleStr = (String)jsonObject.get("role");
SiteRole role = null; SiteRole role = null;
if(roleStr != null) if(roleStr != null)
{ {
role = SiteRole.valueOf(roleStr); role = SiteRole.valueOf(roleStr);
} }
SiteImpl site = new SiteImpl(null, id, guid, title, description, visibility, "st:site", role); SiteImpl site = new SiteImpl(null, id, guid, title, description, visibility, "st:site", role);
return site; return site;
} }
public static ListResponse<Site> parseSites(JSONObject jsonObject)
{
List<Site> sites = new ArrayList<Site>();
JSONObject jsonList = (JSONObject)jsonObject.get("list"); public static ListResponse<Site> parseSites(JSONObject jsonObject)
assertNotNull(jsonList); {
List<Site> sites = new ArrayList<Site>();
JSONArray jsonEntries = (JSONArray)jsonList.get("entries"); JSONObject jsonList = (JSONObject)jsonObject.get("list");
assertNotNull(jsonEntries); assertNotNull(jsonList);
for(int i = 0; i < jsonEntries.size(); i++) JSONArray jsonEntries = (JSONArray)jsonList.get("entries");
{ assertNotNull(jsonEntries);
JSONObject jsonEntry = (JSONObject)jsonEntries.get(i);
JSONObject entry = (JSONObject)jsonEntry.get("entry");
sites.add(parseSite(entry));
}
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<Site> resp = new ListResponse<Site>(paging, sites); ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
return resp;
}
@Override
public SiteRole getRole()
{
return role;
}
public void setRole(SiteRole role) ListResponse<Site> resp = new ListResponse<Site>(paging, sites);
{ return resp;
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") @Override
public JSONObject toJSON() public SiteRole getRole()
{ {
JSONObject siteJson = new JSONObject(); return role;
if (getSiteId() != null) }
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()); siteJson.put("id", getSiteId());
} }
if (getGuid() != null) if (getGuid() != null)
{ {
siteJson.put("guid", getGuid()); siteJson.put("guid", getGuid());
} }
@@ -399,48 +399,48 @@ public class SiteImpl implements Serializable, Site, Comparable<SiteImpl>, Expec
{ {
siteJson.put("preset", getPreset()); siteJson.put("preset", getPreset());
} }
return siteJson; return siteJson;
} }
@Override @Override
public int compareTo(SiteImpl site) public int compareTo(SiteImpl site)
{ {
return siteId.compareTo(site.getSiteId()); return siteId.compareTo(site.getSiteId());
} }
@Override @Override
public int hashCode() public int hashCode()
{ {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result result = prime * result
+ ((networkId == null) ? 0 : networkId.hashCode()); + ((networkId == null) ? 0 : networkId.hashCode());
result = prime * result + ((siteId == null) ? 0 : siteId.hashCode()); result = prime * result + ((siteId == null) ? 0 : siteId.hashCode());
return result; return result;
} }
@Override @Override
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if (this == obj) if (this == obj)
return true; return true;
if (obj == null) if (obj == null)
return false; return false;
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
SiteImpl other = (SiteImpl) obj; SiteImpl other = (SiteImpl) obj;
if (networkId == null) if (networkId == null)
{ {
if (other.networkId != null) if (other.networkId != null)
return false; return false;
} else if (!networkId.equals(other.networkId)) } else if (!networkId.equals(other.networkId))
return false; return false;
if (siteId == null) if (siteId == null)
{ {
if (other.siteId != null) if (other.siteId != null)
return false; return false;
} else if (!siteId.equals(other.siteId)) } else if (!siteId.equals(other.siteId))
return false; return false;
return true; return true;
} }
} }