mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Create "user Homes" folder in bootstrap and patch existing
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4791 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,123 +1,136 @@
|
|||||||
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
|
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
|
||||||
xmlns:cm="http://www.alfresco.org/model/content/1.0"
|
xmlns:cm="http://www.alfresco.org/model/content/1.0"
|
||||||
xmlns:app="http://www.alfresco.org/model/application/1.0">
|
xmlns:app="http://www.alfresco.org/model/application/1.0">
|
||||||
|
|
||||||
<!-- NOTE: all replaced properties referenced from repository.properties file must also be
|
<!-- NOTE: all replaced properties referenced from repository.properties file must also be
|
||||||
mapped in the bootstrap-context.xml spacesBootstrap/configuration section -->
|
|
||||||
<cm:folder view:childName="${spaces.company_home.childname}">
|
mapped in the bootstrap-context.xml spacesBootstrap/configuration section -->
|
||||||
<view:acl view:inherit="false">
|
<cm:folder view:childName="${spaces.company_home.childname}">
|
||||||
<view:ace view:access="ALLOWED">
|
<view:acl view:inherit="false">
|
||||||
<view:authority>GROUP_EVERYONE</view:authority>
|
<view:ace view:access="ALLOWED">
|
||||||
<view:permission>Consumer</view:permission>
|
<view:authority>GROUP_EVERYONE</view:authority>
|
||||||
</view:ace>
|
<view:permission>Consumer</view:permission>
|
||||||
</view:acl>
|
</view:ace>
|
||||||
<app:uifacets />
|
</view:acl>
|
||||||
<cm:name>${spaces.company_home.name}</cm:name>
|
<app:uifacets/>
|
||||||
<app:icon>space-icon-default</app:icon>
|
<cm:name>${spaces.company_home.name}</cm:name>
|
||||||
<cm:title>${spaces.company_home.name}</cm:title>
|
<app:icon>space-icon-default</app:icon>
|
||||||
<cm:description>${spaces.company_home.description}</cm:description>
|
<cm:title>${spaces.company_home.name}</cm:title>
|
||||||
<cm:contains>
|
<cm:description>${spaces.company_home.description}</cm:description>
|
||||||
<cm:folder view:childName="${spaces.dictionary.childname}">
|
<cm:contains>
|
||||||
<app:uifacets />
|
<cm:folder view:childName="${spaces.dictionary.childname}">
|
||||||
<cm:name>${spaces.dictionary.name}</cm:name>
|
<app:uifacets/>
|
||||||
<app:icon>space-icon-default</app:icon>
|
<cm:name>${spaces.dictionary.name}</cm:name>
|
||||||
<cm:title>${spaces.dictionary.name}</cm:title>
|
<app:icon>space-icon-default</app:icon>
|
||||||
<cm:description>${spaces.dictionary.description}</cm:description>
|
<cm:title>${spaces.dictionary.name}</cm:title>
|
||||||
<cm:contains>
|
<cm:description>${spaces.dictionary.description}</cm:description>
|
||||||
<cm:folder view:childName="${spaces.templates.childname}">
|
<cm:contains>
|
||||||
<app:uifacets />
|
<cm:folder view:childName="${spaces.templates.childname}">
|
||||||
<cm:name>${spaces.templates.name}</cm:name>
|
<app:uifacets/>
|
||||||
<app:icon>space-icon-default</app:icon>
|
<cm:name>${spaces.templates.name}</cm:name>
|
||||||
<cm:title>${spaces.templates.name}</cm:title>
|
<app:icon>space-icon-default</app:icon>
|
||||||
<cm:description>${spaces.templates.description}</cm:description>
|
<cm:title>${spaces.templates.name}</cm:title>
|
||||||
</cm:folder>
|
<cm:description>${spaces.templates.description}</cm:description>
|
||||||
<cm:folder view:childName="${spaces.templates.content.childname}">
|
</cm:folder>
|
||||||
<app:uifacets />
|
<cm:folder
|
||||||
<cm:name>${spaces.templates.content.name}</cm:name>
|
view:childName="${spaces.templates.content.childname}">
|
||||||
<app:icon>space-icon-default</app:icon>
|
<app:uifacets/>
|
||||||
<cm:title>${spaces.templates.content.name}</cm:title>
|
<cm:name>${spaces.templates.content.name}</cm:name>
|
||||||
<cm:description>${spaces.templates.content.description}</cm:description>
|
<app:icon>space-icon-default</app:icon>
|
||||||
</cm:folder>
|
<cm:title>${spaces.templates.content.name}</cm:title>
|
||||||
<cm:folder view:childName="${spaces.templates.email.childname}">
|
<cm:description>${spaces.templates.content.description}</cm:description>
|
||||||
<app:uifacets />
|
</cm:folder>
|
||||||
<cm:name>${spaces.templates.email.name}</cm:name>
|
<cm:folder
|
||||||
<app:icon>space-icon-default</app:icon>
|
view:childName="${spaces.templates.email.childname}">
|
||||||
<cm:title>${spaces.templates.email.name}</cm:title>
|
<app:uifacets/>
|
||||||
<cm:description>${spaces.templates.email.description}</cm:description>
|
<cm:name>${spaces.templates.email.name}</cm:name>
|
||||||
</cm:folder>
|
<app:icon>space-icon-default</app:icon>
|
||||||
<cm:folder view:childName="${spaces.templates.rss.childname}">
|
<cm:title>${spaces.templates.email.name}</cm:title>
|
||||||
<view:acl>
|
<cm:description>${spaces.templates.email.description}</cm:description>
|
||||||
<view:ace view:access="ALLOWED">
|
</cm:folder>
|
||||||
<view:authority>guest</view:authority>
|
<cm:folder
|
||||||
<view:permission>Consumer</view:permission>
|
view:childName="${spaces.templates.rss.childname}">
|
||||||
</view:ace>
|
<view:acl>
|
||||||
</view:acl>
|
<view:ace view:access="ALLOWED">
|
||||||
<app:uifacets />
|
<view:authority>guest</view:authority>
|
||||||
<cm:name>${spaces.templates.rss.name}</cm:name>
|
<view:permission>Consumer</view:permission>
|
||||||
<app:icon>space-icon-default</app:icon>
|
</view:ace>
|
||||||
<cm:title>${spaces.templates.rss.name}</cm:title>
|
</view:acl>
|
||||||
<cm:description>${spaces.templates.rss.description}</cm:description>
|
<app:uifacets/>
|
||||||
</cm:folder>
|
<cm:name>${spaces.templates.rss.name}</cm:name>
|
||||||
<cm:folder view:childName="${spaces.savedsearches.childname}">
|
<app:icon>space-icon-default</app:icon>
|
||||||
<view:acl view:inherit="false">
|
<cm:title>${spaces.templates.rss.name}</cm:title>
|
||||||
<view:ace view:access="ALLOWED">
|
<cm:description>${spaces.templates.rss.description}</cm:description>
|
||||||
<view:authority>GROUP_EVERYONE</view:authority>
|
</cm:folder>
|
||||||
<view:permission>Contributor</view:permission>
|
<cm:folder
|
||||||
</view:ace>
|
view:childName="${spaces.savedsearches.childname}">
|
||||||
</view:acl>
|
<view:acl view:inherit="false">
|
||||||
<app:uifacets />
|
<view:ace view:access="ALLOWED">
|
||||||
<cm:name>${spaces.savedsearches.name}</cm:name>
|
<view:authority>GROUP_EVERYONE</view:authority>
|
||||||
<app:icon>space-icon-default</app:icon>
|
<view:permission>Contributor</view:permission>
|
||||||
<cm:title>${spaces.savedsearches.name}</cm:title>
|
</view:ace>
|
||||||
<cm:description>${spaces.savedsearches.description}</cm:description>
|
</view:acl>
|
||||||
</cm:folder>
|
<app:uifacets/>
|
||||||
<cm:folder view:childName="${spaces.scripts.childname}">
|
<cm:name>${spaces.savedsearches.name}</cm:name>
|
||||||
<app:uifacets />
|
<app:icon>space-icon-default</app:icon>
|
||||||
<cm:name>${spaces.scripts.name}</cm:name>
|
<cm:title>${spaces.savedsearches.name}</cm:title>
|
||||||
<app:icon>space-icon-default</app:icon>
|
<cm:description>${spaces.savedsearches.description}</cm:description>
|
||||||
<cm:title>${spaces.scripts.name}</cm:title>
|
</cm:folder>
|
||||||
<cm:description>${spaces.scripts.description}</cm:description>
|
<cm:folder view:childName="${spaces.scripts.childname}">
|
||||||
</cm:folder>
|
<app:uifacets/>
|
||||||
<cm:folder view:childName="${spaces.content_forms.childname}">
|
<cm:name>${spaces.scripts.name}</cm:name>
|
||||||
<app:uifacets />
|
<app:icon>space-icon-default</app:icon>
|
||||||
<cm:name>${spaces.content_forms.name}</cm:name>
|
<cm:title>${spaces.scripts.name}</cm:title>
|
||||||
<app:icon>space-icon-default</app:icon>
|
<cm:description>${spaces.scripts.description}</cm:description>
|
||||||
<cm:title>${spaces.content_forms.name}</cm:title>
|
</cm:folder>
|
||||||
<cm:description>${spaces.content_forms.description}</cm:description>
|
<cm:folder
|
||||||
</cm:folder>
|
view:childName="${spaces.content_forms.childname}">
|
||||||
</cm:contains>
|
<app:uifacets/>
|
||||||
</cm:folder>
|
<cm:name>${spaces.content_forms.name}</cm:name>
|
||||||
<cm:folder view:childName="${spaces.guest_home.childname}">
|
<app:icon>space-icon-default</app:icon>
|
||||||
<view:acl view:inherit="false">
|
<cm:title>${spaces.content_forms.name}</cm:title>
|
||||||
<view:ace view:access="ALLOWED">
|
<cm:description>${spaces.content_forms.description}</cm:description>
|
||||||
<view:authority>guest</view:authority>
|
</cm:folder>
|
||||||
<view:permission>Consumer</view:permission>
|
</cm:contains>
|
||||||
</view:ace>
|
</cm:folder>
|
||||||
<view:ace view:access="ALLOWED">
|
<cm:folder view:childName="${spaces.guest_home.childname}">
|
||||||
<view:authority>GROUP_EVERYONE</view:authority>
|
<view:acl view:inherit="false">
|
||||||
<view:permission>Consumer</view:permission>
|
<view:ace view:access="ALLOWED">
|
||||||
</view:ace>
|
<view:authority>guest</view:authority>
|
||||||
</view:acl>
|
<view:permission>Consumer</view:permission>
|
||||||
<app:uifacets />
|
</view:ace>
|
||||||
<cm:name>${spaces.guest_home.name}</cm:name>
|
<view:ace view:access="ALLOWED">
|
||||||
<app:icon>space-icon-default</app:icon>
|
<view:authority>GROUP_EVERYONE</view:authority>
|
||||||
<cm:title>${spaces.guest_home.name}</cm:title>
|
<view:permission>Consumer</view:permission>
|
||||||
<cm:description>${spaces.guest_home.description}</cm:description>
|
</view:ace>
|
||||||
</cm:folder>
|
</view:acl>
|
||||||
<cm:folder view:childName="${spaces.wcm.childname}">
|
<app:uifacets/>
|
||||||
<view:acl view:inherit="false">
|
<cm:name>${spaces.guest_home.name}</cm:name>
|
||||||
<view:ace view:access="ALLOWED">
|
<app:icon>space-icon-default</app:icon>
|
||||||
<view:authority>GROUP_EVERYONE</view:authority>
|
<cm:title>${spaces.guest_home.name}</cm:title>
|
||||||
<view:permission>Consumer</view:permission>
|
<cm:description>${spaces.guest_home.description}</cm:description>
|
||||||
</view:ace>
|
</cm:folder>
|
||||||
</view:acl>
|
<cm:folder view:childName="${spaces.user_homes.childname}">
|
||||||
<app:uifacets/>
|
<app:uifacets/>
|
||||||
<cm:name>${spaces.wcm.name}</cm:name>
|
<cm:name>${spaces.user_homes.name}</cm:name>
|
||||||
<app:icon>space-icon-default</app:icon>
|
<app:icon>space-icon-default</app:icon>
|
||||||
<cm:title>${spaces.wcm.name}</cm:title>
|
<cm:title>${spaces.user_homes.name}</cm:title>
|
||||||
<cm:description>${spaces.wcm.description}</cm:description>
|
<cm:description>${spaces.user_homes.description}</cm:description>
|
||||||
</cm:folder>
|
</cm:folder>
|
||||||
</cm:contains>
|
<cm:folder view:childName="${spaces.wcm.childname}">
|
||||||
</cm:folder>
|
<view:acl view:inherit="false">
|
||||||
|
<view:ace view:access="ALLOWED">
|
||||||
|
<view:authority>GROUP_EVERYONE</view:authority>
|
||||||
|
<view:permission>Consumer</view:permission>
|
||||||
|
</view:ace>
|
||||||
|
</view:acl>
|
||||||
|
<app:uifacets/>
|
||||||
|
<cm:name>${spaces.wcm.name}</cm:name>
|
||||||
|
<app:icon>space-icon-default</app:icon>
|
||||||
|
<cm:title>${spaces.wcm.name}</cm:title>
|
||||||
|
<cm:description>${spaces.wcm.description}</cm:description>
|
||||||
|
</cm:folder>
|
||||||
|
</cm:contains>
|
||||||
|
</cm:folder>
|
||||||
|
|
||||||
</view:view>
|
</view:view>
|
@@ -309,6 +309,7 @@
|
|||||||
<prop key="spaces.scripts.childname">${spaces.scripts.childname}</prop>
|
<prop key="spaces.scripts.childname">${spaces.scripts.childname}</prop>
|
||||||
<prop key="spaces.wcm.childname">${spaces.wcm.childname}</prop>
|
<prop key="spaces.wcm.childname">${spaces.wcm.childname}</prop>
|
||||||
<prop key="spaces.content_forms.childname">${spaces.content_forms.childname}</prop>
|
<prop key="spaces.content_forms.childname">${spaces.content_forms.childname}</prop>
|
||||||
|
<prop key="spaces.user_homes.childname">${spaces.user_homes.childname}</prop>
|
||||||
</props>
|
</props>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
@@ -32,3 +32,6 @@ spaces.wcm.description=Web Content Management Spaces
|
|||||||
|
|
||||||
spaces.content_forms.name=Web Forms
|
spaces.content_forms.name=Web Forms
|
||||||
spaces.content_forms.description=Web Content Forms
|
spaces.content_forms.description=Web Content Forms
|
||||||
|
|
||||||
|
spaces.user_homes.name=User Homes
|
||||||
|
spaces.user_homes.description=User Homes
|
||||||
|
@@ -111,3 +111,7 @@ patch.systemDescriptorContent.err.no_version_properties=The version.properties r
|
|||||||
patch.systemDescriptorContent.err.no_descriptor=The system descriptor could not be found.
|
patch.systemDescriptorContent.err.no_descriptor=The system descriptor could not be found.
|
||||||
|
|
||||||
patch.multilingualBootstrap.description=Bootstraps the node that will hold the multilingual containers.
|
patch.multilingualBootstrap.description=Bootstraps the node that will hold the multilingual containers.
|
||||||
|
|
||||||
|
patch.userHomesFolder.description=Ensures the existence of the 'User Homes' folder.
|
||||||
|
patch.userHomesFolder.result.exists=The user homes folder already exists: {0}
|
||||||
|
patch.userHomesFolder.result.created=The user homes folder was successfully created: {0}
|
||||||
|
@@ -538,4 +538,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="patch.userHomesFolder" class="org.alfresco.repo.admin.patch.impl.UserHomesFolderPatch" parent="basePatch" >
|
||||||
|
<property name="id"><value>patch.userHomesFolder</value></property>
|
||||||
|
<property name="description"><value>patch.userHomesFolder.description</value></property>
|
||||||
|
<property name="fixesFromSchema"><value>0</value></property>
|
||||||
|
<property name="fixesToSchema"><value>30</value></property>
|
||||||
|
<property name="targetSchema"><value>31</value></property>
|
||||||
|
<!-- helper beans for execution -->
|
||||||
|
<property name="messageSource">
|
||||||
|
<ref bean="bootstrapSpacesMessageSource" />
|
||||||
|
</property>
|
||||||
|
<property name="importerBootstrap">
|
||||||
|
<ref bean="spacesBootstrap" />
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@@ -114,6 +114,7 @@ spaces.savedsearches.childname=app:saved_searches
|
|||||||
spaces.scripts.childname=app:scripts
|
spaces.scripts.childname=app:scripts
|
||||||
spaces.wcm.childname=app:wcm
|
spaces.wcm.childname=app:wcm
|
||||||
spaces.content_forms.childname=app:wcm_forms
|
spaces.content_forms.childname=app:wcm_forms
|
||||||
|
spaces.user_homes.childname=app:user_homes
|
||||||
|
|
||||||
# Folders for storing people
|
# Folders for storing people
|
||||||
system.system_container.childname=sys:system
|
system.system_container.childname=sys:system
|
||||||
|
@@ -19,4 +19,4 @@ version.build=@build-number@
|
|||||||
|
|
||||||
# Schema number
|
# Schema number
|
||||||
|
|
||||||
version.schema=30
|
version.schema=31
|
||||||
|
@@ -0,0 +1,243 @@
|
|||||||
|
/*
|
||||||
|
* 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.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.alfresco.i18n.I18NUtil;
|
||||||
|
import org.alfresco.model.ApplicationModel;
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
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.ChildAssociationRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures that the <b>User Homes</b> folder is present beneath company home.
|
||||||
|
* It inherits permissions from company home.
|
||||||
|
* <p>
|
||||||
|
* This uses the bootstrap importer to get the paths to look for. If not present,
|
||||||
|
* the required structures are created.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @author Andy Hind
|
||||||
|
*/
|
||||||
|
public class UserHomesFolderPatch extends AbstractPatch
|
||||||
|
{
|
||||||
|
private static final String MSG_EXISTS = "patch.userHomesFolder.result.exists";
|
||||||
|
private static final String MSG_CREATED = "patch.userHomesFolder.result.created";
|
||||||
|
|
||||||
|
public static final String PROPERTY_COMPANY_HOME_CHILDNAME = "spaces.company_home.childname";
|
||||||
|
public static final String PROPERTY_USER_HOMES_FOLDER_CHILDNAME = "spaces.user_homes.childname";
|
||||||
|
private static final String PROPERTY_USER_HOMES_FOLDER_NAME = "spaces.user_homes.name";
|
||||||
|
private static final String PROPERTY_USER_HOMES_FOLDER_DESCRIPTION = "spaces.user_homes.description";
|
||||||
|
private static final String PROPERTY_ICON = "space-icon-default";
|
||||||
|
|
||||||
|
private ImporterBootstrap importerBootstrap;
|
||||||
|
private MessageSource messageSource;
|
||||||
|
|
||||||
|
protected NodeRef companyHomeNodeRef;
|
||||||
|
protected Properties configuration;
|
||||||
|
protected NodeRef userHomesFolderNodeRef;
|
||||||
|
|
||||||
|
public void setImporterBootstrap(ImporterBootstrap importerBootstrap)
|
||||||
|
{
|
||||||
|
this.importerBootstrap = importerBootstrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageSource(MessageSource messageSource)
|
||||||
|
{
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure that required common properties have been set
|
||||||
|
*/
|
||||||
|
protected void checkCommonProperties() throws Exception
|
||||||
|
{
|
||||||
|
if (importerBootstrap == null)
|
||||||
|
{
|
||||||
|
throw new PatchException("'importerBootstrap' property has not been set");
|
||||||
|
}
|
||||||
|
else if (namespaceService == null)
|
||||||
|
{
|
||||||
|
throw new PatchException("'namespaceService' property has not been set");
|
||||||
|
}
|
||||||
|
else if (searchService == null)
|
||||||
|
{
|
||||||
|
throw new PatchException("'searchService' property has not been set");
|
||||||
|
}
|
||||||
|
else if (nodeService == null)
|
||||||
|
{
|
||||||
|
throw new PatchException("'nodeService' property has not been set");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts pertinent references and properties that are common to execution
|
||||||
|
* of this and derived patches.
|
||||||
|
*/
|
||||||
|
protected void setUp() throws Exception
|
||||||
|
{
|
||||||
|
// get the node store that we must work against
|
||||||
|
StoreRef storeRef = importerBootstrap.getStoreRef();
|
||||||
|
if (storeRef == null)
|
||||||
|
{
|
||||||
|
throw new PatchException("Bootstrap store has not been set");
|
||||||
|
}
|
||||||
|
NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
|
||||||
|
|
||||||
|
this.configuration = importerBootstrap.getConfiguration();
|
||||||
|
// get the association names that form the path
|
||||||
|
String companyHomeChildName = configuration.getProperty(PROPERTY_COMPANY_HOME_CHILDNAME);
|
||||||
|
if (companyHomeChildName == null || companyHomeChildName.length() == 0)
|
||||||
|
{
|
||||||
|
throw new PatchException("Bootstrap property '" + PROPERTY_COMPANY_HOME_CHILDNAME + "' is not present");
|
||||||
|
}
|
||||||
|
|
||||||
|
String userHomesChildName = configuration.getProperty(PROPERTY_USER_HOMES_FOLDER_CHILDNAME);
|
||||||
|
if (userHomesChildName == null || userHomesChildName.length() == 0)
|
||||||
|
{
|
||||||
|
throw new PatchException("Bootstrap property '" + PROPERTY_USER_HOMES_FOLDER_CHILDNAME + "' is not present");
|
||||||
|
}
|
||||||
|
|
||||||
|
// build the search string to get the company home node
|
||||||
|
StringBuilder sb = new StringBuilder(512);
|
||||||
|
sb.append("/").append(companyHomeChildName);
|
||||||
|
String xpath = sb.toString();
|
||||||
|
// get the company home
|
||||||
|
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, xpath, null, namespaceService, false);
|
||||||
|
if (nodeRefs.size() == 0)
|
||||||
|
{
|
||||||
|
throw new PatchException("XPath didn't return any results: \n" +
|
||||||
|
" root: " + storeRootNodeRef + "\n" +
|
||||||
|
" xpath: " + xpath);
|
||||||
|
}
|
||||||
|
else if (nodeRefs.size() > 1)
|
||||||
|
{
|
||||||
|
throw new PatchException("XPath returned too many results: \n" +
|
||||||
|
" root: " + storeRootNodeRef + "\n" +
|
||||||
|
" xpath: " + xpath + "\n" +
|
||||||
|
" results: " + nodeRefs);
|
||||||
|
}
|
||||||
|
this.companyHomeNodeRef = nodeRefs.get(0);
|
||||||
|
|
||||||
|
// Now we have the optional part. Check for the existence of the user homes folder
|
||||||
|
xpath = userHomesChildName;
|
||||||
|
nodeRefs = searchService.selectNodes(companyHomeNodeRef, xpath, null, namespaceService, false);
|
||||||
|
if (nodeRefs.size() > 1)
|
||||||
|
{
|
||||||
|
throw new PatchException("XPath returned too many results: \n" +
|
||||||
|
" company home node: " + companyHomeNodeRef + "\n" +
|
||||||
|
" xpath: " + xpath + "\n" +
|
||||||
|
" results: " + nodeRefs);
|
||||||
|
}
|
||||||
|
else if (nodeRefs.size() == 0)
|
||||||
|
{
|
||||||
|
// the node does not exist
|
||||||
|
this.userHomesFolderNodeRef = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// we have the user homes folder noderef
|
||||||
|
this.userHomesFolderNodeRef = nodeRefs.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String applyInternal() throws Exception
|
||||||
|
{
|
||||||
|
// properties must be set
|
||||||
|
checkCommonProperties();
|
||||||
|
if (messageSource == null)
|
||||||
|
{
|
||||||
|
throw new PatchException("'messageSource' property has not been set");
|
||||||
|
}
|
||||||
|
|
||||||
|
// get useful values
|
||||||
|
setUp();
|
||||||
|
|
||||||
|
String msg = null;
|
||||||
|
if (userHomesFolderNodeRef == null)
|
||||||
|
{
|
||||||
|
// create it
|
||||||
|
createFolder();
|
||||||
|
msg = I18NUtil.getMessage(MSG_CREATED, userHomesFolderNodeRef);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// it already exists
|
||||||
|
msg = I18NUtil.getMessage(MSG_EXISTS, userHomesFolderNodeRef);
|
||||||
|
}
|
||||||
|
// done
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createFolder()
|
||||||
|
{
|
||||||
|
// get required properties
|
||||||
|
String userHomesChildName = configuration.getProperty(PROPERTY_USER_HOMES_FOLDER_CHILDNAME);
|
||||||
|
if (userHomesChildName == null)
|
||||||
|
{
|
||||||
|
throw new PatchException("Bootstrap property '" + PROPERTY_USER_HOMES_FOLDER_CHILDNAME + "' is not present");
|
||||||
|
}
|
||||||
|
|
||||||
|
String userHomesName = messageSource.getMessage(
|
||||||
|
PROPERTY_USER_HOMES_FOLDER_NAME,
|
||||||
|
null,
|
||||||
|
I18NUtil.getLocale());
|
||||||
|
if (userHomesName == null || userHomesName.length() == 0)
|
||||||
|
{
|
||||||
|
throw new PatchException("Bootstrap property '" + PROPERTY_USER_HOMES_FOLDER_NAME + "' is not present");
|
||||||
|
}
|
||||||
|
|
||||||
|
String userHomesDescription = messageSource.getMessage(
|
||||||
|
PROPERTY_USER_HOMES_FOLDER_DESCRIPTION,
|
||||||
|
null,
|
||||||
|
I18NUtil.getLocale());
|
||||||
|
if (userHomesDescription == null || userHomesDescription.length() == 0)
|
||||||
|
{
|
||||||
|
throw new PatchException("Bootstrap property '" + PROPERTY_USER_HOMES_FOLDER_DESCRIPTION + "' is not present");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(7);
|
||||||
|
properties.put(ContentModel.PROP_NAME, userHomesName);
|
||||||
|
properties.put(ContentModel.PROP_TITLE, userHomesName);
|
||||||
|
properties.put(ContentModel.PROP_DESCRIPTION, userHomesDescription);
|
||||||
|
properties.put(ApplicationModel.PROP_ICON, PROPERTY_ICON);
|
||||||
|
// create the node
|
||||||
|
ChildAssociationRef childAssocRef = nodeService.createNode(
|
||||||
|
companyHomeNodeRef,
|
||||||
|
ContentModel.ASSOC_CONTAINS,
|
||||||
|
QName.resolveToQName(namespaceService, userHomesChildName),
|
||||||
|
ContentModel.TYPE_FOLDER,
|
||||||
|
properties);
|
||||||
|
userHomesFolderNodeRef = childAssocRef.getChildRef();
|
||||||
|
// add the required aspects
|
||||||
|
nodeService.addAspect(userHomesFolderNodeRef, ApplicationModel.ASPECT_UIFACETS, null);
|
||||||
|
|
||||||
|
// done
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user