mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1107 (Mavenization of the RM build)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/UIAUTOMATION@59300 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.policy.ClassPolicy;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Interface containing records management policies
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public interface RecordsManagementPolicies
|
||||
{
|
||||
/** Policy names */
|
||||
public static final QName BEFORE_RM_ACTION_EXECUTION = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeRMActionExecution");
|
||||
public static final QName ON_RM_ACTION_EXECUTION = QName.createQName(NamespaceService.ALFRESCO_URI, "onRMActionExecution");
|
||||
public static final QName BEFORE_CREATE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeCreateReference");
|
||||
public static final QName ON_CREATE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateReference");
|
||||
public static final QName BEFORE_REMOVE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "beforeRemoveReference");
|
||||
public static final QName ON_REMOVE_REFERENCE = QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveReference");
|
||||
|
||||
/** Before records management action execution */
|
||||
public interface BeforeRMActionExecution extends ClassPolicy
|
||||
{
|
||||
public void beforeRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters);
|
||||
}
|
||||
|
||||
/** On records management action execution */
|
||||
public interface OnRMActionExecution extends ClassPolicy
|
||||
{
|
||||
public void onRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters);
|
||||
}
|
||||
|
||||
/** Before creation of reference */
|
||||
public interface BeforeCreateReference extends ClassPolicy
|
||||
{
|
||||
public void beforeCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference);
|
||||
}
|
||||
|
||||
/** On creation of reference */
|
||||
public interface OnCreateReference extends ClassPolicy
|
||||
{
|
||||
public void onCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference);
|
||||
}
|
||||
|
||||
/** Before removal of reference */
|
||||
public interface BeforeRemoveReference extends ClassPolicy
|
||||
{
|
||||
public void beforeRemoveReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference);
|
||||
}
|
||||
|
||||
/** On removal of reference */
|
||||
public interface OnRemoveReference extends ClassPolicy
|
||||
{
|
||||
public void onRemoveReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference);
|
||||
}
|
||||
}
|
@@ -1,191 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService;
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Records management service registry
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface RecordsManagementServiceRegistry extends ServiceRegistry
|
||||
{
|
||||
/** Service QName constants */
|
||||
static final QName RECORDS_MANAGEMENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementService");
|
||||
static final QName DISPOSITION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "DispositionService");
|
||||
static final QName RECORDS_MANAGEMENT_ADMIN_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementAdminService");
|
||||
static final QName RECORDS_MANAGEMENT_ACTION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementActionService");
|
||||
static final QName RECORDS_MANAGEMENT_EVENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementEventService");
|
||||
static final QName RECORDS_MANAGEMENT_AUDIT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementAuditService");
|
||||
static final QName CAPABILITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CapabilityService");
|
||||
static final QName RECORD_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordService");
|
||||
static final QName FREEZE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FreezeService");
|
||||
static final QName EXTENDED_SECURITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ExtendedSecurityService");
|
||||
static final QName FILE_PLAN_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanService");
|
||||
static final QName FILE_PLAN_ROLE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanRoleService");
|
||||
static final QName FILE_PLAN_PERMISSION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanPermissionService");
|
||||
static final QName FILE_PLAN_AUTHENTICATION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FilePlanAuthenticationService");
|
||||
static final QName IDENTIFIER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "recordsManagementIdentifierService");
|
||||
static final QName RECORD_FOLDER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordFolderService");
|
||||
static final QName TRANSFER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "TransferService");
|
||||
@Deprecated
|
||||
static final QName RECORDS_MANAGEMENT_SECURITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementSecurityService");
|
||||
|
||||
|
||||
/**
|
||||
* @return records management service
|
||||
*/
|
||||
@NotAuditable
|
||||
RecordsManagementService getRecordsManagementService();
|
||||
|
||||
/**
|
||||
* @return record service
|
||||
*/
|
||||
@NotAuditable
|
||||
RecordService getRecordService();
|
||||
|
||||
/**
|
||||
* @return disposition service
|
||||
*/
|
||||
@NotAuditable
|
||||
DispositionService getDispositionService();
|
||||
|
||||
/**
|
||||
* @return records management admin service
|
||||
*/
|
||||
@NotAuditable
|
||||
RecordsManagementAdminService getRecordsManagementAdminService();
|
||||
|
||||
/**
|
||||
* @return records management action service
|
||||
*/
|
||||
@NotAuditable
|
||||
RecordsManagementActionService getRecordsManagementActionService();
|
||||
|
||||
/**
|
||||
* @return records management event service
|
||||
*/
|
||||
@NotAuditable
|
||||
RecordsManagementEventService getRecordsManagementEventService();
|
||||
|
||||
/**
|
||||
* @return records management security service
|
||||
*
|
||||
* @deprecated As of release 2.1, replaced with {@link FilePlanRoleService}, {@link FilePlanPermissionService} and {@link ModelSecurityService}
|
||||
*/
|
||||
@Deprecated
|
||||
@NotAuditable
|
||||
RecordsManagementSecurityService getRecordsManagementSecurityService();
|
||||
|
||||
/**
|
||||
* @return records management audit service
|
||||
*/
|
||||
@NotAuditable
|
||||
RecordsManagementAuditService getRecordsManagementAuditService();
|
||||
|
||||
/**
|
||||
* @return capability service
|
||||
* @since 2.0
|
||||
*/
|
||||
@NotAuditable
|
||||
CapabilityService getCapabilityService();
|
||||
|
||||
/**
|
||||
* @return freeze service
|
||||
* @since 2.1
|
||||
*/
|
||||
@NotAuditable
|
||||
FreezeService getFreezeService();
|
||||
|
||||
/**
|
||||
* @return extended security service
|
||||
* @since 2.1
|
||||
*/
|
||||
@NotAuditable
|
||||
ExtendedSecurityService getExtendedSecurityService();
|
||||
|
||||
/**
|
||||
* @return file plan service
|
||||
* @since 2.1
|
||||
*/
|
||||
@NotAuditable
|
||||
FilePlanService getFilePlanService();
|
||||
|
||||
/**
|
||||
* @return file plan role service
|
||||
* @since 2.1
|
||||
*/
|
||||
@NotAuditable
|
||||
FilePlanRoleService getFilePlanRoleService();
|
||||
|
||||
/**
|
||||
* @return file plan permission service
|
||||
* @since 2.1
|
||||
*/
|
||||
@NotAuditable
|
||||
FilePlanPermissionService getFilePlanPermissionService();
|
||||
|
||||
/**
|
||||
* @return file plan authentication service
|
||||
* @since 2.1
|
||||
*/
|
||||
FilePlanAuthenticationService getFilePlanAuthenticationService();
|
||||
|
||||
/**
|
||||
* @return identifier service
|
||||
* @since 2.1
|
||||
*/
|
||||
IdentifierService getIdentifierService();
|
||||
|
||||
/**
|
||||
* @return record folder service
|
||||
* @since 2.2
|
||||
*/
|
||||
@NotAuditable
|
||||
RecordFolderService getRecordFolderService();
|
||||
|
||||
/**
|
||||
* @return transfer service
|
||||
* @since 2.2
|
||||
*/
|
||||
@NotAuditable
|
||||
TransferService getTransferService();
|
||||
}
|
@@ -1,209 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService;
|
||||
import org.alfresco.repo.service.ServiceDescriptorRegistry;
|
||||
|
||||
/**
|
||||
* Records management service registry implementation
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegistry
|
||||
implements RecordsManagementServiceRegistry
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementActionService()
|
||||
*/
|
||||
@Override
|
||||
public RecordsManagementActionService getRecordsManagementActionService()
|
||||
{
|
||||
return (RecordsManagementActionService) getService(RECORDS_MANAGEMENT_ACTION_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementAdminService()
|
||||
*/
|
||||
@Override
|
||||
public RecordsManagementAdminService getRecordsManagementAdminService()
|
||||
{
|
||||
return (RecordsManagementAdminService) getService(RECORDS_MANAGEMENT_ADMIN_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementEventService()
|
||||
*/
|
||||
@Override
|
||||
public RecordsManagementEventService getRecordsManagementEventService()
|
||||
{
|
||||
return (RecordsManagementEventService) getService(RECORDS_MANAGEMENT_EVENT_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementService()
|
||||
*/
|
||||
@Override
|
||||
public RecordsManagementService getRecordsManagementService()
|
||||
{
|
||||
return (RecordsManagementService) getService(RECORDS_MANAGEMENT_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordService()
|
||||
*/
|
||||
public RecordService getRecordService()
|
||||
{
|
||||
return (RecordService) getService(RECORD_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementSecurityService()
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public RecordsManagementSecurityService getRecordsManagementSecurityService()
|
||||
{
|
||||
return (RecordsManagementSecurityService) getService(RECORDS_MANAGEMENT_SECURITY_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementAuditService()
|
||||
*/
|
||||
@Override
|
||||
public RecordsManagementAuditService getRecordsManagementAuditService()
|
||||
{
|
||||
return (RecordsManagementAuditService) getService(RECORDS_MANAGEMENT_AUDIT_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getDictionaryService()
|
||||
*/
|
||||
@Override
|
||||
public DispositionService getDispositionService()
|
||||
{
|
||||
return (DispositionService) getService(DISPOSITION_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getCapabilityService()
|
||||
*/
|
||||
@Override
|
||||
public CapabilityService getCapabilityService()
|
||||
{
|
||||
return (CapabilityService) getService(CAPABILITY_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFreezeService()
|
||||
*/
|
||||
@Override
|
||||
public FreezeService getFreezeService()
|
||||
{
|
||||
return (FreezeService) getService(FREEZE_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getExtendedSecurityService()
|
||||
*/
|
||||
@Override
|
||||
public ExtendedSecurityService getExtendedSecurityService()
|
||||
{
|
||||
return (ExtendedSecurityService) getService(EXTENDED_SECURITY_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanService()
|
||||
*/
|
||||
@Override
|
||||
public FilePlanService getFilePlanService()
|
||||
{
|
||||
return (FilePlanService) getService(FILE_PLAN_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanRoleService()
|
||||
*/
|
||||
@Override
|
||||
public FilePlanRoleService getFilePlanRoleService()
|
||||
{
|
||||
return (FilePlanRoleService) getService(FILE_PLAN_ROLE_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanPermissionService()
|
||||
*/
|
||||
@Override
|
||||
public FilePlanPermissionService getFilePlanPermissionService()
|
||||
{
|
||||
return (FilePlanPermissionService) getService(FILE_PLAN_PERMISSION_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanAuthenticationService()
|
||||
*/
|
||||
@Override
|
||||
public FilePlanAuthenticationService getFilePlanAuthenticationService()
|
||||
{
|
||||
return (FilePlanAuthenticationService) getService(FILE_PLAN_AUTHENTICATION_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getIdentifierService()
|
||||
*/
|
||||
@Override
|
||||
public IdentifierService getIdentifierService()
|
||||
{
|
||||
return (IdentifierService) getService(IDENTIFIER_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordFolderService()
|
||||
*/
|
||||
@Override
|
||||
public RecordFolderService getRecordFolderService()
|
||||
{
|
||||
return (RecordFolderService) getService(RECORD_FOLDER_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getTransferService()
|
||||
*/
|
||||
@Override
|
||||
public TransferService getTransferService()
|
||||
{
|
||||
return (TransferService) getService(TRANSFER_SERVICE);
|
||||
}
|
||||
}
|
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
/**
|
||||
* Auditable action executer abstract base
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public abstract class AuditableActionExecuterAbstractBase extends ActionExecuterAbstractBase implements ApplicationContextAware
|
||||
{
|
||||
/** Indicates whether the action is auditable or not */
|
||||
protected boolean auditable = true;
|
||||
|
||||
/** Indicates whether the action is audited immediately or not */
|
||||
protected boolean auditedImmediately = false;
|
||||
|
||||
/** Application context */
|
||||
protected ApplicationContext applicationContext;
|
||||
|
||||
/** Records management audit service */
|
||||
private RecordsManagementAuditService auditService;
|
||||
|
||||
/**
|
||||
* @param auditable true if auditable, false otherwise
|
||||
*/
|
||||
public void setAuditable(boolean auditable)
|
||||
{
|
||||
this.auditable = auditable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param auditedImmediately true if to be audited immediately, false to be audited after transaction commits
|
||||
*/
|
||||
public void setAuditedImmediately(boolean auditedImmediately)
|
||||
{
|
||||
this.auditedImmediately = auditedImmediately;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
{
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return records management audit service
|
||||
*/
|
||||
private RecordsManagementAuditService getAuditService()
|
||||
{
|
||||
if (auditService == null)
|
||||
{
|
||||
auditService = (RecordsManagementAuditService)applicationContext.getBean("recordsManagementAuditService");
|
||||
}
|
||||
return auditService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#init()
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
if (this instanceof RecordsManagementAction == false)
|
||||
{
|
||||
super.init();
|
||||
}
|
||||
|
||||
if (auditable == true)
|
||||
{
|
||||
getAuditService().registerAuditEvent(this.getActionDefinition().getName(), this.getActionDefinition().getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#execute(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void execute(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
// audit the execution of the action
|
||||
if (auditable == true)
|
||||
{
|
||||
if (auditedImmediately == true)
|
||||
{
|
||||
// To be audited immediately before the action is executed, eg. to audit before actionedUponNodeRef gets deleted during the execution.
|
||||
getAuditService().auditEvent(actionedUponNodeRef, this.getActionDefinition().getName(), null, null, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// To be stacked up with other audit entries and audited after the transaction commits.
|
||||
getAuditService().auditEvent(actionedUponNodeRef, this.getActionDefinition().getName());
|
||||
}
|
||||
}
|
||||
|
||||
// execute the action
|
||||
super.execute(action, actionedUponNodeRef);
|
||||
}
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import org.alfresco.repo.action.parameter.ParameterProcessorComponent;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Extension to action implementation hierarchy to insert parameter substitution processing.
|
||||
*
|
||||
* NOTE: this should eventually be pushed into the core.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public abstract class PropertySubActionExecuterAbstractBase extends AuditableActionExecuterAbstractBase
|
||||
{
|
||||
/** Parameter processor component */
|
||||
protected ParameterProcessorComponent parameterProcessorComponent;
|
||||
|
||||
/** Indicates whether parameter substitutions are allowed */
|
||||
protected boolean allowParameterSubstitutions = false;
|
||||
|
||||
/**
|
||||
* @param parameterProcessorComponent parameter processor component
|
||||
*/
|
||||
public void setParameterProcessorComponent(ParameterProcessorComponent parameterProcessorComponent)
|
||||
{
|
||||
this.parameterProcessorComponent = parameterProcessorComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param allowParameterSubstitutions true if property subs allowed, false otherwise
|
||||
*/
|
||||
public void setAllowParameterSubstitutions(boolean allowParameterSubstitutions)
|
||||
{
|
||||
this.allowParameterSubstitutions = allowParameterSubstitutions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#execute(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public void execute(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
// do the property subs (if any exist)
|
||||
if (allowParameterSubstitutions == true)
|
||||
{
|
||||
parameterProcessorComponent.process(action, getActionDefinition(), actionedUponNodeRef);
|
||||
}
|
||||
|
||||
super.execute(action, actionedUponNodeRef);
|
||||
}
|
||||
}
|
@@ -1,540 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
|
||||
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService;
|
||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.OwnableService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Records management action executer base class
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public abstract class RMActionExecuterAbstractBase extends PropertySubActionExecuterAbstractBase
|
||||
implements RecordsManagementAction,
|
||||
RecordsManagementModel,
|
||||
BeanNameAware
|
||||
{
|
||||
/** Namespace service */
|
||||
protected NamespaceService namespaceService;
|
||||
|
||||
/** Used to control transactional behaviour including post-commit auditing */
|
||||
protected TransactionService transactionService;
|
||||
|
||||
/** Node service */
|
||||
protected NodeService nodeService;
|
||||
|
||||
/** Dictionary service */
|
||||
protected DictionaryService dictionaryService;
|
||||
|
||||
/** Content service */
|
||||
protected ContentService contentService;
|
||||
|
||||
/** Action service */
|
||||
protected ActionService actionService;
|
||||
|
||||
/** Records management action service */
|
||||
protected RecordsManagementAuditService recordsManagementAuditService;
|
||||
|
||||
/** Records management action service */
|
||||
protected RecordsManagementActionService recordsManagementActionService;
|
||||
|
||||
/** Record service */
|
||||
protected RecordService recordService;
|
||||
|
||||
/** Disposition service */
|
||||
protected DispositionService dispositionService;
|
||||
|
||||
/** Vital record service */
|
||||
protected VitalRecordService vitalRecordService;
|
||||
|
||||
/** Records management event service */
|
||||
protected RecordsManagementEventService recordsManagementEventService;
|
||||
|
||||
/** Records management action service */
|
||||
protected RecordsManagementAdminService recordsManagementAdminService;
|
||||
|
||||
/** Ownable service **/
|
||||
protected OwnableService ownableService;
|
||||
|
||||
/** Freeze service */
|
||||
protected FreezeService freezeService;
|
||||
|
||||
/** Model security service */
|
||||
protected ModelSecurityService modelSecurityService;
|
||||
|
||||
/** Record folder service */
|
||||
protected RecordFolderService recordFolderService;
|
||||
|
||||
/** List of kinds for which this action is applicable */
|
||||
protected Set<FilePlanComponentKind> applicableKinds = new HashSet<FilePlanComponentKind>();
|
||||
|
||||
/**
|
||||
* Set the namespace service
|
||||
*/
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the namespace service
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionary service
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content service
|
||||
*/
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set action service
|
||||
*/
|
||||
public void setActionService(ActionService actionService)
|
||||
{
|
||||
this.actionService = actionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the audit service that action details will be sent to
|
||||
*/
|
||||
public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService)
|
||||
{
|
||||
this.recordsManagementAuditService = recordsManagementAuditService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set records management service
|
||||
*/
|
||||
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
|
||||
{
|
||||
this.recordsManagementActionService = recordsManagementActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the disposition service
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vitalRecordService vital record service
|
||||
*/
|
||||
public void setVitalRecordService(VitalRecordService vitalRecordService)
|
||||
{
|
||||
this.vitalRecordService = vitalRecordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set records management event service
|
||||
*/
|
||||
public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService)
|
||||
{
|
||||
this.recordsManagementEventService = recordsManagementEventService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the ownable service
|
||||
* @param ownableSerice
|
||||
*/
|
||||
public void setOwnableService(OwnableService ownableService)
|
||||
{
|
||||
this.ownableService = ownableService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set freeze service
|
||||
*
|
||||
* @param freezeService freeze service
|
||||
*/
|
||||
public void setFreezeService(FreezeService freezeService)
|
||||
{
|
||||
this.freezeService = freezeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set record service
|
||||
*
|
||||
* @param recordService record service
|
||||
*/
|
||||
public void setRecordService(RecordService recordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param recordsManagementAdminService records management admin service
|
||||
*/
|
||||
public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService)
|
||||
{
|
||||
this.recordsManagementAdminService = recordsManagementAdminService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return records management admin service
|
||||
*/
|
||||
public RecordsManagementAdminService getRecordsManagementAdminService()
|
||||
{
|
||||
return recordsManagementAdminService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modelSecurityService model security service
|
||||
*/
|
||||
public void setModelSecurityService(ModelSecurityService modelSecurityService)
|
||||
{
|
||||
this.modelSecurityService = modelSecurityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param recordFolderService record folder service
|
||||
*/
|
||||
public void setRecordFolderService(RecordFolderService recordFolderService)
|
||||
{
|
||||
this.recordFolderService = recordFolderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param applicableKinds kinds that this action is applicable for
|
||||
*/
|
||||
public void setApplicableKinds(String[] applicableKinds)
|
||||
{
|
||||
for(String kind : applicableKinds)
|
||||
{
|
||||
this.applicableKinds.add(FilePlanComponentKind.valueOf(kind));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#createActionDefinition(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected ActionDefinition createActionDefinition(String name)
|
||||
{
|
||||
return new RecordsManagementActionDefinitionImpl(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#getActionDefinition()
|
||||
*/
|
||||
@Override
|
||||
public ActionDefinition getActionDefinition()
|
||||
{
|
||||
ActionDefinition actionDefinition = super.getActionDefinition();
|
||||
((RecordsManagementActionDefinitionImpl)this.actionDefinition).setApplicableKinds(applicableKinds);
|
||||
return actionDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getRecordsManagementActionDefinition()
|
||||
*/
|
||||
@Override
|
||||
public RecordsManagementActionDefinition getRecordsManagementActionDefinition()
|
||||
{
|
||||
return (RecordsManagementActionDefinition)getActionDefinition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
PropertyCheck.mandatory(this, "namespaceService", namespaceService);
|
||||
PropertyCheck.mandatory(this, "transactionService", transactionService);
|
||||
PropertyCheck.mandatory(this, "nodeService", nodeService);
|
||||
PropertyCheck.mandatory(this, "dictionaryService", dictionaryService);
|
||||
PropertyCheck.mandatory(this, "contentService", contentService);
|
||||
PropertyCheck.mandatory(this, "actionService", actionService);
|
||||
PropertyCheck.mandatory(this, "transactionService", transactionService);
|
||||
PropertyCheck.mandatory(this, "recordsManagementAuditService", recordsManagementAuditService);
|
||||
PropertyCheck.mandatory(this, "recordsManagementActionService", recordsManagementActionService);
|
||||
PropertyCheck.mandatory(this, "recordsManagementAdminService", recordsManagementAdminService);
|
||||
PropertyCheck.mandatory(this, "recordsManagementEventService", recordsManagementEventService);
|
||||
|
||||
super.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this records management action is public or not
|
||||
*
|
||||
* @return boolean true if public, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean isPublicAction()
|
||||
{
|
||||
return publicAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.CommonResourceAbstractBase#setBeanName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setBeanName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getLabel()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
String label = I18NUtil.getMessage(this.getTitleKey());
|
||||
|
||||
if (label == null)
|
||||
{
|
||||
// default to the name of the action with first letter capitalised
|
||||
label = StringUtils.capitalize(this.name);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getDescription()
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
String desc = I18NUtil.getMessage(this.getDescriptionKey());
|
||||
|
||||
if (desc == null)
|
||||
{
|
||||
// default to the name of the action with first letter capitalised
|
||||
desc = StringUtils.capitalize(this.name);
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default an action is not a disposition action
|
||||
*
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#isDispositionAction()
|
||||
*/
|
||||
public boolean isDispositionAction()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#execute(org.alfresco.service.cmr.repository.NodeRef, java.util.Map)
|
||||
*/
|
||||
public RecordsManagementActionResult execute(NodeRef filePlanComponent, Map<String, Serializable> parameters)
|
||||
{
|
||||
// Create the action
|
||||
Action action = this.actionService.createAction(name);
|
||||
action.setParameterValues(parameters);
|
||||
|
||||
// disable model security whilst we execute the RM rule
|
||||
modelSecurityService.disable();
|
||||
try
|
||||
{
|
||||
// Execute the action
|
||||
actionService.executeAction(action, filePlanComponent);
|
||||
}
|
||||
finally
|
||||
{
|
||||
modelSecurityService.enable();
|
||||
}
|
||||
|
||||
// Get the result
|
||||
Object value = action.getParameterValue(ActionExecuterAbstractBase.PARAM_RESULT);
|
||||
return new RecordsManagementActionResult(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to pad a string with zero '0' characters to the required length
|
||||
*
|
||||
* @param s String to pad with leading zero '0' characters
|
||||
* @param len Length to pad to
|
||||
*
|
||||
* @return padded string or the original if already at >=len characters
|
||||
*
|
||||
* @deprecated As of 2.1, replaced by {@link org.apache.commons.lang.StringUtils.leftPad}
|
||||
*/
|
||||
@Deprecated
|
||||
protected String padString(String s, int len)
|
||||
{
|
||||
String result = s;
|
||||
for (int i=0; i<(len - s.length()); i++)
|
||||
{
|
||||
result = "0" + result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default there are no parameters.
|
||||
*
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
// No parameters
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, rmActions do not provide an implicit target nodeRef.
|
||||
*/
|
||||
public NodeRef getImplicitTargetNodeRef()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the given records management event for the given 'next action'.
|
||||
*
|
||||
* @param event The event to create
|
||||
* @param nextActionNodeRef The next action node
|
||||
* @return The created event NodeRef
|
||||
*/
|
||||
protected NodeRef createEvent(RecordsManagementEvent event, NodeRef nextActionNodeRef)
|
||||
{
|
||||
NodeRef eventNodeRef = null;
|
||||
|
||||
Map<QName, Serializable> eventProps = new HashMap<QName, Serializable>(7);
|
||||
eventProps.put(PROP_EVENT_EXECUTION_NAME, event.getName());
|
||||
// TODO display label
|
||||
RecordsManagementEventType eventType = recordsManagementEventService.getEventType(event.getType());
|
||||
eventProps.put(PROP_EVENT_EXECUTION_AUTOMATIC, eventType.isAutomaticEvent());
|
||||
eventProps.put(PROP_EVENT_EXECUTION_COMPLETE, false);
|
||||
|
||||
// Create the event execution object
|
||||
this.nodeService.createNode(nextActionNodeRef, ASSOC_EVENT_EXECUTIONS,
|
||||
ASSOC_EVENT_EXECUTIONS, TYPE_EVENT_EXECUTION, eventProps);
|
||||
|
||||
return eventNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates and updates the <code>rma:dispositionEventsEligible</code>
|
||||
* property for the given next disposition action.
|
||||
*
|
||||
* @param nextAction The next disposition action
|
||||
* @return The result of calculation
|
||||
*/
|
||||
protected boolean updateEventEligible(DispositionAction nextAction)
|
||||
{
|
||||
List<EventCompletionDetails> events = nextAction.getEventCompletionDetails();
|
||||
|
||||
boolean eligible = false;
|
||||
if (nextAction.getDispositionActionDefinition().eligibleOnFirstCompleteEvent() == false)
|
||||
{
|
||||
eligible = true;
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (event.isEventComplete() == false)
|
||||
{
|
||||
eligible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (event.isEventComplete() == true)
|
||||
{
|
||||
eligible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the property with the eligible value
|
||||
this.nodeService.setProperty(nextAction.getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE, eligible);
|
||||
|
||||
return eligible;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,303 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public abstract class RMDispositionActionExecuterAbstractBase extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_RECORD_NOT_DECLARED = "rm.action.record-not-declared";
|
||||
private static final String MSG_EXPECTED_RECORD_LEVEL = "rm.action.expected-record-level";
|
||||
private static final String MSG_NOT_ALL_RECORDS_DECLARED = "rm.action.not-all-records-declared";
|
||||
private static final String MSG_NOT_ELIGIBLE = "rm.action.not-eligible";
|
||||
private static final String MSG_NO_DISPOITION_INSTRUCTIONS = "rm.action.no-disposition-instructions";
|
||||
private static final String MSG_NO_DIS_LIFECYCLE_SET = "rm.action.no-disposition-lisfecycle-set";
|
||||
private static final String MSG_NEXT_DISP_NOT_SET = "rm.action.next-disp-not-set";
|
||||
private static final String MSG_NOT_NEXT_DISP = "rm.action.not-next-disp";
|
||||
private static final String MSG_NOT_RECORD_FOLDER = "rm.action.not-record-folder";
|
||||
|
||||
/** Parameter value indicating whether we should be doing non-error raising state checks */
|
||||
public static final String PARAM_NO_ERROR_CHECK = "rm.no-error-check";
|
||||
|
||||
/**
|
||||
* All children of this implementation are disposition actions.
|
||||
*
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isDispositionAction()
|
||||
*/
|
||||
@Override
|
||||
public boolean isDispositionAction()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the disposition is marked complete
|
||||
*
|
||||
* @return boolean true if marked complete, false otherwise
|
||||
*/
|
||||
public boolean getSetDispositionActionComplete()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether we should validate the next disposition action is the action we are
|
||||
* trying to execute.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean checkNextDispositionAction(NodeRef actionedUponNodeRef)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicated whether we should validate the disposition action is eligible or not.
|
||||
*
|
||||
* @param actionedUponNodeRef
|
||||
* @return
|
||||
*/
|
||||
protected boolean checkEligibility(NodeRef actionedUponNodeRef)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
NodeRef nextDispositionActionNodeRef = getNextDispostionAction(actionedUponNodeRef);
|
||||
|
||||
// determine whether we should be raising errors during state checking or not
|
||||
boolean checkError = true;
|
||||
Boolean checkErrorValue = (Boolean)action.getParameterValue(PARAM_NO_ERROR_CHECK);
|
||||
if (checkErrorValue != null)
|
||||
{
|
||||
checkError = checkErrorValue.booleanValue();
|
||||
}
|
||||
|
||||
// Check the validity of the action (is it the next action, are we dealing with the correct type of object for
|
||||
// the disposition level?
|
||||
DispositionSchedule di = checkDispositionActionExecutionValidity(actionedUponNodeRef, nextDispositionActionNodeRef, checkError);
|
||||
if (di != null)
|
||||
{
|
||||
// Check the eligibility of the action
|
||||
if (checkEligibility(actionedUponNodeRef) == false ||
|
||||
dispositionService.isNextDispositionActionEligible(actionedUponNodeRef) == true)
|
||||
{
|
||||
if (di.isRecordLevelDisposition() == true)
|
||||
{
|
||||
// Check that we do indeed have a record
|
||||
if (recordService.isRecord(actionedUponNodeRef) == true)
|
||||
{
|
||||
// Can only execute disposition action on record if declared
|
||||
if (recordService.isDeclared(actionedUponNodeRef) == true)
|
||||
{
|
||||
// Indicate that the disposition action is underway
|
||||
nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date());
|
||||
nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser());
|
||||
|
||||
// Execute record level disposition
|
||||
executeRecordLevelDisposition(action, actionedUponNodeRef);
|
||||
|
||||
if (nodeService.exists(nextDispositionActionNodeRef) == true &&
|
||||
getSetDispositionActionComplete() == true)
|
||||
{
|
||||
nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date());
|
||||
nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_NOT_DECLARED, getName(), actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EXPECTED_RECORD_LEVEL, getName(), actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (recordFolderService.isRecordFolder(actionedUponNodeRef) == true)
|
||||
{
|
||||
if (recordFolderService.isRecordFolderDeclared(actionedUponNodeRef) == true)
|
||||
{
|
||||
// Indicate that the disposition action is underway
|
||||
nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date());
|
||||
nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser());
|
||||
|
||||
executeRecordFolderLevelDisposition(action, actionedUponNodeRef);
|
||||
|
||||
// Indicate that the disposition action is compelte
|
||||
if (nodeService.exists(nextDispositionActionNodeRef) == true &&
|
||||
getSetDispositionActionComplete() == true)
|
||||
{
|
||||
nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date());
|
||||
nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser());
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_ALL_RECORDS_DECLARED, getName(), actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_RECORD_FOLDER, getName(), actionedUponNodeRef.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (nodeService.exists(actionedUponNodeRef) == true && getSetDispositionActionComplete() == true)
|
||||
{
|
||||
// Update the disposition schedule
|
||||
dispositionService.updateNextDispositionAction(actionedUponNodeRef);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_ELIGIBLE, getName(), actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
// TODO add the "checkEligibility" parameter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param action
|
||||
* @param record
|
||||
*/
|
||||
protected abstract void executeRecordLevelDisposition(Action action, NodeRef record);
|
||||
|
||||
/**
|
||||
* @param action
|
||||
* @param recordFolder
|
||||
*/
|
||||
protected abstract void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder);
|
||||
|
||||
/**
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
protected DispositionSchedule checkDispositionActionExecutionValidity(NodeRef nodeRef, NodeRef nextDispositionActionNodeRef, boolean throwError)
|
||||
{
|
||||
// Check the node has associated disposition instructions
|
||||
DispositionSchedule di = dispositionService.getDispositionSchedule(nodeRef);
|
||||
if (di == null)
|
||||
{
|
||||
if (throwError)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_DISPOITION_INSTRUCTIONS, getName(), nodeRef.toString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Check the node has the disposition schedule aspect applied
|
||||
if (nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) == false)
|
||||
{
|
||||
if (throwError)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_DIS_LIFECYCLE_SET, getName(), nodeRef.toString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkNextDispositionAction(nodeRef) == true)
|
||||
{
|
||||
// Check this the next disposition action
|
||||
NodeRef nextDispositionAction = nextDispositionActionNodeRef;
|
||||
if (nextDispositionAction == null)
|
||||
{
|
||||
if (throwError)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NEXT_DISP_NOT_SET, getName(), nodeRef.toString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
String actionName = (String) nodeService.getProperty(nextDispositionAction, PROP_DISPOSITION_ACTION);
|
||||
if (actionName == null || actionName.equals(getName()) == false)
|
||||
{
|
||||
if (throwError)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_NEXT_DISP, getName(), nodeRef.toString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return di;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next disposition action node. Null if none present.
|
||||
*
|
||||
* @param nodeRef
|
||||
* the disposable node reference
|
||||
* @return NodeRef the next disposition action, null if none
|
||||
*/
|
||||
private NodeRef getNextDispostionAction(NodeRef nodeRef)
|
||||
{
|
||||
NodeRef result = null;
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, RegexQNamePattern.MATCH_ALL);
|
||||
if (assocs.size() != 0)
|
||||
{
|
||||
result = assocs.get(0).getChildRef();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
|
||||
/**
|
||||
* Record Management Action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public interface RecordsManagementAction
|
||||
{
|
||||
/**
|
||||
* Get the name of the action
|
||||
*
|
||||
* @return String action name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Get the label of the action
|
||||
*
|
||||
* @return String action label
|
||||
*/
|
||||
public String getLabel();
|
||||
|
||||
/**
|
||||
* Get the description of the action
|
||||
*
|
||||
* @return String action description
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/**
|
||||
* Indicates whether this is a disposition action or not
|
||||
*
|
||||
* @return boolean true if a disposition action, false otherwise
|
||||
*/
|
||||
boolean isDispositionAction();
|
||||
|
||||
/**
|
||||
* Execution of the action
|
||||
*
|
||||
* @param filePlanComponent file plan component the action is executed upon
|
||||
* @param parameters action parameters
|
||||
*/
|
||||
public RecordsManagementActionResult execute(NodeRef filePlanComponent, Map<String, Serializable> parameters);
|
||||
|
||||
/**
|
||||
* Some admin-related rmActions execute against a target nodeRef which is not provided
|
||||
* by the calling code, but is instead an implementation detail of the action.
|
||||
*
|
||||
* @return the target nodeRef
|
||||
*/
|
||||
public NodeRef getImplicitTargetNodeRef();
|
||||
|
||||
/**
|
||||
* Get the records management action definition.
|
||||
*
|
||||
* @return
|
||||
* @since 2.1
|
||||
*/
|
||||
public RecordsManagementActionDefinition getRecordsManagementActionDefinition();
|
||||
|
||||
/**
|
||||
* Indicates whether the action is public or not
|
||||
*
|
||||
* @return
|
||||
* @since 2.1
|
||||
*/
|
||||
public boolean isPublicAction();
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Record Management Action Condition
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface RecordsManagementActionCondition
|
||||
{
|
||||
/**
|
||||
* Get the name of the action condition
|
||||
*
|
||||
* @return String action condition name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Get the label of the action condition
|
||||
*
|
||||
* @return String action condition label
|
||||
*/
|
||||
public String getLabel();
|
||||
|
||||
/**
|
||||
* Get the description of the action condition
|
||||
*
|
||||
* @return String action condition description
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RecordsManagementActionConditionDefinition getRecordsManagementActionConditionDefinition();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isPublicCondition();
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import org.alfresco.service.cmr.action.ActionConditionDefinition;
|
||||
|
||||
/**
|
||||
* Records management condition definition.
|
||||
*
|
||||
* Primarily used as a marker interface.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface RecordsManagementActionConditionDefinition extends ActionConditionDefinition
|
||||
{
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import org.alfresco.repo.action.ActionConditionDefinitionImpl;
|
||||
|
||||
/**
|
||||
* Records management condition definition implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RecordsManagementActionConditionDefinitionImpl extends ActionConditionDefinitionImpl
|
||||
implements RecordsManagementActionConditionDefinition
|
||||
{
|
||||
/** Serial Version UID */
|
||||
private static final long serialVersionUID = -7599279732731533610L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @param name name of the condition
|
||||
*/
|
||||
public RecordsManagementActionConditionDefinitionImpl(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
}
|
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.action.ActionConditionDefinition;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
|
||||
/**
|
||||
* Records management action condition evaluator abstract base implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public abstract class RecordsManagementActionConditionEvaluatorAbstractBase extends ActionConditionEvaluatorAbstractBase
|
||||
implements RecordsManagementActionCondition,
|
||||
BeanNameAware
|
||||
{
|
||||
/** records management action service */
|
||||
protected RecordsManagementActionService recordsManagementActionService;
|
||||
|
||||
/** File Plan Service */
|
||||
protected FilePlanService filePlanService;
|
||||
|
||||
/** bean name */
|
||||
private String name;
|
||||
|
||||
/** public condition */
|
||||
protected boolean publicCondition = true;
|
||||
|
||||
private RetryingTransactionHelper retryingTransactionHelper;
|
||||
|
||||
/**
|
||||
* @param recordsManagementActionService records management action service
|
||||
*/
|
||||
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
|
||||
{
|
||||
this.recordsManagementActionService = recordsManagementActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param retryingTransactionHelper
|
||||
*/
|
||||
public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper)
|
||||
{
|
||||
this.retryingTransactionHelper = retryingTransactionHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#init()
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
// override to prevent condition being registered with the core action service
|
||||
|
||||
// run the following code as System
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork()
|
||||
{
|
||||
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
recordsManagementActionService.register(RecordsManagementActionConditionEvaluatorAbstractBase.this);
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
retryingTransactionHelper.doInTransaction(callback);
|
||||
return null;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPublicCondition(boolean publicCondition)
|
||||
{
|
||||
this.publicCondition = publicCondition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.CommonResourceAbstractBase#setBeanName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setBeanName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
super.setBeanName(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getLabel()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return getActionConditionDefintion().getTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getDescription()
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return getActionConditionDefintion().getDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#getActionConditionDefintion()
|
||||
*
|
||||
* TODO base class should provide "createActionDefinition" method that can be over-ridden like the ActionExecuter
|
||||
* base class to prevent duplication of code and a cleaner extension.
|
||||
*/
|
||||
@Override
|
||||
public ActionConditionDefinition getActionConditionDefintion()
|
||||
{
|
||||
if (this.actionConditionDefinition == null)
|
||||
{
|
||||
this.actionConditionDefinition = new RecordsManagementActionConditionDefinitionImpl(name);
|
||||
((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setTitleKey(getTitleKey());
|
||||
((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setDescriptionKey(getDescriptionKey());
|
||||
((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setAdhocPropertiesAllowed(getAdhocPropertiesAllowed());
|
||||
((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setConditionEvaluator(name);
|
||||
((RecordsManagementActionConditionDefinitionImpl)actionConditionDefinition).setParameterDefinitions(getParameterDefintions());
|
||||
}
|
||||
return this.actionConditionDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> arg0)
|
||||
{
|
||||
// No param implementation by default
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition#isPublicCondition()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPublicCondition()
|
||||
{
|
||||
return publicCondition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition#getRecordsManagementActionConditionDefinition()
|
||||
*/
|
||||
@Override
|
||||
public RecordsManagementActionConditionDefinition getRecordsManagementActionConditionDefinition()
|
||||
{
|
||||
return (RecordsManagementActionConditionDefinition)getActionConditionDefintion();
|
||||
}
|
||||
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
|
||||
/**
|
||||
* Extended action definition interface.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface RecordsManagementActionDefinition extends ActionDefinition
|
||||
{
|
||||
/**
|
||||
* @return list of applicable file plan component kinds
|
||||
*/
|
||||
Set<FilePlanComponentKind> getApplicableKinds();
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
|
||||
import org.alfresco.repo.action.ActionDefinitionImpl;
|
||||
|
||||
/**
|
||||
* Extended action definition implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RecordsManagementActionDefinitionImpl extends ActionDefinitionImpl implements RecordsManagementActionDefinition
|
||||
{
|
||||
/** generated serial version id */
|
||||
private static final long serialVersionUID = -5226538434707253206L;
|
||||
|
||||
/** Applicable kinds */
|
||||
private Set<FilePlanComponentKind> applicableKinds;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @param name action definition name
|
||||
*/
|
||||
public RecordsManagementActionDefinitionImpl(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param applicableKinds applicable kinds
|
||||
*/
|
||||
public void setApplicableKinds(Set<FilePlanComponentKind> applicableKinds)
|
||||
{
|
||||
this.applicableKinds = applicableKinds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition#getApplicableKinds()
|
||||
*/
|
||||
@Override
|
||||
public Set<FilePlanComponentKind> getApplicableKinds()
|
||||
{
|
||||
return applicableKinds;
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009-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.module.org_alfresco_module_rm.action;
|
||||
|
||||
/**
|
||||
* Records management action result.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RecordsManagementActionResult
|
||||
{
|
||||
/** Result value */
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param value result value
|
||||
*/
|
||||
public RecordsManagementActionResult(Object value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return result value
|
||||
*/
|
||||
public Object getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
}
|
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
|
||||
/**
|
||||
* Records management action service interface
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public interface RecordsManagementActionService
|
||||
{
|
||||
/**
|
||||
* Get a list of the available records management actions
|
||||
*
|
||||
* @return List<RecordsManagementAction> records management actions
|
||||
*/
|
||||
List<RecordsManagementAction> getRecordsManagementActions();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @since 2.1
|
||||
*/
|
||||
List<RecordsManagementActionCondition> getRecordsManagementActionConditions();
|
||||
|
||||
/**
|
||||
* Get a list of the available disposition actions. A disposition action is a records
|
||||
* management action that can be used when defining disposition instructions.
|
||||
*
|
||||
* @return List<RecordsManagementAction> disposition actions
|
||||
*/
|
||||
List<RecordsManagementAction> getDispositionActions();
|
||||
|
||||
/**
|
||||
* Gets the named records management action
|
||||
*
|
||||
* @param name The name of the RM action to retrieve
|
||||
* @return The RecordsManagementAction or null if it doesn't exist
|
||||
*/
|
||||
RecordsManagementAction getRecordsManagementAction(String name);
|
||||
|
||||
/**
|
||||
* Gets the named disposition action
|
||||
*
|
||||
* @param name The name of the disposition action to retrieve
|
||||
* @return The RecordsManagementAction or null if it doesn't exist
|
||||
*/
|
||||
RecordsManagementAction getDispositionAction(String name);
|
||||
|
||||
/**
|
||||
* Execute a records management action
|
||||
*
|
||||
* @param nodeRef node reference to a rm container, rm folder or record
|
||||
* @param name action name
|
||||
*/
|
||||
RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name);
|
||||
|
||||
/**
|
||||
* Execute a records management action against several nodes
|
||||
*
|
||||
* @param nodeRefs node references to rm containers, rm folders or records
|
||||
* @param name action name
|
||||
*/
|
||||
Map<NodeRef, RecordsManagementActionResult> executeRecordsManagementAction(List<NodeRef> nodeRefs, String name);
|
||||
|
||||
/**
|
||||
* Execute a records management action
|
||||
*
|
||||
* @param nodeRef node reference to a rm container, rm folder or record
|
||||
* @param name action name
|
||||
* @param parameters action parameters
|
||||
*/
|
||||
RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name, Map<String, Serializable> parameters);
|
||||
|
||||
/**
|
||||
* Execute a records management action against several nodes
|
||||
*
|
||||
* @param nodeRefs node references to rm containers, rm folders or records
|
||||
* @param name action name
|
||||
* @param parameters action parameters
|
||||
*/
|
||||
Map<NodeRef, RecordsManagementActionResult> executeRecordsManagementAction(List<NodeRef> nodeRefs, String name, Map<String, Serializable> parameters);
|
||||
|
||||
/**
|
||||
* Execute a records management action. The nodeRef against which the action is to be
|
||||
* executed must be provided by the RecordsManagementAction implementation.
|
||||
*
|
||||
* @param name action name
|
||||
* @param parameters action parameters
|
||||
*/
|
||||
RecordsManagementActionResult executeRecordsManagementAction(String name, Map<String, Serializable> parameters);
|
||||
|
||||
/**
|
||||
* Register records management action
|
||||
*
|
||||
* @param rmAction records management action
|
||||
*/
|
||||
void register(RecordsManagementAction rmAction);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rmCondition
|
||||
* @since 2.1
|
||||
*/
|
||||
void register(RecordsManagementActionCondition rmCondition);
|
||||
}
|
@@ -1,311 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRMActionExecution;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRMActionExecution;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.PoliciesUtil;
|
||||
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Records Management Action Service Implementation
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RecordsManagementActionServiceImpl implements RecordsManagementActionService
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_NOT_DEFINED = "rm.action.not-defined";
|
||||
private static final String MSG_NO_IMPLICIT_NODEREF = "rm.action.no-implicit-noderef";
|
||||
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(RecordsManagementActionServiceImpl.class);
|
||||
|
||||
/** Registered records management actions */
|
||||
private Map<String, RecordsManagementAction> rmActions = new HashMap<String, RecordsManagementAction>(13);
|
||||
private Map<String, RecordsManagementActionCondition> rmConditions = new HashMap<String, RecordsManagementActionCondition>(13);
|
||||
|
||||
private Map<String, RecordsManagementAction> dispositionActions = new HashMap<String, RecordsManagementAction>(5);
|
||||
|
||||
/** Policy component */
|
||||
PolicyComponent policyComponent;
|
||||
|
||||
/** Node service */
|
||||
NodeService nodeService;
|
||||
|
||||
/** Policy delegates */
|
||||
private ClassPolicyDelegate<BeforeRMActionExecution> beforeRMActionExecutionDelegate;
|
||||
private ClassPolicyDelegate<OnRMActionExecution> onRMActionExecutionDelegate;
|
||||
|
||||
/**
|
||||
* Set the policy component
|
||||
*
|
||||
* @param policyComponent policy component
|
||||
*/
|
||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
{
|
||||
this.policyComponent = policyComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the node service
|
||||
*
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise RM action service
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
// Register the various policies
|
||||
beforeRMActionExecutionDelegate = policyComponent.registerClassPolicy(BeforeRMActionExecution.class);
|
||||
onRMActionExecutionDelegate = policyComponent.registerClassPolicy(OnRMActionExecution.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#register(org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction)
|
||||
*/
|
||||
public void register(RecordsManagementAction rmAction)
|
||||
{
|
||||
if (rmActions.containsKey(rmAction.getName()) == false)
|
||||
{
|
||||
rmActions.put(rmAction.getName(), rmAction);
|
||||
|
||||
if (rmAction.isDispositionAction() == true)
|
||||
{
|
||||
dispositionActions.put(rmAction.getName(), rmAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void register(RecordsManagementActionCondition rmCondition)
|
||||
{
|
||||
if (rmConditions.containsKey(rmCondition.getName()) == false)
|
||||
{
|
||||
rmConditions.put(rmCondition.getName(), rmCondition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke beforeRMActionExecution policy
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param name action name
|
||||
* @param parameters action parameters
|
||||
*/
|
||||
protected void invokeBeforeRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters)
|
||||
{
|
||||
// get qnames to invoke against
|
||||
Set<QName> qnames = PoliciesUtil.getTypeAndAspectQNames(nodeService, nodeRef);
|
||||
// execute policy for node type and aspects
|
||||
BeforeRMActionExecution policy = beforeRMActionExecutionDelegate.get(qnames);
|
||||
policy.beforeRMActionExecution(nodeRef, name, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke onRMActionExecution policy
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param name action name
|
||||
* @param parameters action parameters
|
||||
*/
|
||||
protected void invokeOnRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters)
|
||||
{
|
||||
// get qnames to invoke against
|
||||
Set<QName> qnames = PoliciesUtil.getTypeAndAspectQNames(nodeService, nodeRef);
|
||||
// execute policy for node type and aspects
|
||||
OnRMActionExecution policy = onRMActionExecutionDelegate.get(qnames);
|
||||
policy.onRMActionExecution(nodeRef, name, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#getRecordsManagementActions()
|
||||
*/
|
||||
public List<RecordsManagementAction> getRecordsManagementActions()
|
||||
{
|
||||
List<RecordsManagementAction> result = new ArrayList<RecordsManagementAction>(this.rmActions.size());
|
||||
result.addAll(this.rmActions.values());
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getRecordsManagementActionConditions()
|
||||
*/
|
||||
@Override
|
||||
public List<RecordsManagementActionCondition> getRecordsManagementActionConditions()
|
||||
{
|
||||
List<RecordsManagementActionCondition> result = new ArrayList<RecordsManagementActionCondition>(rmConditions.size());
|
||||
result.addAll(rmConditions.values());
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getDispositionActions(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public List<RecordsManagementAction> getDispositionActions(NodeRef nodeRef)
|
||||
{
|
||||
String userName = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
List<RecordsManagementAction> result = new ArrayList<RecordsManagementAction>(this.rmActions.size());
|
||||
|
||||
for (RecordsManagementAction action : this.rmActions.values())
|
||||
{
|
||||
// TODO check the permissions on the action ...
|
||||
}
|
||||
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#getDispositionActionDefinitions()
|
||||
*/
|
||||
public List<RecordsManagementAction> getDispositionActions()
|
||||
{
|
||||
List<RecordsManagementAction> result = new ArrayList<RecordsManagementAction>(dispositionActions.size());
|
||||
result.addAll(dispositionActions.values());
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getDispositionAction(java.lang.String)
|
||||
*/
|
||||
public RecordsManagementAction getDispositionAction(String name)
|
||||
{
|
||||
return dispositionActions.get(name);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getRecordsManagementAction(java.lang.String)
|
||||
*/
|
||||
public RecordsManagementAction getRecordsManagementAction(String name)
|
||||
{
|
||||
return this.rmActions.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
*/
|
||||
public RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name)
|
||||
{
|
||||
return executeRecordsManagementAction(nodeRef, name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(java.util.List, java.lang.String)
|
||||
*/
|
||||
public Map<NodeRef, RecordsManagementActionResult> executeRecordsManagementAction(List<NodeRef> nodeRefs, String name)
|
||||
{
|
||||
return executeRecordsManagementAction(nodeRefs, name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map)
|
||||
*/
|
||||
public RecordsManagementActionResult executeRecordsManagementAction(NodeRef nodeRef, String name, Map<String, Serializable> parameters)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Executing record management action on " + nodeRef);
|
||||
logger.debug(" actionName = " + name);
|
||||
logger.debug(" parameters = " + parameters);
|
||||
}
|
||||
|
||||
RecordsManagementAction rmAction = this.rmActions.get(name);
|
||||
if (rmAction == null)
|
||||
{
|
||||
String msg = I18NUtil.getMessage(MSG_NOT_DEFINED, name);
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn(msg);
|
||||
}
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
}
|
||||
|
||||
// Execute action
|
||||
invokeBeforeRMActionExecution(nodeRef, name, parameters);
|
||||
RecordsManagementActionResult result = rmAction.execute(nodeRef, parameters);
|
||||
if (nodeService.exists(nodeRef) == true)
|
||||
{
|
||||
invokeOnRMActionExecution(nodeRef, name, parameters);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(java.lang.String, java.util.Map)
|
||||
*/
|
||||
public RecordsManagementActionResult executeRecordsManagementAction(String name, Map<String, Serializable> parameters)
|
||||
{
|
||||
RecordsManagementAction rmAction = rmActions.get(name);
|
||||
|
||||
NodeRef implicitTargetNode = rmAction.getImplicitTargetNodeRef();
|
||||
if (implicitTargetNode == null)
|
||||
{
|
||||
String msg = I18NUtil.getMessage(MSG_NO_IMPLICIT_NODEREF, name);
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn(msg);
|
||||
}
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.executeRecordsManagementAction(implicitTargetNode, name, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementActionService#executeRecordsManagementAction(java.util.List, java.lang.String, java.util.Map)
|
||||
*/
|
||||
public Map<NodeRef, RecordsManagementActionResult> executeRecordsManagementAction(List<NodeRef> nodeRefs, String name, Map<String, Serializable> parameters)
|
||||
{
|
||||
// Execute the action on each node in the list
|
||||
Map<NodeRef, RecordsManagementActionResult> results = new HashMap<NodeRef, RecordsManagementActionResult>(nodeRefs.size());
|
||||
for (NodeRef nodeRef : nodeRefs)
|
||||
{
|
||||
RecordsManagementActionResult result = executeRecordsManagementAction(nodeRef, name, parameters);
|
||||
results.put(nodeRef, result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
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.ResultSet;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
/**
|
||||
* Scheduled disposition job.
|
||||
*
|
||||
* Automatically cuts off eligible nodes.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class ScheduledDispositionJob implements Job
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(ScheduledDispositionJob.class);
|
||||
|
||||
/**
|
||||
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
|
||||
*/
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException
|
||||
{
|
||||
RecordsManagementActionService rmActionService
|
||||
= (RecordsManagementActionService)context.getJobDetail().getJobDataMap().get("recordsManagementActionService");
|
||||
NodeService nodeService = (NodeService)context.getJobDetail().getJobDataMap().get("nodeService");
|
||||
|
||||
|
||||
// Calculate the date range used in the query
|
||||
Calendar cal = Calendar.getInstance();
|
||||
String year = String.valueOf(cal.get(Calendar.YEAR));
|
||||
String month = String.valueOf(cal.get(Calendar.MONTH) + 1);
|
||||
String dayOfMonth = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
|
||||
|
||||
//TODO These pad() calls are in RMActionExecuterAbstractBase. I've copied them
|
||||
// here as I have no access to that class.
|
||||
|
||||
final String currentDate = padString(year, 2) + "-" + padString(month, 2) +
|
||||
"-" + padString(dayOfMonth, 2) + "T00:00:00.00Z";
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Executing ")
|
||||
.append(this.getClass().getSimpleName())
|
||||
.append(" with currentDate ")
|
||||
.append(currentDate);
|
||||
logger.debug(msg.toString());
|
||||
}
|
||||
|
||||
//TODO Copied the 1970 start date from the old RM JavaScript impl.
|
||||
String dateRange = "[\"1970-01-01T00:00:00.00Z\" TO \"" + currentDate + "\"]";
|
||||
|
||||
// Execute the query and process the results
|
||||
String query = "+ASPECT:\"rma:record\" +ASPECT:\"rma:dispositionSchedule\" +@rma\\:dispositionAsOf:" + dateRange;
|
||||
|
||||
SearchService search = (SearchService)context.getJobDetail().getJobDataMap().get("searchService");
|
||||
ResultSet results = search.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_LUCENE, query);
|
||||
|
||||
List<NodeRef> resultNodes = results.getNodeRefs();
|
||||
results.close();
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Found ")
|
||||
.append(resultNodes.size())
|
||||
.append(" records eligible for disposition.");
|
||||
logger.debug(msg.toString());
|
||||
}
|
||||
|
||||
for (NodeRef node : resultNodes )
|
||||
{
|
||||
String dispActionName = (String)nodeService.getProperty(node, RecordsManagementModel.PROP_DISPOSITION_ACTION_NAME);
|
||||
|
||||
// Only automatically execute "cutoff" actions.
|
||||
// destroy and transfer and anything else should be manual for now
|
||||
if (dispActionName != null && dispActionName.equalsIgnoreCase("cutoff"))
|
||||
{
|
||||
rmActionService.executeRecordsManagementAction(node, dispActionName);
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Performing " + dispActionName + " dispoition action on disposable item " + node.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO This has been pasted out of RMActionExecuterAbstractBase. To be relocated.
|
||||
private String padString(String s, int len)
|
||||
{
|
||||
String result = s;
|
||||
for (int i=0; i<(len - s.length()); i++)
|
||||
{
|
||||
result = "0" + result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.constraint;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
|
||||
|
||||
/**
|
||||
* A parameter constraint that reads in a list of allowable values from Spring configuration
|
||||
*
|
||||
* @author Craig Tan
|
||||
* @since 2.1
|
||||
*/
|
||||
public class CustomParameterConstraint extends BaseParameterConstraint
|
||||
{
|
||||
|
||||
private List<String> parameterValues;
|
||||
|
||||
/**
|
||||
* @param parameterValues
|
||||
*/
|
||||
public void setParameterValues(List<String> parameterValues)
|
||||
{
|
||||
this.parameterValues = parameterValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
|
||||
*/
|
||||
protected Map<String, String> getAllowableValuesImpl()
|
||||
{
|
||||
Map<String, String> allowableValues = new HashMap<String, String>(parameterValues.size());
|
||||
|
||||
for (Object parameterValue : parameterValues)
|
||||
{
|
||||
// Look up the I18N value
|
||||
String displayLabel = getI18NLabel(parameterValue.toString());
|
||||
|
||||
// Add to the map of allowed values
|
||||
allowableValues.put(parameterValue.toString(), displayLabel);
|
||||
}
|
||||
|
||||
return allowableValues;
|
||||
}
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.constraint;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
||||
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
|
||||
|
||||
/**
|
||||
* Record type parameter constraint
|
||||
*
|
||||
* @author Craig Tan
|
||||
* @since 2.1
|
||||
*/
|
||||
public class DispositionActionParameterConstraint extends BaseParameterConstraint
|
||||
{
|
||||
/** Name constant */
|
||||
public static final String NAME = "rm-ac-record-types";
|
||||
|
||||
private RecordsManagementActionService rmActionService;
|
||||
|
||||
public void setRecordsManagementActionService(RecordsManagementActionService rmActionService)
|
||||
{
|
||||
this.rmActionService = rmActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
|
||||
*/
|
||||
protected Map<String, String> getAllowableValuesImpl()
|
||||
{
|
||||
List<RecordsManagementAction> rmActions = rmActionService.getDispositionActions();
|
||||
|
||||
Map<String, String> result = new HashMap<String, String>(rmActions.size());
|
||||
for (RecordsManagementAction rmAction : rmActions)
|
||||
{
|
||||
result.put(rmAction.getName(), rmAction.getLabel());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.constraint;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType;
|
||||
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
|
||||
|
||||
/**
|
||||
* Manual event parameter constraint
|
||||
*
|
||||
* @author Craig Tan
|
||||
*/
|
||||
public class ManualEventParameterConstraint extends BaseParameterConstraint
|
||||
{
|
||||
/** Name constant */
|
||||
public static final String NAME = "rm-ac-manual-events";
|
||||
|
||||
private RecordsManagementEventService recordsManagementEventService;
|
||||
|
||||
public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService)
|
||||
{
|
||||
this.recordsManagementEventService = recordsManagementEventService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
|
||||
*/
|
||||
protected Map<String, String> getAllowableValuesImpl()
|
||||
{
|
||||
List<RecordsManagementEvent> events = recordsManagementEventService.getEvents();
|
||||
Map<String, String> result = new HashMap<String, String>(events.size());
|
||||
for (RecordsManagementEvent event : events)
|
||||
{
|
||||
RecordsManagementEventType eventType = recordsManagementEventService.getEventType(event.getType());
|
||||
if (eventType != null && !eventType.isAutomaticEvent())
|
||||
{
|
||||
result.put(event.getName(), event.getDisplayLabel());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.constraint;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
|
||||
import org.alfresco.repo.i18n.StaticMessageLookup;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Record type parameter constraint
|
||||
*
|
||||
* @author Craig Tan
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RecordTypeParameterConstraint extends BaseParameterConstraint
|
||||
{
|
||||
/** Name constant */
|
||||
public static final String NAME = "rm-ac-record-types";
|
||||
|
||||
private RecordService recordService;
|
||||
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
public void setRecordService(RecordService recordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
|
||||
*/
|
||||
protected Map<String, String> getAllowableValuesImpl()
|
||||
{
|
||||
Set<QName> recordTypes = recordService.getRecordMetaDataAspects();
|
||||
|
||||
Map<String, String> result = new HashMap<String, String>(recordTypes.size());
|
||||
for (QName recordType : recordTypes)
|
||||
{
|
||||
|
||||
AspectDefinition aspectDefinition = dictionaryService.getAspect(recordType);
|
||||
if (aspectDefinition != null)
|
||||
{
|
||||
result.put(aspectDefinition.getName().getLocalName(), aspectDefinition.getTitle(new StaticMessageLookup()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,240 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.action.dm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Creates a new record from an existing content object.
|
||||
*
|
||||
* Note: This is a 'normal' dm action, rather than a records management action.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class CreateRecordAction extends AuditableActionExecuterAbstractBase
|
||||
implements RecordsManagementModel
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(CreateRecordAction.class);
|
||||
|
||||
/** Action name */
|
||||
public static final String NAME = "create-record";
|
||||
|
||||
/** Parameter names */
|
||||
public static final String PARAM_FILE_PLAN = "file-plan";
|
||||
public static final String PARAM_HIDE_RECORD = "hide-record";
|
||||
|
||||
/** Sync Model URI */
|
||||
static final String SYNC_MODEL_1_0_URI = "http://www.alfresco.org/model/sync/1.0";
|
||||
/** Synced aspect */
|
||||
static final QName ASPECT_SYNCED = QName.createQName(SYNC_MODEL_1_0_URI, "synced");
|
||||
|
||||
/** Record service */
|
||||
private RecordService recordService;
|
||||
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** File plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/** Dictionary service */
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
/** File plan authentication service */
|
||||
private FilePlanAuthenticationService filePlanAuthenticationService;
|
||||
|
||||
/**
|
||||
* @param recordService record service
|
||||
*/
|
||||
public void setRecordService(RecordService recordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService dictionary service
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanAuthenticationService file plan authentication service
|
||||
*/
|
||||
public void setFilePlanAuthenticationService(FilePlanAuthenticationService filePlanAuthenticationService)
|
||||
{
|
||||
this.filePlanAuthenticationService = filePlanAuthenticationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef)
|
||||
{
|
||||
|
||||
if (nodeService.exists(actionedUponNodeRef) == false)
|
||||
{
|
||||
// do not create record if the actioned upon node does not exist!
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " does not exist.");
|
||||
}
|
||||
}
|
||||
else if (dictionaryService.isSubClass(nodeService.getType(actionedUponNodeRef), ContentModel.TYPE_CONTENT) == false)
|
||||
{
|
||||
// TODO eventually we should support other types .. either as record folders or as composite records
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " is not a supported type.");
|
||||
}
|
||||
}
|
||||
else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD) == true)
|
||||
{
|
||||
// Do not create record if the actioned upon node is already a record!
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " is already a record.");
|
||||
}
|
||||
}
|
||||
else if (nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY) == true)
|
||||
{
|
||||
// We can not create records from working copies
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Can node create record, because " + actionedUponNodeRef.toString() + " is a working copy.");
|
||||
}
|
||||
|
||||
}
|
||||
else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS) == true)
|
||||
{
|
||||
// can not create a record from a previously rejected one
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " has previously been rejected.");
|
||||
}
|
||||
}
|
||||
else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_SYNCED) == true)
|
||||
{
|
||||
// can't declare the record if the node is sync'ed
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Can't declare as record, because " + actionedUponNodeRef.toString() + " is synched content.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NodeRef filePlan = (NodeRef)action.getParameterValue(PARAM_FILE_PLAN);
|
||||
if (filePlan == null)
|
||||
{
|
||||
// TODO .. eventually make the file plan parameter required
|
||||
filePlan = filePlanAuthenticationService.runAsRmAdmin(new RunAsWork<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef doWork() throws Exception
|
||||
{
|
||||
return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
}
|
||||
});
|
||||
|
||||
// if the file plan is still null, raise an exception
|
||||
if (filePlan == null)
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Can not create record, because the default file plan can not be determined. Make sure at least one file plan has been created.");
|
||||
}
|
||||
throw new AlfrescoRuntimeException("Can not create record, because the default file plan can not be determined.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// verify that the provided file plan is actually a file plan
|
||||
if (filePlanService.isFilePlan(filePlan) == false)
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Can not create record, because the provided file plan node reference is not a file plan.");
|
||||
}
|
||||
throw new AlfrescoRuntimeException("Can not create record, because the provided file plan node reference is not a file plan.");
|
||||
}
|
||||
}
|
||||
|
||||
// indicate whether the record should be hidden or not (default not)
|
||||
boolean hideRecord = false;
|
||||
Boolean hideRecordValue = ((Boolean)action.getParameterValue(PARAM_HIDE_RECORD));
|
||||
if (hideRecordValue != null)
|
||||
{
|
||||
hideRecord = hideRecordValue.booleanValue();
|
||||
}
|
||||
|
||||
// create record from existing document
|
||||
recordService.createRecord(filePlan, actionedUponNodeRef, !hideRecord);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> params)
|
||||
{
|
||||
// NOTE: commented out for now so that it doesn't appear in the UI ... enable later when multi-file plan support is added
|
||||
//params.add(new ParameterDefinitionImpl(PARAM_FILE_PLAN, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_FILE_PLAN)));
|
||||
params.add(new ParameterDefinitionImpl(PARAM_HIDE_RECORD, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_HIDE_RECORD)));
|
||||
}
|
||||
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.dm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.repo.action.executer.ScriptActionExecuter;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
|
||||
/**
|
||||
* Executes a JavaScript
|
||||
*
|
||||
* Note: This is a 'normal' dm action, rather than a records management action.
|
||||
*
|
||||
* @author Craig Tan
|
||||
*/
|
||||
public class ExecuteScriptAction extends ScriptActionExecuter
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_SCRIPTREF, DataTypeDefinition.NODE_REF, true,
|
||||
getParamDisplayLabel(PARAM_SCRIPTREF), false, "rm-ac-scripts"));
|
||||
}
|
||||
|
||||
}
|
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.action.dm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Hides a record within a collaboration site.
|
||||
*
|
||||
* Note: This is a 'normal' dm action, rather than a records management action.
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.1
|
||||
*/
|
||||
public class HideRecordAction extends AuditableActionExecuterAbstractBase
|
||||
implements RecordsManagementModel
|
||||
{
|
||||
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(HideRecordAction.class);
|
||||
|
||||
/** Action name */
|
||||
public static final String NAME = "hide-record";
|
||||
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** Record service */
|
||||
private RecordService recordService;
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param recordService record service
|
||||
*/
|
||||
public void setRecordService(RecordService recordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD) == false)
|
||||
{
|
||||
// we cannot hide a document which is not a record
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Cannot hide the document, because '" + actionedUponNodeRef.toString() + "' is not a record.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// hide the record from the collaboration site
|
||||
recordService.hideRecord(actionedUponNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
// Intentionally empty
|
||||
}
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.action.evaluator;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Records management evaluator base implementation that delegates to a configured capability condition
|
||||
* implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class CapabilityConditionEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase
|
||||
{
|
||||
/** Capability Condition */
|
||||
private CapabilityCondition capabilityCondition;
|
||||
|
||||
/**
|
||||
* @param capabilityCondition capability condition
|
||||
*/
|
||||
public void setCapabilityCondition(CapabilityCondition capabilityCondition)
|
||||
{
|
||||
this.capabilityCondition = capabilityCondition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
// check a capability condition has been set and delegate
|
||||
ParameterCheck.mandatory("capabilityCondition", capabilityCondition);
|
||||
return capabilityCondition.evaluate(actionedUponNodeRef);
|
||||
}
|
||||
}
|
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.action.evaluator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase;
|
||||
import org.alfresco.repo.action.evaluator.ActionConditionEvaluator;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Records management action condition who's implementation is delegated to an existing
|
||||
* action condition.
|
||||
* <p>
|
||||
* Useful for creating a RM version of an existing action condition implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class DelegateActionCondition extends RecordsManagementActionConditionEvaluatorAbstractBase
|
||||
{
|
||||
/** Delegate action evaluator */
|
||||
private ActionConditionEvaluator actionConditionEvaluator;
|
||||
|
||||
/**
|
||||
* @param actionEvaluator action evaluator
|
||||
*/
|
||||
public void setActionConditionEvaluator(ActionConditionEvaluator actionConditionEvaluator)
|
||||
{
|
||||
this.actionConditionEvaluator = actionConditionEvaluator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
return actionConditionEvaluator.evaluate(actionCondition, actionedUponNodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#getParameterDefintions()
|
||||
*/
|
||||
@Override
|
||||
protected List<ParameterDefinition> getParameterDefintions()
|
||||
{
|
||||
return actionConditionEvaluator.getActionConditionDefintion().getParameterDefinitions();
|
||||
}
|
||||
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.evaluator;
|
||||
|
||||
/**
|
||||
* Disposition action relative position enumeration class. <br>
|
||||
*
|
||||
* @author Craig Tan
|
||||
* @since 2.1
|
||||
*/
|
||||
public enum DispositionActionRelativePositions
|
||||
{
|
||||
ANY, NEXT, PREVIOUS;
|
||||
}
|
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.action.evaluator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Records management hasDispositionAction evaluator that evaluates whether the given node's disposition schedule has the specified disposition action.
|
||||
*
|
||||
* @author Craig Tan
|
||||
* @since 2.1
|
||||
*/
|
||||
public class HasDispositionActionEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase
|
||||
{
|
||||
/**
|
||||
* Evaluator constants
|
||||
*/
|
||||
public static final String NAME = "hasDispositionAction";
|
||||
|
||||
public static final String PARAM_DISPOSITION_ACTION_RELATIVE_POSITION = "position";
|
||||
|
||||
public static final String PARAM_DISPOSITION_ACTION = "action";
|
||||
|
||||
private DispositionService dispositionService;
|
||||
|
||||
/**
|
||||
* @param dispositionService
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
boolean result = false;
|
||||
String position = ((QName) actionCondition.getParameterValue(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION)).getLocalName();
|
||||
String action = ((QName) actionCondition.getParameterValue(PARAM_DISPOSITION_ACTION)).getLocalName();
|
||||
|
||||
|
||||
if (dispositionService.isDisposableItem(actionedUponNodeRef) == true)
|
||||
{
|
||||
|
||||
if (position.equals(DispositionActionRelativePositions.ANY.toString()))
|
||||
{
|
||||
|
||||
DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(actionedUponNodeRef);
|
||||
if (dispositionSchedule != null)
|
||||
{
|
||||
for (DispositionActionDefinition dispositionActionDefinition : dispositionSchedule.getDispositionActionDefinitions())
|
||||
{
|
||||
if (dispositionActionDefinition.getName().equals(action) == true)
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (position.equals(DispositionActionRelativePositions.NEXT.toString()))
|
||||
{
|
||||
DispositionAction nextDispositionAction = dispositionService.getNextDispositionAction(actionedUponNodeRef);
|
||||
if (nextDispositionAction != null)
|
||||
{
|
||||
// Get the disposition actions name
|
||||
String actionName = nextDispositionAction.getName();
|
||||
if (actionName.equals(action) == true)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (position.equals(DispositionActionRelativePositions.PREVIOUS.toString()))
|
||||
{
|
||||
DispositionAction lastCompletedDispositionAction = dispositionService.getLastCompletedDispostionAction(actionedUponNodeRef);
|
||||
if (lastCompletedDispositionAction != null)
|
||||
{
|
||||
// Get the disposition actions name
|
||||
String actionName = lastCompletedDispositionAction.getName();
|
||||
if (actionName.equals(action) == true)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION, DataTypeDefinition.QNAME, true,
|
||||
getParamDisplayLabel(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION), false, "rm-ac-disposition-action-relative-positions"));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_DISPOSITION_ACTION, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_DISPOSITION_ACTION), false,
|
||||
"rm-ac-disposition-actions"));
|
||||
|
||||
}
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.action.evaluator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Records management IsKind evaluator that evaluates according to the file plan
|
||||
* component kind passed in.
|
||||
*
|
||||
* @author Craig Tan
|
||||
* @since 2.1
|
||||
*/
|
||||
/**
|
||||
* @author ctan
|
||||
*/
|
||||
public class IsKindEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase
|
||||
{
|
||||
/**
|
||||
* Evaluator constants
|
||||
*/
|
||||
public static final String NAME = "isKind";
|
||||
public static final String PARAM_KIND = "kind";
|
||||
|
||||
@Override
|
||||
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
boolean result = false;
|
||||
String kind = ((QName) actionCondition.getParameterValue(PARAM_KIND)).getLocalName();
|
||||
|
||||
FilePlanComponentKind filePlanComponentKind = filePlanService.getFilePlanComponentKind(actionedUponNodeRef);
|
||||
|
||||
if (filePlanComponentKind != null &&
|
||||
filePlanComponentKind.toString().equals(kind))
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_KIND, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_KIND), false, "rm-ac-is-kind-kinds"));
|
||||
}
|
||||
|
||||
}
|
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.action.evaluator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Records management IsRecordType evaluator that evaluates whether the record is of the specified type.
|
||||
*
|
||||
* @author Craig Tan
|
||||
* @since 2.1
|
||||
*/
|
||||
/**
|
||||
* @author ctan
|
||||
*/
|
||||
public class IsRecordTypeEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase implements DOD5015Model
|
||||
{
|
||||
/**
|
||||
* Evaluator constants
|
||||
*/
|
||||
public static final String NAME = "isRecordType";
|
||||
|
||||
public static final String PARAM_RECORD_TYPE = "type";
|
||||
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* @param nodeService
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
boolean result = false;
|
||||
String type = ((QName) actionCondition.getParameterValue(PARAM_RECORD_TYPE)).getLocalName();
|
||||
|
||||
if (type != null)
|
||||
{
|
||||
result = nodeService.hasAspect(actionedUponNodeRef, QName.createQName(DOD_URI, type));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_RECORD_TYPE, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_RECORD_TYPE), false, "rm-ac-record-types"));
|
||||
}
|
||||
|
||||
}
|
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Action to add types to a record
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.1
|
||||
*/
|
||||
public class AddRecordTypeAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(AddRecordTypeAction.class);
|
||||
|
||||
/** I18N */
|
||||
private static final String MSG_ACTIONED_UPON_NOT_RECORD = "rm.action.actioned-upon-not-record";
|
||||
|
||||
/** Constant */
|
||||
private static final String DELIMITER = ",";
|
||||
|
||||
/** Parameter names */
|
||||
public static final String PARAM_ADD_RECORD_TYPES = "recordTypes";
|
||||
|
||||
/** Action name */
|
||||
public static final String NAME = "addRecordTypes";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (eligibleForAction(actionedUponNodeRef) == true)
|
||||
{
|
||||
for (String type : getRecordTypes(action))
|
||||
{
|
||||
recordService.addRecordType(actionedUponNodeRef, QName.createQName(type, namespaceService));
|
||||
}
|
||||
}
|
||||
else if (logger.isWarnEnabled() == true)
|
||||
{
|
||||
logger.warn(I18NUtil.getMessage(MSG_ACTIONED_UPON_NOT_RECORD, this.getClass().getSimpleName(), actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to check the actioned upon node reference to decide to execute the action
|
||||
* The preconditions are:
|
||||
* - The node must exist
|
||||
* - The node must not be frozen
|
||||
* - The node must be record
|
||||
* - The node must not be declared
|
||||
*
|
||||
* @param actionedUponNodeRef node reference
|
||||
* @return Return true if the node reference passes all the preconditions for executing the action, false otherwise
|
||||
*/
|
||||
private boolean eligibleForAction(NodeRef actionedUponNodeRef)
|
||||
{
|
||||
boolean result = false;
|
||||
if (nodeService.exists(actionedUponNodeRef) == true &&
|
||||
freezeService.isFrozen(actionedUponNodeRef) == false &&
|
||||
recordService.isRecord(actionedUponNodeRef) == true &&
|
||||
recordService.isDeclared(actionedUponNodeRef) == false)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the record types from the action
|
||||
*
|
||||
* @param action The action
|
||||
* @return An array of record types
|
||||
*/
|
||||
private String[] getRecordTypes(Action action)
|
||||
{
|
||||
String recordTypes = (String) action.getParameterValue(PARAM_ADD_RECORD_TYPES);
|
||||
return recordTypes.split(DELIMITER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_ADD_RECORD_TYPES, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_ADD_RECORD_TYPES)));
|
||||
}
|
||||
}
|
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* This class applies the aspect specified in the spring bean property customTypeAspect.
|
||||
* It is used to apply one of the 4 "custom type" aspects from the DOD 5015 model.
|
||||
*
|
||||
* @author Neil McErlean
|
||||
*/
|
||||
public class ApplyCustomTypeAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_ACTIONED_UPON_NOT_RECORD = "rm.action.actioned-upon-not-record";
|
||||
private static final String MSG_CUSTOM_ASPECT_NOT_RECOGNISED = "rm.action.custom-aspect-not-recognised";
|
||||
|
||||
private static Log logger = LogFactory.getLog(ApplyCustomTypeAction.class);
|
||||
private QName customTypeAspect;
|
||||
private List<ParameterDefinition> parameterDefinitions;
|
||||
|
||||
public void setCustomTypeAspect(String customTypeAspect)
|
||||
{
|
||||
this.customTypeAspect = QName.createQName(customTypeAspect, namespaceService);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Executing action [" + action.getActionDefinitionName() + "] on " + actionedUponNodeRef);
|
||||
}
|
||||
|
||||
if (recordService.isRecord(actionedUponNodeRef) == true)
|
||||
{
|
||||
// Apply the appropriate aspect and set the properties.
|
||||
Map<QName, Serializable> aspectProps = getPropertyValues(action);
|
||||
this.nodeService.addAspect(actionedUponNodeRef, customTypeAspect, aspectProps);
|
||||
}
|
||||
else if (logger.isWarnEnabled() == true)
|
||||
{
|
||||
logger.warn(I18NUtil.getMessage(MSG_ACTIONED_UPON_NOT_RECORD, this.getClass().getSimpleName(), actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method extracts the properties from the custom type's aspect.
|
||||
* @see #getCustomTypeAspect()
|
||||
*/
|
||||
@Override
|
||||
protected final void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
AspectDefinition aspectDef = dictionaryService.getAspect(customTypeAspect);
|
||||
for (PropertyDefinition propDef : aspectDef.getProperties().values())
|
||||
{
|
||||
QName propName = propDef.getName();
|
||||
QName propType = propDef.getDataType().getName();
|
||||
paramList.add(new ParameterDefinitionImpl(propName.toPrefixString(), propType, propDef.isMandatory(), null));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method converts a Map of String, Serializable to a Map of QName, Serializable.
|
||||
* To do this, it assumes that each parameter name is a String representing a qname
|
||||
* of the form prefix:localName.
|
||||
*/
|
||||
private Map<QName, Serializable> getPropertyValues(Action action)
|
||||
{
|
||||
Map<String, Serializable> paramValues = action.getParameterValues();
|
||||
|
||||
Map<QName, Serializable> result = new HashMap<QName, Serializable>(paramValues.size());
|
||||
for (String paramName : paramValues.keySet())
|
||||
{
|
||||
QName propQName = QName.createQName(paramName, this.namespaceService);
|
||||
result.put(propQName, paramValues.get(paramName));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized List<ParameterDefinition> getParameterDefintions()
|
||||
{
|
||||
// We can take these parameter definitions from the properties defined in the dod model.
|
||||
if (this.parameterDefinitions == null)
|
||||
{
|
||||
AspectDefinition aspectDefinition = dictionaryService.getAspect(customTypeAspect);
|
||||
if (aspectDefinition == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CUSTOM_ASPECT_NOT_RECOGNISED, customTypeAspect));
|
||||
}
|
||||
|
||||
Map<QName, PropertyDefinition> props = aspectDefinition.getProperties();
|
||||
|
||||
this.parameterDefinitions = new ArrayList<ParameterDefinition>(props.size());
|
||||
|
||||
for (QName qn : props.keySet())
|
||||
{
|
||||
String paramName = qn.toPrefixString(namespaceService);
|
||||
QName paramType = props.get(qn).getDataType().getName();
|
||||
boolean paramIsMandatory = props.get(qn).isMandatory();
|
||||
parameterDefinitions.add(new ParameterDefinitionImpl(paramName, paramType, paramIsMandatory, null));
|
||||
}
|
||||
}
|
||||
return parameterDefinitions;
|
||||
}
|
||||
}
|
@@ -1,329 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Period;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Action to implement the consequences of a change to the value of the DispositionActionDefinition
|
||||
* properties. When these properties are changed on a disposition schedule, then any associated
|
||||
* disposition actions may need to be updated as a consequence.
|
||||
*
|
||||
* @author Neil McErlean
|
||||
*/
|
||||
public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(BroadcastDispositionActionDefinitionUpdateAction.class);
|
||||
|
||||
public static final String NAME = "broadcastDispositionActionDefinitionUpdate";
|
||||
public static final String CHANGED_PROPERTIES = "changedProperties";
|
||||
|
||||
private BehaviourFilter behaviourFilter;
|
||||
|
||||
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
|
||||
{
|
||||
this.behaviourFilter = behaviourFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION.equals(nodeService.getType(actionedUponNodeRef)) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<QName> changedProps = (List<QName>)action.getParameterValue(CHANGED_PROPERTIES);
|
||||
|
||||
// Navigate up the containment hierarchy to get the record category grandparent and schedule.
|
||||
NodeRef dispositionScheduleNode = nodeService.getPrimaryParent(actionedUponNodeRef).getParentRef();
|
||||
NodeRef rmContainer = nodeService.getPrimaryParent(dispositionScheduleNode).getParentRef();
|
||||
DispositionSchedule dispositionSchedule = dispositionService.getAssociatedDispositionSchedule(rmContainer);
|
||||
|
||||
behaviourFilter.disableBehaviour();
|
||||
try
|
||||
{
|
||||
List<NodeRef> disposableItems = dispositionService.getDisposableItems(dispositionSchedule);
|
||||
for (NodeRef disposableItem : disposableItems)
|
||||
{
|
||||
updateDisposableItem(dispositionSchedule, disposableItem, actionedUponNodeRef, changedProps);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
behaviourFilter.enableBehaviour();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ds
|
||||
* @param disposableItem
|
||||
* @param dispositionActionDefinition
|
||||
* @param changedProps
|
||||
*/
|
||||
private void updateDisposableItem(DispositionSchedule ds, NodeRef disposableItem, NodeRef dispositionActionDefinition, List<QName> changedProps)
|
||||
{
|
||||
// We need to check that this folder is under the management of the disposition schedule that
|
||||
// has been updated
|
||||
DispositionSchedule itemDs = dispositionService.getDispositionSchedule(disposableItem);
|
||||
if (itemDs != null &&
|
||||
itemDs.getNodeRef().equals(ds.getNodeRef()) == true)
|
||||
{
|
||||
if (nodeService.hasAspect(disposableItem, ASPECT_DISPOSITION_LIFECYCLE))
|
||||
{
|
||||
// disposition lifecycle already exists for node so process changes
|
||||
processActionDefinitionChanges(dispositionActionDefinition, changedProps, disposableItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
// disposition lifecycle does not exist on the node so setup disposition
|
||||
dispositionService.updateNextDispositionAction(disposableItem);
|
||||
}
|
||||
|
||||
// update rolled up search information
|
||||
rollupSearchProperties(disposableItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually update the rolled up search properties
|
||||
*
|
||||
* @param disposableItem disposable item
|
||||
*/
|
||||
private void rollupSearchProperties(NodeRef disposableItem)
|
||||
{
|
||||
DispositionAction da = dispositionService.getNextDispositionAction(disposableItem);
|
||||
if (da != null)
|
||||
{
|
||||
Map<QName, Serializable> props = nodeService.getProperties(disposableItem);
|
||||
|
||||
props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName());
|
||||
props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate());
|
||||
props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, nodeService.getProperty(da.getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE));
|
||||
|
||||
DispositionActionDefinition daDefinition = da.getDispositionActionDefinition();
|
||||
Period period = daDefinition.getPeriod();
|
||||
if (period != null)
|
||||
{
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType());
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression());
|
||||
}
|
||||
else
|
||||
{
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD, null);
|
||||
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null);
|
||||
}
|
||||
|
||||
List<EventCompletionDetails> events = da.getEventCompletionDetails();
|
||||
List<String> list = new ArrayList<String>(events.size());
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
list.add(event.getEventName());
|
||||
}
|
||||
props.put(PROP_RS_DISPOSITION_EVENTS, (Serializable)list);
|
||||
|
||||
nodeService.setProperties(disposableItem, props);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes all the changes applied to the given disposition
|
||||
* action definition node for the given record or folder node.
|
||||
*
|
||||
* @param dispositionActionDef The disposition action definition node
|
||||
* @param changedProps The set of properties changed on the action definition
|
||||
* @param recordOrFolder The record or folder the changes potentially need to be applied to
|
||||
*/
|
||||
private void processActionDefinitionChanges(NodeRef dispositionActionDef, List<QName> changedProps, NodeRef recordOrFolder)
|
||||
{
|
||||
// check that the step being edited is the current step for the folder,
|
||||
// if not, the change has no effect on the current step so ignore
|
||||
DispositionAction nextAction = dispositionService.getNextDispositionAction(recordOrFolder);
|
||||
if (doesChangedStepAffectNextAction(dispositionActionDef, nextAction))
|
||||
{
|
||||
// the change does effect the nextAction for this node
|
||||
// so go ahead and determine what needs updating
|
||||
if (changedProps.contains(PROP_DISPOSITION_PERIOD))
|
||||
{
|
||||
persistPeriodChanges(dispositionActionDef, nextAction);
|
||||
}
|
||||
|
||||
if (changedProps.contains(PROP_DISPOSITION_EVENT) || changedProps.contains(PROP_DISPOSITION_EVENT_COMBINATION))
|
||||
{
|
||||
persistEventChanges(dispositionActionDef, nextAction);
|
||||
}
|
||||
|
||||
if (changedProps.contains(PROP_DISPOSITION_ACTION_NAME))
|
||||
{
|
||||
String action = (String)nodeService.getProperty(dispositionActionDef, PROP_DISPOSITION_ACTION_NAME);
|
||||
nodeService.setProperty(nextAction.getNodeRef(), PROP_DISPOSITION_ACTION, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the disposition action definition (step) being
|
||||
* updated has any effect on the given next action
|
||||
*
|
||||
* @param dispositionActionDef The disposition action definition node
|
||||
* @param nextAction The next disposition action
|
||||
* @return true if the step change affects the next action
|
||||
*/
|
||||
private boolean doesChangedStepAffectNextAction(NodeRef dispositionActionDef,
|
||||
DispositionAction nextAction)
|
||||
{
|
||||
boolean affectsNextAction = false;
|
||||
|
||||
if (dispositionActionDef != null && nextAction != null)
|
||||
{
|
||||
// check whether the id of the action definition node being changed
|
||||
// is the same as the id of the next action
|
||||
String nextActionId = nextAction.getId();
|
||||
if (dispositionActionDef.getId().equals(nextActionId))
|
||||
{
|
||||
affectsNextAction = true;
|
||||
}
|
||||
}
|
||||
|
||||
return affectsNextAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists any changes made to the period on the given disposition action
|
||||
* definition on the given next action.
|
||||
*
|
||||
* @param dispositionActionDef The disposition action definition node
|
||||
* @param nextAction The next disposition action
|
||||
*/
|
||||
private void persistPeriodChanges(NodeRef dispositionActionDef, DispositionAction nextAction)
|
||||
{
|
||||
Date newAsOfDate = null;
|
||||
Period dispositionPeriod = (Period) nodeService.getProperty(dispositionActionDef, PROP_DISPOSITION_PERIOD);
|
||||
|
||||
if (dispositionPeriod != null)
|
||||
{
|
||||
// calculate the new as of date as we have been provided a new period
|
||||
Date now = new Date();
|
||||
newAsOfDate = dispositionPeriod.getNextDate(now);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Set disposition as of date for next action '" + nextAction.getName() +
|
||||
"' (" + nextAction.getNodeRef() + ") to: " + newAsOfDate);
|
||||
}
|
||||
|
||||
nodeService.setProperty(nextAction.getNodeRef(), PROP_DISPOSITION_AS_OF, newAsOfDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists any changes made to the events on the given disposition action
|
||||
* definition on the given next action.
|
||||
*
|
||||
* @param dispositionActionDef The disposition action definition node
|
||||
* @param nextAction The next disposition action
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void persistEventChanges(NodeRef dispositionActionDef, DispositionAction nextAction)
|
||||
{
|
||||
// go through the current events on the next action and remove any that are not present any more
|
||||
List<String> stepEvents = (List<String>) nodeService.getProperty(dispositionActionDef, PROP_DISPOSITION_EVENT);
|
||||
List<EventCompletionDetails> eventsList = nextAction.getEventCompletionDetails();
|
||||
List<String> nextActionEvents = new ArrayList<String>(eventsList.size());
|
||||
for (EventCompletionDetails event : eventsList)
|
||||
{
|
||||
// take note of the event names present on the next action
|
||||
String eventName = event.getEventName();
|
||||
nextActionEvents.add(eventName);
|
||||
|
||||
// if the event has been removed delete from next action
|
||||
if (stepEvents != null && stepEvents.contains(event.getEventName()) == false)
|
||||
{
|
||||
// remove the child association representing the event
|
||||
nodeService.removeChild(nextAction.getNodeRef(), event.getNodeRef());
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Removed '" + eventName + "' from next action '" + nextAction.getName() +
|
||||
"' (" + nextAction.getNodeRef() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
// go through the disposition action definition step events and add any new ones
|
||||
if (stepEvents != null)
|
||||
{
|
||||
for (String eventName : stepEvents)
|
||||
{
|
||||
if (!nextActionEvents.contains(eventName))
|
||||
{
|
||||
createEvent(recordsManagementEventService.getEvent(eventName), nextAction.getNodeRef());
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Added '" + eventName + "' to next action '" + nextAction.getName() +
|
||||
"' (" + nextAction.getNodeRef() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: eventsList contains all the events that have been updated!
|
||||
// TODO: manually update the search properties for the parent node!
|
||||
|
||||
// finally since events may have changed re-calculate the events eligible flag
|
||||
boolean eligible = updateEventEligible(nextAction);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Set events eligible flag to '" + eligible + "' for next action '" + nextAction.getName() +
|
||||
"' (" + nextAction.getNodeRef() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
// Intentionally empty
|
||||
}
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Action to close the records folder
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class CloseRecordFolderAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** Parameter names */
|
||||
public static final String PARAM_CLOSE_PARENT = "closeParent";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (eligibleForAction(actionedUponNodeRef) == true)
|
||||
{
|
||||
recordFolderService.closeRecordFolder(actionedUponNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to check the actioned upon node reference to decide to execute the action
|
||||
* The preconditions are:
|
||||
* - The node must exist
|
||||
* - The node must not be frozen
|
||||
*
|
||||
* @param actionedUponNodeRef node reference
|
||||
* @return Return true if the node reference passes all the preconditions for executing the action, false otherwise
|
||||
*/
|
||||
private boolean eligibleForAction(NodeRef actionedUponNodeRef)
|
||||
{
|
||||
boolean result = false;
|
||||
if (nodeService.exists(actionedUponNodeRef) == true &&
|
||||
freezeService.isFrozen(actionedUponNodeRef) == false)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Complete event action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class CompleteEventAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
public static final String NAME = "completeEvent";
|
||||
public static final String PARAM_EVENT_NAME = "eventName";
|
||||
public static final String PARAM_EVENT_COMPLETED_BY = "eventCompletedBy";
|
||||
public static final String PARAM_EVENT_COMPLETED_AT = "eventCompletedAt";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_EVENT_NAME, DataTypeDefinition.TEXT, true,
|
||||
getParamDisplayLabel(PARAM_EVENT_NAME), false, "rm-ac-manual-events"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (nodeService.exists(actionedUponNodeRef) == true &&
|
||||
freezeService.isFrozen(actionedUponNodeRef) == false)
|
||||
{
|
||||
String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME);
|
||||
String eventCompletedBy = (String)action.getParameterValue(PARAM_EVENT_COMPLETED_BY);
|
||||
Date eventCompletedAt = (Date)action.getParameterValue(PARAM_EVENT_COMPLETED_AT);
|
||||
|
||||
if (this.nodeService.hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE) == true)
|
||||
{
|
||||
// Get the next disposition action
|
||||
DispositionAction da = this.dispositionService.getNextDispositionAction(actionedUponNodeRef);
|
||||
if (da != null)
|
||||
{
|
||||
// Get the disposition event
|
||||
EventCompletionDetails event = getEvent(da, eventName);
|
||||
if (event != null)
|
||||
{
|
||||
if (eventCompletedAt == null)
|
||||
{
|
||||
eventCompletedAt = new Date();
|
||||
}
|
||||
|
||||
if (eventCompletedBy == null)
|
||||
{
|
||||
eventCompletedBy = AuthenticationUtil.getRunAsUser();
|
||||
}
|
||||
|
||||
// Update the event so that it is complete
|
||||
NodeRef eventNodeRef = event.getNodeRef();
|
||||
Map<QName, Serializable> props = this.nodeService.getProperties(eventNodeRef);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETE, true);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, eventCompletedAt);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, eventCompletedBy);
|
||||
this.nodeService.setProperties(eventNodeRef, props);
|
||||
|
||||
// Check to see if the events eligible property needs to be updated
|
||||
updateEventEligible(da);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// RM-695: Commenting error handling out. If the current disposition stage does not define the event being completed nothing should happen.
|
||||
// throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EVENT_NO_DISP_LC, eventName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event from the dispostion action
|
||||
*
|
||||
* @param da
|
||||
* @param eventName
|
||||
* @return
|
||||
*/
|
||||
private EventCompletionDetails getEvent(DispositionAction da, String eventName)
|
||||
{
|
||||
EventCompletionDetails result = null;
|
||||
List<EventCompletionDetails> events = da.getEventCompletionDetails();
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (eventName.equals(event.getEventName()) == true)
|
||||
{
|
||||
result = event;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Create disposition schedule action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class CreateDispositionScheduleAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_NODE_NOT_RECORD_CATEGORY = "rm.action.node-not-record-category";
|
||||
|
||||
/** file plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (eligibleForAction(actionedUponNodeRef) == true)
|
||||
{
|
||||
// Create the disposition schedule
|
||||
dispositionService.createDispositionSchedule(actionedUponNodeRef, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_NOT_RECORD_CATEGORY, actionedUponNodeRef));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to check the actioned upon node reference to decide to execute the action
|
||||
* The preconditions are:
|
||||
* - The node must exist
|
||||
* - The node must not be a record category
|
||||
*
|
||||
* @param actionedUponNodeRef node reference
|
||||
* @return Return true if the node reference passes all the preconditions for executing the action, false otherwise
|
||||
*/
|
||||
private boolean eligibleForAction(NodeRef actionedUponNodeRef)
|
||||
{
|
||||
boolean result = false;
|
||||
if (nodeService.exists(actionedUponNodeRef) == true &&
|
||||
filePlanService.isRecordCategory(actionedUponNodeRef) == true)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Cut off disposition action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class CutOffAction extends RMDispositionActionExecuterAbstractBase
|
||||
{
|
||||
/** Action name */
|
||||
public static final String NAME = "cutoff";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder)
|
||||
{
|
||||
// Close the record folder
|
||||
recordFolderService.closeRecordFolder(recordFolder);
|
||||
|
||||
// Mark the folder as cut off
|
||||
dispositionService.cutoffDisposableItem(recordFolder);
|
||||
|
||||
// Mark all the declared children of the folder as cut off
|
||||
for (NodeRef record : recordService.getRecords(recordFolder))
|
||||
{
|
||||
dispositionService.cutoffDisposableItem(record);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeRecordLevelDisposition(Action action, NodeRef record)
|
||||
{
|
||||
// Mark the record as cut off
|
||||
dispositionService.cutoffDisposableItem(record);
|
||||
}
|
||||
}
|
@@ -1,198 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
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 java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.OwnableService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Declare record action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class DeclareRecordAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_UNDECLARED_ONLY_RECORDS = "rm.action.undeclared-only-records";
|
||||
private static final String MSG_NO_DECLARE_MAND_PROP = "rm.action.no-declare-mand-prop";
|
||||
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(DeclareRecordAction.class);
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (nodeService.exists(actionedUponNodeRef) == true &&
|
||||
recordService.isRecord(actionedUponNodeRef) == true &&
|
||||
freezeService.isFrozen(actionedUponNodeRef) == false)
|
||||
{
|
||||
if (recordService.isDeclared(actionedUponNodeRef) == false)
|
||||
{
|
||||
List<String> missingProperties = new ArrayList<String>(5);
|
||||
// Aspect not already defined - check mandatory properties then add
|
||||
if (mandatoryPropertiesSet(actionedUponNodeRef, missingProperties) == true)
|
||||
{
|
||||
recordService.disablePropertyEditableCheck();
|
||||
try
|
||||
{
|
||||
// Add the declared aspect
|
||||
Map<QName, Serializable> declaredProps = new HashMap<QName, Serializable>(2);
|
||||
declaredProps.put(PROP_DECLARED_AT, new Date());
|
||||
declaredProps.put(PROP_DECLARED_BY, AuthenticationUtil.getRunAsUser());
|
||||
this.nodeService.addAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD, declaredProps);
|
||||
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// remove all owner related rights
|
||||
ownableService.setOwner(actionedUponNodeRef, OwnableService.NO_OWNER);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
recordService.enablePropertyEditableCheck();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug(buildMissingPropertiesErrorString(missingProperties));
|
||||
action.setParameterValue(ActionExecuterAbstractBase.PARAM_RESULT, "missingProperties");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn(I18NUtil.getMessage(MSG_UNDECLARED_ONLY_RECORDS, actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String buildMissingPropertiesErrorString(List<String> missingProperties)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(255);
|
||||
builder.append(I18NUtil.getMessage(MSG_NO_DECLARE_MAND_PROP));
|
||||
builder.append(" ");
|
||||
for (String missingProperty : missingProperties)
|
||||
{
|
||||
builder.append(missingProperty)
|
||||
.append(", ");
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to check whether all the mandatory properties of the node have been set
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return boolean true if all mandatory properties are set, false otherwise
|
||||
*/
|
||||
private boolean mandatoryPropertiesSet(NodeRef nodeRef, List<String> missingProperties)
|
||||
{
|
||||
boolean result = true;
|
||||
|
||||
Map<QName, Serializable> nodeRefProps = this.nodeService.getProperties(nodeRef);
|
||||
|
||||
QName nodeRefType = this.nodeService.getType(nodeRef);
|
||||
|
||||
TypeDefinition typeDef = this.dictionaryService.getType(nodeRefType);
|
||||
for (PropertyDefinition propDef : typeDef.getProperties().values())
|
||||
{
|
||||
if (propDef.isMandatory() == true)
|
||||
{
|
||||
if (nodeRefProps.get(propDef.getName()) == null)
|
||||
{
|
||||
logMissingProperty(propDef, missingProperties);
|
||||
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result != false)
|
||||
{
|
||||
Set<QName> aspects = this.nodeService.getAspects(nodeRef);
|
||||
for (QName aspect : aspects)
|
||||
{
|
||||
AspectDefinition aspectDef = this.dictionaryService.getAspect(aspect);
|
||||
for (PropertyDefinition propDef : aspectDef.getProperties().values())
|
||||
{
|
||||
if (propDef.isMandatory() == true)
|
||||
{
|
||||
if (nodeRefProps.get(propDef.getName()) == null)
|
||||
{
|
||||
logMissingProperty(propDef, missingProperties);
|
||||
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log information about missing properties.
|
||||
*
|
||||
* @param propDef property definition
|
||||
* @param missingProperties missing properties
|
||||
*/
|
||||
private void logMissingProperty(PropertyDefinition propDef, List<String> missingProperties)
|
||||
{
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Mandatory property missing: ").append(propDef.getName());
|
||||
logger.warn(msg.toString());
|
||||
}
|
||||
missingProperties.add(propDef.getName().toString());
|
||||
}
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.action.executer.ActionExecuter;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Records management action who's implementation is delegated to an existing Action.
|
||||
* <p>
|
||||
* Useful for creating a RM version of an existing action implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class DelegateAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** Delegate action executer*/
|
||||
private ActionExecuter delegateActionExecuter;
|
||||
|
||||
/** should we check whether the node is frozen */
|
||||
private boolean checkFrozen = false;
|
||||
|
||||
/**
|
||||
* @param delegateActionExecuter delegate action executer
|
||||
*/
|
||||
public void setDelegateAction(ActionExecuter delegateActionExecuter)
|
||||
{
|
||||
this.delegateActionExecuter = delegateActionExecuter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param checkFrozen true if we check whether the actioned upon node reference is frozen, false otherwise
|
||||
*/
|
||||
public void setCheckFrozen(boolean checkFrozen)
|
||||
{
|
||||
this.checkFrozen = checkFrozen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (nodeService.exists(actionedUponNodeRef) == true &&
|
||||
(checkFrozen == false || freezeService.isFrozen(actionedUponNodeRef) == false))
|
||||
{
|
||||
// do the property subs (if any exist)
|
||||
if (allowParameterSubstitutions == true)
|
||||
{
|
||||
parameterProcessorComponent.process(action, delegateActionExecuter.getActionDefinition(), actionedUponNodeRef);
|
||||
}
|
||||
|
||||
delegateActionExecuter.execute(action, actionedUponNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#getParameterDefintions()
|
||||
*/
|
||||
@Override
|
||||
protected List<ParameterDefinition> getParameterDefintions()
|
||||
{
|
||||
return delegateActionExecuter.getActionDefinition().getParameterDefinitions();
|
||||
}
|
||||
}
|
@@ -1,240 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.RenditionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.repo.content.cleanup.EagerContentStoreCleaner;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Destroy action.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class DestroyAction extends RMDispositionActionExecuterAbstractBase
|
||||
{
|
||||
/** Action name */
|
||||
public static final String NAME = "destroy";
|
||||
|
||||
/** Eager content store cleaner */
|
||||
private EagerContentStoreCleaner eagerContentStoreCleaner;
|
||||
|
||||
/** Capability service */
|
||||
private CapabilityService capabilityService;
|
||||
|
||||
/** Indicates if ghosting is enabled or not */
|
||||
private boolean ghostingEnabled = true;
|
||||
|
||||
/**
|
||||
* @param eagerContentStoreCleaner eager content store cleaner
|
||||
*/
|
||||
public void setEagerContentStoreCleaner(EagerContentStoreCleaner eagerContentStoreCleaner)
|
||||
{
|
||||
this.eagerContentStoreCleaner = eagerContentStoreCleaner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param capabilityService capability service
|
||||
*/
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
{
|
||||
this.capabilityService = capabilityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ghostingEnabled true if ghosting is enabled, false otherwise
|
||||
*/
|
||||
public void setGhostingEnabled(boolean ghostingEnabled)
|
||||
{
|
||||
this.ghostingEnabled = ghostingEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#checkNextDispositionAction()
|
||||
*/
|
||||
@Override
|
||||
protected boolean checkNextDispositionAction(NodeRef actionedUponNodeRef)
|
||||
{
|
||||
return checkForDestroyRecordsCapability(actionedUponNodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#checkEligibility(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected boolean checkEligibility(NodeRef actionedUponNodeRef)
|
||||
{
|
||||
return checkForDestroyRecordsCapability(actionedUponNodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param actionedUponNodeRef
|
||||
* @return
|
||||
*/
|
||||
private boolean checkForDestroyRecordsCapability(NodeRef actionedUponNodeRef)
|
||||
{
|
||||
boolean result = true;
|
||||
if (AccessStatus.ALLOWED.equals(capabilityService.getCapability("DestroyRecords").hasPermission(actionedUponNodeRef)) == true)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder)
|
||||
{
|
||||
List<NodeRef> records = recordService.getRecords(recordFolder);
|
||||
for (NodeRef record : records)
|
||||
{
|
||||
executeRecordLevelDisposition(action, record);
|
||||
}
|
||||
|
||||
if (ghostingEnabled == true)
|
||||
{
|
||||
nodeService.addAspect(recordFolder, ASPECT_GHOSTED, Collections.<QName, Serializable> emptyMap());
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeService.deleteNode(recordFolder);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeRecordLevelDisposition(Action action, NodeRef record)
|
||||
{
|
||||
doDestroy(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the content destroy
|
||||
*
|
||||
* @param nodeRef
|
||||
*/
|
||||
private void doDestroy(NodeRef nodeRef)
|
||||
{
|
||||
// Clear the content
|
||||
clearAllContent(nodeRef);
|
||||
|
||||
// Clear thumbnail content
|
||||
clearThumbnails(nodeRef);
|
||||
|
||||
if (ghostingEnabled == true)
|
||||
{
|
||||
// Add the ghosted aspect
|
||||
nodeService.addAspect(nodeRef, ASPECT_GHOSTED, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If ghosting is not enabled, delete the node
|
||||
nodeService.deleteNode(nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all the content properties
|
||||
*
|
||||
* @param nodeRef
|
||||
*/
|
||||
private void clearAllContent(NodeRef nodeRef)
|
||||
{
|
||||
Set<QName> props = this.nodeService.getProperties(nodeRef).keySet();
|
||||
props.retainAll(this.dictionaryService.getAllProperties(DataTypeDefinition.CONTENT));
|
||||
for (QName prop : props)
|
||||
{
|
||||
// Clear the content
|
||||
clearContent(nodeRef, prop);
|
||||
|
||||
// Remove the property
|
||||
this.nodeService.removeProperty(nodeRef, prop);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all the thumbnail information
|
||||
*
|
||||
* @param nodeRef
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private void clearThumbnails(NodeRef nodeRef)
|
||||
{
|
||||
// Remove the renditioned aspect (and its properties and associations) if it is present.
|
||||
//
|
||||
// From Alfresco 3.3 it is the rn:renditioned aspect which defines the
|
||||
// child-association being considered in this method.
|
||||
// Note also that the cm:thumbnailed aspect extends the rn:renditioned aspect.
|
||||
//
|
||||
// We want to remove the rn:renditioned aspect, but due to the possibility
|
||||
// that there is Alfresco 3.2-era data with the cm:thumbnailed aspect
|
||||
// applied, we must consider removing it too.
|
||||
if (nodeService.hasAspect(nodeRef, RenditionModel.ASPECT_RENDITIONED) ||
|
||||
nodeService.hasAspect(nodeRef, ContentModel.ASPECT_THUMBNAILED))
|
||||
{
|
||||
// Add the ghosted aspect to all the renditioned children, so that they will not be archived when the
|
||||
// renditioned aspect is removed
|
||||
Set<QName> childAssocTypes = dictionaryService.getAspect(RenditionModel.ASPECT_RENDITIONED).getChildAssociations().keySet();
|
||||
for (ChildAssociationRef child : nodeService.getChildAssocs(nodeRef))
|
||||
{
|
||||
if (childAssocTypes.contains(child.getTypeQName()))
|
||||
{
|
||||
// Clear the content and delete the rendition
|
||||
clearAllContent(child.getChildRef());
|
||||
nodeService.deleteNode(child.getChildRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear a content property
|
||||
*
|
||||
* @param nodeRef
|
||||
* @param contentProperty
|
||||
*/
|
||||
private void clearContent(NodeRef nodeRef, QName contentProperty)
|
||||
{
|
||||
// Ensure the content is cleaned at the end of the transaction
|
||||
ContentData contentData = (ContentData)nodeService.getProperty(nodeRef, contentProperty);
|
||||
if (contentData != null && contentData.getContentUrl() != null)
|
||||
{
|
||||
eagerContentStoreCleaner.registerOrphanedContentUrl(contentData.getContentUrl(), true);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Edit review as of date action.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class EditDispositionActionAsOfDateAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_VALID_DATE_DISP_ASOF = "rm.action.valid-date-disp-asof";
|
||||
private static final String MSG_DISP_ASOF_LIFECYCLE_APPLIED = "rm.action.disp-asof-lifecycle-applied";
|
||||
|
||||
/** Action parameters */
|
||||
public static final String PARAM_AS_OF_DATE = "asOfDate";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (this.nodeService.hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE) == true)
|
||||
{
|
||||
// Get the action parameter
|
||||
Date asOfDate = (Date)action.getParameterValue(PARAM_AS_OF_DATE);
|
||||
if (asOfDate == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_VALID_DATE_DISP_ASOF));
|
||||
}
|
||||
|
||||
// Set the dispostion action as of date
|
||||
DispositionAction da = dispositionService.getNextDispositionAction(actionedUponNodeRef);
|
||||
if (da != null)
|
||||
{
|
||||
nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_AS_OF, asOfDate);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_DISP_ASOF_LIFECYCLE_APPLIED));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Edit freeze reason Action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class EditHoldReasonAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
private static final String MSG_HOLD_EDIT_REASON_NONE = "rm.action.hold-edit-reason-none";
|
||||
private static final String MSG_HOLD_EDIT_TYPE = "rm.action.hold-edit-type";
|
||||
|
||||
/** Parameter names */
|
||||
public static final String PARAM_REASON = "reason";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (freezeService.isHold(actionedUponNodeRef))
|
||||
{
|
||||
// Get the property values
|
||||
String reason = (String) action.getParameterValue(PARAM_REASON);
|
||||
if (StringUtils.isBlank(reason))
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_HOLD_EDIT_REASON_NONE));
|
||||
}
|
||||
|
||||
// Update hold reason
|
||||
freezeService.updateReason(actionedUponNodeRef, reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_HOLD_EDIT_TYPE, TYPE_HOLD.toString(), actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* Edit review as of date action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class EditReviewAsOfDateAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_SPECIFY_VALID_DATE = "rm.action.specify-avlid-date";
|
||||
private static final String MSG_REVIEW_DETAILS_ONLY = "rm.action.review-details-only";
|
||||
|
||||
public static final String PARAM_AS_OF_DATE = "asOfDate";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (recordService.isRecord(actionedUponNodeRef) == true &&
|
||||
nodeService.hasAspect(actionedUponNodeRef, ASPECT_VITAL_RECORD) == true)
|
||||
{
|
||||
// Get the action parameter
|
||||
Date reviewAsOf = (Date)action.getParameterValue(PARAM_AS_OF_DATE);
|
||||
if (reviewAsOf == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_SPECIFY_VALID_DATE));
|
||||
}
|
||||
|
||||
// Set the as of date
|
||||
this.nodeService.setProperty(actionedUponNodeRef, PROP_REVIEW_AS_OF, reviewAsOf);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_REVIEW_DETAILS_ONLY));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,239 +0,0 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* File To action implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class FileToAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** action name */
|
||||
public static final String NAME = "fileTo";
|
||||
|
||||
/** action parameters */
|
||||
public static final String PARAM_DESTINATION_RECORD_FOLDER = "destinationRecordFolder";
|
||||
public static final String PARAM_PATH = "path";
|
||||
public static final String PARAM_CREATE_RECORD_FOLDER = "createRecordFolder";
|
||||
|
||||
/** file folder service */
|
||||
private FileFolderService fileFolderService;
|
||||
|
||||
/** file plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/**
|
||||
* @param fileFolderService file folder service
|
||||
*/
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_PATH, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_PATH)));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_CREATE_RECORD_FOLDER, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_CREATE_RECORD_FOLDER)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (nodeService.exists(actionedUponNodeRef) == true &&
|
||||
freezeService.isFrozen(actionedUponNodeRef) == false)
|
||||
{
|
||||
if (recordService.isFiled(actionedUponNodeRef) == false)
|
||||
{
|
||||
// first look to see if the destination record folder has been specified
|
||||
NodeRef recordFolder = (NodeRef)action.getParameterValue(PARAM_DESTINATION_RECORD_FOLDER);
|
||||
if (recordFolder == null)
|
||||
{
|
||||
// get the reference to the record folder based on the relative path
|
||||
recordFolder = createOrResolveRecordFolder(action, actionedUponNodeRef);
|
||||
}
|
||||
|
||||
if (recordFolder == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to execute file to action, because the destination record folder could not be determined.");
|
||||
}
|
||||
|
||||
if (recordFolderService.isRecordFolder(recordFolder) == true)
|
||||
{
|
||||
final NodeRef finalRecordFolder = recordFolder;
|
||||
try
|
||||
{
|
||||
fileFolderService.move(actionedUponNodeRef, finalRecordFolder, null);
|
||||
}
|
||||
catch (FileNotFoundException fileNotFound)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to execute file to action, because the move operation failed.", fileNotFound);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to execute file to action, becuase the destination was not a record folder.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param action
|
||||
* @param actionedUponNodeRef
|
||||
* @return
|
||||
*/
|
||||
private NodeRef createOrResolveRecordFolder(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
// TODO check the action for a context node reference
|
||||
// the file plan node always provides the context
|
||||
NodeRef context = filePlanService.getFilePlan(actionedUponNodeRef);
|
||||
if (context == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to execute fileTo action, because the path resolution context could not be found.");
|
||||
}
|
||||
else if (nodeService.exists(context) == false)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to execute fileTo action, because the context for the relative path does not exist.");
|
||||
}
|
||||
|
||||
// look for the path parameter
|
||||
String path = (String)action.getParameterValue(PARAM_PATH);
|
||||
String[] pathValues = ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
|
||||
if (path != null && path.isEmpty() == false)
|
||||
{
|
||||
pathValues = StringUtils.tokenizeToStringArray(path, "/", false, true);
|
||||
}
|
||||
|
||||
// look for the creation strategy
|
||||
boolean create = false;
|
||||
Boolean createValue = (Boolean)action.getParameterValue(PARAM_CREATE_RECORD_FOLDER);
|
||||
if (createValue != null)
|
||||
{
|
||||
create = createValue.booleanValue();
|
||||
}
|
||||
|
||||
// try and get child
|
||||
NodeRef recordFolder = resolvePath(context, pathValues);
|
||||
|
||||
if (recordFolder == null)
|
||||
{
|
||||
if (create == true)
|
||||
{
|
||||
// get the parent into which we are going to create the new record folder
|
||||
NodeRef parent = resolveParent(context, pathValues);
|
||||
if (parent == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to create new record folder, because destination parent could not be found.");
|
||||
}
|
||||
|
||||
// ensure we are trying to create a record folder in a record category
|
||||
if (filePlanService.isRecordCategory(parent) == false)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to create nre record folder, beacuse the parent is not a record category.");
|
||||
}
|
||||
|
||||
// get the new record folders name
|
||||
String recordFolderName = pathValues[pathValues.length-1];
|
||||
recordFolder = recordFolderService.createRecordFolder(parent, recordFolderName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to execute FileTo action, because the destination record folder does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
return recordFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context
|
||||
* @param pathValues
|
||||
* @return
|
||||
*/
|
||||
private NodeRef resolvePath(final NodeRef context, final String[] pathValues)
|
||||
{
|
||||
NodeRef result = null;
|
||||
FileInfo fileInfo = null;
|
||||
try
|
||||
{
|
||||
fileInfo = fileFolderService.resolveNamePath(context, new ArrayList<String>(Arrays.asList(pathValues)), false);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
// ignore, checking for null
|
||||
}
|
||||
if (fileInfo != null)
|
||||
{
|
||||
result = fileInfo.getNodeRef();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context
|
||||
* @param pathValues
|
||||
* @return
|
||||
*/
|
||||
private NodeRef resolveParent(NodeRef context, String[] pathValues)
|
||||
{
|
||||
NodeRef result = null;
|
||||
|
||||
if (ArrayUtils.isEmpty(pathValues) == true)
|
||||
{
|
||||
// this should never occur since if the path is empty then the context it the resolution of the
|
||||
// path .. the context must already exist
|
||||
throw new AlfrescoRuntimeException("Unable to resolve the parent, because no valid path was specified.");
|
||||
}
|
||||
else if (pathValues.length == 1)
|
||||
{
|
||||
// the context is the parent
|
||||
result = context;
|
||||
}
|
||||
else
|
||||
{
|
||||
pathValues = (String[])ArrayUtils.remove(pathValues, pathValues.length-1);
|
||||
result = resolvePath(context, pathValues);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Freeze Action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class FreezeAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** Parameter names */
|
||||
public static final String PARAM_REASON = "reason";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_REASON, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_REASON)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
// NOTE: we can only freeze records and record folders so ignore everything else
|
||||
if (nodeService.exists(actionedUponNodeRef) == true &&
|
||||
nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_PENDING_DELETE) == false &&
|
||||
(recordService.isRecord(actionedUponNodeRef) == true ||
|
||||
recordFolderService.isRecordFolder(actionedUponNodeRef) == true) &&
|
||||
freezeService.isFrozen(actionedUponNodeRef) == false)
|
||||
{
|
||||
freezeService.freeze((String) action.getParameterValue(PARAM_REASON), actionedUponNodeRef);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Action to re-open the records folder
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class OpenRecordFolderAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(OpenRecordFolderAction.class);
|
||||
|
||||
/** I18N */
|
||||
private static final String MSG_NO_OPEN_RECORD_FOLDER = "rm.action.no-open-record-folder";
|
||||
|
||||
/** Parameter names */
|
||||
public static final String PARAM_OPEN_PARENT = "openParent";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (nodeService.exists(actionedUponNodeRef) == true &&
|
||||
freezeService.isFrozen(actionedUponNodeRef) == false)
|
||||
{
|
||||
// TODO move re-open logic into a service method
|
||||
// TODO check that the user in question has the correct permission to re-open a records folder
|
||||
|
||||
if (recordService.isRecord(actionedUponNodeRef))
|
||||
{
|
||||
ChildAssociationRef assocRef = nodeService.getPrimaryParent(actionedUponNodeRef);
|
||||
if (assocRef != null)
|
||||
{
|
||||
actionedUponNodeRef = assocRef.getParentRef();
|
||||
}
|
||||
}
|
||||
|
||||
if (recordFolderService.isRecordFolder(actionedUponNodeRef) == true)
|
||||
{
|
||||
Boolean isClosed = (Boolean) nodeService.getProperty(actionedUponNodeRef, PROP_IS_CLOSED);
|
||||
if (Boolean.TRUE.equals(isClosed) == true)
|
||||
{
|
||||
nodeService.setProperty(actionedUponNodeRef, PROP_IS_CLOSED, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isWarnEnabled())
|
||||
logger.warn(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Reject action for an unfiled record
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RejectAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** Parameter names */
|
||||
public static final String PARAM_REASON = "reason";
|
||||
|
||||
/** Action name */
|
||||
public static final String NAME = "reject";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (nodeService.exists(actionedUponNodeRef) == true &&
|
||||
freezeService.isFrozen(actionedUponNodeRef) == false &&
|
||||
nodeService.getProperty(actionedUponNodeRef, PROP_RECORD_ORIGINATING_LOCATION) != null)
|
||||
{
|
||||
recordService.rejectRecord(actionedUponNodeRef, (String) action.getParameterValue(PARAM_REASON));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_REASON, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_REASON)));
|
||||
}
|
||||
}
|
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Relinquish Hold Action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RelinquishHoldAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_NOT_HOLD_TYPE = "rm.action.not-hold-type";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (freezeService.isHold(actionedUponNodeRef))
|
||||
{
|
||||
freezeService.relinquish(actionedUponNodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_HOLD_TYPE, TYPE_HOLD.toString(), actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.repo.workflow.WorkflowModel;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.workflow.RMWorkflowModel;
|
||||
import org.apache.axis.utils.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Request info action for starting a workflow to request more information for an undeclared record
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RequestInfoAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(RequestInfoAction.class);
|
||||
|
||||
/** Parameter names */
|
||||
public static final String PARAM_REQUESTED_INFO = "requestedInfo";
|
||||
public static final String PARAM_ASSIGNEES = "assignees";
|
||||
public static final String PARAM_RULE_CREATOR = "ruleCreator";
|
||||
|
||||
/** Action name */
|
||||
public static final String NAME = "requestInfo";
|
||||
|
||||
/** Workflow definition name */
|
||||
private static final String REQUEST_INFO_WORKFLOW_DEFINITION_NAME = "activiti$activitiRequestForInformation";
|
||||
|
||||
/** Workflow service */
|
||||
private WorkflowService workflowService;
|
||||
|
||||
/**
|
||||
* @param workflowService workflow service
|
||||
*/
|
||||
public void setWorkflowService(WorkflowService workflowService)
|
||||
{
|
||||
this.workflowService = workflowService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (nodeService.exists(actionedUponNodeRef) == true &&
|
||||
nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_PENDING_DELETE) == false &&
|
||||
recordService.isRecord(actionedUponNodeRef) == true &&
|
||||
recordService.isDeclared(actionedUponNodeRef) == false)
|
||||
{
|
||||
String workflowDefinitionId = workflowService.getDefinitionByName(REQUEST_INFO_WORKFLOW_DEFINITION_NAME).getId();
|
||||
Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
|
||||
|
||||
parameters.put(WorkflowModel.ASSOC_PACKAGE, getWorkflowPackage(action, actionedUponNodeRef));
|
||||
parameters.put(RMWorkflowModel.RM_MIXED_ASSIGNEES, getAssignees(action));
|
||||
parameters.put(RMWorkflowModel.RM_REQUESTED_INFORMATION, getRequestedInformation(action));
|
||||
parameters.put(RMWorkflowModel.RM_RULE_CREATOR, getRuleCreator(action));
|
||||
|
||||
workflowService.startWorkflow(workflowDefinitionId, parameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.info("Can't start the request information workflow for node '" + actionedUponNodeRef.toString() + "'." );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_REQUESTED_INFO, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_REQUESTED_INFO)));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_ASSIGNEES, DataTypeDefinition.ANY, true, getParamDisplayLabel(PARAM_ASSIGNEES)));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_RULE_CREATOR, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_RULE_CREATOR)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for creating a workflow package to contain the actioned upon nodeRef
|
||||
*
|
||||
* @param action The request info action
|
||||
* @param actionedUponNodeRef The actioned upon nodeRef
|
||||
* @return Returns a workflow package containing the actioned upon nodeRef
|
||||
*/
|
||||
private NodeRef getWorkflowPackage(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
NodeRef workflowPackage = (NodeRef) action.getParameterValue(WorkflowModel.ASSOC_PACKAGE.toPrefixString(namespaceService));
|
||||
workflowPackage = workflowService.createPackage(workflowPackage);
|
||||
ChildAssociationRef childAssoc = nodeService.getPrimaryParent(actionedUponNodeRef);
|
||||
nodeService.addChild(workflowPackage, actionedUponNodeRef, WorkflowModel.ASSOC_PACKAGE_CONTAINS, childAssoc.getQName());
|
||||
return workflowPackage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for getting the assignees from the action
|
||||
*
|
||||
* @param action The request info action
|
||||
* @return Returns a list of {@link NodeRef}s each representing the assignee
|
||||
*/
|
||||
private Serializable getAssignees(Action action)
|
||||
{
|
||||
List<NodeRef> assigneesList = new ArrayList<NodeRef>();
|
||||
String assigneesAsString = (String) action.getParameterValue(PARAM_ASSIGNEES);
|
||||
String[] assignees = StringUtils.split(assigneesAsString, ',');
|
||||
for (String assignee : assignees)
|
||||
{
|
||||
assigneesList.add(new NodeRef(assignee));
|
||||
}
|
||||
return (Serializable) assigneesList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for getting the requested information from the action
|
||||
*
|
||||
* @param action The request info action
|
||||
* @return Returns the requested information
|
||||
*/
|
||||
private Serializable getRequestedInformation(Action action)
|
||||
{
|
||||
return action.getParameterValue(PARAM_REQUESTED_INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for getting the rule creator
|
||||
*
|
||||
* @param action The request info action
|
||||
* @return Returns the rule creator
|
||||
*/
|
||||
private Serializable getRuleCreator(Action action)
|
||||
{
|
||||
return action.getParameterValue(PARAM_RULE_CREATOR);
|
||||
}
|
||||
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Retain action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RetainAction extends RMDispositionActionExecuterAbstractBase
|
||||
{
|
||||
@Override
|
||||
protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeRecordLevelDisposition(Action action, NodeRef record)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
@@ -1,261 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Multipart;
|
||||
import javax.mail.Part;
|
||||
import javax.mail.internet.ContentType;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeUtility;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.ImapModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
/**
|
||||
* Split Email Action
|
||||
*
|
||||
* Splits the attachments for an email message out to independent records.
|
||||
*
|
||||
* @author Mark Rogers
|
||||
*/
|
||||
public class SplitEmailAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_NO_READ_MIME_MESSAGE = "rm.action.no-read-mime-message";
|
||||
private static final String MSG_EMAIL_DECLARED = "rm.action.email-declared";
|
||||
private static final String MSG_EMAIL_NOT_RECORD = "rm.action.email-not-record";
|
||||
|
||||
/** Relationship Labels */
|
||||
private static final String REL_FROM = "Message";
|
||||
private static final String REL_TO = "Attachment";
|
||||
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(SplitEmailAction.class);
|
||||
|
||||
private QName relationshipQName;
|
||||
|
||||
public void bootstrap()
|
||||
{
|
||||
String compoundId = recordsManagementAdminService.getCompoundIdFor(REL_FROM, REL_TO);
|
||||
|
||||
Map<QName, AssociationDefinition> map = recordsManagementAdminService.getCustomReferenceDefinitions();
|
||||
for (Map.Entry<QName, AssociationDefinition> entry : map.entrySet())
|
||||
{
|
||||
if (compoundId.equals(entry.getValue().getTitle(dictionaryService)) == true)
|
||||
{
|
||||
relationshipQName = entry.getKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (relationshipQName == null)
|
||||
{
|
||||
relationshipQName = recordsManagementAdminService.addCustomChildAssocDefinition(REL_FROM, REL_TO);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
// get node type
|
||||
nodeService.getType(actionedUponNodeRef);
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("split email:" + actionedUponNodeRef);
|
||||
}
|
||||
|
||||
if (recordService.isRecord(actionedUponNodeRef) == true)
|
||||
{
|
||||
if (recordService.isDeclared(actionedUponNodeRef) == false)
|
||||
{
|
||||
ChildAssociationRef parent = nodeService.getPrimaryParent(actionedUponNodeRef);
|
||||
|
||||
/**
|
||||
* Check whether the email message has already been split - do nothing if it has already been split
|
||||
*/
|
||||
List<AssociationRef> refs = nodeService.getTargetAssocs(actionedUponNodeRef, ImapModel.ASSOC_IMAP_ATTACHMENT);
|
||||
if(refs.size() > 0)
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("mail message has already been split - do nothing");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content and if its a mime message then create atachments for each part
|
||||
*/
|
||||
try
|
||||
{
|
||||
ContentReader reader = contentService.getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT);
|
||||
InputStream is = reader.getContentInputStream();
|
||||
MimeMessage mimeMessage = new MimeMessage(null, is);
|
||||
Object content = mimeMessage.getContent();
|
||||
if (content instanceof Multipart)
|
||||
{
|
||||
Multipart multipart = (Multipart)content;
|
||||
|
||||
for (int i = 0, n = multipart.getCount(); i < n; i++)
|
||||
{
|
||||
Part part = multipart.getBodyPart(i);
|
||||
if ("attachment".equalsIgnoreCase(part.getDisposition()))
|
||||
{
|
||||
createAttachment(actionedUponNodeRef, parent.getParentRef(), part);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_READ_MIME_MESSAGE, e.toString()), e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_DECLARED, actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_NOT_RECORD, actionedUponNodeRef.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create attachment from Mime Message Part
|
||||
* @param messageNodeRef - the node ref of the mime message
|
||||
* @param parentNodeRef - the node ref of the parent folder
|
||||
* @param part
|
||||
* @throws MessagingException
|
||||
* @throws IOException
|
||||
*/
|
||||
private void createAttachment(NodeRef messageNodeRef, NodeRef parentNodeRef, Part part) throws MessagingException, IOException
|
||||
{
|
||||
String fileName = part.getFileName();
|
||||
try
|
||||
{
|
||||
fileName = MimeUtility.decodeText(fileName);
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("Cannot decode file name '" + fileName + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
Map<QName, Serializable> messageProperties = nodeService.getProperties(messageNodeRef);
|
||||
String messageTitle = (String)messageProperties.get(ContentModel.PROP_NAME);
|
||||
if(messageTitle == null)
|
||||
{
|
||||
messageTitle = fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
messageTitle = messageTitle + " - " + fileName;
|
||||
}
|
||||
|
||||
ContentType contentType = new ContentType(part.getContentType());
|
||||
|
||||
Map<QName, Serializable> docProps = new HashMap<QName, Serializable>(1);
|
||||
docProps.put(ContentModel.PROP_NAME, messageTitle + " - " + fileName);
|
||||
docProps.put(ContentModel.PROP_TITLE, fileName);
|
||||
|
||||
/**
|
||||
* Create an attachment node in the same folder as the message
|
||||
*/
|
||||
ChildAssociationRef attachmentRef = nodeService.createNode(parentNodeRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, fileName),
|
||||
ContentModel.TYPE_CONTENT,
|
||||
docProps);
|
||||
|
||||
/**
|
||||
* Write the content into the new attachment node
|
||||
*/
|
||||
ContentWriter writer = contentService.getWriter(attachmentRef.getChildRef(), ContentModel.PROP_CONTENT, true);
|
||||
writer.setMimetype(contentType.getBaseType());
|
||||
OutputStream os = writer.getContentOutputStream();
|
||||
FileCopyUtils.copy(part.getInputStream(), os);
|
||||
|
||||
/**
|
||||
* Create a link from the message to the attachment
|
||||
*/
|
||||
createRMReference(messageNodeRef, attachmentRef.getChildRef());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a link from the message to the attachment
|
||||
*/
|
||||
private void createRMReference(final NodeRef parentRef, final NodeRef childRef)
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// add the relationship
|
||||
recordsManagementAdminService.addCustomReference(parentRef, childRef, relationshipQName);
|
||||
|
||||
// add the IMAP attachment aspect
|
||||
nodeService.createAssociation(
|
||||
parentRef,
|
||||
childRef,
|
||||
ImapModel.ASSOC_IMAP_ATTACHMENT);
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService;
|
||||
import org.alfresco.repo.action.executer.ActionExecuter;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Transfer action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class TransferAction extends RMDispositionActionExecuterAbstractBase
|
||||
{
|
||||
/** Action name */
|
||||
public static final String NAME = "transfer";
|
||||
|
||||
/** Indicates whether the transfer is an accession or not */
|
||||
private boolean isAccession = false;
|
||||
|
||||
/** transfer service */
|
||||
private TransferService transferService;
|
||||
|
||||
/**
|
||||
* Indicates whether this transfer is an accession or not
|
||||
*
|
||||
* @param isAccession
|
||||
*/
|
||||
public void setIsAccession(boolean isAccession)
|
||||
{
|
||||
this.isAccession = isAccession;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param transferService transfer service
|
||||
*/
|
||||
public void setTransferService(TransferService transferService)
|
||||
{
|
||||
this.transferService = transferService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not set the transfer action to auto-complete
|
||||
*
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#getSetDispositionActionComplete()
|
||||
*/
|
||||
@Override
|
||||
public boolean getSetDispositionActionComplete()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder)
|
||||
{
|
||||
doTransfer(action, recordFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeRecordLevelDisposition(Action action, NodeRef record)
|
||||
{
|
||||
doTransfer(action, record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the transfer node and link the disposition lifecycle node beneath it
|
||||
*
|
||||
* @param action action
|
||||
* @param dispositionLifeCycleNodeRef disposition lifecycle node
|
||||
*/
|
||||
private void doTransfer(Action action, NodeRef dispositionLifeCycleNodeRef)
|
||||
{
|
||||
NodeRef transferNodeRef = transferService.transfer(dispositionLifeCycleNodeRef, isAccession);
|
||||
|
||||
// Set the return value of the action
|
||||
action.setParameterValue(ActionExecuter.PARAM_RESULT, transferNodeRef);
|
||||
}
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.transfer.TransferService;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Transfer complete action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class TransferCompleteAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_NODE_NOT_TRANSFER = "rm.action.node-not-transfer";
|
||||
|
||||
/** Transfer service */
|
||||
protected TransferService transferService;
|
||||
|
||||
/**
|
||||
* @param transferService transfer service
|
||||
*/
|
||||
public void setTransferService(TransferService transferService)
|
||||
{
|
||||
this.transferService = transferService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
|
||||
* org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
checkTransferSubClass(actionedUponNodeRef);
|
||||
transferService.completeTransfer(actionedUponNodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the actioned upon node reference is a sub class of transfer
|
||||
*
|
||||
* @param actionedUponNodeRef actioned upon node reference
|
||||
*/
|
||||
private void checkTransferSubClass(NodeRef actionedUponNodeRef)
|
||||
{
|
||||
QName type = nodeService.getType(actionedUponNodeRef);
|
||||
if (dictionaryService.isSubClass(type, TYPE_TRANSFER) == false)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_NOT_TRANSFER));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* UnCutoff action implementation
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class UnCutoffAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_UNDO_NOT_LAST = "rm.action.undo-not-last";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE) == true &&
|
||||
nodeService.hasAspect(actionedUponNodeRef, ASPECT_CUT_OFF) == true)
|
||||
{
|
||||
// Get the last disposition action
|
||||
DispositionAction da = dispositionService.getLastCompletedDispostionAction(actionedUponNodeRef);
|
||||
|
||||
// Check that the last disposition action was a cutoff
|
||||
if (da == null || da.getName().equals("cutoff") == false)
|
||||
{
|
||||
// Can not undo cut off since cut off was not the last thing done
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNDO_NOT_LAST));
|
||||
}
|
||||
|
||||
// Remove the cutoff aspect
|
||||
nodeService.removeAspect(actionedUponNodeRef, ASPECT_CUT_OFF);
|
||||
if (recordFolderService.isRecordFolder(actionedUponNodeRef) == true)
|
||||
{
|
||||
List<NodeRef> records = recordService.getRecords(actionedUponNodeRef);
|
||||
for (NodeRef record : records)
|
||||
{
|
||||
nodeService.removeAspect(record, ASPECT_CUT_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the current disposition action
|
||||
DispositionAction currentDa = dispositionService.getNextDispositionAction(actionedUponNodeRef);
|
||||
if (currentDa != null)
|
||||
{
|
||||
nodeService.deleteNode(currentDa.getNodeRef());
|
||||
}
|
||||
|
||||
// Move the previous (cutoff) disposition back to be current
|
||||
nodeService.moveNode(da.getNodeRef(), actionedUponNodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION);
|
||||
|
||||
// Reset the started and completed property values
|
||||
nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_STARTED_AT, null);
|
||||
nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_STARTED_BY, null);
|
||||
nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_AT, null);
|
||||
nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_BY, null);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Undeclare record action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class UndeclareRecordAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(UndeclareRecordAction.class);
|
||||
|
||||
/** I18N */
|
||||
private static final String MSG_RECORDS_ONLY_UNDECLARED = "rm.action.records_only_undeclared";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
if (nodeService.exists(actionedUponNodeRef) == true)
|
||||
{
|
||||
if (recordService.isRecord(actionedUponNodeRef) == true)
|
||||
{
|
||||
// repoen if already complete and not frozen
|
||||
if (recordService.isDeclared(actionedUponNodeRef) == true &&
|
||||
freezeService.isFrozen(actionedUponNodeRef) == false)
|
||||
{
|
||||
// Remove the declared aspect
|
||||
this.nodeService.removeAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn(I18NUtil.getMessage(MSG_RECORDS_ONLY_UNDECLARED));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Undo event action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class UndoEventAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_EVENT_NOT_DONE = "rm.action.event-not-undone";
|
||||
|
||||
/** Params */
|
||||
public static final String PARAM_EVENT_NAME = "eventName";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME);
|
||||
|
||||
if (this.nodeService.hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE) == true)
|
||||
{
|
||||
// Get the next disposition action
|
||||
DispositionAction da = this.dispositionService.getNextDispositionAction(actionedUponNodeRef);
|
||||
if (da != null)
|
||||
{
|
||||
// Get the disposition event
|
||||
EventCompletionDetails event = getEvent(da, eventName);
|
||||
if (event != null)
|
||||
{
|
||||
// Update the event so that it is undone
|
||||
NodeRef eventNodeRef = event.getNodeRef();
|
||||
Map<QName, Serializable> props = this.nodeService.getProperties(eventNodeRef);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETE, false);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, null);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, null);
|
||||
this.nodeService.setProperties(eventNodeRef, props);
|
||||
|
||||
// Check to see if the events eligible property needs to be updated
|
||||
updateEventEigible(da);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EVENT_NOT_DONE, eventName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event from the disposition action
|
||||
*
|
||||
* @param da
|
||||
* @param eventName
|
||||
* @return
|
||||
*/
|
||||
private EventCompletionDetails getEvent(DispositionAction da, String eventName)
|
||||
{
|
||||
EventCompletionDetails result = null;
|
||||
List<EventCompletionDetails> events = da.getEventCompletionDetails();
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (eventName.equals(event.getEventName()) == true)
|
||||
{
|
||||
result = event;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param da
|
||||
* @param nodeRef
|
||||
*/
|
||||
private void updateEventEigible(DispositionAction da)
|
||||
{
|
||||
List<EventCompletionDetails> events = da.getEventCompletionDetails();
|
||||
|
||||
boolean eligible = false;
|
||||
if (da.getDispositionActionDefinition().eligibleOnFirstCompleteEvent() == false)
|
||||
{
|
||||
eligible = true;
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (event.isEventComplete() == false)
|
||||
{
|
||||
eligible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (event.isEventComplete() == true)
|
||||
{
|
||||
eligible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the property with the eligible value
|
||||
this.nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE, eligible);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
// TODO add parameter definitions ....
|
||||
// eventName
|
||||
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Unfreeze Action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class UnfreezeAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
freezeService.unFreeze(actionedUponNodeRef);
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.admin;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Custom metadata exception.
|
||||
*
|
||||
* @author Roy Wethearll
|
||||
* @since 2.1
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.CannotApplyConstraintMetadataException
|
||||
*/
|
||||
public class CannotApplyConstraintMetadataException extends CustomMetadataException
|
||||
{
|
||||
private static final long serialVersionUID = -6194867814140009959L;
|
||||
public static final String MSG_CANNOT_APPLY_CONSTRAINT = "rm.admin.cannot-apply-constraint";
|
||||
|
||||
public CannotApplyConstraintMetadataException(QName lovConstraint, String propIdAsString, QName dataType)
|
||||
{
|
||||
super(I18NUtil.getMessage(CannotApplyConstraintMetadataException.MSG_CANNOT_APPLY_CONSTRAINT, lovConstraint, propIdAsString, dataType));
|
||||
}
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.admin;
|
||||
|
||||
/**
|
||||
* Custom metadata exception.
|
||||
*
|
||||
* @author Roy Wethearll
|
||||
* @since 2.1
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.CustomMetadataException
|
||||
*/
|
||||
public abstract class CustomMetadataException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = -6676112294794381360L;
|
||||
|
||||
public CustomMetadataException(String msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.admin;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Custom metadata exception.
|
||||
*
|
||||
* @author Roy Wethearll
|
||||
* @since 2.1
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.InvalidCustomAspectMetadataException
|
||||
*/
|
||||
public class InvalidCustomAspectMetadataException extends CustomMetadataException
|
||||
{
|
||||
private static final long serialVersionUID = -6194867814140009959L;
|
||||
public static final String MSG_INVALID_CUSTOM_ASPECT = "rm.admin.invalid-custom-aspect";
|
||||
|
||||
public InvalidCustomAspectMetadataException(QName customAspect, String aspectName)
|
||||
{
|
||||
super(I18NUtil.getMessage(MSG_INVALID_CUSTOM_ASPECT, customAspect, aspectName));
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.admin;
|
||||
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Custom metadata exception.
|
||||
*
|
||||
* @author Roy Wethearll
|
||||
* @since 2.1
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.NotCustomisableMetadataException
|
||||
*/
|
||||
public class NotCustomisableMetadataException extends CustomMetadataException
|
||||
{
|
||||
private static final long serialVersionUID = -6194867814140009959L;
|
||||
public static final String MSG_NOT_CUSTOMISABLE = "rm.admin.not-customisable";
|
||||
|
||||
public NotCustomisableMetadataException(String aspectName)
|
||||
{
|
||||
super(I18NUtil.getMessage(MSG_NOT_CUSTOMISABLE, aspectName));
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.admin;
|
||||
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Custom metadata exception.
|
||||
*
|
||||
* @author Roy Wethearll
|
||||
* @since 2.1
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.PropertyAlreadyExistsMetadataException
|
||||
*/
|
||||
public class PropertyAlreadyExistsMetadataException extends CustomMetadataException
|
||||
{
|
||||
private static final long serialVersionUID = -6194867814140009959L;
|
||||
|
||||
public static final String MSG_PROPERTY_ALREADY_EXISTS = "rm.admin.property-already-exists";
|
||||
|
||||
public PropertyAlreadyExistsMetadataException(String propIdAsString)
|
||||
{
|
||||
super(I18NUtil.getMessage(MSG_PROPERTY_ALREADY_EXISTS, propIdAsString));
|
||||
}
|
||||
}
|
@@ -1,409 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.admin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Records management custom model service interface. Implementations of this class are responsible
|
||||
* for the creation and maintenance of RM-related custom properties and custom associations.
|
||||
*
|
||||
* @author Neil McErlean, janv
|
||||
* @since 2.1
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService
|
||||
*/
|
||||
public interface RecordsManagementAdminService
|
||||
{
|
||||
/**
|
||||
* Initialise the custom model
|
||||
*/
|
||||
public void initialiseCustomModel();
|
||||
|
||||
/**
|
||||
* Get a list of all registered customisable types and aspects.
|
||||
*
|
||||
* @return {@link Set}<{@link QName}> QName's of customisable types and aspects
|
||||
*/
|
||||
public Set<QName> getCustomisable();
|
||||
|
||||
/**
|
||||
* Get a list of all the registered customisable types and aspects present on a given
|
||||
* node reference.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return {@link Set}<{@link QName}> QName's of customisable types and aspects, empty if none
|
||||
*/
|
||||
public Set<QName> getCustomisable(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Indicates whether a type (or aspect) is customisable.
|
||||
*
|
||||
* @param type customisable type {@link QName}
|
||||
* @return boolean true if type customisable, false otherwise
|
||||
*/
|
||||
public boolean isCustomisable(QName type);
|
||||
|
||||
/**
|
||||
* Makes a type customisable.
|
||||
*
|
||||
* @param type type {@link QName} to make customisable
|
||||
*/
|
||||
public void makeCustomisable(QName type);
|
||||
|
||||
/**
|
||||
* Assuming the custom properties are not in use, makes a type no longer customisable.
|
||||
*
|
||||
* @param type type {@link QName} to make customisable
|
||||
*/
|
||||
public void unmakeCustomisable(QName type);
|
||||
|
||||
/**
|
||||
* Indicates whether the custom property exists.
|
||||
*
|
||||
* @param property properties {@link QName}
|
||||
* @return boolean true if property exists, false otherwise
|
||||
*/
|
||||
public boolean existsCustomProperty(QName property);
|
||||
|
||||
/**
|
||||
* This method returns the custom properties that have been defined for the specified
|
||||
* customisable RM element.
|
||||
* <P/>
|
||||
* Note: the custom property definitions are retrieved from the dictionaryService
|
||||
* which is notified of any newly created definitions on transaction commit.
|
||||
* Therefore custom properties created in the current transaction will not appear
|
||||
* in the result of this method.
|
||||
*
|
||||
* @param customisedElement
|
||||
* @return
|
||||
* @see CustomisableRmElement
|
||||
*/
|
||||
public Map<QName, PropertyDefinition> getCustomPropertyDefinitions(QName customisableType);
|
||||
|
||||
/**
|
||||
* This method returns the custom properties that have been defined for all of
|
||||
* the specified customisable RM elements.
|
||||
* Note: the custom property definitions are retrieved from the dictionaryService
|
||||
* which is notified of any newly created definitions on transaction commit.
|
||||
* Therefore custom properties created in the current transaction will not appear
|
||||
* in the result of this method.
|
||||
*
|
||||
* @return
|
||||
* @see CustomisableRmElement
|
||||
*/
|
||||
public Map<QName, PropertyDefinition> getCustomPropertyDefinitions();
|
||||
|
||||
/**
|
||||
* Add custom property definition
|
||||
*
|
||||
* Note: no default value, single valued, optional, not system protected, no constraints
|
||||
*
|
||||
* @param propId - If a value for propId is provided it will be used to identify property definitions
|
||||
* within URLs and in QNames. Therefore it must contain URL/QName-valid characters
|
||||
* only. It must also be unique.
|
||||
* If a null value is passed, an id will be generated.
|
||||
* @param aspectName - mandatory. The aspect within which the property is to be defined.
|
||||
* This must be one of the CustomisableRmElements.
|
||||
* @param label - mandatory
|
||||
* @param dataType - mandatory
|
||||
* @param title - optional
|
||||
* @param description - optional
|
||||
*
|
||||
* @return the propId, whether supplied as a parameter or generated.
|
||||
* @see CustomisableRmElement#getCorrespondingAspect()
|
||||
*/
|
||||
public QName addCustomPropertyDefinition(QName propId, QName typeName, String label, QName dataType, String title, String description) throws CustomMetadataException;
|
||||
|
||||
/**
|
||||
* Add custom property definition with one optional constraint reference
|
||||
*
|
||||
* @param propId - If a value for propId is provided it will be used to identify property definitions
|
||||
* within URLs and in QNames. Therefore it must contain URL/QName-valid characters
|
||||
* only. It must also be unique.
|
||||
* If a null value is passed, an id will be generated.
|
||||
* @param aspectName - mandatory. The aspect within which the property is to be defined.
|
||||
* This must be one of the CustomisableRmElements.
|
||||
* @param label - mandatory
|
||||
* @param dataType - mandatory
|
||||
* @param title - optional
|
||||
* @param description - optional
|
||||
* @param defaultValue - optional
|
||||
* @param multiValued - TRUE if multi-valued property
|
||||
* @param mandatory - TRUE if mandatory property
|
||||
* @param isProtected - TRUE if protected property
|
||||
* @param lovConstraintQName - optional custom constraint
|
||||
*
|
||||
* @return the propId, whether supplied as a parameter or generated.
|
||||
* @see CustomisableRmElement#getCorrespondingAspect()
|
||||
*/
|
||||
|
||||
// TODO propId string (not QName) ?
|
||||
// TODO remove title (since it is ignored) (or remove label to title)
|
||||
|
||||
public QName addCustomPropertyDefinition(QName propId,
|
||||
QName typeName,
|
||||
String label,
|
||||
QName dataType,
|
||||
String title,
|
||||
String description,
|
||||
String defaultValue,
|
||||
boolean multiValued,
|
||||
boolean mandatory,
|
||||
boolean isProtected,
|
||||
QName lovConstraintQName) throws CustomMetadataException;
|
||||
|
||||
/**
|
||||
* Update the custom property definition's label (title).
|
||||
*
|
||||
* @param propQName the qname of the property definition
|
||||
* @param newLabel the new value for the label.
|
||||
* @return the propId.
|
||||
*/
|
||||
public QName setCustomPropertyDefinitionLabel(QName propQName, String newLabel) throws PropertyAlreadyExistsMetadataException;
|
||||
|
||||
/**
|
||||
* Update the name and label of the custom property definition.
|
||||
* @param propQName The qname of the existing property definition
|
||||
* @param newName THe new name for both the custom property and its label.
|
||||
* @return
|
||||
* @throws CustomMetadataException
|
||||
*/
|
||||
public QName updateCustomPropertyDefinitionName(QName propQName, String newName) throws CustomMetadataException;
|
||||
|
||||
/**
|
||||
* Sets a new list of values constraint on the custom property definition.
|
||||
*
|
||||
* @param propQName the qname of the property definition
|
||||
* @param newLovConstraint the List-Of-Values constraintRef.
|
||||
* @return the propId.
|
||||
*/
|
||||
public QName setCustomPropertyDefinitionConstraint(QName propQName, QName newLovConstraint);
|
||||
|
||||
/**
|
||||
* Removes all list of values constraints from the custom property definition.
|
||||
*
|
||||
* @param propQName the qname of the property definition
|
||||
* @return the propId.
|
||||
*/
|
||||
public QName removeCustomPropertyDefinitionConstraints(QName propQName);
|
||||
|
||||
/**
|
||||
* Remove custom property definition
|
||||
*
|
||||
* @param propQName
|
||||
*/
|
||||
public void removeCustomPropertyDefinition(QName propQName);
|
||||
|
||||
/**
|
||||
* This method returns the custom references that have been defined in the custom
|
||||
* model.
|
||||
* Note: the custom reference definitions are retrieved from the dictionaryService
|
||||
* which is notified of any newly created definitions on transaction commit.
|
||||
* Therefore custom references created in the current transaction will not appear
|
||||
* in the results.
|
||||
*
|
||||
* @return The Map of custom references (both parent-child and standard).
|
||||
*/
|
||||
public Map<QName, AssociationDefinition> getCustomReferenceDefinitions();
|
||||
|
||||
/**
|
||||
* Fetches all associations <i>from</i> the given source.
|
||||
*
|
||||
* @param node the node from which the associations start.
|
||||
* @return a List of associations.
|
||||
*/
|
||||
public List<AssociationRef> getCustomReferencesFrom(NodeRef node);
|
||||
|
||||
/**
|
||||
* Fetches all child associations of the given source. i.e. all associations where the
|
||||
* given node is the parent.
|
||||
*
|
||||
* @param node
|
||||
* @return
|
||||
*/
|
||||
public List<ChildAssociationRef> getCustomChildReferences(NodeRef node);
|
||||
|
||||
/**
|
||||
* Returns a List of all associations <i>to</i> the given node.
|
||||
*
|
||||
* @param node the node to which the associations point.
|
||||
* @return a List of associations.
|
||||
*/
|
||||
public List<AssociationRef> getCustomReferencesTo(NodeRef node);
|
||||
|
||||
/**
|
||||
* Fetches all child associations where the given node is the child.
|
||||
*
|
||||
* @param node
|
||||
* @return
|
||||
*/
|
||||
public List<ChildAssociationRef> getCustomParentReferences(NodeRef node);
|
||||
|
||||
/**
|
||||
* This method adds the specified custom reference instance between the specified nodes.
|
||||
* Only one instance of any custom reference type is allowed in a given direction
|
||||
* between two given records.
|
||||
*
|
||||
* @param fromNode
|
||||
* @param toNode
|
||||
* @param assocId the server-side qname e.g. {http://www.alfresco.org/model/rmcustom/1.0}abcd-12-efgh-4567
|
||||
* @throws AlfrescoRuntimeException if an instance of the specified reference type
|
||||
* already exists from fromNode to toNode.
|
||||
*/
|
||||
public void addCustomReference(NodeRef fromNode, NodeRef toNode, QName assocId);
|
||||
|
||||
/**
|
||||
* This method removes the specified custom reference instance from the specified node.
|
||||
*
|
||||
* @param fromNode
|
||||
* @param toNode
|
||||
* @param assocId the server-side qname e.g. {http://www.alfresco.org/model/rmcustom/1.0}abcd-12-efgh-4567
|
||||
*/
|
||||
public void removeCustomReference(NodeRef fromNode, NodeRef toNode, QName assocId);
|
||||
|
||||
/**
|
||||
* This method creates a new custom association, using the given label as the title.
|
||||
*
|
||||
* @param label the title of the association definition
|
||||
* @return the QName of the newly-created association.
|
||||
*/
|
||||
public QName addCustomAssocDefinition(String label);
|
||||
|
||||
/**
|
||||
* This method creates a new custom child association, combining the given source and
|
||||
* target and using the combined String as the title.
|
||||
*
|
||||
* @param source
|
||||
* @param target
|
||||
* @return the QName of the newly-created association.
|
||||
*/
|
||||
public QName addCustomChildAssocDefinition(String source, String target);
|
||||
|
||||
/**
|
||||
* This method updates the source and target values for the specified child association.
|
||||
* The source and target will be combined into a single string and stored in the title property.
|
||||
* Source and target are String metadata for RM parent/child custom references.
|
||||
*
|
||||
* @param refQName qname of the child association.
|
||||
* @param newSource the new value for the source field.
|
||||
* @param newTarget the new value for the target field.
|
||||
* @see #getCompoundIdFor(String, String)
|
||||
* @see #splitSourceTargetId(String)
|
||||
*/
|
||||
public QName updateCustomChildAssocDefinition(QName refQName, String newSource, String newTarget);
|
||||
|
||||
/**
|
||||
* This method updates the label value for the specified association.
|
||||
* The label will be stored in the title property.
|
||||
* Label is String metadata for bidirectional custom references.
|
||||
*
|
||||
* @param refQName qname of the child association.
|
||||
* @param newLabel the new value for the label field.
|
||||
*/
|
||||
public QName updateCustomAssocDefinition(QName refQName, String newLabel);
|
||||
|
||||
/**
|
||||
* This method returns ConstraintDefinition objects defined in the given model
|
||||
* (note: not property references or in-line defs)
|
||||
* The custom constraint definitions are retrieved from the dictionaryService
|
||||
* which is notified of any newly created definitions on transaction commit.
|
||||
* Therefore custom constraints created in the current transaction will not appear
|
||||
* in the results.
|
||||
*/
|
||||
public List<ConstraintDefinition> getCustomConstraintDefinitions(QName modelQName);
|
||||
|
||||
/**
|
||||
* This method adds a Constraint definition to the custom model.
|
||||
* The implementation of this method would have to go into the M2Model and insert
|
||||
* the relevant M2Objects for this new constraint.
|
||||
*
|
||||
* param type not included as it would always be RMListOfValuesConstraint for RM.
|
||||
*
|
||||
* @param constraintName the name e.g. rmc:foo
|
||||
* @param title the human-readable title e.g. My foo list
|
||||
* @param caseSensitive
|
||||
* @param allowedValues the allowed values list
|
||||
* @param matchLogic AND (all values must match), OR (at least one values must match)
|
||||
*/
|
||||
public void addCustomConstraintDefinition(QName constraintName, String title, boolean caseSensitive, List<String> allowedValues, MatchLogic matchLogic);
|
||||
|
||||
/**
|
||||
* Remove custom constraint definition - if not referenced (by any properties)
|
||||
*
|
||||
*
|
||||
* @param constraintName the name e.g. rmc:foo
|
||||
*/
|
||||
public void removeCustomConstraintDefinition(QName constraintName);
|
||||
|
||||
/**
|
||||
* Update custom constraint definition with new list of values (replaces existing list, if any)
|
||||
*
|
||||
* @param constraintName the name e.g. rmc:foo
|
||||
* @param newValues
|
||||
*/
|
||||
public void changeCustomConstraintValues(QName constraintName, List<String> newValues);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param constraintName
|
||||
* @param title
|
||||
*/
|
||||
public void changeCustomConstraintTitle(QName constraintName, String title);
|
||||
|
||||
/**
|
||||
* This method iterates over the custom properties, references looking for one whose id
|
||||
* exactly matches that specified.
|
||||
*
|
||||
* @param localName the localName part of the qname of the property or reference definition.
|
||||
* @return the QName of the property, association definition which matches, or null.
|
||||
*/
|
||||
public QName getQNameForClientId(String localName);
|
||||
|
||||
/**
|
||||
* Given a compound id for source and target strings (as used with parent/child
|
||||
* custom references), this method splits the String and returns an array containing
|
||||
* the source and target IDs separately.
|
||||
*
|
||||
* @param sourceTargetId the compound ID.
|
||||
* @return a String array, where result[0] == sourceId and result[1] == targetId.
|
||||
*/
|
||||
public String[] splitSourceTargetId(String sourceTargetId);
|
||||
|
||||
/**
|
||||
* This method retrieves a compound ID (client-side) for the specified
|
||||
* sourceId and targetId.
|
||||
*
|
||||
* @param sourceId
|
||||
* @param targetId
|
||||
* @return
|
||||
*/
|
||||
public String getCompoundIdFor(String sourceId, String targetId);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,268 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.audit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.ISO8601DateFormat;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Class to represent a Records Management audit entry.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public final class RecordsManagementAuditEntry
|
||||
{
|
||||
private final Date timestamp;
|
||||
private final String userName;
|
||||
private final String fullName;
|
||||
private final String userRole;
|
||||
private final NodeRef nodeRef;
|
||||
private final String nodeName;
|
||||
private final String nodeType;
|
||||
private final String event;
|
||||
private final String identifier;
|
||||
private final String path;
|
||||
private final Map<QName, Serializable> beforeProperties;
|
||||
private final Map<QName, Serializable> afterProperties;
|
||||
private Map<QName, Pair<Serializable, Serializable>> changedProperties;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public RecordsManagementAuditEntry(Date timestamp,
|
||||
String userName, String fullName, String userRole,
|
||||
NodeRef nodeRef, String nodeName, String nodeType,
|
||||
String event, String identifier, String path,
|
||||
Map<QName, Serializable> beforeProperties,
|
||||
Map<QName, Serializable> afterProperties)
|
||||
{
|
||||
ParameterCheck.mandatory("timestamp", timestamp);
|
||||
ParameterCheck.mandatory("userName", userName);
|
||||
|
||||
this.timestamp = timestamp;
|
||||
this.userName = userName;
|
||||
this.userRole = userRole;
|
||||
this.fullName = fullName;
|
||||
this.nodeRef = nodeRef;
|
||||
this.nodeName = nodeName;
|
||||
this.nodeType = nodeType;
|
||||
this.event = event;
|
||||
this.identifier = identifier;
|
||||
this.path = path;
|
||||
this.beforeProperties = beforeProperties;
|
||||
this.afterProperties = afterProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("(")
|
||||
.append("timestamp=").append(timestamp)
|
||||
.append(", userName=").append(userName)
|
||||
.append(", userRole=").append(userRole)
|
||||
.append(", fullName=").append(fullName)
|
||||
.append(", nodeRef=").append(nodeRef)
|
||||
.append(", nodeName=").append(nodeName)
|
||||
.append(", event=").append(event)
|
||||
.append(", identifier=").append(identifier)
|
||||
.append(", path=").append(path)
|
||||
.append(", beforeProperties=").append(beforeProperties)
|
||||
.append(", afterProperties=").append(afterProperties)
|
||||
.append(", changedProperties=").append(changedProperties)
|
||||
.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The date of the audit entry
|
||||
*/
|
||||
public Date getTimestamp()
|
||||
{
|
||||
return this.timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The date of the audit entry as an ISO8601 formatted String
|
||||
*/
|
||||
public String getTimestampString()
|
||||
{
|
||||
return ISO8601DateFormat.format(this.timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The username of the user that caused the audit log entry to be created
|
||||
*/
|
||||
public String getUserName()
|
||||
{
|
||||
return this.userName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The full name of the user that caused the audit log entry to be created
|
||||
*/
|
||||
public String getFullName()
|
||||
{
|
||||
return this.fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The role of the user that caused the audit log entry to be created
|
||||
*/
|
||||
public String getUserRole()
|
||||
{
|
||||
return this.userRole;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The NodeRef of the node the audit log entry is for
|
||||
*/
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.nodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The name of the node the audit log entry is for
|
||||
*/
|
||||
public String getNodeName()
|
||||
{
|
||||
return this.nodeName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The type of the node the audit log entry is for
|
||||
*/
|
||||
public String getNodeType()
|
||||
{
|
||||
return this.nodeType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The human readable description of the reason for the audit log
|
||||
* entry i.e. metadata updated, record declared
|
||||
*/
|
||||
public String getEvent()
|
||||
{
|
||||
return this.event;
|
||||
}
|
||||
|
||||
/**
|
||||
* An identifier for the item being audited, for example for a record
|
||||
* it will be the unique record identifier, for a user it would be the
|
||||
* username etc.
|
||||
*
|
||||
* @return Ad identifier for the thing being audited
|
||||
*/
|
||||
public String getIdentifier()
|
||||
{
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The path to the object being audited
|
||||
*/
|
||||
public String getPath()
|
||||
{
|
||||
return this.path;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Map of properties before the audited action
|
||||
*/
|
||||
public Map<QName, Serializable> getBeforeProperties()
|
||||
{
|
||||
return this.beforeProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Map of properties after the audited action
|
||||
*/
|
||||
public Map<QName, Serializable> getAfterProperties()
|
||||
{
|
||||
return this.afterProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Map of changed properties
|
||||
*/
|
||||
public Map<QName, Pair<Serializable, Serializable>> getChangedProperties()
|
||||
{
|
||||
if (this.changedProperties == null)
|
||||
{
|
||||
initChangedProperties();
|
||||
}
|
||||
|
||||
return this.changedProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the map of changed values given the before and after properties
|
||||
*/
|
||||
private void initChangedProperties()
|
||||
{
|
||||
if (this.beforeProperties != null && this.afterProperties != null)
|
||||
{
|
||||
this.changedProperties = new HashMap<QName, Pair<Serializable, Serializable>>(
|
||||
this.beforeProperties.size() + this.afterProperties.size());
|
||||
|
||||
// add all the properties present before the audited action
|
||||
for (QName valuePropName : this.beforeProperties.keySet())
|
||||
{
|
||||
Pair<Serializable, Serializable> values = new Pair<Serializable, Serializable>(
|
||||
this.beforeProperties.get(valuePropName),
|
||||
this.afterProperties.get(valuePropName));
|
||||
this.changedProperties.put(valuePropName, values);
|
||||
}
|
||||
|
||||
// add all the properties present after the audited action that
|
||||
// have not already been added
|
||||
for (QName valuePropName : this.afterProperties.keySet())
|
||||
{
|
||||
if (!this.beforeProperties.containsKey(valuePropName))
|
||||
{
|
||||
Pair<Serializable, Serializable> values = new Pair<Serializable, Serializable>(null,
|
||||
this.afterProperties.get(valuePropName));
|
||||
this.changedProperties.put(valuePropName, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,205 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.audit;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Class to represent the parameters for a Records Management
|
||||
* audit log query.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public final class RecordsManagementAuditQueryParameters
|
||||
{
|
||||
private int maxEntries = -1;
|
||||
private String user;
|
||||
private NodeRef nodeRef;
|
||||
private Date dateFrom;
|
||||
private Date dateTo;
|
||||
private String event;
|
||||
private QName property;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public RecordsManagementAuditQueryParameters()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The username to filter by
|
||||
*/
|
||||
public String getUser()
|
||||
{
|
||||
return this.user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts the retrieved audit trail to entries made by
|
||||
* the provided user.
|
||||
*
|
||||
* @param user The username to filter by
|
||||
*/
|
||||
public void setUser(String user)
|
||||
{
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The maximum number of audit log entries to retrieve
|
||||
*/
|
||||
public int getMaxEntries()
|
||||
{
|
||||
return this.maxEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts the retrieved audit trail to the last
|
||||
* <code>maxEntries</code> entries.
|
||||
*
|
||||
* @param maxEntries Maximum number of entries
|
||||
*/
|
||||
public void setMaxEntries(int maxEntries)
|
||||
{
|
||||
this.maxEntries = maxEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The node to get entries for
|
||||
*/
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.nodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts the retrieved audit trail to only those entries
|
||||
* created by the give node.
|
||||
*
|
||||
* @param nodeRef The node to get entries for
|
||||
*/
|
||||
public void setNodeRef(NodeRef nodeRef)
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The date to retrieve entries from
|
||||
*/
|
||||
public Date getDateFrom()
|
||||
{
|
||||
return this.dateFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts the retrieved audit trail to only those entries
|
||||
* that occurred after the given date.
|
||||
*
|
||||
* @param dateFrom Date to retrieve entries after
|
||||
*/
|
||||
public void setDateFrom(Date dateFrom)
|
||||
{
|
||||
this.dateFrom = dateFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The date to retrive entries to
|
||||
*/
|
||||
public Date getDateTo()
|
||||
{
|
||||
return this.dateTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts the retrieved audit trail to only those entries
|
||||
* that occurred before the given date.
|
||||
*
|
||||
* @param dateTo Date to retrieve entries before
|
||||
*/
|
||||
public void setDateTo(Date dateTo)
|
||||
{
|
||||
this.dateTo = dateTo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The event to retrive entries for
|
||||
*/
|
||||
public String getEvent()
|
||||
{
|
||||
return this.event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts the retrieved audit trail to only those entries
|
||||
* that match the given event string.
|
||||
*
|
||||
* @param event Event to retrieve entries for
|
||||
*/
|
||||
public void setEvent(String event)
|
||||
{
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The property to retrieve entries for
|
||||
*/
|
||||
public QName getProperty()
|
||||
{
|
||||
return this.property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts the audit trail to only those entries that involve
|
||||
* the given property.
|
||||
*
|
||||
* @param property The property to retrieve entries for
|
||||
*/
|
||||
public void setProperty(QName property)
|
||||
{
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(super.toString());
|
||||
|
||||
builder.append(" (nodeRef='").append(nodeRef).append("', user='")
|
||||
.append(user).append("', dateFrom='").append(dateFrom)
|
||||
.append("', dateTo='").append(dateTo).append("', maxEntries='")
|
||||
.append(maxEntries).append("', event='").append(event)
|
||||
.append("', property='").append(property).append("')");
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
@@ -1,213 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.audit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Records management audit service.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public interface RecordsManagementAuditService extends RecordsManagementAuditServiceDeprecated
|
||||
{
|
||||
public enum ReportFormat { HTML, JSON }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves a list of audit events.
|
||||
*
|
||||
* @return List of audit events
|
||||
*/
|
||||
List<AuditEvent> getAuditEvents();
|
||||
|
||||
/**
|
||||
* Register audit event.
|
||||
* <p>
|
||||
* Creates an instance of a simple audit event and registers it with
|
||||
* the service.
|
||||
*
|
||||
* @param name name of audit event
|
||||
* @param label display label of audit event
|
||||
*/
|
||||
void registerAuditEvent(String name, String label);
|
||||
|
||||
/**
|
||||
* Register audit event.
|
||||
*
|
||||
* @param auditEvent audit event
|
||||
*/
|
||||
void registerAuditEvent(AuditEvent auditEvent);
|
||||
|
||||
/**
|
||||
* Audits an event, assumes no properties where modified and that the event should not be audited
|
||||
* immediately.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param eventName event name
|
||||
*/
|
||||
void auditEvent(NodeRef nodeRef,
|
||||
String eventName);
|
||||
|
||||
/**
|
||||
* Audits an event, assumes that the event should not be audited immediately and not be removed if no property is changed.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param eventName event name
|
||||
* @param before property values before event
|
||||
* @param after property values after event
|
||||
*/
|
||||
void auditEvent(NodeRef nodeRef,
|
||||
String eventName,
|
||||
Map<QName, Serializable> before,
|
||||
Map<QName, Serializable> after);
|
||||
|
||||
/**
|
||||
* Audit event, assumes not to be removed if no property is changed.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param eventName event name
|
||||
* @param before property values before event
|
||||
* @param after property values after event
|
||||
* @param immediate true if event is to be audited immediately, false otherwise
|
||||
*/
|
||||
void auditEvent(NodeRef nodeRef,
|
||||
String eventName,
|
||||
Map<QName, Serializable> before,
|
||||
Map<QName, Serializable> after,
|
||||
boolean immediate);
|
||||
|
||||
/**
|
||||
* Audit event.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param eventName event name
|
||||
* @param before property values before event
|
||||
* @param after property values after event
|
||||
* @param immediate true if event is to be audited immediately, false otherwise
|
||||
* @param removeIfNoPropertyChanged true if event is not audited when there are no properties changed, false otherwise
|
||||
*/
|
||||
void auditEvent(NodeRef nodeRef,
|
||||
String eventName,
|
||||
Map<QName, Serializable> before,
|
||||
Map<QName, Serializable> after,
|
||||
boolean immediate,
|
||||
boolean removeIfNoPropertyChanged);
|
||||
|
||||
/**
|
||||
* Determines whether the RM audit log is currently enabled.
|
||||
*
|
||||
* @param filePlan file plan
|
||||
* @return true if RM auditing is active false otherwise
|
||||
*/
|
||||
boolean isAuditLogEnabled(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
* Start RM auditing.
|
||||
*
|
||||
* @param filePlan file plan
|
||||
*/
|
||||
void startAuditLog(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
* Stop RM auditing.
|
||||
*
|
||||
* @param filePlan file plan
|
||||
*/
|
||||
void stopAuditLog(NodeRef filePlan);
|
||||
|
||||
|
||||
/**
|
||||
* Clears the RM audit.
|
||||
*
|
||||
* @param filePlan file plan
|
||||
*/
|
||||
void clearAuditLog(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
* Returns the date the RM audit was last started.
|
||||
*
|
||||
* @param filePlan file plan
|
||||
* @return Date the audit was last started
|
||||
*/
|
||||
Date getDateAuditLogLastStarted(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
* Returns the date the RM audit was last stopped.
|
||||
*
|
||||
* @return Date the audit was last stopped
|
||||
*/
|
||||
Date getDateAuditLogLastStopped(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
* Retrieves a list of audit log entries using the provided parameters
|
||||
* represented by the RecordsManagementAuditQueryParameters instance.
|
||||
* <p>
|
||||
* The parameters are all optional so an empty RecordsManagementAuditQueryParameters
|
||||
* object will result in ALL audit log entries for the RM system being
|
||||
* returned. Setting the various parameters effectively filters the full
|
||||
* audit trail.
|
||||
*
|
||||
* @param params Parameters to use to retrieve audit trail (never <tt>null</tt>)
|
||||
* @param format The format the report should be produced in
|
||||
* @return File containing JSON representation of audit trail
|
||||
*/
|
||||
File getAuditTrailFile(RecordsManagementAuditQueryParameters params, ReportFormat format);
|
||||
|
||||
/**
|
||||
* Retrieves a list of audit log entries using the provided parameters
|
||||
* represented by the RecordsManagementAuditQueryParameters instance.
|
||||
* <p>
|
||||
* The parameters are all optional so an empty RecordsManagementAuditQueryParameters
|
||||
* object will result in ALL audit log entries for the RM system being
|
||||
* returned. Setting the various parameters effectively filters the full
|
||||
* audit trail.
|
||||
*
|
||||
* @param params Parameters to use to retrieve audit trail (never <tt>null</tt>)
|
||||
* @return All entries for the audit trail
|
||||
*/
|
||||
List<RecordsManagementAuditEntry> getAuditTrail(RecordsManagementAuditQueryParameters params);
|
||||
|
||||
/**
|
||||
* Retrieves a list of audit log entries using the provided parameters
|
||||
* represented by the RecordsManagementAuditQueryParameters instance and
|
||||
* then files the resulting log as an undeclared record in the record folder
|
||||
* represented by the given NodeRef.
|
||||
* <p>
|
||||
* The parameters are all optional so an empty RecordsManagementAuditQueryParameters
|
||||
* object will result in ALL audit log entries for the RM system being
|
||||
* returned. Setting the various parameters effectively filters the full
|
||||
* audit trail.
|
||||
*
|
||||
* @param params Parameters to use to retrieve audit trail (never <tt>null</tt>)
|
||||
* @param destination NodeRef representing a record folder in which to file the audit log
|
||||
* @param format The format the report should be produced in
|
||||
* @return NodeRef of the undeclared record filed
|
||||
*/
|
||||
NodeRef fileAuditTrailAsRecord(RecordsManagementAuditQueryParameters params, NodeRef destination, ReportFormat format);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Class to represent an audit event
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent>
|
||||
{
|
||||
/** Name */
|
||||
protected String name;
|
||||
|
||||
/** Label */
|
||||
protected String label;
|
||||
|
||||
/** Records management audit service */
|
||||
protected RecordsManagementAuditService recordsManagementAuditService;
|
||||
|
||||
/** Policy component */
|
||||
//protected PolicyComponent policyComponent;
|
||||
|
||||
/**
|
||||
* @param recordsManagementAuditService records management audit service
|
||||
*/
|
||||
public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService)
|
||||
{
|
||||
this.recordsManagementAuditService = recordsManagementAuditService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param policyComponent policy component
|
||||
*/
|
||||
// public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
// {
|
||||
// this.policyComponent = policyComponent;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
recordsManagementAuditService.registerAuditEvent(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public AuditEvent()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @param name audit event name
|
||||
* @param label audit event label (can be actual label or I18N lookup key)
|
||||
*/
|
||||
public AuditEvent(String name, String label)
|
||||
{
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return audit event name
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name audit event name
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return audit event label
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
String lookup = I18NUtil.getMessage(label);
|
||||
if (lookup == null)
|
||||
{
|
||||
lookup = label;
|
||||
}
|
||||
return lookup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param label audit event label
|
||||
*/
|
||||
public void setLabel(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compare(AuditEvent first, AuditEvent second)
|
||||
{
|
||||
return first.getLabel().compareTo(second.getLabel());
|
||||
}
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Copy audit event.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class CopyAuditEvent extends AuditEvent implements OnCopyCompletePolicy
|
||||
{
|
||||
/**
|
||||
* Audit copy of file plan components
|
||||
*
|
||||
* @see org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy#onCopyComplete(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, boolean, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void onCopyComplete(QName classRef,
|
||||
NodeRef sourceNodeRef,
|
||||
NodeRef targetNodeRef,
|
||||
boolean copyToNewNode,
|
||||
Map<NodeRef, NodeRef> copyMap)
|
||||
{
|
||||
if (copyToNewNode == true)
|
||||
{
|
||||
recordsManagementAuditService.auditEvent(targetNodeRef, getName());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
|
||||
/**
|
||||
* Audits the creation of file plan component objects
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class CreateObjectAuditEvent extends AuditEvent implements OnCreateNodePolicy
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void onCreateNode(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), name);
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
|
||||
/**
|
||||
* Audits person creation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class CreatePersonAuditEvent extends AuditEvent implements OnCreateNodePolicy
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "cm:person"
|
||||
)
|
||||
public void onCreateNode(ChildAssociationRef childAssocRef)
|
||||
{
|
||||
recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), name);
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Audits file plan component delete
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class DeleteObjectAuditEvent extends AuditEvent implements BeforeDeleteNodePolicy
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void beforeDeleteNode(NodeRef nodeRef)
|
||||
{
|
||||
recordsManagementAuditService.auditEvent(nodeRef, name, null, null, true, false);
|
||||
}
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* File audit event.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class FileAuditEvent extends AuditEvent implements OnUpdatePropertiesPolicy
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:record"
|
||||
)
|
||||
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||
{
|
||||
if (before.get(PROP_DATE_FILED) == null && after.get(PROP_DATE_FILED) != null)
|
||||
{
|
||||
// then we can assume that the record has just been filed
|
||||
recordsManagementAuditService.auditEvent(nodeRef, getName());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
|
||||
/**
|
||||
* Link audit event.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class LinkAuditEvent extends AuditEvent implements OnCreateChildAssociationPolicy
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.ASSOCIATION,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
|
||||
{
|
||||
// only care about linking child associations
|
||||
if (childAssocRef.isPrimary() == false)
|
||||
{
|
||||
// TODO
|
||||
// add some dummy properties to indicate the details of the link?
|
||||
recordsManagementAuditService.auditEvent(childAssocRef.getChildRef(), getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
|
||||
/**
|
||||
* Move audit event.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class MoveAuditEvent extends AuditEvent implements OnMoveNodePolicy
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
|
||||
{
|
||||
recordsManagementAuditService.auditEvent(newChildAssocRef.getChildRef(), getName());
|
||||
}
|
||||
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.module.org_alfresco_module_rm.audit.event;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Audits file plan component property updates
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
@BehaviourBean
|
||||
public class UpdateObjectAuditEvent extends AuditEvent implements OnUpdatePropertiesPolicy
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
type = "rma:filePlanComponent"
|
||||
)
|
||||
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||
{
|
||||
recordsManagementAuditService.auditEvent(nodeRef, name, before, after, false, true);
|
||||
}
|
||||
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.audit.extractor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
||||
import org.alfresco.repo.audit.extractor.AbstractDataExtractor;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
|
||||
/**
|
||||
* An extractor that uses a node context to determine the currently-authenticated
|
||||
* user's RM roles. This is not a data generator because it can only function in
|
||||
* the context of a give node.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 3.2
|
||||
*/
|
||||
public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtractor
|
||||
{
|
||||
private NodeService nodeService;
|
||||
private FilePlanService filePlanService;
|
||||
private FilePlanRoleService filePlanRoleService;
|
||||
|
||||
/**
|
||||
* Used to check that the node in the context is a fileplan component
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanRoleService file plan role service
|
||||
*/
|
||||
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
|
||||
{
|
||||
this.filePlanRoleService = filePlanRoleService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns <tt>true</tt> if the data is a NodeRef and it represents
|
||||
* a fileplan component
|
||||
*/
|
||||
public boolean isSupported(Serializable data)
|
||||
{
|
||||
if (data == null || !(data instanceof NodeRef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.audit.extractor.DataExtractor#extractData(java.io.Serializable)
|
||||
*/
|
||||
public Serializable extractData(Serializable value) throws Throwable
|
||||
{
|
||||
NodeRef nodeRef = (NodeRef) value;
|
||||
String user = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
if (user == null)
|
||||
{
|
||||
// No-one is authenticated
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the rm root
|
||||
NodeRef rmRootNodeRef = filePlanService.getFilePlan(nodeRef);
|
||||
|
||||
Set<Role> roles = filePlanRoleService.getRolesByUser(rmRootNodeRef, user);
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
for (Role role : roles)
|
||||
{
|
||||
if (sb.length() > 0)
|
||||
{
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(role.getDisplayLabel());
|
||||
}
|
||||
|
||||
// Done
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.audit.extractor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.audit.extractor.AbstractDataExtractor;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
|
||||
/**
|
||||
* An extractor that gets a node's {@link RecordsManagementModel#PROP_IDENTIFIER identifier} property.
|
||||
* This will only extract data if the node is a
|
||||
* {@link RecordsManagementModel#ASPECT_RECORD_COMPONENT_ID Record component identifier}.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 3.2
|
||||
*/
|
||||
public final class FilePlanIdentifierDataExtractor extends AbstractDataExtractor
|
||||
{
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* Used to check that the node in the context is a fileplan component
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns <tt>true</tt> if the data is a NodeRef and it represents
|
||||
* a fileplan component
|
||||
*/
|
||||
public boolean isSupported(Serializable data)
|
||||
{
|
||||
if (data == null || !(data instanceof NodeRef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_RECORD_COMPONENT_ID);
|
||||
}
|
||||
|
||||
public Serializable extractData(Serializable value) throws Throwable
|
||||
{
|
||||
NodeRef nodeRef = (NodeRef) value;
|
||||
|
||||
String identifier = (String) nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_IDENTIFIER);
|
||||
|
||||
// Done
|
||||
return identifier;
|
||||
}
|
||||
}
|
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.audit.extractor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.audit.extractor.AbstractDataExtractor;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
|
||||
/**
|
||||
* An extractor that extracts the <b>cm:name</b> path from the RM root down to
|
||||
* - and including - the node's own name. This will only extract data if the
|
||||
* node is a {@link RecordsManagementModel#ASPECT_FILE_PLAN_COMPONENT fileplan component}.
|
||||
*
|
||||
* @see FilePlanService#getNodeRefPath(NodeRef)
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 3.2
|
||||
*/
|
||||
public final class FilePlanNamePathDataExtractor extends AbstractDataExtractor
|
||||
{
|
||||
private NodeService nodeService;
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/**
|
||||
* Used to check that the node in the context is a fileplan component
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns <tt>true</tt> if the data is a NodeRef and it represents
|
||||
* a fileplan component
|
||||
*/
|
||||
public boolean isSupported(Serializable data)
|
||||
{
|
||||
if (data == null || !(data instanceof NodeRef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.audit.extractor.DataExtractor#extractData(java.io.Serializable)
|
||||
*/
|
||||
public Serializable extractData(Serializable value) throws Throwable
|
||||
{
|
||||
NodeRef nodeRef = (NodeRef) value;
|
||||
|
||||
// Get path from the RM root
|
||||
List<NodeRef> nodeRefPath = filePlanService.getNodeRefPath(nodeRef);
|
||||
|
||||
StringBuilder sb = new StringBuilder(128);
|
||||
for (NodeRef pathNodeRef : nodeRefPath)
|
||||
{
|
||||
String name = (String)nodeService.getProperty(pathNodeRef, ContentModel.PROP_NAME);
|
||||
sb.append("/").append(name);
|
||||
}
|
||||
|
||||
// Done
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.audit.extractor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.audit.extractor.AbstractDataExtractor;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
|
||||
/**
|
||||
* An extractor that extracts the NodeRef path from the RM root down to
|
||||
* - and including - the node itself. This will only extract data if the
|
||||
* node is a {@link RecordsManagementModel#ASPECT_FILE_PLAN_COMPONENT fileplan component}.
|
||||
*
|
||||
* @see FilePlanService#getNodeRefPath(NodeRef)
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 1.0
|
||||
*/
|
||||
public final class FilePlanNodeRefPathDataExtractor extends AbstractDataExtractor
|
||||
{
|
||||
private NodeService nodeService;
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/**
|
||||
* Used to check that the node in the context is a fileplan component
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns <tt>true</tt> if the data is a NodeRef and it represents
|
||||
* a fileplan component
|
||||
*/
|
||||
public boolean isSupported(Serializable data)
|
||||
{
|
||||
if (data == null || !(data instanceof NodeRef))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT);
|
||||
}
|
||||
|
||||
public Serializable extractData(Serializable value) throws Throwable
|
||||
{
|
||||
NodeRef nodeRef = (NodeRef) value;
|
||||
|
||||
// Get path from the RM root
|
||||
List<NodeRef> nodeRefPath = filePlanService.getNodeRefPath(nodeRef);
|
||||
|
||||
// Done
|
||||
return (Serializable) nodeRefPath;
|
||||
}
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.bootstrap;
|
||||
|
||||
import org.alfresco.repo.module.ImporterModuleComponent;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
|
||||
/**
|
||||
* Custom implementation of module component importer
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.0
|
||||
*/
|
||||
public class BootstrapImporterModuleComponent extends ImporterModuleComponent
|
||||
{
|
||||
private static final String CONFIG_NODEID = "rm_config_folder";
|
||||
|
||||
private NodeService nodeService;
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Need to check whether this module has already been executed.
|
||||
*
|
||||
* @see org.alfresco.repo.module.ImporterModuleComponent#executeInternal()
|
||||
*/
|
||||
@Override
|
||||
protected void executeInternal() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID);
|
||||
if (nodeService.exists(nodeRef) == false)
|
||||
{
|
||||
super.executeInternal();
|
||||
}
|
||||
}
|
||||
catch (Throwable exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.bootstrap;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.SplitEmailAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.email.CustomEmailMappingService;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
||||
|
||||
|
||||
/**
|
||||
* RM module bootstrap
|
||||
*
|
||||
* @author janv
|
||||
*/
|
||||
public class RecordsManagementBootstrap extends AbstractLifecycleBean
|
||||
{
|
||||
private TransactionService transactionService;
|
||||
private RMCaveatConfigService caveatConfigService;
|
||||
private CustomEmailMappingService customEmailMappingService;
|
||||
private RecordsManagementAdminService adminService;
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
public void setCaveatConfigService(RMCaveatConfigService caveatConfigService)
|
||||
{
|
||||
this.caveatConfigService = caveatConfigService;
|
||||
}
|
||||
|
||||
public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService)
|
||||
{
|
||||
this.customEmailMappingService = customEmailMappingService;
|
||||
}
|
||||
|
||||
public void setRecordsManagementAdminService(RecordsManagementAdminService adminService)
|
||||
{
|
||||
this.adminService = adminService;
|
||||
}
|
||||
|
||||
public CustomEmailMappingService getCustomEmailMappingService()
|
||||
{
|
||||
return customEmailMappingService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
// run as System on bootstrap
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork()
|
||||
{
|
||||
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
// initialise caveat config
|
||||
caveatConfigService.init();
|
||||
|
||||
// Initialise the custom model
|
||||
adminService.initialiseCustomModel();
|
||||
|
||||
// Initialise the SplitEmailAction
|
||||
SplitEmailAction action = (SplitEmailAction)getApplicationContext().getBean("splitEmail");
|
||||
action.bootstrap();
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShutdown(ApplicationEvent event)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
}
|
||||
|
@@ -1,296 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.capability;
|
||||
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Abstract capability implementation.
|
||||
*
|
||||
* @author Andy Hind
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public abstract class AbstractCapability extends RMSecurityCommon
|
||||
implements Capability, RecordsManagementModel, RMPermissionModel
|
||||
{
|
||||
/** Capability service */
|
||||
protected CapabilityService capabilityService;
|
||||
|
||||
/** Capability name */
|
||||
protected String name;
|
||||
|
||||
/** Capability title and description */
|
||||
protected String title;
|
||||
protected String description;
|
||||
|
||||
/** Capability group */
|
||||
protected Group group;
|
||||
|
||||
/** Capability index */
|
||||
protected int index;
|
||||
|
||||
/** Indicates whether this is a private capability or not */
|
||||
protected boolean isPrivate = false;
|
||||
|
||||
/**
|
||||
* @param capabilityService capability service
|
||||
*/
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
{
|
||||
this.capabilityService = capabilityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
capabilityService.registerCapability(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name capability name
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title capability title
|
||||
*/
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getTitle()
|
||||
*/
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
String title = this.title;
|
||||
if (StringUtils.isBlank(title))
|
||||
{
|
||||
title = I18NUtil.getMessage("capability." + getName() + ".title");
|
||||
if (StringUtils.isBlank(title) == true)
|
||||
{
|
||||
title = getName();
|
||||
}
|
||||
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description capability description
|
||||
*/
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param descriptionId message id
|
||||
*/
|
||||
public void setDescriptionId(String descriptionId)
|
||||
{
|
||||
this.description = I18NUtil.getMessage(descriptionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getDescription()
|
||||
*/
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#isPrivate()
|
||||
*/
|
||||
public boolean isPrivate()
|
||||
{
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isPrivate indicates whether the capability is private or not
|
||||
*/
|
||||
public void setPrivate(boolean isPrivate)
|
||||
{
|
||||
this.isPrivate = isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the vote to an AccessStatus
|
||||
*
|
||||
* @param vote
|
||||
* @return
|
||||
*/
|
||||
private AccessStatus translate(int vote)
|
||||
{
|
||||
switch (vote)
|
||||
{
|
||||
case AccessDecisionVoter.ACCESS_ABSTAIN:
|
||||
return AccessStatus.UNDETERMINED;
|
||||
case AccessDecisionVoter.ACCESS_GRANTED:
|
||||
return AccessStatus.ALLOWED;
|
||||
case AccessDecisionVoter.ACCESS_DENIED:
|
||||
return AccessStatus.DENIED;
|
||||
default:
|
||||
return AccessStatus.UNDETERMINED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#hasPermission(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public AccessStatus hasPermission(NodeRef nodeRef)
|
||||
{
|
||||
return translate(hasPermissionRaw(nodeRef));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the current user has permission on this capability.
|
||||
* <p>
|
||||
* Returns the raw permission value.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return raw permission value
|
||||
*/
|
||||
public int hasPermissionRaw(NodeRef nodeRef)
|
||||
{
|
||||
String prefix = "hasPermissionRaw" + getName();
|
||||
int result = getTransactionCache(prefix, nodeRef);
|
||||
if (result != NOSET_VALUE)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (checkRmRead(nodeRef) == AccessDecisionVoter.ACCESS_DENIED)
|
||||
{
|
||||
result = AccessDecisionVoter.ACCESS_DENIED;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = hasPermissionImpl(nodeRef);
|
||||
}
|
||||
|
||||
return setTransactionCache(prefix, nodeRef, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation. Override if different behaviour required.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
protected int hasPermissionImpl(NodeRef nodeRef)
|
||||
{
|
||||
return evaluate(nodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public int evaluate(NodeRef source, NodeRef target)
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_ABSTAIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getGroup()
|
||||
*/
|
||||
public Group getGroup()
|
||||
{
|
||||
return this.group;
|
||||
}
|
||||
|
||||
public void setGroup(Group group)
|
||||
{
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getIndex()
|
||||
*/
|
||||
public int getIndex()
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public void setIndex(int index)
|
||||
{
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
final AbstractCapability other = (AbstractCapability) obj;
|
||||
if (getName() == null)
|
||||
{
|
||||
if (other.getName() != null)
|
||||
return false;
|
||||
}
|
||||
else if (!getName().equals(other.getName()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.capability;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
|
||||
/**
|
||||
* Capability Interface.
|
||||
*
|
||||
* @author andyh
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public interface Capability
|
||||
{
|
||||
/**
|
||||
* Does this capability apply to this nodeRef?
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
AccessStatus hasPermission(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
int hasPermissionRaw(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Evaluates the capability.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
int evaluate(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Evaluates the capability, taking into account a target.
|
||||
*
|
||||
* @param source source node reference
|
||||
* @param target target node reference
|
||||
* @return int permission value
|
||||
*/
|
||||
int evaluate(NodeRef source, NodeRef target);
|
||||
|
||||
/**
|
||||
* Indicates whether this is a private capability or not. Private capabilities are used internally, otherwise
|
||||
* they are made available to the user to assign to roles.
|
||||
*
|
||||
* @return boolean true if private, false otherwise
|
||||
*/
|
||||
boolean isPrivate();
|
||||
|
||||
/**
|
||||
* Get the name of the capability
|
||||
*
|
||||
* @return String capability name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Get the title of the capability
|
||||
*
|
||||
* @return String capability title
|
||||
*/
|
||||
String getTitle();
|
||||
|
||||
/**
|
||||
* Get the description of the capability
|
||||
*
|
||||
* @return String capability description
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Gets the group of a capability
|
||||
*
|
||||
* @return Group capability group
|
||||
*/
|
||||
Group getGroup();
|
||||
|
||||
/**
|
||||
* Gets the index of a capability
|
||||
*
|
||||
* @return int capability index
|
||||
*/
|
||||
int getIndex();
|
||||
}
|
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.capability;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
|
||||
/**
|
||||
* Capability service implementation
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface CapabilityService
|
||||
{
|
||||
/**
|
||||
* Register a capability
|
||||
*
|
||||
* @param capability capability
|
||||
*/
|
||||
void registerCapability(Capability capability);
|
||||
|
||||
/**
|
||||
* Get a named capability.
|
||||
*
|
||||
* @param name capability name
|
||||
* @return {@link Capability} capability or null if not found
|
||||
*/
|
||||
Capability getCapability(String name);
|
||||
|
||||
/**
|
||||
* Get a list of all the assignable capabilities.
|
||||
*
|
||||
* @return {@link Set}<{@link Capability}> set of all the assignable capabilities
|
||||
*/
|
||||
Set<Capability> getCapabilities();
|
||||
|
||||
/**
|
||||
* Get a list of all the capabilities, optionally including those that are non-assignable.
|
||||
*
|
||||
* @param includePrivate indicates that the private, or non-assignable capabilities are included in the result
|
||||
* @return {@link Set}<{@link Capability}> set of capabilities
|
||||
*/
|
||||
Set<Capability> getCapabilities(boolean includePrivate);
|
||||
|
||||
/**
|
||||
* Get all the capabilities access state based on the current user for the assignable capabilities.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return
|
||||
*/
|
||||
Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Get all the capabilities access state based on the current user.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return
|
||||
*/
|
||||
Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodeRef
|
||||
* @param capabilityNames
|
||||
* @return
|
||||
*/
|
||||
Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, List<String> capabilityNames);
|
||||
|
||||
/**
|
||||
* Helper method to get the access state for a single capability.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @param capabilityName
|
||||
* @return
|
||||
*/
|
||||
AccessStatus getCapabilityAccessState(NodeRef nodeRef, String capabilityName);
|
||||
|
||||
/**
|
||||
* Gets the list of all the capability groups (in index order)
|
||||
*
|
||||
* @return {@link List}<{@link Group}> List of all the capability groups (in index order)
|
||||
*/
|
||||
List<Group> getGroups();
|
||||
|
||||
/**
|
||||
* Gets a list of capabilities for the given group id
|
||||
*
|
||||
* @param groupId The id of a group for which the list of capabilities should be retrieved
|
||||
* @return {@link List}<{@link Capability}> List of capabilities for the given group
|
||||
*/
|
||||
List<Capability> getCapabilitiesByGroupId(String groupId);
|
||||
|
||||
/**
|
||||
* Get a list of capabilities for the given group
|
||||
*
|
||||
* @param group The group for which the list of capabilities should be retrieved
|
||||
* @return {@link List}<{@link Capability}> List of capabilities for the given group
|
||||
*/
|
||||
List<Capability> getCapabilitiesByGroup(Group group);
|
||||
|
||||
/**
|
||||
* Gets a group from it's id
|
||||
*
|
||||
* @param groupId The id of the group which should be retrieved
|
||||
* @return Group The group with the id groupId
|
||||
*/
|
||||
Group getGroup(String groupId);
|
||||
|
||||
/**
|
||||
* Adds a group to the list of groups
|
||||
*
|
||||
* @param group The group which should be added
|
||||
*/
|
||||
void addGroup(Group group);
|
||||
|
||||
/**
|
||||
* Removes a group from the list of groups
|
||||
*
|
||||
* @param group The group which should be removed
|
||||
*/
|
||||
void removeGroup(Group group);
|
||||
}
|
@@ -1,279 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.capability;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* @author Roy Wetherall
|
||||
* @since 2.0
|
||||
*/
|
||||
public class CapabilityServiceImpl implements CapabilityService
|
||||
{
|
||||
/** Capabilities */
|
||||
private Map<String, Capability> capabilities = new HashMap<String, Capability>(57);
|
||||
|
||||
/** Groups */
|
||||
private Map<String, Group> groups = new HashMap<String, Group>(13);
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapability(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Capability getCapability(String name)
|
||||
{
|
||||
ParameterCheck.mandatoryString("name", name);
|
||||
|
||||
return capabilities.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#registerCapability(org.alfresco.module.org_alfresco_module_rm.capability.Capability)
|
||||
*/
|
||||
@Override
|
||||
public void registerCapability(Capability capability)
|
||||
{
|
||||
ParameterCheck.mandatory("capability", capability);
|
||||
|
||||
capabilities.put(capability.getName(), capability);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities()
|
||||
*/
|
||||
@Override
|
||||
public Set<Capability> getCapabilities()
|
||||
{
|
||||
return getCapabilities(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities(boolean)
|
||||
*/
|
||||
@Override
|
||||
public Set<Capability> getCapabilities(boolean includePrivate)
|
||||
{
|
||||
Set<Capability> result = null;
|
||||
if (includePrivate == true)
|
||||
{
|
||||
result = new HashSet<Capability>(capabilities.values());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new HashSet<Capability>(capabilities.size());
|
||||
for (Capability capability : capabilities.values())
|
||||
{
|
||||
if (capability.isPrivate() == false)
|
||||
{
|
||||
result.add(capability);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef)
|
||||
{
|
||||
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||
|
||||
return getCapabilitiesAccessState(nodeRef, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate)
|
||||
{
|
||||
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||
|
||||
Set<Capability> listOfCapabilites = getCapabilities(includePrivate);
|
||||
HashMap<Capability, AccessStatus> answer = new HashMap<Capability, AccessStatus>();
|
||||
for (Capability capability : listOfCapabilites)
|
||||
{
|
||||
AccessStatus status = capability.hasPermission(nodeRef);
|
||||
if (answer.put(capability, status) != null)
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
|
||||
*/
|
||||
public Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, List<String> capabilityNames)
|
||||
{
|
||||
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||
ParameterCheck.mandatory("capabilityNames", capabilityNames);
|
||||
|
||||
HashMap<Capability, AccessStatus> answer = new HashMap<Capability, AccessStatus>();
|
||||
for (String capabilityName : capabilityNames)
|
||||
{
|
||||
Capability capability = capabilities.get(capabilityName);
|
||||
if (capability != null)
|
||||
{
|
||||
AccessStatus status = capability.hasPermission(nodeRef);
|
||||
if (answer.put(capability, status) != null)
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilityAccessState(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public AccessStatus getCapabilityAccessState(NodeRef nodeRef, String capabilityName)
|
||||
{
|
||||
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||
ParameterCheck.mandatory("capabilityName", capabilityName);
|
||||
|
||||
AccessStatus result = AccessStatus.UNDETERMINED;
|
||||
Capability capability = getCapability(capabilityName);
|
||||
if (capability != null)
|
||||
{
|
||||
List<String> list = Collections.singletonList(capabilityName);
|
||||
Map<Capability, AccessStatus> map = getCapabilitiesAccessState(nodeRef, list);
|
||||
result = map.get(capability);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getGroups()
|
||||
*/
|
||||
@Override
|
||||
public List<Group> getGroups()
|
||||
{
|
||||
List<Group> groups = new ArrayList<Group>();
|
||||
for (Map.Entry<String, Group> entry : this.groups.entrySet())
|
||||
{
|
||||
groups.add(entry.getValue());
|
||||
}
|
||||
|
||||
Collections.sort(groups, new Comparator<Group>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Group g1, Group g2)
|
||||
{
|
||||
return g1.getIndex() - g2.getIndex();
|
||||
}
|
||||
});
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesByGroupId(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<Capability> getCapabilitiesByGroupId(String groupId)
|
||||
{
|
||||
ParameterCheck.mandatoryString("groupId", groupId);
|
||||
|
||||
String id = this.groups.get(groupId).getId();
|
||||
|
||||
List<Capability> capabilities = new ArrayList<Capability>();
|
||||
for (Capability capability : getCapabilities())
|
||||
{
|
||||
Group group = capability.getGroup();
|
||||
if (group != null)
|
||||
{
|
||||
if (group.getId().equalsIgnoreCase(id))
|
||||
{
|
||||
capabilities.add(capability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(capabilities, new Comparator<Capability>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Capability c1, Capability c2)
|
||||
{
|
||||
return c1.getIndex() - c2.getIndex();
|
||||
}
|
||||
});
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesByGroup(org.alfresco.module.org_alfresco_module_rm.capability.Group)
|
||||
*/
|
||||
@Override
|
||||
public List<Capability> getCapabilitiesByGroup(Group group)
|
||||
{
|
||||
ParameterCheck.mandatory("group", group);
|
||||
|
||||
return getCapabilitiesByGroupId(group.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getGroup(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Group getGroup(String groupId)
|
||||
{
|
||||
ParameterCheck.mandatoryString("groupId", groupId);
|
||||
|
||||
return this.groups.get(groupId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#addGroup(org.alfresco.module.org_alfresco_module_rm.capability.Group)
|
||||
*/
|
||||
@Override
|
||||
public void addGroup(Group group)
|
||||
{
|
||||
ParameterCheck.mandatory("group", group);
|
||||
|
||||
groups.put(group.getId(), group);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#removeGroup(org.alfresco.module.org_alfresco_module_rm.capability.Group)
|
||||
*/
|
||||
@Override
|
||||
public void removeGroup(Group group)
|
||||
{
|
||||
ParameterCheck.mandatory("group", group);
|
||||
|
||||
groups.remove(group.getId());
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.capability;
|
||||
|
||||
/**
|
||||
* Group interface
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface Group
|
||||
{
|
||||
/**
|
||||
* Gets the id of a group (Get the id of the group)
|
||||
*
|
||||
* @return String the group id
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Gets the title of a group
|
||||
*
|
||||
* @return String the group title
|
||||
*/
|
||||
String getTitle();
|
||||
|
||||
/**
|
||||
* Gets the index of a group
|
||||
*
|
||||
* @return int the group index
|
||||
*/
|
||||
int getIndex();
|
||||
}
|
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.capability;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Group implementation
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.1
|
||||
*/
|
||||
public class GroupImpl implements Group
|
||||
{
|
||||
/** The group id */
|
||||
private String id;
|
||||
|
||||
/** The group title */
|
||||
private String title;
|
||||
|
||||
/** The group index */
|
||||
private int index;
|
||||
|
||||
/** Capability service */
|
||||
private CapabilityService capabilityService;
|
||||
|
||||
/**
|
||||
* Sets the capability service
|
||||
*
|
||||
* @param capabilityService the capability service
|
||||
*/
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
{
|
||||
this.capabilityService = capabilityService;
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
this.capabilityService.addGroup(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Group#getId()
|
||||
*/
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Group#getTitle()
|
||||
*/
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
String title = this.title;
|
||||
if (StringUtils.isBlank(title))
|
||||
{
|
||||
title = I18NUtil.getMessage("capability.group." + getId() + ".title");
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Group#getIndex()
|
||||
*/
|
||||
@Override
|
||||
public int getIndex()
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public void setIndex(int index)
|
||||
{
|
||||
this.index = index;
|
||||
}
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.capability;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy;
|
||||
|
||||
/**
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public interface PolicyRegister
|
||||
{
|
||||
void registerPolicy(Policy policy);
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.capability;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
||||
import org.alfresco.repo.action.RuntimeActionService;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.springframework.aop.framework.ProxyFactoryBean;
|
||||
|
||||
/**
|
||||
* RM action proxy factory bean.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RMActionProxyFactoryBean extends ProxyFactoryBean
|
||||
{
|
||||
private static final long serialVersionUID = 539749542853266449L;
|
||||
|
||||
/** Runtime action service */
|
||||
protected RuntimeActionService runtimeActionService;
|
||||
|
||||
/** Records management action service */
|
||||
protected RecordsManagementActionService recordsManagementActionService;
|
||||
|
||||
/** Records management audit service */
|
||||
protected RecordsManagementAuditService recordsManagementAuditService;
|
||||
|
||||
/**
|
||||
* Set action service
|
||||
*
|
||||
* @param actionService
|
||||
*/
|
||||
public void setRuntimeActionService(RuntimeActionService runtimeActionService)
|
||||
{
|
||||
this.runtimeActionService = runtimeActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set records management service
|
||||
*
|
||||
* @param recordsManagementActionService
|
||||
*/
|
||||
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
|
||||
{
|
||||
this.recordsManagementActionService = recordsManagementActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set records management service
|
||||
*
|
||||
* @param recordsManagementAuditService
|
||||
*/
|
||||
public void setRecordsManagementAuditService(RecordsManagementAuditService recordsManagementAuditService)
|
||||
{
|
||||
this.recordsManagementAuditService = recordsManagementAuditService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the action
|
||||
*/
|
||||
public void registerAction()
|
||||
{
|
||||
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
RecordsManagementAction action = (RecordsManagementAction)getObject();
|
||||
recordsManagementActionService.register(action);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,347 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.capability;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.acegisecurity.Authentication;
|
||||
import net.sf.acegisecurity.ConfigAttribute;
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.policy.ConfigAttributeDefinition;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.policy.Policy;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.repo.transaction.TransactionalResourceHelper;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Records managment entry voter.
|
||||
*
|
||||
* @author Roy Wetherall, Andy Hind
|
||||
*/
|
||||
public class RMEntryVoter extends RMSecurityCommon
|
||||
implements AccessDecisionVoter, InitializingBean, PolicyRegister
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(RMEntryVoter.class);
|
||||
|
||||
/** Namespace resolver */
|
||||
private NamespacePrefixResolver nspr;
|
||||
|
||||
/** Capability Service */
|
||||
private CapabilityService capabilityService;
|
||||
|
||||
/** Policy map */
|
||||
private HashMap<String, Policy> policies = new HashMap<String, Policy>();
|
||||
|
||||
/**
|
||||
* @param capabilityService capability service
|
||||
*/
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
{
|
||||
this.capabilityService = capabilityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nspr namespace prefix resolver
|
||||
*/
|
||||
public void setNamespacePrefixResolver(NamespacePrefixResolver nspr)
|
||||
{
|
||||
this.nspr = nspr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a policy the voter
|
||||
*
|
||||
* @param policy policy
|
||||
*/
|
||||
public void registerPolicy(Policy policy)
|
||||
{
|
||||
policies.put(policy.getName(), policy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.sf.acegisecurity.vote.AccessDecisionVoter#supports(net.sf.acegisecurity.ConfigAttribute)
|
||||
*/
|
||||
@Override
|
||||
public boolean supports(ConfigAttribute attribute)
|
||||
{
|
||||
if ((attribute.getAttribute() != null) &&
|
||||
(attribute.getAttribute().equals(ConfigAttributeDefinition.RM_ABSTAIN) ||
|
||||
attribute.getAttribute().equals(ConfigAttributeDefinition.RM_QUERY) ||
|
||||
attribute.getAttribute().equals(ConfigAttributeDefinition.RM_ALLOW) ||
|
||||
attribute.getAttribute().equals(ConfigAttributeDefinition.RM_DENY) ||
|
||||
attribute.getAttribute().startsWith(ConfigAttributeDefinition.RM_CAP) ||
|
||||
attribute.getAttribute().startsWith(ConfigAttributeDefinition.RM)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.sf.acegisecurity.vote.AccessDecisionVoter#supports(java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public boolean supports(Class clazz)
|
||||
{
|
||||
return (MethodInvocation.class.isAssignableFrom(clazz));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.sf.acegisecurity.vote.AccessDecisionVoter#vote(net.sf.acegisecurity.Authentication, java.lang.Object, net.sf.acegisecurity.ConfigAttributeDefinition)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public int vote(Authentication authentication, Object object, net.sf.acegisecurity.ConfigAttributeDefinition config)
|
||||
{
|
||||
MethodInvocation mi = (MethodInvocation)object;
|
||||
|
||||
if (TransactionalResourceHelper.isResourcePresent("voting") == true)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" .. grant access already voting: " + mi.getMethod().getDeclaringClass().getName() + "." + mi.getMethod().getName());
|
||||
}
|
||||
return AccessDecisionVoter.ACCESS_GRANTED;
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Method: " + mi.getMethod().getDeclaringClass().getName() + "." + mi.getMethod().getName());
|
||||
}
|
||||
|
||||
AlfrescoTransactionSupport.bindResource("voting", true);
|
||||
try
|
||||
{
|
||||
// The system user can do anything
|
||||
if (AuthenticationUtil.isRunAsUserTheSystemUser())
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Access granted for the system user");
|
||||
}
|
||||
return AccessDecisionVoter.ACCESS_GRANTED;
|
||||
}
|
||||
|
||||
List<ConfigAttributeDefinition> supportedDefinitions = extractSupportedDefinitions(config);
|
||||
|
||||
// No RM definitions so we do not vote
|
||||
if (supportedDefinitions.size() == 0)
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_ABSTAIN;
|
||||
}
|
||||
|
||||
MethodInvocation invocation = (MethodInvocation) object;
|
||||
|
||||
Method method = invocation.getMethod();
|
||||
Class[] params = method.getParameterTypes();
|
||||
|
||||
// If there are only capability (RM_CAP) and policy (RM) entries non must deny
|
||||
// If any abstain we deny
|
||||
// All present must vote to allow unless an explicit direction comes first (e.g. RM_ALLOW)
|
||||
|
||||
for (ConfigAttributeDefinition cad : supportedDefinitions)
|
||||
{
|
||||
// Whatever is found first takes precedence
|
||||
if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_DENY))
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_DENIED;
|
||||
}
|
||||
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_ABSTAIN))
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_ABSTAIN;
|
||||
}
|
||||
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_ALLOW))
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_GRANTED;
|
||||
}
|
||||
// RM_QUERY is a special case - the entry is allowed and filtering sorts out the results
|
||||
// It is distinguished from RM_ALLOW so query may have additional behaviour in the future
|
||||
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_QUERY))
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_GRANTED;
|
||||
}
|
||||
// Ignore config that references method arguments that do not exist
|
||||
// Arguably we should deny here but that requires a full impact analysis
|
||||
// These entries effectively abstain
|
||||
else if (((cad.getParameters().get(0) != null) && (cad.getParameters().get(0) >= invocation.getArguments().length)) ||
|
||||
((cad.getParameters().get(1) != null) && (cad.getParameters().get(1) >= invocation.getArguments().length)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM_CAP))
|
||||
{
|
||||
switch(checkCapability(invocation, params, cad))
|
||||
{
|
||||
case AccessDecisionVoter.ACCESS_DENIED:
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_DENIED;
|
||||
}
|
||||
case AccessDecisionVoter.ACCESS_ABSTAIN:
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
if(logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("Capability " + cad.getRequired() + " abstained for " + invocation.getMethod(), new IllegalStateException());
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug("Capability " + cad.getRequired() + " abstained for " + invocation.getMethod());
|
||||
}
|
||||
}
|
||||
// abstain denies
|
||||
return AccessDecisionVoter.ACCESS_DENIED;
|
||||
}
|
||||
case AccessDecisionVoter.ACCESS_GRANTED:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cad.getTypeString().equals(ConfigAttributeDefinition.RM))
|
||||
{
|
||||
switch(checkPolicy(invocation, params, cad))
|
||||
{
|
||||
case AccessDecisionVoter.ACCESS_DENIED:
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_DENIED;
|
||||
}
|
||||
case AccessDecisionVoter.ACCESS_ABSTAIN:
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
if(logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("Policy " + cad.getPolicyName() + " abstained for " + invocation.getMethod(), new IllegalStateException());
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug("Policy " + cad.getPolicyName() + " abstained for " + invocation.getMethod());
|
||||
}
|
||||
}
|
||||
// abstain denies
|
||||
return AccessDecisionVoter.ACCESS_DENIED;
|
||||
}
|
||||
case AccessDecisionVoter.ACCESS_GRANTED:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
AlfrescoTransactionSupport.unbindResource("voting");
|
||||
}
|
||||
|
||||
// all voted to allow
|
||||
return AccessDecisionVoter.ACCESS_GRANTED;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param invocation
|
||||
* @param params
|
||||
* @param cad
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
private int checkCapability(MethodInvocation invocation, Class[] params, ConfigAttributeDefinition cad)
|
||||
{
|
||||
NodeRef testNodeRef = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent());
|
||||
if (testNodeRef == null)
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_ABSTAIN;
|
||||
}
|
||||
Capability capability = capabilityService.getCapability(cad.getRequired().getName());
|
||||
if (capability == null)
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_DENIED;
|
||||
}
|
||||
return capability.hasPermissionRaw(testNodeRef);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param invocation
|
||||
* @param params
|
||||
* @param cad
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
private int checkPolicy(MethodInvocation invocation, Class[] params, ConfigAttributeDefinition cad)
|
||||
{
|
||||
Policy policy = policies.get(cad.getPolicyName());
|
||||
if (policy == null)
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_GRANTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return policy.evaluate(invocation, params, cad);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
private List<ConfigAttributeDefinition> extractSupportedDefinitions(net.sf.acegisecurity.ConfigAttributeDefinition config)
|
||||
{
|
||||
List<ConfigAttributeDefinition> definitions = new ArrayList<ConfigAttributeDefinition>(2);
|
||||
Iterator iter = config.getConfigAttributes();
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
ConfigAttribute attr = (ConfigAttribute) iter.next();
|
||||
|
||||
if (this.supports(attr))
|
||||
{
|
||||
definitions.add(new ConfigAttributeDefinition(attr, nspr));
|
||||
}
|
||||
|
||||
}
|
||||
return definitions;
|
||||
}
|
||||
}
|
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.capability;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.security.permissions.impl.SimplePermissionReference;
|
||||
|
||||
/**
|
||||
* Capability constants for the RM Permission Model
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public interface RMPermissionModel
|
||||
{
|
||||
// Assignment of Filing
|
||||
public static final String FILING = "Filing";
|
||||
public static final String READ_RECORDS = "ReadRecords";
|
||||
public static final String FILE_RECORDS = "FileRecords";
|
||||
|
||||
// Roles
|
||||
public static final String ROLE_NAME_USER = "User";
|
||||
public static final String ROLE_NAME_POWER_USER = "PowerUser";
|
||||
public static final String ROLE_NAME_SECURITY_OFFICER = "SecurityOfficer";
|
||||
public static final String ROLE_NAME_RECORDS_MANAGER = "RecordsManager";
|
||||
|
||||
public static final String ROLE_NAME_ADMINISTRATOR = "Administrator";
|
||||
public static final String ROLE_ADMINISTRATOR = SimplePermissionReference.getPermissionReference(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT, ROLE_NAME_ADMINISTRATOR).toString();
|
||||
|
||||
// Capability permissions
|
||||
|
||||
public static final String DECLARE_RECORDS = "DeclareRecords";
|
||||
|
||||
public static final String VIEW_RECORDS = "ViewRecords";
|
||||
|
||||
public static final String CREATE_MODIFY_DESTROY_FOLDERS = "CreateModifyDestroyFolders";
|
||||
|
||||
public static final String EDIT_RECORD_METADATA = "EditRecordMetadata";
|
||||
|
||||
public static final String EDIT_NON_RECORD_METADATA = "EditNonRecordMetadata";
|
||||
|
||||
public static final String ADD_MODIFY_EVENT_DATES = "AddModifyEventDates";
|
||||
|
||||
public static final String CLOSE_FOLDERS = "CloseFolders";
|
||||
|
||||
public static final String DECLARE_RECORDS_IN_CLOSED_FOLDERS = "DeclareRecordsInClosedFolders";
|
||||
|
||||
public static final String RE_OPEN_FOLDERS = "ReOpenFolders";
|
||||
|
||||
public static final String CYCLE_VITAL_RECORDS = "CycleVitalRecords";
|
||||
|
||||
public static final String PLANNING_REVIEW_CYCLES = "PlanningReviewCycles";
|
||||
|
||||
public static final String UPDATE_TRIGGER_DATES = "UpdateTriggerDates";
|
||||
|
||||
public static final String CREATE_MODIFY_DESTROY_EVENTS = "CreateModifyDestroyEvents";
|
||||
|
||||
public static final String MANAGE_ACCESS_RIGHTS = "ManageAccessRights";
|
||||
|
||||
public static final String MOVE_RECORDS = "MoveRecords";
|
||||
|
||||
public static final String CHANGE_OR_DELETE_REFERENCES = "ChangeOrDeleteReferences";
|
||||
|
||||
public static final String DELETE_LINKS = "DeleteLinks";
|
||||
|
||||
public static final String EDIT_DECLARED_RECORD_METADATA = "EditDeclaredRecordMetadata";
|
||||
|
||||
public static final String MANUALLY_CHANGE_DISPOSITION_DATES = "ManuallyChangeDispositionDates";
|
||||
|
||||
public static final String APPROVE_RECORDS_SCHEDULED_FOR_CUTOFF = "ApproveRecordsScheduledForCutoff";
|
||||
|
||||
public static final String CREATE_MODIFY_RECORDS_IN_CUTOFF_FOLDERS = "CreateModifyRecordsInCutoffFolders";
|
||||
|
||||
public static final String EXTEND_RETENTION_PERIOD_OR_FREEZE = "ExtendRetentionPeriodOrFreeze";
|
||||
|
||||
public static final String UNFREEZE = "Unfreeze";
|
||||
|
||||
public static final String VIEW_UPDATE_REASONS_FOR_FREEZE = "ViewUpdateReasonsForFreeze";
|
||||
|
||||
public static final String DESTROY_RECORDS_SCHEDULED_FOR_DESTRUCTION = "DestroyRecordsScheduledForDestruction";
|
||||
|
||||
public static final String DESTROY_RECORDS = "DestroyRecords";
|
||||
|
||||
public static final String UPDATE_VITAL_RECORD_CYCLE_INFORMATION = "UpdateVitalRecordCycleInformation";
|
||||
|
||||
public static final String UNDECLARE_RECORDS = "UndeclareRecords";
|
||||
|
||||
public static final String DECLARE_AUDIT_AS_RECORD = "DeclareAuditAsRecord";
|
||||
|
||||
public static final String DELETE_AUDIT = "DeleteAudit";
|
||||
|
||||
public static final String CREATE_MODIFY_DESTROY_TIMEFRAMES = "CreateModifyDestroyTimeframes";
|
||||
|
||||
public static final String AUTHORIZE_NOMINATED_TRANSFERS = "AuthorizeNominatedTransfers";
|
||||
|
||||
public static final String EDIT_SELECTION_LISTS = "EditSelectionLists";
|
||||
|
||||
public static final String AUTHORIZE_ALL_TRANSFERS = "AuthorizeAllTransfers";
|
||||
|
||||
public static final String CREATE_MODIFY_DESTROY_FILEPLAN_METADATA = "CreateModifyDestroyFileplanMetadata";
|
||||
|
||||
public static final String CREATE_AND_ASSOCIATE_SELECTION_LISTS = "CreateAndAssociateSelectionLists";
|
||||
|
||||
public static final String ATTACH_RULES_TO_METADATA_PROPERTIES = "AttachRulesToMetadataProperties";
|
||||
|
||||
public static final String CREATE_MODIFY_DESTROY_FILEPLAN_TYPES = "CreateModifyDestroyFileplanTypes";
|
||||
|
||||
public static final String CREATE_MODIFY_DESTROY_RECORD_TYPES = "CreateModifyDestroyRecordTypes";
|
||||
|
||||
public static final String MAKE_OPTIONAL_PARAMETERS_MANDATORY = "MakeOptionalParametersMandatory";
|
||||
|
||||
public static final String MAP_EMAIL_METADATA = "MapEmailMetadata";
|
||||
|
||||
public static final String DELETE_RECORDS = "DeleteRecords";
|
||||
|
||||
public static final String TRIGGER_AN_EVENT = "TriggerAnEvent";
|
||||
|
||||
public static final String CREATE_MODIFY_DESTROY_ROLES = "CreateModifyDestroyRoles";
|
||||
|
||||
public static final String CREATE_MODIFY_DESTROY_USERS_AND_GROUPS = "CreateModifyDestroyUsersAndGroups";
|
||||
|
||||
public static final String PASSWORD_CONTROL = "PasswordControl";
|
||||
|
||||
public static final String ENABLE_DISABLE_AUDIT_BY_TYPES = "EnableDisableAuditByTypes";
|
||||
|
||||
public static final String SELECT_AUDIT_METADATA = "SelectAuditMetadata";
|
||||
|
||||
public static final String DISPLAY_RIGHTS_REPORT = "DisplayRightsReport";
|
||||
|
||||
public static final String ACCESS_AUDIT = "AccessAudit";
|
||||
|
||||
public static final String EXPORT_AUDIT = "ExportAudit";
|
||||
|
||||
public static final String CREATE_MODIFY_DESTROY_REFERENCE_TYPES = "CreateModifyDestroyReferenceTypes";
|
||||
|
||||
public static final String UPDATE_CLASSIFICATION_DATES = "UpdateClassificationDates";
|
||||
|
||||
public static final String CREATE_MODIFY_DESTROY_CLASSIFICATION_GUIDES = "CreateModifyDestroyClassificationGuides";
|
||||
|
||||
public static final String UPGRADE_DOWNGRADE_AND_DECLASSIFY_RECORDS = "UpgradeDowngradeAndDeclassifyRecords";
|
||||
|
||||
public static final String UPDATE_EXEMPTION_CATEGORIES = "UpdateExemptionCategories";
|
||||
|
||||
public static final String MAP_CLASSIFICATION_GUIDE_METADATA = "MapClassificationGuideMetadata";
|
||||
|
||||
public static final String MANAGE_ACCESS_CONTROLS = "ManageAccessControls";
|
||||
}
|
@@ -1,357 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.capability;
|
||||
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigComponent;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
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.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Common security functions.
|
||||
*
|
||||
* TODO move methods to the appropriate services
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.0
|
||||
*/
|
||||
public class RMSecurityCommon
|
||||
{
|
||||
/** No set value */
|
||||
protected int NOSET_VALUE = -100;
|
||||
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(RMSecurityCommon.class);
|
||||
|
||||
/** Services */
|
||||
protected NodeService nodeService; //This is the internal NodeService -- no permission checks
|
||||
protected PermissionService permissionService;
|
||||
protected RMCaveatConfigComponent caveatConfigComponent;
|
||||
protected FilePlanService filePlanService;
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permissionService permission service
|
||||
*/
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param caveatConfigComponent caveat config service
|
||||
*/
|
||||
public void setCaveatConfigComponent(RMCaveatConfigComponent caveatConfigComponent)
|
||||
{
|
||||
this.caveatConfigComponent = caveatConfigComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value into the transaction cache
|
||||
*
|
||||
* @param prefix
|
||||
* @param nodeRef
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
protected int setTransactionCache(String prefix, NodeRef nodeRef, int value)
|
||||
{
|
||||
String user = AuthenticationUtil.getRunAsUser();
|
||||
AlfrescoTransactionSupport.bindResource(prefix + nodeRef.toString() + user, Integer.valueOf(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value from the transaction cache
|
||||
*
|
||||
* @param prefix
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
protected int getTransactionCache(String prefix, NodeRef nodeRef)
|
||||
{
|
||||
int result = NOSET_VALUE;
|
||||
String user = AuthenticationUtil.getRunAsUser();
|
||||
Integer value = (Integer)AlfrescoTransactionSupport.getResource(prefix + nodeRef.toString() + user);
|
||||
if (value != null)
|
||||
{
|
||||
result = value.intValue();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for RM read
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
public int checkRead(NodeRef nodeRef)
|
||||
{
|
||||
int result = AccessDecisionVoter.ACCESS_ABSTAIN;
|
||||
if (nodeRef != null)
|
||||
{
|
||||
// now we know the node - we can abstain for certain types and aspects (eg, rm)
|
||||
result = checkRead(nodeRef, false);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for RM read
|
||||
*
|
||||
* @param nodeRef
|
||||
* @param allowDMRead
|
||||
* @return
|
||||
*/
|
||||
public int checkRead(NodeRef nodeRef, boolean allowDMRead)
|
||||
{
|
||||
int result = AccessDecisionVoter.ACCESS_ABSTAIN;
|
||||
|
||||
if (nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)== true)
|
||||
{
|
||||
result = checkRmRead(nodeRef);
|
||||
}
|
||||
else if (allowDMRead == true)
|
||||
{
|
||||
// Check DM read for copy etc
|
||||
// DM does not grant - it can only deny
|
||||
if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("\t\tPermission is denied");
|
||||
Thread.dumpStack();
|
||||
}
|
||||
result = AccessDecisionVoter.ACCESS_DENIED;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = AccessDecisionVoter.ACCESS_GRANTED;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
public int checkRmRead(NodeRef nodeRef)
|
||||
{
|
||||
int result = getTransactionCache("checkRmRead", nodeRef);
|
||||
if (result != NOSET_VALUE)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
// Get the file plan for the node
|
||||
NodeRef filePlan = filePlanService.getFilePlan(nodeRef);
|
||||
|
||||
// Admin role
|
||||
//if (permissionService.hasPermission(filePlan, RMPermissionModel.ROLE_ADMINISTRATOR) == AccessStatus.ALLOWED)
|
||||
//{
|
||||
// if (logger.isDebugEnabled())
|
||||
// {
|
||||
// logger.debug("\t\tAdmin user, access granted. (nodeRef=" + nodeRef.toString() + ", user=" + AuthenticationUtil.getRunAsUser() + ")");
|
||||
// }
|
||||
// return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_GRANTED);
|
||||
// }
|
||||
|
||||
if (permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS) == AccessStatus.DENIED)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("\t\tUser does not have read record permission on node, access denied. (nodeRef=" + nodeRef.toString() + ", user=" + AuthenticationUtil.getRunAsUser() + ")");
|
||||
}
|
||||
return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_DENIED);
|
||||
}
|
||||
|
||||
if (permissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS) == AccessStatus.DENIED)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("\t\tUser does not have view records capability permission on node, access denied. (filePlan=" + filePlan.toString() + ", user=" + AuthenticationUtil.getRunAsUser() + ")");
|
||||
}
|
||||
return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_DENIED);
|
||||
}
|
||||
|
||||
if (caveatConfigComponent.hasAccess(nodeRef))
|
||||
{
|
||||
return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_GRANTED);
|
||||
}
|
||||
else
|
||||
{
|
||||
return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_DENIED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected NodeRef getTestNode(MethodInvocation invocation, Class[] params, int position, boolean parent)
|
||||
{
|
||||
NodeRef testNodeRef = null;
|
||||
if (position < 0)
|
||||
{
|
||||
testNodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (testNodeRef == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to find default file plan node.");
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("\tPermission test against the file plan node " + nodeService.getPath(testNodeRef));
|
||||
}
|
||||
}
|
||||
else if (StoreRef.class.isAssignableFrom(params[position]))
|
||||
{
|
||||
if (invocation.getArguments()[position] != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("\tPermission test against the store - using permissions on the root node");
|
||||
}
|
||||
StoreRef storeRef = (StoreRef) invocation.getArguments()[position];
|
||||
if (nodeService.exists(storeRef))
|
||||
{
|
||||
testNodeRef = nodeService.getRootNode(storeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (NodeRef.class.isAssignableFrom(params[position]))
|
||||
{
|
||||
testNodeRef = (NodeRef) invocation.getArguments()[position];
|
||||
if (parent)
|
||||
{
|
||||
testNodeRef = nodeService.getPrimaryParent(testNodeRef).getParentRef();
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
if (nodeService.exists(testNodeRef))
|
||||
{
|
||||
logger.debug("\tPermission test for parent on node " + nodeService.getPath(testNodeRef));
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug("\tPermission test for parent on non-existing node " + testNodeRef);
|
||||
}
|
||||
logger.debug("\tPermission test for parent on node " + nodeService.getPath(testNodeRef));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
if (nodeService.exists(testNodeRef))
|
||||
{
|
||||
logger.debug("\tPermission test on node " + nodeService.getPath(testNodeRef));
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug("\tPermission test on non-existing node " + testNodeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ChildAssociationRef.class.isAssignableFrom(params[position]))
|
||||
{
|
||||
if (invocation.getArguments()[position] != null)
|
||||
{
|
||||
if (parent)
|
||||
{
|
||||
testNodeRef = ((ChildAssociationRef) invocation.getArguments()[position]).getParentRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
testNodeRef = ((ChildAssociationRef) invocation.getArguments()[position]).getChildRef();
|
||||
}
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
if (nodeService.exists(testNodeRef))
|
||||
{
|
||||
logger.debug("\tPermission test on node " + nodeService.getPath(testNodeRef));
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug("\tPermission test on non-existing node " + testNodeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (AssociationRef.class.isAssignableFrom(params[position]))
|
||||
{
|
||||
if (invocation.getArguments()[position] != null)
|
||||
{
|
||||
if (parent)
|
||||
{
|
||||
testNodeRef = ((AssociationRef) invocation.getArguments()[position]).getSourceRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
testNodeRef = ((AssociationRef) invocation.getArguments()[position]).getTargetRef();
|
||||
}
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
if (nodeService.exists(testNodeRef))
|
||||
{
|
||||
logger.debug("\tPermission test on node " + nodeService.getPath(testNodeRef));
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug("\tPermission test on non-existing node " + testNodeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return testNodeRef;
|
||||
}
|
||||
}
|
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.capability.declarative;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
|
||||
/**
|
||||
* Abstract capability condition.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public abstract class AbstractCapabilityCondition implements CapabilityCondition,
|
||||
BeanNameAware,
|
||||
RecordsManagementModel
|
||||
{
|
||||
/** Capability condition name */
|
||||
protected String name;
|
||||
|
||||
/** Services */
|
||||
protected RecordService recordService;
|
||||
protected PermissionService permissionService;
|
||||
protected NodeService nodeService;
|
||||
protected FreezeService freezeService;
|
||||
protected FilePlanService filePlanService;
|
||||
protected DispositionService dispositionService;
|
||||
protected RecordFolderService recordFolderService;
|
||||
|
||||
/**
|
||||
* @param recordService record service
|
||||
*/
|
||||
public void setRecordService(RecordService recordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permissionService permission service
|
||||
*/
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param freezeService freeze service
|
||||
*/
|
||||
public void setFreezeService(FreezeService freezeService)
|
||||
{
|
||||
this.freezeService = freezeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dispositionService disposition service
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param recordFolderService record folder service
|
||||
*/
|
||||
public void setRecordFolderService(RecordFolderService recordFolderService)
|
||||
{
|
||||
this.recordFolderService = recordFolderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setBeanName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* 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.module.org_alfresco_module_rm.capability.declarative;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
public interface CapabilityCondition
|
||||
{
|
||||
String getName();
|
||||
|
||||
boolean evaluate(NodeRef nodeRef);
|
||||
}
|
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.capability.declarative;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Generic implementation of a composite capability
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class CompositeCapability extends DeclarativeCapability
|
||||
{
|
||||
/** List of capabilities */
|
||||
private List<Capability> capabilities;
|
||||
|
||||
/**
|
||||
* @param capabilites list of capabilities
|
||||
*/
|
||||
public void setCapabilities(List<Capability> capabilities)
|
||||
{
|
||||
this.capabilities = capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability#evaluateImpl(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public int evaluateImpl(NodeRef nodeRef)
|
||||
{
|
||||
int result = AccessDecisionVoter.ACCESS_DENIED;
|
||||
|
||||
// Check each capability using 'OR' logic
|
||||
for (Capability capability : capabilities)
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Evaluating child capability " + capability.getName() + " on nodeRef " + nodeRef.toString() + " for composite capability " + name);
|
||||
}
|
||||
|
||||
int capabilityResult = capability.evaluate(nodeRef);
|
||||
if (capabilityResult != AccessDecisionVoter.ACCESS_DENIED)
|
||||
{
|
||||
result = AccessDecisionVoter.ACCESS_ABSTAIN;
|
||||
if (isUndetermined() == false && capabilityResult == AccessDecisionVoter.ACCESS_GRANTED)
|
||||
{
|
||||
result = AccessDecisionVoter.ACCESS_GRANTED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Access denied for child capability " + capability.getName() + " on nodeRef " + nodeRef.toString() + " for composite capability " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a target capability is specified then we evaluate that. Otherwise we combine the results of the provided capabilities.
|
||||
*
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public int evaluate(NodeRef source, NodeRef target)
|
||||
{
|
||||
int result = AccessDecisionVoter.ACCESS_ABSTAIN;
|
||||
|
||||
// Check we are dealing with a file plan component
|
||||
if (filePlanService.isFilePlanComponent(source) == true &&
|
||||
filePlanService.isFilePlanComponent(target) == true)
|
||||
{
|
||||
// Check the kind of the object, the permissions and the conditions
|
||||
if (checkKinds(source) == true && checkPermissions(source) == true && checkConditions(source) == true)
|
||||
{
|
||||
if (targetCapability != null)
|
||||
{
|
||||
result = targetCapability.evaluate(target);
|
||||
}
|
||||
|
||||
if (AccessDecisionVoter.ACCESS_DENIED != result)
|
||||
{
|
||||
// Check each capability using 'OR' logic
|
||||
for (Capability capability : capabilities)
|
||||
{
|
||||
result = capability.evaluate(source, target);
|
||||
if (result == AccessDecisionVoter.ACCESS_GRANTED)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = AccessDecisionVoter.ACCESS_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,368 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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.module.org_alfresco_module_rm.capability.declarative;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.AbstractCapability;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
/**
|
||||
* Declarative capability implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class DeclarativeCapability extends AbstractCapability
|
||||
implements ApplicationContextAware
|
||||
{
|
||||
/** Logger */
|
||||
protected static Log logger = LogFactory.getLog(DeclarativeCapability.class);
|
||||
|
||||
/** Application Context */
|
||||
protected ApplicationContext applicationContext;
|
||||
|
||||
/** Required permissions */
|
||||
protected List<String> permissions;
|
||||
|
||||
/** Map of conditions and expected evaluation result */
|
||||
protected Map<String, Boolean> conditions;
|
||||
|
||||
/** List of file plan component kinds one of which must be satisfied */
|
||||
protected List<String> kinds;
|
||||
|
||||
/** Capability to be evaluated against the target node reference */
|
||||
protected Capability targetCapability;
|
||||
|
||||
/** Indicates whether to return an undetermined result */
|
||||
protected boolean isUndetermined = false;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
{
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permissions permissions
|
||||
*/
|
||||
public void setPermissions(List<String> permissions)
|
||||
{
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param conditions conditions and expected values
|
||||
*/
|
||||
public void setConditions(Map<String, Boolean> conditions)
|
||||
{
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link Map}<String, Boolean> conditions and expected values
|
||||
*/
|
||||
public Map<String, Boolean> getConditions()
|
||||
{
|
||||
return conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param kinds list of file plan component kinds
|
||||
*/
|
||||
public void setKinds(List<String> kinds)
|
||||
{
|
||||
this.kinds = kinds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link List}<@link String> list of expected file plan component kinds
|
||||
*/
|
||||
public List<String> getKinds()
|
||||
{
|
||||
return kinds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set a single kind.
|
||||
*
|
||||
* @param kind file plan component kind
|
||||
*/
|
||||
public void setKind(String kind)
|
||||
{
|
||||
this.kinds = Collections.singletonList(kind);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the capability will return an undetermined result when evaluating permissions
|
||||
* for a single node reference or not. The default is to return grant.
|
||||
*
|
||||
* @param isUndetermined true if undetermined result, false otherwise
|
||||
*/
|
||||
public void setUndetermined(boolean isUndetermined)
|
||||
{
|
||||
this.isUndetermined = isUndetermined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean isUndetermined()
|
||||
{
|
||||
return isUndetermined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper @see #setPermissions(List)
|
||||
*
|
||||
* @param permission permission
|
||||
*/
|
||||
public void setPermission(String permission)
|
||||
{
|
||||
List<String> permissions = new ArrayList<String>(1);
|
||||
permissions.add(permission);
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetCapability target capability
|
||||
*/
|
||||
public void setTargetCapability(Capability targetCapability)
|
||||
{
|
||||
this.targetCapability = targetCapability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the permissions passed.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return boolean true if the permissions are present, false otherwise
|
||||
*/
|
||||
protected boolean checkPermissionsImpl(NodeRef nodeRef, String ... permissions)
|
||||
{
|
||||
boolean result = true;
|
||||
NodeRef filePlan = filePlanService.getFilePlan(nodeRef);
|
||||
|
||||
for (String permission : permissions)
|
||||
{
|
||||
if (permissionService.hasPermission(filePlan, permission) != AccessStatus.ALLOWED)
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the permissions required for the capability.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
protected boolean checkPermissions(NodeRef nodeRef)
|
||||
{
|
||||
boolean result = true;
|
||||
if (permissions != null && permissions.isEmpty() == false)
|
||||
{
|
||||
result = checkPermissionsImpl(nodeRef, (String[])permissions.toArray(new String[permissions.size()]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the passed conditions.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
protected boolean checkConditions(NodeRef nodeRef, Map<String, Boolean> conditions)
|
||||
{
|
||||
boolean result = true;
|
||||
if (conditions != null)
|
||||
{
|
||||
for (Map.Entry<String, Boolean> entry : conditions.entrySet())
|
||||
{
|
||||
boolean expected = entry.getValue().booleanValue();
|
||||
String conditionName = entry.getKey();
|
||||
|
||||
CapabilityCondition condition = (CapabilityCondition)applicationContext.getBean(conditionName);
|
||||
if (condition == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Capability condition " + conditionName + " does not exist. Check the configuration of the capability " + name + ".");
|
||||
}
|
||||
|
||||
boolean actual = condition.evaluate(nodeRef);
|
||||
if (expected != actual)
|
||||
{
|
||||
result = false;
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Condition " + condition.getName() + " failed for capability " + getName() + " on nodeRef " + nodeRef.toString());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the set conditions.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return boolean true if conditions satisfied, false otherwise
|
||||
*/
|
||||
protected boolean checkConditions(NodeRef nodeRef)
|
||||
{
|
||||
return checkConditions(nodeRef, conditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the node ref is of the expected kind
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
protected boolean checkKinds(NodeRef nodeRef)
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
FilePlanComponentKind actualKind = filePlanService.getFilePlanComponentKind(nodeRef);
|
||||
|
||||
if (actualKind != null)
|
||||
{
|
||||
if (kinds != null && kinds.isEmpty() == false)
|
||||
{
|
||||
// need to check the actual file plan kind is in the list specified
|
||||
for (String kindString : kinds)
|
||||
{
|
||||
FilePlanComponentKind kind = FilePlanComponentKind.valueOf(kindString);
|
||||
if (actualKind.equals(kind) == true)
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we don't have any specific kinds to check, so we pass since we have a file
|
||||
// plan component in our hands
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.AbstractCapability#hasPermissionImpl(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public int evaluate(NodeRef nodeRef)
|
||||
{
|
||||
int result = AccessDecisionVoter.ACCESS_ABSTAIN;
|
||||
|
||||
// Check we are dealing with a file plan component
|
||||
if (filePlanService.isFilePlanComponent(nodeRef) == true)
|
||||
{
|
||||
// Check the kind of the object, the permissions and the conditions
|
||||
if (checkKinds(nodeRef) == true && checkPermissions(nodeRef) == true && checkConditions(nodeRef) == true)
|
||||
{
|
||||
// Opportunity for child implementations to extend
|
||||
result = evaluateImpl(nodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = AccessDecisionVoter.ACCESS_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
// Last chance for child implementations to veto/change the result
|
||||
result = onEvaluate(nodeRef, result);
|
||||
|
||||
// log access denied to help with debug
|
||||
if (logger.isDebugEnabled() == true && AccessDecisionVoter.ACCESS_DENIED == result)
|
||||
{
|
||||
logger.debug("Capability " + getName() + " returned an Access Denied result during evaluation of node " + nodeRef.toString());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int evaluate(NodeRef source, NodeRef target)
|
||||
{
|
||||
int result = evaluate(source);
|
||||
if (targetCapability != null && result != AccessDecisionVoter.ACCESS_DENIED)
|
||||
{
|
||||
result = targetCapability.evaluate(target);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation. Given extending classes a hook point for further checks.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return
|
||||
*/
|
||||
protected int evaluateImpl(NodeRef nodeRef)
|
||||
{
|
||||
int result = AccessDecisionVoter.ACCESS_GRANTED;
|
||||
if (isUndetermined == true)
|
||||
{
|
||||
result = AccessDecisionVoter.ACCESS_ABSTAIN;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation.
|
||||
*
|
||||
* Called before evaluate completes. The result returned overwrites the already discovered result.
|
||||
* Provides a hook point for child implementations that wish to veto the result.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
protected int onEvaluate(NodeRef nodeRef, int result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user