|
|
|
@ -117,8 +117,6 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return applicationRelease;
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
@ -126,7 +124,32 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|
|
|
|
"IO Exception while saving the screens hots for the " + "application " + applicationId, e);
|
|
|
|
|
} catch (ApplicationStorageManagementException e) {
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
throw new ApplicationStorageManagementException("Application Management DAO exception while trying to"
|
|
|
|
|
throw new ApplicationStorageManagementException("Application Management DAO exception while trying to "
|
|
|
|
|
+ "update the screen-shot count for the application " + applicationId + " for the tenant id "
|
|
|
|
|
+ tenantId, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease updateImageArtifacts(int applicationId, String uuid, InputStream iconFileStream,
|
|
|
|
|
InputStream bannerFileStream, List<InputStream> screenShotStreams)
|
|
|
|
|
throws ResourceManagementException, ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
ApplicationRelease applicationRelease = validateApplicationRelease(uuid);
|
|
|
|
|
applicationRelease = uploadImageArtifacts(applicationId, applicationRelease, iconFileStream, bannerFileStream, screenShotStreams);
|
|
|
|
|
return applicationRelease;
|
|
|
|
|
} catch (ApplicationStorageManagementException e) {
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
throw new ApplicationStorageManagementException("Application Storage exception while trying to"
|
|
|
|
|
+ " update the screen-shot count for the application " + applicationId + " for the tenant "
|
|
|
|
|
+ tenantId, e);
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
throw new ApplicationManagementException("Application Management DAO exception while trying to"
|
|
|
|
|
+ " update the screen-shot count for the application " + applicationId + " for the tenant "
|
|
|
|
|
+ tenantId, e);
|
|
|
|
|
}
|
|
|
|
@ -167,100 +190,125 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public InputStream getReleasedArtifacts(String applicationUUID, String versionName)
|
|
|
|
|
throws ApplicationStorageManagementException {
|
|
|
|
|
// todo this should be validate application release
|
|
|
|
|
Application application = validateApplication(applicationUUID);
|
|
|
|
|
String artifactPath = storagePath + application.getId() + File.separator + versionName;
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("ApplicationRelease artifacts are searched in the location " + artifactPath);
|
|
|
|
|
}
|
|
|
|
|
public ApplicationRelease updateReleaseArtifacts(int applicationId, String applicationUuid, InputStream binaryFile)
|
|
|
|
|
throws ResourceManagementException {
|
|
|
|
|
|
|
|
|
|
File binaryFile = new File(artifactPath);
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
|
|
|
|
|
if (!binaryFile.exists()) {
|
|
|
|
|
throw new ApplicationStorageManagementException("Binary file does not exist for this release");
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
return new FileInputStream(artifactPath);
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
throw new ApplicationStorageManagementException(
|
|
|
|
|
"Binary file does not exist for the version " + versionName + " for the application ", e);
|
|
|
|
|
}
|
|
|
|
|
ApplicationRelease applicationRelease = null;
|
|
|
|
|
try {
|
|
|
|
|
applicationRelease = validateApplicationRelease(applicationUuid);
|
|
|
|
|
applicationRelease = uploadReleaseArtifacts(applicationId, applicationRelease,binaryFile);
|
|
|
|
|
return applicationRelease;
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
throw new ApplicationStorageManagementException("Application Management exception while trying to"
|
|
|
|
|
+ " update the Application artifact for the application " + applicationId + " for the tenant "
|
|
|
|
|
+ tenantId, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//todo
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteApplicationArtifacts(String applicationUUID) throws ApplicationStorageManagementException {
|
|
|
|
|
public InputStream getReleasedArtifacts(String applicationUUID, String versionName)
|
|
|
|
|
throws ApplicationStorageManagementException {
|
|
|
|
|
return null;
|
|
|
|
|
// todo this should be validate application release
|
|
|
|
|
Application application = validateApplication(applicationUUID);
|
|
|
|
|
String artifactDirectoryPath = storagePath + application.getId();
|
|
|
|
|
File artifactDirectory = new File(artifactDirectoryPath);
|
|
|
|
|
// Application application = validateApplication(applicationUUID);
|
|
|
|
|
// String artifactPath = storagePath + application.getId() + File.separator + versionName;
|
|
|
|
|
//
|
|
|
|
|
// if (log.isDebugEnabled()) {
|
|
|
|
|
// log.debug("ApplicationRelease artifacts are searched in the location " + artifactPath);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// File binaryFile = new File(artifactPath);
|
|
|
|
|
//
|
|
|
|
|
// if (!binaryFile.exists()) {
|
|
|
|
|
// throw new ApplicationStorageManagementException("Binary file does not exist for this release");
|
|
|
|
|
// } else {
|
|
|
|
|
// try {
|
|
|
|
|
// return new FileInputStream(artifactPath);
|
|
|
|
|
// } catch (FileNotFoundException e) {
|
|
|
|
|
// throw new ApplicationStorageManagementException(
|
|
|
|
|
// "Binary file does not exist for the version " + versionName + " for the application ", e);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (artifactDirectory.exists()) {
|
|
|
|
|
StorageManagementUtil.deleteDir(artifactDirectory);
|
|
|
|
|
}
|
|
|
|
|
//todo
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteApplicationArtifacts(String applicationUUID) throws ApplicationStorageManagementException {
|
|
|
|
|
// todo this should be validate application release
|
|
|
|
|
// Application application = validateApplication(applicationUUID);
|
|
|
|
|
// String artifactDirectoryPath = storagePath + application.getId();
|
|
|
|
|
// File artifactDirectory = new File(artifactDirectoryPath);
|
|
|
|
|
//
|
|
|
|
|
// if (artifactDirectory.exists()) {
|
|
|
|
|
// StorageManagementUtil.deleteDir(artifactDirectory);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//todo
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteApplicationReleaseArtifacts(String applicationUUID, String version)
|
|
|
|
|
throws ApplicationStorageManagementException {
|
|
|
|
|
// todo this should be validate application release
|
|
|
|
|
Application application = validateApplication(applicationUUID);
|
|
|
|
|
String artifactPath = storagePath + application.getId() + File.separator + version;
|
|
|
|
|
File artifact = new File(artifactPath);
|
|
|
|
|
|
|
|
|
|
if (artifact.exists()) {
|
|
|
|
|
StorageManagementUtil.deleteDir(artifact);
|
|
|
|
|
}
|
|
|
|
|
// Application application = validateApplication(applicationUUID);
|
|
|
|
|
// String artifactPath = storagePath + application.getId() + File.separator + version;
|
|
|
|
|
// File artifact = new File(artifactPath);
|
|
|
|
|
//
|
|
|
|
|
// if (artifact.exists()) {
|
|
|
|
|
// StorageManagementUtil.deleteDir(artifact);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//todo
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteAllApplicationReleaseArtifacts(String applicationUUID) throws
|
|
|
|
|
ApplicationStorageManagementException {
|
|
|
|
|
// todo this should be validate application release
|
|
|
|
|
validateApplication(applicationUUID);
|
|
|
|
|
try {
|
|
|
|
|
List<ApplicationRelease> applicationReleases = DataHolder.getInstance().getApplicationReleaseManager()
|
|
|
|
|
.getReleases(applicationUUID);
|
|
|
|
|
for (ApplicationRelease applicationRelease : applicationReleases) {
|
|
|
|
|
deleteApplicationReleaseArtifacts(applicationUUID, applicationRelease.getVersion());
|
|
|
|
|
}
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
throw new ApplicationStorageManagementException(
|
|
|
|
|
"Application Management Exception while getting releases " + "for the application "
|
|
|
|
|
+ applicationUUID, e);
|
|
|
|
|
}
|
|
|
|
|
// validateApplication(applicationUUID);
|
|
|
|
|
// try {
|
|
|
|
|
// List<ApplicationRelease> applicationReleases = DataHolder.getInstance().getApplicationReleaseManager()
|
|
|
|
|
// .getReleases(applicationUUID);
|
|
|
|
|
// for (ApplicationRelease applicationRelease : applicationReleases) {
|
|
|
|
|
// deleteApplicationReleaseArtifacts(applicationUUID, applicationRelease.getVersion());
|
|
|
|
|
// }
|
|
|
|
|
// } catch (ApplicationManagementException e) {
|
|
|
|
|
// throw new ApplicationStorageManagementException(
|
|
|
|
|
// "Application Management Exception while getting releases " + "for the application "
|
|
|
|
|
// + applicationUUID, e);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//todo
|
|
|
|
|
@Override
|
|
|
|
|
public ImageArtifact getImageArtifact(String applicationUUID, String name, int count) throws
|
|
|
|
|
ApplicationStorageManagementException {
|
|
|
|
|
return null;
|
|
|
|
|
// todo this should be validate application release
|
|
|
|
|
Application application = validateApplication(applicationUUID);
|
|
|
|
|
validateImageArtifactNames(name);
|
|
|
|
|
String imageArtifactPath = storagePath + application.getId() + File.separator + name.toLowerCase();
|
|
|
|
|
|
|
|
|
|
if (name.equalsIgnoreCase(Constants.IMAGE_ARTIFACTS[2])) {
|
|
|
|
|
imageArtifactPath += count;
|
|
|
|
|
}
|
|
|
|
|
File imageFile = new File(imageArtifactPath);
|
|
|
|
|
if (!imageFile.exists()) {
|
|
|
|
|
throw new ApplicationStorageManagementException(
|
|
|
|
|
"Image artifact " + name + " does not exist for the " + "application with UUID " + applicationUUID);
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
return StorageManagementUtil.createImageArtifact(imageFile, imageArtifactPath);
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
throw new ApplicationStorageManagementException(
|
|
|
|
|
"File not found exception while trying to get the image artifact " + name + " for the "
|
|
|
|
|
+ "application " + applicationUUID, e);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new ApplicationStorageManagementException("IO Exception while trying to detect the image "
|
|
|
|
|
+ "artifact " + name + " for the application " + applicationUUID, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Application application = validateApplication(applicationUUID);
|
|
|
|
|
// validateImageArtifactNames(name);
|
|
|
|
|
// String imageArtifactPath = storagePath + application.getId() + File.separator + name.toLowerCase();
|
|
|
|
|
//
|
|
|
|
|
// if (name.equalsIgnoreCase(Constants.IMAGE_ARTIFACTS[2])) {
|
|
|
|
|
// imageArtifactPath += count;
|
|
|
|
|
// }
|
|
|
|
|
// File imageFile = new File(imageArtifactPath);
|
|
|
|
|
// if (!imageFile.exists()) {
|
|
|
|
|
// throw new ApplicationStorageManagementException(
|
|
|
|
|
// "Image artifact " + name + " does not exist for the " + "application with UUID " + applicationUUID);
|
|
|
|
|
// } else {
|
|
|
|
|
// try {
|
|
|
|
|
// return StorageManagementUtil.createImageArtifact(imageFile, imageArtifactPath);
|
|
|
|
|
// } catch (FileNotFoundException e) {
|
|
|
|
|
// throw new ApplicationStorageManagementException(
|
|
|
|
|
// "File not found exception while trying to get the image artifact " + name + " for the "
|
|
|
|
|
// + "application " + applicationUUID, e);
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// throw new ApplicationStorageManagementException("IO Exception while trying to detect the image "
|
|
|
|
|
// + "artifact " + name + " for the application " + applicationUUID, e);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -311,7 +359,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|
|
|
|
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
|
|
|
|
+ "parameter to get the relevant application.");
|
|
|
|
|
}
|
|
|
|
|
ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager().getRelease();
|
|
|
|
|
ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager().
|
|
|
|
|
getReleaseByUuid(applicationUuid);
|
|
|
|
|
if (applicationRelease == null) {
|
|
|
|
|
throw new NotFoundException(
|
|
|
|
|
"Application with UUID " + applicationUuid + " does not exist.");
|
|
|
|
|