From 9d5e912d11f9eb74d9ef179e875c8e9befe5d56d Mon Sep 17 00:00:00 2001 From: Chatura Dilan Date: Thu, 4 May 2017 18:21:03 +0530 Subject: [PATCH] Added MySQL DAO --- .../src/main/resources/publisher-api.yaml | 2 +- .../src/main/resources/store-api.yaml | 2 +- .../api/common/GsonMessageBodyHandler.java | 3 +- .../mgt/api/dto/StoreApplication.java | 88 --------------- .../responses/ApplicationsListResponse.java | 59 ---------- .../ApplicationManagementService.java | 11 +- .../ApplicationManagementServiceImpl.java | 27 ++--- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 2 +- .../pom.xml | 2 + .../core/components/ApplicationManager.java | 5 +- .../impl/ApplicationManagerImpl.java | 11 +- .../core/dao/ApplicationManagementDAO.java | 7 +- .../dao/ApplicationManagementDAOFactory.java | 58 ++++++++++ .../dao/ApplicationManagementDAOImpl.java | 96 ----------------- .../dao/ApplicationManagementDAOUtil.java | 39 +++++-- .../dao/impl/GenericAppManagementDAO.java | 102 ++++++++++++++++++ .../application/mgt/core/dto/Application.java | 102 ++++++++++++++++++ .../mgt/core/dto/ApplicationList.java | 44 ++++++++ .../mgt/core/dto/ApplicationType.java | 20 +++- .../application/mgt/core/dto/Category.java | 55 ++++++++++ .../application/mgt/core/dto/Pagination.java | 62 +++++++++++ .../mgt/core/dto/StoreApplication.java | 79 -------------- ...ApplicationManagementServiceComponent.java | 5 +- .../jaxrs/AnnotationExclusionStrategy.java | 35 ++++++ .../application/mgt/core/jaxrs/Exclude.java | 29 +++++ .../carbon-home/repository/conf/carbon.xml | 2 +- .../repository/conf/etc/osgi-debug.options | 2 +- .../repository/conf/tomcat/web.xml | 6 +- .../app/pages/cdmf.page.devices/devices.hbs | 4 +- .../app/pages/cdmf.page.groups/groups.hbs | 2 +- .../public/less/theme-variables.less | 2 +- .../lib/theme-wso2_1.0/less/theme-wso2.less | 36 +++---- .../carbon-home/repository/conf/carbon.xml | 2 +- .../repository/conf/etc/osgi-debug.options | 2 +- .../repository/conf/tomcat/web.xml | 6 +- .../resources/conf/certificate-config.xml | 2 +- .../src/main/resources/conf/cdm-config.xml | 2 +- .../email/templates/user-enrollment.vm | 12 +-- .../email/templates/user-registration.vm | 16 +-- .../default-enrollment-invitation.vm | 12 +-- .../email/templates/user-enrollment.vm | 12 +-- .../email/templates/user-registration.vm | 16 +-- 42 files changed, 635 insertions(+), 446 deletions(-) delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/dto/StoreApplication.java delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/responses/ApplicationsListResponse.java create 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/ApplicationManagementDAOImpl.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/GenericAppManagementDAO.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationList.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Category.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Pagination.java delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/StoreApplication.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/jaxrs/AnnotationExclusionStrategy.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/jaxrs/Exclude.java diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml index f213bd66524..e2d97583426 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml @@ -2009,7 +2009,7 @@ parameters: name: limit in: query description: | - Maximum size of resource array to return. + Maximum length of resource array to return. default: 25 type: integer diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/store-api.yaml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/store-api.yaml index eed49e831e1..43c19533b7d 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/store-api.yaml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/store-api.yaml @@ -1568,7 +1568,7 @@ parameters: name: limit in: query description: | - Maximum size of resource array to return. + Maximum length of resource array to return. default: 25 type: integer diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/GsonMessageBodyHandler.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/GsonMessageBodyHandler.java index d53e6fade2c..fccfd66b19c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/GsonMessageBodyHandler.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/common/GsonMessageBodyHandler.java @@ -21,6 +21,7 @@ package org.wso2.carbon.device.application.mgt.api.common; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import org.wso2.carbon.device.application.mgt.core.jaxrs.AnnotationExclusionStrategy; import javax.ws.rs.Consumes; import javax.ws.rs.Produces; @@ -50,7 +51,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter, Messag private Gson getGson() { if (gson == null) { - final GsonBuilder gsonBuilder = new GsonBuilder(); + final GsonBuilder gsonBuilder = new GsonBuilder().setExclusionStrategies(new AnnotationExclusionStrategy()); gson = gsonBuilder.create(); } return gson; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/dto/StoreApplication.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/dto/StoreApplication.java deleted file mode 100644 index 0eb39d13e87..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/dto/StoreApplication.java +++ /dev/null @@ -1,88 +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.api.dto; - -import org.codehaus.jackson.annotate.JsonIgnore; -import org.wso2.carbon.device.application.mgt.core.dto.Application; - -import java.util.List; - -public class StoreApplication { - - private int id; - - private String uuid; - - private String iconName; - - private String bannerName; - - private List screenshotNames; - - private Application application; - - @JsonIgnore - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getIconName() { - return iconName; - } - - public void setIconName(String iconName) { - this.iconName = iconName; - } - - public String getBannerName() { - return bannerName; - } - - public void setBannerName(String bannerName) { - this.bannerName = bannerName; - } - - public List getScreenshotNames() { - return screenshotNames; - } - - public void setScreenshotNames(List screenshotNames) { - this.screenshotNames = screenshotNames; - } - - 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.api/src/main/java/org/wso2/carbon/device/application/mgt/api/responses/ApplicationsListResponse.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/responses/ApplicationsListResponse.java deleted file mode 100644 index de927e4706b..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/responses/ApplicationsListResponse.java +++ /dev/null @@ -1,59 +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.api.responses; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.beanutils.BeanUtils; -import org.wso2.carbon.device.application.mgt.api.dto.StoreApplication; -import org.wso2.carbon.device.application.mgt.core.dto.Application; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -@XmlRootElement -public class ApplicationsListResponse { - - @ApiModelProperty(value = "List of applications types returned") - @JsonProperty("applications") - @XmlElement - private List applications; - - public ApplicationsListResponse(List applications) - throws InvocationTargetException, IllegalAccessException { - this.applications = new ArrayList<>(); - for(org.wso2.carbon.device.application.mgt.core.dto.StoreApplication applicationDTO : applications){ - StoreApplication application = new StoreApplication(); - BeanUtils.copyProperties(application, applicationDTO); - this.applications.add(application); - } - } - - 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.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementService.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementService.java index e74e42d2cac..48685d76b04 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementService.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementService.java @@ -20,12 +20,11 @@ package org.wso2.carbon.device.application.mgt.api.services; import io.swagger.annotations.*; import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse; -import org.wso2.carbon.device.application.mgt.api.responses.ApplicationsListResponse; +import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; -import javax.servlet.http.HttpServletResponse; import javax.ws.rs.*; -import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; @Api(value = "Application Management", description = "This API carries all device management related operations " + "such as get all the available devices, etc.") @@ -57,7 +56,7 @@ public interface ApplicationManagementService { @ApiResponse( code = 200, message = "OK. \n Successfully got application list.", - response = ApplicationsListResponse.class), + response = ApplicationList.class), @ApiResponse( code = 304, message = "Not Modified. \n " + @@ -67,8 +66,8 @@ public interface ApplicationManagementService { message = "Internal Server Error. \n Error occurred while getting the application list.", response = ErrorResponse.class) }) - ApplicationsListResponse getApplications(@Context final HttpServletResponse servletResponse, - @ApiParam( + Response getApplications( + @ApiParam( name = "If-Modified-Since", value = "Validates if the requested variant has not been modified since the time specified", required = false) 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 f36a54218bb..ef89c438c43 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 @@ -18,20 +18,17 @@ */ package org.wso2.carbon.device.application.mgt.api.services.impl; -import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.application.mgt.api.responses.ApplicationsListResponse; import org.wso2.carbon.device.application.mgt.core.components.ApplicationManager; -import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException; +import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; import org.wso2.carbon.device.application.mgt.core.util.ApplicationManagementUtil; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; @Produces({ "application/json"}) @Consumes({ "application/json"}) @@ -43,21 +40,15 @@ public class ApplicationManagementServiceImpl { @GET @Consumes("application/json") @Path("applications") - public ApplicationsListResponse getApplications(@Context final HttpServletResponse servletResponse) { + public Response getApplications() { ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManager(); try { - ApplicationsListResponse applicationsListResponse = - new ApplicationsListResponse(applicationManager.getApplications()); - return applicationsListResponse; + ApplicationList applications = applicationManager.getApplications(); + return Response.status(Response.Status.OK).entity(applications).build(); } catch (Exception e) { String msg = "Error occurred while getting the application list"; log.error(msg, e); - try { - servletResponse.sendError(Response.Status.NOT_FOUND.getStatusCode()); - } catch (IOException e1) { - log.error(msg, e1); - } - return null; + return Response.status(Response.Status.NOT_FOUND).build(); } } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml index afe76168696..65b5a921e7e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -17,6 +17,6 @@ http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> - + \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml index c0a0759c7d5..5a7933cd2da 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml @@ -85,6 +85,7 @@ org.json, org.xml.sax, javax.sql, + com.google.gson, javax.naming, javax.xml.bind.annotation, @@ -93,6 +94,7 @@ org.wso2.carbon.device.mgt.common.*, io.swagger.annotations.*;resolution:=optional, org.wso2.carbon.device.mgt.core.*, + org.wso2.carbon.device.mgt.core.utils.*, org.wso2.carbon.registry.indexing.*, 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 index a7360f22d2c..26b58de04ef 100644 --- 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 @@ -19,16 +19,15 @@ 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.StoreApplication; +import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagerException; -import java.util.ArrayList; import java.util.List; public interface ApplicationManager { public void createApplication(Application application) throws ApplicationManagerException; - public List getApplications() throws ApplicationManagerException; + public ApplicationList getApplications() 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 index 3a03194d3fc..80161047d6b 100644 --- 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 @@ -22,16 +22,12 @@ 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.dao.ApplicationManagementDAOException; -import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAOImpl; import org.wso2.carbon.device.application.mgt.core.dto.Application; -import org.wso2.carbon.device.application.mgt.core.dto.StoreApplication; +import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; 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.sql.SQLException; -import java.util.ArrayList; import java.util.List; public class ApplicationManagerImpl implements ApplicationManager { @@ -56,11 +52,10 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public List getApplications() throws ApplicationManagerException { + public ApplicationList getApplications() throws ApplicationManagerException { ConnectionManagerUtil.openConnection(); ApplicationManagementDAO applicationManagementDAO = ApplicationManagementDataHolder.getInstance().getApplicationManagementDAO(); - List applications = null; - applications = applicationManagementDAO.getApplications(); + ApplicationList applications = applicationManagementDAO.getApplications(); 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 index cecdf2822f3..9ab39c67ff3 100644 --- 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 @@ -18,9 +18,8 @@ */ package org.wso2.carbon.device.application.mgt.core.dao; -import org.apache.axis2.databinding.types.Day; import org.wso2.carbon.device.application.mgt.core.dto.Application; -import org.wso2.carbon.device.application.mgt.core.dto.StoreApplication; +import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; import java.util.HashMap; import java.util.List; @@ -58,8 +57,8 @@ public interface ApplicationManagementDAO { } } - public void createApplication(StoreApplication application) throws ApplicationManagementDAOException; + public void createApplication(Application application) throws ApplicationManagementDAOException; - public List getApplications() throws ApplicationManagementDAOException; + public ApplicationList getApplications() 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/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 new file mode 100644 index 00000000000..3ec8fdb1960 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOFactory.java @@ -0,0 +1,58 @@ +/* + * 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/ApplicationManagementDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOImpl.java deleted file mode 100644 index 4c69408e757..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationManagementDAOImpl.java +++ /dev/null @@ -1,96 +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.JSONException; -import org.wso2.carbon.device.application.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.device.application.mgt.core.dto.StoreApplication; -import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; -import org.wso2.carbon.device.application.mgt.core.dto.Application; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -public class ApplicationManagementDAOImpl implements ApplicationManagementDAO { - - private DatabaseType databaseType; - private static DataSource dataSource; - - private static final String TABLE_PREFIX = "APPM"; - - private static final Log log = LogFactory.getLog(ApplicationManagementDAOImpl.class); - - public ApplicationManagementDAOImpl(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); - } - - @Override - public void createApplication(StoreApplication application) throws ApplicationManagementDAOException { - - } - - @Override - public List getApplications() throws ApplicationManagementDAOException { - - Connection conn = null; - PreparedStatement stmt = null; - ResultSet rs = null; - String sql = null; - List applications; - - try { - conn = ConnectionManagerUtil.getCurrentConnection().get(); - switch (databaseType) { - case H2: - case MYSQL: - sql = "SELECT * FROM APPM_STORE_APPLICATION"; - } - - stmt = conn.prepareStatement(sql); - rs = stmt.executeQuery(); - applications = new ArrayList<>(); - while (rs.next()) { - applications.add(ApplicationManagementDAOUtil.loadApplication(rs)); - } - - } catch (SQLException e) { - throw new ApplicationManagementDAOException("Error occurred while getting application List", e); - } catch (JSONException e) { - throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e); - } finally { - ApplicationManagementDAOUtil.cleanupResources(stmt, rs); - } - 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/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 index 7baa4380a34..5b6ae3e72af 100644 --- 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 @@ -24,26 +24,49 @@ 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.StoreApplication; +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 StoreApplication loadApplication(ResultSet rs) throws SQLException, JSONException { + 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(); - StoreApplication storeApplication = new StoreApplication(); - storeApplication.setUuid(rs.getString("UUID")); - storeApplication.setIconName(rs.getString("ICON_NAME")); - storeApplication.setBannerName(rs.getString("BANNER_NAME")); - storeApplication.setScreenshotNames(jsonArrayStringToList(rs.getString("SCREENSHOTS"))); - return storeApplication; + 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) { 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 new file mode 100644 index 00000000000..01c84551799 --- /dev/null +++ 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 @@ -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.dao.impl; + +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.dto.Application; +import org.wso2.carbon.device.application.mgt.core.dto.ApplicationList; +import org.wso2.carbon.device.application.mgt.core.dto.Pagination; +import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class GenericAppManagementDAO implements ApplicationManagementDAO { + + @Override + public void createApplication(Application application) throws ApplicationManagementDAOException { + + } + + @Override + public ApplicationList getApplications() throws ApplicationManagementDAOException { + + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; + String sql = null; + ApplicationList applicationList = new ApplicationList(); + List applications = new ArrayList<>(); + Pagination pagination = new Pagination(); + + try { + + 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 " + + "FROM APPM_APPLICATION AS AP " + + "INNER JOIN APPM_APPLICATION_TYPE AS AT ON AP.APPLICATION_TYPE_ID = AT.ID " + + "INNER JOIN APPM_APPLICATION_CATEGORY AS CT ON AP.CATEGORY_ID = CT.ID;"; + + stmt = conn.prepareStatement(sql); + rs = stmt.executeQuery(); + + int length = 0; + sql = "SELECT FOUND_ROWS() AS COUNT;"; + stmt = conn.prepareStatement(sql); + ResultSet rsCount = stmt.executeQuery(); + if(rsCount.next()){ + pagination.setCount(rsCount.getInt("COUNT")); + } + + while (rs.next()) { + + //Getting properties + sql = "SELECT * FROM APPM_APPLICATION_PROPERTIES WHERE APPLICATION_ID=?"; + stmt = conn.prepareStatement(sql); + stmt.setInt(1, rs.getInt("ID")); + ResultSet rsProperties = stmt.executeQuery(); + + applications.add(ApplicationManagementDAOUtil.loadApplication(rs, rsProperties)); + length++; + } + + pagination.setLength(length); + + applicationList.setApplications(applications); + applicationList.setPagination(pagination); + + } catch (SQLException e) { + throw new ApplicationManagementDAOException("Error occurred while getting application List", e); + } catch (JSONException e) { + throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e); + } finally { + ApplicationManagementDAOUtil.cleanupResources(stmt, rs); + } + return applicationList; + + } +} 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 3fa3e4846ff..56b45fa45b8 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 @@ -18,16 +18,46 @@ */ package org.wso2.carbon.device.application.mgt.core.dto; + +import org.wso2.carbon.device.application.mgt.core.jaxrs.Exclude; + +import java.util.Date; +import java.util.List; import java.util.Map; public class Application { + @Exclude private int id; + private String name; + + private String uuid; + private String description; + + private String iconName; + + private String bannerName; + + private String videoName; + + private List screenshots; + + private List tags; + + private Date createdAt; + + private Date modifiedAt; + private ApplicationType applicationType; + + private Category category; + private Map properties; + public Application() { + } public int getId() { return id; @@ -45,6 +75,14 @@ public class Application { this.name = name; } + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + public String getDescription() { return description; } @@ -53,6 +91,62 @@ public class Application { this.description = description; } + public String getIconName() { + return iconName; + } + + public void setIconName(String iconName) { + this.iconName = iconName; + } + + public String getBannerName() { + return bannerName; + } + + public void setBannerName(String bannerName) { + this.bannerName = bannerName; + } + + public String getVideoName() { + return videoName; + } + + public void setVideoName(String videoName) { + this.videoName = videoName; + } + + public List getScreenshots() { + return screenshots; + } + + public void setScreenshots(List screenshots) { + this.screenshots = screenshots; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + 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 ApplicationType getApplicationType() { return applicationType; } @@ -61,6 +155,14 @@ public class Application { this.applicationType = applicationType; } + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + public Map getProperties() { return 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/ApplicationList.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationList.java new file mode 100644 index 00000000000..c089cbb3881 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationList.java @@ -0,0 +1,44 @@ +/* + * 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.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/dto/ApplicationType.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationType.java index 153f9da89fc..c6a9bb25ee3 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationType.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/ApplicationType.java @@ -18,11 +18,18 @@ */ package org.wso2.carbon.device.application.mgt.core.dto; +import org.wso2.carbon.device.application.mgt.core.jaxrs.Exclude; + public class ApplicationType { - protected int id; - protected String name; - protected String code; + @Exclude + private int id; + + private String name; + + private String code; + + private String parameters; public int getId() { return id; @@ -48,4 +55,11 @@ public class ApplicationType { this.code = code; } + public String getParameters() { + return parameters; + } + + public void setParameters(String parameters) { + this.parameters = parameters; + } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Category.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Category.java new file mode 100644 index 00000000000..4d79f071c7e --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Category.java @@ -0,0 +1,55 @@ +/* + * 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; + +public class Category { + + @Exclude + private int id; + + private String name; + + private String description; + + 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; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Pagination.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Pagination.java new file mode 100644 index 00000000000..34146acfe2f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/Pagination.java @@ -0,0 +1,62 @@ +/* + * 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 Pagination { + + private int offset; + + private int limit; + + private int length; + + private int count; + + public int getOffset() { + return offset; + } + + public void setOffset(int offset) { + this.offset = offset; + } + + public int getLimit() { + return limit; + } + + public void setLimit(int limit) { + this.limit = limit; + } + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length = length; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/StoreApplication.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/StoreApplication.java deleted file mode 100644 index 6c1ed83326a..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dto/StoreApplication.java +++ /dev/null @@ -1,79 +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.dto; - -import java.util.List; - -public class StoreApplication { - - private int id; - private String uuid; - private String iconName; - private String bannerName; - private List screenshotNames; - private Application application; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getIconName() { - return iconName; - } - - public void setIconName(String iconName) { - this.iconName = iconName; - } - - public String getBannerName() { - return bannerName; - } - - public void setBannerName(String bannerName) { - this.bannerName = bannerName; - } - - public List getScreenshotNames() { - return screenshotNames; - } - - public void setScreenshotNames(List screenshotNames) { - this.screenshotNames = screenshotNames; - } - - 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/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 daf29e8be15..a03667b425b 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 @@ -27,7 +27,7 @@ import org.wso2.carbon.device.application.mgt.core.components.impl.ApplicationMa 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.ApplicationManagementDAOImpl; +import org.wso2.carbon.device.application.mgt.core.dao.ApplicationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import javax.naming.NamingException; @@ -55,7 +55,8 @@ public class ApplicationManagementServiceComponent { DataSourceConfig dataSourceConfig = ApplicationConfigurationManager.getInstance() .getApplicationManagerConfiguration().getApplicationManagerRepository().getDataSourceConfig(); - ApplicationManagementDAO applicationManagementDAO = new ApplicationManagementDAOImpl(dataSourceConfig); + ApplicationManagementDAO applicationManagementDAO = new ApplicationManagementDAOFactory(dataSourceConfig) + .getApplicationManagementDAO(); ApplicationManagementDataHolder.getInstance() .setApplicationManagementDAO(applicationManagementDAO); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/jaxrs/AnnotationExclusionStrategy.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/jaxrs/AnnotationExclusionStrategy.java new file mode 100644 index 00000000000..550f1e4cede --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/jaxrs/AnnotationExclusionStrategy.java @@ -0,0 +1,35 @@ +/* + * 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.jaxrs; + +import com.google.gson.ExclusionStrategy; +import com.google.gson.FieldAttributes; + +public class AnnotationExclusionStrategy implements ExclusionStrategy { + + @Override + public boolean shouldSkipField(FieldAttributes f) { + return f.getAnnotation(Exclude.class) != null; + } + + @Override + public boolean shouldSkipClass(Class clazz) { + return false; + } +} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/jaxrs/Exclude.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/jaxrs/Exclude.java new file mode 100644 index 00000000000..af9c3c794d1 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/jaxrs/Exclude.java @@ -0,0 +1,29 @@ +/* + * 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.jaxrs; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface Exclude { +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/carbon.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/carbon.xml index ca5863d18d9..97a1658aa34 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/carbon.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/carbon.xml @@ -468,7 +468,7 @@ --> 100 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options index ba8e3c6c20f..80e56b83f2f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options @@ -62,7 +62,7 @@ org.eclipse.osgi/defaultprofile/logfilename = # requested. org.eclipse.osgi/defaultprofile/logsynchronously = false -# Specify the size of the default profile implementation log buffer. +# Specify the length of the default profile implementation log buffer. org.eclipse.osgi/defaultprofile/buffersize = 256 #### Monitoring settings diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/tomcat/web.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/tomcat/web.xml index d4241ef741a..b9f1e4a3e91 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/tomcat/web.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/carbon-home/repository/conf/tomcat/web.xml @@ -47,7 +47,7 @@ - + @@ -56,7 +56,7 @@ - + @@ -67,7 +67,7 @@ - + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs index 059aa68899d..bacf924066c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs @@ -383,7 +383,7 @@