mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
21536: Fix for ALF-4068 - IE6 XSS issue 21538: Added missing I18N label for when no wiki page defined in dashlet POST component 21562: Merged BRANCHES/DEV/BELARUS/V3.3-BUG-FIX-2010_06_14 to BRANCHES/DEV/V3.3-BUG-FIX: 20742: ALF-3572: Treat PasswordText as default for CMIS Web Service authentication 21575: Merged BRANCHES/DEV/BELARUS/V3.3-BUG-FIX-2010_06_24 to BRANCHES/DEV/V3.3-BUG-FIX: 21098: Bug is related to unsupported CMISResultSetMetaDataImpl.getLimitBy() method. But LimitBy parameter is required for a lot of search logic parts including permissions and constraints checks. To support LimitBy parameter the following solution was implemented: 21578: Dictionary DAO: wrap initDictionary in writeLock - investigating intermittent failure of RepoAdminServiceImplTest.testSimpleDynamicModelViaNodeService (eg. b29/b59 of V3.3-BUG-FIX) 21593: Fix ALF-1703: properties of type 'propertyXML' are returned as 'propertyString' 21594: Fix ALF-4202: Cannot issue query with join via Web Services binding - wasn't issuing query with CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS query mode 21611: Fix ALF-2649: CMIS query join return partial entry result 21627: Merged V3.3 to V3.3-BUG-FIX 21532: Fix for ALF-3042: Missing Null check for the propertyDefinition. - fixed all unprotected uses within indexing and query 21534: Fix for ALF-2151: Range queries don't work. - docs updated - added unit test to check for failure of d:content ranges as expected 21558: Fix for ALF-4183 - Publishing a draft blog post does not turn on permission inheritence 21609: Fix NFS problems with gEdit and OpenOffice when editing documents in the root of the filesystem. ALF-3955. Also fixed an unreported issue where an InvalidNodeRefException is thrown by the file cache timer after several edit/save operations on a file. 21626: Merged PATCHES/V3.2.1 to V3.3 21606: ALF-4044: Introduced new policy.content.update.ignoreEmpty setting, that when true causes the repository to behave as it did before the fix to ALF-254. I.e. writing empty content will not trigger onContentPropertyUpdate policies or inbound content rules. This enables better compatibility with mac clients using CIFS or WebDAV; they actually create and close a file before appending its data. 21607: (RECORD ONLY) Incremented version label git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21628 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
297 lines
8.6 KiB
Java
297 lines
8.6 KiB
Java
/*
|
|
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
|
*
|
|
* This file is part of Alfresco
|
|
*
|
|
* 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/>.
|
|
*/
|
|
package org.alfresco.repo.cmis.rest;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
|
|
import org.alfresco.cmis.CMISPropertyDefinition;
|
|
import org.alfresco.cmis.CMISResultSet;
|
|
import org.alfresco.cmis.CMISResultSetColumn;
|
|
import org.alfresco.cmis.CMISResultSetMetaData;
|
|
import org.alfresco.cmis.CMISResultSetRow;
|
|
import org.alfresco.repo.template.TemplateNode;
|
|
import org.alfresco.service.ServiceRegistry;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
|
|
|
import freemarker.core.Environment;
|
|
import freemarker.template.SimpleCollection;
|
|
import freemarker.template.TemplateCollectionModel;
|
|
import freemarker.template.TemplateModelException;
|
|
|
|
|
|
/**
|
|
* CMIS Result Set for use in Freemarker
|
|
*
|
|
* @author davidc
|
|
*/
|
|
public class CMISTemplateResultSet implements Serializable
|
|
{
|
|
private static final long serialVersionUID = 2245418238171563934L;
|
|
|
|
private CMISResultSet resultSet;
|
|
private ServiceRegistry serviceRegistry;
|
|
private TemplateImageResolver imageResolver;
|
|
|
|
/**
|
|
* Construct
|
|
*
|
|
* @param resultSet
|
|
* @param serviceRegistry
|
|
* @param imageResolver
|
|
*/
|
|
public CMISTemplateResultSet(CMISResultSet resultSet, ServiceRegistry serviceRegistry, TemplateImageResolver imageResolver)
|
|
{
|
|
this.resultSet = resultSet;
|
|
this.serviceRegistry = serviceRegistry;
|
|
this.imageResolver = imageResolver;
|
|
}
|
|
|
|
/**
|
|
* @return result set meta-data
|
|
*/
|
|
public CMISResultSetMetaData getMetaData()
|
|
{
|
|
return resultSet.getMetaData();
|
|
}
|
|
|
|
/**
|
|
* @return result set length
|
|
*/
|
|
public int getLength()
|
|
{
|
|
return resultSet.getLength();
|
|
}
|
|
|
|
/**
|
|
* @return start index within full result set
|
|
*/
|
|
public int getStart()
|
|
{
|
|
return resultSet.getStart();
|
|
}
|
|
|
|
/**
|
|
* @return selectors
|
|
*/
|
|
public String[] getSelectors()
|
|
{
|
|
return resultSet.getMetaData().getSelectorNames();
|
|
}
|
|
|
|
/**
|
|
* @return result set rows
|
|
* @throws TemplateModelException
|
|
*/
|
|
public TemplateCollectionModel getRows()
|
|
throws TemplateModelException
|
|
{
|
|
return new SimpleCollection(new TemplateIterator(resultSet.iterator()), Environment.getCurrentEnvironment().getObjectWrapper());
|
|
}
|
|
|
|
|
|
/**
|
|
* Result Set Iterator
|
|
*
|
|
* @author davidc
|
|
*/
|
|
public class TemplateIterator implements Iterator<TemplateIterator.TemplateRow>
|
|
{
|
|
private Iterator<CMISResultSetRow> iter;
|
|
|
|
/**
|
|
* Construct
|
|
*
|
|
* @param iter
|
|
*/
|
|
public TemplateIterator(Iterator<CMISResultSetRow> iter)
|
|
{
|
|
this.iter = iter;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see java.util.Iterator#hasNext()
|
|
*/
|
|
public boolean hasNext()
|
|
{
|
|
return iter.hasNext();
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see java.util.Iterator#next()
|
|
*/
|
|
public TemplateRow next()
|
|
{
|
|
return new TemplateRow(iter.next());
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see java.util.Iterator#remove()
|
|
*/
|
|
public void remove()
|
|
{
|
|
iter.remove();
|
|
}
|
|
|
|
|
|
/**
|
|
* Template Row
|
|
*/
|
|
public class TemplateRow
|
|
{
|
|
private CMISResultSetRow row;
|
|
private Map<String, TemplateNode> nodes = null;
|
|
|
|
/**
|
|
* Construct
|
|
*
|
|
* @param row
|
|
*/
|
|
public TemplateRow(CMISResultSetRow row)
|
|
{
|
|
this.row = row;
|
|
}
|
|
|
|
/**
|
|
* @return a map of serializable column values with the column name as the key
|
|
*/
|
|
public Map<String, Serializable> getValues()
|
|
{
|
|
return row.getValues();
|
|
}
|
|
|
|
/**
|
|
* @return nodes associated with row
|
|
*/
|
|
public Collection<TemplateNode> getNodes()
|
|
{
|
|
Map<String, TemplateNode> nodes = buildNodes();
|
|
return nodes.size() == 0 ? null : nodes.values();
|
|
}
|
|
|
|
/**
|
|
* @return node (if there is only a single node associated with the row), otherwise null
|
|
*/
|
|
public TemplateNode getNode()
|
|
{
|
|
try
|
|
{
|
|
NodeRef nodeRef = row.getNodeRef();
|
|
return new TemplateNode(nodeRef, serviceRegistry, imageResolver);
|
|
}
|
|
catch(UnsupportedOperationException e) {}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Builds a map of Template Nodes for the nodes associated with this row
|
|
*
|
|
* @return templates nodes indexed by selector
|
|
*/
|
|
private Map<String, TemplateNode> buildNodes()
|
|
{
|
|
if (nodes == null)
|
|
{
|
|
Map<String, NodeRef> nodeRefs = row.getNodeRefs();
|
|
if (nodeRefs == null || nodeRefs.size() == 0)
|
|
{
|
|
nodes = Collections.emptyMap();
|
|
}
|
|
else
|
|
{
|
|
HashMap<String, TemplateNode> templateNodes = new HashMap<String, TemplateNode>();
|
|
for (Map.Entry<String, NodeRef> entry : nodeRefs.entrySet())
|
|
{
|
|
templateNodes.put(entry.getKey(), new TemplateNode(entry.getValue(), serviceRegistry, imageResolver));
|
|
}
|
|
nodes = templateNodes;
|
|
}
|
|
}
|
|
return nodes;
|
|
}
|
|
|
|
/**
|
|
* Gets column type for specified column name
|
|
*
|
|
* @param colName column name
|
|
* @return column type
|
|
*/
|
|
public String getColumnType(String colName)
|
|
{
|
|
CMISResultSetColumn col = resultSet.getMetaData().getColumn(colName);
|
|
return col == null ? null : col.getCMISDataType().getLabel();
|
|
}
|
|
|
|
/**
|
|
* Gets property definition for specified column name
|
|
*
|
|
* @param colName column name
|
|
* @return property definition (or null, if not applicable)
|
|
*/
|
|
public CMISPropertyDefinition getPropertyDefinition(String colName)
|
|
{
|
|
CMISResultSetColumn col = resultSet.getMetaData().getColumn(colName);
|
|
return col == null ? null : col.getCMISPropertyDefinition();
|
|
}
|
|
|
|
/**
|
|
* Gets node for specified selector
|
|
*
|
|
* @param selector
|
|
* @return template node
|
|
*/
|
|
public TemplateNode getSelectorNode(String selector)
|
|
{
|
|
return nodes.get(selector);
|
|
}
|
|
|
|
/**
|
|
* @return overall score
|
|
*/
|
|
public float getScore()
|
|
{
|
|
return row.getScore();
|
|
}
|
|
|
|
/**
|
|
* @return a map of selector name to score
|
|
*/
|
|
public Float getSelectorScore(String selector)
|
|
{
|
|
return row.getScore(selector);
|
|
}
|
|
|
|
/**
|
|
* NOTE: If you want the overall position in paged results you have to add the skipCount for the result set
|
|
*
|
|
* @return row index
|
|
*/
|
|
public int getIndex()
|
|
{
|
|
return row.getIndex();
|
|
}
|
|
}
|
|
}
|
|
}
|