mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4921 - fix upload file to record folder and failing tests
This commit is contained in:
@@ -32,6 +32,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ID_IS_TEMPORARILY_EDITABLE;
|
||||
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;
|
||||
@@ -41,6 +42,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;
|
||||
@@ -103,4 +105,7 @@ public class RecordCategoryChildProperties extends TestModel
|
||||
|
||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
|
||||
private Boolean recordSearchHasDispositionSchedule;
|
||||
|
||||
@JsonProperty (PROPERTIES_OWNER)
|
||||
private Owner owner;
|
||||
}
|
@@ -67,5 +67,4 @@ public class UnfiledContainerProperties extends TestModel
|
||||
|
||||
@JsonProperty (required = true, value = PROPERTIES_ROOT_NODE_REF)
|
||||
private String rootNodeRef;
|
||||
|
||||
}
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user