mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.2.N (5.2.1) to HEAD (5.2)
129189 mmuller: Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1) 129011 adavis: REPO-243 People Live Search - Fix build failures - replace tabs in Person.java git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@129363 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -46,6 +46,7 @@ import org.junit.runners.Suite;
|
|||||||
NodeAssociationsApiTest.class,
|
NodeAssociationsApiTest.class,
|
||||||
NodeVersionsApiTest.class,
|
NodeVersionsApiTest.class,
|
||||||
QueriesNodesApiTest.class,
|
QueriesNodesApiTest.class,
|
||||||
|
QueriesPeopleApiTest.class,
|
||||||
RenditionsTest.class,
|
RenditionsTest.class,
|
||||||
SharedLinkApiTest.class,
|
SharedLinkApiTest.class,
|
||||||
ActivitiesPostingTest.class,
|
ActivitiesPostingTest.class,
|
||||||
|
@@ -348,10 +348,10 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
|||||||
assertEquals(content1_Id, node.getId());
|
assertEquals(content1_Id, node.getId());
|
||||||
UserInfo createdByUser = node.getCreatedByUser();
|
UserInfo createdByUser = node.getCreatedByUser();
|
||||||
assertEquals(user1, createdByUser.getId());
|
assertEquals(user1, createdByUser.getId());
|
||||||
assertEquals(user1 + " " + user1, createdByUser.getDisplayName());
|
assertEquals(UserInfo.getTestDisplayName(user1), createdByUser.getDisplayName());
|
||||||
UserInfo modifiedByUser = node.getModifiedByUser();
|
UserInfo modifiedByUser = node.getModifiedByUser();
|
||||||
assertEquals(user1, modifiedByUser.getId());
|
assertEquals(user1, modifiedByUser.getId());
|
||||||
assertEquals(user1 + " " + user1, modifiedByUser.getDisplayName());
|
assertEquals(UserInfo.getTestDisplayName(user1), modifiedByUser.getDisplayName());
|
||||||
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, node.getContent().getMimeType());
|
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, node.getContent().getMimeType());
|
||||||
assertNotNull(node.getContent().getMimeTypeName());
|
assertNotNull(node.getContent().getMimeTypeName());
|
||||||
assertNotNull(node.getContent().getEncoding());
|
assertNotNull(node.getContent().getEncoding());
|
||||||
@@ -665,7 +665,7 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
|||||||
String content_Id = documentResp.getId();
|
String content_Id = documentResp.getId();
|
||||||
|
|
||||||
// Expected result ...
|
// Expected result ...
|
||||||
UserInfo expectedUser = new UserInfo(user1, user1+" "+user1);
|
UserInfo expectedUser = new UserInfo(user1);
|
||||||
|
|
||||||
Document d1 = new Document();
|
Document d1 = new Document();
|
||||||
d1.setId(content_Id);
|
d1.setId(content_Id);
|
||||||
@@ -1912,7 +1912,7 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
|||||||
|
|
||||||
String myNodeId = getMyNodeId();
|
String myNodeId = getMyNodeId();
|
||||||
|
|
||||||
UserInfo expectedUser = new UserInfo(user1, user1+" "+user1);
|
UserInfo expectedUser = new UserInfo(user1);
|
||||||
|
|
||||||
String postUrl = getNodeChildrenUrl(myNodeId);
|
String postUrl = getNodeChildrenUrl(myNodeId);
|
||||||
|
|
||||||
@@ -2392,7 +2392,7 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
|||||||
setRequestContext(user1);
|
setRequestContext(user1);
|
||||||
|
|
||||||
String myNodeId = getMyNodeId();
|
String myNodeId = getMyNodeId();
|
||||||
UserInfo expectedUser = new UserInfo(user1, user1+" "+user1);
|
UserInfo expectedUser = new UserInfo(user1);
|
||||||
String myChildrenUrl = getNodeChildrenUrl(myNodeId);
|
String myChildrenUrl = getNodeChildrenUrl(myNodeId);
|
||||||
|
|
||||||
// create folder f1
|
// create folder f1
|
||||||
@@ -2576,7 +2576,7 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
|||||||
String folder0Name = "f0-testCreateEmptyFile-"+RUNID;
|
String folder0Name = "f0-testCreateEmptyFile-"+RUNID;
|
||||||
String f0Id = createFolder(Nodes.PATH_MY, folder0Name).getId();
|
String f0Id = createFolder(Nodes.PATH_MY, folder0Name).getId();
|
||||||
|
|
||||||
UserInfo expectedUser = new UserInfo(user1, user1+" "+user1);
|
UserInfo expectedUser = new UserInfo(user1);
|
||||||
|
|
||||||
String postUrl = getNodeChildrenUrl(f0Id);
|
String postUrl = getNodeChildrenUrl(f0Id);
|
||||||
|
|
||||||
@@ -2718,7 +2718,7 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
|||||||
String folder0Name = "f0-testUpdateNodeInfo-"+RUNID;
|
String folder0Name = "f0-testUpdateNodeInfo-"+RUNID;
|
||||||
String f0Id = createFolder(Nodes.PATH_MY, folder0Name).getId();
|
String f0Id = createFolder(Nodes.PATH_MY, folder0Name).getId();
|
||||||
|
|
||||||
UserInfo expectedUser = new UserInfo(user1, user1+" "+user1);
|
UserInfo expectedUser = new UserInfo(user1);
|
||||||
|
|
||||||
String postUrl = getNodeChildrenUrl(f0Id);
|
String postUrl = getNodeChildrenUrl(f0Id);
|
||||||
|
|
||||||
|
@@ -38,6 +38,7 @@ import org.alfresco.rest.api.tests.client.data.Document;
|
|||||||
import org.alfresco.rest.api.tests.client.data.Node;
|
import org.alfresco.rest.api.tests.client.data.Node;
|
||||||
import org.alfresco.rest.api.tests.client.data.QuickShareLinkEmailRequest;
|
import org.alfresco.rest.api.tests.client.data.QuickShareLinkEmailRequest;
|
||||||
import org.alfresco.rest.api.tests.client.data.Rendition;
|
import org.alfresco.rest.api.tests.client.data.Rendition;
|
||||||
|
import org.alfresco.rest.api.tests.client.data.UserInfo;
|
||||||
import org.alfresco.rest.api.tests.util.MultiPartBuilder;
|
import org.alfresco.rest.api.tests.util.MultiPartBuilder;
|
||||||
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -153,10 +154,10 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
|||||||
|
|
||||||
assertEquals(docModifiedAt.getTime(), resp.getModifiedAt().getTime()); // not changed
|
assertEquals(docModifiedAt.getTime(), resp.getModifiedAt().getTime()); // not changed
|
||||||
assertEquals(docModifiedBy, resp.getModifiedByUser().getId()); // not changed (ie. not user2)
|
assertEquals(docModifiedBy, resp.getModifiedByUser().getId()); // not changed (ie. not user2)
|
||||||
assertEquals(docModifiedBy+" "+docModifiedBy, resp.getModifiedByUser().getDisplayName());
|
assertEquals(UserInfo.getTestDisplayName(docModifiedBy), resp.getModifiedByUser().getDisplayName());
|
||||||
|
|
||||||
assertEquals(user2, resp.getSharedByUser().getId());
|
assertEquals(user2, resp.getSharedByUser().getId());
|
||||||
assertEquals(user2+" "+user2, resp.getSharedByUser().getDisplayName());
|
assertEquals(UserInfo.getTestDisplayName(user2), resp.getSharedByUser().getDisplayName());
|
||||||
|
|
||||||
// -ve test - try to create again (same user) - already exists
|
// -ve test - try to create again (same user) - already exists
|
||||||
post(URL_SHARED_LINKS, toJsonAsStringNonNull(body), 409);
|
post(URL_SHARED_LINKS, toJsonAsStringNonNull(body), 409);
|
||||||
@@ -187,9 +188,9 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
|||||||
assertNull(resp.getAllowableOperations()); // include is ignored
|
assertNull(resp.getAllowableOperations()); // include is ignored
|
||||||
|
|
||||||
assertNull(resp.getModifiedByUser().getId()); // userId not returned
|
assertNull(resp.getModifiedByUser().getId()); // userId not returned
|
||||||
assertEquals(user1+" "+user1, resp.getModifiedByUser().getDisplayName());
|
assertEquals(UserInfo.getTestDisplayName(user1), resp.getModifiedByUser().getDisplayName());
|
||||||
assertNull(resp.getSharedByUser().getId()); // userId not returned
|
assertNull(resp.getSharedByUser().getId()); // userId not returned
|
||||||
assertEquals(user2+" "+user2, resp.getSharedByUser().getDisplayName());
|
assertEquals(UserInfo.getTestDisplayName(user2), resp.getSharedByUser().getDisplayName());
|
||||||
|
|
||||||
// access to get shared link info - pass user2 (but ignore in non-MT)
|
// access to get shared link info - pass user2 (but ignore in non-MT)
|
||||||
params = Collections.singletonMap("include", "allowableOperations");
|
params = Collections.singletonMap("include", "allowableOperations");
|
||||||
@@ -202,9 +203,9 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
|||||||
assertNull(resp.getAllowableOperations()); // include is ignored
|
assertNull(resp.getAllowableOperations()); // include is ignored
|
||||||
|
|
||||||
assertNull(resp.getModifiedByUser().getId()); // userId not returned
|
assertNull(resp.getModifiedByUser().getId()); // userId not returned
|
||||||
assertEquals(user1+" "+user1, resp.getModifiedByUser().getDisplayName());
|
assertEquals(UserInfo.getTestDisplayName(user1), resp.getModifiedByUser().getDisplayName());
|
||||||
assertNull(resp.getSharedByUser().getId()); // userId not returned
|
assertNull(resp.getSharedByUser().getId()); // userId not returned
|
||||||
assertEquals(user2+" "+user2, resp.getSharedByUser().getDisplayName());
|
assertEquals(UserInfo.getTestDisplayName(user2), resp.getSharedByUser().getDisplayName());
|
||||||
|
|
||||||
|
|
||||||
// allowable operations not included - no params
|
// allowable operations not included - no params
|
||||||
@@ -225,9 +226,9 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
|||||||
assertNull(resp.getAllowableOperations()); // include is ignored
|
assertNull(resp.getAllowableOperations()); // include is ignored
|
||||||
|
|
||||||
assertNull(resp.getModifiedByUser().getId()); // userId not returned
|
assertNull(resp.getModifiedByUser().getId()); // userId not returned
|
||||||
assertEquals(user1+" "+user1, resp.getModifiedByUser().getDisplayName());
|
assertEquals(UserInfo.getTestDisplayName(user1), resp.getModifiedByUser().getDisplayName());
|
||||||
assertNull(resp.getSharedByUser().getId()); // userId not returned
|
assertNull(resp.getSharedByUser().getId()); // userId not returned
|
||||||
assertEquals(user2+" "+user2, resp.getSharedByUser().getDisplayName());
|
assertEquals(UserInfo.getTestDisplayName(user2), resp.getSharedByUser().getDisplayName());
|
||||||
|
|
||||||
// unauth access to file 1 content (via shared link)
|
// unauth access to file 1 content (via shared link)
|
||||||
response = getSingle(QuickShareLinkEntityResource.class, shared1Id + "/content", null, 200);
|
response = getSingle(QuickShareLinkEntityResource.class, shared1Id + "/content", null, 200);
|
||||||
|
@@ -1,511 +1,511 @@
|
|||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* Alfresco Remote API
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
* provided under the following open source license terms:
|
* provided under the following open source license terms:
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.tests.client.data;
|
package org.alfresco.rest.api.tests.client.data;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.tenant.TenantService;
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging;
|
import org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging;
|
||||||
import org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse;
|
import org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
public class Person implements Serializable, Comparable<Person>, ExpectedComparison
|
public class Person implements Serializable, Comparable<Person>, ExpectedComparison
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 3185698391792389751L;
|
private static final long serialVersionUID = 3185698391792389751L;
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private Boolean enabled;
|
private Boolean enabled;
|
||||||
private String username;
|
private String username;
|
||||||
private String firstName;
|
private String firstName;
|
||||||
private String lastName;
|
private String lastName;
|
||||||
private Company company;
|
private Company company;
|
||||||
private String skype;
|
private String skype;
|
||||||
private String location;
|
private String location;
|
||||||
private String tel;
|
private String tel;
|
||||||
private String mob;
|
private String mob;
|
||||||
private String instantmsg;
|
private String instantmsg;
|
||||||
private String google;
|
private String google;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
private static Collator collator = Collator.getInstance();
|
private static Collator collator = Collator.getInstance();
|
||||||
|
|
||||||
public Person(String id, String username, Boolean enabled, String firstName, String lastName,
|
public Person(String id, String username, Boolean enabled, String firstName, String lastName,
|
||||||
Company company, String skype, String location, String tel,
|
Company company, String skype, String location, String tel,
|
||||||
String mob, String instantmsg, String google, String description)
|
String mob, String instantmsg, String google, String description)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
if(id == null)
|
if(id == null)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.firstName = firstName;
|
this.firstName = firstName;
|
||||||
this.lastName = lastName;
|
this.lastName = lastName;
|
||||||
this.company = company;
|
this.company = company;
|
||||||
this.skype = skype;
|
this.skype = skype;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.tel = tel;
|
this.tel = tel;
|
||||||
this.mob = mob;
|
this.mob = mob;
|
||||||
this.instantmsg = instantmsg;
|
this.instantmsg = instantmsg;
|
||||||
this.google = google;
|
this.google = google;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId()
|
public String getId()
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id)
|
public void setId(String id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getEnabled() {
|
public Boolean getEnabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(Boolean enabled) {
|
public void setEnabled(Boolean enabled) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsername(String username) {
|
public void setUsername(String username) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSkype() {
|
public String getSkype() {
|
||||||
return skype;
|
return skype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSkype(String skype) {
|
public void setSkype(String skype) {
|
||||||
this.skype = skype;
|
this.skype = skype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLocation() {
|
public String getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(String location) {
|
public void setLocation(String location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTel() {
|
public String getTel() {
|
||||||
return tel;
|
return tel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTel(String tel) {
|
public void setTel(String tel) {
|
||||||
this.tel = tel;
|
this.tel = tel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMob() {
|
public String getMob() {
|
||||||
return mob;
|
return mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMob(String mob) {
|
public void setMob(String mob) {
|
||||||
this.mob = mob;
|
this.mob = mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInstantmsg() {
|
public String getInstantmsg() {
|
||||||
return instantmsg;
|
return instantmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInstantmsg(String instantmsg) {
|
public void setInstantmsg(String instantmsg) {
|
||||||
this.instantmsg = instantmsg;
|
this.instantmsg = instantmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGoogle() {
|
public String getGoogle() {
|
||||||
return google;
|
return google;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGoogle(String google) {
|
public void setGoogle(String google) {
|
||||||
this.google = google;
|
this.google = google;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFirstName()
|
public String getFirstName()
|
||||||
{
|
{
|
||||||
return firstName;
|
return firstName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Company getCompany()
|
public Company getCompany()
|
||||||
{
|
{
|
||||||
return company;
|
return company;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCompany(Company company)
|
public void setCompany(Company company)
|
||||||
{
|
{
|
||||||
this.company = company;
|
this.company = company;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFirstName(String firstName)
|
public void setFirstName(String firstName)
|
||||||
{
|
{
|
||||||
this.firstName = firstName;
|
this.firstName = firstName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLastName()
|
public String getLastName()
|
||||||
{
|
{
|
||||||
return lastName;
|
return lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastName(String lastName)
|
public void setLastName(String lastName)
|
||||||
{
|
{
|
||||||
this.lastName = lastName;
|
this.lastName = lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "Person [" + (id != null ? "id=" + id + ", " : "")
|
return "Person [" + (id != null ? "id=" + id + ", " : "")
|
||||||
+ (enabled != null ? "enabled=" + enabled + ", " : "")
|
+ (enabled != null ? "enabled=" + enabled + ", " : "")
|
||||||
+ (username != null ? "username=" + username + ", " : "")
|
+ (username != null ? "username=" + username + ", " : "")
|
||||||
+ (firstName != null ? "firstName=" + firstName + ", " : "")
|
+ (firstName != null ? "firstName=" + firstName + ", " : "")
|
||||||
+ (lastName != null ? "lastName=" + lastName + ", " : "")
|
+ (lastName != null ? "lastName=" + lastName + ", " : "")
|
||||||
+ (company != null ? "company=" + company + ", " : "")
|
+ (company != null ? "company=" + company + ", " : "")
|
||||||
+ (skype != null ? "skype=" + skype + ", " : "")
|
+ (skype != null ? "skype=" + skype + ", " : "")
|
||||||
+ (location != null ? "location=" + location + ", " : "")
|
+ (location != null ? "location=" + location + ", " : "")
|
||||||
+ (tel != null ? "tel=" + tel + ", " : "")
|
+ (tel != null ? "tel=" + tel + ", " : "")
|
||||||
+ (mob != null ? "mob=" + mob + ", " : "")
|
+ (mob != null ? "mob=" + mob + ", " : "")
|
||||||
+ (instantmsg != null ? "instantmsg=" + instantmsg + ", " : "")
|
+ (instantmsg != null ? "instantmsg=" + instantmsg + ", " : "")
|
||||||
+ (google != null ? "google=" + google + ", " : "")
|
+ (google != null ? "google=" + google + ", " : "")
|
||||||
+ (description != null ? "description=" + description + ", " : "")
|
+ (description != null ? "description=" + description + ", " : "")
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public JSONObject toJSON(boolean fullVisibility)
|
public JSONObject toJSON(boolean fullVisibility)
|
||||||
{
|
{
|
||||||
JSONObject personJson = new JSONObject();
|
JSONObject personJson = new JSONObject();
|
||||||
personJson.put("id", getId());
|
personJson.put("id", getId());
|
||||||
personJson.put("firstName", getFirstName());
|
personJson.put("firstName", getFirstName());
|
||||||
personJson.put("lastName", getLastName());
|
personJson.put("lastName", getLastName());
|
||||||
if(fullVisibility)
|
if(fullVisibility)
|
||||||
{
|
{
|
||||||
personJson.put("skypeId", "skype");
|
personJson.put("skypeId", "skype");
|
||||||
personJson.put("location", "location");
|
personJson.put("location", "location");
|
||||||
personJson.put("telephone", "tel");
|
personJson.put("telephone", "tel");
|
||||||
personJson.put("mobile", "mob");
|
personJson.put("mobile", "mob");
|
||||||
personJson.put("instantMessageId", "instantmsg");
|
personJson.put("instantMessageId", "instantmsg");
|
||||||
personJson.put("googleId", "google");
|
personJson.put("googleId", "google");
|
||||||
|
|
||||||
personJson.put("company", company.toJSON());
|
personJson.put("company", company.toJSON());
|
||||||
|
|
||||||
}
|
}
|
||||||
return personJson;
|
return personJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Person parsePerson(JSONObject jsonObject)
|
public static Person parsePerson(JSONObject jsonObject)
|
||||||
{
|
{
|
||||||
Boolean enabled = (Boolean)jsonObject.get("enabled");
|
Boolean enabled = (Boolean)jsonObject.get("enabled");
|
||||||
String location = (String)jsonObject.get("location");
|
String location = (String)jsonObject.get("location");
|
||||||
String instantMessageId = (String)jsonObject.get("instantMessageId");
|
String instantMessageId = (String)jsonObject.get("instantMessageId");
|
||||||
String googleId = (String)jsonObject.get("googleId");
|
String googleId = (String)jsonObject.get("googleId");
|
||||||
String skypeId = (String)jsonObject.get("skypeId");
|
String skypeId = (String)jsonObject.get("skypeId");
|
||||||
String username = (String)jsonObject.get("username");
|
String username = (String)jsonObject.get("username");
|
||||||
String telephone = (String)jsonObject.get("telephone");
|
String telephone = (String)jsonObject.get("telephone");
|
||||||
String mobile = (String)jsonObject.get("mobile");
|
String mobile = (String)jsonObject.get("mobile");
|
||||||
String userId = (String)jsonObject.get("id");
|
String userId = (String)jsonObject.get("id");
|
||||||
String firstName = (String)jsonObject.get("firstName");
|
String firstName = (String)jsonObject.get("firstName");
|
||||||
String lastName = (String)jsonObject.get("lastName");
|
String lastName = (String)jsonObject.get("lastName");
|
||||||
String description = (String)jsonObject.get("description");
|
String description = (String)jsonObject.get("description");
|
||||||
|
|
||||||
JSONObject companyJSON = (JSONObject)jsonObject.get("company");
|
JSONObject companyJSON = (JSONObject)jsonObject.get("company");
|
||||||
Company company = null;
|
Company company = null;
|
||||||
if(companyJSON != null)
|
if(companyJSON != null)
|
||||||
{
|
{
|
||||||
String organization = (String)companyJSON.get("organization");
|
String organization = (String)companyJSON.get("organization");
|
||||||
String address1 = (String)companyJSON.get("address1");
|
String address1 = (String)companyJSON.get("address1");
|
||||||
String address2 = (String)companyJSON.get("address2");
|
String address2 = (String)companyJSON.get("address2");
|
||||||
String address3 = (String)companyJSON.get("address3");
|
String address3 = (String)companyJSON.get("address3");
|
||||||
String postcode = (String)companyJSON.get("postcode");
|
String postcode = (String)companyJSON.get("postcode");
|
||||||
String companyTelephone = (String)companyJSON.get("telephone");
|
String companyTelephone = (String)companyJSON.get("telephone");
|
||||||
String fax = (String)companyJSON.get("fax");
|
String fax = (String)companyJSON.get("fax");
|
||||||
String companyEmail = (String)companyJSON.get("email");
|
String companyEmail = (String)companyJSON.get("email");
|
||||||
if (organization != null ||
|
if (organization != null ||
|
||||||
address2 != null ||
|
address2 != null ||
|
||||||
address3 != null ||
|
address3 != null ||
|
||||||
postcode != null ||
|
postcode != null ||
|
||||||
companyTelephone != null ||
|
companyTelephone != null ||
|
||||||
fax != null ||
|
fax != null ||
|
||||||
companyEmail != null)
|
companyEmail != null)
|
||||||
{
|
{
|
||||||
company = new Company(organization, address1, address2, address3, postcode, companyTelephone, fax, companyEmail);
|
company = new Company(organization, address1, address2, address3, postcode, companyTelephone, fax, companyEmail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Person person = new Person(userId, username, enabled, firstName, lastName, company, skypeId, location, telephone, mobile, instantMessageId, googleId, description);
|
Person person = new Person(userId, username, enabled, firstName, lastName, company, skypeId, location, telephone, mobile, instantMessageId, googleId, description);
|
||||||
return person;
|
return person;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Person restriced()
|
public Person restriced()
|
||||||
{
|
{
|
||||||
Person p = new Person(getId(), getUsername(), getEnabled(), getFirstName(), getLastName(), null, null, null, null, null, null, null, null);
|
Person p = new Person(getId(), getUsername(), getEnabled(), getFirstName(), getLastName(), null, null, null, null, null, null, null, null);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class UserContext
|
private static class UserContext
|
||||||
{
|
{
|
||||||
private String networkId;
|
private String networkId;
|
||||||
private String personId;
|
private String personId;
|
||||||
|
|
||||||
UserContext(String networkId, String personId)
|
UserContext(String networkId, String personId)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.networkId = networkId;
|
this.networkId = networkId;
|
||||||
this.personId = personId;
|
this.personId = personId;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getNetworkId()
|
String getNetworkId()
|
||||||
{
|
{
|
||||||
return networkId;
|
return networkId;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getPersonId()
|
String getPersonId()
|
||||||
{
|
{
|
||||||
return personId;
|
return personId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ThreadLocal<UserContext> userContext = new ThreadLocal<UserContext>();
|
private static ThreadLocal<UserContext> userContext = new ThreadLocal<UserContext>();
|
||||||
public static void setUserContext(String personId)
|
public static void setUserContext(String personId)
|
||||||
{
|
{
|
||||||
String networkId = Person.getNetworkId(personId);
|
String networkId = Person.getNetworkId(personId);
|
||||||
userContext.set(new UserContext(networkId, personId));
|
userContext.set(new UserContext(networkId, personId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearUserContext()
|
public static void clearUserContext()
|
||||||
{
|
{
|
||||||
userContext.set(null);
|
userContext.set(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserContext gettUserContext()
|
public static UserContext gettUserContext()
|
||||||
{
|
{
|
||||||
return userContext.get();
|
return userContext.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getNetworkId(String personId)
|
public static String getNetworkId(String personId)
|
||||||
{
|
{
|
||||||
int idx = personId.indexOf("@");
|
int idx = personId.indexOf("@");
|
||||||
return(idx == -1 ? TenantService.DEFAULT_DOMAIN : personId.substring(idx + 1));
|
return(idx == -1 ? TenantService.DEFAULT_DOMAIN : personId.substring(idx + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNetworkId()
|
private String getNetworkId()
|
||||||
{
|
{
|
||||||
return Person.getNetworkId(id);
|
return Person.getNetworkId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVisible()
|
public boolean isVisible()
|
||||||
{
|
{
|
||||||
boolean ret = true;
|
boolean ret = true;
|
||||||
|
|
||||||
UserContext uc = gettUserContext();
|
UserContext uc = gettUserContext();
|
||||||
String networkId = getNetworkId();
|
String networkId = getNetworkId();
|
||||||
if(uc != null)
|
if(uc != null)
|
||||||
{
|
{
|
||||||
if(!networkId.equals(uc.getNetworkId()))
|
if(!networkId.equals(uc.getNetworkId()))
|
||||||
{
|
{
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void expected(Object o)
|
public void expected(Object o)
|
||||||
{
|
{
|
||||||
assertTrue("o is an instance of " + o.getClass(), o instanceof Person);
|
assertTrue("o is an instance of " + o.getClass(), o instanceof Person);
|
||||||
|
|
||||||
Person other = (Person)o;
|
Person other = (Person)o;
|
||||||
|
|
||||||
AssertUtil.assertEquals("userId", id, other.getId());
|
AssertUtil.assertEquals("userId", id, other.getId());
|
||||||
AssertUtil.assertEquals("firstName", firstName, other.getFirstName());
|
AssertUtil.assertEquals("firstName", firstName, other.getFirstName());
|
||||||
AssertUtil.assertEquals("lastName", lastName, other.getLastName());
|
AssertUtil.assertEquals("lastName", lastName, other.getLastName());
|
||||||
AssertUtil.assertEquals("enabled", enabled, other.getEnabled());
|
AssertUtil.assertEquals("enabled", enabled, other.getEnabled());
|
||||||
|
|
||||||
if(isVisible())
|
if(isVisible())
|
||||||
{
|
{
|
||||||
AssertUtil.assertEquals("skype", skype, other.getSkype());
|
AssertUtil.assertEquals("skype", skype, other.getSkype());
|
||||||
AssertUtil.assertEquals("location", location, other.getLocation());
|
AssertUtil.assertEquals("location", location, other.getLocation());
|
||||||
AssertUtil.assertEquals("tel", tel, other.getTel());
|
AssertUtil.assertEquals("tel", tel, other.getTel());
|
||||||
AssertUtil.assertEquals("mobile", mob, other.getMob());
|
AssertUtil.assertEquals("mobile", mob, other.getMob());
|
||||||
AssertUtil.assertEquals("instanceMessageId", instantmsg, other.getInstantmsg());
|
AssertUtil.assertEquals("instanceMessageId", instantmsg, other.getInstantmsg());
|
||||||
AssertUtil.assertEquals("googleId", google, other.getGoogle());
|
AssertUtil.assertEquals("googleId", google, other.getGoogle());
|
||||||
if(company != null)
|
if(company != null)
|
||||||
{
|
{
|
||||||
company.expected(getCompany());
|
company.expected(getCompany());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<QName, Serializable> getProperties()
|
public Map<QName, Serializable> getProperties()
|
||||||
{
|
{
|
||||||
final Map<QName, Serializable> props = new HashMap<QName, Serializable>();
|
final Map<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||||
|
|
||||||
if(firstName != null)
|
if(firstName != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_FIRSTNAME, firstName);
|
props.put(ContentModel.PROP_FIRSTNAME, firstName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lastName != null)
|
if(lastName != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_LASTNAME, lastName);
|
props.put(ContentModel.PROP_LASTNAME, lastName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(skype != null)
|
if(skype != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_SKYPE, skype);
|
props.put(ContentModel.PROP_SKYPE, skype);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(location != null)
|
if(location != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_LOCATION, location);
|
props.put(ContentModel.PROP_LOCATION, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tel != null)
|
if(tel != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_TELEPHONE, tel);
|
props.put(ContentModel.PROP_TELEPHONE, tel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(username != null)
|
if(username != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_USERNAME, username);
|
props.put(ContentModel.PROP_USERNAME, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mob != null)
|
if(mob != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_MOBILE, mob);
|
props.put(ContentModel.PROP_MOBILE, mob);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(instantmsg != null)
|
if(instantmsg != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_INSTANTMSG, instantmsg);
|
props.put(ContentModel.PROP_INSTANTMSG, instantmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(google != null)
|
if(google != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_GOOGLEUSERNAME, google);
|
props.put(ContentModel.PROP_GOOGLEUSERNAME, google);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(company != null)
|
if(company != null)
|
||||||
{
|
{
|
||||||
if(company.getOrganization() != null)
|
if(company.getOrganization() != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_ORGANIZATION, company.getOrganization());
|
props.put(ContentModel.PROP_ORGANIZATION, company.getOrganization());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(company.getAddress1() != null)
|
if(company.getAddress1() != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_COMPANYADDRESS1, company.getAddress1());
|
props.put(ContentModel.PROP_COMPANYADDRESS1, company.getAddress1());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(company.getAddress2() != null)
|
if(company.getAddress2() != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_COMPANYADDRESS2, company.getAddress2());
|
props.put(ContentModel.PROP_COMPANYADDRESS2, company.getAddress2());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(company.getAddress3() != null)
|
if(company.getAddress3() != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_COMPANYADDRESS3, company.getAddress3());
|
props.put(ContentModel.PROP_COMPANYADDRESS3, company.getAddress3());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(company.getPostcode() != null)
|
if(company.getPostcode() != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_COMPANYPOSTCODE, company.getPostcode());
|
props.put(ContentModel.PROP_COMPANYPOSTCODE, company.getPostcode());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(company.getTelephone() != null)
|
if(company.getTelephone() != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_COMPANYTELEPHONE, company.getTelephone());
|
props.put(ContentModel.PROP_COMPANYTELEPHONE, company.getTelephone());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(company.getFax() != null)
|
if(company.getFax() != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_COMPANYFAX, company.getFax());
|
props.put(ContentModel.PROP_COMPANYFAX, company.getFax());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(company.getEmail() != null)
|
if(company.getEmail() != null)
|
||||||
{
|
{
|
||||||
props.put(ContentModel.PROP_COMPANYEMAIL, company.getEmail());
|
props.put(ContentModel.PROP_COMPANYEMAIL, company.getEmail());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Person o)
|
public int compareTo(Person o)
|
||||||
{
|
{
|
||||||
int ret = Person.collator.compare(lastName, o.getLastName());
|
int ret = Person.collator.compare(lastName, o.getLastName());
|
||||||
if(ret == 0)
|
if(ret == 0)
|
||||||
{
|
{
|
||||||
ret = Person.collator.compare(firstName, o.getFirstName());
|
ret = Person.collator.compare(firstName, o.getFirstName());
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ListResponse<Person> parsePeople(JSONObject jsonObject)
|
public static ListResponse<Person> parsePeople(JSONObject jsonObject)
|
||||||
{
|
{
|
||||||
List<Person> people = new ArrayList<Person>();
|
List<Person> people = new ArrayList<Person>();
|
||||||
|
|
||||||
JSONObject jsonList = (JSONObject)jsonObject.get("list");
|
JSONObject jsonList = (JSONObject)jsonObject.get("list");
|
||||||
assertNotNull(jsonList);
|
assertNotNull(jsonList);
|
||||||
|
|
||||||
JSONArray jsonEntries = (JSONArray)jsonList.get("entries");
|
JSONArray jsonEntries = (JSONArray)jsonList.get("entries");
|
||||||
assertNotNull(jsonEntries);
|
assertNotNull(jsonEntries);
|
||||||
|
|
||||||
for(int i = 0; i < jsonEntries.size(); i++)
|
for(int i = 0; i < jsonEntries.size(); i++)
|
||||||
{
|
{
|
||||||
JSONObject jsonEntry = (JSONObject)jsonEntries.get(i);
|
JSONObject jsonEntry = (JSONObject)jsonEntries.get(i);
|
||||||
JSONObject entry = (JSONObject)jsonEntry.get("entry");
|
JSONObject entry = (JSONObject)jsonEntry.get("entry");
|
||||||
people.add(parsePerson(entry));
|
people.add(parsePerson(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
|
ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
|
||||||
ListResponse<Person> resp = new ListResponse<Person>(paging, people);
|
ListResponse<Person> resp = new ListResponse<Person>(paging, people);
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -42,12 +42,35 @@ public class UserInfo
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserInfo(String id)
|
||||||
|
{
|
||||||
|
this(id, getTestDisplayName(id));
|
||||||
|
}
|
||||||
|
|
||||||
public UserInfo(String id, String displayName)
|
public UserInfo(String id, String displayName)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Builds a test display name from a test user id. The display name is normally
|
||||||
|
* make up of the first and last name and in the case of test users the user id
|
||||||
|
* is also used for both first and last name. With the addition of a network to
|
||||||
|
* the user id, the display name looks rather strange. This method simply strips
|
||||||
|
* the network (if it exists) from the user id and uses that for both first and
|
||||||
|
* last names.
|
||||||
|
*/
|
||||||
|
public static String getTestDisplayName(String id)
|
||||||
|
{
|
||||||
|
int i = id.lastIndexOf('@');
|
||||||
|
if (i != -1)
|
||||||
|
{
|
||||||
|
id = id.substring(0, i);
|
||||||
|
}
|
||||||
|
return id+' '+id;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDisplayName()
|
public String getDisplayName()
|
||||||
{
|
{
|
||||||
return displayName;
|
return displayName;
|
||||||
|
Reference in New Issue
Block a user