Merge feature/RM-4921_ExceptionsDoneOnTransactionCommit into feature/RM-5012_recordIdentifier

This commit is contained in:
Ana Bozianu
2017-05-08 17:40:28 +03:00
6 changed files with 34 additions and 16 deletions

View File

@@ -31,6 +31,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IDENTIFIER;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IS_CLOSED;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_OWNER;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_REVIEW_PERIOD;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF;
@@ -40,6 +41,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
import org.alfresco.utility.model.TestModel;
@@ -99,4 +101,7 @@ public class RecordCategoryChildProperties extends TestModel
@JsonProperty (PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
private Boolean recordSearchHasDispositionSchedule;
@JsonProperty (PROPERTIES_OWNER)
private Owner owner;
}

View File

@@ -60,4 +60,7 @@ public class UnfiledContainerProperties extends TestModel
/*************************/
@JsonProperty (required = true, value = PROPERTIES_IDENTIFIER)
private String identifier;
@JsonProperty (required = true, value = PROPERTIES_ROOT_NODE_REF)
private String rootNodeRef;
}

View File

@@ -241,10 +241,10 @@ public class FilePlanTests extends BaseRMRestTest
assertStatusCode(OK);
// Verify the returned description field for the file plan component
assertEquals(renamedFilePlan.getProperties().getDescription(), FILE_PLAN_DESCRIPTION);
assertEquals(FILE_PLAN_DESCRIPTION, renamedFilePlan.getProperties().getDescription());
// Verify the returned title field for the file plan component
assertEquals(renamedFilePlan.getProperties().getTitle(), FILE_PLAN_TITLE);
assertEquals(FILE_PLAN_TITLE, renamedFilePlan.getProperties().getTitle());
}
/**

View File

@@ -349,9 +349,6 @@ public class ElectronicRecordTests extends BaseRMRestTest
UnfiledContainerChild unfiledContainerChildModel= UnfiledContainerChild.builder()
.name(ELECTRONIC_RECORD_NAME)
.nodeType(CONTENT_TYPE)
.content(RecordContent.builder()
.mimeType(TEXT_PLAIN_VALUE)
.build())
.relativePath(relativePath)
.build();

View File

@@ -126,7 +126,7 @@ public class FilePlanEntityResource
}
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
RetryingTransactionCallback<Void> updateCallback = new RetryingTransactionCallback<Void>()
{
public Void execute()
{
@@ -134,9 +134,17 @@ public class FilePlanEntityResource
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
transactionService.getRetryingTransactionHelper().doInTransaction(updateCallback, false, true);
RetryingTransactionCallback<FileInfo> readCallback = new RetryingTransactionCallback<FileInfo>()
{
public FileInfo execute()
{
return fileFolderService.getFileInfo(nodeRef);
}
};
FileInfo info = transactionService.getRetryingTransactionHelper().doInTransaction(readCallback, false, true);
FileInfo info = fileFolderService.getFileInfo(nodeRef);
return nodesModelFactory.createFilePlan(info, parameters, null, false);
}
}

View File

@@ -67,6 +67,7 @@ import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.Pair;
import org.apache.commons.lang3.StringUtils;
import org.springframework.extensions.webscripts.servlet.FormData;
@@ -224,21 +225,25 @@ public class UnfiledRecordFolderChildrenRelation implements RelationshipResource
// Retrieve the input data and resolve the parent node
final UploadInfo uploadInfo = new UploadInfo(formData);
final NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, uploadInfo.getRelativePath());
// Create the record
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
// Create the record - returns pair(newNode,parentNode)
RetryingTransactionCallback<Pair<NodeRef,NodeRef>> callback = new RetryingTransactionCallback<Pair<NodeRef,NodeRef>>()
{
public NodeRef execute()
public Pair<NodeRef,NodeRef> execute()
{
return apiUtils.uploadRecord(parentNodeRef, uploadInfo.getFileName(), uploadInfo.getNodeType(), uploadInfo.getProperties(), uploadInfo.getContent().getInputStream());
final NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, uploadInfo.getRelativePath());
NodeRef newNode = apiUtils.uploadRecord(parentNodeRef, uploadInfo.getFileName(), uploadInfo.getNodeType(), uploadInfo.getProperties(), uploadInfo.getContent().getInputStream());
return new Pair<NodeRef, NodeRef>(newNode, parentNodeRef);
}
};
NodeRef newNode = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
Pair<NodeRef,NodeRef> nodeAndParentInfo = transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
NodeRef newNode = nodeAndParentInfo.getFirst();
NodeRef parent = nodeAndParentInfo.getSecond();
// Get file info for response
FileInfo info = fileFolderService.getFileInfo(newNode);
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
apiUtils.postActivity(info, parent, ActivityType.FILE_ADDED);
return nodesModelFactory.createUnfiledRecordFolderChild(info, parameters, null, false);
}
}