mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
include_declare_record_refactoring_in_Rest
This commit is contained in:
@@ -388,8 +388,7 @@
|
|||||||
|
|
||||||
<bean id="declareRecord" class="org.alfresco.module.org_alfresco_module_rm.action.impl.DeclareRecordAction" parent="rmAction">
|
<bean id="declareRecord" class="org.alfresco.module.org_alfresco_module_rm.action.impl.DeclareRecordAction" parent="rmAction">
|
||||||
<property name="publicAction" value="true"/>
|
<property name="publicAction" value="true"/>
|
||||||
<property name="checkMandatoryPropertiesEnabled" value="${rm.completerecord.mandatorypropertiescheck.enabled}"/>
|
<property name="recordService" ref="RecordService" />
|
||||||
<property name="transactionalResourceHelper" ref="rm.transactionalResourceHelper" />
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- undeclare record -->
|
<!-- undeclare record -->
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -27,33 +27,13 @@
|
|||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||||
|
|
||||||
import static org.alfresco.module.org_alfresco_module_rm.record.RecordUtils.generateRecordIdentifier;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
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.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl;
|
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper;
|
|
||||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.node.integrity.IntegrityException;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
|
||||||
import org.alfresco.service.cmr.action.Action;
|
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.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.security.OwnableService;
|
import org.alfresco.util.ParameterCheck;
|
||||||
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
|
* Declare record action
|
||||||
@@ -62,36 +42,24 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
|||||||
*/
|
*/
|
||||||
public class DeclareRecordAction extends RMActionExecuterAbstractBase
|
public class DeclareRecordAction extends RMActionExecuterAbstractBase
|
||||||
{
|
{
|
||||||
/** action name */
|
/**
|
||||||
|
* action name
|
||||||
|
*/
|
||||||
public static final String NAME = "declareRecord";
|
public static final String NAME = "declareRecord";
|
||||||
|
|
||||||
/** I18N */
|
/**
|
||||||
private static final String MSG_UNDECLARED_ONLY_RECORDS = "rm.action.undeclared-only-records";
|
* Record service
|
||||||
private static final String MSG_NO_DECLARE_MAND_PROP = "rm.action.no-declare-mand-prop";
|
*/
|
||||||
|
private RecordService recordService;
|
||||||
/** Logger */
|
|
||||||
private static Log logger = LogFactory.getLog(DeclareRecordAction.class);
|
|
||||||
|
|
||||||
/** check mandatory properties */
|
|
||||||
private boolean checkMandatoryPropertiesEnabled = true;
|
|
||||||
|
|
||||||
/** transactional resource helper */
|
|
||||||
private TransactionalResourceHelper transactionalResourceHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param checkMandatoryPropertiesEnabled true if check mandatory properties is enabled, false otherwise
|
* Sets the record service
|
||||||
|
*
|
||||||
|
* @param recordService record service
|
||||||
*/
|
*/
|
||||||
public void setCheckMandatoryPropertiesEnabled(boolean checkMandatoryPropertiesEnabled)
|
public void setRecordService(RecordService recordService)
|
||||||
{
|
{
|
||||||
this.checkMandatoryPropertiesEnabled = checkMandatoryPropertiesEnabled;
|
this.recordService = recordService;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param transactionalResourceHelper
|
|
||||||
*/
|
|
||||||
public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper)
|
|
||||||
{
|
|
||||||
this.transactionalResourceHelper = transactionalResourceHelper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,167 +68,14 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
|
|||||||
@Override
|
@Override
|
||||||
protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef)
|
protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef)
|
||||||
{
|
{
|
||||||
if (getNodeService().exists(actionedUponNodeRef) &&
|
ParameterCheck.mandatory("actionedUponNodeRef", actionedUponNodeRef);
|
||||||
getRecordService().isRecord(actionedUponNodeRef) &&
|
try
|
||||||
!getFreezeService().isFrozen(actionedUponNodeRef))
|
|
||||||
{
|
{
|
||||||
if (!getRecordService().isDeclared(actionedUponNodeRef))
|
recordService.complete(actionedUponNodeRef);
|
||||||
{
|
} catch (IntegrityException e)
|
||||||
// if the record is newly created make sure the record identifier is set before completing the record
|
|
||||||
Set<NodeRef> newRecords = transactionalResourceHelper.getSet(RecordServiceImpl.KEY_NEW_RECORDS);
|
|
||||||
if(newRecords.contains(actionedUponNodeRef))
|
|
||||||
{
|
|
||||||
generateRecordIdentifier(getNodeService(), getIdentifierService(), actionedUponNodeRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> missingProperties = new ArrayList<>(5);
|
|
||||||
// Aspect not already defined - check mandatory properties then add
|
|
||||||
if (!checkMandatoryPropertiesEnabled ||
|
|
||||||
mandatoryPropertiesSet(actionedUponNodeRef, missingProperties))
|
|
||||||
{
|
|
||||||
getRecordService().disablePropertyEditableCheck();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Add the declared aspect
|
|
||||||
Map<QName, Serializable> declaredProps = new HashMap<>(2);
|
|
||||||
declaredProps.put(PROP_DECLARED_AT, new Date());
|
|
||||||
declaredProps.put(PROP_DECLARED_BY, AuthenticationUtil.getRunAsUser());
|
|
||||||
this.getNodeService().addAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD, declaredProps);
|
|
||||||
|
|
||||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Void doWork()
|
|
||||||
{
|
|
||||||
// remove all owner related rights
|
|
||||||
getOwnableService().setOwner(actionedUponNodeRef, OwnableService.NO_OWNER);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
getRecordService().enablePropertyEditableCheck();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.debug(buildMissingPropertiesErrorString(missingProperties));
|
|
||||||
action.setParameterValue(ActionExecuterAbstractBase.PARAM_RESULT, "missingProperties");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (logger.isWarnEnabled())
|
action.setParameterValue(ActionExecuterAbstractBase.PARAM_RESULT, e.getMessage());
|
||||||
{
|
|
||||||
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.getNodeService().getProperties(nodeRef);
|
|
||||||
|
|
||||||
QName nodeRefType = this.getNodeService().getType(nodeRef);
|
|
||||||
|
|
||||||
TypeDefinition typeDef = this.getDictionaryService().getType(nodeRefType);
|
|
||||||
for (PropertyDefinition propDef : typeDef.getProperties().values())
|
|
||||||
{
|
|
||||||
if (propDef.isMandatory() && nodeRefProps.get(propDef.getName()) == null)
|
|
||||||
{
|
|
||||||
logMissingProperty(propDef, missingProperties);
|
|
||||||
|
|
||||||
result = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
Set<QName> aspects = this.getNodeService().getAspects(nodeRef);
|
|
||||||
for (QName aspect : aspects)
|
|
||||||
{
|
|
||||||
AspectDefinition aspectDef = this.getDictionaryService().getAspect(aspect);
|
|
||||||
for (PropertyDefinition propDef : aspectDef.getProperties().values())
|
|
||||||
{
|
|
||||||
if (propDef.isMandatory() && nodeRefProps.get(propDef.getName()) == null)
|
|
||||||
{
|
|
||||||
logMissingProperty(propDef, missingProperties);
|
|
||||||
|
|
||||||
result = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for missing mandatory metadata from custom aspect definitions
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
QName aspect = ASPECT_RECORD;
|
|
||||||
if (nodeRefType.equals(TYPE_NON_ELECTRONIC_DOCUMENT))
|
|
||||||
{
|
|
||||||
aspect = TYPE_NON_ELECTRONIC_DOCUMENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get customAspectImpl
|
|
||||||
String localName = aspect.toPrefixString(getNamespaceService()).replace(":", "");
|
|
||||||
localName = MessageFormat.format("{0}CustomProperties", localName);
|
|
||||||
QName customAspect = QName.createQName(RM_CUSTOM_URI, localName);
|
|
||||||
|
|
||||||
AspectDefinition aspectDef = this.getDictionaryService().getAspect(customAspect);
|
|
||||||
|
|
||||||
for (PropertyDefinition propDef : aspectDef.getProperties().values())
|
|
||||||
{
|
|
||||||
if (propDef.isMandatory() && 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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -55,9 +55,8 @@ public interface RecordService
|
|||||||
* A record metadata aspect can be registered more than once if it applies to more than one
|
* A record metadata aspect can be registered more than once if it applies to more than one
|
||||||
* file plan type.
|
* file plan type.
|
||||||
*
|
*
|
||||||
* @param recordMetadataAspect record metadata aspect qualified name
|
* @param recordMetadataAspect record metadata aspect qualified name
|
||||||
* @param filePlanType file plan type
|
* @param filePlanType file plan type
|
||||||
*
|
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
void registerRecordMetadataAspect(QName recordMetadataAspect, QName filePlanType);
|
void registerRecordMetadataAspect(QName recordMetadataAspect, QName filePlanType);
|
||||||
@@ -72,8 +71,7 @@ public interface RecordService
|
|||||||
/**
|
/**
|
||||||
* Disables the property editable check for a given node in this transaction only.
|
* Disables the property editable check for a given node in this transaction only.
|
||||||
*
|
*
|
||||||
* @param nodeRef node reference
|
* @param nodeRef node reference
|
||||||
*
|
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
void disablePropertyEditableCheck(NodeRef nodeRef);
|
void disablePropertyEditableCheck(NodeRef nodeRef);
|
||||||
@@ -84,213 +82,199 @@ public interface RecordService
|
|||||||
void enablePropertyEditableCheck();
|
void enablePropertyEditableCheck();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of all the record meta-data aspects
|
* Gets a list of all the record meta-data aspects
|
||||||
*
|
*
|
||||||
* @return {@link Set}<{@link QName}> list of record meta-data aspects
|
* @return {@link Set}<{@link QName}> list of record meta-data aspects
|
||||||
*
|
* @deprecated since 2.2, file plan component required to provide context
|
||||||
* @deprecated since 2.2, file plan component required to provide context
|
*/
|
||||||
*/
|
@Deprecated
|
||||||
@Deprecated
|
Set<QName> getRecordMetaDataAspects();
|
||||||
Set<QName> getRecordMetaDataAspects();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether the provided aspect is a registered record meta-data
|
|
||||||
* aspect.
|
|
||||||
*
|
|
||||||
* @param aspect aspect {@link QName}
|
|
||||||
* @return boolean true if the aspect is a registered record meta-data aspect, false otherwise
|
|
||||||
*
|
|
||||||
* @since 2.3
|
|
||||||
*/
|
|
||||||
boolean isRecordMetadataAspect(QName aspect);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whther the provided property is declared on a registered record
|
|
||||||
* meta-data aspect.
|
|
||||||
*
|
|
||||||
* @param property property {@link QName}
|
|
||||||
* @return boolean true if the property is declared on a registered record meta-data aspect,
|
|
||||||
* false otherwise
|
|
||||||
*
|
|
||||||
* @since 2.3
|
|
||||||
*/
|
|
||||||
boolean isRecordMetadataProperty(QName property);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of all the record metadata aspects relevant to the file plan type of the
|
|
||||||
* file plan component provided.
|
|
||||||
* <p>
|
|
||||||
* If a null context is provided all record meta-data aspects are returned, but this is not
|
|
||||||
* recommended.
|
|
||||||
*
|
|
||||||
* @param nodeRef node reference to file plan component providing context
|
|
||||||
* @return {@link Set}<{@link QName}> list of record meta-data aspects
|
|
||||||
*
|
|
||||||
* @since 2.2
|
|
||||||
*/
|
|
||||||
Set<QName> getRecordMetadataAspects(NodeRef nodeRef);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of all the record metadata aspect that relate to the provided file plan type.
|
|
||||||
* <p>
|
|
||||||
* If null is provided for the file plan type then record metadata aspects for the default
|
|
||||||
* file plan type (rma:filePlan) are returned.
|
|
||||||
*
|
|
||||||
* @param filePlanType file plan type
|
|
||||||
* @return{@link Set}<{@link QName}> list of record meta-data aspects
|
|
||||||
*
|
|
||||||
* @since 2.2
|
|
||||||
*/
|
|
||||||
Set<QName> getRecordMetadataAspects(QName filePlanType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether if the given node reference is a record or not
|
|
||||||
*
|
|
||||||
* @param nodeRef node reference to be checked
|
|
||||||
* @return boolean true if the node reference is a record, false otherwise
|
|
||||||
*/
|
|
||||||
boolean isRecord(NodeRef nodeRef);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether the record is declared
|
|
||||||
*
|
|
||||||
* @param nodeRef node reference of the record for which the check would be performed
|
|
||||||
* @return boolean true if record is declared, false otherwise
|
|
||||||
*/
|
|
||||||
boolean isDeclared(NodeRef nodeRef);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new unfiled record from an existing node.
|
|
||||||
* <p>
|
|
||||||
* Note that the node reference of the record will be the same as the original
|
|
||||||
* document.
|
|
||||||
*
|
|
||||||
* @param filePlan The filePlan in which the record should be placed. filePlan can be <code>null</code> in this case the default RM site will be used.
|
|
||||||
* @param nodeRef The node from which the record will be created
|
|
||||||
* @param isLinked indicates if the newly created record is linked to it's original location or not.
|
|
||||||
*/
|
|
||||||
void createRecord(NodeRef filePlan, NodeRef nodeRef, boolean isLinked);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Links the newly created record to it's original location.
|
|
||||||
*
|
|
||||||
* @see #createRecord(NodeRef, NodeRef, boolean)
|
|
||||||
*/
|
|
||||||
void createRecord(NodeRef filePlan, NodeRef nodeRef);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a record from a copy of the node reference provided.
|
|
||||||
*
|
|
||||||
* @param filePlan file plan
|
|
||||||
* @param nodeRef node reference
|
|
||||||
*/
|
|
||||||
NodeRef createRecordFromCopy(NodeRef filePlan, NodeRef nodeRef);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new document in the unfiled records container if the given node reference is a file plan
|
|
||||||
* node reference otherwise the node reference will be used as the destination for the new record.
|
|
||||||
*
|
|
||||||
* @param parent parent node reference
|
|
||||||
* @param name name of the new record
|
|
||||||
* @param type content type, cm:content if null
|
|
||||||
* @param properties properties
|
|
||||||
* @param reader content reader
|
|
||||||
*/
|
|
||||||
NodeRef createRecordFromContent(NodeRef parent, String name, QName type, Map<QName, Serializable> properties, ContentReader reader);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether the record is filed or not
|
|
||||||
*
|
|
||||||
* @param nodeRef record
|
|
||||||
* @return boolean true if filed, false otherwise
|
|
||||||
*/
|
|
||||||
boolean isFiled(NodeRef record);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 'File' a new document that arrived in the file plan structure.
|
|
||||||
*
|
|
||||||
* @param nodeRef record
|
|
||||||
*/
|
|
||||||
void file(NodeRef record);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether all the mandatory metadata for the record is populated or not
|
* Indicates whether the provided aspect is a registered record meta-data
|
||||||
|
* aspect.
|
||||||
*
|
*
|
||||||
* @param record record for which to check if all mandatory metadata is populated
|
* @param aspect aspect {@link QName}
|
||||||
* @return boolean true if all mandatory metadata is populated, false otherwise
|
* @return boolean true if the aspect is a registered record meta-data aspect, false otherwise
|
||||||
|
* @since 2.3
|
||||||
*/
|
*/
|
||||||
boolean isMandatoryPropertiesPopulated(NodeRef record);
|
boolean isRecordMetadataAspect(QName aspect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Completes a record.
|
* Indicates whther the provided property is declared on a registered record
|
||||||
|
* meta-data aspect.
|
||||||
*
|
*
|
||||||
* @param record record to be completed
|
* @param property property {@link QName}
|
||||||
|
* @return boolean true if the property is declared on a registered record meta-data aspect,
|
||||||
|
* false otherwise
|
||||||
|
* @since 2.3
|
||||||
*/
|
*/
|
||||||
void complete(NodeRef record);
|
boolean isRecordMetadataProperty(QName property);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rejects a record with the provided reason
|
* Gets a list of all the record metadata aspects relevant to the file plan type of the
|
||||||
*
|
* file plan component provided.
|
||||||
* @param nodeRef The record which will be rejected
|
* <p>
|
||||||
* @param reason The reason for rejection
|
* If a null context is provided all record meta-data aspects are returned, but this is not
|
||||||
*/
|
* recommended.
|
||||||
void rejectRecord(NodeRef nodeRef, String reason);
|
*
|
||||||
|
* @param nodeRef node reference to file plan component providing context
|
||||||
|
* @return {@link Set}<{@link QName}> list of record meta-data aspects
|
||||||
|
* @since 2.2
|
||||||
|
*/
|
||||||
|
Set<QName> getRecordMetadataAspects(NodeRef nodeRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether a property of a record is editable for the current user or not.
|
* Gets a list of all the record metadata aspect that relate to the provided file plan type.
|
||||||
*
|
* <p>
|
||||||
* @param record record
|
* If null is provided for the file plan type then record metadata aspects for the default
|
||||||
* @param property property
|
* file plan type (rma:filePlan) are returned.
|
||||||
* @return boolean true if editable, false otherwise.
|
*
|
||||||
*/
|
* @param filePlanType file plan type
|
||||||
boolean isPropertyEditable(NodeRef record, QName property);
|
* @return{@link Set}<{@link QName}> list of record meta-data aspects
|
||||||
|
* @since 2.2
|
||||||
|
*/
|
||||||
|
Set<QName> getRecordMetadataAspects(QName filePlanType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the given node (record or record folder) is a metadata stub or not.
|
* Checks whether if the given node reference is a record or not
|
||||||
*
|
*
|
||||||
* @param nodeRef node reference
|
* @param nodeRef node reference to be checked
|
||||||
* @return boolean true if a metadata stub, false otherwise
|
* @return boolean true if the node reference is a record, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean isMetadataStub(NodeRef nodeRef);
|
boolean isRecord(NodeRef nodeRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of all the records within a record folder
|
* Indicates whether the record is declared
|
||||||
*
|
*
|
||||||
* @param recordFolder record folder
|
* @param nodeRef node reference of the record for which the check would be performed
|
||||||
* @return List<NodeRef> list of records in the record folder
|
* @return boolean true if record is declared, false otherwise
|
||||||
*/
|
*/
|
||||||
List<NodeRef> getRecords(NodeRef recordFolder);
|
boolean isDeclared(NodeRef nodeRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified type to the record
|
* Creates a new unfiled record from an existing node.
|
||||||
*
|
* <p>
|
||||||
* @param nodeRef Record node reference
|
* Note that the node reference of the record will be the same as the original
|
||||||
* @param typeQName Type to add
|
* document.
|
||||||
*/
|
*
|
||||||
void addRecordType(NodeRef nodeRef, QName typeQName);
|
* @param filePlan The filePlan in which the record should be placed. filePlan can be <code>null</code> in this case the default RM site will be used.
|
||||||
|
* @param nodeRef The node from which the record will be created
|
||||||
|
* @param isLinked indicates if the newly created record is linked to it's original location or not.
|
||||||
|
*/
|
||||||
|
void createRecord(NodeRef filePlan, NodeRef nodeRef, boolean isLinked);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a record from the given document
|
* Links the newly created record to it's original location.
|
||||||
*
|
*
|
||||||
* @param nodeRef The document node reference from which a record will be created
|
* @see #createRecord(NodeRef, NodeRef, boolean)
|
||||||
*/
|
*/
|
||||||
void makeRecord(NodeRef nodeRef);
|
void createRecord(NodeRef filePlan, NodeRef nodeRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Links a record to a record folder
|
* Creates a record from a copy of the node reference provided.
|
||||||
*
|
*
|
||||||
* @param record the record to link
|
* @param filePlan file plan
|
||||||
* @param recordFolder the record folder to link it to
|
* @param nodeRef node reference
|
||||||
*/
|
*/
|
||||||
void link(NodeRef record, NodeRef recordFolder);
|
NodeRef createRecordFromCopy(NodeRef filePlan, NodeRef nodeRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlinks a record from a specified record folder.
|
* Creates a new document in the unfiled records container if the given node reference is a file plan
|
||||||
*
|
* node reference otherwise the node reference will be used as the destination for the new record.
|
||||||
* @param record the record to unlink
|
*
|
||||||
* @param recordFolder the record folder to unlink it from
|
* @param parent parent node reference
|
||||||
*
|
* @param name name of the new record
|
||||||
* @since 2.3
|
* @param type content type, cm:content if null
|
||||||
*/
|
* @param properties properties
|
||||||
void unlink(NodeRef record, NodeRef recordFolder);
|
* @param reader content reader
|
||||||
|
*/
|
||||||
|
NodeRef createRecordFromContent(NodeRef parent, String name, QName type, Map<QName, Serializable> properties, ContentReader reader);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the record is filed or not
|
||||||
|
*
|
||||||
|
* @param record Record node reference
|
||||||
|
* @return boolean true if filed, false otherwise
|
||||||
|
*/
|
||||||
|
boolean isFiled(NodeRef record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 'File' a new document that arrived in the file plan structure.
|
||||||
|
*
|
||||||
|
* @param record Record node reference
|
||||||
|
*/
|
||||||
|
void file(NodeRef record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rejects a record with the provided reason
|
||||||
|
*
|
||||||
|
* @param nodeRef The record which will be rejected
|
||||||
|
* @param reason The reason for rejection
|
||||||
|
*/
|
||||||
|
void rejectRecord(NodeRef nodeRef, String reason);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether a property of a record is editable for the current user or not.
|
||||||
|
*
|
||||||
|
* @param record record
|
||||||
|
* @param property property
|
||||||
|
* @return boolean true if editable, false otherwise.
|
||||||
|
*/
|
||||||
|
boolean isPropertyEditable(NodeRef record, QName property);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the given node (record or record folder) is a metadata stub or not.
|
||||||
|
*
|
||||||
|
* @param nodeRef node reference
|
||||||
|
* @return boolean true if a metadata stub, false otherwise
|
||||||
|
*/
|
||||||
|
boolean isMetadataStub(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of all the records within a record folder
|
||||||
|
*
|
||||||
|
* @param recordFolder record folder
|
||||||
|
* @return List<NodeRef> list of records in the record folder
|
||||||
|
*/
|
||||||
|
List<NodeRef> getRecords(NodeRef recordFolder);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the specified type to the record
|
||||||
|
*
|
||||||
|
* @param nodeRef Record node reference
|
||||||
|
* @param typeQName Type to add
|
||||||
|
*/
|
||||||
|
void addRecordType(NodeRef nodeRef, QName typeQName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a record from the given document
|
||||||
|
*
|
||||||
|
* @param nodeRef The document node reference from which a record will be created
|
||||||
|
*/
|
||||||
|
void makeRecord(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Links a record to a record folder
|
||||||
|
*
|
||||||
|
* @param record the record to link
|
||||||
|
* @param recordFolder the record folder to link it to
|
||||||
|
*/
|
||||||
|
void link(NodeRef record, NodeRef recordFolder);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlinks a record from a specified record folder.
|
||||||
|
*
|
||||||
|
* @param record the record to unlink
|
||||||
|
* @param recordFolder the record folder to unlink it from
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
void unlink(NodeRef record, NodeRef recordFolder);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Completes a record
|
||||||
|
*
|
||||||
|
* @param nodeRef Record node reference
|
||||||
|
*/
|
||||||
|
void complete(NodeRef nodeRef);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,8 +32,8 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionResult;
|
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionResult;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.DeclareRecordAction;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -55,9 +55,9 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
private static final boolean OPTIONAL_METADATA = false;
|
private static final boolean OPTIONAL_METADATA = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* complete record action
|
* Record service impl
|
||||||
*/
|
*/
|
||||||
private DeclareRecordAction action;
|
private RecordServiceImpl recordServiceImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices()
|
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices()
|
||||||
@@ -67,8 +67,8 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
{
|
{
|
||||||
super.initServices();
|
super.initServices();
|
||||||
|
|
||||||
// get the action
|
// get the record service
|
||||||
action = (DeclareRecordAction) applicationContext.getBean("declareRecord");
|
recordServiceImpl = (RecordServiceImpl) applicationContext.getBean("recordService");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +80,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
super.tearDownImpl();
|
super.tearDownImpl();
|
||||||
|
|
||||||
// ensure action is returned to original state
|
// ensure action is returned to original state
|
||||||
action.setCheckMandatoryPropertiesEnabled(true);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,7 +100,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
public void given()
|
public void given()
|
||||||
{
|
{
|
||||||
// enable mandatory parameter check
|
// enable mandatory parameter check
|
||||||
action.setCheckMandatoryPropertiesEnabled(true);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(true);
|
||||||
|
|
||||||
// create a record
|
// create a record
|
||||||
record = utils.createRecord(rmFolder, "record.txt", "title");
|
record = utils.createRecord(rmFolder, "record.txt", "title");
|
||||||
@@ -140,7 +140,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
public void given()
|
public void given()
|
||||||
{
|
{
|
||||||
// enable mandatory parameter check
|
// enable mandatory parameter check
|
||||||
action.setCheckMandatoryPropertiesEnabled(true);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(true);
|
||||||
|
|
||||||
// create a record
|
// create a record
|
||||||
record = utils.createRecord(rmFolder, "record.txt", "title");
|
record = utils.createRecord(rmFolder, "record.txt", "title");
|
||||||
@@ -183,7 +183,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
public void given() throws Exception
|
public void given() throws Exception
|
||||||
{
|
{
|
||||||
// enable mandatory parameter check
|
// enable mandatory parameter check
|
||||||
action.setCheckMandatoryPropertiesEnabled(true);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(true);
|
||||||
|
|
||||||
// create the custom metadata definition (that has a mandatory property) for electronic records
|
// create the custom metadata definition (that has a mandatory property) for electronic records
|
||||||
defineCustomMetadata(CUSTOM_ELECTRONIC_TEST, ASPECT_RECORD, MANDATORY_METADATA);
|
defineCustomMetadata(CUSTOM_ELECTRONIC_TEST, ASPECT_RECORD, MANDATORY_METADATA);
|
||||||
@@ -229,7 +229,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
public void given() throws Exception
|
public void given() throws Exception
|
||||||
{
|
{
|
||||||
// enable mandatory parameter check
|
// enable mandatory parameter check
|
||||||
action.setCheckMandatoryPropertiesEnabled(true);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(true);
|
||||||
|
|
||||||
// define the custom metadata definition (that has a mandatory property)
|
// define the custom metadata definition (that has a mandatory property)
|
||||||
defineCustomMetadata(CUSTOM_ELECTRONIC_TEST, ASPECT_RECORD, MANDATORY_METADATA);
|
defineCustomMetadata(CUSTOM_ELECTRONIC_TEST, ASPECT_RECORD, MANDATORY_METADATA);
|
||||||
@@ -279,7 +279,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
public void given() throws Exception
|
public void given() throws Exception
|
||||||
{
|
{
|
||||||
// enable mandatory parameter check
|
// enable mandatory parameter check
|
||||||
action.setCheckMandatoryPropertiesEnabled(true);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(true);
|
||||||
|
|
||||||
// create the custom metadata definition (that has a mandatory property) for non-electronic records
|
// create the custom metadata definition (that has a mandatory property) for non-electronic records
|
||||||
defineCustomMetadata(CUSTOM_NON_ELECTRONIC_TEST, TYPE_NON_ELECTRONIC_DOCUMENT, MANDATORY_METADATA);
|
defineCustomMetadata(CUSTOM_NON_ELECTRONIC_TEST, TYPE_NON_ELECTRONIC_DOCUMENT, MANDATORY_METADATA);
|
||||||
@@ -326,7 +326,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
public void given() throws Exception
|
public void given() throws Exception
|
||||||
{
|
{
|
||||||
// enable mandatory parameter check
|
// enable mandatory parameter check
|
||||||
action.setCheckMandatoryPropertiesEnabled(true);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(true);
|
||||||
|
|
||||||
// create the custom metadata definition (that has a mandatory property)
|
// create the custom metadata definition (that has a mandatory property)
|
||||||
defineCustomMetadata(CUSTOM_NON_ELECTRONIC_TEST, TYPE_NON_ELECTRONIC_DOCUMENT, MANDATORY_METADATA);
|
defineCustomMetadata(CUSTOM_NON_ELECTRONIC_TEST, TYPE_NON_ELECTRONIC_DOCUMENT, MANDATORY_METADATA);
|
||||||
@@ -375,7 +375,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
public void given() throws Exception
|
public void given() throws Exception
|
||||||
{
|
{
|
||||||
// enable mandatory parameter check
|
// enable mandatory parameter check
|
||||||
action.setCheckMandatoryPropertiesEnabled(true);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(true);
|
||||||
|
|
||||||
// create the custom metadata definition (that does not have a mandatory property)
|
// create the custom metadata definition (that does not have a mandatory property)
|
||||||
defineCustomMetadata(CUSTOM_ELECTRONIC_TEST, ASPECT_RECORD, OPTIONAL_METADATA);
|
defineCustomMetadata(CUSTOM_ELECTRONIC_TEST, ASPECT_RECORD, OPTIONAL_METADATA);
|
||||||
@@ -422,7 +422,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
public void given() throws Exception
|
public void given() throws Exception
|
||||||
{
|
{
|
||||||
// enable mandatory parameter check
|
// enable mandatory parameter check
|
||||||
action.setCheckMandatoryPropertiesEnabled(true);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(true);
|
||||||
|
|
||||||
// create the record custom metadata definition (that has a mandatory property)
|
// create the record custom metadata definition (that has a mandatory property)
|
||||||
defineCustomMetadata(CUSTOM_ELECTRONIC_TEST, ASPECT_RECORD, MANDATORY_METADATA);
|
defineCustomMetadata(CUSTOM_ELECTRONIC_TEST, ASPECT_RECORD, MANDATORY_METADATA);
|
||||||
@@ -469,7 +469,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
public void given() throws Exception
|
public void given() throws Exception
|
||||||
{
|
{
|
||||||
// enable mandatory parameter check
|
// enable mandatory parameter check
|
||||||
action.setCheckMandatoryPropertiesEnabled(true);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(true);
|
||||||
|
|
||||||
// create the non-electronic record custom metadata definition (that has a mandatory property)
|
// create the non-electronic record custom metadata definition (that has a mandatory property)
|
||||||
defineCustomMetadata(CUSTOM_NON_ELECTRONIC_TEST, TYPE_NON_ELECTRONIC_DOCUMENT, MANDATORY_METADATA);
|
defineCustomMetadata(CUSTOM_NON_ELECTRONIC_TEST, TYPE_NON_ELECTRONIC_DOCUMENT, MANDATORY_METADATA);
|
||||||
@@ -515,7 +515,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
public void given()
|
public void given()
|
||||||
{
|
{
|
||||||
// disable mandatory parameter check
|
// disable mandatory parameter check
|
||||||
action.setCheckMandatoryPropertiesEnabled(false);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(false);
|
||||||
|
|
||||||
// create a record
|
// create a record
|
||||||
record = utils.createRecord(rmFolder, "record.txt", "title");
|
record = utils.createRecord(rmFolder, "record.txt", "title");
|
||||||
@@ -555,7 +555,7 @@ public class CompleteRecordTest extends BaseRMTestCase
|
|||||||
public void given()
|
public void given()
|
||||||
{
|
{
|
||||||
// enable mandatory parameter check
|
// enable mandatory parameter check
|
||||||
action.setCheckMandatoryPropertiesEnabled(false);
|
recordServiceImpl.setCheckMandatoryPropertiesEnabled(false);
|
||||||
|
|
||||||
// create a record
|
// create a record
|
||||||
record = utils.createRecord(rmFolder, "record.txt", "title");
|
record = utils.createRecord(rmFolder, "record.txt", "title");
|
||||||
|
Reference in New Issue
Block a user