/** * Create an instance of {@link BusinessObjectDataRestoreDto } * */ public BusinessObjectDataRestoreDto createBusinessObjectDataRestoreDto() { return new BusinessObjectDataRestoreDto(); }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { theBusinessObjectDataKey = this.getBusinessObjectDataKey(); strategy.appendField(locator, this, "businessObjectDataKey", buffer, theBusinessObjectDataKey, (this.businessObjectDataKey!= null)); theStorageName = this.getStorageName(); strategy.appendField(locator, this, "storageName", buffer, theStorageName, (this.storageName!= null)); theS3Endpoint = this.getS3Endpoint(); strategy.appendField(locator, this, "s3Endpoint", buffer, theS3Endpoint, (this.s3Endpoint!= null)); theS3BucketName = this.getS3BucketName(); strategy.appendField(locator, this, "s3BucketName", buffer, theS3BucketName, (this.s3BucketName!= null)); theS3KeyPrefix = this.getS3KeyPrefix(); strategy.appendField(locator, this, "s3KeyPrefix", buffer, theS3KeyPrefix, (this.s3KeyPrefix!= null)); theNewStorageUnitStatus = this.getNewStorageUnitStatus(); strategy.appendField(locator, this, "newStorageUnitStatus", buffer, theNewStorageUnitStatus, (this.newStorageUnitStatus!= null)); theOldStorageUnitStatus = this.getOldStorageUnitStatus(); strategy.appendField(locator, this, "oldStorageUnitStatus", buffer, theOldStorageUnitStatus, (this.oldStorageUnitStatus!= null)); theStorageFiles = (((this.storageFiles!= null)&&(!this.storageFiles.isEmpty()))?this.getStorageFiles():null); strategy.appendField(locator, this, "storageFiles", buffer, theStorageFiles, ((this.storageFiles!= null)&&(!this.storageFiles.isEmpty()))); theException = this.getException(); strategy.appendField(locator, this, "exception", buffer, theException, (this.exception!= null));
/** * Completes the expiration of a storage unit. * * @param businessObjectDataRestoreDto the DTO that holds various parameters needed to expire business object data */ protected void completeStorageUnitExpirationImpl(BusinessObjectDataRestoreDto businessObjectDataRestoreDto) { // Retrieve the business object data and ensure it exists. BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataRestoreDto.getBusinessObjectDataKey()); // Retrieve the storage unit and ensure it exists. StorageUnitEntity storageUnitEntity = storageUnitDaoHelper.getStorageUnitEntity(businessObjectDataRestoreDto.getStorageName(), businessObjectDataEntity); // Update the storage unit status. String oldStorageUnitStatus = storageUnitEntity.getStatus().getCode(); String reason = StorageUnitStatusEntity.ARCHIVED; storageUnitDaoHelper.updateStorageUnitStatus(storageUnitEntity, StorageUnitStatusEntity.ARCHIVED, reason); // Update the new and old storage unit status values in the DTO. businessObjectDataRestoreDto.setNewStorageUnitStatus(storageUnitEntity.getStatus().getCode()); businessObjectDataRestoreDto.setOldStorageUnitStatus(oldStorageUnitStatus); }
/** * Expires a restored S3 storage unit. * * @param storageUnitKey the storage unit key */ protected void expireS3StorageUnitImpl(BusinessObjectDataStorageUnitKey storageUnitKey) { // Build the business object data restore DTO. BusinessObjectDataRestoreDto businessObjectDataRestoreDto = expireRestoredBusinessObjectDataHelperService.prepareToExpireStorageUnit(storageUnitKey); // Create storage unit notification for the storage unit. notificationEventService.processStorageUnitNotificationEventAsync(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG, businessObjectDataRestoreDto.getBusinessObjectDataKey(), businessObjectDataRestoreDto.getStorageName(), businessObjectDataRestoreDto.getNewStorageUnitStatus(), businessObjectDataRestoreDto.getOldStorageUnitStatus()); // Execute the S3 specific steps required to expire business object data. expireRestoredBusinessObjectDataHelperService.executeS3SpecificSteps(businessObjectDataRestoreDto); // Execute the after step. expireRestoredBusinessObjectDataHelperService.completeStorageUnitExpiration(businessObjectDataRestoreDto); // Create storage unit notification for the storage unit. notificationEventService.processStorageUnitNotificationEventAsync(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG, businessObjectDataRestoreDto.getBusinessObjectDataKey(), businessObjectDataRestoreDto.getStorageName(), businessObjectDataRestoreDto.getNewStorageUnitStatus(), businessObjectDataRestoreDto.getOldStorageUnitStatus()); }
public Void answer(InvocationOnMock invocation) { // Get the parameters DTO for the business object data restore. BusinessObjectDataRestoreDto businessObjectDataRestoreDto = (BusinessObjectDataRestoreDto) invocation.getArguments()[0]; //Set the value for the new and old storage unit statuses. businessObjectDataRestoreDto.setNewStorageUnitStatus(StorageUnitStatusEntity.RESTORED); businessObjectDataRestoreDto.setOldStorageUnitStatus(StorageUnitStatusEntity.RESTORING); return null; } }).when(businessObjectDataFinalizeRestoreHelperService).completeFinalizeRestore(businessObjectDataRestoreDto);
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof BusinessObjectDataRestoreDto) { final BusinessObjectDataRestoreDto copy = ((BusinessObjectDataRestoreDto) draftCopy); if (businessObjectDataKeyShouldBeCopiedAndSet == Boolean.TRUE) { BusinessObjectDataKey sourceBusinessObjectDataKey; sourceBusinessObjectDataKey = this.getBusinessObjectDataKey(); BusinessObjectDataKey copyBusinessObjectDataKey = ((BusinessObjectDataKey) strategy.copy(LocatorUtils.property(locator, "businessObjectDataKey", sourceBusinessObjectDataKey), sourceBusinessObjectDataKey, (this.businessObjectDataKey!= null))); copy.setBusinessObjectDataKey(copyBusinessObjectDataKey); } else { if (businessObjectDataKeyShouldBeCopiedAndSet == Boolean.FALSE) { if (storageNameShouldBeCopiedAndSet == Boolean.TRUE) { String sourceStorageName; sourceStorageName = this.getStorageName(); String copyStorageName = ((String) strategy.copy(LocatorUtils.property(locator, "storageName", sourceStorageName), sourceStorageName, (this.storageName!= null))); copy.setStorageName(copyStorageName); } else { if (storageNameShouldBeCopiedAndSet == Boolean.FALSE) { if (s3EndpointShouldBeCopiedAndSet == Boolean.TRUE) { String sourceS3Endpoint; sourceS3Endpoint = this.getS3Endpoint(); String copyS3Endpoint = ((String) strategy.copy(LocatorUtils.property(locator, "s3Endpoint", sourceS3Endpoint), sourceS3Endpoint, (this.s3Endpoint!= null))); copy.setS3Endpoint(copyS3Endpoint); } else { if (s3EndpointShouldBeCopiedAndSet == Boolean.FALSE) { if (s3BucketNameShouldBeCopiedAndSet == Boolean.TRUE) {
s3FileTransferRequestParamsDto.setS3BucketName(businessObjectDataRestoreDto.getS3BucketName()); s3FileTransferRequestParamsDto.setS3Endpoint(businessObjectDataRestoreDto.getS3Endpoint()); s3FileTransferRequestParamsDto.setS3KeyPrefix(StringUtils.appendIfMissing(businessObjectDataRestoreDto.getS3KeyPrefix(), "/")); .validateRegisteredS3Files(businessObjectDataRestoreDto.getStorageFiles(), actualS3Files, businessObjectDataRestoreDto.getStorageName(), businessObjectDataRestoreDto.getBusinessObjectDataKey());
BusinessObjectDataRestoreDto businessObjectDataRestoreDto = new BusinessObjectDataRestoreDto(); businessObjectDataRestoreDto.setBusinessObjectDataKey(businessObjectDataKey); businessObjectDataRestoreDto.setNewStorageUnitStatus(storageUnitEntity.getStatus().getCode()); businessObjectDataRestoreDto.setOldStorageUnitStatus(oldStorageUnitStatus); businessObjectDataRestoreDto.setS3BucketName(s3BucketName); businessObjectDataRestoreDto.setS3Endpoint(configurationHelper.getProperty(ConfigurationValue.S3_ENDPOINT)); businessObjectDataRestoreDto.setS3KeyPrefix(s3KeyPrefix); businessObjectDataRestoreDto.setStorageFiles(storageFiles); businessObjectDataRestoreDto.setStorageName(storageName);
BusinessObjectDataRestoreDto businessObjectDataRestoreDto = new BusinessObjectDataRestoreDto(); businessObjectDataRestoreDto.setBusinessObjectDataKey(businessObjectDataKey); businessObjectDataRestoreDto.setStorageName(storageName); businessObjectDataRestoreDto.setS3Endpoint(configurationHelper.getProperty(ConfigurationValue.S3_ENDPOINT)); businessObjectDataRestoreDto.setS3BucketName(s3BucketName); businessObjectDataRestoreDto.setS3KeyPrefix(s3KeyPrefix); businessObjectDataRestoreDto.setStorageFiles(storageFiles);
new BusinessObjectDataRestoreDto(businessObjectDataKey, STORAGE_NAME, S3_ENDPOINT, S3_BUCKET_NAME, S3_KEY_PREFIX, NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS, Arrays.asList(new StorageFile(S3_KEY, FILE_SIZE, ROW_COUNT)), NO_EXCEPTION); assertEquals(StorageUnitStatusEntity.RESTORED, businessObjectDataRestoreDto.getNewStorageUnitStatus()); assertEquals(StorageUnitStatusEntity.RESTORING, businessObjectDataRestoreDto.getOldStorageUnitStatus());
new BusinessObjectDataRestoreDto(businessObjectDataKey, STORAGE_NAME, S3_ENDPOINT, S3_BUCKET_NAME, S3_KEY_PREFIX, NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS, storageFiles, NO_EXCEPTION); assertNotNull(businessObjectDataRestoreDto.getException()); assertEquals(IllegalArgumentException.class, businessObjectDataRestoreDto.getException().getClass()); assertEquals(String.format("S3 file \"%s\" is not archived (found %s storage class when expecting %s). S3 Bucket Name: \"%s\"", S3_KEY, StorageClass.Standard.toString(), StorageClass.Glacier.toString(), S3_BUCKET_NAME), businessObjectDataRestoreDto.getException().getMessage()); businessObjectDataRestoreDto.setException(NO_EXCEPTION); assertEquals(new BusinessObjectDataRestoreDto(businessObjectDataKey, STORAGE_NAME, S3_ENDPOINT, S3_BUCKET_NAME, S3_KEY_PREFIX, NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS, storageFiles, NO_EXCEPTION), businessObjectDataRestoreDto);
@Test public void testPrepareToFinalizeRestoreMissingOptionalParameters() throws Exception { // Create a business object data key without sub-partition values. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION); // Create database entities required for testing. BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper.createDatabaseEntitiesForFinalizeRestoreTesting(businessObjectDataKey); // Get the storage unit entity. StorageUnitEntity storageUnitEntity = storageUnitDaoHelper.getStorageUnitEntity(STORAGE_NAME, businessObjectDataEntity); // Create a storage unit key. BusinessObjectDataStorageUnitKey storageUnitKey = storageUnitHelper.createStorageUnitKey(businessObjectDataKey, STORAGE_NAME); // Prepare to finalize a restore for business object data without sub-partition values. BusinessObjectDataRestoreDto result = businessObjectDataFinalizeRestoreHelperService.prepareToFinalizeRestore(storageUnitKey); // Validate the returned object. assertEquals(new BusinessObjectDataRestoreDto(businessObjectDataKey, STORAGE_NAME, NO_S3_ENDPOINT, S3_BUCKET_NAME, result.getS3KeyPrefix(), NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS, storageFileHelper.createStorageFilesFromEntities(storageUnitEntity.getStorageFiles()), NO_EXCEPTION), result); }
@Test public void testPrepareToInitiateRestoreLowerCaseParameters() { // Create a business object data key. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION); // Create database entities required for testing. businessObjectDataServiceTestHelper.createDatabaseEntitiesForInitiateRestoreTesting(businessObjectDataKey); // Execute a before step for the initiate a business object data restore request // using lower case input parameters (except for case-sensitive partition values). BusinessObjectDataRestoreDto storagePolicyTransitionParamsDto = businessObjectDataInitiateRestoreHelperService.prepareToInitiateRestore( new BusinessObjectDataKey(BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION), EXPIRATION_IN_DAYS); // Validate the returned object. assertEquals(businessObjectDataKey, storagePolicyTransitionParamsDto.getBusinessObjectDataKey()); }
s3FileTransferRequestParamsDto.setS3Endpoint(businessObjectDataRestoreDto.getS3Endpoint()); s3FileTransferRequestParamsDto.setS3BucketName(businessObjectDataRestoreDto.getS3BucketName()); s3FileTransferRequestParamsDto.setS3KeyPrefix(StringUtils.appendIfMissing(businessObjectDataRestoreDto.getS3KeyPrefix(), "/")); .validateRegisteredS3Files(businessObjectDataRestoreDto.getStorageFiles(), actualS3Files, businessObjectDataRestoreDto.getStorageName(), businessObjectDataRestoreDto.getBusinessObjectDataKey());
BusinessObjectDataRestoreDto businessObjectDataRestoreDto = new BusinessObjectDataRestoreDto(); businessObjectDataRestoreDto.setBusinessObjectDataKey(businessObjectDataKey); businessObjectDataRestoreDto.setNewStorageUnitStatus(storageUnitEntity.getStatus().getCode()); businessObjectDataRestoreDto.setOldStorageUnitStatus(oldStorageUnitStatus); businessObjectDataRestoreDto.setS3BucketName(s3BucketName); businessObjectDataRestoreDto.setS3Endpoint(configurationHelper.getProperty(ConfigurationValue.S3_ENDPOINT)); businessObjectDataRestoreDto.setS3KeyPrefix(s3KeyPrefix); businessObjectDataRestoreDto.setStorageFiles(storageFiles); businessObjectDataRestoreDto.setStorageName(storageName);
/** * Expires a restored S3 storage unit. * * @param storageUnitKey the storage unit key */ protected void expireS3StorageUnitImpl(BusinessObjectDataStorageUnitKey storageUnitKey) { // Build the business object data restore DTO. BusinessObjectDataRestoreDto businessObjectDataRestoreDto = expireRestoredBusinessObjectDataHelperService.prepareToExpireStorageUnit(storageUnitKey); // Create storage unit notification for the storage unit. notificationEventService.processStorageUnitNotificationEventAsync(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG, businessObjectDataRestoreDto.getBusinessObjectDataKey(), businessObjectDataRestoreDto.getStorageName(), businessObjectDataRestoreDto.getNewStorageUnitStatus(), businessObjectDataRestoreDto.getOldStorageUnitStatus()); // Execute the S3 specific steps required to expire business object data. expireRestoredBusinessObjectDataHelperService.executeS3SpecificSteps(businessObjectDataRestoreDto); // Execute the after step. expireRestoredBusinessObjectDataHelperService.completeStorageUnitExpiration(businessObjectDataRestoreDto); // Create storage unit notification for the storage unit. notificationEventService.processStorageUnitNotificationEventAsync(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG, businessObjectDataRestoreDto.getBusinessObjectDataKey(), businessObjectDataRestoreDto.getStorageName(), businessObjectDataRestoreDto.getNewStorageUnitStatus(), businessObjectDataRestoreDto.getOldStorageUnitStatus()); }
BusinessObjectDataRestoreDto businessObjectDataRestoreDto = new BusinessObjectDataRestoreDto(); businessObjectDataRestoreDto.setBusinessObjectDataKey(businessObjectDataKey); businessObjectDataRestoreDto.setStorageName(storageName); businessObjectDataRestoreDto.setS3Endpoint(configurationHelper.getProperty(ConfigurationValue.S3_ENDPOINT)); businessObjectDataRestoreDto.setS3BucketName(s3BucketName); businessObjectDataRestoreDto.setS3KeyPrefix(s3KeyPrefix); businessObjectDataRestoreDto.setStorageFiles(storageFiles);
new BusinessObjectDataRestoreDto(businessObjectDataKey, STORAGE_NAME, S3_ENDPOINT, S3_BUCKET_NAME, S3_KEY_PREFIX, NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS, Arrays.asList(new StorageFile(S3_KEY, FILE_SIZE, ROW_COUNT)), NO_EXCEPTION); assertEquals(StorageUnitStatusEntity.ARCHIVED, businessObjectDataRestoreDto.getNewStorageUnitStatus()); assertEquals(StorageUnitStatusEntity.EXPIRING, businessObjectDataRestoreDto.getOldStorageUnitStatus());
public Void answer(InvocationOnMock invocation) { // Get the parameters DTO for the business object data restore. BusinessObjectDataRestoreDto businessObjectDataRestoreDto = (BusinessObjectDataRestoreDto) invocation.getArguments()[0]; // Set the value for the new and old storage unit statuses. businessObjectDataRestoreDto.setNewStorageUnitStatus(StorageUnitStatusEntity.ARCHIVED); businessObjectDataRestoreDto.setOldStorageUnitStatus(StorageUnitStatusEntity.EXPIRING); return null; } }).when(expireRestoredBusinessObjectDataHelperService).completeStorageUnitExpiration(businessObjectDataRestoreDto);
@Test public void testPrepareToFinalizeRestore() throws Exception { // Create a business object data key. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION); // Create a storage unit key. BusinessObjectDataStorageUnitKey storageUnitKey = storageUnitHelper.createStorageUnitKey(businessObjectDataKey, STORAGE_NAME); // Create database entities required for testing. BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper.createDatabaseEntitiesForFinalizeRestoreTesting(businessObjectDataKey); // Get the storage unit entity. StorageUnitEntity storageUnitEntity = storageUnitDaoHelper.getStorageUnitEntity(STORAGE_NAME, businessObjectDataEntity); // Prepare to finalize a restore for the business object data. BusinessObjectDataRestoreDto result = businessObjectDataFinalizeRestoreHelperService.prepareToFinalizeRestore(storageUnitKey); // Validate the returned object. assertEquals(new BusinessObjectDataRestoreDto(businessObjectDataKey, STORAGE_NAME, NO_S3_ENDPOINT, S3_BUCKET_NAME, result.getS3KeyPrefix(), NO_STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS, storageFileHelper.createStorageFilesFromEntities(storageUnitEntity.getStorageFiles()), NO_EXCEPTION), result); }