Fixes to guest permissions and patch

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2251 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2006-01-30 16:50:58 +00:00
parent 5ccf3681e9
commit 6bcc456fcd
3 changed files with 28 additions and 8 deletions

View File

@@ -8,7 +8,7 @@
<view:acl view:inherit="false"> <view:acl view:inherit="false">
<view:ace view:access="ALLOWED"> <view:ace view:access="ALLOWED">
<view:authority>GROUP_EVERYONE</view:authority> <view:authority>GROUP_EVERYONE</view:authority>
<view:permission>Read</view:permission> <view:permission>Guest</view:permission>
</view:ace> </view:ace>
</view:acl> </view:acl>
<app:uifacets /> <app:uifacets />
@@ -51,11 +51,11 @@
<view:acl view:inherit="false"> <view:acl view:inherit="false">
<view:ace view:access="ALLOWED"> <view:ace view:access="ALLOWED">
<view:authority>guest</view:authority> <view:authority>guest</view:authority>
<view:permission>Read</view:permission> <view:permission>Guest</view:permission>
</view:ace> </view:ace>
<view:ace view:access="ALLOWED"> <view:ace view:access="ALLOWED">
<view:authority>GROUP_EVERYONE</view:authority> <view:authority>GROUP_EVERYONE</view:authority>
<view:permission>Read</view:permission> <view:permission>Guest</view:permission>
</view:ace> </view:ace>
</view:acl> </view:acl>
<app:uifacets /> <app:uifacets />

View File

@@ -131,6 +131,9 @@
<property name="namespaceService"> <property name="namespaceService">
<ref bean="namespaceService" /> <ref bean="namespaceService" />
</property> </property>
<property name="messageSource">
<ref bean="guestMessageSource" />
</property>
</bean> </bean>
<bean id="patch.fixNodeSerializableValues" class="org.alfresco.repo.admin.patch.impl.NodePropertySerializablePatch" parent="basePatch" > <bean id="patch.fixNodeSerializableValues" class="org.alfresco.repo.admin.patch.impl.NodePropertySerializablePatch" parent="basePatch" >
<property name="id"><value>patch.fixNodeSerializableValues</value></property> <property name="id"><value>patch.fixNodeSerializableValues</value></property>
@@ -144,6 +147,14 @@
</property> </property>
</bean> </bean>
<bean id="guestMessageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>alfresco/messages/bootstrap-spaces</value>
</list>
</property>
</bean>
<!-- This component ensures that patches get applied on startup --> <!-- This component ensures that patches get applied on startup -->
<!-- The order is important here. All the self-registering patches must be defined before this bean --> <!-- The order is important here. All the self-registering patches must be defined before this bean -->
<bean id="patchExecuter" <bean id="patchExecuter"

View File

@@ -35,6 +35,8 @@ import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.security.PersonService;
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.springframework.context.MessageSource;
import org.springframework.context.support.ResourceBundleMessageSource;
/** /**
* Ensures that the <b>guest</b> user homespace exists.<br/> * Ensures that the <b>guest</b> user homespace exists.<br/>
@@ -68,6 +70,8 @@ public class GuestUserPatch extends AbstractPatch
private NamespaceService namespaceService; private NamespaceService namespaceService;
private String guestId = "guest"; private String guestId = "guest";
private MessageSource messageSource;
public GuestUserPatch() public GuestUserPatch()
{ {
@@ -108,6 +112,11 @@ public class GuestUserPatch extends AbstractPatch
{ {
this.searchService = searchService; this.searchService = searchService;
} }
public void setMessageSource(MessageSource messageSource)
{
this.messageSource = messageSource;
}
@Override @Override
protected String applyInternal() throws Exception protected String applyInternal() throws Exception
@@ -181,13 +190,13 @@ public class GuestUserPatch extends AbstractPatch
{ {
// create // create
String guestHomeName = configuration.getProperty(GUEST_HOME_NAME); String guestHomeName = messageSource.getMessage(GUEST_HOME_NAME, null, I18NUtil.getLocale());
if (guestHomeName == null || guestHomeName.length() == 0) if (guestHomeName == null || guestHomeName.length() == 0)
{ {
throw new PatchException("Bootstrap property '" + GUEST_HOME_NAME + "' is not present"); throw new PatchException("Bootstrap property '" + GUEST_HOME_NAME + "' is not present");
} }
String guestHomeDescription = configuration.getProperty(GUEST_HOME_DESCRIPTION); String guestHomeDescription = messageSource.getMessage(GUEST_HOME_DESCRIPTION, null, I18NUtil.getLocale());
if (guestHomeDescription == null || guestHomeDescription.length() == 0) if (guestHomeDescription == null || guestHomeDescription.length() == 0)
{ {
throw new PatchException("Bootstrap property '" + GUEST_HOME_DESCRIPTION + "' is not present"); throw new PatchException("Bootstrap property '" + GUEST_HOME_DESCRIPTION + "' is not present");
@@ -228,8 +237,8 @@ public class GuestUserPatch extends AbstractPatch
private void setGuestHomePermissions(NodeRef nodeRef) private void setGuestHomePermissions(NodeRef nodeRef)
{ {
permissionService.setInheritParentPermissions(nodeRef, false); permissionService.setInheritParentPermissions(nodeRef, false);
permissionService.setPermission(nodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); permissionService.setPermission(nodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.GUEST, true);
permissionService.setPermission(nodeRef, guestId, PermissionService.READ, true); permissionService.setPermission(nodeRef, guestId, PermissionService.GUEST, true);
} }
private NodeRef setCompanyHomeSpacePermissions(NodeRef storeRootNodeRef, String companyHomeChildName) private NodeRef setCompanyHomeSpacePermissions(NodeRef storeRootNodeRef, String companyHomeChildName)
@@ -251,7 +260,7 @@ public class GuestUserPatch extends AbstractPatch
permissionService.setInheritParentPermissions(companyHomeRef, false); permissionService.setInheritParentPermissions(companyHomeRef, false);
permissionService permissionService
.setPermission(companyHomeRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); .setPermission(companyHomeRef, PermissionService.ALL_AUTHORITIES, PermissionService.GUEST, true);
return companyHomeRef; return companyHomeRef;
} }