mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Add application deleting functionality
Modified DAO layer. When delete an application it is moved to REMOVED status.
This commit is contained in:
parent
c95733a781
commit
0b78df50a7
@ -515,9 +515,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
conn = this.getDBConnection();
|
conn = this.getDBConnection();
|
||||||
String sql = "DELETE FROM AP_APP WHERE ID = ? ";
|
String sql = "UPDATE AP_APP SET STATUS = ? WHERE ID = ? ";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(1, appId);
|
stmt.setString(1, AppLifecycleState.REMOVED.toString());
|
||||||
|
stmt.setInt(2, appId);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
|
|
||||||
} catch (DBConnectionException e) {
|
} catch (DBConnectionException e) {
|
||||||
|
|||||||
@ -422,7 +422,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState);
|
addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState);
|
||||||
storedLocations.add(applicationRelease.getAppHashValue());
|
storedLocations.add(applicationRelease.getAppHashValue());
|
||||||
}
|
}
|
||||||
//todo add column into application and move application into removed state
|
try {
|
||||||
|
ConnectionManagerUtil.openDBConnection();
|
||||||
|
ApplicationManagementDAOFactory.getApplicationDAO().deleteApplication(applicationId);
|
||||||
|
} finally {
|
||||||
|
ConnectionManagerUtil.closeDBConnection();
|
||||||
|
}
|
||||||
return storedLocations;
|
return storedLocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -232,7 +232,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
}
|
}
|
||||||
applicationRelease = applicationStorageManager
|
applicationRelease = applicationStorageManager
|
||||||
.updateImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, attachments);
|
.updateImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, attachments);
|
||||||
//todo need to implement updateRelease method
|
|
||||||
applicationManager.updateRelease(appId, applicationRelease);
|
applicationManager.updateRelease(appId, applicationRelease);
|
||||||
return Response.status(Response.Status.OK)
|
return Response.status(Response.Status.OK)
|
||||||
.entity("Successfully uploaded artifacts for the application " + applicationUuid).build();
|
.entity("Successfully uploaded artifacts for the application " + applicationUuid).build();
|
||||||
@ -262,7 +261,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
public Response updateApplicationArtifact(
|
public Response updateApplicationArtifact(
|
||||||
@PathParam("appType") String appType,
|
@PathParam("appType") String appType,
|
||||||
@PathParam("appId") int applicationId,
|
@PathParam("appId") int applicationId,
|
||||||
@PathParam("uuid") String applicationUuuid,
|
@PathParam("uuid") String applicationUuid,
|
||||||
@Multipart("binaryFile") Attachment binaryFile) {
|
@Multipart("binaryFile") Attachment binaryFile) {
|
||||||
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
||||||
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
@ -272,27 +271,26 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
|
|
||||||
if (binaryFile == null) {
|
if (binaryFile == null) {
|
||||||
return Response.status(Response.Status.BAD_REQUEST)
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
.entity("Uploading artifacts for the application is failed " + applicationUuuid).build();
|
.entity("Uploading artifacts for the application is failed " + applicationUuid).build();
|
||||||
}
|
}
|
||||||
applicationRelease = applicationManager.validateApplicationRelease(applicationUuuid);
|
applicationRelease = applicationManager.validateApplicationRelease(applicationUuid);
|
||||||
applicationRelease = applicationStorageManager.updateReleaseArtifacts(applicationRelease, appType,
|
applicationRelease = applicationStorageManager.updateReleaseArtifacts(applicationRelease, appType,
|
||||||
binaryFile.getDataHandler().getInputStream());
|
binaryFile.getDataHandler().getInputStream());
|
||||||
//todo
|
|
||||||
applicationManager.updateRelease(applicationId, applicationRelease);
|
applicationManager.updateRelease(applicationId, applicationRelease);
|
||||||
return Response.status(Response.Status.OK)
|
return Response.status(Response.Status.OK)
|
||||||
.entity("Successfully uploaded artifacts for the application " + applicationUuuid).build();
|
.entity("Successfully uploaded artifacts for the application " + applicationUuid).build();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Exception while trying to read icon, banner files for the application " + applicationUuuid);
|
log.error("Exception while trying to read icon, banner files for the application " + applicationUuid);
|
||||||
return APIUtil.getResponse(new ApplicationManagementException(
|
return APIUtil.getResponse(new ApplicationManagementException(
|
||||||
"Exception while trying to read icon, banner files for the application " + applicationUuuid, e),
|
"Exception while trying to read icon, banner files for the application " + applicationUuid, e),
|
||||||
Response.Status.BAD_REQUEST);
|
Response.Status.BAD_REQUEST);
|
||||||
} catch (ResourceManagementException e) {
|
} catch (ResourceManagementException e) {
|
||||||
log.error("Error occurred while uploading the image artifacts of the application with the uuid "
|
log.error("Error occurred while uploading the image artifacts of the application with the uuid "
|
||||||
+ applicationUuuid, e);
|
+ applicationUuid, e);
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
log.error("Error occurred while updating the image artifacts of the application with the uuid "
|
log.error("Error occurred while updating the image artifacts of the application with the uuid "
|
||||||
+ applicationUuuid, e);
|
+ applicationUuid, e);
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,8 +359,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
|
|
||||||
applicationRelease = applicationStorageManager
|
applicationRelease = applicationStorageManager
|
||||||
.updateImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, attachments);
|
.updateImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, attachments);
|
||||||
|
|
||||||
//todo
|
|
||||||
applicationRelease = applicationManager.updateRelease(applicationId, applicationRelease);
|
applicationRelease = applicationManager.updateRelease(applicationId, applicationRelease);
|
||||||
|
|
||||||
return Response.status(Response.Status.OK).entity(applicationRelease).build();
|
return Response.status(Response.Status.OK).entity(applicationRelease).build();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user