Merge V1.2.0 BRANCH to HEAD

svn merge -r 2519:2565 svn://www.alfresco.org/alfresco/BRANCHES/V1.2.0/root HEAD/root


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2566 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-03-22 12:23:43 +00:00
parent 9fe16d5ae3
commit 506e408ca7
29 changed files with 725 additions and 182 deletions

View File

@@ -3,7 +3,7 @@
<!-- <!--
Repository Boostrap Sequence. Repository Bootstrap Sequence.
This file specifies the initialisation (and order of initialisation) to perform during Repository startup. This file specifies the initialisation (and order of initialisation) to perform during Repository startup.
@@ -34,6 +34,10 @@
<prop key="path">/</prop> <prop key="path">/</prop>
<prop key="location">alfresco/bootstrap/alfrescoUserStore.xml</prop> <prop key="location">alfresco/bootstrap/alfrescoUserStore.xml</prop>
</props> </props>
<props>
<prop key="path">/${alfresco_user_store.system_container.childname}</prop>
<prop key="location">alfresco/bootstrap/alfrescoAuthorityStore.xml</prop>
</props>
</list> </list>
</property> </property>
</bean> </bean>

View File

@@ -0,0 +1,10 @@
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
xmlns:cm="http://www.alfresco.org/model/content/1.0"
xmlns:sys="http://www.alfresco.org/model/system/1.0"
xmlns:usr="http://www.alfresco.org/model/user/1.0"
xmlns:app="http://www.alfresco.org/model/application/1.0">
<sys:container view:childName="${alfresco_user_store.authorities_container.childname}">
</sys:container>
</view:view>

View File

@@ -18,8 +18,6 @@
</usr:user> </usr:user>
</sys:children> </sys:children>
</sys:container> </sys:container>
<sys:container view:childName="${alfresco_user_store.authorities_container.childname}">
</sys:container>
</sys:children> </sys:children>
</sys:container> </sys:container>

View File

@@ -6,6 +6,14 @@ patch.executer.not_executed =\n=== Recorded patch (not executed) === \nID: {0}\n
patch.executer.executed =\n=== Applied patch === \nID: {0}\nRESULT: \n{1}\n===================================== patch.executer.executed =\n=== Applied patch === \nID: {0}\nRESULT: \n{1}\n=====================================
patch.executer.failed =\n=== Failed to apply patch === \nID: {0}\nRESULT: \n{1}\n===================================== patch.executer.failed =\n=== Failed to apply patch === \nID: {0}\nRESULT: \n{1}\n=====================================
# General patch messages
patch.genericBootstrap.result.exists=Bootstrap location already exists: {0}
patch.genericBootstrap.result.created=Imported view into bootstrap location: {0} ({1})
patch.genericBootstrap.err.multiple_found=Multiple nodes found: {0}
patch.general.property_not_set=Patch property ''{0}'' has not been set on this patch: {1}
# Individual patch messages # Individual patch messages
patch.savedSearchesFolder.description=Ensures the existence of the 'Saved Searches' folder. patch.savedSearchesFolder.description=Ensures the existence of the 'Saved Searches' folder.
@@ -19,6 +27,8 @@ patch.savedSearchesPermission.err.not_found='Saved Searches' folder could not be
patch.updatePermissionData.description=Update permission entries from 'folder' to 'cmobject'. patch.updatePermissionData.description=Update permission entries from 'folder' to 'cmobject'.
patch.updatePermissionData.result=Created the following permission reference names: {0}. \nUpdated {1} permission entries. patch.updatePermissionData.result=Created the following permission reference names: {0}. \nUpdated {1} permission entries.
patch.authoritiesFolder.description=Ensures the existence of the user authorities folder [JIRA: AR-497].
patch.guestUser.description=Add the guest user, guest home space; and fix permissions on company home, guest home and guest person. patch.guestUser.description=Add the guest user, guest home space; and fix permissions on company home, guest home and guest person.
patch.guestUser.result=Added guest user and fixed permissions. patch.guestUser.result=Added guest user and fixed permissions.

View File

@@ -153,9 +153,9 @@
<grantedToGroup permissionGroup="Delete" /> <grantedToGroup permissionGroup="Delete" />
<!-- Commented out parent permission check ... <!-- Commented out parent permission check ...
<requiredPermission on="parent" name="ReadChildren" implies="false"/> <requiredPermission on="parent" name="ReadChildren" implies="false"/>
-->
<requiredPermission on="parent" name="DeleteChildren" implies="false"/> <requiredPermission on="parent" name="DeleteChildren" implies="false"/>
<requiredPermission on="node" name="DeleteChildren" implies="false"/> <requiredPermission on="node" name="DeleteChildren" implies="false"/>
-->
<!-- Remove the recursive check for now for performance --> <!-- Remove the recursive check for now for performance -->
<!-- TODO: have one permission to check for delete on an item and one to check --> <!-- TODO: have one permission to check for delete on an item and one to check -->
<!-- child permissions when delete is called on the node service --> <!-- child permissions when delete is called on the node service -->

View File

@@ -44,7 +44,10 @@
<property name="sys:versionSchema"> <property name="sys:versionSchema">
<type>d:int</type> <type>d:int</type>
<mandatory enforced="true">true</mandatory> <mandatory enforced="true">true</mandatory>
<default>0</default> <default>0</default>
</property>
<property name="sys:license">
<type>d:content</type>
</property> </property>
</properties> </properties>
</type> </type>

View File

