mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Refactored the source code
This commit is contained in:
parent
c3f04eeed0
commit
7278408b44
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
|||||||
@ -175,7 +175,10 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
throw new ApplicationManagementException(
|
throw new ApplicationManagementException(
|
||||||
"User-store exception while checking whether the user " + userName + " of tenant " + tenantId
|
"User-store exception while checking whether the user " + userName + " of tenant " + tenantId
|
||||||
+ " has the publisher permission");
|
+ " has the publisher permission", e);
|
||||||
|
} catch (ApplicationManagementDAOException e) {
|
||||||
|
throw new ApplicationManagementException(
|
||||||
|
"DAO exception while getting applications for the user " + userName + " of tenant " + tenantId, e);
|
||||||
} finally {
|
} finally {
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
ConnectionManagerUtil.closeDBConnection();
|
||||||
}
|
}
|
||||||
@ -526,14 +529,15 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager()
|
ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager()
|
||||||
.getReleaseByUuid(applicationUuid);
|
.getReleaseByUuid(applicationUuid);
|
||||||
if (applicationRelease == null) {
|
if (applicationRelease == null) {
|
||||||
throw new NotFoundException(
|
throw new ApplicationManagementException(
|
||||||
"Application with UUID " + applicationUuid + " does not exist.");
|
"Application with UUID " + applicationUuid + " does not exist.");
|
||||||
}
|
}
|
||||||
return applicationRelease;
|
return applicationRelease;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationRelease updateRelease(int appId, ApplicationRelease applicationRelease) throws ApplicationManagementException {
|
public ApplicationRelease updateRelease(int appId, ApplicationRelease applicationRelease) throws
|
||||||
|
ApplicationManagementException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -787,17 +791,15 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
!SortingOrder.DESC.toString().equals(filter.getSortBy())) {
|
!SortingOrder.DESC.toString().equals(filter.getSortBy())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (filter.getAppType() != null) {
|
if (filter.getAppType() != null) {
|
||||||
Boolean isValidRequest = false;
|
Boolean isValidRequest = false;
|
||||||
for (ApplicationType applicationType: ApplicationType.values()){
|
for (ApplicationType applicationType : ApplicationType.values()) {
|
||||||
if(applicationType.toString().equals(filter.getAppType())){
|
if (applicationType.toString().equals(filter.getAppType())) {
|
||||||
isValidRequest = true;
|
isValidRequest = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isValidRequest){
|
if (!isValidRequest) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
|||||||
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
||||||
import org.wso2.carbon.device.application.mgt.common.*;
|
import org.wso2.carbon.device.application.mgt.common.*;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.exception.ValidationException;
|
||||||
import org.wso2.carbon.device.application.mgt.publisher.api.APIUtil;
|
import org.wso2.carbon.device.application.mgt.publisher.api.APIUtil;
|
||||||
import org.wso2.carbon.device.application.mgt.publisher.api.services.ApplicationManagementAPI;
|
import org.wso2.carbon.device.application.mgt.publisher.api.services.ApplicationManagementAPI;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||||
@ -58,12 +59,10 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
|
|
||||||
private static Log log = LogFactory.getLog(ApplicationManagementAPIImpl.class);
|
private static Log log = LogFactory.getLog(ApplicationManagementAPIImpl.class);
|
||||||
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Override
|
@Override
|
||||||
@Consumes("application/json")
|
@Consumes("application/json")
|
||||||
public Response getApplications(
|
public Response getApplications(@Valid Filter filter) {
|
||||||
@Valid Filter filter) {
|
|
||||||
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -73,9 +72,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
("Couldn't find any application for requested query.").build();
|
("Couldn't find any application for requested query.").build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(applications).build();
|
return Response.status(Response.Status.OK).entity(applications).build();
|
||||||
} catch (NotFoundException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
return Response.status(Response.Status.NOT_FOUND).build();
|
|
||||||
} catch (ApplicationManagementException e) {
|
|
||||||
String msg = "Error occurred while getting the application list for publisher ";
|
String msg = "Error occurred while getting the application list for publisher ";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user