App publishing improvements #385

Merged
tcdlpds merged 2 commits from rajitha/device-mgt-core:stream-api into master 5 months ago
Collaborator

Purpose

  • Contains improvements for artifact copying procedure, heap memory overflowing issue, release update improvements and local file downloader service improvements.
## Purpose * Contains improvements for artifact copying procedure, heap memory overflowing issue, release update improvements and local file downloader service improvements.
rajitha added 1 commit 7 months ago
pahansith requested changes 6 months ago
releaseDTO.setUuid(UUID.randomUUID().toString());
releaseDTO.setAppHashValue(md5OfApp);
releaseDTO.setInstallerName(applicationArtifact.getInstallerName());
Owner

Format code

Format code
rajitha marked this conversation as resolved
} catch (StorageManagementException e) {
String msg = "Error occurred while md5sum value retrieving process: application UUID "
+ releaseDTO.getUuid();
log.error(msg, e);
Owner

Check if throwing the error to the caller is required

Check if throwing the error to the caller is required
rajitha marked this conversation as resolved
log.error(msg);
throw new ApplicationManagementException(msg);
}
String md5OfApp = applicationStorageManager.getMD5(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())));
Owner

Format code

Format code
rajitha marked this conversation as resolved
}
applicationReleaseDTO.setAppHashValue(md5OfApp);
applicationStorageManager
Owner

Format code

Format code
rajitha marked this conversation as resolved
applicationReleaseDTO.setPackageName(packageName);
String deletingAppHashValue = applicationReleaseDTO.getAppHashValue();
applicationReleaseDTO.setAppHashValue(md5OfApp);
applicationStorageManager.uploadReleaseArtifact(applicationReleaseDTO, deviceType,
Owner

Format code

Format code
rajitha marked this conversation as resolved
applicationReleaseDTO.get().setInstallerName(applicationArtifact.getInstallerName());
String deletingAppHashValue = applicationReleaseDTO.get().getAppHashValue();
applicationReleaseDTO.get().setAppHashValue(md5OfApp);
applicationStorageManager.
Owner

Format code

Format code
rajitha marked this conversation as resolved
String deviceType, InputStream binaryFile, int tenantId) throws ResourceManagementException {
try {
byte [] content = IOUtils.toByteArray(binaryFile);
//byte [] content = IOUtils.toByteArray(binaryFile);
Owner

Remove commented line if not necessary

Remove commented line if not necessary
rajitha marked this conversation as resolved
}
@Override
public String getAbsolutePathOfFile(String hashVal, String folderName, String fileName, int tenantId) {
Owner

Can be converted to an static method

Can be converted to an static method
rajitha marked this conversation as resolved
}
private static FileDescriptor resolve(String []urlSegments) throws FileTransferServiceHelperUtilException {
if (urlSegments.length < 4) {
Owner

Add a comment why this length check is necessary and use a constant for the numeric literal

Add a comment why this length check is necessary and use a constant for the numeric literal
rajitha marked this conversation as resolved
String appHash = urlSegments[urlSegments.length - 3];
try {
InputStream fileStream = DataHolder.getInstance().
Owner

Close the stream.

Close the stream.
Poster
Collaborator

Stream closes where the places this stream is getting use.

Stream closes where the places this stream is getting use.
rajitha marked this conversation as resolved
bufferedOutputStream.write(buffer, 0, n);
}
} finally {
inputStream.close();
Owner

Why thie close statement is removed? Also required to close the BufferedOutputStream as well.

Why thie close statement is removed? Also required to close the BufferedOutputStream as well.
Poster
Collaborator

Since both the streams are implements AutoCloseable interface, there is no such need to close streams manually when used with try-with-resource block.

Since both the streams are implements `AutoCloseable` interface, there is no such need to close streams manually when used with try-with-resource block.
rajitha marked this conversation as resolved
rajitha force-pushed stream-api from edde23df16 to 2eb73213f3 5 months ago
tcdlpds merged commit 541853df30 into master 5 months ago

Reviewers

pahansith requested changes 6 months ago
The pull request has been merged as 541853df30.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: community/device-mgt-core#385
Loading…
There is no content yet.