Add stream base file uploading #338

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

Purpose

  • Contains stream file upload changes
## Purpose * Contains stream file upload changes
rajitha force-pushed stream-api from 7ee6ecfc71 to 0a9e5a3d3f 7 months ago
rajitha force-pushed stream-api from 0a9e5a3d3f to b3be13f0ae 7 months ago
rajitha changed title from WIP: Add stream base file uploading to Add stream base file uploading 7 months ago
rajitha force-pushed stream-api from 378ee295db to 938d604a30 7 months ago
tcdlpds requested changes 6 months ago
}
@SuppressWarnings("unchecked")
private <T> Application createApplicationBasedOnRemoteStatus(T app, boolean isPublished) throws ApplicationManagementException {
Owner

Add method level comment

Add method level comment
rajitha marked this conversation as resolved
List<?> releaseWrappers = ApplicationManagementUtil.deriveApplicationWithoutRelease(app);
Application createdApplication = triggerApplicationCreation(app, isPublished);
if (createdApplication == null) {
throw new ApplicationManagementException("Application creation request failed");
Owner

Improve error message

Improve error message
rajitha marked this conversation as resolved
((CustomAppWrapper) app).setCustomAppReleaseWrappers((List<CustomAppReleaseWrapper>) releaseWrappers);
createApplicationReleaseBasedOnRemoteStatus(createdApplication.getId(),
((CustomAppWrapper) app).getCustomAppReleaseWrappers().get(0), isPublished);
}
Owner

Handle else part here

Handle else part here
rajitha marked this conversation as resolved
return triggerApplicationCreation(app, isPublished);
}
private <T> Application triggerApplicationCreation(T app, boolean isPublished) throws ApplicationManagementException {
Owner

Add method level comment

Add method level comment
rajitha marked this conversation as resolved
}
}
private <T> ApplicationRelease createApplicationReleaseBasedOnRemoteStatus(int appId, T releaseWrapper, boolean isPublished)
Owner

Add method level comment

Add method level comment
rajitha marked this conversation as resolved
if (ApplicationManagementUtil.getRemoteStatusFromWrapper(releaseWrapper)) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
new Thread(() -> {
Owner

Add into new method

Add into new method
rajitha marked this conversation as resolved
if (releaseWrapper instanceof CustomAppReleaseWrapper) {
return triggerCustomAppRelease(appId, (CustomAppReleaseWrapper) releaseWrapper, isPublished);
}
Owner

Handle Else section

Handle Else section
rajitha marked this conversation as resolved
return new ApplicationRelease();
}
private ApplicationRelease triggerEntAppRelease(int appId, EntAppReleaseWrapper releaseWrapper, boolean isPublished)
Owner

Add method level comment

Add method level comment
rajitha marked this conversation as resolved
validateReleaseCreatingRequest(releaseWrapper, deviceType);
validateBinaryArtifact(releaseWrapper.getBinaryFile());
validateImageArtifacts(releaseWrapper.getIcon(), releaseWrapper.getScreenshots());
//validateBinaryArtifact(releaseWrapper.getBinaryFile());
Owner

Remove commented lines

Remove commented lines
rajitha marked this conversation as resolved
}
return remoteFileDownloaderService;
} catch (FileTransferServiceException e) {
throw new FileDownloaderServiceException("Error encountered while acquiring file downloader service", e);
Owner

Log the error

Log the error
rajitha marked this conversation as resolved
}
}
private static class LocalFileDownloaderService implements FileDownloaderService {
Owner

Add method level comment

Add method level comment
rajitha marked this conversation as resolved
try {
return fileTransferService.resolve(downloadUrl);
} catch (FileTransferServiceException e) {
throw new FileDownloaderServiceException("Error encountered while downloading file pointing by " + downloadUrl, e);
Owner

Log the error

Log the error
rajitha marked this conversation as resolved
}
}
private static class RemoteFileDownloaderService implements FileDownloaderService {
Owner

Add method level comment

Add method level comment
rajitha marked this conversation as resolved
}
}
private FileMetaEntry getFileMetaEntry(URL downloadUrl) throws FileDownloaderServiceException {
Owner

Add method level comment

Add method level comment
rajitha marked this conversation as resolved
}
if (!Files.isDirectory(root)) {
throw new FileTransferServiceHelperUtilException(root.toAbsolutePath() + " is not a directory");
Owner

log the error

log the error
rajitha marked this conversation as resolved
}
}
private static Path locateArtifactHolder(String artifactHolder) throws FileTransferServiceHelperUtilException, NotFoundException {
Owner

Add method level comments

Add method level comments
rajitha marked this conversation as resolved
}
if (!Objects.equals(System.getProperty("iot.gateway.host"), downloadUrl.getHost())) {
return null;
Owner

Add debug logs for these null returning points

Add debug logs for these null returning points
rajitha marked this conversation as resolved
rajitha force-pushed stream-api from 938d604a30 to 25aa1af786 6 months ago
rajitha force-pushed stream-api from 25aa1af786 to 3798134011 6 months ago
rajitha added 1 commit 6 months ago
pahansith merged commit 78dd491789 into master 6 months ago

Reviewers

tcdlpds requested changes 6 months ago
The pull request has been merged as 78dd491789.
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#338
Loading…
There is no content yet.