diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleasesDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleasesDAO.java new file mode 100644 index 0000000000..b624467839 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleasesDAO.java @@ -0,0 +1,23 @@ +/* + * 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 ApplicationReleasesDAO { + +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationsDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationsDAO.java new file mode 100644 index 0000000000..3353b5cebb --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationsDAO.java @@ -0,0 +1,36 @@ +/* + * 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.dao.common.ApplicationManagementDAOException; +import org.wso2.carbon.device.application.mgt.core.dto.Application; +import org.wso2.carbon.device.application.mgt.core.dto.Filter; +import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList; + +public interface ApplicationsDAO { + + Application createApplication(Application application) throws ApplicationManagementDAOException; + + ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException; + + Application editApplication(Application application) throws ApplicationManagementDAOException; + + void deleteApplication (Application application)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/CategoriesDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/CategoriesDAO.java new file mode 100644 index 0000000000..87ef7c6f8f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/CategoriesDAO.java @@ -0,0 +1,22 @@ +/* + * 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 CategoriesDAO { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/CommentsDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/CommentsDAO.java new file mode 100644 index 0000000000..98e97614ad --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/CommentsDAO.java @@ -0,0 +1,22 @@ +/* + * 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 CommentsDAO { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/LifecycleStatesDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/LifecycleStatesDAO.java new file mode 100644 index 0000000000..94048146bc --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/LifecycleStatesDAO.java @@ -0,0 +1,23 @@ +/* + * 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 LifecycleStatesDAO { + +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/PlatformsDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/PlatformsDAO.java new file mode 100644 index 0000000000..381ff20f3a --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/PlatformsDAO.java @@ -0,0 +1,23 @@ +/* + * 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 PlatformsDAO { + +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ResourceTypesDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ResourceTypesDAO.java new file mode 100644 index 0000000000..901619c524 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ResourceTypesDAO.java @@ -0,0 +1,22 @@ +/* + * 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 ResourceTypesDAO { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionsDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionsDAO.java new file mode 100644 index 0000000000..b2fcdaa8b4 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionsDAO.java @@ -0,0 +1,22 @@ +/* + * 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 SubscriptionsDAO { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/VisibilitiesDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/VisibilitiesDAO.java new file mode 100644 index 0000000000..67c8d76389 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/VisibilitiesDAO.java @@ -0,0 +1,22 @@ +/* + * 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 VisibilitiesDAO { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAO.java new file mode 100644 index 0000000000..4962a481ad --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAO.java @@ -0,0 +1,28 @@ +/* + * 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.common; + +import org.apache.abdera.model.Categories; +import org.wso2.carbon.device.application.mgt.core.dao.*; +import org.wso2.carbon.device.application.mgt.core.dto.LifecycleState; + +public interface ApplicationManagementDAO extends ApplicationReleasesDAO, ApplicationsDAO, CategoriesDAO, CommentsDAO, + LifecycleStatesDAO, PlatformsDAO, ResourceTypesDAO, SubscriptionsDAO, VisibilitiesDAO { + +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAOException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAOException.java new file mode 100644 index 0000000000..b4401ae410 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAOException.java @@ -0,0 +1,32 @@ +/* + * 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.common; + +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/common/ApplicationManagementDAOFactory.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAOFactory.java new file mode 100644 index 0000000000..fca7134e50 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAOFactory.java @@ -0,0 +1,57 @@ +/* + * 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.common; + +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 org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil.DatabaseType; + +import javax.sql.DataSource; +import java.sql.SQLException; + +public class ApplicationManagementDAOFactory { + + public static final String H2 = "H2"; + private 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 = 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/common/ApplicationManagementDAOUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAOUtil.java new file mode 100644 index 0000000000..863549f7ac --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAOUtil.java @@ -0,0 +1,107 @@ +/* + * 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.common; + +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.Platform; +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, ResultSet rsTags) + 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.setCreatedAt(rs.getDate("CREATED_AT")); + application.setModifiedAt(rs.getDate("MODIFIED_AT")); + + Platform platform = new Platform(); + platform.setName(rs.getString("APL_NAME")); + platform.setCode(rs.getString("APL_IDENTIFIER")); + application.setPlatform(platform); + + Map properties = new HashMap<>(); + while (rsProperties.next()) { + properties.put(rsProperties.getString("PROP_KEY"), rsProperties.getString("PROP_VAL")); + } + application.setProperties(properties); + + List tags = new ArrayList<>(); + while ((rsTags.next())){ + tags.add(rsTags.getString("NAME")); + } + application.setTags(tags); + + Category category = new Category(); + category.setName(rs.getString("CAT_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; + } +} 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/GenericAppManagementDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/GenericAppManagementDAO.java index bf2b5b6744..65416d12ce 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/GenericAppManagementDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/GenericAppManagementDAO.java @@ -18,12 +18,14 @@ */ package org.wso2.carbon.device.application.mgt.core.dao.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.json.JSONException; -import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAO; -import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAOException; -import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAOUtil; +import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAO; +import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOException; +import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOUtil; 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.lists.ApplicationList; import org.wso2.carbon.device.application.mgt.core.dto.Filter; import org.wso2.carbon.device.application.mgt.core.dto.Pagination; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; @@ -37,14 +39,21 @@ import java.util.List; public class GenericAppManagementDAO implements ApplicationManagementDAO { - @Override - public void createApplication(Application application) throws ApplicationManagementDAOException { + private static final Log log = LogFactory.getLog(ApplicationManagementDAO.class); + @Override + public Application createApplication(Application application) throws ApplicationManagementDAOException { + return null; } @Override public ApplicationList getApplications(Filter filter) throws ApplicationManagementDAOException { + if(log.isDebugEnabled()){ + log.debug("Getting application data from the database"); + log.debug(String.format("Filter: limit=%s, offset=%", filter.getLimit(), filter.getOffset())); + } + Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; @@ -64,12 +73,14 @@ public class GenericAppManagementDAO implements ApplicationManagementDAO { conn = ConnectionManagerUtil.getCurrentConnection().get(); - sql += "SELECT SQL_CALC_FOUND_ROWS AP.*, AT.NAME AS AT_NAME, AT.CODE AS AT_CODE, CT.NAME AS CT_NAME "; - sql += "FROM APPM_APPLICATION AS AP "; - sql += "INNER JOIN APPM_APPLICATION_TYPE AS AT ON AP.APPLICATION_TYPE_ID = AT.ID "; - sql += "INNER JOIN APPM_APPLICATION_CATEGORY AS CT ON AP.CATEGORY_ID = CT.ID "; + sql += "SELECT SQL_CALC_FOUND_ROWS APP.*, APL.NAME AS APL_NAME, APL.IDENTIFIER AS APL_IDENTIFIER," + + " CAT.NAME AS CAT_NAME "; + sql += "FROM APPM_APPLICATION AS APP "; + sql += "INNER JOIN APPM_PLATFORM_APPLICATION_MAPPING AS APM ON APP.PLATFORM_APPLICATION_MAPPING_ID = APM.ID "; + sql += "INNER JOIN APPM_PLATFORM AS APL ON APM.PLATFORM_ID = APL.ID "; + sql += "INNER JOIN APPM_APPLICATION_CATEGORY AS CAT ON APP.APPLICATION_CATEGORY_ID = CAT.ID "; if (filter.getSearchQuery() != null || "".equals(filter.getSearchQuery())) { - sql += "WHERE AP.NAME LIKE ? "; + sql += "WHERE APP.NAME LIKE ? "; } sql += "LIMIT ? "; sql += "OFFSET ?;"; @@ -95,12 +106,18 @@ public class GenericAppManagementDAO implements ApplicationManagementDAO { while (rs.next()) { //Getting properties - sql = "SELECT * FROM APPM_APPLICATION_PROPERTIES WHERE APPLICATION_ID=?"; + sql = "SELECT * FROM APPM_APPLICATION_PROPERTY WHERE APPLICATION_ID=?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, rs.getInt("ID")); ResultSet rsProperties = stmt.executeQuery(); - applications.add(ApplicationManagementDAOUtil.loadApplication(rs, rsProperties)); + //Getting tags + sql = "SELECT * FROM APPM_APPLICATION_TAG WHERE APPLICATION_ID=?"; + stmt = conn.prepareStatement(sql); + stmt.setInt(1, rs.getInt("ID")); + ResultSet rsTags = stmt.executeQuery(); + + applications.add(ApplicationManagementDAOUtil.loadApplication(rs, rsProperties, rsTags)); length++; } @@ -119,4 +136,14 @@ public class GenericAppManagementDAO implements ApplicationManagementDAO { return applicationList; } + + @Override + public Application editApplication(Application application) throws ApplicationManagementDAOException { + return null; + } + + @Override + public void deleteApplication(Application application) 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/dto/Application.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Application.java index 56b45fa45b..d7dd21cf08 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Application.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Application.java @@ -30,9 +30,11 @@ public class Application { @Exclude private int id; + private String uuid; + private String name; - private String uuid; + private String shortDescription; private String description; @@ -46,18 +48,22 @@ public class Application { private List tags; - private Date createdAt; - - private Date modifiedAt; + private List subscriptions; - private ApplicationType applicationType; + private Platform platform; private Category category; private Map properties; - public Application() { - } + private String createdBy; + + private Date createdAt; + + private Date modifiedAt; + + private boolean published; + public int getId() { return id; @@ -67,6 +73,14 @@ public class Application { this.id = id; } + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + public String getName() { return name; } @@ -75,12 +89,12 @@ public class Application { this.name = name; } - public String getUuid() { - return uuid; + public String getShortDescription() { + return shortDescription; } - public void setUuid(String uuid) { - this.uuid = uuid; + public void setShortDescription(String shortDescription) { + this.shortDescription = shortDescription; } public String getDescription() { @@ -131,28 +145,20 @@ public class Application { this.tags = tags; } - public Date getCreatedAt() { - return createdAt; + public List getSubscriptions() { + return subscriptions; } - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; + public void setSubscriptions(List subscriptions) { + this.subscriptions = subscriptions; } - public Date getModifiedAt() { - return modifiedAt; + public Platform getPlatform() { + return platform; } - public void setModifiedAt(Date modifiedAt) { - this.modifiedAt = modifiedAt; - } - - public ApplicationType getApplicationType() { - return applicationType; - } - - public void setApplicationType(ApplicationType applicationType) { - this.applicationType = applicationType; + public void setPlatform(Platform platform) { + this.platform = platform; } public Category getCategory() { @@ -170,4 +176,36 @@ public class Application { public void setProperties(Map properties) { this.properties = properties; } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getModifiedAt() { + return modifiedAt; + } + + public void setModifiedAt(Date modifiedAt) { + this.modifiedAt = modifiedAt; + } + + public boolean isPublished() { + return published; + } + + public void setPublished(boolean published) { + this.published = published; + } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationRelease.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationRelease.java new file mode 100644 index 0000000000..d328587fa5 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationRelease.java @@ -0,0 +1,149 @@ +/* + * 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.dto; + +import java.util.Date; +import java.util.Map; + +public class ApplicationRelease { + + private enum ReleaseChannel { + PRODUCTION, ALPHA, BETA + } + + private int id; + + private int versionId; + + private String versionName; + + private String resource; + + private ReleaseChannel releaseChannel; + + private String releaseDetails; + + private Date createdAt; + + private Application application; + + private LifecycleState lifecycleState; + + private Date lifecycleStateModifiedAt; + + private String lifecycleStateModifiedBy; + + private Map properties; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getVersionId() { + return versionId; + } + + public void setVersionId(int versionId) { + this.versionId = versionId; + } + + public String getVersionName() { + return versionName; + } + + public void setVersionName(String versionName) { + this.versionName = versionName; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public ReleaseChannel getReleaseChannel() { + return releaseChannel; + } + + public void setReleaseChannel(ReleaseChannel releaseChannel) { + this.releaseChannel = releaseChannel; + } + + public String getReleaseDetails() { + return releaseDetails; + } + + public void setReleaseDetails(String releaseDetails) { + this.releaseDetails = releaseDetails; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Application getApplication() { + return application; + } + + public void setApplication(Application application) { + this.application = application; + } + + public LifecycleState getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public Date getLifecycleStateModifiedAt() { + return lifecycleStateModifiedAt; + } + + public void setLifecycleStateModifiedAt(Date lifecycleStateModifiedAt) { + this.lifecycleStateModifiedAt = lifecycleStateModifiedAt; + } + + public String getLifecycleStateModifiedBy() { + return lifecycleStateModifiedBy; + } + + public void setLifecycleStateModifiedBy(String lifecycleStateModifiedBy) { + this.lifecycleStateModifiedBy = lifecycleStateModifiedBy; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Comment.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Comment.java new file mode 100644 index 0000000000..311c8f18cc --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Comment.java @@ -0,0 +1,102 @@ +/* + * 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.dto; + +public class Comment { + + private String id; + + private String comment; + + private int rating; + + private Comment parent; + + private String createdBy; + + private String createdAt; + + private String modifiedAt; + + private Application application; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public int getRating() { + return rating; + } + + public void setRating(int rating) { + this.rating = rating; + } + + public Comment getParent() { + return parent; + } + + public void setParent(Comment parent) { + this.parent = parent; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public String getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(String createdAt) { + this.createdAt = createdAt; + } + + public String getModifiedAt() { + return modifiedAt; + } + + public void setModifiedAt(String modifiedAt) { + this.modifiedAt = modifiedAt; + } + + public Application getApplication() { + return application; + } + + public void setApplication(Application application) { + this.application = application; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Filter.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Filter.java index 95b5c8f183..575a74d723 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Filter.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Filter.java @@ -22,6 +22,10 @@ import java.util.Map; public class Filter { + public enum SortingOrder { + ASC, DESC + } + private int limit; private int offset; @@ -32,6 +36,10 @@ public class Filter { private String searchQuery; + private SortingOrder sortingOrder; + + private String sortBy; + public int getLimit() { return limit; } @@ -72,10 +80,28 @@ public class Filter { this.searchQuery = searchQuery; } + public SortingOrder getSortingOrder() { + return sortingOrder; + } + + public void setSortingOrder(SortingOrder sortingOrder) { + this.sortingOrder = sortingOrder; + } + + public String getSortBy() { + return sortBy; + } + + public void setSortBy(String sortBy) { + this.sortBy = sortBy; + } + public boolean hasCondition() { if (filterProperties != null || searchQuery != null || filter != null) { return true; } return false; } + + } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/LifecycleState.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/LifecycleState.java new file mode 100644 index 0000000000..d4899b3682 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/LifecycleState.java @@ -0,0 +1,52 @@ +/* + * 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.dto; + +public class LifecycleState { + + 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; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Platform.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Platform.java new file mode 100644 index 0000000000..da17697675 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Platform.java @@ -0,0 +1,107 @@ +/* + * 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.dto; + +import org.wso2.carbon.device.application.mgt.core.jaxrs.Exclude; + +import java.util.List; + +public class Platform { + + @Exclude + private int id; + + private String name; + + private String description; + + private String code; + + private String iconName; + + private List tags; + + private String properties; + + private List applications; + + public int getId() { + return id; + } + + public void setId(int 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 String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getIconName() { + return iconName; + } + + public void setIconName(String iconName) { + this.iconName = iconName; + } + + public String getProperties() { + return properties; + } + + public void setProperties(String properties) { + this.properties = properties; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public List getApplications() { + return applications; + } + + public void setApplications(List applications) { + this.applications = applications; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ResourceType.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ResourceType.java new file mode 100644 index 0000000000..29c27dbd32 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ResourceType.java @@ -0,0 +1,52 @@ +/* + * 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.dto; + +public class ResourceType { + + 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; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Subscription.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Subscription.java new file mode 100644 index 0000000000..2874f9f8f5 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Subscription.java @@ -0,0 +1,74 @@ +/* + * 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.dto; + +import java.util.Date; + +public class Subscription { + + private ResourceType type; + + private String value; + + private Date createdAt; + + private Application application; + + private ApplicationRelease applicationRelease; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public ResourceType getType() { + return type; + } + + public void setType(ResourceType type) { + this.type = type; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Application getApplication() { + return application; + } + + public void setApplication(Application application) { + this.application = application; + } + + public ApplicationRelease getApplicationRelease() { + return applicationRelease; + } + + public void setApplicationRelease(ApplicationRelease applicationRelease) { + this.applicationRelease = applicationRelease; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Visibility.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Visibility.java new file mode 100644 index 0000000000..9e1364dd11 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Visibility.java @@ -0,0 +1,64 @@ +/* + * 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.dto; + +import java.util.Date; + +public class Visibility { + + private ResourceType type; + + private String value; + + private Application application; + + private ApplicationRelease applicationRelease; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public ResourceType getType() { + return type; + } + + public void setType(ResourceType type) { + this.type = type; + } + + public Application getApplication() { + return application; + } + + public void setApplication(Application application) { + this.application = application; + } + + public ApplicationRelease getApplicationRelease() { + return applicationRelease; + } + + public void setApplicationRelease(ApplicationRelease applicationRelease) { + this.applicationRelease = applicationRelease; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/lists/ApplicationList.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/lists/ApplicationList.java new file mode 100644 index 0000000000..fe3d1898ad --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/lists/ApplicationList.java @@ -0,0 +1,47 @@ +/* + * 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.dto.lists; + +import org.wso2.carbon.device.application.mgt.core.dto.Application; +import org.wso2.carbon.device.application.mgt.core.dto.Pagination; + +import java.util.List; + +public class ApplicationList { + + private List applications; + + private Pagination pagination; + + public List getApplications() { + return applications; + } + + public void setApplications(List applications) { + this.applications = applications; + } + + public Pagination getPagination() { + return pagination; + } + + public void setPagination(Pagination pagination) { + this.pagination = pagination; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementDataHolder.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementDataHolder.java index 82f629b533..a1bb0b6988 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementDataHolder.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementDataHolder.java @@ -18,7 +18,7 @@ */ package org.wso2.carbon.device.application.mgt.core.internal; -import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAO; +import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAO; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; public class ApplicationManagementDataHolder { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java index a03667b425..5501e90fd2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java @@ -22,18 +22,18 @@ import org.apache.commons.logging.Log; import org.osgi.service.component.ComponentContext; import org.osgi.framework.BundleContext; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.application.mgt.core.components.ApplicationManager; -import org.wso2.carbon.device.application.mgt.core.components.impl.ApplicationManagerImpl; +import org.wso2.carbon.device.application.mgt.core.services.ApplicationManagementService; +import org.wso2.carbon.device.application.mgt.core.services.impl.ApplicationManagementServiceImpl; import org.wso2.carbon.device.application.mgt.core.config.ApplicationConfigurationManager; import org.wso2.carbon.device.application.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAO; -import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAOFactory; +import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAO; +import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import javax.naming.NamingException; /** - * @scr.component name="org.wso2.carbon.application.mgt" immediate="true" + * @scr.component name="org.wso2.carbon.application.mgt.service" immediate="true" * @scr.reference name="org.wso2.carbon.device.manager" * interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService" * cardinality="1..1" @@ -49,8 +49,8 @@ public class ApplicationManagementServiceComponent { protected void activate(ComponentContext componentContext) throws NamingException { BundleContext bundleContext = componentContext.getBundleContext(); - bundleContext.registerService(ApplicationManager.class.getName(), - ApplicationManagerImpl.getInstance(), null); + bundleContext.registerService(ApplicationManagementService.class.getName(), + ApplicationManagementServiceImpl.getInstance(), null); DataSourceConfig dataSourceConfig = ApplicationConfigurationManager.getInstance() @@ -73,14 +73,14 @@ public class ApplicationManagementServiceComponent { protected void setDeviceManagementService(DeviceManagementProviderService deviceManagementProviderService) { if (log.isDebugEnabled()) { - log.debug("Setting Application Management OSGI Service"); + log.debug("Setting Application Management OSGI Manager"); } ApplicationManagementDataHolder.getInstance().setDeviceManagementService(deviceManagementProviderService); } protected void unsetDeviceManagementService(DeviceManagementProviderService deviceManagementProviderService) { if (log.isDebugEnabled()) { - log.debug("Removing Application Management OSGI Service"); + log.debug("Removing Application Management OSGI Manager"); } ApplicationManagementDataHolder.getInstance().setDeviceManagementService(null); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/ApplicationManagementService.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/ApplicationManagementService.java new file mode 100644 index 0000000000..c6e890a7c2 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/ApplicationManagementService.java @@ -0,0 +1,30 @@ +/* + * 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.services; + +import org.wso2.carbon.device.application.mgt.core.dto.Application; +import org.wso2.carbon.device.application.mgt.core.dto.lists.ApplicationList; +import org.wso2.carbon.device.application.mgt.core.dto.Filter; +import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException; + +public interface ApplicationManagementService extends ApplicationReleaseManager, ApplicationManager, CategoryManager, + CommentsManager, LifecycleStateManager, PlatformManager, ResourceTypeManager, SubscriptionManager, + VisibilityManager { + +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/ApplicationManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/ApplicationManager.java new file mode 100644 index 0000000000..dbb57801b1 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/ApplicationManager.java @@ -0,0 +1,31 @@ +/* + * 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.services; + +import org.wso2.carbon.device.application.mgt.core.dto.Application; +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.exception.ApplicationManagerException; + +public interface ApplicationManager { + + void createApplication(Application application) throws ApplicationManagerException; + + 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/services/ApplicationReleaseManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/ApplicationReleaseManager.java new file mode 100644 index 0000000000..5d30f29fa6 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/ApplicationReleaseManager.java @@ -0,0 +1,22 @@ +/* + * 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.services; + +public interface ApplicationReleaseManager { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/CategoryManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/CategoryManager.java new file mode 100644 index 0000000000..08621f19fe --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/CategoryManager.java @@ -0,0 +1,22 @@ +/* + * 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.services; + +public interface CategoryManager { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/CommentsManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/CommentsManager.java new file mode 100644 index 0000000000..d0c04cfc7c --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/CommentsManager.java @@ -0,0 +1,22 @@ +/* + * 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.services; + +public interface CommentsManager { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/LifecycleStateManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/LifecycleStateManager.java new file mode 100644 index 0000000000..a09d7475b4 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/LifecycleStateManager.java @@ -0,0 +1,23 @@ +/* + * 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.services; + +public interface LifecycleStateManager { + +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/PlatformManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/PlatformManager.java new file mode 100644 index 0000000000..9b90516d56 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/PlatformManager.java @@ -0,0 +1,22 @@ +/* + * 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.services; + +public interface PlatformManager { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/ResourceTypeManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/ResourceTypeManager.java new file mode 100644 index 0000000000..582e2b30b7 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/ResourceTypeManager.java @@ -0,0 +1,22 @@ +/* + * 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.services; + +public interface ResourceTypeManager { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/SubscriptionManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/SubscriptionManager.java new file mode 100644 index 0000000000..074292d031 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/SubscriptionManager.java @@ -0,0 +1,22 @@ +/* + * 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.services; + +public interface SubscriptionManager { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/VisibilityManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/VisibilityManager.java new file mode 100644 index 0000000000..a83435cec2 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/VisibilityManager.java @@ -0,0 +1,22 @@ +/* + * 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.services; + +public interface VisibilityManager { +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/impl/ApplicationManagementServiceImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/impl/ApplicationManagementServiceImpl.java new file mode 100644 index 0000000000..a4ab9f7e20 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/services/impl/ApplicationManagementServiceImpl.java @@ -0,0 +1,61 @@ +/* + * 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.services.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.application.mgt.core.services.ApplicationManagementService; +import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAO; +import org.wso2.carbon.device.application.mgt.core.dto.Application; +import org.wso2.carbon.device.application.mgt.core.dto.lists.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; + +public class ApplicationManagementServiceImpl implements ApplicationManagementService { + + private static final Log log = LogFactory.getLog(ApplicationManagementServiceImpl.class); + + + private static ApplicationManagementServiceImpl applicationManager = new ApplicationManagementServiceImpl(); + + private ApplicationManagementServiceImpl() { + + } + + public static ApplicationManagementServiceImpl 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/util/ApplicationManagementUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java index 103cf97c7d..55626599b2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.application.mgt.core.components.ApplicationManager; +import org.wso2.carbon.device.application.mgt.core.services.ApplicationManagementService; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException; import javax.xml.XMLConstants; @@ -35,10 +35,10 @@ public class ApplicationManagementUtil { private static Log log = LogFactory.getLog(ApplicationManagementUtil.class); - public static ApplicationManager getApplicationManager() { + public static ApplicationManagementService getApplicationManagementService() { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ApplicationManager applicationManager = - (ApplicationManager) CarbonContext.getThreadLocalCarbonContext().getOSGiService(ApplicationManager.class, null); + ApplicationManagementService applicationManager = + (ApplicationManagementService) CarbonContext.getThreadLocalCarbonContext().getOSGiService(ApplicationManagementService.class, null); if (applicationManager == null) { String msg = "Application Management provider service has not initialized."; log.error(msg); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ConnectionManagerUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ConnectionManagerUtil.java index 1bac612e71..dd0718cfbf 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ConnectionManagerUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ConnectionManagerUtil.java @@ -29,8 +29,10 @@ import javax.naming.InitialContext; import javax.sql.DataSource; import java.sql.Connection; import java.sql.SQLException; +import java.util.HashMap; import java.util.Hashtable; import java.util.List; +import java.util.Map; public class ConnectionManagerUtil { @@ -40,6 +42,36 @@ public class ConnectionManagerUtil { CONNECTION_NOT_BORROWED, CONNECTION_BORROWED, CONNECTION_CLOSED } + 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); + } + } + private static final ThreadLocal currentConnection = new ThreadLocal<>(); private static ThreadLocal currentTxState = new ThreadLocal<>(); private static DataSource dataSource;