mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-07 18:25:23 +00:00
41597: ALF-1907: Check out rule is active for spaces - Merged in fix from DEV - Changed List of applicable types to a Set - Added quick initial checks against the set before doing the subtype checks - Various typo fixes 41598: Add an additional line of INFO to log the database details 41599: Fix for ALF-8374 - Simple view: incorrect file type icon for *.page and *.eps files 41600: Merge DEV to V4.1-BUG-FIX 41478 : ALF-14078: CLONE - Saving files with apps on Mac OS X Lion in CIFS doesn't invoke rules 41605: Fix for ALF-14653 - Share - Page link created wrongly in wiki. Solution to split wiki page name and title from Alex Bykov. 41608: CIFS cluster saving of text file fails. ALF-14179 The client releases the oplock by closing the file, if a remote oplock break was used then a notification to the remote node was missing in this case. 41616: ALF-13577:modified the delete site REST API to set the status code to 409 if a node is locked. 41624: MT: ALF-14331 - UserUsageTrackingComponent fails if disabled (in MT config) - defensive fix (exact steps do not repeat) - may also fix ALF-15956 41652: more debug 41653: Fix for ALF-15965 - IE9 - Script error occurs when manage aspect for a document 41655: Merged BRANCHES/V4.1 to BRANCHES/DEV/V4.1-BUG-FIX (RECORD ONLY) 41654: Fix for ALF-15965 - hand merged back from rev 41653 41658: ALF-14967: Task operations through task-forms now audited 41664: Reverse-merging change 41616 out of the product due to file formatting irregularities. This checkin was a fix for ALF-13577. A subsequent check-in will add the same fix but without the formatting problems. 41665: ALF-11452: Disabling JBPM now prevents jobexecutor thread from starting and consuming unneeded resources 41671: Reimplementation of fix for ALF-13577. Slight edit on previous fix. It now lets the NodeLockedException out of the Java layer and 'catches' this exception in the JavaScript layer. The API returns a 409 (conflict) if a NodeLockedException makes it to the JavaScript - the previous fix was returning 409 for *any* AlfrescoRuntimeException thrown during a site delete. Also this checkin preserves the whitespace/file layout of the preceding version. 41688: ALF-15867 WikiServiceImplTest failing on SQL Server - Switched WikiService_transaction bean over to using RetryingTransactionInterceptor 41720: ALF-15967: Using START_USER_ID_ instead of "initiator" property to query process instances started by user X to prevent extra joins 41730: Fix for ALF-15995 NodeRef is missing in log on "Problem converting to Freemarker" error 41743: ALF-9779 REGRESSION: FTP - Failed to retrieve directory listing for tenant user 41745: Removed a HomeShareMapper - there were two 41747: Fix for ALF-15811 SOLR query increases DocBitSet inefficiently Part of ALF-14861 SOLR to scale for non-admin users in 100k sites and a subgroup of each of 1000 independent groupings with 1000 subgroups 41748: Fix for ALF-15950 Solr: throws NPE: org.alfresco.solr.SolrLuceneAnalyser.loadAnalyzer - return default analyzer 41752: Fix for ALF-13634 Re-created category won't show up again on a node in Document Library. 41779: ALF-11283 - Got the home share mapper up and working after some refactoring. 41795: Fix for ALF-14361 CMIS object type definition for Document and Folder not spec compliant 41796: ALF-16008: missing column on clean Alfresco and after upgrade from 3.4.10 (703) - Schema-Reference for DB2 referenced a non-existent column. 41802: Fixed ALF-16029: TransactionCleanupTest throws constraint violations - Fallout from ALF-12358; sys:deleted node types have a mandatory property - Before bulk-deleting nodes, we need to delete properties - Use overriding DAo for MySQL. Other DBs can use standard delete with joins - NB: Fixed TransactionalCleanupTest to double-check the purge job 41822: Refactor to both Share Mappers. 41838: BDE-85: Deploy alfresco-mmt with a proper pom.xml containing dependencies Also, refactor Maven deployment to use a macro 41858: ALF-14444 - CloudSync: Ensure unknown properties when synced to Cloud are ignored properly 41876: Fix ALF-16067 - Items with cm:versionable aspect [custom aspect added] throw errors in Share UI 41877: Updated Spring Surf libs (1148) - downgrades module deployment error messages 41878: ALF-16069 - RU: 'Web Deployed' folder is not localized if Alfresco is installed with Russian locale. 41879: Fix non-continuous build, trying to call continuous-init from maven-env-prerequisites 41918: Merged PATCHES/V4.1.1 to V4.1-BUG-FIX 41657: ALF-15965 - IE9 - Script error occurs when manage aspect for a document (correct 4.1.1 branch this time) 41834: Merged DEV to V4.1.1 (4.1.1) 41827: ALF-15983: SPP: Meeting space: all-day event is displayed on the day before specified during creation Removing of time zone has been modified to be sensitive to Outlook meeting events which are not requiring special conversion for the start and end dates 41835: Merged DEV to V4.1.1 (4.1.1) 41833: ALF-16038 : DB2: Upgrade script needed to remove ALFUSER.ACT_HI_ACTINST.OWNER_ The patch was created to remove an unnecessary column in DB2. 41845: Reverse merge: << In attempt to clear 12 new DB2 build errors - don't think it is going to work >> 41835: Merged DEV to V4.1.1 (4.1.1) 41833: ALF-16038 : DB2: Upgrade script needed to remove ALFUSER.ACT_HI_ACTINST.OWNER_ The patch was created to remove an unnecessary column in DB2. Merged V4.1-BUG-FIX (4.1.2) to V4.1.1 (4.1.1) 41337: Merged V3.4-BUG-FIX (3.4.11) to V4.1-BUG-FIX (4.1.2) 41336: TransformerDebug: Use debug rather than trace when there are transformers but they are all unavailable. 41868: Reverse the reverse merge (back to r41835 state used in build #33 given to QA) 41845: Reverse merge: << In attempt to clear 12 new DB2 build errors - don't think it is going to work >> 41835: Merged DEV to V4.1.1 (4.1.1) 41833: ALF-16038 : DB2: Upgrade script needed to remove ALFUSER.ACT_HI_ACTINST.OWNER_ The patch was created to remove an unnecessary column in DB2. Merged V4.1-BUG-FIX (4.1.2) to V4.1.1 (4.1.1) 41337: Merged V3.4-BUG-FIX (3.4.11) to V4.1-BUG-FIX (4.1.2) 41336: TransformerDebug: Use debug rather than trace when there are transformers but they are all unavailable. 41914: Merged DEV to PATCHES/V4.1.1 41909: ALF-16078 : DB2: it's impossible to upgrade Alfresco from 3.4.10 to 4.1.1 (build 33). The remove-column-activiti.sql was marked as optional. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@41919 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
409 lines
14 KiB
Java
409 lines
14 KiB
Java
/*
|
|
* Copyright (C) 2005-2011 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.wiki;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.alfresco.error.AlfrescoRuntimeException;
|
|
import org.alfresco.model.ContentModel;
|
|
import org.alfresco.query.CannedQueryFactory;
|
|
import org.alfresco.query.CannedQueryResults;
|
|
import org.alfresco.query.CannedQuerySortDetails;
|
|
import org.alfresco.query.EmptyPagingResults;
|
|
import org.alfresco.query.PagingRequest;
|
|
import org.alfresco.query.PagingResults;
|
|
import org.alfresco.repo.content.MimetypeMap;
|
|
import org.alfresco.repo.domain.node.NodeDAO;
|
|
import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQuery;
|
|
import org.alfresco.repo.node.getchildren.GetChildrenAuditableCannedQueryFactory;
|
|
import org.alfresco.repo.query.NodeBackedEntity;
|
|
import org.alfresco.repo.site.SiteServiceImpl;
|
|
import org.alfresco.service.cmr.model.FileFolderService;
|
|
import org.alfresco.service.cmr.model.FileNotFoundException;
|
|
import org.alfresco.service.cmr.repository.ContentReader;
|
|
import org.alfresco.service.cmr.repository.ContentService;
|
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.cmr.repository.NodeService;
|
|
import org.alfresco.service.cmr.site.SiteService;
|
|
import org.alfresco.service.cmr.tagging.TaggingService;
|
|
import org.alfresco.service.cmr.wiki.WikiPageInfo;
|
|
import org.alfresco.service.cmr.wiki.WikiService;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.alfresco.service.transaction.TransactionService;
|
|
import org.alfresco.util.Pair;
|
|
import org.alfresco.util.registry.NamedObjectRegistry;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
/**
|
|
* @author Nick Burch (based on existing webscript controllers in the REST API)
|
|
* @since 4.0
|
|
*/
|
|
public class WikiServiceImpl implements WikiService
|
|
{
|
|
public static final String WIKI_COMPONENT = "wiki";
|
|
|
|
protected static final String CANNED_QUERY_GET_CHILDREN = "wikiGetChildrenCannedQueryFactory";
|
|
|
|
/**
|
|
* The logger
|
|
*/
|
|
@SuppressWarnings("unused")
|
|
private static Log logger = LogFactory.getLog(WikiServiceImpl.class);
|
|
|
|
private NodeDAO nodeDAO;
|
|
private NodeService nodeService;
|
|
private SiteService siteService;
|
|
private ContentService contentService;
|
|
private TaggingService taggingService;
|
|
private FileFolderService fileFolderService;
|
|
private TransactionService transactionService;
|
|
private NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry;
|
|
|
|
public void setNodeDAO(NodeDAO nodeDAO)
|
|
{
|
|
this.nodeDAO = nodeDAO;
|
|
}
|
|
|
|
public void setNodeService(NodeService nodeService)
|
|
{
|
|
this.nodeService = nodeService;
|
|
}
|
|
|
|
public void setSiteService(SiteService siteService)
|
|
{
|
|
this.siteService = siteService;
|
|
}
|
|
|
|
public void setContentService(ContentService contentService)
|
|
{
|
|
this.contentService = contentService;
|
|
}
|
|
|
|
public void setTaggingService(TaggingService taggingService)
|
|
{
|
|
this.taggingService = taggingService;
|
|
}
|
|
|
|
public void setFileFolderService(FileFolderService fileFolderService)
|
|
{
|
|
this.fileFolderService = fileFolderService;
|
|
}
|
|
|
|
public void setTransactionService(TransactionService transactionService)
|
|
{
|
|
this.transactionService = transactionService;
|
|
}
|
|
|
|
/**
|
|
* Set the registry of {@link CannedQueryFactory canned queries}
|
|
*/
|
|
public void setCannedQueryRegistry(NamedObjectRegistry<CannedQueryFactory<? extends Object>> cannedQueryRegistry)
|
|
{
|
|
this.cannedQueryRegistry = cannedQueryRegistry;
|
|
}
|
|
|
|
/**
|
|
* Fetches the Wiki Container on a site, creating as required if requested.
|
|
*/
|
|
protected NodeRef getSiteWikiContainer(final String siteShortName, boolean create)
|
|
{
|
|
return SiteServiceImpl.getSiteContainer(
|
|
siteShortName, WIKI_COMPONENT, create,
|
|
siteService, transactionService, taggingService);
|
|
}
|
|
|
|
/**
|
|
* Turns a Title into a Page Name.
|
|
*/
|
|
private static String buildName(String title)
|
|
{
|
|
// The name is based on the title, but with underscores
|
|
String name = title.replace(' ', '_');
|
|
name = name.replaceAll("\"", "%22");
|
|
name = name.replaceAll("[*]", "%2a");
|
|
name = name.replaceAll("<", "%3c");
|
|
name = name.replaceAll(">", "%3e");
|
|
name = name.replaceAll(":", "%3a");
|
|
name = name.replaceAll("([.]?[.]+$)", "%2e");
|
|
return name;
|
|
}
|
|
|
|
private WikiPageInfo buildPage(NodeRef nodeRef, NodeRef container, String name, String preLoadedContents)
|
|
{
|
|
WikiPageInfoImpl page = new WikiPageInfoImpl(nodeRef, container, name);
|
|
|
|
// Grab all the properties, we need the bulk of them anyway
|
|
Map<QName,Serializable> props = nodeService.getProperties(nodeRef);
|
|
|
|
// Start with the auditable properties
|
|
page.setCreator((String)props.get(ContentModel.PROP_CREATOR));
|
|
page.setModifier((String)props.get(ContentModel.PROP_MODIFIER));
|
|
page.setCreatedAt((Date)props.get(ContentModel.PROP_CREATED));
|
|
page.setModifiedAt((Date)props.get(ContentModel.PROP_MODIFIED));
|
|
|
|
// Now the wiki ones
|
|
page.setTitle((String)props.get(ContentModel.PROP_TITLE));
|
|
|
|
// Finally, do the content
|
|
String contents = preLoadedContents;
|
|
if (contents == null)
|
|
{
|
|
ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
|
|
if (reader != null)
|
|
{
|
|
contents = reader.getContentString();
|
|
}
|
|
}
|
|
page.setContents(contents);
|
|
|
|
// Finally tags
|
|
page.setTags(taggingService.getTags(nodeRef));
|
|
|
|
// All done
|
|
return page;
|
|
}
|
|
|
|
|
|
@Override
|
|
public WikiPageInfo getWikiPage(String siteShortName, String pageTitle)
|
|
{
|
|
NodeRef container = getSiteWikiContainer(siteShortName, false);
|
|
if (container == null)
|
|
{
|
|
// No links
|
|
return null;
|
|
}
|
|
|
|
String pageName = buildName(pageTitle);
|
|
NodeRef link = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, pageName);
|
|
if (link != null)
|
|
{
|
|
return buildPage(link, container, pageName, null);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public WikiPageInfo createWikiPage(String siteShortName, String title,
|
|
String content)
|
|
{
|
|
// Grab the location to store in
|
|
NodeRef container = getSiteWikiContainer(siteShortName, true);
|
|
|
|
// Build the name
|
|
String name = buildName(title);
|
|
|
|
// Get the properties for the node
|
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
|
|
props.put(ContentModel.PROP_NAME, name);
|
|
props.put(ContentModel.PROP_TITLE, title);
|
|
|
|
// Build the node
|
|
NodeRef nodeRef = nodeService.createNode(
|
|
container,
|
|
ContentModel.ASSOC_CONTAINS,
|
|
QName.createQName(name),
|
|
ContentModel.TYPE_CONTENT,
|
|
props
|
|
).getChildRef();
|
|
|
|
// Store the content
|
|
ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
|
|
writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
|
|
writer.setEncoding("UTF-8");
|
|
writer.putContent(content);
|
|
|
|
// Generate the wrapping object for it
|
|
// Build it that way, so creator and created date come through
|
|
return buildPage(nodeRef, container, name, content);
|
|
}
|
|
|
|
@Override
|
|
public WikiPageInfo updateWikiPage(WikiPageInfo page)
|
|
{
|
|
// Sanity check what we were given
|
|
if (page.getNodeRef() == null)
|
|
{
|
|
throw new IllegalArgumentException("Can't update a page that was never persisted, call create instead");
|
|
}
|
|
|
|
NodeRef nodeRef = page.getNodeRef();
|
|
String nodeName = buildName(page.getTitle());
|
|
|
|
// Handle the rename case
|
|
boolean renamed = false;
|
|
if (! nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE).equals(page.getTitle()))
|
|
{
|
|
try
|
|
{
|
|
fileFolderService.rename(nodeRef, nodeName);
|
|
renamed = true;
|
|
}
|
|
catch (FileNotFoundException e)
|
|
{
|
|
throw new AlfrescoRuntimeException("Invalid node state - wiki page no longer found");
|
|
}
|
|
nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, nodeName);
|
|
nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, page.getTitle());
|
|
}
|
|
|
|
// Change the content
|
|
ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
|
|
writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
|
|
writer.setEncoding("UTF-8");
|
|
writer.putContent(page.getContents());
|
|
|
|
// Now do the tags
|
|
taggingService.setTags(nodeRef, page.getTags());
|
|
|
|
// If we re-named, re-create the object
|
|
if (renamed)
|
|
{
|
|
page = buildPage(nodeRef, page.getContainerNodeRef(), nodeName, page.getContents());
|
|
}
|
|
|
|
// All done
|
|
return page;
|
|
}
|
|
|
|
@Override
|
|
public void deleteWikiPage(WikiPageInfo page)
|
|
{
|
|
if (page.getNodeRef() == null)
|
|
{
|
|
throw new IllegalArgumentException("Can't delete a wiki page that was never persisted");
|
|
}
|
|
|
|
nodeService.deleteNode(page.getNodeRef());
|
|
}
|
|
|
|
@Override
|
|
public PagingResults<WikiPageInfo> listWikiPages(String siteShortName, PagingRequest paging)
|
|
{
|
|
return listWikiPages(siteShortName, null, paging);
|
|
}
|
|
|
|
@Override
|
|
public PagingResults<WikiPageInfo> listWikiPages(String siteShortName, String user,
|
|
PagingRequest paging)
|
|
{
|
|
return listWikiPages(siteShortName, user, null, null, null, null, paging);
|
|
}
|
|
|
|
@Override
|
|
public PagingResults<WikiPageInfo> listWikiPagesByCreated(String siteShortName,
|
|
Date from, Date to, PagingRequest paging)
|
|
{
|
|
return listWikiPages(siteShortName, null, from, to, null, null, paging);
|
|
}
|
|
|
|
@Override
|
|
public PagingResults<WikiPageInfo> listWikiPagesByModified(String siteShortName,
|
|
Date from, Date to, PagingRequest paging)
|
|
{
|
|
return listWikiPages(siteShortName, null, null, null, from, to, paging);
|
|
}
|
|
|
|
public PagingResults<WikiPageInfo> listWikiPages(String siteShortName, String username,
|
|
Date createdFrom, Date createdTo, Date modifiedFrom, Date modifiedTo, PagingRequest paging)
|
|
{
|
|
NodeRef container = getSiteWikiContainer(siteShortName, false);
|
|
if (container == null)
|
|
{
|
|
// No events
|
|
return new EmptyPagingResults<WikiPageInfo>();
|
|
}
|
|
|
|
// Grab the factory
|
|
GetChildrenAuditableCannedQueryFactory getChildrenCannedQueryFactory =
|
|
(GetChildrenAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN);
|
|
|
|
// Do the sorting, newest first by created date
|
|
CannedQuerySortDetails sorting = getChildrenCannedQueryFactory.createDateDescendingCQSortDetails();
|
|
|
|
// Run the canned query
|
|
GetChildrenAuditableCannedQuery cq = (GetChildrenAuditableCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(
|
|
container, ContentModel.TYPE_CONTENT, username, createdFrom, createdTo, null,
|
|
modifiedFrom, modifiedTo, sorting, paging);
|
|
|
|
// Execute the canned query
|
|
CannedQueryResults<NodeBackedEntity> results = cq.execute();
|
|
|
|
// Convert to Link objects
|
|
return wrap(results, container);
|
|
}
|
|
|
|
/**
|
|
* Our class to wrap up paged results of NodeBackedEntities as
|
|
* WikiPageInfo instances
|
|
*/
|
|
private PagingResults<WikiPageInfo> wrap(final PagingResults<NodeBackedEntity> results, final NodeRef container)
|
|
{
|
|
// Pre-load the nodes before we create them
|
|
List<Long> ids = new ArrayList<Long>();
|
|
for (NodeBackedEntity node : results.getPage())
|
|
{
|
|
ids.add(node.getId());
|
|
}
|
|
nodeDAO.cacheNodesById(ids);
|
|
|
|
// Wrap
|
|
return new PagingResults<WikiPageInfo>()
|
|
{
|
|
@Override
|
|
public String getQueryExecutionId()
|
|
{
|
|
return results.getQueryExecutionId();
|
|
}
|
|
|
|
@Override
|
|
public List<WikiPageInfo> getPage()
|
|
{
|
|
List<WikiPageInfo> pages = new ArrayList<WikiPageInfo>();
|
|
for (NodeBackedEntity node : results.getPage())
|
|
{
|
|
NodeRef nodeRef = node.getNodeRef();
|
|
String name = node.getName();
|
|
pages.add(buildPage(nodeRef, container, name, null));
|
|
}
|
|
return pages;
|
|
}
|
|
|
|
@Override
|
|
public boolean hasMoreItems()
|
|
{
|
|
return results.hasMoreItems();
|
|
}
|
|
|
|
@Override
|
|
public Pair<Integer, Integer> getTotalResultCount()
|
|
{
|
|
return results.getTotalResultCount();
|
|
}
|
|
};
|
|
}
|
|
}
|