From c04e4d3c42a80f52a8ac2ad2c59c6631b95690de Mon Sep 17 00:00:00 2001 From: sinthuja Date: Tue, 29 Aug 2017 12:39:21 +0530 Subject: [PATCH] Committing initial refactoring for visibility change. --- .../application/mgt/common/Visibility.java | 65 +++---------------- .../VisibilityManagementException.java} | 20 +++++- .../common/services/VisibilityManager.java | 11 +++- .../services/VisibilityTypeManager.java | 26 -------- .../mgt/core/dao/ResourceTypeDAO.java | 22 ------- .../GenericLifecycleStateImpl.java | 4 +- .../mgt/core/impl/VisibilityManagerImpl.java | 25 ++++++- 7 files changed, 61 insertions(+), 112 deletions(-) rename components/application-mgt/{org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/VisibilityTypeManagerImpl.java => org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/VisibilityManagementException.java} (53%) delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityTypeManager.java delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ResourceTypeDAO.java diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Visibility.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Visibility.java index e8d361d5b8..c2992aa670 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Visibility.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Visibility.java @@ -18,6 +18,8 @@ */ package org.wso2.carbon.device.application.mgt.common; +import java.util.List; + /** * This class represents the visibility details of an Application. */ @@ -25,19 +27,7 @@ public class Visibility { private Type type; - private String value; - - private Application application; - - private ApplicationRelease applicationRelease; - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } + private List allowedList; public Type getType() { return type; @@ -47,55 +37,18 @@ public class Visibility { this.type = type; } - public Application getApplication() { - return application; - } - - public void setApplication(Application application) { - this.application = application; - } - - public ApplicationRelease getApplicationRelease() { - return applicationRelease; + public List getAllowedList() { + return allowedList; } - public void setApplicationRelease(ApplicationRelease applicationRelease) { - this.applicationRelease = applicationRelease; + public void setAllowedList(List allowedList) { + this.allowedList = allowedList; } /** * Type of the visibility of the application. */ - public class Type { - - private String id; - - private String name; - - private String description; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } + public enum Type { + PUBLIC, ROLES, DEVICE_GROUPS } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/VisibilityTypeManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/VisibilityManagementException.java similarity index 53% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/VisibilityTypeManagerImpl.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/VisibilityManagementException.java index 5396a67000..660d18f1c5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/VisibilityTypeManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/VisibilityManagementException.java @@ -15,9 +15,23 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.core.impl; +package org.wso2.carbon.device.application.mgt.common.exception; -import org.wso2.carbon.device.application.mgt.common.services.VisibilityTypeManager; +/** + * This specialized exception is thrown by the Visibility Manager during unexpected behaviour + * or unsupported parameters. + */ +public class VisibilityManagementException extends ApplicationManagementException { -public class VisibilityTypeManagerImpl implements VisibilityTypeManager { + public VisibilityManagementException(String msg, Exception nestedEx) { + super(msg, nestedEx); + } + + public VisibilityManagementException(String message, Throwable cause) { + super(message, cause); + } + + public VisibilityManagementException(String msg) { + super(msg); + } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityManager.java index 3e22b6f4de..670ad5ce79 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityManager.java @@ -18,9 +18,18 @@ package org.wso2.carbon.device.application.mgt.common.services; +import org.wso2.carbon.device.application.mgt.common.Visibility; + /** - * This interface manages all the operations related with Application Visibility. + * This interface manages all the operations related with Application Visibility, and in the case of the restr */ public interface VisibilityManager { + void addVisibilityMapping(String applicationId, Visibility visibility); + + Visibility getVisibility(String applicationId); + + void updateVisibilityMapping(String applicationId, Visibility visibility); + + void removeVisibilityMapping(String applicationId); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityTypeManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityTypeManager.java deleted file mode 100644 index 83018ad1d4..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityTypeManager.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.application.mgt.common.services; - -/** - * VisibilityTypeManager is responsible for handling all the operations related to VisibilityType, this includes - * creating, updating and viewing the {@link org.wso2.carbon.device.application.mgt.common.Visibility.Type} - */ -public interface VisibilityTypeManager { -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ResourceTypeDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ResourceTypeDAO.java deleted file mode 100644 index d4cf3b3ac6..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ResourceTypeDAO.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.application.mgt.core.dao; - -public interface ResourceTypeDAO { -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateImpl.java index a772ba8583..dcadb97a30 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateImpl.java @@ -44,11 +44,9 @@ public class GenericLifecycleStateImpl extends AbstractDAOImpl implements Lifecy Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; - String sql = ""; - try { conn = this.getDBConnection(); - sql += "SELECT * FROM APPM_LIFECYCLE_STATE WHERE IDENTIFIER = ? "; + String sql = "SELECT * FROM APPM_LIFECYCLE_STATE WHERE IDENTIFIER = ? "; stmt = conn.prepareStatement(sql); stmt.setString(1, identifier); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/VisibilityManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/VisibilityManagerImpl.java index 315d3c6122..612b041233 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/VisibilityManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/VisibilityManagerImpl.java @@ -17,7 +17,30 @@ */ package org.wso2.carbon.device.application.mgt.core.impl; +import org.wso2.carbon.device.application.mgt.common.Visibility; import org.wso2.carbon.device.application.mgt.common.services.VisibilityManager; -public class VisibilityManagerImpl implements VisibilityManager{ +/** + * This is the defaut implementation for the visibility manager. + */ +public class VisibilityManagerImpl implements VisibilityManager { + @Override + public void addVisibilityMapping(String applicationId, Visibility visibility) { + + } + + @Override + public Visibility getVisibility(String applicationId) { + return null; + } + + @Override + public void updateVisibilityMapping(String applicationId, Visibility visibility) { + + } + + @Override + public void removeVisibilityMapping(String applicationId) { + + } }