Refactor code

feature/appm-store/pbac
Chatura Dilan 8 years ago
parent b25f14668e
commit 352c881c24

@ -37,7 +37,8 @@ public class APIUtil {
private static ApplicationManager applicationManager;
public static ApplicationManager getApplicationManagemer() {
public static ApplicationManager getApplicationManager() {
if (applicationManager == null) {
synchronized (APIUtil.class) {
if (applicationManager == null) {
@ -52,10 +53,12 @@ public class APIUtil {
}
}
}
return applicationManager;
}
public static Response getResponse(ApplicationManagementException ex, Response.Status status) {
//TODO: check for exception type and set the response code.
ErrorResponse errorMessage = new ErrorResponse();
errorMessage.setMessage(ex.getMessage());
@ -64,5 +67,6 @@ public class APIUtil {
}
errorMessage.setCode(status.getStatusCode());
return Response.status(status).entity(errorMessage).build();
}
}

@ -44,7 +44,7 @@ public class ApplicationManagementAPIImpl {
@Path("applications")
public Response getApplications(@QueryParam("offset") int offset, @QueryParam("limit") int limit,
@QueryParam("query") String searchQuery) {
ApplicationManager applicationManager = APIUtil.getApplicationManagemer();
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
if (limit == 0) {
limit = DEFAULT_LIMIT;

@ -25,7 +25,11 @@ import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManage
public interface ApplicationManager{
void createApplication(Application application) throws ApplicationManagementException;
public Application createApplication(Application application) throws ApplicationManagementException;
ApplicationList getApplications(Filter filter) throws ApplicationManagementException;
public Application editApplication(int applicationId, Application application) throws ApplicationManagementException;
public void deleteApplication(int applicationId) throws ApplicationManagementException;
public ApplicationList getApplications(Filter filter) throws ApplicationManagementException;
}

@ -18,5 +18,11 @@
*/
package org.wso2.carbon.device.application.mgt.common.services;
import org.wso2.carbon.device.application.mgt.common.Application;
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
public interface ApplicationReleaseManager{
}

@ -18,5 +18,19 @@
*/
package org.wso2.carbon.device.application.mgt.common.services;
import org.wso2.carbon.device.application.mgt.common.Application;
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
import org.wso2.carbon.device.application.mgt.common.Category;
import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
public interface CategoryManager{
public Category createCategory(Category application) throws ApplicationManagementException;
public Category editCategory(int applicationId, Category category) throws ApplicationManagementException;
public void deleteCategory(int applicationId) throws ApplicationManagementException;
public Category getCategory(Filter filter) throws ApplicationManagementException;
}

@ -28,13 +28,25 @@ import org.wso2.carbon.device.application.mgt.core.dao.common.DAOFactory;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
public class ApplicationManagerImpl implements ApplicationManager {
@Override
public void createApplication(Application application) throws ApplicationManagementException {
public Application createApplication(Application application) throws ApplicationManagementException {
return null;
}
@Override
public Application editApplication(int applicationId, Application application) throws ApplicationManagementException {
return null;
}
@Override
public void deleteApplication(int applicationId) throws ApplicationManagementException {
}
@Override
public ApplicationList getApplications(Filter filter) throws ApplicationManagementException {
try {
ConnectionManagerUtil.openConnection();
ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
@ -42,5 +54,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
} finally {
ConnectionManagerUtil.closeConnection();
}
}
}

@ -17,7 +17,30 @@
*/
package org.wso2.carbon.device.application.mgt.core.impl;
import org.wso2.carbon.device.application.mgt.common.Category;
import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
public class CategoryManagerImpl implements CategoryManager {
@Override
public Category createCategory(Category application) throws ApplicationManagementException {
return null;
}
@Override
public Category editCategory(int applicationId, Category category) throws ApplicationManagementException {
return null;
}
@Override
public void deleteCategory(int applicationId) throws ApplicationManagementException {
}
@Override
public Category getCategory(Filter filter) throws ApplicationManagementException {
return null;
}
}

Loading…
Cancel
Save