mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
REPO-1390 , REPO-1391: Add support for retrieving site presets
- Implemented the API; - Added automated tests. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@131764 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -77,4 +77,5 @@ public interface Sites
|
|||||||
|
|
||||||
String PARAM_SITE_ROLE = "role";
|
String PARAM_SITE_ROLE = "role";
|
||||||
String PARAM_VISIBILITY = "visibility";
|
String PARAM_VISIBILITY = "visibility";
|
||||||
|
String PARAM_PRESET = "preset";
|
||||||
}
|
}
|
||||||
|
@@ -76,7 +76,7 @@ import org.alfresco.rest.framework.resource.parameters.Parameters;
|
|||||||
import org.alfresco.rest.framework.resource.parameters.SortColumn;
|
import org.alfresco.rest.framework.resource.parameters.SortColumn;
|
||||||
import org.alfresco.rest.framework.resource.parameters.where.Query;
|
import org.alfresco.rest.framework.resource.parameters.where.Query;
|
||||||
import org.alfresco.rest.framework.resource.parameters.where.QueryHelper;
|
import org.alfresco.rest.framework.resource.parameters.where.QueryHelper;
|
||||||
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker;
|
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalkerOrSupported;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.favourites.FavouritesService;
|
import org.alfresco.service.cmr.favourites.FavouritesService;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
@@ -144,7 +144,7 @@ public class SitesImpl implements Sites
|
|||||||
}
|
}
|
||||||
|
|
||||||
// list children filtering (via where clause)
|
// list children filtering (via where clause)
|
||||||
private final static Set<String> LIST_SITES_EQUALS_QUERY_PROPERTIES = new HashSet<>(Arrays.asList(new String[] { PARAM_VISIBILITY }));
|
private final static Set<String> LIST_SITES_EQUALS_QUERY_PROPERTIES = new HashSet<>(Arrays.asList(new String[] { PARAM_VISIBILITY, PARAM_PRESET }));
|
||||||
|
|
||||||
protected Nodes nodes;
|
protected Nodes nodes;
|
||||||
protected People people;
|
protected People people;
|
||||||
@@ -759,17 +759,22 @@ public class SitesImpl implements Sites
|
|||||||
Query q = parameters.getQuery();
|
Query q = parameters.getQuery();
|
||||||
if (q != null)
|
if (q != null)
|
||||||
{
|
{
|
||||||
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(LIST_SITES_EQUALS_QUERY_PROPERTIES, null);
|
filterProps = new ArrayList<FilterProp>();
|
||||||
|
MapBasedQueryWalkerOrSupported propertyWalker = new MapBasedQueryWalkerOrSupported(LIST_SITES_EQUALS_QUERY_PROPERTIES, null);
|
||||||
QueryHelper.walk(q, propertyWalker);
|
QueryHelper.walk(q, propertyWalker);
|
||||||
|
|
||||||
String siteVisibilityStr = propertyWalker.getProperty(PARAM_VISIBILITY, WhereClauseParser.EQUALS, String.class);
|
String siteVisibilityStr = propertyWalker.getProperty(PARAM_VISIBILITY, WhereClauseParser.EQUALS, String.class);
|
||||||
if (siteVisibilityStr != null && !siteVisibilityStr.isEmpty())
|
if (siteVisibilityStr != null && !siteVisibilityStr.isEmpty())
|
||||||
{
|
{
|
||||||
SiteVisibility siteVisibility = getSiteVisibilityFromParam(siteVisibilityStr);
|
SiteVisibility siteVisibility = getSiteVisibilityFromParam(siteVisibilityStr);
|
||||||
|
|
||||||
filterProps = new ArrayList<FilterProp>();
|
|
||||||
filterProps.add(new FilterPropString(SiteModel.PROP_SITE_VISIBILITY, siteVisibility.name(), FilterPropString.FilterTypeString.EQUALS));
|
filterProps.add(new FilterPropString(SiteModel.PROP_SITE_VISIBILITY, siteVisibility.name(), FilterPropString.FilterTypeString.EQUALS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String sitePreset = propertyWalker.getProperty(PARAM_PRESET, WhereClauseParser.EQUALS, String.class);
|
||||||
|
if (sitePreset != null && !sitePreset.isEmpty())
|
||||||
|
{
|
||||||
|
filterProps.add(new FilterPropString(SiteModel.PROP_SITE_PRESET, sitePreset, FilterPropString.FilterTypeString.EQUALS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return filterProps;
|
return filterProps;
|
||||||
@@ -779,7 +784,7 @@ public class SitesImpl implements Sites
|
|||||||
{
|
{
|
||||||
Map<QName, Serializable> propVals = new HashMap<>();
|
Map<QName, Serializable> propVals = new HashMap<>();
|
||||||
propVals.put(SiteModel.PROP_SITE_VISIBILITY, siteMembership.getSiteInfo().getVisibility().name());
|
propVals.put(SiteModel.PROP_SITE_VISIBILITY, siteMembership.getSiteInfo().getVisibility().name());
|
||||||
|
propVals.put(SiteModel.PROP_SITE_PRESET, siteMembership.getSiteInfo().getSitePreset());
|
||||||
return includeFilter(propVals, filterProps);
|
return includeFilter(propVals, filterProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1097,7 +1102,7 @@ public class SitesImpl implements Sites
|
|||||||
SiteInfo siteInfo = null;
|
SiteInfo siteInfo = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
siteInfo = siteService.createSite("sitePreset", site.getId(), site.getTitle(), site.getDescription(), site.getVisibility());
|
siteInfo = siteService.createSite(site.getPreset(), site.getId(), site.getTitle(), site.getDescription(), site.getVisibility());
|
||||||
}
|
}
|
||||||
catch (SiteServiceException sse)
|
catch (SiteServiceException sse)
|
||||||
{
|
{
|
||||||
|
@@ -44,28 +44,8 @@ public class Site implements Comparable<Site>
|
|||||||
protected String guid; // site nodeId
|
protected String guid; // site nodeId
|
||||||
protected String title;
|
protected String title;
|
||||||
protected String description;
|
protected String description;
|
||||||
|
|
||||||
public void setTitle(String title)
|
|
||||||
{
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description)
|
|
||||||
{
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVisibility(SiteVisibility visibility)
|
|
||||||
{
|
|
||||||
this.visibility = visibility;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRole(String role)
|
|
||||||
{
|
|
||||||
this.role = role;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SiteVisibility visibility;
|
protected SiteVisibility visibility;
|
||||||
|
protected String preset;
|
||||||
protected String role;
|
protected String role;
|
||||||
|
|
||||||
public Site()
|
public Site()
|
||||||
@@ -83,6 +63,7 @@ public class Site implements Comparable<Site>
|
|||||||
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.role = role;
|
this.role = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,16 +93,51 @@ public class Site implements Comparable<Site>
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description)
|
||||||
|
{
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
public SiteVisibility getVisibility()
|
public SiteVisibility getVisibility()
|
||||||
{
|
{
|
||||||
return visibility;
|
return visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setVisibility(SiteVisibility visibility)
|
||||||
|
{
|
||||||
|
this.visibility = visibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPreset()
|
||||||
|
{
|
||||||
|
return preset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreset(String preset)
|
||||||
|
{
|
||||||
|
this.preset = preset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRole()
|
||||||
|
{
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole(String role)
|
||||||
|
{
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
@@ -168,8 +184,4 @@ public class Site implements Comparable<Site>
|
|||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRole()
|
|
||||||
{
|
|
||||||
return role;
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -98,11 +98,11 @@ public abstract class QueryHelper
|
|||||||
* Default implementation. Override the methods you are interested in. If you don't
|
* Default implementation. Override the methods you are interested in. If you don't
|
||||||
* override the methods then an InvalidQueryException will be thrown.
|
* override the methods then an InvalidQueryException will be thrown.
|
||||||
*/
|
*/
|
||||||
private static final String UNSUPPORTED_TEXT = "Unsupported Predicate";
|
|
||||||
private static final InvalidQueryException UNSUPPORTED = new InvalidQueryException(UNSUPPORTED_TEXT);
|
|
||||||
|
|
||||||
public static class WalkerCallbackAdapter implements WalkerCallback
|
public static class WalkerCallbackAdapter implements WalkerCallback
|
||||||
{
|
{
|
||||||
|
private static final String UNSUPPORTED_TEXT = "Unsupported Predicate";
|
||||||
|
protected static final InvalidQueryException UNSUPPORTED = new InvalidQueryException(UNSUPPORTED_TEXT);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exists(String propertyName, boolean negated) { throw UNSUPPORTED;}
|
public void exists(String propertyName, boolean negated) { throw UNSUPPORTED;}
|
||||||
@Override
|
@Override
|
||||||
|
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Remote API
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
package org.alfresco.rest.workflow.api.impl;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query walker extension of MapBasedQueryWalker created to
|
||||||
|
* add support for OR operation and set AND operation as unsupported.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MapBasedQueryWalkerOrSupported extends MapBasedQueryWalker
|
||||||
|
{
|
||||||
|
|
||||||
|
public MapBasedQueryWalkerOrSupported(Set<String> supportedEqualsParameters, Set<String> supportedMatchesParameters)
|
||||||
|
{
|
||||||
|
super(supportedEqualsParameters, supportedMatchesParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void or()
|
||||||
|
{
|
||||||
|
// We don't need to do anything in this method. However, overriding the
|
||||||
|
// method indicates that OR is supported.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void and()
|
||||||
|
{
|
||||||
|
throw UNSUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
@@ -45,6 +45,7 @@ import org.alfresco.rest.api.tests.client.RequestContext;
|
|||||||
import org.alfresco.rest.api.tests.client.data.*;
|
import org.alfresco.rest.api.tests.client.data.*;
|
||||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
|
import org.apache.commons.collections.map.HashedMap;
|
||||||
import org.apache.commons.httpclient.HttpStatus;
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
@@ -97,6 +98,10 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
private String site6_title = "b_" + GUID.generate();
|
private String site6_title = "b_" + GUID.generate();
|
||||||
private String site6_description = "a_" + GUID.generate();
|
private String site6_description = "a_" + GUID.generate();
|
||||||
|
|
||||||
|
private String preset = "sitePreset";
|
||||||
|
private static final String AND_PREDICATE = " AND ";
|
||||||
|
private static final String OR_PREDICATE = " OR ";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Before
|
@Before
|
||||||
public void
|
public void
|
||||||
@@ -159,9 +164,11 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
|
|
||||||
private void initializeNetwork3WithSites() throws Exception
|
private void initializeNetwork3WithSites() throws Exception
|
||||||
{
|
{
|
||||||
|
String siteDescription = "description";
|
||||||
|
|
||||||
if (network3 == null)
|
if (network3 == null)
|
||||||
{
|
{
|
||||||
network3 = getRepoService().createNetwork(this.getClass().getName().toLowerCase()+"-2-"+RUNID, true);
|
network3 = getRepoService().createNetwork(this.getClass().getName().toLowerCase() + "-3-" + RUNID, true);
|
||||||
network3.create();
|
network3.create();
|
||||||
|
|
||||||
TenantUtil.runAsSystemTenant(new TenantRunAsWork<Void>()
|
TenantUtil.runAsSystemTenant(new TenantRunAsWork<Void>()
|
||||||
@@ -178,16 +185,20 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
|
|
||||||
Sites sitesProxy = publicApiClient.sites();
|
Sites sitesProxy = publicApiClient.sites();
|
||||||
|
|
||||||
Site site = new SiteImpl("site A" + GUID.generate(), SiteVisibility.PRIVATE.toString());
|
Site site = new SiteImpl().withSiteId("a-" + GUID.generate()).withTitle("site A" + GUID.generate()).withDescription(siteDescription)
|
||||||
|
.withVisibility(SiteVisibility.PRIVATE.toString()).withPreset(preset);
|
||||||
site7 = sitesProxy.createSite(site);
|
site7 = sitesProxy.createSite(site);
|
||||||
|
|
||||||
site = new SiteImpl("site B" + GUID.generate(), SiteVisibility.PUBLIC.toString());
|
site = new SiteImpl().withSiteId("b-" + GUID.generate()).withTitle("site B" + GUID.generate()).withDescription(siteDescription)
|
||||||
|
.withVisibility(SiteVisibility.PUBLIC.toString()).withPreset(preset);
|
||||||
site8 = sitesProxy.createSite(site);
|
site8 = sitesProxy.createSite(site);
|
||||||
|
|
||||||
site = new SiteImpl("site C" + GUID.generate(), SiteVisibility.PUBLIC.toString());
|
site = new SiteImpl().withSiteId("c-" + GUID.generate()).withTitle("site C" + GUID.generate()).withDescription(siteDescription)
|
||||||
|
.withVisibility(SiteVisibility.PUBLIC.toString()).withPreset(preset);
|
||||||
site9 = sitesProxy.createSite(site);
|
site9 = sitesProxy.createSite(site);
|
||||||
|
|
||||||
site = new SiteImpl("site D" + GUID.generate(), SiteVisibility.MODERATED.toString());
|
site = new SiteImpl().withSiteId("d-" + GUID.generate()).withTitle("site D" + GUID.generate()).withDescription(siteDescription)
|
||||||
|
.withVisibility(SiteVisibility.MODERATED.toString()).withPreset("site-dashboard");
|
||||||
site10 = sitesProxy.createSite(site);
|
site10 = sitesProxy.createSite(site);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -980,15 +991,25 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
return sitesProxy.getSites(createParams(paging, params));
|
return sitesProxy.getSites(createParams(paging, params));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListResponse<Site> listSitesWithWhere(final Paging paging, String siteVisibility) throws Exception
|
private ListResponse<Site> listSitesWithWhere(final Paging paging, Map<String, String> filters, String predicate) throws Exception
|
||||||
{
|
{
|
||||||
final Sites sitesProxy = publicApiClient.sites();
|
final Sites sitesProxy = publicApiClient.sites();
|
||||||
|
|
||||||
|
String visibility = filters.get("visibility");
|
||||||
|
String preset = filters.get("preset");
|
||||||
|
String pred = predicate;
|
||||||
|
|
||||||
final Map<String, String> params = new HashMap<>();
|
final Map<String, String> params = new HashMap<>();
|
||||||
if (siteVisibility != null)
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (visibility != null || preset != null)
|
||||||
{
|
{
|
||||||
params.put("where", "(visibility=" + siteVisibility + ")");
|
sb.append("(");
|
||||||
|
sb.append(visibility != null ? "visibility=" + visibility : "");
|
||||||
|
sb.append(pred != null ? pred : "");
|
||||||
|
sb.append(preset != null ? "preset='" + preset + "'" : "");
|
||||||
|
sb.append(")");
|
||||||
}
|
}
|
||||||
|
params.put("where", sb.toString());
|
||||||
|
|
||||||
return sitesProxy.getSites(createParams(paging, params));
|
return sitesProxy.getSites(createParams(paging, params));
|
||||||
}
|
}
|
||||||
@@ -999,8 +1020,11 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
int totalResults = 1;
|
int totalResults = 1;
|
||||||
Paging paging = getPaging(null, null, totalResults, totalResults);
|
Paging paging = getPaging(null, null, totalResults, totalResults);
|
||||||
|
|
||||||
|
Map<String, String> filters = new HashMap<String, String>();
|
||||||
|
filters.put("visibility", SiteVisibility.PRIVATE.name());
|
||||||
|
|
||||||
// list sites
|
// list sites
|
||||||
ListResponse<Site> resp = listSitesWithWhere(null, SiteVisibility.PRIVATE.name());
|
ListResponse<Site> resp = listSitesWithWhere(null, filters, null);
|
||||||
|
|
||||||
// check results
|
// check results
|
||||||
List<SiteImpl> expectedList = new LinkedList<>();
|
List<SiteImpl> expectedList = new LinkedList<>();
|
||||||
@@ -1015,8 +1039,11 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
int totalResults = 2;
|
int totalResults = 2;
|
||||||
Paging paging = getPaging(null, null, totalResults, totalResults);
|
Paging paging = getPaging(null, null, totalResults, totalResults);
|
||||||
|
|
||||||
|
Map<String, String> filters = new HashMap<String, String>();
|
||||||
|
filters.put("visibility", SiteVisibility.PUBLIC.name());
|
||||||
|
|
||||||
// list sites
|
// list sites
|
||||||
ListResponse<Site> resp = listSitesWithWhere(null, SiteVisibility.PUBLIC.name());
|
ListResponse<Site> resp = listSitesWithWhere(null, filters, null);
|
||||||
|
|
||||||
// check results
|
// check results
|
||||||
List<SiteImpl> expectedList = new LinkedList<>();
|
List<SiteImpl> expectedList = new LinkedList<>();
|
||||||
@@ -1034,8 +1061,11 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
int totalResults = 2;
|
int totalResults = 2;
|
||||||
Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);
|
||||||
|
|
||||||
|
Map<String, String> filters = new HashMap<String, String>();
|
||||||
|
filters.put("visibility", SiteVisibility.PUBLIC.name());
|
||||||
|
|
||||||
// list sites
|
// list sites
|
||||||
ListResponse<Site> resp = listSitesWithWhere(paging, SiteVisibility.PUBLIC.name());
|
ListResponse<Site> resp = listSitesWithWhere(paging, filters, null);
|
||||||
|
|
||||||
// check results
|
// check results
|
||||||
List<SiteImpl> expectedList = new LinkedList<>();
|
List<SiteImpl> expectedList = new LinkedList<>();
|
||||||
@@ -1050,8 +1080,11 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
int totalResults = 1;
|
int totalResults = 1;
|
||||||
Paging paging = getPaging(null, null, totalResults, totalResults);
|
Paging paging = getPaging(null, null, totalResults, totalResults);
|
||||||
|
|
||||||
|
Map<String, String> filters = new HashMap<String, String>();
|
||||||
|
filters.put("visibility", SiteVisibility.MODERATED.name());
|
||||||
|
|
||||||
// list sites
|
// list sites
|
||||||
ListResponse<Site> resp = listSitesWithWhere(null, SiteVisibility.MODERATED.name());
|
ListResponse<Site> resp = listSitesWithWhere(null, filters, null);
|
||||||
|
|
||||||
// check results
|
// check results
|
||||||
List<SiteImpl> expectedList = new LinkedList<>();
|
List<SiteImpl> expectedList = new LinkedList<>();
|
||||||
@@ -1064,7 +1097,10 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
listSitesWithWhere(null, "invalidVisibility");
|
Map<String, String> filters = new HashMap<String, String>();
|
||||||
|
filters.put("visibility", "invalidVisibility");
|
||||||
|
|
||||||
|
listSitesWithWhere(null, filters, null);
|
||||||
fail("");
|
fail("");
|
||||||
}
|
}
|
||||||
catch (PublicApiException e)
|
catch (PublicApiException e)
|
||||||
@@ -1073,6 +1109,63 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testListSitesWhereByVisibilityORPreset() throws Exception
|
||||||
|
{
|
||||||
|
// paging
|
||||||
|
int totalResults = 2;
|
||||||
|
Paging paging = getPaging(null, null, totalResults, totalResults);
|
||||||
|
|
||||||
|
Map<String, String> filters = new HashMap<String, String>();
|
||||||
|
filters.put("visibility", SiteVisibility.PRIVATE.name());
|
||||||
|
filters.put("preset", "site-dashboard");
|
||||||
|
|
||||||
|
ListResponse<Site> resp = listSitesWithWhere(null, filters, OR_PREDICATE);
|
||||||
|
|
||||||
|
// check results
|
||||||
|
List<SiteImpl> expectedList = new LinkedList<>();
|
||||||
|
expectedList.add((SiteImpl) site7);
|
||||||
|
expectedList.add((SiteImpl) site10);
|
||||||
|
|
||||||
|
checkList(expectedList, paging.getExpectedPaging(), resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListSitesWherePreset() throws Exception
|
||||||
|
{
|
||||||
|
// paging
|
||||||
|
int totalResults = 1;
|
||||||
|
Paging paging = getPaging(null, null, totalResults, totalResults);
|
||||||
|
|
||||||
|
Map<String, String> filters = new HashMap<String, String>();
|
||||||
|
filters.put("preset", "site-dashboard");
|
||||||
|
ListResponse<Site> resp = listSitesWithWhere(null, filters, null);
|
||||||
|
// check results
|
||||||
|
List<SiteImpl> expectedList = new LinkedList<>();
|
||||||
|
expectedList.add((SiteImpl) site10);
|
||||||
|
|
||||||
|
checkList(expectedList, paging.getExpectedPaging(), resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListSitesWherePresetNonexistent() throws Exception
|
||||||
|
{
|
||||||
|
Map<String, String> filters = new HashMap<String, String>();
|
||||||
|
filters.put("preset", "nonexistentPreset");
|
||||||
|
listSitesWithWhere(null, filters, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testListSitesWhereVisibilityANDPreset() throws Exception
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Map<String, String> filters = new HashMap<String, String>();
|
||||||
|
filters.put("visibility", SiteVisibility.PUBLIC.name());
|
||||||
|
filters.put("preset", "sitePreset");
|
||||||
|
listSitesWithWhere(null, filters, AND_PREDICATE);
|
||||||
|
}
|
||||||
|
catch (PublicApiException e)
|
||||||
|
{
|
||||||
|
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testListSitesWhereExpected() throws Exception
|
public void testListSitesWhereExpected() throws Exception
|
||||||
{
|
{
|
||||||
@@ -1084,6 +1177,11 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
testListSitesWhereSiteVisibilityPublicAndSkipCount();
|
testListSitesWhereSiteVisibilityPublicAndSkipCount();
|
||||||
testListSitesWhereSiteVisibilityModerated();
|
testListSitesWhereSiteVisibilityModerated();
|
||||||
testListSitesWhereSiteVisibilityInvalid();
|
testListSitesWhereSiteVisibilityInvalid();
|
||||||
|
|
||||||
|
testListSitesWherePreset();
|
||||||
|
testListSitesWherePresetNonexistent();
|
||||||
|
testListSitesWhereVisibilityANDPreset();
|
||||||
|
testListSitesWhereByVisibilityORPreset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -30,15 +30,26 @@ import org.json.simple.JSONObject;
|
|||||||
public interface Site extends JSONAble
|
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();
|
Boolean isCreated();
|
||||||
String getSiteId();
|
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);
|
void expected(Object o);
|
||||||
JSONObject toJSON();
|
JSONObject toJSON();
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,7 @@ public class SiteImpl implements Serializable, Site, Comparable<SiteImpl>, Expec
|
|||||||
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 type;
|
protected String type;
|
||||||
|
|
||||||
public SiteImpl()
|
public SiteImpl()
|
||||||
@@ -124,6 +125,76 @@ public class SiteImpl implements Serializable, Site, Comparable<SiteImpl>, Expec
|
|||||||
this.guid = guid;
|
this.guid = guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Site withCreated(Boolean created)
|
||||||
|
{
|
||||||
|
this.setCreated(created);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiteImpl withNetworkId(String networkId)
|
||||||
|
{
|
||||||
|
this.setNetworkId(networkId);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiteImpl withSiteId(String siteId)
|
||||||
|
{
|
||||||
|
this.setSiteId(siteId);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiteImpl withGuid(String guid)
|
||||||
|
{
|
||||||
|
this.setGuid(guid);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiteImpl withTitle(String title)
|
||||||
|
{
|
||||||
|
this.setTitle(title);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiteImpl withDescription(String description)
|
||||||
|
{
|
||||||
|
this.setDescription(description);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiteImpl withRole(SiteRole role)
|
||||||
|
{
|
||||||
|
this.setRole(role);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiteImpl withVisibility(String visibility)
|
||||||
|
{
|
||||||
|
this.setVisibility(visibility);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiteImpl withPreset(String preset)
|
||||||
|
{
|
||||||
|
this.setPreset(preset);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiteImpl withType(String type)
|
||||||
|
{
|
||||||
|
this.setType(type);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void expected(Object o)
|
public void expected(Object o)
|
||||||
{
|
{
|
||||||
@@ -185,6 +256,11 @@ public class SiteImpl implements Serializable, Site, Comparable<SiteImpl>, Expec
|
|||||||
return visibility;
|
return visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPreset()
|
||||||
|
{
|
||||||
|
return preset;
|
||||||
|
}
|
||||||
|
|
||||||
public String getType()
|
public String getType()
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
@@ -220,6 +296,11 @@ public class SiteImpl implements Serializable, Site, Comparable<SiteImpl>, Expec
|
|||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPreset(String preset)
|
||||||
|
{
|
||||||
|
this.preset = preset;
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(String type)
|
public void setType(String type)
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@@ -313,6 +394,10 @@ public class SiteImpl implements Serializable, Site, Comparable<SiteImpl>, Expec
|
|||||||
if (getVisibility() != null)
|
if (getVisibility() != null)
|
||||||
{
|
{
|
||||||
siteJson.put("visibility", getVisibility());
|
siteJson.put("visibility", getVisibility());
|
||||||
|
}
|
||||||
|
if (getPreset() != null)
|
||||||
|
{
|
||||||
|
siteJson.put("preset", getPreset());
|
||||||
}
|
}
|
||||||
return siteJson;
|
return siteJson;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user