From 84c64439716ea9c5b369f3e547531f95deb0d720 Mon Sep 17 00:00:00 2001 From: Harshan Liyanage Date: Mon, 15 May 2017 17:30:46 +0530 Subject: [PATCH] Fixed build issues. --- .../ApplicationManagementServiceImpl.java | 6 +- .../core/components/ApplicationManager.java | 34 ------ .../impl/ApplicationManagerImpl.java | 63 ----------- .../core/dao/ApplicationManagementDAO.java | 65 ------------ .../ApplicationManagementDAOException.java | 32 ------ .../dao/ApplicationManagementDAOFactory.java | 58 ---------- .../dao/ApplicationManagementDAOUtil.java | 100 ------------------ 7 files changed, 3 insertions(+), 355 deletions(-) delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/components/ApplicationManager.java delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/components/impl/ApplicationManagerImpl.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/ApplicationManagementDAO.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/ApplicationManagementDAOException.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/ApplicationManagementDAOFactory.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/ApplicationManagementDAOUtil.java diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementServiceImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementServiceImpl.java index 87de7714b9..bf86b93a48 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementServiceImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementServiceImpl.java @@ -20,10 +20,10 @@ package org.wso2.carbon.device.application.mgt.api.services.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.application.mgt.core.components.ApplicationManager; -import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; import org.wso2.carbon.device.application.mgt.core.dto.Filter; +import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList; import org.wso2.carbon.device.application.mgt.core.util.ApplicationManagementUtil; +import org.wso2.carbon.device.application.mgt.core.services.ApplicationManager; import javax.ws.rs.*; import javax.ws.rs.core.Response; @@ -42,7 +42,7 @@ public class ApplicationManagementServiceImpl { @Path("applications") public Response getApplications(@QueryParam("offset") int offset, @QueryParam("limit") int limit, @QueryParam("q") String searchQuery) { - ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManager(); + ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagementService(); try { if(limit == 0){ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/components/ApplicationManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/components/ApplicationManager.java deleted file mode 100644 index f14e734317..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/components/ApplicationManager.java +++ /dev/null @@ -1,34 +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.components; - -import org.wso2.carbon.device.application.mgt.core.dto.Application; -import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; -import org.wso2.carbon.device.application.mgt.core.dto.Filter; -import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException; - -import java.util.List; - -public interface ApplicationManager { - - public void createApplication(Application application) throws ApplicationManagerException; - - public ApplicationList getApplications(Filter filter) throws ApplicationManagerException; - -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/components/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/components/impl/ApplicationManagerImpl.java deleted file mode 100644 index 12e4ba519e..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/components/impl/ApplicationManagerImpl.java +++ /dev/null @@ -1,63 +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.components.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.application.mgt.core.components.ApplicationManager; -import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAO; -import org.wso2.carbon.device.application.mgt.core.dto.Application; -import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; -import org.wso2.carbon.device.application.mgt.core.dto.Filter; -import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException; -import org.wso2.carbon.device.application.mgt.core.internal.ApplicationManagementDataHolder; -import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; - -import java.util.List; - -public class ApplicationManagerImpl implements ApplicationManager { - - private static final Log log = LogFactory.getLog(ApplicationManagerImpl.class); - - - private static ApplicationManagerImpl applicationManager = new ApplicationManagerImpl(); - - private ApplicationManagerImpl() { - - } - - public static ApplicationManagerImpl getInstance() { - return applicationManager; - } - - - @Override - public void createApplication(Application application) { - - } - - @Override - public ApplicationList getApplications(Filter filter) throws ApplicationManagerException { - ConnectionManagerUtil.openConnection(); - ApplicationManagementDAO applicationManagementDAO = ApplicationManagementDataHolder.getInstance().getApplicationManagementDAO(); - ApplicationList applications = applicationManagementDAO.getApplications(filter); - ConnectionManagerUtil.closeConnection(); - return applications; - } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAO.java deleted file mode 100644 index 7020b9b20d..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAO.java +++ /dev/null @@ -1,65 +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; - -import org.wso2.carbon.device.application.mgt.core.dto.Application; -import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; -import org.wso2.carbon.device.application.mgt.core.dto.Filter; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public interface ApplicationManagementDAO { - - public enum DatabaseType { - - H2("H2"), - MYSQL("MySQL"), - ORACLE("Oracle"), - POSTGRESQL("PostgreSQL"), - MSSQL("Microsoft SQL Server"); - - private final String value; - private static final Map lookup = new HashMap(); - - static { - for (DatabaseType databaseType : DatabaseType.values()) { - lookup.put(databaseType.getValue(), databaseType); - } - } - - DatabaseType(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - public static DatabaseType lookup(String value) { - return lookup.get(value); - } - } - - public void createApplication(Application application) throws ApplicationManagementDAOException; - - public ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException; - -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOException.java deleted file mode 100644 index 4759d47817..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOException.java +++ /dev/null @@ -1,32 +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; - -import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException; - -public class ApplicationManagementDAOException extends ApplicationManagerException { - - public ApplicationManagementDAOException(String message, Throwable throwable) { - super(message, throwable); - } - - public ApplicationManagementDAOException(String message) { - super(message, new Exception()); - } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOFactory.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOFactory.java deleted file mode 100644 index 3ec8fdb196..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOFactory.java +++ /dev/null @@ -1,58 +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; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.application.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.device.application.mgt.core.dao.impl.GenericAppManagementDAO; -import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; - -import javax.sql.DataSource; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; - -public class ApplicationManagementDAOFactory { - - public static final String H2 = "H2"; - private ApplicationManagementDAO.DatabaseType databaseType; - private static DataSource dataSource; - - private static final Log log = LogFactory.getLog(ApplicationManagementDAOFactory.class); - - public ApplicationManagementDAOFactory(DataSourceConfig dataSourceConfig) { - dataSource = ConnectionManagerUtil.resolveDataSource(dataSourceConfig); - ConnectionManagerUtil.setDataSource(dataSource); - String databaseEngine = H2; - try { - databaseEngine = dataSource.getConnection().getMetaData().getDatabaseProductName(); - } catch (SQLException e) { - log.error("Error occurred while retrieving config.datasource connection", e); - } - this.databaseType = ApplicationManagementDAO.DatabaseType.lookup(databaseEngine); - } - - public ApplicationManagementDAO getApplicationManagementDAO(){ - switch (databaseType) { - default: - return new GenericAppManagementDAO(); - } - } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOUtil.java deleted file mode 100644 index 5b6ae3e72a..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOUtil.java +++ /dev/null @@ -1,100 +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; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONArray; -import org.json.JSONException; -import org.wso2.carbon.device.application.mgt.core.dto.Application; -import org.wso2.carbon.device.application.mgt.core.dto.ApplicationType; -import org.wso2.carbon.device.application.mgt.core.dto.Category; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ApplicationManagementDAOUtil { - - private static final Log log = LogFactory.getLog(ApplicationManagementDAOUtil.class); - - public static Application loadApplication(ResultSet rs , ResultSet rsProperties) throws SQLException, JSONException { - Application application = new Application(); - application.setId(rs.getInt("ID")); - application.setName(rs.getString("NAME")); - application.setUuid(rs.getString("UUID")); - application.setDescription(rs.getString("DESCRIPTION")); - application.setIconName(rs.getString("ICON_NAME")); - application.setBannerName(rs.getString("BANNER_NAME")); - application.setVideoName(rs.getString("VIDEO_NAME")); - application.setScreenshots(jsonArrayStringToList(rs.getString("SCREENSHOTS"))); - application.setTags(jsonArrayStringToList(rs.getString("TAGS"))); - application.setCreatedAt(rs.getDate("CREATED_AT")); - application.setModifiedAt(rs.getDate("MODIFIED_AT")); - - ApplicationType applicationType = new ApplicationType(); - applicationType.setName(rs.getString("AT_NAME")); - applicationType.setCode(rs.getString("AT_CODE")); - application.setApplicationType(applicationType); - - Map properties = new HashMap<>(); - while (rsProperties.next()){ - properties.put(rsProperties.getString("PROP_KEY"), rsProperties.getString("PROP_VAL")); - } - application.setProperties(properties); - - Category category = new Category(); - category.setName(rs.getString("CT_NAME")); - application.setCategory(category); - return application; - } - - public static void cleanupResources(PreparedStatement stmt, ResultSet rs) { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing result set", e); - } - } - if (stmt != null) { - try { - stmt.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing prepared statement", e); - } - } - } - - public static List jsonArrayStringToList(String value) throws JSONException { - JSONArray jsonArray = new JSONArray(value); - List list = new ArrayList<>(); - if (jsonArray != null) { - int len = jsonArray.length(); - for (int i = 0; i < len; i++) { - list.add(jsonArray.get(i).toString()); - } - } - return list; - } -}