@@ -77,11 +77,19 @@
<!-- Helper beans --> <!-- Helper beans -->
<!-- --> <!-- -->
<bean id="patch.savedSearches.Base" abstract="true" parent="basePatch" > <bean id="patch.genericBootstrap.Base" abstract="true" parent="basePatch" >
<!-- helper beans for execution --> <property name="namespaceService">
<property name="importerBootstrap"> <ref bean="namespaceService" />
<ref bean="spacesBootstrap" />
</property> </property>
<property name="searchService">
<ref bean="searchService" />
</property>
<property name="nodeService">
<ref bean="nodeService"/>
</property>
</bean>
<bean id="patch.savedSearches.Base" abstract="true" parent="basePatch" >
<property name="namespaceService"> <property name="namespaceService">
<ref bean="namespaceService" /> <ref bean="namespaceService" />
</property> </property>
@@ -105,6 +113,26 @@
<!-- Patch definitions --> <!-- Patch definitions -->
<!-- --> <!-- -->
<bean id="patch.authoritiesFolder" class="org.alfresco.repo.admin.patch.impl.GenericBootstrapPatch" parent="patch.genericBootstrap.Base" >
<property name="id"><value>patch.authoritiesFolder</value></property>
<property name="description"><value>patch.authoritiesFolder.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>0</value></property>
<property name="targetSchema"><value>6</value></property>
<!-- bootstrap view -->
<property name="importerBootstrap">
<ref bean="userBootstrap" />
</property>
<property name="checkPath">
<value>/${alfresco_user_store.system_container.childname}/${alfresco_user_store.authorities_container.childname}</value>
</property>
<property name="bootstrapView">
<props>
<prop key="path">/${alfresco_user_store.system_container.childname}</prop>
<prop key="location">alfresco/bootstrap/alfrescoAuthorityStore.xml</prop>
</props>
</property>
</bean>
<bean id="patch.savedSearchesFolder" class="org.alfresco.repo.admin.patch.impl.SavedSearchFolderPatch" parent="patch.savedSearches.Base" > <bean id="patch.savedSearchesFolder" class="org.alfresco.repo.admin.patch.impl.SavedSearchFolderPatch" parent="patch.savedSearches.Base" >
<property name="id"><value>patch.savedSearchesFolder</value></property> <property name="id"><value>patch.savedSearchesFolder</value></property>
<property name="description"><value>patch.savedSearchesFolder.description</value></property> <property name="description"><value>patch.savedSearchesFolder.description</value></property>

View File

@@ -337,7 +337,7 @@
org.alfresco.service.cmr.repository.NodeService.getNodeStatus=ACL_NODE.0.sys:base.Read org.alfresco.service.cmr.repository.NodeService.getNodeStatus=ACL_NODE.0.sys:base.Read
org.alfresco.service.cmr.repository.NodeService.getRootNode=ACL_NODE.0.sys:base.Read org.alfresco.service.cmr.repository.NodeService.getRootNode=ACL_NODE.0.sys:base.Read
org.alfresco.service.cmr.repository.NodeService.createNode=ACL_NODE.0.sys:base.CreateChildren org.alfresco.service.cmr.repository.NodeService.createNode=ACL_NODE.0.sys:base.CreateChildren
org.alfresco.service.cmr.repository.NodeService.moveNode=ACL_NODE.0.sys:base.WriteProperties,ACL_PARENT.0.sys:base.DeleteChildren,ACL_NODE.1.sys:base.CreateChildren org.alfresco.service.cmr.repository.NodeService.moveNode=ACL_NODE.0.sys:base.DeleteNode,ACL_NODE.1.sys:base.CreateChildren
org.alfresco.service.cmr.repository.NodeService.setChildAssociationIndex=ACL_PARENT.0.sys:base.WriteProperties org.alfresco.service.cmr.repository.NodeService.setChildAssociationIndex=ACL_PARENT.0.sys:base.WriteProperties
org.alfresco.service.cmr.repository.NodeService.getType=ACL_NODE.0.sys:base.Read org.alfresco.service.cmr.repository.NodeService.getType=ACL_NODE.0.sys:base.Read
org.alfresco.service.cmr.repository.NodeService.setType=ACL_NODE.0.sys:base.Write org.alfresco.service.cmr.repository.NodeService.setType=ACL_NODE.0.sys:base.Write
@@ -345,9 +345,9 @@
org.alfresco.service.cmr.repository.NodeService.removeAspect=ACL_NODE.0.sys:base.Write org.alfresco.service.cmr.repository.NodeService.removeAspect=ACL_NODE.0.sys:base.Write
org.alfresco.service.cmr.repository.NodeService.hasAspect=ACL_NODE.0.sys:base.ReadProperties org.alfresco.service.cmr.repository.NodeService.hasAspect=ACL_NODE.0.sys:base.ReadProperties
org.alfresco.service.cmr.repository.NodeService.getAspects=ACL_NODE.0.sys:base.ReadProperties org.alfresco.service.cmr.repository.NodeService.getAspects=ACL_NODE.0.sys:base.ReadProperties
org.alfresco.service.cmr.repository.NodeService.deleteNode=ACL_NODE.0.sys:base.Delete org.alfresco.service.cmr.repository.NodeService.deleteNode=ACL_NODE.0.sys:base.DeleteNode
org.alfresco.service.cmr.repository.NodeService.addChild=ACL_NODE.0.sys:base.CreateChildren,ACL_NODE.1.sys:base.ReadProperties org.alfresco.service.cmr.repository.NodeService.addChild=ACL_NODE.0.sys:base.CreateChildren,ACL_NODE.1.sys:base.ReadProperties
org.alfresco.service.cmr.repository.NodeService.removeChild=ACL_NODE.1.sys:base.Delete org.alfresco.service.cmr.repository.NodeService.removeChild=ACL_NODE.1.sys:base.DeleteChildren
org.alfresco.service.cmr.repository.NodeService.getProperties=ACL_NODE.0.sys:base.ReadProperties org.alfresco.service.cmr.repository.NodeService.getProperties=ACL_NODE.0.sys:base.ReadProperties
org.alfresco.service.cmr.repository.NodeService.getProperty=ACL_NODE.0.sys:base.ReadProperties org.alfresco.service.cmr.repository.NodeService.getProperty=ACL_NODE.0.sys:base.ReadProperties
org.alfresco.service.cmr.repository.NodeService.setProperties=ACL_NODE.0.sys:base.WriteProperties org.alfresco.service.cmr.repository.NodeService.setProperties=ACL_NODE.0.sys:base.WriteProperties

View File

@@ -43,6 +43,7 @@ import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.util.SearchLanguageConversion;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -382,9 +383,13 @@ public class CifsHelper
" Path Root: " + pathRootNodeRef + "\n" + " Path Root: " + pathRootNodeRef + "\n" +
" Path Element: " + pathElement); " Path Element: " + pathElement);
} }
// escape for the Lucene syntax search
String escapedPathElement = SearchLanguageConversion.convertCifsToLucene(pathElement);
// do the lookup // do the lookup
List<org.alfresco.service.cmr.model.FileInfo> childInfos = fileFolderService.search(pathRootNodeRef, pathElement, false); List<org.alfresco.service.cmr.model.FileInfo> childInfos = fileFolderService.search(
pathRootNodeRef,
escapedPathElement,
false);
// convert to noderefs // convert to noderefs
List<NodeRef> results = new ArrayList<NodeRef>(childInfos.size()); List<NodeRef> results = new ArrayList<NodeRef>(childInfos.size());
for (org.alfresco.service.cmr.model.FileInfo info : childInfos) for (org.alfresco.service.cmr.model.FileInfo info : childInfos)

