From 83aea1fd019c0b053d677a631983874ff91f073b Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Sun, 8 Jan 2017 11:45:46 +0530 Subject: [PATCH 01/12] Merge branch 'master' of https://github.com/wso2/carbon-device-mgt into merge-master # Conflicts: # components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml # components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml # components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml # components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml # components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java # components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/ExtendedFileProtocolIteratorFactory.java # components/apimgt-extensions/pom.xml # components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml # components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml # components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml # components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java # components/certificate-mgt/pom.xml # components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml # components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml # components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml # components/device-mgt-extensions/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PasswordResetWrapper.java # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/Profile.java # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ProfileFeature.java # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java # components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java # components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/Policy.java # components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/Profile.java # components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java # components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/SearchDAO.java # components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/impl/SearchDAOImpl.java # components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/ProcessorImpl.java # components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java # components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml # components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationProcessor.java # components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/ExtendedFileProtocolIteratorFactory.java # components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/ExtendedIteratorFactory.java # components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error400.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error401.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error403.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error404.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error405.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/error-pages/error500.html # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/pages/uuf.page.sign-in/sign-in.hbs # components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js # components/device-mgt/pom.xml # components/email-sender/org.wso2.carbon.email.sender.core/pom.xml # components/email-sender/pom.xml # components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml # components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml # components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml # components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml # components/identity-extensions/dynamic-client-registration/pom.xml # components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml # components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/OAuthExtUtils.java # components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java # components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml # components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml # components/identity-extensions/pom.xml # components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml # components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml # components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml # components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml # components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml # components/policy-mgt/pom.xml # components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml # components/webapp-authenticator-framework/pom.xml # features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml # features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml # features/apimgt-extensions/pom.xml # features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml # features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml # features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml # features/certificate-mgt/pom.xml # features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature/pom.xml # features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml # features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml # features/device-mgt-extensions/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml # features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml # features/device-mgt/pom.xml # features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml # features/dynamic-client-registration/pom.xml # features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml # features/email-sender/pom.xml # features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml # features/jwt-client/pom.xml # features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml # features/oauth-extensions/pom.xml # features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml # features/policy-mgt/pom.xml # features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml # features/webapp-authenticator-framework/pom.xml # pom.xml --- .../lifecycle/util/AnnotationProcessor.java | 10 +- .../ExtendedFileProtocolIteratorFactory.java | 2 +- .../mgt/core/impl/CertificateGenerator.java | 8 +- .../pom.xml | 4 + .../mgt/jaxrs/beans/ApplicationWrapper.java | 23 +- .../mgt/jaxrs/beans/BasePaginatedResult.java | 4 +- .../jaxrs/beans/OldPasswordResetWrapper.java | 9 +- .../mgt/jaxrs/beans/PasswordResetWrapper.java | 7 +- .../device/mgt/jaxrs/beans/PolicyWrapper.java | 52 ++-- .../permission/AnnotationProcessor.java | 32 ++- .../core/dao/DeviceManagementDAOFactory.java | 11 +- .../mgt/core/search/mgt/dao/SearchDAO.java | 29 --- .../search/mgt/dao/impl/SearchDAOImpl.java | 238 ------------------ .../device/mgt/core/Search/DeviceDetails.java | 4 +- .../device/mgt/core/Search/SearchDevice.java | 183 -------------- .../device/mgt/core/Search/util/Utils.java | 106 -------- .../app/modules/business-controllers/user.js | 9 +- .../cdmf.page.users/public/js/listing.js | 20 +- .../uuf-template-app/lib/modules/auth/auth.js | 48 ++-- pom.xml | 2 +- 20 files changed, 157 insertions(+), 644 deletions(-) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/SearchDAO.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/impl/SearchDAOImpl.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/SearchDevice.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/util/Utils.java diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java index c967039259..8c95252db8 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java @@ -27,7 +27,15 @@ import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration; import javax.servlet.ServletContext; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HttpMethod; +import javax.ws.rs.OPTIONS; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; import java.io.File; import java.io.IOException; import java.lang.annotation.Annotation; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/ExtendedFileProtocolIteratorFactory.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/ExtendedFileProtocolIteratorFactory.java index 3d5ad74087..c073387016 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/ExtendedFileProtocolIteratorFactory.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/ExtendedFileProtocolIteratorFactory.java @@ -21,7 +21,7 @@ import java.io.File; import java.io.IOException; import java.net.URL; -class ExtendedFileProtocolIteratorFactory implements DirectoryIteratorFactory { +final class ExtendedFileProtocolIteratorFactory implements DirectoryIteratorFactory { private static final String ENCODING_SCHEME = "UTF-8"; diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java index 8f47afc688..f81539018b 100755 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java @@ -21,8 +21,6 @@ import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.bouncycastle.asn1.ASN1Encodable; -import org.bouncycastle.asn1.ASN1InputStream; -import org.bouncycastle.asn1.ASN1Primitive; import org.bouncycastle.asn1.pkcs.Attribute; import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; import org.bouncycastle.asn1.x500.RDN; @@ -65,13 +63,13 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.security.auth.x500.X500Principal; import javax.xml.bind.DatatypeConverter; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; import java.math.BigInteger; import java.security.*; import java.security.cert.Certificate; import java.security.cert.*; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.PKCS8EncodedKeySpec; import java.util.ArrayList; import java.util.Collection; import java.util.Date; diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml index 48621fc0c8..4a5bd40660 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml @@ -115,6 +115,10 @@ + + org.apache.felix + maven-scr-plugin + org.apache.felix maven-bundle-plugin diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ApplicationWrapper.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ApplicationWrapper.java index 1040045dde..39d6de263e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ApplicationWrapper.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ApplicationWrapper.java @@ -29,14 +29,29 @@ import java.util.List; "role or devices the application is associated with.") public class ApplicationWrapper { - @ApiModelProperty(name = "userNameList", value = "List of user names.", required = true) + @ApiModelProperty( + name = "userNameList", + value = "List of user names.", + required = true) private List userNameList; - @ApiModelProperty(name = "roleNameList", value = "List of role names.", required = true) + + @ApiModelProperty( + name = "roleNameList", + value = "List of role names.", + required = true) private List roleNameList; - @ApiModelProperty(name = "deviceIdentifiers", value = "List of device identifiers.", required = true, + + @ApiModelProperty( + name = "deviceIdentifiers", + value = "List of device identifiers.", + required = true, dataType = "List[org.wso2.carbon.device.mgt.common.DeviceIdentifier]") private List deviceIdentifiers; - @ApiModelProperty(name = "application", value = "Details of the mobile application.", required = true) + + @ApiModelProperty( + name = "application", + value = "Details of the mobile application.", + required = true) private MobileApp application; public MobileApp getApplication() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java index 422a3d3008..8d1c82d8d7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java @@ -26,7 +26,9 @@ public class BasePaginatedResult { /** * Number of Resources returned. */ - @ApiModelProperty(value = "Number of total resources.", example = "2") + @ApiModelProperty( + value = "Number of total resources.", + example = "1") @JsonProperty("count") private int count; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/OldPasswordResetWrapper.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/OldPasswordResetWrapper.java index bef53c06b7..bbd8a3dcdf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/OldPasswordResetWrapper.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/OldPasswordResetWrapper.java @@ -25,9 +25,12 @@ import io.swagger.annotations.ApiModelProperty; public class OldPasswordResetWrapper extends PasswordResetWrapper{ /* - Base64 encoded password - */ - @ApiModelProperty(name = "oldPassword", value = "Old password of the user.", required = true ) + Base64 encoded password + */ + @ApiModelProperty( + name = "oldPassword", + value = "Old password of the user.", + required = true ) private String oldPassword; public String getOldPassword() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PasswordResetWrapper.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PasswordResetWrapper.java index f1e186835a..ae28860466 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PasswordResetWrapper.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PasswordResetWrapper.java @@ -27,8 +27,11 @@ public class PasswordResetWrapper { /* Base64 encoded password */ - @ApiModelProperty(name = "newPassword", value = "New password of the user.", required = true, - example = "JiM&100%pW") + @ApiModelProperty( + name = "newPassword", + value = "New password of the user.", + required = true, + example = "JiM&100%pW") private String newPassword; public String getNewPassword() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java index 1028a334be..06e99cd74d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java @@ -30,49 +30,71 @@ import java.util.List; + "Wrappers") public class PolicyWrapper { - @ApiModelProperty(name = "policyName", value = "The name of the policy", required = true) + @ApiModelProperty( + name = "policyName", + value = "The name of the policy", + required = true) @Size(max = 45) private String policyName; - @ApiModelProperty(name = "description", value = "Gives a description on the policy", required = true) + @ApiModelProperty( + name = "description", + value = "Gives a description on the policy", + required = true) @Size(max = 1000) private String description; - @ApiModelProperty(name = "compliance", value = "Provides the non-compliance rules. WSO2 EMM provides the" - + " following non-compliance rules:\n" + @ApiModelProperty( + name = "compliance", + value = "Provides the non-compliance rules. WSO2 EMM provides the following non-compliance rules:\n" + "Enforce - Forcefully enforce the policies on the devices\n" + "Warning - If the device does not adhere to the given policies a warning message will be sent\n" + "Monitor - If the device does not adhere to the given policies the server is notified of the " + "violation unknown to the user and the administrator can take the necessary actions with regard" - + " to the reported", required = true) + + " to the reported", + required = true) @Size(max = 100) private String compliance; - @ApiModelProperty(name = "ownershipType", value = "The policy ownership type. It can be any of the " - + "following values:\n" + @ApiModelProperty( + name = "ownershipType", + value = "The policy ownership type. It can be any of the following values:\n" + "ANY - The policy will be applied on the BYOD and COPE device types\n" + "BYOD (Bring Your Own Device) - The policy will only be applied on the BYOD device type\n" + "COPE (Corporate-Owned, Personally-Enabled) - The policy will only be applied on the COPE " - + "device type", required = true) + + "device type", + required = true) @Size(max = 45) private String ownershipType; - @ApiModelProperty(name = "active", value = "If the value is true it indicates that the policy is active. " - + "If the value is false it indicates that the policy is inactive", required = true) + @ApiModelProperty( + name = "active", + value = "If the value is true it indicates that the policy is active. If the value is false it " + + "indicates that the policy is inactive", + required = true) private boolean active; - @ApiModelProperty(name = "profile", value = "Contains the details of the profile that is included in the" - + " policy", required = true) + @ApiModelProperty( + name = "profile", + value = "Contains the details of the profile that is included in the policy", + required = true) private Profile profile; - @ApiModelProperty(name = "roles", value = "The roles to whom the policy is applied on", required = true) + @ApiModelProperty( + name = "roles", + value = "The roles to whom the policy is applied on", + required = true) private List roles; - @ApiModelProperty(name = "deviceIdentifiers", value = "Lists out the devices the policy is enforced on", + @ApiModelProperty( + name = "deviceIdentifiers", + value = "Lists out the devices the policy is enforced on", required = true) private List deviceIdentifiers; - @ApiModelProperty(name = "users", value = "Lists out the users on whose devices the policy is enforced", + @ApiModelProperty( + name = "users", + value = "Lists out the users on whose devices the policy is enforced", required = true) private List users; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java index 88849f2d22..b591b1a1df 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java @@ -27,7 +27,13 @@ import org.wso2.carbon.apimgt.api.model.Scope; import org.wso2.carbon.device.mgt.common.permission.mgt.Permission; import javax.servlet.ServletContext; -import javax.ws.rs.*; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HttpMethod; +import javax.ws.rs.OPTIONS; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; import java.io.File; import java.io.IOException; import java.lang.annotation.Annotation; @@ -53,6 +59,7 @@ public class AnnotationProcessor { private static final String STRING_ARR = "string_arr"; private static final String STRING = "string"; + private static final String API_CLASS_NAME = org.wso2.carbon.apimgt.annotations.api.API.class.getName(); private static final String SWAGGER_ANNOTATIONS_PROPERTIES = "properties"; private static final String SWAGGER_ANNOTATIONS_EXTENSIONS = "extensions"; @@ -119,15 +126,18 @@ public class AnnotationProcessor { * @throws IOException */ public Set scanStandardContext(String className) throws IOException { - ExtendedAnnotationDB db = new ExtendedAnnotationDB(); - db.addIgnoredPackages(PACKAGE_ORG_APACHE); - db.addIgnoredPackages(PACKAGE_ORG_CODEHAUS); - db.addIgnoredPackages(PACKAGE_ORG_SPRINGFRAMEWORK); - URL classPath = findWebInfClassesPath(servletContext); - db.scanArchives(classPath); - - //Returns a list of classes with given Annotation - return db.getAnnotationIndex().get(className); + if (API_CLASS_NAME.equals(className)) { + ExtendedAnnotationDB db = new ExtendedAnnotationDB(); + db.addIgnoredPackages(PACKAGE_ORG_APACHE); + db.addIgnoredPackages(PACKAGE_ORG_CODEHAUS); + db.addIgnoredPackages(PACKAGE_ORG_SPRINGFRAMEWORK); + URL classPath = findWebInfClassesPath(servletContext); + db.scanArchives(classPath); + + //Returns a list of classes with given Annotation + return db.getAnnotationIndex().get(className); + } + return null; } /** @@ -332,7 +342,7 @@ public class AnnotationProcessor { * @param servletContext * @return null if cannot determin /WEB-INF/classes */ - public static URL findWebInfClassesPath(ServletContext servletContext) { + private static URL findWebInfClassesPath(ServletContext servletContext) { String path = servletContext.getRealPath("/WEB-INF/classes"); if (path == null) return null; File fp = new File(path); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java index 9ec776d2ef..a949ee7f99 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java @@ -26,7 +26,10 @@ import org.wso2.carbon.device.mgt.common.TransactionManagementException; import org.wso2.carbon.device.mgt.common.UnsupportedDatabaseEngineException; import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition; -import org.wso2.carbon.device.mgt.core.dao.impl.*; +import org.wso2.carbon.device.mgt.core.dao.impl.ApplicationDAOImpl; +import org.wso2.carbon.device.mgt.core.dao.impl.ApplicationMappingDAOImpl; +import org.wso2.carbon.device.mgt.core.dao.impl.DeviceTypeDAOImpl; +import org.wso2.carbon.device.mgt.core.dao.impl.EnrollmentDAOImpl; import org.wso2.carbon.device.mgt.core.dao.impl.device.GenericDeviceDAOImpl; import org.wso2.carbon.device.mgt.core.dao.impl.device.OracleDeviceDAOImpl; import org.wso2.carbon.device.mgt.core.dao.impl.device.PostgreSQLDeviceDAOImpl; @@ -34,8 +37,6 @@ import org.wso2.carbon.device.mgt.core.dao.impl.device.SQLServerDeviceDAOImpl; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO; import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.impl.DeviceDetailsDAOImpl; -import org.wso2.carbon.device.mgt.core.search.mgt.dao.SearchDAO; -import org.wso2.carbon.device.mgt.core.search.mgt.dao.impl.SearchDAOImpl; import javax.sql.DataSource; import java.sql.Connection; @@ -135,10 +136,6 @@ public class DeviceManagementDAOFactory { return new DeviceDetailsDAOImpl(); } - public static SearchDAO getSearchDAO() { - return new SearchDAOImpl(); - } - public static void init(DataSourceConfig config) { dataSource = resolveDataSource(config); try { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/SearchDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/SearchDAO.java deleted file mode 100644 index f40c074d8c..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/SearchDAO.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2016, 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.mgt.core.search.mgt.dao; - - -public interface SearchDAO { - -// List searchDeviceDetailsTable(String query) throws SearchDAOException; -// -// List searchDevicePropertyTable(String query) throws SearchDAOException; - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/impl/SearchDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/impl/SearchDAOImpl.java deleted file mode 100644 index 8d2c705699..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/dao/impl/SearchDAOImpl.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2016, 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.mgt.core.search.mgt.dao.impl; - -import org.wso2.carbon.device.mgt.core.search.mgt.dao.SearchDAO; - - -public class SearchDAOImpl implements SearchDAO { -// -// private static final Log log = LogFactory.getLog(SearchDAOImpl.class); -// -// @Override -// public List searchDeviceDetailsTable(String query) throws SearchDAOException { -// if (log.isDebugEnabled()) { -// log.debug("Query : " + query); -// } -// Connection conn; -// PreparedStatement stmt = null; -// ResultSet rs; -// List devices = new ArrayList<>(); -// Map devs = new HashMap<>(); -// try { -// conn = this.getConnection(); -// stmt = conn.prepareStatement(query); -// rs = stmt.executeQuery(); -// while (rs.next()) { -// if (!devs.containsKey(rs.getInt("ID"))) { -// Device device = new Device(); -// device.setId(rs.getInt("ID")); -// device.setDescription(rs.getString("DESCRIPTION")); -// device.setName("NAME"); -// device.setType(rs.getString("DEVICE_TYPE_NAME")); -// device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION")); -// -// DeviceIdentifier identifier = new DeviceIdentifier(); -// identifier.setType(rs.getString("DEVICE_TYPE_NAME")); -// identifier.setId(rs.getString("DEVICE_IDENTIFICATION")); -// -// DeviceInfo deviceInfo = new DeviceInfo(); -// deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY")); -// deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL")); -// deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE")); -// deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE")); -// deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL")); -// deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY")); -// deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY")); -// deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY")); -// deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY")); -// deviceInfo.setOsVersion(rs.getString("OS_VERSION")); -// deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE")); -// deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN")); -// deviceInfo.setSsid(rs.getString("SSID")); -// deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY")); -// deviceInfo.setVendor(rs.getString("VENDOR")); -// deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP"))); -// -// DeviceLocation deviceLocation = new DeviceLocation(); -// deviceLocation.setLatitude(rs.getDouble("LATITUDE")); -// deviceLocation.setLongitude(rs.getDouble("LONGITUDE")); -// deviceLocation.setStreet1(rs.getString("STREET1")); -// deviceLocation.setStreet2(rs.getString("STREET2")); -// deviceLocation.setCity(rs.getString("CITY")); -// deviceLocation.setState(rs.getString("STATE")); -// deviceLocation.setZip(rs.getString("ZIP")); -// deviceLocation.setCountry(rs.getString("COUNTRY")); -// deviceLocation.setDeviceId(rs.getInt("ID")); -// deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP"))); -// -// deviceInfo.setLocation(deviceLocation); -// device.setDeviceInfo(deviceInfo); -// devices.add(device); -// devs.put(device.getId(), device.getId()); -// } -// } -// } catch (SQLException e) { -// throw new SearchDAOException("Error occurred while acquiring the device details.", e); -// } finally { -// DeviceManagementDAOUtil.cleanupResources(stmt, null); -// } -// -// this.fillPropertiesOfDevices(devices); -// -// if (log.isDebugEnabled()) { -// log.debug("Number of the device returned from the query : " + devices.size()); -// } -// return devices; -// } -// -// @Override -// public List searchDevicePropertyTable(String query) throws SearchDAOException { -// if (log.isDebugEnabled()) { -// log.debug("Query : " + query); -// } -// -// Connection conn; -// PreparedStatement stmt = null; -// ResultSet rs; -// List devices = new ArrayList<>(); -// Map devs = new HashMap<>(); -// try { -// conn = this.getConnection(); -// stmt = conn.prepareStatement(query); -// rs = stmt.executeQuery(); -// while (rs.next()) { -// if (!devs.containsKey(rs.getInt("ID"))) { -// Device device = new Device(); -// device.setId(rs.getInt("ID")); -// device.setDescription(rs.getString("DESCRIPTION")); -// device.setName(rs.getString("NAME")); -// device.setType(rs.getString("DEVICE_TYPE_NAME")); -// device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION")); -// -// DeviceIdentifier identifier = new DeviceIdentifier(); -// identifier.setType(rs.getString("DEVICE_TYPE_NAME")); -// identifier.setId(rs.getString("DEVICE_IDENTIFICATION")); -// -// DeviceInfo deviceInfo = new DeviceInfo(); -// deviceInfo.setAvailableRAMMemory(rs.getDouble("AVAILABLE_RAM_MEMORY")); -// deviceInfo.setBatteryLevel(rs.getDouble("BATTERY_LEVEL")); -// deviceInfo.setConnectionType(rs.getString("CONNECTION_TYPE")); -// deviceInfo.setCpuUsage(rs.getDouble("CPU_USAGE")); -// deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL")); -// deviceInfo.setExternalAvailableMemory(rs.getDouble("EXTERNAL_AVAILABLE_MEMORY")); -// deviceInfo.setExternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY")); -// deviceInfo.setInternalAvailableMemory(rs.getDouble("INTERNAL_AVAILABLE_MEMORY")); -// deviceInfo.setInternalTotalMemory(rs.getDouble("EXTERNAL_TOTAL_MEMORY")); -// deviceInfo.setOsVersion(rs.getString("OS_VERSION")); -// deviceInfo.setOsBuildDate(rs.getString("OS_BUILD_DATE")); -// deviceInfo.setPluggedIn(rs.getBoolean("PLUGGED_IN")); -// deviceInfo.setSsid(rs.getString("SSID")); -// deviceInfo.setTotalRAMMemory(rs.getDouble("TOTAL_RAM_MEMORY")); -// deviceInfo.setVendor(rs.getString("VENDOR")); -// deviceInfo.setUpdatedTime(new java.util.Date(rs.getLong("UPDATE_TIMESTAMP"))); -// -// DeviceLocation deviceLocation = new DeviceLocation(); -// deviceLocation.setLatitude(rs.getDouble("LATITUDE")); -// deviceLocation.setLongitude(rs.getDouble("LONGITUDE")); -// deviceLocation.setStreet1(rs.getString("STREET1")); -// deviceLocation.setStreet2(rs.getString("STREET2")); -// deviceLocation.setCity(rs.getString("CITY")); -// deviceLocation.setState(rs.getString("STATE")); -// deviceLocation.setZip(rs.getString("ZIP")); -// deviceLocation.setCountry(rs.getString("COUNTRY")); -// deviceLocation.setDeviceId(rs.getInt("ID")); -// deviceLocation.setUpdatedTime(new java.util.Date(rs.getLong("DL_UPDATED_TIMESTAMP"))); -// -// deviceInfo.setLocation(deviceLocation); -// device.setDeviceInfo(deviceInfo); -// devices.add(device); -// devs.put(device.getId(), device.getId()); -// } -// -// } -// } catch (SQLException e) { -// throw new SearchDAOException("Error occurred while aquiring the device details.", e); -// } finally { -// DeviceManagementDAOUtil.cleanupResources(stmt, null); -// } -// -// this.fillPropertiesOfDevices(devices); -// -// if (log.isDebugEnabled()) { -// log.debug("Number of the device returned from the query : " + devices.size()); -// } -// -// return devices; -// } -// -// -// private Connection getConnection() throws SQLException { -// return DeviceManagementDAOFactory.getConnection(); -// } -// -// private List fillPropertiesOfDevices(List devices) throws SearchDAOException { -// if (devices.isEmpty()) { -// return null; -// } -// -// Connection conn; -// PreparedStatement stmt; -// ResultSet rs; -// -// try { -// conn = this.getConnection(); -// String query = "SELECT * FROM DM_DEVICE_INFO WHERE DEVICE_ID IN (?) ORDER BY DEVICE_ID ;"; -// stmt = conn.prepareStatement(query); -// if (conn.getMetaData().getDatabaseProductName().contains("H2") || -// conn.getMetaData().getDatabaseProductName().contains("MySQL")) { -// String inData = Utils.getDeviceIdsAsString(devices); -// stmt.setString(1, inData); -// } else { -// Array array = conn.createArrayOf("INT", Utils.getArrayOfDeviceIds(devices)); -// stmt.setArray(1, array); -// } -// rs = stmt.executeQuery(); -// -// DeviceInfo dInfo; -// while (rs.next()) { -// dInfo = this.getDeviceInfo(devices, rs.getInt("DEVICE_ID")); -// dInfo.getDeviceDetailsMap().put(rs.getString("KEY_FIELD"), rs.getString("VALUE_FIELD")); -// } -// } catch (SQLException e) { -// throw new SearchDAOException("Error occurred while retrieving the device properties.", e); -// } -// return devices; -// } -// -// private DeviceInfo getDeviceInfo(List devices, int deviceId) { -// for (Device device : devices) { -// if (device.getId() == deviceId) { -// if (device.getDeviceInfo() == null) { -// device.setDeviceInfo(new DeviceInfo()); -// } -// return device.getDeviceInfo(); -// } -// } -// return null; -// } - -} - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/DeviceDetails.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/DeviceDetails.java index 0d9a824322..0e34717d9e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/DeviceDetails.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/DeviceDetails.java @@ -17,18 +17,16 @@ */ -package org.wso2.carbon.device.mgt.core.search; +package org.wso2.carbon.device.mgt.core.Search; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.device.details.mgt.impl.DeviceInformationManagerImpl; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; -import org.wso2.carbon.device.mgt.core.search.util.Utils; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/SearchDevice.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/SearchDevice.java deleted file mode 100644 index 8d46eb2d58..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/SearchDevice.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2016, 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.mgt.core.search; - -import com.google.gson.Gson; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.search.Condition; -import org.wso2.carbon.device.mgt.common.search.SearchContext; -import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest; -import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; -import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; -import org.wso2.carbon.device.mgt.core.search.mgt.impl.SearchManagerServiceImpl; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; - -import java.util.ArrayList; -import java.util.List; - -public class SearchDevice extends BaseDeviceManagementTest { - - private static final Log log = LogFactory.getLog(DeviceDetails.class); - - @BeforeClass - @Override - public void init() throws Exception { - DeviceManagementProviderService deviceManagementProviderService = new DeviceManagementProviderServiceImpl(); - DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProviderService); - } - - @Test - public void searchDeviceDetails() throws Exception { - - SearchContext context = new SearchContext(); - List conditions = new ArrayList<>(); - - - Condition cond = new Condition(); - cond.setKey("BATTERY_VOLTAGE"); - cond.setOperator("="); - cond.setValue("40"); - cond.setState(Condition.State.AND); - conditions.add(cond); - -// Condition cond2 = new Condition(); -// cond2.setKey("CPU_USAGE"); -// cond2.setOperator(">"); -// cond2.setValue("40"); -// cond2.setState(Condition.State.OR); -// conditions.add(cond2); -// -// Condition cond3 = new Condition(); -// cond3.setKey("LOCATION"); -// cond3.setOperator("="); -// cond3.setValue("Colombo"); -// cond3.setState(Condition.State.AND); -// conditions.add(cond3); - - context.setConditions(conditions); - - SearchManagerService service = new SearchManagerServiceImpl(); - List devices = service.search(context); - - Gson gson = new Gson(); - String bbbb = gson.toJson(devices); - log.info(bbbb); - - - for (Device device : devices) { - log.debug(device.getDescription()); - log.debug(device.getDeviceIdentifier()); - } - - } - - @Test - public void doValidLocationSearch() throws Exception { - - SearchContext context = new SearchContext(); - List conditions = new ArrayList<>(); - - Condition cond = new Condition(); - cond.setKey("LOCATION"); - cond.setOperator("="); - cond.setValue("Karan"); - cond.setState(Condition.State.AND); - conditions.add(cond); - - context.setConditions(conditions); - - SearchManagerService service = new SearchManagerServiceImpl(); - List devices = service.search(context); - - Gson gson = new Gson(); - String bbbb = gson.toJson(devices); - log.info("Valid Search " + bbbb); - - - for (Device device : devices) { - log.debug(device.getDescription()); - log.debug(device.getDeviceIdentifier()); - } - } - - @Test - public void doInvalidLocationSearch() throws Exception { - - SearchContext context = new SearchContext(); - List conditions = new ArrayList<>(); - - Condition cond = new Condition(); - cond.setKey("LOCATION"); - cond.setOperator("="); - cond.setValue("Colombo"); - cond.setState(Condition.State.AND); - conditions.add(cond); - - context.setConditions(conditions); - - SearchManagerService service = new SearchManagerServiceImpl(); - List devices = service.search(context); - - Gson gson = new Gson(); - String bbbb = gson.toJson(devices); - log.info("Invalid Search " + bbbb); - - - for (Device device : devices) { - log.debug(device.getDescription()); - log.debug(device.getDeviceIdentifier()); - } - } - - @Test - public void doStringSearch() throws Exception { - - SearchContext context = new SearchContext(); - List conditions = new ArrayList<>(); - - Condition cond = new Condition(); - cond.setKey("deviceModel"); - cond.setOperator("="); - cond.setValue("SM-T520"); - cond.setState(Condition.State.AND); - conditions.add(cond); - - context.setConditions(conditions); - - SearchManagerService service = new SearchManagerServiceImpl(); - List devices = service.search(context); - - Gson gson = new Gson(); - String bbbb = gson.toJson(devices); - log.info("Invalid Search " + bbbb); - - - for (Device device : devices) { - log.debug(device.getDescription()); - log.debug(device.getDeviceIdentifier()); - } - } -} - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/util/Utils.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/util/Utils.java deleted file mode 100644 index 58c6f621ac..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/Search/util/Utils.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2016, 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.mgt.core.search.util; - -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; -import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; -import org.wso2.carbon.device.mgt.core.common.TestDataHolder; - -import java.util.HashMap; -import java.util.Map; - -public class Utils { - - public static DeviceInfo getDeviceInfo() { - - DeviceInfo deviceInfo = new DeviceInfo(); - - deviceInfo.setIMSI("e6f236ac82537a8e"); - deviceInfo.setSsid("FAFDA"); - - - deviceInfo.setAvailableRAMMemory(1.24); - deviceInfo.setBatteryLevel(27.3); - deviceInfo.setConnectionType("GSM"); - deviceInfo.setCpuUsage(82.34); - deviceInfo.setDeviceModel("SM-T520"); - deviceInfo.setExternalAvailableMemory(2.45); - deviceInfo.setExternalTotalMemory(16.23); - deviceInfo.setIMEI("e6f236ac82537a8e"); - deviceInfo.setIMSI("GT-0WDA"); - deviceInfo.setInternalAvailableMemory(3.56); - deviceInfo.setInternalTotalMemory(7.89); - deviceInfo.setMobileSignalStrength(0.67); - deviceInfo.setOperator("Dialog"); - deviceInfo.setOsVersion("Lolipop"); - deviceInfo.setOsBuildDate("1467366458"); - deviceInfo.setPluggedIn(true); - deviceInfo.setSsid("SSSSSS"); - deviceInfo.setTotalRAMMemory(4.00); - deviceInfo.setVendor("SAMSUNG"); - - - Map propertyMap = new HashMap<>(); - - propertyMap.put("BATTERY_VOLTAGE", "40"); - propertyMap.put("BATTERY_HEALTH", "Good"); - propertyMap.put("BATTERY_STATUS", "SWElLED"); - propertyMap.put("LOW_MEMORY", "false"); - propertyMap.put("MEMORY_THRESHOLD", "100663296"); - propertyMap.put("CPU_IOW", "12"); - propertyMap.put("CPU_IRQ", "1"); - - deviceInfo.setDeviceDetailsMap(propertyMap); - - return deviceInfo; - } - - - public static DeviceLocation getSampleDeviceLocation(){ - - - DeviceLocation deviceLocation = new DeviceLocation(); - deviceLocation.setDeviceIdentifier(Utils.getDeviceIdentifier()); - deviceLocation.setLatitude(76.2422); - deviceLocation.setLongitude(81.43); - deviceLocation.setStreet1("4"); - deviceLocation.setStreet2("Isuru Uyana"); - deviceLocation.setCity("Karanadeniya"); - deviceLocation.setState("Karandeniya"); - deviceLocation.setZip("80360"); - deviceLocation.setCountry("Sri Lanka"); - deviceLocation.setDeviceId(1); - - return deviceLocation; - } - - public static DeviceIdentifier getDeviceIdentifier(){ - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setType(TestDataHolder.TEST_DEVICE_TYPE); - deviceIdentifier.setId("12345"); - - return deviceIdentifier; - } - -} - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index 51cbd25c64..c6ed7da1bd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -674,6 +674,7 @@ var userModule = function () { */ publicMethods.getSecondaryUserStores = function () { var returnVal = []; + // To call the userstore admin service, user needs to have admin permission if (publicMethods.isAuthorized("/permission/admin")) { var endpoint = devicemgtProps["adminService"] + constants["USER_STORE_CONFIG_ADMIN_SERVICE_END_POINT"]; var wsPayload = ""; @@ -682,7 +683,7 @@ var userModule = function () { wsPayload, endpoint, function (wsResponse) { - var domainIDs = stringify(wsResponse.*::['return']. *::domainId.text()); + var domainIDs = stringify(wsResponse. * ::['return']. * ::domainId.text()); if (domainIDs != "\"\"") { var regExpForSearch = new RegExp(constants["USER_STORES_NOISY_CHAR"], "g"); domainIDs = domainIDs.replace(regExpForSearch, ""); @@ -692,11 +693,11 @@ var userModule = function () { log.error("Error retrieving secondary user stores", e); }, constants["SOAP_VERSION"]); - } else { + } else { if (log.isDebugEnabled()) { log.debug("User does not have admin permission to get the secondary user store details."); - } - } + } + } return returnVal; }; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js index 3e3c64781f..ad1e3b549d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js @@ -68,10 +68,10 @@ $("a#invite-user-link").click(function () { modalDialog.showAsError(); } else { modalDialog.header(""); - modalDialog.content("An invitation mail will be sent to the selected user(s) to initiate an enrolment process." + - " Do you wish to continue ?"); - modalDialog.footer('
yes' + - 'No
'); + modalDialog.content("An invitation mail will be sent to the selected user(s) to initiate an enrolment " + + "process. Do you wish to continue ?"); + modalDialog.footer('
yes' + + 'No
'); modalDialog.show(); } @@ -82,18 +82,18 @@ $("a#invite-user-link").click(function () { usernameList, function () { modalDialog.header("User invitation email for enrollment was successfully sent."); - modalDialog.footer(''); + modalDialog.footer(''); $("a#invite-user-success-link").click(function () { modalDialog.hide(); }); }, function () { - modalDialog.header(' Unexpected Error !'); + modalDialog.header(' Unexpected Error !'); modalDialog.content('An unexpected error occurred. Try again later.'); - modalDialog.footer(''); + modalDialog.footer(''); $("a#invite-user-error-link").click(function () { modalDialog.hide(); }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js index a18d2efc50..93cffdbf86 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js @@ -502,25 +502,34 @@ var module = {}; // This is a logout response. module.logout(response); } else { - // This is a login response. - var ssoConfigs = getSsoConfigurations(); - var CarbonUtils = Packages.org.wso2.carbon.utils.CarbonUtils; - var keyStorePassword = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Password"); - var keyStoreName = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Location"); - var identityAlias = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_IDENTITY_ALIAS]; - var keyStoreParams = { - KEY_STORE_NAME: keyStoreName, - KEY_STORE_PASSWORD: keyStorePassword, - IDP_ALIAS: identityAlias - }; - - if (!ssoClient.validateSamlResponse(samlResponseObj, ssoConfigs, keyStoreParams)) { - var msg = "Invalid signature found in the SAML response."; - log.error(msg); - response.sendError(500, msg); - return; - } + // This is a login response. + var ssoConfigs = getSsoConfigurations(); + var CarbonUtils = Packages.org.wso2.carbon.utils.CarbonUtils; + var keyStorePassword = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Password"); + var keyStoreName = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Location"); + var identityAlias = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_IDENTITY_ALIAS]; + var keyStoreParams = { + KEY_STORE_NAME: keyStoreName, + KEY_STORE_PASSWORD: keyStorePassword, + IDP_ALIAS: identityAlias + }; + var rsEnabled = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_RESPONSE_SIGNING_ENABLED]; + if (utils.parseBoolean(rsEnabled)) { + if (!ssoClient.validateSignature(samlResponseObj, keyStoreParams)) { + var msg = "Invalid signature found in the SAML response."; + log.error(msg); + response.sendError(500, msg); + return; + } + } + if (!ssoClient.validateSamlResponse(samlResponseObj, ssoConfigs, keyStoreParams)) { + var msg = "Invalid SAML response found."; + log.error(msg); + response.sendError(500, msg); + return; + } + /** * @type {{sessionId: string, loggedInUser: string, sessionIndex: string, samlToken: * string}} @@ -531,10 +540,9 @@ var module = {}; var ssoSessions = getSsoSessions(); ssoSessions[ssoSession.sessionId] = ssoSession; if (ssoSession.sessionIndex) { - module.loadTenant(ssoSession.loggedInUser); var carbonUser = (require("carbon")).server.tenantUser(ssoSession.loggedInUser); - module.loadTenant(ssoSession.loggedInUser); utils.setCurrentUser(carbonUser.username, carbonUser.domain, carbonUser.tenantId); + module.loadTenant(ssoSession.loggedInUser); var scriptArgument = {input: {samlToken: ssoSession.samlToken}, user: module.getCurrentUser()}; handleEvent(OPERATION_LOGIN, EVENT_SUCCESS, scriptArgument); } diff --git a/pom.xml b/pom.xml index e9339f6644..3179162acb 100644 --- a/pom.xml +++ b/pom.xml @@ -1581,7 +1581,7 @@ io.swagger swagger-annotations - ${swagger.version} + ${swagger.annotations.version} io.swagger From 0acd273ae1f9bd5f6364c94c3856528637badeab Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Sun, 8 Jan 2017 12:41:09 +0530 Subject: [PATCH 02/12] Fixing merge conflicts --- .../permission/AnnotationProcessor.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java index b591b1a1df..01532e259e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/permission/AnnotationProcessor.java @@ -27,6 +27,7 @@ import org.wso2.carbon.apimgt.api.model.Scope; import org.wso2.carbon.device.mgt.common.permission.mgt.Permission; import javax.servlet.ServletContext; +import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.HttpMethod; @@ -34,6 +35,7 @@ import javax.ws.rs.OPTIONS; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; +import javax.ws.rs.Produces; import java.io.File; import java.io.IOException; import java.lang.annotation.Annotation; @@ -59,7 +61,6 @@ public class AnnotationProcessor { private static final String STRING_ARR = "string_arr"; private static final String STRING = "string"; - private static final String API_CLASS_NAME = org.wso2.carbon.apimgt.annotations.api.API.class.getName(); private static final String SWAGGER_ANNOTATIONS_PROPERTIES = "properties"; private static final String SWAGGER_ANNOTATIONS_EXTENSIONS = "extensions"; @@ -126,18 +127,15 @@ public class AnnotationProcessor { * @throws IOException */ public Set scanStandardContext(String className) throws IOException { - if (API_CLASS_NAME.equals(className)) { - ExtendedAnnotationDB db = new ExtendedAnnotationDB(); - db.addIgnoredPackages(PACKAGE_ORG_APACHE); - db.addIgnoredPackages(PACKAGE_ORG_CODEHAUS); - db.addIgnoredPackages(PACKAGE_ORG_SPRINGFRAMEWORK); - URL classPath = findWebInfClassesPath(servletContext); - db.scanArchives(classPath); - - //Returns a list of classes with given Annotation - return db.getAnnotationIndex().get(className); - } - return null; + ExtendedAnnotationDB db = new ExtendedAnnotationDB(); + db.addIgnoredPackages(PACKAGE_ORG_APACHE); + db.addIgnoredPackages(PACKAGE_ORG_CODEHAUS); + db.addIgnoredPackages(PACKAGE_ORG_SPRINGFRAMEWORK); + URL classPath = findWebInfClassesPath(servletContext); + db.scanArchives(classPath); + + //Returns a list of classes with given Annotation + return db.getAnnotationIndex().get(className); } /** From 1ad9439162375e00688f7b22e8bbb6338bafcb76 Mon Sep 17 00:00:00 2001 From: charitha Date: Mon, 9 Jan 2017 15:02:10 +0530 Subject: [PATCH 03/12] Add select2 controller to select roles to share a group --- .../app/pages/cdmf.page.groups/groups.hbs | 21 +++++++++-- .../cdmf.page.groups/public/js/listing.js | 37 +++++-------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs index da79afe1bd..198890e4ba 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs @@ -119,10 +119,9 @@

