Merged 5.2.N (5.2.1) to HEAD (5.2)

131764 rmunteanu: 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/HEAD/root@132294 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-11-03 13:57:18 +00:00
parent e42b6f2990
commit 7d606bd6eb
8 changed files with 364 additions and 97 deletions

View File

@@ -77,4 +77,5 @@ public interface Sites
String PARAM_SITE_ROLE = "role";
String PARAM_VISIBILITY = "visibility";
String PARAM_PRESET = "preset";
}

View File

@@ -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.where.Query;
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.favourites.FavouritesService;
import org.alfresco.service.cmr.model.FileInfo;
@@ -144,7 +144,7 @@ public class SitesImpl implements Sites
}
// 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 People people;
@@ -759,17 +759,22 @@ public class SitesImpl implements Sites
Query q = parameters.getQuery();
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);
String siteVisibilityStr = propertyWalker.getProperty(PARAM_VISIBILITY, WhereClauseParser.EQUALS, String.class);
if (siteVisibilityStr != null && !siteVisibilityStr.isEmpty())
{
SiteVisibility siteVisibility = getSiteVisibilityFromParam(siteVisibilityStr);
filterProps = new ArrayList<FilterProp>();
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;
@@ -779,7 +784,7 @@ public class SitesImpl implements Sites
{
Map<QName, Serializable> propVals = new HashMap<>();
propVals.put(SiteModel.PROP_SITE_VISIBILITY, siteMembership.getSiteInfo().getVisibility().name());
propVals.put(SiteModel.PROP_SITE_PRESET, siteMembership.getSiteInfo().getSitePreset());
return includeFilter(propVals, filterProps);
}
@@ -1097,7 +1102,7 @@ public class SitesImpl implements Sites
SiteInfo siteInfo = null;
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)
{

View File

@@ -44,30 +44,10 @@ public class Site implements Comparable<Site>
protected String guid; // site nodeId
protected String title;
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 String preset;
protected String role;
public Site()
{
}
@@ -83,6 +63,7 @@ public class Site implements Comparable<Site>
this.title = siteInfo.getTitle();
this.description = siteInfo.getDescription();
this.visibility = siteInfo.getVisibility();
this.preset = siteInfo.getSitePreset();
this.role = role;
}
@@ -112,16 +93,51 @@ public class Site implements Comparable<Site>
return title;
}
public void setTitle(String title)
{
this.title = title;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public SiteVisibility getVisibility()
{
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
public boolean equals(Object obj)
{
@@ -168,8 +184,4 @@ public class Site implements Comparable<Site>
+ "]";
}
public String getRole()
{
return role;
}
}

View File

@@ -1,28 +1,28 @@
/*
* #%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%
*/
/*
* #%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.framework.resource.parameters.where;
import java.util.ArrayList;
@@ -98,11 +98,11 @@ public abstract class QueryHelper
* Default implementation. Override the methods you are interested in. If you don't
* 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
{
private static final String UNSUPPORTED_TEXT = "Unsupported Predicate";
protected static final InvalidQueryException UNSUPPORTED = new InvalidQueryException(UNSUPPORTED_TEXT);
@Override
public void exists(String propertyName, boolean negated) { throw UNSUPPORTED;}
@Override
@@ -166,7 +166,7 @@ public abstract class QueryHelper
List<Tree> children = getChildren(tree);
//Don't need the first item because its the property name
String[] inVals = new String[children.size()-1];
for (int i = 1; i < children.size(); i++)
for (int i = 1; i < children.size(); i++)
{
inVals[i-1] = stripQuotes(children.get(i).getText());
}
@@ -200,7 +200,7 @@ public abstract class QueryHelper
case WhereClauseParser.OR:
callback.or();
List<Tree> children = getChildren(tree);
for (Tree child : children)
for (Tree child : children)
{
callbackTree(child, callback, negated);
}
@@ -208,7 +208,7 @@ public abstract class QueryHelper
case WhereClauseParser.AND:
callback.and();
List<Tree> childrenOfAnd = getChildren(tree);
for (Tree child : childrenOfAnd)
for (Tree child : childrenOfAnd)
{
callbackTree(child, callback, negated);
}

View File

@@ -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;
}
}