View File

@@ -58,6 +58,7 @@ public interface ContentModel
static final QName PROP_SYS_VERSION_REVISION = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionRevision"); static final QName PROP_SYS_VERSION_REVISION = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionRevision");
static final QName PROP_SYS_VERSION_LABEL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionLabel"); static final QName PROP_SYS_VERSION_LABEL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionLabel");
static final QName PROP_SYS_VERSION_SCHEMA = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionSchema"); static final QName PROP_SYS_VERSION_SCHEMA = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionSchema");
static final QName PROP_SYS_LICENSE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "license");
// //
// Content Model Definitions // Content Model Definitions

View File

@@ -37,6 +37,15 @@ import org.apache.commons.logging.LogFactory;
*/ */
public abstract class AbstractPatch implements Patch public abstract class AbstractPatch implements Patch
{ {
/**
* I18N message when properties nto set.
* <ul>
* <li>{0} = property name</li>
* <li>{1} = patch instance</li>
* </ul>
*/
public static final String ERR_PROPERTY_NOT_SET = "patch.general.property_not_set";
private static Log logger = LogFactory.getLog(AbstractPatch.class); private static Log logger = LogFactory.getLog(AbstractPatch.class);
private String id; private String id;
@@ -215,30 +224,38 @@ public abstract class AbstractPatch implements Patch
{ {
return ((this.fixesFromSchema <= version) && (version <= fixesToSchema)); return ((this.fixesFromSchema <= version) && (version <= fixesToSchema));
} }
/**
* Performs a null check on the supplied value.
*
* @param value value to check
* @param name name of the property to report
*/
protected final void checkPropertyNotNull(Object value, String name)
{
if (value == null)
{
throw new PatchException(ERR_PROPERTY_NOT_SET, "bootstrapView", this);
}
}
/** /**
* Check that the schema version properties have been set appropriately * Check that the schema version properties have been set appropriately.
* Derived classes can override this method to perform their own validation provided
* that this method is called by the derived class.
*/ */
private void checkProperties() protected void checkProperties()
{ {
// check that the necessary properties have been set // check that the necessary properties have been set
if (id == null || description == null) checkPropertyNotNull(id, "id");
{ checkPropertyNotNull(description, "description");
throw new AlfrescoRuntimeException( checkPropertyNotNull(transactionService, "transactionService");
"Patch properties 'id', 'fixesFromSchema' and 'description' have not all been set on this patch: \n" + if (fixesFromSchema == -1 || fixesToSchema == -1 || targetSchema == -1)
" patch: " + this);
}
else if (fixesFromSchema == -1 || fixesToSchema == -1 || targetSchema == -1)
{ {
throw new AlfrescoRuntimeException( throw new AlfrescoRuntimeException(
"Patch properties 'fixesFromSchema', 'fixesToSchema' and 'targetSchema' have not all been set on this patch: \n" + "Patch properties 'fixesFromSchema', 'fixesToSchema' and 'targetSchema' have not all been set on this patch: \n" +
" patch: " + this); " patch: " + this);
} }
else if (transactionService == null)
{
throw new AlfrescoRuntimeException("'transactionService' property has not been set: \n" +
" patch: " + this);
}
} }
/** /**

View File

@@ -0,0 +1,144 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.admin.patch.impl;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.service.cmr.admin.PatchException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
/**
* Generic patch that uses existing {@link org.alfresco.repo.importer.ImporterBootstrap importers}
* to import snippets into the system. These snippets would otherwise have been bootstrapped by
* a clean install.
* <p>
* By providing this class with a bootstrap view and an importer, it can check whether the path
* exists and perform the import if it doesn't.
*
* @author Derek Hulley
*/
public class GenericBootstrapPatch extends AbstractPatch
{
private static final String MSG_EXISTS = "patch.genericBootstrap.result.exists";
private static final String MSG_CREATED = "patch.genericBootstrap.result.created";
private static final String ERR_MULTIPLE_FOUND = "patch.genericBootstrap.err.multiple_found";
private NamespaceService namespaceService;
private NodeService nodeService;
private SearchService searchService;
private ImporterBootstrap importerBootstrap;
private String checkPath;
private Properties bootstrapView;
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
/**
* @param importerBootstrap the bootstrap bean that performs the user store bootstrap
*/
public void setImporterBootstrap(ImporterBootstrap importerBootstrap)
{
this.importerBootstrap = importerBootstrap;
}
/**
* Set the XPath statement that must be executed to check whether the import data is
* already present or not.
*
* @param checkPath an XPath statement
*/
public void setCheckPath(String checkPath)
{
this.checkPath = checkPath;
}
/**
* @see ImporterBootstrap#setBootstrapViews(List)
*
* @param bootstrapView the bootstrap location
*/
public void setBootstrapView(Properties bootstrapView)
{
this.bootstrapView = bootstrapView;
}
@Override
protected void checkProperties()
{
checkPropertyNotNull(namespaceService, "blah");
checkPropertyNotNull(nodeService, "nodeService");
checkPropertyNotNull(searchService, "searchService");
checkPropertyNotNull(importerBootstrap, "importerBootstrap");
checkPropertyNotNull(checkPath, "checkPath");
checkPropertyNotNull(bootstrapView, "bootstrapView");
// fulfil contract of override
super.checkProperties();
}
@Override
protected String applyInternal() throws Exception
{
StoreRef storeRef = importerBootstrap.getStoreRef();
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
List<NodeRef> results = searchService.selectNodes(
rootNodeRef,
checkPath,
null,
namespaceService,
false);
if (results.size() > 1)
{
throw new PatchException(ERR_MULTIPLE_FOUND, checkPath);
}
else if (results.size() == 1)
{
// nothing to do - it exsists
return I18NUtil.getMessage(MSG_EXISTS, checkPath);
}
String path = bootstrapView.getProperty("path");
List<Properties> bootstrapViews = Collections.singletonList(bootstrapView);
// modify the bootstrapper
importerBootstrap.setBootstrapViews(bootstrapViews);
importerBootstrap.setUseExistingStore(true); // allow import into existing store
importerBootstrap.bootstrap();
// done
return I18NUtil.getMessage(MSG_CREATED, path, rootNodeRef);
}
}

View File

@@ -18,6 +18,8 @@ package org.alfresco.repo.descriptor;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -34,12 +36,18 @@ import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.descriptor.Descriptor; import org.alfresco.service.descriptor.Descriptor;
import org.alfresco.service.descriptor.DescriptorService; import org.alfresco.service.descriptor.DescriptorService;
import org.alfresco.service.license.LicenseDescriptor;
import org.alfresco.service.license.LicenseException;
import org.alfresco.service.license.LicenseService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.ContextRefreshedEvent;
@@ -51,10 +59,12 @@ import org.springframework.core.io.Resource;
* *
* @author David Caruana * @author David Caruana
*/ */
public class DescriptorServiceImpl implements DescriptorService, ApplicationListener, InitializingBean public class DescriptorServiceImpl implements DescriptorService, ApplicationListener, InitializingBean, ApplicationContextAware
{ {
private static Log logger = LogFactory.getLog(DescriptorServiceImpl.class); private static Log logger = LogFactory.getLog(DescriptorServiceImpl.class);
private ApplicationContext applicationContext;
private Properties serverProperties; private Properties serverProperties;
private ImporterBootstrap systemBootstrap; private ImporterBootstrap systemBootstrap;
@@ -62,11 +72,19 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
private NodeService nodeService; private NodeService nodeService;
private SearchService searchService; private SearchService searchService;
private TransactionService transactionService; private TransactionService transactionService;
private LicenseService licenseService = null;
private Descriptor serverDescriptor; private Descriptor serverDescriptor;
private Descriptor installedRepoDescriptor; private Descriptor installedRepoDescriptor;
/* (non-Javadoc)
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
this.applicationContext = applicationContext;
}
/** /**
* Sets the server descriptor from a resource file * Sets the server descriptor from a resource file
@@ -120,7 +138,7 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
{ {
this.searchService = searchService; this.searchService = searchService;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.alfresco.service.descriptor.DescriptorService#getDescriptor() * @see org.alfresco.service.descriptor.DescriptorService#getDescriptor()
*/ */
@@ -137,6 +155,14 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
return installedRepoDescriptor; return installedRepoDescriptor;
} }
/* (non-Javadoc)
* @see org.alfresco.service.descriptor.DescriptorService#getLicenseDescriptor()
*/
public LicenseDescriptor getLicenseDescriptor()
{
return licenseService.getLicense();
}
/** /**
* @param event * @param event
*/ */
@@ -150,9 +176,12 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
{ {
public Descriptor doWork() public Descriptor doWork()
{ {
// verify license, but only if license component is installed
licenseService.verifyLicense();
// persist the server descriptor values // persist the server descriptor values
updateCurrentRepositoryDescriptor(serverDescriptor); updateCurrentRepositoryDescriptor(serverDescriptor);
// return the repository installed descriptor // return the repository installed descriptor
return createInstalledRepositoryDescriptor(); return createInstalledRepositoryDescriptor();
} }
@@ -168,6 +197,9 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
{ {
// initialise server descriptor // initialise server descriptor
serverDescriptor = createServerDescriptor(); serverDescriptor = createServerDescriptor();
// initialise license service (if installed)
initialiseLicenseService();
} }
/** /**
@@ -306,6 +338,77 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
return descriptorNodeRef; return descriptorNodeRef;
} }
/**
* Initialise License Service
*/
private void initialiseLicenseService()
{
try
{
// NOTE: We could tie in the License Component via Spring configuration, but then it could
// be declaratively taken out in an installed environment.
Class licenseComponentClass = Class.forName("org.alfresco.license.LicenseComponent");
Constructor constructor = licenseComponentClass.getConstructor(new Class[] { ApplicationContext.class} );
licenseService = (LicenseService)constructor.newInstance(new Object[] { applicationContext } );
}
catch (ClassNotFoundException e)
{
licenseService = new NOOPLicenseService();
}
catch (SecurityException e)
{
throw new AlfrescoRuntimeException("Failed to initialise license service", e);
}
catch (IllegalArgumentException e)
{
throw new AlfrescoRuntimeException("Failed to initialise license service", e);
}
catch (NoSuchMethodException e)
{
throw new AlfrescoRuntimeException("Failed to initialise license service", e);
}
catch (InvocationTargetException e)
{
throw new AlfrescoRuntimeException("Failed to initialise license service", e);
}
catch (InstantiationException e)
{
throw new AlfrescoRuntimeException("Failed to initialise license service", e);
}
catch (IllegalAccessException e)
{
throw new AlfrescoRuntimeException("Failed to initialise license service", e);
}
}
/**
* Dummy License Service
*/
private class NOOPLicenseService implements LicenseService
{
/* (non-Javadoc)
* @see org.alfresco.service.license.LicenseService#install()
*/
public void installLicense() throws LicenseException
{
}
/* (non-Javadoc)
* @see org.alfresco.service.license.LicenseService#verify()
*/
public void verifyLicense() throws LicenseException
{
}
/* (non-Javadoc)
* @see org.alfresco.service.license.LicenseService#getLicense()
*/
public LicenseDescriptor getLicense() throws LicenseException
{
return null;
}
}
/** /**
* Unknown descriptor * Unknown descriptor
* *

View File

@@ -16,10 +16,12 @@
*/ */
package org.alfresco.repo.descriptor; package org.alfresco.repo.descriptor;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.alfresco.service.descriptor.Descriptor; import org.alfresco.service.descriptor.Descriptor;
import org.alfresco.service.descriptor.DescriptorService; import org.alfresco.service.descriptor.DescriptorService;
import org.alfresco.service.license.LicenseDescriptor;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
@@ -79,6 +81,27 @@ public class DescriptorStartupLog implements ApplicationListener
logger.warn(String.format("Alfresco JVM - WARNING - maximum heap size %.3fMB is less than recommended 512MB", maxHeapMB)); logger.warn(String.format("Alfresco JVM - WARNING - maximum heap size %.3fMB is less than recommended 512MB", maxHeapMB));
} }
} }
// Log License Descriptors (if applicable)
LicenseDescriptor license = descriptorService.getLicenseDescriptor();
if (license != null && logger.isInfoEnabled())
{
String subject = license.getSubject();
String msg = "Alfresco license: " + subject;
Date validUntil = license.getValidUntil();
if (validUntil != null)
{
Integer days = license.getDays();
Integer remainingDays = license.getRemainingDays();
msg += " limited to " + days + " days expiring " + validUntil + " (" + remainingDays + " days remaining)";
}
else
{
msg += " (does not expire)";
}
logger.info(msg);
}
// Log Repository Descriptors // Log Repository Descriptors
if (logger.isInfoEnabled()) if (logger.isInfoEnabled())
@@ -90,16 +113,8 @@ public class DescriptorStartupLog implements ApplicationListener
int serverSchemaVersion = serverDescriptor.getSchema(); int serverSchemaVersion = serverDescriptor.getSchema();
String installedRepoVersion = installedRepoDescriptor.getVersion(); String installedRepoVersion = installedRepoDescriptor.getVersion();
int installedSchemaVersion = installedRepoDescriptor.getSchema(); int installedSchemaVersion = installedRepoDescriptor.getSchema();
logger.info( logger.info(String.format("Alfresco started (%s): Current version %s schema %d - Installed version %s schema %d",
String.format( serverEdition, serverVersion, serverSchemaVersion, installedRepoVersion, installedSchemaVersion));
"Alfresco started (%s): " +
"Current version %s schema %d - " +
"Installed version %s schema %d",
serverEdition,
serverVersion,
serverSchemaVersion,
installedRepoVersion,
installedSchemaVersion));
} }
} }
} }