Select user role(s) -

-
-

+
+
'; - $('.roleCheckBoxes').each( - function () { - if (data.roles[i] == $(this).data('role-name')) { - $(this).attr('checked', true); - } - } - ); + html += ''; } + html += ''; $("#rolesListing").html(html); markAlreadySavedUsersRoles(groupId); + $("select.select2[multiple=multiple]").select2({ + tags: false + }); } else { $("#rolesListing").html("No roles available"); } From e1228b408a19321cecb207c3602cb227e4fec3d7 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Mon, 9 Jan 2017 16:35:33 +0530 Subject: [PATCH 04/12] Removed [httpsWebURL] from config.json --- .../main/resources/jaggeryapps/devicemgt/app/conf/config.json | 1 - 1 file changed, 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 95996fb6bb..cbdd321dc4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -2,7 +2,6 @@ "appContext": "/devicemgt/", "httpsURL" : "%https.ip%", "httpURL" : "%http.ip%", - "httpsWebURL" : "%https.ip%", "wssURL" : "https://localhost:9445", "wsURL" : "%http.ip%", "portalURL": "https://%server.ip%:9445", From b35e0dd2fa5019f229be72cba84aa4ea667c4eaf Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 10 Jan 2017 03:09:42 +0530 Subject: [PATCH 05/12] added missing components --- .../pom.xml | 7 +++++++ .../device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml | 5 +++++ pom.xml | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml index 0cc36fe99e..8c8d0665d6 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml @@ -48,6 +48,10 @@ org.wso2.orbit.org.scannotation scannotation
+ + io.swagger + swagger-annotations + @@ -137,6 +141,9 @@ org.wso2.orbit.org.scannotation:scannotation:${scannotation.version} + + io.swagger:swagger-annotations:${swagger.version} + org.wso2.carbon.core.server:${carbon.kernel.version} diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index 3ba32fa1bc..ee5fa7b255 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -48,6 +48,10 @@ javax.servlet.jsp javax.servlet.jsp-api + + org.wso2.carbon.store + org.wso2.store.sso.common + @@ -76,6 +80,7 @@ javax.servlet.jsp:javax.servlet.jsp-api + org.wso2.carbon.store:org.wso2.store.sso.common:${carbon.store.sso.common.version} diff --git a/pom.xml b/pom.xml index e9339f6644..76fb99e3b2 100644 --- a/pom.xml +++ b/pom.xml @@ -1664,6 +1664,11 @@ wss4j ${org.apache.ws.security.wso2.version} + + org.wso2.carbon.store + org.wso2.store.sso.common + ${carbon.store.sso.common.version} + @@ -2059,6 +2064,9 @@ 2.1.7-wso2v7 1.5.11.wso2v15 + + + 1.4.4 From ac8dae7ed03b8b10a612c8c4ee5bbdea9044c167 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 10 Jan 2017 09:27:10 +0530 Subject: [PATCH 06/12] fixing test failures --- .../src/test/resources/testng.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml index b30b66cb78..32c9dca57d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml @@ -31,7 +31,7 @@ - + From 471e6347908f556353e08c04e7a6f5aa5e62e3f7 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 10 Jan 2017 12:11:03 +0530 Subject: [PATCH 07/12] merged with upstream --- .../org/wso2/carbon/device/mgt/core/search/DeviceDetails.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/search/DeviceDetails.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/search/DeviceDetails.java index 0e34717d9e..7846c21ea0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/search/DeviceDetails.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/search/DeviceDetails.java @@ -17,7 +17,7 @@ */ -package org.wso2.carbon.device.mgt.core.Search; +package org.wso2.carbon.device.mgt.core.search; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; From 643acd78276472bdb89bd97f277a7ff63716c89d Mon Sep 17 00:00:00 2001 From: Ace Date: Tue, 10 Jan 2017 16:16:31 +0530 Subject: [PATCH 08/12] Adding api for renaming devices --- .../org.wso2.carbon.device.mgt.api/pom.xml | 4 +- .../service/api/DeviceManagementService.java | 77 +++++++++++++++++++ .../impl/DeviceManagementServiceImpl.java | 26 +++++++ .../devicemgt/app/conf/config.json | 1 + .../cdmf.page.devices/public/js/listing.js | 6 +- 5 files changed, 110 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index 27b01bd554..ce88139cb6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -201,8 +201,8 @@ - com.google.code.gson - gson + org.json.wso2 + json commons-codec.wso2 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index 3c96e96a50..8574b4088d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -29,6 +29,7 @@ import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ResponseHeader; +import org.json.JSONObject; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.Device; @@ -401,6 +402,82 @@ public interface DeviceManagementService { String deviceId); + //device rename request would looks like follows + //POST devices/type/virtual_firealarm/id/us06ww93auzp/rename + @POST + @Path("/type/{device-type}/id/{device-id}/rename") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Update the device specified by device id", + notes = "Returns the status of the updated device operation.", + tags = "Device Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:update") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully fetched information of the device.", + response = Device.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 304, + message = "Not Modified. Empty body because the client already has the latest " + + "version of the requested resource."), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 404, + message = "Not Found. \n No device is found under the provided type and id.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while retrieving information requested device.", + response = ErrorResponse.class) + }) + Response renameDevice( + @ApiParam( + name = "device", + value = "The payload containing new name for device with updated name.", + required = true) + Device device, + @ApiParam( + name = "device-type", + value = "The device type, such as ios, android or windows.", + required = true) + @PathParam("device-type") + @Size(max = 45) + String deviceType, + @ApiParam( + name = "device-id", + value = "The device identifier of the device.", + required = true) + @PathParam("device-id") + @Size(max = 45) + String deviceId); + + @GET @Path("/{type}/{id}/features") @ApiOperation( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index 013a04c350..dd4c604162 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -18,8 +18,11 @@ */ package org.wso2.carbon.device.mgt.jaxrs.service.impl; +import io.swagger.annotations.ApiParam; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.json.JSONException; +import org.json.JSONObject; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.app.mgt.Application; @@ -30,6 +33,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.search.SearchContext; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; +import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; @@ -236,6 +240,28 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } } + @POST + @Override + @Path("/type/{device-type}/id/{device-id}/rename") + public Response renameDevice(Device device, @PathParam("device-type") String deviceType, + @PathParam("device-id") String deviceId) { + DeviceManagementProviderService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceManagementService(); + try { + Device persistedDevice = deviceManagementProviderService.getDevice(new DeviceIdentifier + (deviceId, deviceType)); + persistedDevice.setName(device.getName()); + boolean response = deviceManagementProviderService.modifyEnrollment(persistedDevice); + return Response.status(Response.Status.CREATED).entity(response).build(); + + } catch (DeviceManagementException e) { + log.error("Error encountered while updating device of type : " + deviceType + " and " + + "ID : " + deviceId); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setMessage("Error while updating " + + "device of type " + deviceType + " and ID : " + deviceId).build()).build(); + } + } + @GET @Path("/{type}/{id}") @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 8b923a9b82..e9259819aa 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -90,6 +90,7 @@ "perm:devices:operations", "perm:devices:search", "perm:devices:details", + "perm:devices:update", "perm:devices:view", "perm:view-configuration", "perm:manage-configuration", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js index 978d85e804..9fe08fa365 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js @@ -730,7 +730,7 @@ function attachDeviceEvents() { var deviceId = $(this).data("deviceid"); var deviceType = $(this).data("devicetype"); var deviceName = $(this).data("devicename"); - var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceType + "/id/" + deviceId; + var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceType + "/id/" + deviceId + "/rename"; $(modalPopupContent).html($('#edit-device-modal-content').html()); $('#edit-device-name').val(deviceName); @@ -738,7 +738,9 @@ function attachDeviceEvents() { $("a#edit-device-yes-link").click(function () { var newDeviceName = $('#edit-device-name').val(); - invokerUtil.put(serviceURL, {"name": newDeviceName}, function (message) { + var request = {}; + request['name'] = newDeviceName; + invokerUtil.put(serviceURL, request, function (message) { $(modalPopupContent).html($('#edit-device-200-content').html()); setTimeout(function () { hidePopup(); From c6d186aa1addd35a47bd575334c51d3b0c3a7f6c Mon Sep 17 00:00:00 2001 From: Ace Date: Tue, 10 Jan 2017 16:19:57 +0530 Subject: [PATCH 09/12] Adding missing fix --- .../devicemgt/app/pages/cdmf.page.devices/public/js/listing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js index 9fe08fa365..688a3a8b21 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js @@ -740,7 +740,7 @@ function attachDeviceEvents() { var newDeviceName = $('#edit-device-name').val(); var request = {}; request['name'] = newDeviceName; - invokerUtil.put(serviceURL, request, function (message) { + invokerUtil.post(serviceURL, request, function (message) { $(modalPopupContent).html($('#edit-device-200-content').html()); setTimeout(function () { hidePopup(); From 4588cfbed461c8a86a6218d672399697711b9443 Mon Sep 17 00:00:00 2001 From: kamidu Date: Tue, 10 Jan 2017 17:22:42 +0530 Subject: [PATCH 10/12] Fixing the permission management issue in EMM console --- .../mgt/jaxrs/service/impl/RoleManagementServiceImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java index ee664e2c63..dd6932981f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -404,10 +404,15 @@ public class RoleManagementServiceImpl implements RoleManagementService { // Get all role permissions final UIPermissionNode rolePermissions = this.getAllRolePermissions(roleName, userRealm); List permissions = new ArrayList(); + final UIPermissionNode emmRolePermissions = (UIPermissionNode)this.getRolePermissions(roleName); + List emmConsolePermissions = new ArrayList(); + this.getAuthorizedPermissions(emmRolePermissions, emmConsolePermissions); + emmConsolePermissions.removeAll(new ArrayList(Arrays.asList(roleInfo.getPermissions()))); this.getAuthorizedPermissions(rolePermissions, permissions); for (String permission : roleInfo.getPermissions()) { permissions.add(permission); } + permissions.removeAll(emmConsolePermissions); String [] allApplicablePerms = new String[permissions.size()]; allApplicablePerms = permissions.toArray(allApplicablePerms); roleInfo.setPermissions(allApplicablePerms); From ef2a1b84a261a18669b2070348ea475d4993d862 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Wed, 11 Jan 2017 09:11:59 +0530 Subject: [PATCH 11/12] IOTS-376 : Fixing cannot delete a device --- .../service/api/DeviceManagementService.java | 60 +++++++++---------- .../impl/DeviceManagementServiceImpl.java | 53 +++++++++++----- 2 files changed, 66 insertions(+), 47 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index 8574b4088d..621ec26d73 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -331,20 +331,21 @@ public interface DeviceManagementService { @HeaderParam("If-Modified-Since") String ifModifiedSince); - //device delete request would looks like follows - //DELETE devices/type/virtual_firealarm/id/us06ww93auzp - @DELETE - @Path("/type/{device-type}/id/{device-id}") + //device rename request would looks like follows + //POST devices/type/virtual_firealarm/id/us06ww93auzp/rename + @POST + @Path("/type/{device-type}/id/{device-id}/rename") @ApiOperation( produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "Delete the device specified by device id", - notes = "Returns the status of the deleted device operation.", + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Update the device specified by device id", + notes = "Returns the status of the updated device operation.", tags = "Device Management", extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:delete") - }) + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:update") + }) } ) @ApiResponses( @@ -384,38 +385,41 @@ public interface DeviceManagementService { "Server error occurred while retrieving information requested device.", response = ErrorResponse.class) }) - //TODO need to introduce delete permission - Response deleteDevice( + Response renameDevice( + @ApiParam( + name = "device", + value = "The payload containing new name for device with updated name.", + required = true) + Device device, @ApiParam( name = "device-type", value = "The device type, such as ios, android or windows.", required = true) @PathParam("device-type") @Size(max = 45) - String deviceType, + String deviceType, @ApiParam( name = "device-id", value = "The device identifier of the device.", required = true) @PathParam("device-id") @Size(max = 45) - String deviceId); - + String deviceId); - //device rename request would looks like follows - //POST devices/type/virtual_firealarm/id/us06ww93auzp/rename - @POST - @Path("/type/{device-type}/id/{device-id}/rename") + //device remove request would looks like follows + //DELETE devices/type/virtual_firealarm/id/us06ww93auzp + @DELETE + @Path("/type/{device-type}/id/{device-id}") @ApiOperation( produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Update the device specified by device id", - notes = "Returns the status of the updated device operation.", + httpMethod = "DELETE", + value = "Remove the device specified by device id", + notes = "Returns the status of the deleted device operation.", tags = "Device Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:update") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:delete") }) } ) @@ -423,7 +427,7 @@ public interface DeviceManagementService { value = { @ApiResponse( code = 200, - message = "OK. \n Successfully fetched information of the device.", + message = "OK. \n Successfully deleted the device.", response = Device.class, responseHeaders = { @ResponseHeader( @@ -456,12 +460,7 @@ public interface DeviceManagementService { "Server error occurred while retrieving information requested device.", response = ErrorResponse.class) }) - Response renameDevice( - @ApiParam( - name = "device", - value = "The payload containing new name for device with updated name.", - required = true) - Device device, + Response deleteDevice( @ApiParam( name = "device-type", value = "The device type, such as ios, android or windows.", @@ -477,7 +476,6 @@ public interface DeviceManagementService { @Size(max = 45) String deviceId); - @GET @Path("/{type}/{id}/features") @ApiOperation( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index dd4c604162..9a8f3b80f3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -18,22 +18,27 @@ */ package org.wso2.carbon.device.mgt.jaxrs.service.impl; -import io.swagger.annotations.ApiParam; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.json.JSONException; -import org.json.JSONObject; import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.Feature; +import org.wso2.carbon.device.mgt.common.FeatureManager; +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.device.mgt.common.search.SearchContext; import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; -import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; @@ -44,15 +49,20 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.OperationList; import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceManagementService; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; -import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import javax.validation.constraints.Size; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.text.ParseException; @@ -229,14 +239,25 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @Override @Path("/type/{device-type}/id/{device-id}") public Response deleteDevice(@PathParam("device-type") String deviceType, @PathParam("device-id") String deviceId) { - - log.info("Deleting " + deviceType + " " + deviceId + "is not supported"); + DeviceManagementProviderService deviceManagementProviderService = + DeviceMgtAPIUtils.getDeviceManagementService(); try { - return Response.status(Response.Status.BAD_REQUEST).entity("{Deleting device(s) is not supported}").build(); - } catch (Exception e) { - String msg = "Error occurred while deleting device(s)"; - log.error(msg, e); - return Response.serverError().entity(new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType); + Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier); + if (persistedDevice == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + + boolean response = deviceManagementProviderService.disenrollDevice(deviceIdentifier); + return Response.status(Response.Status.OK).entity(response).build(); + + } catch (DeviceManagementException e) { + String msg = "Error encountered while deleting device of type : " + deviceType + " and " + + "ID : " + deviceId; + log.error(msg); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build() + ).build(); } } From 0d721a226b16ba2cf648e1b5893bf2fb2b345254 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Wed, 11 Jan 2017 12:41:34 +0530 Subject: [PATCH 12/12] updated ui config --- .../resources/jaggeryapps/devicemgt/app/conf/config.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index cbdd321dc4..8937754615 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -1,7 +1,7 @@ { "appContext": "/devicemgt/", - "httpsURL" : "%https.ip%", - "httpURL" : "%http.ip%", + "httpsURL" : "https://localhost:8243", + "httpURL" : "http://localhost:8280", "wssURL" : "https://localhost:9445", "wsURL" : "%http.ip%", "portalURL": "https://%server.ip%:9445", @@ -12,7 +12,7 @@ "iOSConfigRoot" : "%https.ip%/ios-enrollment/", "iOSAPIRoot" : "%https.ip%/ios/", "adminService": "%https.ip%", - "gatewayEnabled": false, + "gatewayEnabled": true, "oauthProvider": { "appRegistration": { "appType": "webapp",