Skip to content

Commit 8cccdd0

Browse files
authored
Rename filesystem StorageService copy to export and mark as READ operation (#3555)
* changed transactional operation type, CREATE to READ in DefaultTransactionalStorageService's copy method. * refactored copy method that received toPath argument to export to file system. * formatted code style.
1 parent 572bf3e commit 8cccdd0

6 files changed

Lines changed: 12 additions & 12 deletions

File tree

roda-core/roda-core/src/main/java/org/roda/core/model/DefaultModelService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5627,13 +5627,13 @@ public void exportObject(LiteRODAObject lite, StorageService toStorage, String..
56275627
public void exportToPath(IsRODAObject object, Path toPath, boolean replaceExisting, String... fromPathPartials)
56285628
throws RequestNotValidException, AuthorizationDeniedException, AlreadyExistsException, GenericException {
56295629
StoragePath sourceObjectPath = DefaultStoragePath.parse(ModelUtils.getStoragePath(object), fromPathPartials);
5630-
getStorage().copy(getStorage(), sourceObjectPath, toPath, "", replaceExisting);
5630+
getStorage().export(getStorage(), sourceObjectPath, toPath, "", replaceExisting);
56315631
}
56325632

56335633
public void exportToPath(LiteRODAObject lite, Path toPath, boolean replaceExisting, String... fromPathPartials)
56345634
throws RequestNotValidException, AuthorizationDeniedException, AlreadyExistsException, GenericException {
56355635
StoragePath sourceObjectPath = DefaultStoragePath.parse(ModelUtils.getStoragePath(lite), fromPathPartials);
5636-
getStorage().copy(getStorage(), sourceObjectPath, toPath, "", replaceExisting);
5636+
getStorage().export(getStorage(), sourceObjectPath, toPath, "", replaceExisting);
56375637
}
56385638

56395639
@Override

roda-core/roda-core/src/main/java/org/roda/core/model/DefaultTransactionalModelService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3933,7 +3933,7 @@ public void exportToPath(IsRODAObject object, Path toPath, boolean replaceExisti
39333933
throws RequestNotValidException, AuthorizationDeniedException, AlreadyExistsException, GenericException {
39343934
TransactionalModelOperationLog operationLog = operationRegistry.registerOperation(object, OperationType.READ);
39353935
try {
3936-
getModelService().exportToPath(object, toPath, replaceExisting, fromPathPartials);
3936+
mainModelService.exportToPath(object, toPath, replaceExisting, fromPathPartials);
39373937
operationRegistry.updateOperationState(operationLog, OperationState.SUCCESS);
39383938
} catch (RequestNotValidException | AuthorizationDeniedException | AlreadyExistsException | GenericException e) {
39393939
operationRegistry.updateOperationState(operationLog, OperationState.FAILURE);

roda-core/roda-core/src/main/java/org/roda/core/storage/DefaultTransactionalStorageService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,12 @@ public void copy(StorageService fromService, StoragePath fromStoragePath, Storag
421421
}
422422

423423
@Override
424-
public void copy(StorageService fromService, StoragePath fromStoragePath, Path toPath, String resource,
424+
public void export(StorageService fromService, StoragePath fromStoragePath, Path toPath, String resource,
425425
boolean replaceExisting) throws AlreadyExistsException, GenericException, AuthorizationDeniedException {
426426
List<TransactionalStoragePathOperationLog> operationLogs = registerOperationForCopy(fromService, fromStoragePath,
427-
toPath, OperationType.CREATE);
427+
toPath, OperationType.READ);
428428
try {
429-
stagingStorageService.copy(fromService, fromStoragePath, toPath, resource, replaceExisting);
429+
stagingStorageService.export(fromService, fromStoragePath, toPath, resource, replaceExisting);
430430
for (TransactionalStoragePathOperationLog operationLog : operationLogs) {
431431
updateOperationState(operationLog, OperationState.SUCCESS);
432432
}
@@ -909,8 +909,8 @@ private List<TransactionalStoragePathOperationLog> registerOperationForCopy(Stor
909909
private List<TransactionalStoragePathOperationLog> registerOperationForCopy(StorageService fromService,
910910
StoragePath fromStoragePath, StoragePath toStoragePath, OperationType operation)
911911
throws AuthorizationDeniedException, GenericException {
912-
List<TransactionalStoragePathOperationLog> ret = new ArrayList<>(
913-
List.of(registerOperation(toStoragePath, operation)));
912+
List<TransactionalStoragePathOperationLog> ret = new ArrayList<>();
913+
ret.add(registerOperation(toStoragePath,operation));
914914
try (CloseableIterable<Resource> listResourcesUnderDirectory = fromService
915915
.listResourcesUnderDirectory(fromStoragePath, true)) {
916916
if (listResourcesUnderDirectory == null) {

roda-core/roda-core/src/main/java/org/roda/core/storage/StorageService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ void copy(StorageService fromService, StoragePath fromStoragePath, StoragePath t
347347
throws AlreadyExistsException, GenericException, RequestNotValidException, NotFoundException,
348348
AuthorizationDeniedException;
349349

350-
void copy(StorageService fromService, StoragePath fromStoragePath, Path toPath, String resource, boolean replaceExisting)
350+
void export(StorageService fromService, StoragePath fromStoragePath, Path toPath, String resource, boolean replaceExisting)
351351
throws AlreadyExistsException, GenericException, AuthorizationDeniedException;
352352

353353
/**

roda-core/roda-core/src/main/java/org/roda/core/storage/StorageServiceWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ public void copy(StorageService fromService, StoragePath fromStoragePath, Storag
179179
}
180180

181181
@Override
182-
public void copy(StorageService fromService, StoragePath fromStoragePath, Path toPath, String resource,
182+
public void export(StorageService fromService, StoragePath fromStoragePath, Path toPath, String resource,
183183
boolean replaceExisting) throws AlreadyExistsException, GenericException, AuthorizationDeniedException {
184184
RodaCoreFactory.checkIfWriteIsAllowedAndIfFalseThrowException(nodeType);
185-
storageService.copy(fromService, fromStoragePath, toPath, resource, false);
185+
storageService.export(fromService, fromStoragePath, toPath, resource, replaceExisting);
186186
}
187187

188188
@Override

roda-core/roda-core/src/main/java/org/roda/core/storage/fs/FileStorageService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ public void copy(StorageService fromService, StoragePath fromStoragePath, Storag
567567
}
568568

569569
@Override
570-
public void copy(StorageService fromService, StoragePath fromStoragePath, Path toPath, String resource,
570+
public void export(StorageService fromService, StoragePath fromStoragePath, Path toPath, String resource,
571571
boolean replaceExisting) throws AlreadyExistsException, GenericException {
572572
Path sourcePath = null;
573573
if (StringUtils.isNotBlank(resource)) {

0 commit comments

Comments
 (0)