View File

@@ -72,6 +72,7 @@ public class ImporterBootstrap implements ApplicationListener
// Dependencies // Dependencies
private boolean allowWrite = true; private boolean allowWrite = true;
private boolean useExistingStore = false;
private TransactionService transactionService; private TransactionService transactionService;
private NamespaceService namespaceService; private NamespaceService namespaceService;
private NodeService nodeService; private NodeService nodeService;
@@ -94,6 +95,18 @@ public class ImporterBootstrap implements ApplicationListener
this.allowWrite = write; this.allowWrite = write;
} }
/**
* Set whether the importer bootstrap should only perform an import if the store
* being referenced doesn't already exist.
*
* @param useExistingStore true to allow imports into an existing store,
* otherwise false (default) to only import if the store doesn't exist.
*/
public void setUseExistingStore(boolean useExistingStore)
{
this.useExistingStore = useExistingStore;
}
/** /**
* Sets the Transaction Service * Sets the Transaction Service
* *
@@ -305,11 +318,13 @@ public class ImporterBootstrap implements ApplicationListener
} }
else else
{ {
// create the store // create the store if necessary
storeRef = nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier()); if (!nodeService.exists(storeRef))
{
if (logger.isDebugEnabled()) storeRef = nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
logger.debug("Created store: " + storeRef); if (logger.isDebugEnabled())
logger.debug("Created store: " + storeRef);
}
// bootstrap the store contents // bootstrap the store contents
if (bootstrapViews != null) if (bootstrapViews != null)
@@ -538,12 +553,16 @@ public class ImporterBootstrap implements ApplicationListener
*/ */
private boolean performBootstrap() private boolean performBootstrap()
{ {
if (nodeService.exists(storeRef)) if (useExistingStore)
{
// it doesn't matter if the store exists or not
return true;
}
else if (nodeService.exists(storeRef))
{ {
return false; return false;
} }
else if (mustNotExistStoreUrls != null)
if (mustNotExistStoreUrls != null)
{ {
for (String storeUrl : mustNotExistStoreUrls) for (String storeUrl : mustNotExistStoreUrls)
{ {

View File

@@ -115,11 +115,15 @@ public class RulesAspect
this.ruleService.disableRules(nodeRef); this.ruleService.disableRules(nodeRef);
try try
{ {
this.nodeService.createNode( int count = this.nodeService.getChildAssocs(nodeRef, RuleModel.ASSOC_RULE_FOLDER, RuleModel.ASSOC_RULE_FOLDER).size();
nodeRef, if (count == 0)
RuleModel.ASSOC_RULE_FOLDER, {
RuleModel.ASSOC_RULE_FOLDER, this.nodeService.createNode(
ContentModel.TYPE_SYSTEM_FOLDER); nodeRef,
RuleModel.ASSOC_RULE_FOLDER,
RuleModel.ASSOC_RULE_FOLDER,
ContentModel.TYPE_SYSTEM_FOLDER);
}
} }
finally finally
{ {

View File

@@ -108,29 +108,17 @@ public class LuceneAnalyser extends Analyzer
{ {
analyser = new WhitespaceAnalyzer(); analyser = new WhitespaceAnalyzer();
} }
else if (fieldName.equals("TEXT"))
{
DataTypeDefinition dataType = dictionaryService.getDataType(DataTypeDefinition.TEXT);
analyser = loadAnalyzer(dataType);
}
else if (fieldName.startsWith("@")) else if (fieldName.startsWith("@"))
{ {
QName propertyQName = QName.createQName(fieldName.substring(1)); QName propertyQName = QName.createQName(fieldName.substring(1));
PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName); PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName);
DataTypeDefinition dataType = (propertyDef == null) ? dictionaryService.getDataType(DataTypeDefinition.TEXT) : propertyDef.getDataType(); DataTypeDefinition dataType = (propertyDef == null) ? dictionaryService.getDataType(DataTypeDefinition.TEXT) : propertyDef.getDataType();
String analyserClassName = dataType.getAnalyserClassName(); analyser = loadAnalyzer(dataType);
try
{
Class<?> clazz = Class.forName(analyserClassName);
analyser = (Analyzer)clazz.newInstance();
}
catch (ClassNotFoundException e)
{
throw new RuntimeException("Unable to load analyser for property " + fieldName.substring(1) + " of type " + dataType.getName() + " using " + analyserClassName);
}
catch (InstantiationException e)
{
throw new RuntimeException("Unable to load analyser for property " + fieldName.substring(1) + " of type " + dataType.getName() + " using " + analyserClassName);
}
catch (IllegalAccessException e)
{
throw new RuntimeException("Unable to load analyser for property " + fieldName.substring(1) + " of type " + dataType.getName() + " using " + analyserClassName);
}
} }
else else
{ {
@@ -139,4 +127,28 @@ public class LuceneAnalyser extends Analyzer
analysers.put(fieldName, analyser); analysers.put(fieldName, analyser);
return analyser; return analyser;
} }
private Analyzer loadAnalyzer(DataTypeDefinition dataType)
{
String analyserClassName = dataType.getAnalyserClassName();
try
{
Class<?> clazz = Class.forName(analyserClassName);
Analyzer analyser = (Analyzer)clazz.newInstance();
return analyser;
}
catch (ClassNotFoundException e)
{
throw new RuntimeException("Unable to load analyser for property of type " + dataType.getName() + " using " + analyserClassName);
}
catch (InstantiationException e)
{
throw new RuntimeException("Unable to load analyser for property of type " + dataType.getName() + " using " + analyserClassName);
}
catch (IllegalAccessException e)
{
throw new RuntimeException("Unable to load analyser for property of type " + dataType.getName() + " using " + analyserClassName);
}
}
} }

View File

@@ -80,16 +80,6 @@ public class DefaultMutableAuthenticationDao implements MutableAuthenticationDao
return true; return true;
} }
/**
* Get the store ref where user objects are persisted.
*
* @return
*/
public StoreRef getUserStoreRef()
{
throw new AlfrescoRuntimeException("Not implemented");
}
/** /**
* Enable/disable a user. * Enable/disable a user.
* *

View File

@@ -21,8 +21,6 @@ import java.util.Date;
import net.sf.acegisecurity.providers.dao.AuthenticationDao; import net.sf.acegisecurity.providers.dao.AuthenticationDao;
import net.sf.acegisecurity.providers.dao.SaltSource; import net.sf.acegisecurity.providers.dao.SaltSource;
import org.alfresco.service.cmr.repository.StoreRef;
/** /**
* A service provider interface to provide both acegi integration via AuthenticationDao and SaltSource * A service provider interface to provide both acegi integration via AuthenticationDao and SaltSource
* and mutability support for user definitions. * and mutability support for user definitions.
@@ -65,14 +63,6 @@ public interface MutableAuthenticationDao extends AuthenticationDao, SaltSource
*/ */
public boolean userExists(String userName); public boolean userExists(String userName);
/**
* Get the store ref where user objects are persisted.
*
* @return
*/
public StoreRef getUserStoreRef();
/** /**
* Enable/disable a user. * Enable/disable a user.
* *

View File

@@ -29,16 +29,14 @@ import net.sf.acegisecurity.providers.dao.User;
import net.sf.acegisecurity.providers.dao.UsernameNotFoundException; import net.sf.acegisecurity.providers.dao.UsernameNotFoundException;
import net.sf.acegisecurity.providers.encoding.PasswordEncoder; import net.sf.acegisecurity.providers.encoding.PasswordEncoder;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.search.QueryParameterDefImpl;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.search.QueryParameterDefinition;
import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow; import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.cmr.search.SearchParameters; import org.alfresco.service.cmr.search.SearchParameters;
@@ -50,10 +48,7 @@ import org.springframework.dao.DataAccessException;
public class RepositoryAuthenticationDao implements MutableAuthenticationDao public class RepositoryAuthenticationDao implements MutableAuthenticationDao
{ {
private static final StoreRef STOREREF_USERS = new StoreRef("user", "alfrescoUserStore");
private static final String SYSTEM_FOLDER = "/sys:system";
private static final String PEOPLE_FOLDER = SYSTEM_FOLDER + "/sys:people";
private NodeService nodeService; private NodeService nodeService;
@@ -65,8 +60,6 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
private PasswordEncoder passwordEncoder; private PasswordEncoder passwordEncoder;
private StoreRef userStoreRef;
private boolean userNamesAreCaseSensitive; private boolean userNamesAreCaseSensitive;
public boolean getUserNamesAreCaseSensitive() public boolean getUserNamesAreCaseSensitive()
@@ -132,7 +125,7 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
SearchParameters sp = new SearchParameters(); SearchParameters sp = new SearchParameters();
sp.setLanguage(SearchService.LANGUAGE_LUCENE); sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery("@usr\\:username:" + userName); sp.setQuery("@usr\\:username:" + userName);
sp.addStore(getUserStoreRef()); sp.addStore(STOREREF_USERS);
sp.excludeDataInTheCurrentTransaction(false); sp.excludeDataInTheCurrentTransaction(false);
ResultSet rs = null; ResultSet rs = null;
@@ -175,7 +168,7 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
{ {
throw new AuthenticationException("User already exists: " + userName); throw new AuthenticationException("User already exists: " + userName);
} }
NodeRef typesNode = getOrCreateTypeLocation(); NodeRef typesNode = getUserFolderLocation();
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(ContentModel.PROP_USER_USERNAME, userName); properties.put(ContentModel.PROP_USER_USERNAME, userName);
String salt = null; // GUID.generate(); String salt = null; // GUID.generate();
@@ -185,41 +178,47 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
properties.put(ContentModel.PROP_CREDENTIALS_EXPIRE, Boolean.valueOf(false)); properties.put(ContentModel.PROP_CREDENTIALS_EXPIRE, Boolean.valueOf(false));
properties.put(ContentModel.PROP_ENABLED, Boolean.valueOf(true)); properties.put(ContentModel.PROP_ENABLED, Boolean.valueOf(true));
properties.put(ContentModel.PROP_ACCOUNT_LOCKED, Boolean.valueOf(false)); properties.put(ContentModel.PROP_ACCOUNT_LOCKED, Boolean.valueOf(false));
nodeService.createNode(typesNode, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_USER, ContentModel.TYPE_USER, nodeService.createNode(
typesNode,
ContentModel.ASSOC_CHILDREN,
ContentModel.TYPE_USER,
ContentModel.TYPE_USER,
properties); properties);
} }
private NodeRef getOrCreateTypeLocation() private NodeRef getUserFolderLocation()
{ {
NodeRef rootNode = nodeService.getRootNode(getUserStoreRef()); QName qnameAssocSystem = QName.createQName("sys", "system", namespacePrefixResolver);
List<ChildAssociationRef> results = nodeService.getChildAssocs(rootNode, RegexQNamePattern.MATCH_ALL, QName QName qnameAssocUsers = QName.createQName("sys", "people", namespacePrefixResolver); // see AR-527
.createQName("sys", "system", namespacePrefixResolver)); NodeRef rootNode = nodeService.getRootNode(STOREREF_USERS);
NodeRef sysNode = null; List<ChildAssociationRef> results = nodeService.getChildAssocs(
rootNode,
RegexQNamePattern.MATCH_ALL,
qnameAssocSystem);
NodeRef sysNodeRef = null;
if (results.size() == 0) if (results.size() == 0)
{ {
sysNode = nodeService.createNode(rootNode, ContentModel.ASSOC_CHILDREN, throw new AlfrescoRuntimeException("Required authority system folder path not found: " + qnameAssocSystem);
QName.createQName("sys", "system", namespacePrefixResolver), ContentModel.TYPE_CONTAINER)
.getChildRef();
} }
else else
{ {
sysNode = results.get(0).getChildRef(); sysNodeRef = results.get(0).getChildRef();
} }
results = nodeService.getChildAssocs(sysNode, RegexQNamePattern.MATCH_ALL, QName.createQName("sys", "people", results = nodeService.getChildAssocs(
namespacePrefixResolver)); sysNodeRef,
NodeRef typesNode = null; RegexQNamePattern.MATCH_ALL,
qnameAssocUsers);
NodeRef userNodeRef = null;
if (results.size() == 0) if (results.size() == 0)
{ {
typesNode = nodeService.createNode(sysNode, ContentModel.ASSOC_CHILDREN, throw new AlfrescoRuntimeException("Required user folder path not found: " + qnameAssocUsers);
QName.createQName("sys", "people", namespacePrefixResolver), ContentModel.TYPE_CONTAINER)
.getChildRef();
} }
else else
{ {
typesNode = results.get(0).getChildRef(); userNodeRef = results.get(0).getChildRef();
} }
return typesNode; return userNodeRef;
} }
public void updateUser(String userName, char[] rawPassword) throws AuthenticationException public void updateUser(String userName, char[] rawPassword) throws AuthenticationException
@@ -248,20 +247,6 @@ public class RepositoryAuthenticationDao implements MutableAuthenticationDao
nodeService.deleteNode(userRef); nodeService.deleteNode(userRef);
} }
public synchronized StoreRef getUserStoreRef()
{
if (userStoreRef == null)
{
userStoreRef = new StoreRef("user", "alfrescoUserStore");
}
if (!nodeService.exists(userStoreRef))
{
nodeService.createStore(userStoreRef.getProtocol(), userStoreRef.getIdentifier());
}
return userStoreRef;
}
public Object getSalt(UserDetails userDetails) public Object getSalt(UserDetails userDetails)
{ {
// NodeRef userRef = getUserOrNull(userDetails.getUsername()); // NodeRef userRef = getUserOrNull(userDetails.getUsername());

View File

@@ -26,7 +26,7 @@ import org.alfresco.service.namespace.QName;
public class PermissionModelTest extends AbstractPermissionTest public class PermissionModelTest extends AbstractPermissionTest
{ {
public PermissionModelTest() public PermissionModelTest()
{ {
super(); super();
@@ -40,6 +40,30 @@ public class PermissionModelTest extends AbstractPermissionTest
assertEquals(5, grantees.size()); assertEquals(5, grantees.size());
} }
public void testIncludePermissionGroups2()
{
Set<PermissionReference> grantees = permissionModelDAO.getGranteePermissions(new SimplePermissionReference(QName.createQName("cm", "cmobject",
namespacePrefixResolver), "Contributor"));
assertEquals(11, grantees.size());
}
public void testIncludePermissionGroups3()
{
Set<PermissionReference> grantees = permissionModelDAO.getGranteePermissions(new SimplePermissionReference(QName.createQName("cm", "cmobject",
namespacePrefixResolver), "Editor"));
assertEquals(11, grantees.size());
}
public void testIncludePermissionGroups4()
{
Set<PermissionReference> grantees = permissionModelDAO.getGranteePermissions(new SimplePermissionReference(QName.createQName("cm", "cmobject",
namespacePrefixResolver), "Collaborator"));
assertEquals(16, grantees.size());
}
public void testGetGrantingPermissions() public void testGetGrantingPermissions()
{ {
Set<PermissionReference> granters = permissionModelDAO.getGrantingPermissions(new SimplePermissionReference(QName.createQName("sys", "base", Set<PermissionReference> granters = permissionModelDAO.getGrantingPermissions(new SimplePermissionReference(QName.createQName("sys", "base",

View File

@@ -25,9 +25,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.permissions.PermissionServiceSPI; import org.alfresco.repo.security.permissions.PermissionServiceSPI;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
@@ -41,7 +41,6 @@ import org.alfresco.service.cmr.security.NoSuchPersonException;
import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.NamespacePrefixResolver; import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
public class PersonServiceImpl implements PersonService public class PersonServiceImpl implements PersonService
{ {
@@ -148,8 +147,9 @@ public class PersonServiceImpl implements PersonService
NodeRef nodeRef = row.getNodeRef(); NodeRef nodeRef = row.getNodeRef();
if (nodeService.exists(nodeRef)) if (nodeService.exists(nodeRef))
{ {
String realUserName = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty( String realUserName = DefaultTypeConverter.INSTANCE.convert(
nodeRef, ContentModel.PROP_USERNAME)); String.class,
nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME));
realUserName = userNamesAreCaseSensitive ? realUserName : realUserName.toLowerCase(); realUserName = userNamesAreCaseSensitive ? realUserName : realUserName.toLowerCase();
if (realUserName.equals(userName)) if (realUserName.equals(userName))
{ {
@@ -235,47 +235,26 @@ public class PersonServiceImpl implements PersonService
.get(ContentModel.PROP_USERNAME)); .get(ContentModel.PROP_USERNAME));
String userName = userNamesAreCaseSensitive ? caseSensitiveUserName : caseSensitiveUserName.toLowerCase(); String userName = userNamesAreCaseSensitive ? caseSensitiveUserName : caseSensitiveUserName.toLowerCase();
properties.put(ContentModel.PROP_USERNAME, userName); properties.put(ContentModel.PROP_USERNAME, userName);
return nodeService.createNode(getPeopleContainer(), ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_PERSON, return nodeService.createNode(
ContentModel.TYPE_PERSON, properties).getChildRef(); getPeopleContainer(),
ContentModel.ASSOC_CHILDREN,
ContentModel.TYPE_PERSON,
ContentModel.TYPE_PERSON,
properties).getChildRef();
} }
public NodeRef getPeopleContainer() public NodeRef getPeopleContainer()
{ {
NodeRef rootNodeRef = nodeService.getRootNode(storeRef); NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
List<NodeRef> results = searchService.selectNodes(rootNodeRef, PEOPLE_FOLDER, null, namespacePrefixResolver, List<NodeRef> results = searchService.selectNodes(
rootNodeRef,
PEOPLE_FOLDER,
null,
namespacePrefixResolver,
false); false);
NodeRef typesNode = null;
if (results.size() == 0) if (results.size() == 0)
{ {
throw new AlfrescoRuntimeException("Required people system path not found: " + PEOPLE_FOLDER);
List<ChildAssociationRef> result = nodeService.getChildAssocs(rootNodeRef, RegexQNamePattern.MATCH_ALL,
QName.createQName("sys", "system", namespacePrefixResolver));
NodeRef sysNode = null;
if (result.size() == 0)
{
sysNode = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
QName.createQName("sys", "system", namespacePrefixResolver), ContentModel.TYPE_CONTAINER)
.getChildRef();
}
else
{
sysNode = result.get(0).getChildRef();
}
result = nodeService.getChildAssocs(sysNode, RegexQNamePattern.MATCH_ALL, QName.createQName("sys",
"people", namespacePrefixResolver));
if (result.size() == 0)
{
typesNode = nodeService.createNode(sysNode, ContentModel.ASSOC_CHILDREN,
QName.createQName("sys", "people", namespacePrefixResolver), ContentModel.TYPE_CONTAINER)
.getChildRef();
return typesNode;
}
else
{
return result.get(0).getChildRef();
}
} }
else else
{ {

View File

@@ -27,21 +27,20 @@ public class PatchException extends AlfrescoRuntimeException
{ {
private static final long serialVersionUID = 7022368915143884315L; private static final long serialVersionUID = 7022368915143884315L;
private String report;
/** /**
* @param report the patch failure report * @param msgId the patch failure message ID
*/ */
public PatchException(String report) public PatchException(String msgId)
{ {
super(report); super(msgId);
} }
/** /**
* @return Returns the patch failure report * @param msgId the patch failure message ID
* @param args variable number of message arguments
*/ */
public String getReport() public PatchException(String msgId, Object ... args)
{ {
return report; super(msgId, args);
} }
} }

View File

@@ -61,6 +61,14 @@ public interface FileFolderService
* Searches for all files and folders with the matching name pattern, * Searches for all files and folders with the matching name pattern,
* using wildcard characters <b>*</b> and <b>?</b>. * using wildcard characters <b>*</b> and <b>?</b>.
* *
* @param contextNodeRef the context of the search. This node will never be returned
* as part of the search results.
* @param namePattern the name of the file or folder to search for, or a
* {@link org.alfresco.util.SearchLanguageConversion#DEF_LUCENE wildcard} pattern
* to search for.
* @param includeSubFolders true to search the entire hierarchy below the search context
* @return Returns a list of file or folder matches
*
* @see #search(NodeRef, String, boolean, boolean, boolean) * @see #search(NodeRef, String, boolean, boolean, boolean)
*/ */
public List<FileInfo> search( public List<FileInfo> search(

View File

@@ -16,6 +16,8 @@
*/ */
package org.alfresco.service.descriptor; package org.alfresco.service.descriptor;
import org.alfresco.service.license.LicenseDescriptor;
/** /**
* Service for retrieving meta-data about Alfresco stack. * Service for retrieving meta-data about Alfresco stack.
@@ -40,4 +42,12 @@ public interface DescriptorService
* @return repository descriptor * @return repository descriptor
*/ */
public Descriptor getInstalledRepositoryDescriptor(); public Descriptor getInstalledRepositoryDescriptor();
/**
* Gets the License Service
*
* @return the license service
*/
public LicenseDescriptor getLicenseDescriptor();
} }

View File

@@ -0,0 +1,80 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.license;
import java.security.Principal;
import java.util.Date;
/**
* Provides access to License information.
*
* @author davidc
*/
public interface LicenseDescriptor
{
/**
* Gets the date license was issued
*
* @return issue date
*/
public Date getIssued();
/**
* Gets the date license is valid till
*
* @return valid until date (or null, if no time limit)
*/
public Date getValidUntil();
/**
* Gets the length (in days) of license validity
*
* @return length in days of license validity (or null, if no time limit)
*/
public Integer getDays();
/**
* Ges the number of remaining days left on license
*
* @return remaining days (or null, if no time limit)
*/
public Integer getRemainingDays();
/**
* Gets the subject of the license
*
* @return the subject
*/
public String getSubject();
/**
* Gets the holder of the license
*
* @return the holder
*/
public Principal getHolder();
/**
* Gets the issuer of the license
*
* @return the issuer
*/
public Principal getIssuer();
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.license;
/**
* Base Exception of License Exceptions.
*
* @author David Caruana
*/
public class LicenseException extends RuntimeException
{
private static final long serialVersionUID = -6463994144095426247L;
public LicenseException(String msg)
{
super(msg);
}
public LicenseException(String msg, Throwable cause)
{
super(msg, cause);
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.service.license;
/**
* Contract for managing licenses
*
* @author davidc
*/
public interface LicenseService
{
/**
* Verify License
*
* @throws LicenseException
*/
public void verifyLicense() throws LicenseException;
/**
* Get description of installed license
*
* @return license descriptor (or null, if one is not installed)
* @throws LicenseException
*/
public LicenseDescriptor getLicense() throws LicenseException;
}

View File

@@ -49,6 +49,16 @@ public class SearchLanguageConversion
* Lucene syntax summary: {@link QueryParser#escape(String) Lucene Query Parser} * Lucene syntax summary: {@link QueryParser#escape(String) Lucene Query Parser}
*/ */
public static LanguageDefinition DEF_LUCENE = new LuceneLanguageDef(); public static LanguageDefinition DEF_LUCENE = new LuceneLanguageDef();
/**
* CIFS name patch query language summary:
* <ul>
* <li>Escape: \ (but not used)</li>
* <li>Single char search: ?</li>
* <li>Multiple char search: *</li>
* <li>Reserved: "*\<>?/:|£%&+;</li>
* </ul>
*/
public static LanguageDefinition DEF_CIFS = new SimpleLanguageDef('\\', "*", "?", "\"*\\<>?/:|£%&+;");
/** /**
* Escape a string according to the <b>XPath</b> like function syntax. * Escape a string according to the <b>XPath</b> like function syntax.
@@ -128,6 +138,18 @@ public class SearchLanguageConversion
return convert(DEF_XPATH_LIKE, DEF_LUCENE, xpathLikeClause); return convert(DEF_XPATH_LIKE, DEF_LUCENE, xpathLikeClause);
} }
/**
* Convert a <b>CIFS</b> name path into the equivalent <b>Lucene</b> query.
*
* @param cifsNamePath the CIFS named path
* @return Returns a valid <b>Lucene</b> expression that is equivalent to the
* given CIFS name path
*/
public static String convertCifsToLucene(String cifsNamePath)
{
return convert(DEF_CIFS, DEF_LUCENE, cifsNamePath);
}
public static String convert(LanguageDefinition from, LanguageDefinition to, String query) public static String convert(LanguageDefinition from, LanguageDefinition to, String query)
{ {
char[] chars = query.toCharArray(); char[] chars = query.toCharArray();