mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merging with master
This commit is contained in:
commit
6a8a5cbd5a
@ -22,13 +22,13 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - API Management Annotations</name>
|
||||
<description>WSO2 Carbon - API Management Custom Annotation Module</description>
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed 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.apimgt.annotations.api;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* This class is the representation of custom developed Permission annotation.
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Permission {
|
||||
|
||||
/**
|
||||
* Represents the permission name.
|
||||
* @return Returns permission name.
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Represents the permission string.
|
||||
* @return Returns permission string.
|
||||
*/
|
||||
String permission();
|
||||
|
||||
}
|
||||
@ -21,12 +21,12 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>WSO2 Carbon - API Application Management API</name>
|
||||
|
||||
@ -22,12 +22,12 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - API Application Management</name>
|
||||
|
||||
@ -22,13 +22,13 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - API Management Webapp Publisher</name>
|
||||
<description>WSO2 Carbon - API Management Webapp Publisher</description>
|
||||
|
||||
@ -44,33 +44,33 @@ public class APIPublisherStartupHandler implements ServerStartupObserver {
|
||||
|
||||
@Override
|
||||
public void completedServerStartup() {
|
||||
APIPublisherDataHolder.getInstance().setServerStarted(true);
|
||||
currentAPIsStack = APIPublisherDataHolder.getInstance().getUnpublishedApis();
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Server has just started, hence started publishing unpublished APIs");
|
||||
log.debug("Total number of unpublished APIs: "
|
||||
+ APIPublisherDataHolder.getInstance().getUnpublishedApis().size());
|
||||
}
|
||||
publisher = APIPublisherDataHolder.getInstance().getApiPublisherService();
|
||||
while (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty()) {
|
||||
try {
|
||||
retryTime = retryTime * CONNECTION_RETRY_FACTOR;
|
||||
Thread.sleep(retryTime);
|
||||
} catch (InterruptedException te) {
|
||||
log.error("Error occurred while sleeping", te);
|
||||
}
|
||||
if (!APIPublisherDataHolder.getInstance().getUnpublishedApis().isEmpty()) {
|
||||
publishAPIs(currentAPIsStack, failedAPIsStack);
|
||||
} else {
|
||||
publishAPIs(failedAPIsStack, currentAPIsStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
// APIPublisherDataHolder.getInstance().setServerStarted(true);
|
||||
// currentAPIsStack = APIPublisherDataHolder.getInstance().getUnpublishedApis();
|
||||
// Thread t = new Thread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// if (log.isDebugEnabled()) {
|
||||
// log.debug("Server has just started, hence started publishing unpublished APIs");
|
||||
// log.debug("Total number of unpublished APIs: "
|
||||
// + APIPublisherDataHolder.getInstance().getUnpublishedApis().size());
|
||||
// }
|
||||
// publisher = APIPublisherDataHolder.getInstance().getApiPublisherService();
|
||||
// while (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty()) {
|
||||
// try {
|
||||
// retryTime = retryTime * CONNECTION_RETRY_FACTOR;
|
||||
// Thread.sleep(retryTime);
|
||||
// } catch (InterruptedException te) {
|
||||
// log.error("Error occurred while sleeping", te);
|
||||
// }
|
||||
// if (!APIPublisherDataHolder.getInstance().getUnpublishedApis().isEmpty()) {
|
||||
// publishAPIs(currentAPIsStack, failedAPIsStack);
|
||||
// } else {
|
||||
// publishAPIs(failedAPIsStack, currentAPIsStack);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// t.start();
|
||||
}
|
||||
|
||||
private void publishAPIs(Stack<API> apis, Stack<API> failedStack) {
|
||||
|
||||
@ -49,72 +49,72 @@ public class APIPublisherLifecycleListener implements LifecycleListener {
|
||||
|
||||
@Override
|
||||
public void lifecycleEvent(LifecycleEvent lifecycleEvent) {
|
||||
if (Lifecycle.AFTER_START_EVENT.equals(lifecycleEvent.getType()) && WebappPublisherConfig.getInstance()
|
||||
.isPublished()) {
|
||||
StandardContext context = (StandardContext) lifecycleEvent.getLifecycle();
|
||||
ServletContext servletContext = context.getServletContext();
|
||||
String param = servletContext.getInitParameter(PARAM_MANAGED_API_ENABLED);
|
||||
boolean isManagedApi = (param != null && !param.isEmpty()) && Boolean.parseBoolean(param);
|
||||
|
||||
String profile = System.getProperty(PROPERTY_PROFILE);
|
||||
|
||||
if (WebappPublisherConfig.getInstance().getProfiles().getProfile().contains(profile.toLowerCase())
|
||||
&& isManagedApi) {
|
||||
try {
|
||||
AnnotationProcessor annotationProcessor = new AnnotationProcessor(context);
|
||||
Set<String> annotatedAPIClasses = annotationProcessor.
|
||||
scanStandardContext(org.wso2.carbon.apimgt.annotations.api.API.class.getName());
|
||||
|
||||
List<APIResourceConfiguration> apiDefinitions = annotationProcessor.extractAPIInfo(servletContext,
|
||||
annotatedAPIClasses);
|
||||
|
||||
for (APIResourceConfiguration apiDefinition : apiDefinitions) {
|
||||
|
||||
APIConfig apiConfig = APIPublisherUtil.buildApiConfig(servletContext, apiDefinition);
|
||||
|
||||
try {
|
||||
int tenantId = APIPublisherDataHolder.getInstance().getTenantManager().
|
||||
getTenantId(apiConfig.getTenantDomain());
|
||||
|
||||
boolean isTenantActive = APIPublisherDataHolder.getInstance().
|
||||
getTenantManager().isTenantActive(tenantId);
|
||||
|
||||
if (isTenantActive) {
|
||||
apiConfig.init();
|
||||
API api = APIPublisherUtil.getAPI(apiConfig);
|
||||
boolean isServerStarted = APIPublisherDataHolder.getInstance().isServerStarted();
|
||||
if (isServerStarted) {
|
||||
APIPublisherService apiPublisherService =
|
||||
APIPublisherDataHolder.getInstance().getApiPublisherService();
|
||||
if (apiPublisherService == null) {
|
||||
throw new IllegalStateException(
|
||||
"API Publisher service is not initialized properly");
|
||||
}
|
||||
apiPublisherService.publishAPI(api);
|
||||
} else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Server has not started yet. Hence adding API '" +
|
||||
api.getId().getApiName() + "' to the queue");
|
||||
}
|
||||
APIPublisherDataHolder.getInstance().getUnpublishedApis().push(api);
|
||||
}
|
||||
} else {
|
||||
log.error("No tenant [" + apiConfig.getTenantDomain() + "] " +
|
||||
"found when publishing the Web app");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error("Error occurred while publishing API '" + apiConfig.getName() +
|
||||
"' with the context '" + apiConfig.getContext() +
|
||||
"' and version '" + apiConfig.getVersion() + "'", e);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Error encountered while discovering annotated classes", e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
log.error("Error while scanning class for annotations", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (Lifecycle.AFTER_START_EVENT.equals(lifecycleEvent.getType()) && WebappPublisherConfig.getInstance()
|
||||
// .isPublished()) {
|
||||
// StandardContext context = (StandardContext) lifecycleEvent.getLifecycle();
|
||||
// ServletContext servletContext = context.getServletContext();
|
||||
// String param = servletContext.getInitParameter(PARAM_MANAGED_API_ENABLED);
|
||||
// boolean isManagedApi = (param != null && !param.isEmpty()) && Boolean.parseBoolean(param);
|
||||
//
|
||||
// String profile = System.getProperty(PROPERTY_PROFILE);
|
||||
//
|
||||
// if (WebappPublisherConfig.getInstance().getProfiles().getProfile().contains(profile.toLowerCase())
|
||||
// && isManagedApi) {
|
||||
// try {
|
||||
// AnnotationProcessor annotationProcessor = new AnnotationProcessor(context);
|
||||
// Set<String> annotatedAPIClasses = annotationProcessor.
|
||||
// scanStandardContext(org.wso2.carbon.apimgt.annotations.api.API.class.getName());
|
||||
//
|
||||
// List<APIResourceConfiguration> apiDefinitions = annotationProcessor.extractAPIInfo(servletContext,
|
||||
// annotatedAPIClasses);
|
||||
//
|
||||
// for (APIResourceConfiguration apiDefinition : apiDefinitions) {
|
||||
//
|
||||
// APIConfig apiConfig = APIPublisherUtil.buildApiConfig(servletContext, apiDefinition);
|
||||
//
|
||||
// try {
|
||||
// int tenantId = APIPublisherDataHolder.getInstance().getTenantManager().
|
||||
// getTenantId(apiConfig.getTenantDomain());
|
||||
//
|
||||
// boolean isTenantActive = APIPublisherDataHolder.getInstance().
|
||||
// getTenantManager().isTenantActive(tenantId);
|
||||
//
|
||||
// if (isTenantActive) {
|
||||
// apiConfig.init();
|
||||
// API api = APIPublisherUtil.getAPI(apiConfig);
|
||||
// boolean isServerStarted = APIPublisherDataHolder.getInstance().isServerStarted();
|
||||
// if (isServerStarted) {
|
||||
// APIPublisherService apiPublisherService =
|
||||
// APIPublisherDataHolder.getInstance().getApiPublisherService();
|
||||
// if (apiPublisherService == null) {
|
||||
// throw new IllegalStateException(
|
||||
// "API Publisher service is not initialized properly");
|
||||
// }
|
||||
// apiPublisherService.publishAPI(api);
|
||||
// } else {
|
||||
// if (log.isDebugEnabled()) {
|
||||
// log.debug("Server has not started yet. Hence adding API '" +
|
||||
// api.getId().getApiName() + "' to the queue");
|
||||
// }
|
||||
// APIPublisherDataHolder.getInstance().getUnpublishedApis().push(api);
|
||||
// }
|
||||
// } else {
|
||||
// log.error("No tenant [" + apiConfig.getTenantDomain() + "] " +
|
||||
// "found when publishing the Web app");
|
||||
// }
|
||||
// } catch (Throwable e) {
|
||||
// log.error("Error occurred while publishing API '" + apiConfig.getName() +
|
||||
// "' with the context '" + apiConfig.getContext() +
|
||||
// "' and version '" + apiConfig.getVersion() + "'", e);
|
||||
// }
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// log.error("Error encountered while discovering annotated classes", e);
|
||||
// } catch (ClassNotFoundException e) {
|
||||
// log.error("Error while scanning class for annotations", e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//TODO : Need to implemented, to merge API Definitions in cases where implementation of an API Lies in two classes
|
||||
|
||||
@ -22,13 +22,13 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WSO2 Carbon - API Management Extensions Component</name>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -76,7 +76,7 @@
|
||||
<tasks>
|
||||
<copy todir="${basedir}/../../../repository/deployment/server/webapps" overwrite="true">
|
||||
<fileset dir="${basedir}/target">
|
||||
<include name="api-scep-mgt-v1.0.war"/>
|
||||
<include name="api-scep-mgt-v1.0.war" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</tasks>
|
||||
|
||||
@ -4,6 +4,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.certificate.mgt.jaxrs.beans.ErrorResponse;
|
||||
|
||||
@ -47,6 +48,7 @@ public interface CertificateMgtService {
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "certificate:sign-csr", name = "Sign CSR", description = "")
|
||||
@Permission(name = "Sign CSR", permission = "/device-mgt/certificates/manage")
|
||||
Response getSignedCertFromCSR(
|
||||
@ApiParam(
|
||||
name = "If-Modified-Since",
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
<!-- Device related APIs -->
|
||||
<Permission>
|
||||
<name>get certificate in the database</name>
|
||||
<path>/device-mgt/admin/certificate/GetSignCSR</path>
|
||||
<path>/device-mgt/certificate/GetSignCSR</path>
|
||||
<url>/certificates/scep/signcsr</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -72,7 +72,7 @@
|
||||
<tasks>
|
||||
<copy todir="${basedir}/../../../repository/deployment/server/webapps" overwrite="true">
|
||||
<fileset dir="${basedir}/target">
|
||||
<include name="api#certificate-mgt#v1.0.war"/>
|
||||
<include name="api#certificate-mgt#v1.0.war" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</tasks>
|
||||
|
||||
@ -2,6 +2,7 @@ package org.wso2.carbon.certificate.mgt.cert.jaxrs.api;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.CertificateList;
|
||||
import org.wso2.carbon.certificate.mgt.cert.jaxrs.api.beans.EnrollmentCertificate;
|
||||
@ -77,7 +78,7 @@ public interface CertificateManagementAdminService {
|
||||
message = "Internal Server Error. \n Server error occurred while adding certificates.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "certificate:manage", name = "Add certificates", description = "")
|
||||
@Permission(name = "Manage certificates", permission = "/device-mgt/certificates/manage")
|
||||
Response addCertificate(
|
||||
@ApiParam(
|
||||
name = "enrollmentCertificates",
|
||||
@ -135,7 +136,7 @@ public interface CertificateManagementAdminService {
|
||||
"Server error occurred while retrieving information requested certificate.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "certificate:view", name = "View certificates", description = "")
|
||||
@Permission(name = "View certificates", permission = "/device-mgt/certificates/view")
|
||||
Response getCertificate(
|
||||
@ApiParam(name = "serialNumber",
|
||||
value = "Provide the serial number of the certificate that you wish to get the details of",
|
||||
@ -207,7 +208,7 @@ public interface CertificateManagementAdminService {
|
||||
"Server error occurred while retrieving all certificates enrolled in the system.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "certificate:view", name = "View certificates", description = "")
|
||||
@Permission(name = "View certificates", permission = "/device-mgt/certificates/view")
|
||||
Response getAllCertificates(
|
||||
@ApiParam(
|
||||
name = "offset",
|
||||
@ -250,7 +251,7 @@ public interface CertificateManagementAdminService {
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while removing the certificate.",
|
||||
response = ErrorResponse.class)})
|
||||
@Scope(key = "certificate:manage", name = "Add certificates", description = "")
|
||||
@Permission(name = "Manage certificates", permission = "/device-mgt/certificates/manage")
|
||||
Response removeCertificate(
|
||||
@ApiParam(
|
||||
name = "serialNumber",
|
||||
|
||||
@ -21,13 +21,13 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - Certificate Management Core</name>
|
||||
<description>WSO2 Carbon - Certificate Management Core</description>
|
||||
|
||||
@ -22,14 +22,14 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WSO2 Carbon - Certificate Management Component</name>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ public class GCMNotificationStrategy implements NotificationStrategy {
|
||||
|
||||
HttpURLConnection conn = null;
|
||||
try {
|
||||
conn = (HttpURLConnection) (new URL(config.getProperty(GCM_ENDPOINT)).openConnection());
|
||||
conn = (HttpURLConnection) new URL(GCM_ENDPOINT).openConnection();
|
||||
conn.setDoOutput(true);
|
||||
conn.setUseCaches(false);
|
||||
conn.setFixedLengthStreamingMode(bytes.length);
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -29,12 +30,19 @@ public class RoleInfo {
|
||||
|
||||
@ApiModelProperty(name = "roleName", value = "The name of the role.", required = true)
|
||||
private String roleName;
|
||||
@ApiModelProperty(name = "scopes", value = "Lists out all the scopes associated with roles.",
|
||||
@ApiModelProperty(name = "permissions", value = "Lists out all the permissions associated with roles.",
|
||||
required = true, dataType = "List[java.lang.String]")
|
||||
private List<String> scopes;
|
||||
private String[] permissions;
|
||||
@ApiModelProperty(name = "users", value = "The list of users assigned to the selected role.",
|
||||
required = true, dataType = "List[java.lang.String]")
|
||||
private String[] users;
|
||||
@ApiModelProperty(name = "permissionList", value = "This contain the following, " +
|
||||
"\n resourcePath\tThe path related to the API.\n " +
|
||||
"displayName\tThe name of the permission that is shown " +
|
||||
"in the UI.\n" +
|
||||
"nodeList\tLists out the nested permissions.",
|
||||
required = true)
|
||||
private UIPermissionNode permissionList;
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
@ -44,12 +52,12 @@ public class RoleInfo {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public List<String> getScopes() {
|
||||
return scopes;
|
||||
public String[] getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setScopes(List<String> scopes) {
|
||||
this.scopes = scopes;
|
||||
public void setPermissions(String[] permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public String[] getUsers() {
|
||||
@ -60,4 +68,12 @@ public class RoleInfo {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public UIPermissionNode getPermissionList() {
|
||||
return permissionList;
|
||||
}
|
||||
|
||||
public void setPermissionList(UIPermissionNode permissionList) {
|
||||
this.permissionList = permissionList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -40,6 +40,7 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
@Consumes(APPLICATION_JSON)
|
||||
public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, MessageBodyReader<Object> {
|
||||
|
||||
public static final String DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
||||
private Gson gson;
|
||||
private static final String UTF_8 = "UTF-8";
|
||||
|
||||
@ -50,7 +51,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, Messag
|
||||
private Gson getGson() {
|
||||
if (gson == null) {
|
||||
final GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gson = gsonBuilder.create();
|
||||
gson = gsonBuilder.setDateFormat(DATE_FORMAT).create();
|
||||
}
|
||||
return gson;
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ActivityList;
|
||||
@ -92,7 +93,7 @@ public interface ActivityInfoProviderService {
|
||||
message = "Internal Server Error. \n Server error occurred while fetching activity data.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "activity:view", name = "View Activities", description = "")
|
||||
@Permission(name = "View Activities", permission = "/device-mgt/devices/owning/view")
|
||||
Response getActivity(
|
||||
@ApiParam(
|
||||
name = "id",
|
||||
@ -153,7 +154,7 @@ public interface ActivityInfoProviderService {
|
||||
message = "Internal Server Error. \n Server error occurred while fetching activity data.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "activity:view", name = "View Activities", description = "")
|
||||
@Permission(name = "View Activities", permission = "/device-mgt/devices/owning/view")
|
||||
Response getActivities(
|
||||
@ApiParam(
|
||||
name = "since",
|
||||
|
||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
@ -81,7 +82,7 @@ public interface ConfigurationManagementService {
|
||||
"platform configuration.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "configuration:view", name = "View Configurations", description = "")
|
||||
@Permission(name = "View Configurations", permission = "/device-mgt/configurations/view")
|
||||
Response getConfiguration(
|
||||
@ApiParam(
|
||||
name = "If-Modified-Since",
|
||||
@ -127,7 +128,7 @@ public interface ConfigurationManagementService {
|
||||
"Server error occurred while modifying general platform configuration.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "configuration:modify", name = "Modify Configurations", description = "")
|
||||
@Permission(name = "Manage configurations", permission = "/device-mgt/configurations/manage")
|
||||
Response updateConfiguration(
|
||||
@ApiParam(
|
||||
name = "configuration",
|
||||
|
||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.Feature;
|
||||
@ -92,7 +93,7 @@ public interface DeviceManagementService {
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the device list.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "device:view", name = "View Devices", description = "")
|
||||
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view")
|
||||
Response getDevices(
|
||||
@ApiParam(
|
||||
name = "name",
|
||||
@ -199,7 +200,7 @@ public interface DeviceManagementService {
|
||||
"Server error occurred while retrieving information requested device.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "device:view", name = "View Devices", description = "")
|
||||
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view")
|
||||
Response getDevice(
|
||||
@ApiParam(
|
||||
name = "type",
|
||||
@ -281,7 +282,7 @@ public interface DeviceManagementService {
|
||||
"Server error occurred while retrieving feature list of the device.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "device:view", name = "View Devices", description = "")
|
||||
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view")
|
||||
Response getFeaturesOfDevice(
|
||||
@ApiParam(
|
||||
name = "type",
|
||||
@ -357,7 +358,7 @@ public interface DeviceManagementService {
|
||||
"Server error occurred while enrolling the device.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "device:view", name = "View Devices", description = "")
|
||||
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view")
|
||||
Response searchDevices(
|
||||
@ApiParam(
|
||||
name = "offset",
|
||||
@ -436,8 +437,7 @@ public interface DeviceManagementService {
|
||||
"Server error occurred while retrieving installed application list of the device.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "device:view", name = "View Devices", description = "")
|
||||
|
||||
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view")
|
||||
Response getInstalledApplications(
|
||||
@ApiParam(
|
||||
name = "type",
|
||||
@ -533,7 +533,7 @@ public interface DeviceManagementService {
|
||||
"Server error occurred while retrieving operation list scheduled for the device.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "device:view", name = "View Devices", description = "")
|
||||
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view")
|
||||
Response getDeviceOperations(
|
||||
@ApiParam(
|
||||
name = "type",
|
||||
@ -631,7 +631,7 @@ public interface DeviceManagementService {
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
@Scope(key = "device:view", name = "View Devices", description = "")
|
||||
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view")
|
||||
Response getEffectivePolicyOfDevice(
|
||||
@ApiParam(
|
||||
name = "type",
|
||||
@ -683,7 +683,7 @@ public interface DeviceManagementService {
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
@Scope(key = "device:view", name = "View Devices", description = "")
|
||||
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view")
|
||||
Response getComplianceDataOfDevice(
|
||||
@ApiParam(
|
||||
name = "type",
|
||||
|
||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceTypeList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
@ -78,7 +79,7 @@ public interface DeviceTypeManagementService {
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
@Scope(key = "device-type:admin:view", name = "View device types", description = "")
|
||||
@Permission(name = "View Device Types", permission = "/device-mgt/devices/owning/view")
|
||||
Response getDeviceTypes(
|
||||
@ApiParam(
|
||||
name = "If-Modified-Since",
|
||||
|
||||
@ -82,7 +82,7 @@ public interface GroupManagementService {
|
||||
//
|
||||
// @GET
|
||||
// @Path("/{groupName}/devices")
|
||||
// @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/admin/groups/roles"})
|
||||
// @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/groups/roles"})
|
||||
// Response getDevicesOfGroup(@PathParam("groupName") String groupName, @QueryParam("offset") int offset,
|
||||
// @QueryParam("limit") int limit);
|
||||
//
|
||||
|
||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.NotificationList;
|
||||
@ -90,7 +91,7 @@ public interface NotificationManagementService {
|
||||
"\n Server error occurred while fetching the notification list.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "notification:view", name = "View and manage notifications", description = "")
|
||||
@Permission(name = "View notifications", permission = "/device-mgt/notifications/view")
|
||||
Response getNotifications(
|
||||
@ApiParam(
|
||||
name = "status",
|
||||
@ -142,7 +143,7 @@ public interface NotificationManagementService {
|
||||
message = "Error occurred while updating notification status.")
|
||||
}
|
||||
)
|
||||
@Scope(key = "notification:view", name = "View and manage notifications", description = "")
|
||||
@Permission(name = "View notifications", permission = "/device-mgt/notifications/view")
|
||||
Response updateNotificationStatus(
|
||||
@ApiParam(
|
||||
name = "id",
|
||||
|
||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
|
||||
@ -100,7 +101,7 @@ public interface PolicyManagementService {
|
||||
"Server error occurred while adding a new policy.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "policy:manage", name = "Add policies", description = "")
|
||||
@Permission(name = "Manage policies", permission = "/device-mgt/policies/manage")
|
||||
Response addPolicy(
|
||||
@ApiParam(
|
||||
name = "policy",
|
||||
@ -154,7 +155,7 @@ public interface PolicyManagementService {
|
||||
"policies."),
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "policy:view", name = "Views policies", description = "")
|
||||
@Permission(name = "View policies", permission = "/device-mgt/policies/view")
|
||||
Response getPolicies(
|
||||
@ApiParam(
|
||||
name = "If-Modified-Since",
|
||||
@ -220,7 +221,7 @@ public interface PolicyManagementService {
|
||||
"policy.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "policy:view", name = "View policies", description = "")
|
||||
@Permission(name = "View policies", permission = "/device-mgt/policies/view")
|
||||
Response getPolicy(
|
||||
@ApiParam(
|
||||
name = "id",
|
||||
@ -284,7 +285,7 @@ public interface PolicyManagementService {
|
||||
"Server error occurred while updating the policy.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "policy:manage", name = "Add policies", description = "")
|
||||
@Permission(name = "Manage policies", permission = "/device-mgt/policies/manage")
|
||||
Response updatePolicy(
|
||||
@ApiParam(
|
||||
name = "id",
|
||||
@ -330,7 +331,7 @@ public interface PolicyManagementService {
|
||||
"Server error occurred while bulk removing policies.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "policy:manage", name = "Add policies", description = "")
|
||||
@Permission(name = "Manage policies", permission = "/device-mgt/policies/manage")
|
||||
Response removePolicies(
|
||||
@ApiParam(
|
||||
name = "policyIds",
|
||||
@ -366,7 +367,7 @@ public interface PolicyManagementService {
|
||||
message = "ErrorResponse in activating policies.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "policy:manage", name = "Add policies", description = "")
|
||||
@Permission(name = "Manage policies", permission = "/device-mgt/policies/manage")
|
||||
Response activatePolicies(
|
||||
@ApiParam(
|
||||
name = "policyIds",
|
||||
@ -374,7 +375,7 @@ public interface PolicyManagementService {
|
||||
required = true)
|
||||
List<Integer> policyIds);
|
||||
|
||||
@PUT
|
||||
@POST
|
||||
@Path("/deactivate-policy")
|
||||
@ApiOperation(
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
@ -402,7 +403,7 @@ public interface PolicyManagementService {
|
||||
message = "ErrorResponse in deactivating policies.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "policy:manage", name = "Add policies", description = "")
|
||||
@Permission(name = "Manage policies", permission = "/device-mgt/policies/manage")
|
||||
Response deactivatePolicies(
|
||||
@ApiParam(
|
||||
name = "policyIds",
|
||||
@ -435,7 +436,7 @@ public interface PolicyManagementService {
|
||||
message = "ErrorResponse in deactivating policies.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "policy:manage", name = "Add policies", description = "")
|
||||
@Permission(name = "Manage policies", permission = "/device-mgt/policies/manage")
|
||||
Response applyChanges();
|
||||
|
||||
|
||||
@ -464,7 +465,7 @@ public interface PolicyManagementService {
|
||||
message = "Exception in updating policy priorities.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "policy:manage", name = "Add policies", description = "")
|
||||
@Permission(name = "Manage policies", permission = "/device-mgt/policies/manage")
|
||||
Response updatePolicyPriorities(
|
||||
@ApiParam(
|
||||
name = "priorityUpdatedPolicies",
|
||||
|
||||
@ -20,10 +20,12 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.Scope;
|
||||
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
@ -76,7 +78,7 @@ public interface RoleManagementService {
|
||||
message = "Internal Server Error. \n Server error occurred while fetching requested list of roles.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@org.wso2.carbon.apimgt.annotations.api.Scope(key = "role:view", name = "View roles", description = "")
|
||||
@Permission(name = "View Roles", permission = "/device-mgt/roles/view")
|
||||
Response getRoles(
|
||||
@ApiParam(
|
||||
name = "filter",
|
||||
@ -105,16 +107,16 @@ public interface RoleManagementService {
|
||||
@QueryParam("limit") int limit);
|
||||
|
||||
@GET
|
||||
@Path("/scopes")
|
||||
@Path("/{roleName}/permissions")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Getting authorization scopes.",
|
||||
value = "Getting permission details of a role.",
|
||||
notes = "In an organization an individual is associated a with set of responsibilities based on their " +
|
||||
"role. In EMM you are able to configure scopes based on the responsibilities carried " +
|
||||
"out by a role. Therefore if you wish to retrieve the scopes details of roles, you can do " +
|
||||
"role. In EMM you are able to configure permissions based on the responsibilities carried " +
|
||||
"out by a role. Therefore if you wish to retrieve the permission details of a role, you can do " +
|
||||
"so using this REST API.",
|
||||
response = List.class,
|
||||
response = UIPermissionNode.class,
|
||||
responseContainer = "List",
|
||||
tags = "Role Management"
|
||||
)
|
||||
@ -122,8 +124,8 @@ public interface RoleManagementService {
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the scopes list.",
|
||||
response = List.class,
|
||||
message = "OK. \n Successfully fetched the permission list of the given role.",
|
||||
response = UIPermissionNode.class,
|
||||
responseContainer = "List",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
@ -158,8 +160,13 @@ public interface RoleManagementService {
|
||||
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the permission list of the requested role.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@org.wso2.carbon.apimgt.annotations.api.Scope(key = "role:view", name = "View roles", description = "")
|
||||
Response getScopes(
|
||||
@Permission(name = "View Roles", permission = "/device-mgt/roles/view")
|
||||
Response getPermissionsOfRole(
|
||||
@ApiParam(
|
||||
name = "roleName",
|
||||
value = "Name of the role.",
|
||||
required = true)
|
||||
@PathParam("roleName") String roleName,
|
||||
@ApiParam(
|
||||
name = "If-Modified-Since",
|
||||
value = "Validates if the requested variant has not been modified since the time specified",
|
||||
@ -216,7 +223,7 @@ public interface RoleManagementService {
|
||||
"requested role.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@org.wso2.carbon.apimgt.annotations.api.Scope(key = "role:view", name = "View roles", description = "")
|
||||
@Permission(name = "View Roles", permission = "/device-mgt/roles/view")
|
||||
Response getRole(
|
||||
@ApiParam(
|
||||
name = "roleName",
|
||||
@ -276,7 +283,7 @@ public interface RoleManagementService {
|
||||
message = "Internal Server Error. \n Server error occurred while adding a new role.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@org.wso2.carbon.apimgt.annotations.api.Scope(key = "role:manage", name = "Add roles", description = "")
|
||||
@Permission(name = "Manage Roles", permission = "/device-mgt/roles/manage")
|
||||
Response addRole(
|
||||
@ApiParam(
|
||||
name = "role",
|
||||
@ -326,7 +333,7 @@ public interface RoleManagementService {
|
||||
message = "Internal Server Error. \n Server error occurred while updating the role.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@org.wso2.carbon.apimgt.annotations.api.Scope(key = "role:manage", name = "Add roles", description = "")
|
||||
@Permission(name = "Manage Roles", permission = "/device-mgt/roles/manage")
|
||||
Response updateRole(
|
||||
@ApiParam(
|
||||
name = "roleName",
|
||||
@ -363,7 +370,7 @@ public interface RoleManagementService {
|
||||
message = "Internal Server Error. \n Server error occurred while removing the role.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@org.wso2.carbon.apimgt.annotations.api.Scope(key = "role:manage", name = "Add roles", description = "")
|
||||
@Permission(name = "Manage Roles", permission = "/device-mgt/roles/manage")
|
||||
Response deleteRole(
|
||||
@ApiParam(
|
||||
name = "roleName",
|
||||
@ -421,7 +428,7 @@ public interface RoleManagementService {
|
||||
"Server error occurred while updating the user list of the role.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@org.wso2.carbon.apimgt.annotations.api.Scope(key = "role:manage", name = "Add roles", description = "")
|
||||
@Permission(name = "Manage Roles", permission = "/device-mgt/roles/manage")
|
||||
Response updateUsersOfRole(
|
||||
@ApiParam(
|
||||
name = "roleName",
|
||||
|
||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.*;
|
||||
|
||||
@ -83,7 +84,7 @@ public interface UserManagementService {
|
||||
message = "Internal Server Error. \n Server error occurred while adding a new user.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "user:manage", name = "Add users", description = "")
|
||||
@Permission(name = "Manage Users", permission = "/device-mgt/users/manage")
|
||||
Response addUser(
|
||||
@ApiParam(
|
||||
name = "user",
|
||||
@ -135,7 +136,7 @@ public interface UserManagementService {
|
||||
" fetching the requested user.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "user:view", name = "View users", description = "")
|
||||
@Permission(name = "View Users", permission = "/device-mgt/users/view")
|
||||
Response getUser(
|
||||
@ApiParam(
|
||||
name = "username",
|
||||
@ -192,7 +193,7 @@ public interface UserManagementService {
|
||||
"Server error occurred while updating the user.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "user:manage", name = "Add users", description = "")
|
||||
@Permission(name = "Manage Users", permission = "/device-mgt/users/manage")
|
||||
Response updateUser(
|
||||
@ApiParam(
|
||||
name = "username",
|
||||
@ -227,7 +228,7 @@ public interface UserManagementService {
|
||||
response = ErrorResponse.class
|
||||
)
|
||||
})
|
||||
@Scope(key = "user:manage", name = "Add users", description = "")
|
||||
@Permission(name = "Manage Users", permission = "/device-mgt/users/manage")
|
||||
Response removeUser(
|
||||
@ApiParam(name = "username", value = "Username of the user to be deleted.", required = true)
|
||||
@PathParam("username") String username);
|
||||
@ -276,7 +277,7 @@ public interface UserManagementService {
|
||||
" assigned to the user.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "user:view", name = "View users", description = "")
|
||||
@Permission(name = "View Users", permission = "/device-mgt/users/view")
|
||||
Response getRolesOfUser(
|
||||
@ApiParam(name = "username", value = "Username of the user.", required = true)
|
||||
@PathParam("username") String username);
|
||||
@ -287,12 +288,12 @@ public interface UserManagementService {
|
||||
httpMethod = "GET",
|
||||
value = "Get user list",
|
||||
notes = "If you wish to get the details of all the users registered with EMM, you can do so "
|
||||
+ "using the REST API",
|
||||
+ "using this REST API",
|
||||
tags = "User Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the requested role.",
|
||||
message = "OK. \n Successfully fetched the requested users.",
|
||||
response = BasicUserInfoList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
@ -319,7 +320,7 @@ public interface UserManagementService {
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the user list.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "user:view", name = "View users", description = "")
|
||||
@Permission(name = "View Users", permission = "/device-mgt/users/view")
|
||||
Response getUsers(
|
||||
@ApiParam(
|
||||
name = "filter",
|
||||
@ -342,6 +343,36 @@ public interface UserManagementService {
|
||||
required = false)
|
||||
@QueryParam("limit") int limit);
|
||||
|
||||
@GET
|
||||
@Path("/count")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Get user count",
|
||||
notes = "If you wish to get the user count registered with EMM, you can do so using this REST API",
|
||||
tags = "User Management")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the user count.",
|
||||
response = BasicUserInfoList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body")
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the user list.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Permission(name = "View Users", permission = "/device-mgt/users/view")
|
||||
Response getUserCount();
|
||||
|
||||
@GET
|
||||
@Path("/search/usernames")
|
||||
@ApiOperation(
|
||||
@ -386,7 +417,7 @@ public interface UserManagementService {
|
||||
"list that matches the given filter.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "user:view", name = "View users", description = "")
|
||||
@Permission(name = "View Users", permission = "/device-mgt/users/view")
|
||||
Response getUserNames(
|
||||
@ApiParam(
|
||||
name = "filter",
|
||||
@ -440,7 +471,7 @@ public interface UserManagementService {
|
||||
"Server error occurred while updating credentials of the user.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "user:view", name = "View users", description = "")
|
||||
@Permission(name = "View Users", permission = "/device-mgt/users/view")
|
||||
Response resetPassword(
|
||||
@ApiParam(
|
||||
name = "username",
|
||||
@ -483,7 +514,7 @@ public interface UserManagementService {
|
||||
"Server error occurred while updating credentials of the user.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "user:manage", name = "Add users", description = "")
|
||||
@Permission(name = "Manage Users", permission = "/device-mgt/users/manage")
|
||||
Response inviteExistingUsersToEnrollDevice(
|
||||
@ApiParam(
|
||||
name = "users",
|
||||
|
||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationWrapper;
|
||||
@ -74,7 +75,7 @@ public interface ApplicationManagementAdminService {
|
||||
"a given set of devices.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "application:manage", name = "Install/Uninstall applications", description = "")
|
||||
@Permission(name = "Install/Uninstall applications", permission = "/device-mgt/applications/manage")
|
||||
Response installApplication(
|
||||
@ApiParam(
|
||||
name = "applicationWrapper",
|
||||
@ -113,7 +114,7 @@ public interface ApplicationManagementAdminService {
|
||||
"a given set of devices.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "application:manage", name = "Install/Uninstall applications", description = "")
|
||||
@Permission(name = "Install/Uninstall applications", permission = "/device-mgt/applications/manage")
|
||||
Response uninstallApplication(
|
||||
@ApiParam(
|
||||
name = "applicationWrapper",
|
||||
|
||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
@ -85,7 +86,7 @@ public interface DeviceManagementAdminService {
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the device list.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "device:admin:view", name = "View Devices", description = "")
|
||||
@Permission(name = "View Devices", permission = "/device-mgt/devices/owning/view")
|
||||
Response getDevicesByName(
|
||||
@ApiParam(
|
||||
name = "name",
|
||||
|
||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Permission;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
|
||||
@ -68,7 +69,7 @@ public interface UserManagementAdminService {
|
||||
"Server error occurred while updating credentials of the user.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
@Scope(key = "user:admin:reset-password", name = "View users", description = "")
|
||||
@Permission(name = "View Users", permission = "/device-mgt/users/manage")
|
||||
Response resetUserPassword(
|
||||
@ApiParam(
|
||||
name = "username",
|
||||
|
||||
@ -122,7 +122,7 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
|
||||
int count = dmService.getActivityCountUpdatedAfter(timestamp);
|
||||
activityList.setCount(count);
|
||||
if (activities == null || activities.size() == 0) {
|
||||
if (isIfModifiedSinceSet || isSinceSet) {
|
||||
if (isIfModifiedSinceSet) {
|
||||
return Response.notModified().build();
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.CarbonContext;
|
||||
@ -50,6 +51,7 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -127,8 +129,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
request.setSince(sinceDate);
|
||||
result = dms.getAllDevices(request);
|
||||
if (result == null || result.getData() == null || result.getData().size() <= 0) {
|
||||
return Response.status(Response.Status.OK).entity("No device is modified " +
|
||||
"after the timestamp provided in 'since' filter").build();
|
||||
devices.setList(new ArrayList<Device>());
|
||||
devices.setCount(0);
|
||||
return Response.status(Response.Status.OK).entity(devices).build();
|
||||
}
|
||||
} else {
|
||||
result = dms.getAllDevices(request);
|
||||
|
||||
@ -221,14 +221,22 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
||||
RequestValidationUtil.validatePolicyIds(policyIds);
|
||||
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
|
||||
boolean policyDeleted = true;
|
||||
String invalidPolicyIds = "";
|
||||
try {
|
||||
PolicyAdministratorPoint pap = policyManagementService.getPAP();
|
||||
for (int i : policyIds) {
|
||||
Policy policy = pap.getPolicy(i);
|
||||
if (policy == null || !pap.deletePolicy(policy)) {
|
||||
if (policy == null) {
|
||||
invalidPolicyIds += i + ",";
|
||||
policyDeleted = false;
|
||||
}
|
||||
}
|
||||
if(policyDeleted) {
|
||||
for(int i : policyIds) {
|
||||
Policy policy = pap.getPolicy(i);
|
||||
pap.deletePolicy(policy);
|
||||
}
|
||||
}
|
||||
} catch (PolicyManagementException e) {
|
||||
String msg = "ErrorResponse occurred while removing policies";
|
||||
log.error(msg, e);
|
||||
@ -239,12 +247,14 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
||||
return Response.status(Response.Status.OK).entity("Policies have been successfully deleted").build();
|
||||
} else {
|
||||
//TODO:Check of this logic is correct
|
||||
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage("Policy doesn't exist").build()).build();
|
||||
String ModifiedInvalidPolicyIds = invalidPolicyIds.substring(0, invalidPolicyIds.length()-1);
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage("Policies with the policy ID " +
|
||||
ModifiedInvalidPolicyIds + " doesn't exist").build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@PUT
|
||||
@POST
|
||||
@Path("/activate-policy")
|
||||
@Override
|
||||
public Response activatePolicies(List<Integer> policyIds) {
|
||||
@ -276,7 +286,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
||||
}
|
||||
}
|
||||
|
||||
@PUT
|
||||
@POST
|
||||
@Path("/deactivate-policy")
|
||||
@Override
|
||||
public Response deactivatePolicies(List<Integer> policyIds) {
|
||||
|
||||
@ -20,6 +20,8 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.CarbonConstants;
|
||||
import org.wso2.carbon.base.MultitenantConstants;
|
||||
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
@ -32,11 +34,11 @@ 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.jaxrs.util.DeviceMgtUtil;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.SetReferenceTransformer;
|
||||
import org.wso2.carbon.user.api.AuthorizationManager;
|
||||
import org.wso2.carbon.user.api.UserRealm;
|
||||
import org.wso2.carbon.user.api.UserStoreException;
|
||||
import org.wso2.carbon.user.api.UserStoreManager;
|
||||
import org.wso2.carbon.user.api.*;
|
||||
import org.wso2.carbon.user.core.common.AbstractUserStoreManager;
|
||||
import org.wso2.carbon.user.mgt.UserRealmProxy;
|
||||
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
|
||||
import org.wso2.carbon.user.mgt.common.UserAdminException;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
@ -90,28 +92,66 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/scopes")
|
||||
@Path("/{roleName}/permissions")
|
||||
@Override
|
||||
public Response getScopes(
|
||||
public Response getPermissionsOfRole(
|
||||
@PathParam("roleName") String roleName,
|
||||
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||
|
||||
List<Scope> scopes = new ArrayList<>();
|
||||
RequestValidationUtil.validateRoleName(roleName);
|
||||
try {
|
||||
ScopeManagementService scopeManagementService = DeviceMgtAPIUtils.getScopeManagementService();
|
||||
if (scopeManagementService == null) {
|
||||
log.error("Scope management service initialization is failed, hence scopes will not be retrieved");
|
||||
} else {
|
||||
scopes = DeviceMgtUtil.convertAPIScopestoScopes(scopeManagementService.getAllScopes());
|
||||
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
|
||||
if (!userRealm.getUserStoreManager().isExistingRole(roleName)) {
|
||||
return Response.status(404).entity(new ErrorResponse.ErrorResponseBuilder().setMessage(
|
||||
"No role exists with the name '" + roleName + "'").build()).build();
|
||||
}
|
||||
return Response.status(Response.Status.OK).entity(scopes).build();
|
||||
} catch (ScopeManagementException e) {
|
||||
String msg = "Error occurred while retrieving the scopes";
|
||||
|
||||
final UIPermissionNode rolePermissions = this.getUIPermissionNode(roleName, userRealm);
|
||||
if (rolePermissions == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("No permissions found for the role '" + roleName + "'");
|
||||
}
|
||||
}
|
||||
return Response.status(Response.Status.OK).entity(rolePermissions).build();
|
||||
} catch (UserAdminException e) {
|
||||
String msg = "Error occurred while retrieving the permissions of role '" + roleName + "'";
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||
} catch (UserStoreException e) {
|
||||
String msg = "Error occurred while retrieving the underlying user realm attached to the " +
|
||||
"current logged in user";
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
private UIPermissionNode getUIPermissionNode(String roleName, UserRealm userRealm)
|
||||
throws UserAdminException {
|
||||
org.wso2.carbon.user.core.UserRealm userRealmCore = null;
|
||||
if (userRealm instanceof org.wso2.carbon.user.core.UserRealm) {
|
||||
userRealmCore = (org.wso2.carbon.user.core.UserRealm) userRealm;
|
||||
}
|
||||
final UserRealmProxy userRealmProxy = new UserRealmProxy(userRealmCore);
|
||||
final UIPermissionNode rolePermissions =
|
||||
userRealmProxy.getRolePermissions(roleName, MultitenantConstants.SUPER_TENANT_ID);
|
||||
UIPermissionNode[] deviceMgtPermissions = new UIPermissionNode[2];
|
||||
|
||||
for (UIPermissionNode permissionNode : rolePermissions.getNodeList()) {
|
||||
if (permissionNode.getResourcePath().equals("/permission/admin")) {
|
||||
for (UIPermissionNode node : permissionNode.getNodeList()) {
|
||||
if (node.getResourcePath().equals("/permission/admin/device-mgt")) {
|
||||
deviceMgtPermissions[0] = node;
|
||||
} else if (node.getResourcePath().equals("/permission/admin/login")) {
|
||||
deviceMgtPermissions[1] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rolePermissions.setNodeList(deviceMgtPermissions);
|
||||
return rolePermissions;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{roleName}")
|
||||
@Override
|
||||
@ -122,49 +162,62 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
||||
}
|
||||
RequestValidationUtil.validateRoleName(roleName);
|
||||
RoleInfo roleInfo = new RoleInfo();
|
||||
List<String> scopes = new ArrayList<>();
|
||||
try {
|
||||
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
|
||||
if (!userStoreManager.isExistingRole(roleName)) {
|
||||
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||
return Response.status(404).entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" +
|
||||
roleName + "'").build()).build();
|
||||
}
|
||||
ScopeManagementService scopeManagementService = DeviceMgtAPIUtils.getScopeManagementService();
|
||||
if (scopeManagementService == null) {
|
||||
log.error("Scope management service initialization is failed, hence scopes will not be retrieved");
|
||||
} else {
|
||||
scopes = DeviceMgtUtil.convertAPIScopesToScopeKeys(scopeManagementService.getScopesOfRole(roleName));
|
||||
}
|
||||
roleInfo.setRoleName(roleName);
|
||||
roleInfo.setUsers(userStoreManager.getUserListOfRole(roleName));
|
||||
roleInfo.setScopes(scopes);
|
||||
// Get the permission nodes and hand picking only device management and login perms
|
||||
final UIPermissionNode rolePermissions = this.getUIPermissionNode(roleName, userRealm);
|
||||
List<String> permList = new ArrayList<>();
|
||||
this.iteratePermissions(rolePermissions, permList);
|
||||
roleInfo.setPermissionList(rolePermissions);
|
||||
String[] permListAr = new String[permList.size()];
|
||||
roleInfo.setPermissions(permList.toArray(permListAr));
|
||||
|
||||
return Response.status(Response.Status.OK).entity(roleInfo).build();
|
||||
} catch (UserStoreException e) {
|
||||
} catch (UserStoreException | UserAdminException e) {
|
||||
String msg = "Error occurred while retrieving the user role '" + roleName + "'";
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||
} catch (ScopeManagementException e) {
|
||||
String msg = "Error occurred while retrieving the scopes";
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> iteratePermissions(UIPermissionNode uiPermissionNode, List<String> list) {
|
||||
for (UIPermissionNode permissionNode : uiPermissionNode.getNodeList()) {
|
||||
list.add(permissionNode.getResourcePath());
|
||||
if (permissionNode.getNodeList() != null && permissionNode.getNodeList().length > 0) {
|
||||
iteratePermissions(permissionNode, list);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Override
|
||||
public Response addRole(RoleInfo roleInfo) {
|
||||
RequestValidationUtil.validateRoleDetails(roleInfo);
|
||||
RequestValidationUtil.validateRoleName(roleInfo.getRoleName());
|
||||
|
||||
try {
|
||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Persisting the role in the underlying user store");
|
||||
}
|
||||
userStoreManager.addRole(roleInfo.getRoleName(), roleInfo.getUsers(), null);
|
||||
Permission[] permissions = null;
|
||||
if (roleInfo.getPermissions() != null && roleInfo.getPermissions().length > 0) {
|
||||
permissions = new Permission[roleInfo.getPermissions().length];
|
||||
for (int i = 0; i < permissions.length; i++) {
|
||||
String permission = roleInfo.getPermissions()[i];
|
||||
permissions[i] = new Permission(permission, CarbonConstants.UI_PERMISSION_ACTION);
|
||||
}
|
||||
}
|
||||
userStoreManager.addRole(roleInfo.getRoleName(), roleInfo.getUsers(), permissions);
|
||||
|
||||
//TODO fix what's returned in the entity
|
||||
return Response.created(new URI(API_BASE_PATH + "/" + roleInfo.getRoleName())).entity(
|
||||
@ -194,7 +247,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
||||
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
|
||||
final UserStoreManager userStoreManager = userRealm.getUserStoreManager();
|
||||
if (!userStoreManager.isExistingRole(roleName)) {
|
||||
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||
return Response.status(404).entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" +
|
||||
roleName + "'").build()).build();
|
||||
}
|
||||
@ -220,12 +273,14 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
||||
userStoreManager.updateUserListOfRole(newRoleName, usersToDelete, usersToAdd);
|
||||
}
|
||||
|
||||
if (roleInfo.getScopes() != null) {
|
||||
ScopeManagementService scopeManagementService = DeviceMgtAPIUtils.getScopeManagementService();
|
||||
if (scopeManagementService == null) {
|
||||
log.error("Scope management service initialization is failed, hence scopes will not be updated");
|
||||
} else {
|
||||
scopeManagementService.updateScopes(roleInfo.getScopes(), roleName);
|
||||
if (roleInfo.getPermissions() != null) {
|
||||
// Delete all authorizations for the current role before authorizing the permission tree
|
||||
authorizationManager.clearRoleAuthorization(roleName);
|
||||
if (roleInfo.getPermissions().length > 0) {
|
||||
for (int i = 0; i < roleInfo.getPermissions().length; i++) {
|
||||
String permission = roleInfo.getPermissions()[i];
|
||||
authorizationManager.authorizeRole(roleName, permission, CarbonConstants.UI_PERMISSION_ACTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO: Need to send the updated role information in the entity back to the client
|
||||
@ -236,11 +291,6 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||
} catch (ScopeManagementException e) {
|
||||
String msg = "Error occurred while updating scopes of role '" + roleName + "'";
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,12 +299,11 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
||||
@Override
|
||||
public Response deleteRole(@PathParam("roleName") String roleName) {
|
||||
RequestValidationUtil.validateRoleName(roleName);
|
||||
|
||||
try {
|
||||
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
|
||||
final UserStoreManager userStoreManager = userRealm.getUserStoreManager();
|
||||
if (!userStoreManager.isExistingRole(roleName)) {
|
||||
return Response.status(Response.Status.NOT_FOUND).entity(
|
||||
return Response.status(404).entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" +
|
||||
roleName + "'").build()).build();
|
||||
}
|
||||
@ -267,26 +316,12 @@ public class RoleManagementServiceImpl implements RoleManagementService {
|
||||
// Delete all authorizations for the current role before deleting
|
||||
authorizationManager.clearRoleAuthorization(roleName);
|
||||
|
||||
//removing scopes
|
||||
ScopeManagementService scopeManagementService = DeviceMgtAPIUtils.getScopeManagementService();
|
||||
if (scopeManagementService == null) {
|
||||
log.error("Scope management service initialization is failed, hence scopes will not be updated");
|
||||
} else {
|
||||
scopeManagementService.removeScopes(roleName);
|
||||
}
|
||||
|
||||
return Response.status(Response.Status.OK).entity("Role '" + roleName + "' has " +
|
||||
"successfully been deleted").build();
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} catch (UserStoreException e) {
|
||||
String msg = "Error occurred while deleting the role '" + roleName + "'";
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||
} catch (ScopeManagementException e) {
|
||||
String msg = "Error occurred while deleting scopes of role '" + roleName + "'";
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -316,6 +316,28 @@ public class UserManagementServiceImpl implements UserManagementService {
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/count")
|
||||
@Override
|
||||
public Response getUserCount() {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Getting the user count");
|
||||
}
|
||||
|
||||
try {
|
||||
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
|
||||
int userCount = userStoreManager.listUsers("*", -1).length;
|
||||
BasicUserInfoList result = new BasicUserInfoList();
|
||||
result.setCount(userCount);
|
||||
return Response.status(Response.Status.OK).entity(result).build();
|
||||
} catch (UserStoreException e) {
|
||||
String msg = "Error occurred while retrieving the user count.";
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/search/usernames")
|
||||
@Override
|
||||
|
||||
@ -45,334 +45,334 @@
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Devices</name>
|
||||
<path>/device-mgt/admin/devices</path>
|
||||
<path>/device-mgt/devices</path>
|
||||
<url>/</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<!-- Device related APIs -->
|
||||
<Permission>
|
||||
<name>List devices</name>
|
||||
<path>/device-mgt/admin/devices/List</path>
|
||||
<path>/device-mgt/devices/List</path>
|
||||
<url>/devices</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Search devices</name>
|
||||
<path>/device-mgt/admin/devices/Search</path>
|
||||
<path>/device-mgt/devices/Search</path>
|
||||
<url>/devices/search-devices</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View device</name>
|
||||
<path>/device-mgt/admin/devices/View</path>
|
||||
<path>/device-mgt/devices/View</path>
|
||||
<url>/devices/*/*</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View device info</name>
|
||||
<path>/device-mgt/admin/devices/View</path>
|
||||
<path>/device-mgt/devices/View</path>
|
||||
<url>/devices/*/*/info</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View device applications</name>
|
||||
<path>/device-mgt/admin/devices/View-Applications</path>
|
||||
<path>/device-mgt/devices/View-Applications</path>
|
||||
<url>/devices/*/*/applications</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View device effective-policy</name>
|
||||
<path>/device-mgt/admin/devices/View-Active-Policy</path>
|
||||
<path>/device-mgt/devices/View-Active-Policy</path>
|
||||
<url>/devices/*/*/effective-policy</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View devices feature</name>
|
||||
<path>/device-mgt/admin/devices/View-Features</path>
|
||||
<path>/device-mgt/devices/View-Features</path>
|
||||
<url>/devices/*/*/features</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View device operations</name>
|
||||
<path>/device-mgt/admin/devices/View-Operations</path>
|
||||
<path>/device-mgt/devices/View-Operations</path>
|
||||
<url>/devices/*/*/operations</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View Compliance Data</name>
|
||||
<path>/device-mgt/admin/devices/View-Compliance-Data</path>
|
||||
<path>/device-mgt/devices/View-Compliance-Data</path>
|
||||
<url>/devices/*/*/compliance-data</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>List all devices</name>
|
||||
<path>/device-mgt/admin/devices/Admin-View</path>
|
||||
<path>/device-mgt/devices/Admin-View</path>
|
||||
<url>/admin/devices</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View device types</name>
|
||||
<path>/device-mgt/admin/devices/Admin-DeviceType-View</path>
|
||||
<path>/device-mgt/devices/Admin-DeviceType-View</path>
|
||||
<url>/admin/device-types</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<!-- End of Device related APIs -->
|
||||
<Permission>
|
||||
<name>Policies</name>
|
||||
<path>/device-mgt/admin/policies</path>
|
||||
<path>/device-mgt/policies</path>
|
||||
<url>/</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<!-- Policy related APIs -->
|
||||
<Permission>
|
||||
<name>List policies</name>
|
||||
<path>/device-mgt/admin/policies/List</path>
|
||||
<path>/device-mgt/policies/List</path>
|
||||
<url>/policies</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Add Policy</name>
|
||||
<path>/device-mgt/admin/policies/Add</path>
|
||||
<path>/device-mgt/policies/Add</path>
|
||||
<url>/policies</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Activate policy</name>
|
||||
<path>/device-mgt/admin/policies/Activate-Policy</path>
|
||||
<path>/device-mgt/policies/Activate-Policy</path>
|
||||
<url>/policies/activate-policy</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Deactivate Policy</name>
|
||||
<path>/device-mgt/admin/policies/Deactivate-Policy</path>
|
||||
<path>/device-mgt/policies/Deactivate-Policy</path>
|
||||
<url>/policies/deactivate-policy</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Remove Policy</name>
|
||||
<path>/device-mgt/admin/policies/Remove</path>
|
||||
<path>/device-mgt/policies/Remove</path>
|
||||
<url>/policies/remove-policy</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View Policy</name>
|
||||
<path>/device-mgt/admin/policies/View</path>
|
||||
<path>/device-mgt/policies/View</path>
|
||||
<url>/policies/*</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Update Policy</name>
|
||||
<path>/device-mgt/admin/policies/Update</path>
|
||||
<path>/device-mgt/policies/Update</path>
|
||||
<url>/policies/*</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Update Policy</name>
|
||||
<path>/device-mgt/admin/policies/Update</path>
|
||||
<path>/device-mgt/policies/Update</path>
|
||||
<url>/policies/apply-changes</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Update Policy</name>
|
||||
<path>/device-mgt/admin/policies/Change-Priority</path>
|
||||
<path>/device-mgt/policies/Change-Priority</path>
|
||||
<url>/policies/priorities</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
<!-- End of Policy related APIs -->
|
||||
<Permission>
|
||||
<name>Notifications</name>
|
||||
<path>/device-mgt/admin/notifications</path>
|
||||
<path>/device-mgt/notifications</path>
|
||||
<url>/</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<!-- Notification related APIs -->
|
||||
<Permission>
|
||||
<name>View notifications</name>
|
||||
<path>/device-mgt/admin/notifications/View</path>
|
||||
<path>/device-mgt/notifications/View</path>
|
||||
<url>/notifications</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Mark checked notifications</name>
|
||||
<path>/device-mgt/admin/notifications/View</path>
|
||||
<path>/device-mgt/notifications/View</path>
|
||||
<url>/notifications/*/mark-checked</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
<!-- End of Notification related APIs -->
|
||||
<Permission>
|
||||
<name>Users</name>
|
||||
<path>/device-mgt/admin/users</path>
|
||||
<path>/device-mgt/users</path>
|
||||
<url>/</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<!-- User related APIs -->
|
||||
<Permission>
|
||||
<name>List users</name>
|
||||
<path>/device-mgt/admin/users/List</path>
|
||||
<path>/device-mgt/users/List</path>
|
||||
<url>/users</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Add user</name>
|
||||
<path>/device-mgt/admin/users/Add</path>
|
||||
<path>/device-mgt/users/Add</path>
|
||||
<url>/users</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>List users</name>
|
||||
<path>/device-mgt/admin/users/Search</path>
|
||||
<path>/device-mgt/users/Search</path>
|
||||
<url>/users/search/usernames</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Remove user</name>
|
||||
<path>/device-mgt/admin/users/Remove</path>
|
||||
<path>/device-mgt/users/Remove</path>
|
||||
<url>/users/*</url>
|
||||
<method>DELETE</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View user</name>
|
||||
<path>/device-mgt/admin/users/View</path>
|
||||
<path>/device-mgt/users/View</path>
|
||||
<url>/users/*</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Update user</name>
|
||||
<path>/device-mgt/admin/users/Update</path>
|
||||
<path>/device-mgt/users/Update</path>
|
||||
<url>/users/*</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Update user credentials</name>
|
||||
<path>/device-mgt/admin/users/Change-Password</path>
|
||||
<path>/device-mgt/users/Change-Password</path>
|
||||
<url>/users/*/credentials</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View assigned role</name>
|
||||
<path>/device-mgt/admin/roles/Assigned-Roles</path>
|
||||
<path>/device-mgt/roles/Assigned-Roles</path>
|
||||
<url>/users/*/roles</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Change any user credentials</name>
|
||||
<path>/device-mgt/admin/users/Change-Password-Any</path>
|
||||
<path>/device-mgt/users/Change-Password-Any</path>
|
||||
<url>/admin/users/*/credentials</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Send invitation mail</name>
|
||||
<path>/device-mgt/admin/users/Send-invitations</path>
|
||||
<path>/device-mgt/users/Send-invitations</path>
|
||||
<url>/users/send-invitation</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
<!-- End of User related APIs -->
|
||||
<Permission>
|
||||
<name>Roles</name>
|
||||
<path>/device-mgt/admin/roles</path>
|
||||
<path>/device-mgt/roles</path>
|
||||
<url>/</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<!-- Role related APIs -->
|
||||
<Permission>
|
||||
<name>List roles</name>
|
||||
<path>/device-mgt/admin/roles/List</path>
|
||||
<path>/device-mgt/roles/List</path>
|
||||
<url>/roles</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Add role</name>
|
||||
<path>/device-mgt/admin/roles/Add</path>
|
||||
<path>/device-mgt/roles/Add</path>
|
||||
<url>/roles</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Remove role</name>
|
||||
<path>/device-mgt/admin/roles/Remove</path>
|
||||
<path>/device-mgt/roles/Remove</path>
|
||||
<url>/roles/*</url>
|
||||
<method>DELETE</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View role</name>
|
||||
<path>/device-mgt/admin/roles/View</path>
|
||||
<path>/device-mgt/roles/View</path>
|
||||
<url>/roles/*</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Update role</name>
|
||||
<path>/device-mgt/admin/roles/Update</path>
|
||||
<path>/device-mgt/roles/Update</path>
|
||||
<url>/roles/*</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View role permissions</name>
|
||||
<path>/device-mgt/admin/roles/View-Permission</path>
|
||||
<path>/device-mgt/roles/View-Permission</path>
|
||||
<url>/roles/*/permissions</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Add Users to role</name>
|
||||
<path>/device-mgt/admin/roles/Add-Users</path>
|
||||
<path>/device-mgt/roles/Add-Users</path>
|
||||
<url>/roles/*/users</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
<!-- End of Role related APIs -->
|
||||
<Permission>
|
||||
<name>Configurations</name>
|
||||
<path>/device-mgt/admin/general-configs</path>
|
||||
<path>/device-mgt/general-configs</path>
|
||||
<url>/</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<!-- Configuration related APIs -->
|
||||
<Permission>
|
||||
<name>View configuration</name>
|
||||
<path>/device-mgt/admin/general-configuration/View</path>
|
||||
<path>/device-mgt/general-configuration/View</path>
|
||||
<url>/configuration</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Update configuration</name>
|
||||
<path>/device-mgt/admin/general-configuration/Update</path>
|
||||
<path>/device-mgt/general-configuration/Update</path>
|
||||
<url>/configuration</url>
|
||||
<method>PUT</method>
|
||||
</Permission>
|
||||
<!-- End of Configuration related APIs -->
|
||||
<Permission>
|
||||
<name>Activities</name>
|
||||
<path>/device-mgt/admin/activities</path>
|
||||
<path>/device-mgt/activities</path>
|
||||
<url>/</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<!-- Activity related APIs -->
|
||||
<Permission>
|
||||
<name>View Activities</name>
|
||||
<path>/device-mgt/admin/activities/View</path>
|
||||
<path>/device-mgt/devices/owning/view</path>
|
||||
<url>/activities</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>View Activity Details</name>
|
||||
<path>/device-mgt/admin/activities/View</path>
|
||||
<path>/device-mgt/devices/owning/view</path>
|
||||
<url>/activities/*</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<!-- End of Activity related APIs -->
|
||||
<Permission>
|
||||
<name>Applications</name>
|
||||
<path>/device-mgt/admin/applications</path>
|
||||
<path>/device-mgt/applications</path>
|
||||
<url>/</url>
|
||||
<method>GET</method>
|
||||
</Permission>
|
||||
<!-- Application related APIs -->
|
||||
<Permission>
|
||||
<name>Install Applications</name>
|
||||
<path>/device-mgt/admin/application/Install</path>
|
||||
<path>/device-mgt/application/Install</path>
|
||||
<url>/admin/applications/install-application</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Uninstall-Applications</name>
|
||||
<path>/device-mgt/admin/application/Uninstall</path>
|
||||
<path>/device-mgt/application/Uninstall</path>
|
||||
<url>/admin/applications/uninstall-application</url>
|
||||
<method>POST</method>
|
||||
</Permission>
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ public class DeviceGroupConstants {
|
||||
|
||||
public static class Permissions {
|
||||
public static final String[] DEFAULT_ADMIN_PERMISSIONS =
|
||||
{"/permission/device-mgt/admin/groups", "/permission/device-mgt/user/groups"};
|
||||
{"/permission/device-mgt/groups", "/permission/device-mgt/user/groups"};
|
||||
public static final String[] DEFAULT_OPERATOR_PERMISSIONS =
|
||||
{"/permission/device-mgt/user/groups/device_operation"};
|
||||
public static final String[] DEFAULT_STATS_MONITOR_PERMISSIONS =
|
||||
|
||||
@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.common.notification.mgt;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
|
||||
/**
|
||||
* DTO of Notification object which is used to communicate Operation notifications to MDM core.
|
||||
@ -58,6 +57,16 @@ public class Notification {
|
||||
"CHECKED: The message is in the read state.", required = true)
|
||||
private Status status;
|
||||
|
||||
@JsonProperty(value = "deviceIdentifier", required = false)
|
||||
@ApiModelProperty(name = "deviceIdentifier", value = "Defines the device ID related to the notification.",
|
||||
required = false)
|
||||
private String deviceIdentifier;
|
||||
|
||||
@JsonProperty(value = "devieType", required = false)
|
||||
@ApiModelProperty(name = "devieType", value = "Defines the device type related to the notification.",
|
||||
required = false)
|
||||
private String deviceType;
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
@ -90,6 +99,22 @@ public class Notification {
|
||||
this.operationId = operationId;
|
||||
}
|
||||
|
||||
public String getDeviceIdentifier() {
|
||||
return deviceIdentifier;
|
||||
}
|
||||
|
||||
public void setDeviceIdentifier(String deviceIdentifier) {
|
||||
this.deviceIdentifier = deviceIdentifier;
|
||||
}
|
||||
|
||||
public String getDevcieType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setDeviceType(String devieType) {
|
||||
this.deviceType = devieType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "notification {" +
|
||||
@ -97,6 +122,8 @@ public class Notification {
|
||||
", status=" + status +
|
||||
", description='" + description + '\'' +
|
||||
", operationId='" + operationId + '\'' +
|
||||
", deviceIdentifier='" + deviceIdentifier + '\'' +
|
||||
", deviceType='" + deviceType + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ import java.util.List;
|
||||
public class ActivityStatus {
|
||||
|
||||
public enum Status {
|
||||
IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED
|
||||
IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, INVALID, UNAUTHORIZED
|
||||
}
|
||||
|
||||
@ApiModelProperty(
|
||||
|
||||
@ -26,18 +26,10 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
*/
|
||||
public class Permission {
|
||||
|
||||
private String name; // permission name
|
||||
private String path; // permission string
|
||||
private String url; // url of the resource
|
||||
private String urlTemplate; // resource template
|
||||
private String method; // http method
|
||||
private String context;
|
||||
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public void setContext(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
@ -55,11 +47,19 @@ public class Permission {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getUrlTemplate() {
|
||||
return urlTemplate;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setUrlTemplate(String urlTemplate) {
|
||||
this.urlTemplate = urlTemplate;
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ public interface PermissionManagerService {
|
||||
* @throws PermissionManagementException If some unusual behaviour is observed while adding the
|
||||
* permission.
|
||||
*/
|
||||
void addPermission(Permission permission) throws PermissionManagementException;
|
||||
boolean addPermission(Permission permission) throws PermissionManagementException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -47,7 +47,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthorizationService {
|
||||
|
||||
private final static String CDM_ADMIN_PERMISSION = "/device-mgt/admin";
|
||||
private final static String CDM_ADMIN_PERMISSION = "/device-mgt/devices/any/permitted-actions-upon-owning-device";
|
||||
private final static String CDM_ADMIN = "Device Management Administrator";
|
||||
private static Log log = LogFactory.getLog(DeviceAccessAuthorizationServiceImpl.class);
|
||||
|
||||
public DeviceAccessAuthorizationServiceImpl() {
|
||||
@ -243,7 +244,10 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori
|
||||
}
|
||||
|
||||
private boolean addAdminPermissionToRegistry() throws PermissionManagementException {
|
||||
return PermissionUtils.putPermission(PermissionUtils.getAbsolutePermissionPath(CDM_ADMIN_PERMISSION));
|
||||
Permission permission = new Permission();
|
||||
permission.setName(CDM_ADMIN);
|
||||
permission.setPath(PermissionUtils.getAbsolutePermissionPath(CDM_ADMIN_PERMISSION));
|
||||
return PermissionUtils.putPermission(permission);
|
||||
}
|
||||
|
||||
private Map<String, String> getOwnershipOfDevices(List<Device> devices) {
|
||||
|
||||
@ -21,8 +21,8 @@ package org.wso2.carbon.device.mgt.core.config.permission;
|
||||
import org.apache.catalina.core.StandardContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.scannotation.AnnotationDB;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.device.mgt.common.permission.mgt.Permission;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.ws.rs.*;
|
||||
@ -91,21 +91,20 @@ public class AnnotationProcessor {
|
||||
* @param entityClasses
|
||||
* @return
|
||||
*/
|
||||
public List<org.wso2.carbon.device.mgt.common.permission.mgt.Permission>
|
||||
extractPermissions(Set<String> entityClasses) {
|
||||
public List<Permission>
|
||||
extractPermissions(Set<String> entityClasses) {
|
||||
|
||||
List<org.wso2.carbon.device.mgt.common.permission.mgt.Permission> permissions = new ArrayList<>();
|
||||
List<Permission> permissions = new ArrayList<>();
|
||||
|
||||
if (entityClasses != null && !entityClasses.isEmpty()) {
|
||||
|
||||
for (final String className : entityClasses) {
|
||||
|
||||
List<org.wso2.carbon.device.mgt.common.permission.mgt.Permission> resourcePermissions =
|
||||
List<Permission> resourcePermissions =
|
||||
AccessController.doPrivileged(new PrivilegedAction<List<org.wso2.carbon.device.mgt.common.permission.mgt.Permission>>() {
|
||||
public List<org.wso2.carbon.device.mgt.common.permission.mgt.Permission> run() {
|
||||
Class<?> clazz;
|
||||
List<org.wso2.carbon.device.mgt.common.permission.mgt.Permission> apiPermissions =
|
||||
new ArrayList<>();
|
||||
List<Permission> apiPermissions = new ArrayList<>();
|
||||
try {
|
||||
clazz = classLoader.loadClass(className);
|
||||
|
||||
@ -114,7 +113,7 @@ public class AnnotationProcessor {
|
||||
.class.getName());
|
||||
|
||||
Annotation apiAnno = clazz.getAnnotation(apiClazz);
|
||||
List<org.wso2.carbon.device.mgt.common.permission.mgt.Permission> resourceList;
|
||||
List<Permission> resourceList;
|
||||
|
||||
if (apiAnno != null) {
|
||||
|
||||
@ -170,15 +169,13 @@ public class AnnotationProcessor {
|
||||
* @return
|
||||
* @throws Throwable
|
||||
*/
|
||||
private List<org.wso2.carbon.device.mgt.common.permission.mgt.Permission>
|
||||
getApiResources(String resourceRootContext, Method[] annotatedMethods) throws Throwable {
|
||||
private List<Permission> getApiResources(String resourceRootContext, Method[] annotatedMethods) throws Throwable {
|
||||
|
||||
List<org.wso2.carbon.device.mgt.common.permission.mgt.Permission> permissions = new ArrayList<>();
|
||||
List<Permission> permissions = new ArrayList<>();
|
||||
Permission permission;
|
||||
String subCtx;
|
||||
for (Method method : annotatedMethods) {
|
||||
Annotation[] annotations = method.getDeclaredAnnotations();
|
||||
org.wso2.carbon.device.mgt.common.permission.mgt.Permission permission =
|
||||
new org.wso2.carbon.device.mgt.common.permission.mgt.Permission();
|
||||
|
||||
if (isHttpMethodAvailable(annotations)) {
|
||||
Annotation methodContextAnno = method.getAnnotation(pathClazz);
|
||||
@ -187,9 +184,7 @@ public class AnnotationProcessor {
|
||||
} else {
|
||||
subCtx = WILD_CARD;
|
||||
}
|
||||
permission.setContext(makeContextURLReady(resourceRootContext));
|
||||
permission.setUrlTemplate(makeContextURLReady(subCtx));
|
||||
|
||||
permission = new Permission();
|
||||
// this check is added to avoid url resolving conflict which happens due
|
||||
// to adding of '*' notation for dynamic path variables.
|
||||
if (WILD_CARD.equals(subCtx)) {
|
||||
@ -203,10 +198,14 @@ public class AnnotationProcessor {
|
||||
httpMethod = getHTTPMethodAnnotation(annotations[i]);
|
||||
if (httpMethod != null) {
|
||||
permission.setMethod(httpMethod);
|
||||
break;
|
||||
}
|
||||
if (annotations[i].annotationType().getName().
|
||||
equals(org.wso2.carbon.apimgt.annotations.api.Permission.class.getName())) {
|
||||
this.setPermission(method, permission);
|
||||
}
|
||||
}
|
||||
permissions.add(permission);
|
||||
|
||||
}
|
||||
}
|
||||
return permissions;
|
||||
@ -214,6 +213,7 @@ public class AnnotationProcessor {
|
||||
|
||||
/**
|
||||
* Read Method annotations indicating HTTP Methods
|
||||
*
|
||||
* @param annotation
|
||||
*/
|
||||
private String getHTTPMethodAnnotation(Annotation annotation) {
|
||||
@ -255,7 +255,7 @@ public class AnnotationProcessor {
|
||||
* @return
|
||||
*/
|
||||
private String makeContextURLReady(String context) {
|
||||
if (context != null && ! context.isEmpty()) {
|
||||
if (context != null && !context.isEmpty()) {
|
||||
if (context.startsWith("/")) {
|
||||
return context;
|
||||
} else {
|
||||
@ -294,19 +294,15 @@ public class AnnotationProcessor {
|
||||
* @param servletContext
|
||||
* @return null if cannot determin /WEB-INF/classes
|
||||
*/
|
||||
public static URL findWebInfClassesPath(ServletContext servletContext)
|
||||
{
|
||||
public static URL findWebInfClassesPath(ServletContext servletContext) {
|
||||
String path = servletContext.getRealPath("/WEB-INF/classes");
|
||||
if (path == null) return null;
|
||||
File fp = new File(path);
|
||||
if (fp.exists() == false) return null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
URI uri = fp.toURI();
|
||||
return uri.toURL();
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@ -329,4 +325,24 @@ public class AnnotationProcessor {
|
||||
return replacedPath.toString();
|
||||
}
|
||||
|
||||
private void setPermission(Method currentMethod, Permission permission) throws Throwable {
|
||||
Class<org.wso2.carbon.apimgt.annotations.api.Permission> permissionClass =
|
||||
(Class<org.wso2.carbon.apimgt.annotations.api.Permission>) classLoader.
|
||||
loadClass(org.wso2.carbon.apimgt.annotations.api.Permission.class.getName());
|
||||
Annotation permissionAnnotation = currentMethod.getAnnotation(permissionClass);
|
||||
if (permissionClass != null) {
|
||||
Method[] permissionClassMethods = permissionClass.getMethods();
|
||||
for (Method method : permissionClassMethods) {
|
||||
switch (method.getName()) {
|
||||
case "name":
|
||||
permission.setName(invokeMethod(method, permissionAnnotation, STRING));
|
||||
break;
|
||||
case "permission":
|
||||
permission.setPath(invokeMethod(method, permissionAnnotation, STRING));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.config.permission;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.permission.mgt.Permission;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents the information related to permissions.
|
||||
*/
|
||||
public class PermissionConfiguration {
|
||||
|
||||
private String scopeName;
|
||||
private String[] permissions;
|
||||
|
||||
public String getScopeName() {
|
||||
return scopeName;
|
||||
}
|
||||
|
||||
public void setScopeName(String scope) {
|
||||
this.scopeName = scope;
|
||||
}
|
||||
|
||||
public String[] getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(String[] permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
}
|
||||
@ -28,17 +28,10 @@ import org.wso2.carbon.device.mgt.common.permission.mgt.Permission;
|
||||
import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagerService;
|
||||
import org.wso2.carbon.device.mgt.core.config.permission.AnnotationProcessor;
|
||||
import org.wso2.carbon.device.mgt.core.config.permission.PermissionConfiguration;
|
||||
import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
|
||||
import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionUtils;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@ -416,12 +416,23 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
||||
boolean isOwnershipProvided = false;
|
||||
String status = request.getStatus();
|
||||
boolean isStatusProvided = false;
|
||||
Date since = request.getSince();
|
||||
boolean isSinceProvided = false;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String sql = "SELECT COUNT(d1.ID) AS DEVICE_COUNT FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, d.DEVICE_IDENTIFICATION, " +
|
||||
"t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID " +
|
||||
"AND d.TENANT_ID = ?";
|
||||
"t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t";
|
||||
|
||||
//Add query for last updated timestamp
|
||||
if (since != null) {
|
||||
sql = sql + " , DM_DEVICE_DETAIL dt";
|
||||
isSinceProvided = true;
|
||||
}
|
||||
sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||
//Add query for last updated timestamp
|
||||
if (isSinceProvided) {
|
||||
sql = sql + " AND dt.DEVICE_ID = d.ID AND dt.UPDATE_TIMESTAMP > ?";
|
||||
}
|
||||
if (deviceType != null && !deviceType.isEmpty()) {
|
||||
sql = sql + " AND t.NAME = ?";
|
||||
isDeviceTypeProvided = true;
|
||||
@ -452,12 +463,16 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
int paramIdx = 2;
|
||||
if (isSinceProvided) {
|
||||
stmt.setLong(paramIdx++, since.getTime());
|
||||
}
|
||||
if (isDeviceTypeProvided) {
|
||||
stmt.setString(paramIdx++, request.getDeviceType());
|
||||
}
|
||||
if (isDeviceNameProvided) {
|
||||
stmt.setString(paramIdx++, request.getDeviceName() + "%");
|
||||
}
|
||||
|
||||
stmt.setInt(paramIdx++, tenantId);
|
||||
if (isOwnershipProvided) {
|
||||
stmt.setString(paramIdx++, request.getOwnership());
|
||||
@ -748,10 +763,9 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String sql = "SELECT ID AS ENROLMENT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = (SELECT DISTINCT d.ID " +
|
||||
"FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID " +
|
||||
"AND d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? AND d.TENANT_ID = ?) " +
|
||||
"AND STATUS = ? AND TENANT_ID = ?";
|
||||
String sql = "SELECT e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID FROM DM_DEVICE d, DM_DEVICE_TYPE t " +
|
||||
"WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? AND d.TENANT_ID = ?) dtm " +
|
||||
"WHERE e.DEVICE_ID = dtm.ID AND e.STATUS = ? AND e.TENANT_ID = ?;";
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setString(1, deviceId.getId());
|
||||
stmt.setString(2, deviceId.getType());
|
||||
|
||||
@ -59,8 +59,21 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
|
||||
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
|
||||
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " +
|
||||
"d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t " +
|
||||
"WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||
"d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE " +
|
||||
"FROM DM_DEVICE d, DM_DEVICE_TYPE t ";
|
||||
|
||||
//Add the query to filter active devices on timestamp
|
||||
if (since != null) {
|
||||
sql = sql + ", DM_DEVICE_DETAIL dt";
|
||||
isSinceProvided = true;
|
||||
}
|
||||
|
||||
sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||
|
||||
//Add query for last updated timestamp
|
||||
if (isSinceProvided) {
|
||||
sql = sql + " AND dt.DEVICE_ID = d.ID AND dt.UPDATE_TIMESTAMP > ?";
|
||||
}
|
||||
|
||||
//Add the query for device-type
|
||||
if (deviceType != null && !deviceType.isEmpty()) {
|
||||
@ -73,12 +86,6 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
isDeviceNameProvided = true;
|
||||
}
|
||||
|
||||
//Add query for last updated timestamp
|
||||
if (since != null) {
|
||||
sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?";
|
||||
isSinceProvided = true;
|
||||
}
|
||||
|
||||
sql = sql + ") d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?";
|
||||
|
||||
//Add the query for ownership
|
||||
@ -102,15 +109,16 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
int paramIdx = 2;
|
||||
if (isSinceProvided) {
|
||||
stmt.setLong(paramIdx++, since.getTime());
|
||||
}
|
||||
if (isDeviceTypeProvided) {
|
||||
stmt.setString(paramIdx++, request.getDeviceType());
|
||||
}
|
||||
if (isDeviceNameProvided) {
|
||||
stmt.setString(paramIdx++, request.getDeviceName() + "%");
|
||||
}
|
||||
if (isSinceProvided) {
|
||||
stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime()));
|
||||
}
|
||||
|
||||
stmt.setInt(paramIdx++, tenantId);
|
||||
if (isOwnershipProvided) {
|
||||
stmt.setString(paramIdx++, request.getOwnership());
|
||||
|
||||
@ -31,6 +31,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -55,6 +56,8 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
boolean isOwnershipProvided = false;
|
||||
String status = request.getStatus();
|
||||
boolean isStatusProvided = false;
|
||||
Date since = request.getSince();
|
||||
boolean isSinceProvided = false;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String sql = "SELECT * FROM (SELECT ROWNUM offset, rs.* FROM (SELECT d1.ID AS DEVICE_ID, " +
|
||||
@ -62,7 +65,20 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
"e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, " +
|
||||
"e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
|
||||
"d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
|
||||
"DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||
"DM_DEVICE_TYPE t ";
|
||||
|
||||
//Add the query to filter active devices on timestamp
|
||||
if (since != null) {
|
||||
sql = sql + ", DM_DEVICE_DETAIL dt";
|
||||
isSinceProvided = true;
|
||||
}
|
||||
|
||||
sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||
|
||||
//Add query for last updated timestamp
|
||||
if (isSinceProvided) {
|
||||
sql = sql + " AND dt.DEVICE_ID = d.ID AND dt.UPDATE_TIMESTAMP > ?";
|
||||
}
|
||||
|
||||
//Add the query for device-type
|
||||
if (deviceType != null && !deviceType.isEmpty()) {
|
||||
@ -98,6 +114,9 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
int paramIdx = 2;
|
||||
if (isSinceProvided) {
|
||||
stmt.setLong(paramIdx++, since.getTime());
|
||||
}
|
||||
if (isDeviceTypeProvided) {
|
||||
stmt.setString(paramIdx++, request.getDeviceType());
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -54,6 +55,8 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
boolean isOwnershipProvided = false;
|
||||
String status = request.getStatus();
|
||||
boolean isStatusProvided = false;
|
||||
Date since = request.getSince();
|
||||
boolean isSinceProvided = false;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
|
||||
|
||||
@ -30,6 +30,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -54,13 +55,28 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
boolean isOwnershipProvided = false;
|
||||
String status = request.getStatus();
|
||||
boolean isStatusProvided = false;
|
||||
Date since = request.getSince();
|
||||
boolean isSinceProvided = false;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
|
||||
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
|
||||
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " +
|
||||
"d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t " +
|
||||
"WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||
"d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE " +
|
||||
"FROM DM_DEVICE d, DM_DEVICE_TYPE t ";
|
||||
|
||||
//Add the query to filter active devices on timestamp
|
||||
if (since != null) {
|
||||
sql = sql + ", DM_DEVICE_DETAIL dt";
|
||||
isSinceProvided = true;
|
||||
}
|
||||
|
||||
sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||
|
||||
//Add query for last updated timestamp
|
||||
if (isSinceProvided) {
|
||||
sql = sql + " AND dt.DEVICE_ID = d.ID AND dt.UPDATE_TIMESTAMP > ?";
|
||||
}
|
||||
|
||||
//Add the query for device-type
|
||||
if (deviceType != null && !deviceType.isEmpty()) {
|
||||
@ -96,6 +112,9 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
int paramIdx = 2;
|
||||
if (isSinceProvided) {
|
||||
stmt.setLong(paramIdx++, since.getTime());
|
||||
}
|
||||
if (isDeviceTypeProvided) {
|
||||
stmt.setString(paramIdx++, request.getDeviceType());
|
||||
}
|
||||
@ -143,7 +162,8 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " +
|
||||
"d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
|
||||
"DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND t.NAME = ? " +
|
||||
"AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
"AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY ENROLMENT_ID" +
|
||||
" OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setString(1, request.getDeviceType());
|
||||
stmt.setInt(2, tenantId);
|
||||
@ -177,7 +197,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
"AS DEVICE_TYPE FROM DM_DEVICE d, (SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, " +
|
||||
"e.DEVICE_ID, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " +
|
||||
"e.TENANT_ID = ? AND e.OWNER = ?) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " +
|
||||
"AND t.ID = d.DEVICE_TYPE_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
"AND t.ID = d.DEVICE_TYPE_ID ORDER BY ENROLMENT_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
stmt.setString(2, request.getOwner());
|
||||
@ -211,7 +231,8 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, " +
|
||||
"d.DESCRIPTION, t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, " +
|
||||
"DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.NAME LIKE ? AND d.TENANT_ID = ?) d1 " +
|
||||
"WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
"WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY ENROLMENT_ID " +
|
||||
"OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setString(1, request.getDeviceName() + "%");
|
||||
stmt.setInt(2, tenantId);
|
||||
@ -246,8 +267,8 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM (SELECT e.ID, e.DEVICE_ID, e.OWNER, e.OWNERSHIP, e.STATUS, " +
|
||||
"e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e " +
|
||||
"WHERE TENANT_ID = ? AND OWNERSHIP = ?) e, DM_DEVICE d, DM_DEVICE_TYPE t " +
|
||||
"WHERE DEVICE_ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? OFFSET ? " +
|
||||
"ROWS FETCH NEXT ? ROWS ONLY";
|
||||
"WHERE DEVICE_ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? ORDER BY ENROLMENT_ID " +
|
||||
"OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
stmt.setString(2, request.getOwnership());
|
||||
@ -282,8 +303,8 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM (SELECT e.ID, e.DEVICE_ID, e.OWNER, e.OWNERSHIP, e.STATUS, " +
|
||||
"e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e " +
|
||||
"WHERE TENANT_ID = ? AND STATUS = ?) e, DM_DEVICE d, DM_DEVICE_TYPE t " +
|
||||
"WHERE DEVICE_ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? OFFSET ? ROWS" +
|
||||
" FETCH NEXT ? ROWS ONLY";
|
||||
"WHERE DEVICE_ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? ORDER BY ENROLMENT_ID " +
|
||||
"OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
stmt.setString(2, request.getStatus());
|
||||
@ -337,7 +358,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, " +
|
||||
"d.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
|
||||
"DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?" + filteringString +
|
||||
") d1 WHERE d1.ID = e.DEVICE_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
") d1 WHERE d1.ID = e.DEVICE_ID ORDER BY ENROLMENT_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
|
||||
@ -31,7 +31,6 @@ import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagement
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
||||
import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagerService;
|
||||
import org.wso2.carbon.device.mgt.common.scope.mgt.ScopeManagementService;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
|
||||
@ -52,7 +51,6 @@ import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
|
||||
import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
|
||||
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
|
||||
import org.wso2.carbon.device.mgt.core.scope.mgt.ScopeManagementServiceImpl;
|
||||
import org.wso2.carbon.device.mgt.core.scope.mgt.dao.ScopeManagementDAOFactory;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
||||
@ -243,10 +241,6 @@ public class DeviceManagementServiceComponent {
|
||||
= new NotificationManagementServiceImpl();
|
||||
bundleContext.registerService(NotificationManagementService.class.getName(), notificationManagementService, null);
|
||||
|
||||
/* Registering Scope Management Service */
|
||||
ScopeManagementService scopeManagementService = new ScopeManagementServiceImpl();
|
||||
bundleContext.registerService(ScopeManagementService.class.getName(), scopeManagementService, null);
|
||||
|
||||
/* Registering DeviceAccessAuthorization Service */
|
||||
DeviceAccessAuthorizationService deviceAccessAuthorizationService = new DeviceAccessAuthorizationServiceImpl();
|
||||
DeviceManagementDataHolder.getInstance().setDeviceAccessAuthorizationService(deviceAccessAuthorizationService);
|
||||
|
||||
@ -51,7 +51,7 @@ public class SQLServerNotificationDAOImpl extends AbstractNotificationDAOImpl {
|
||||
"NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " +
|
||||
"TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?";
|
||||
|
||||
sql = sql + " OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
sql = sql + " ORDER BY n1.NOTIFICATION_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
@ -92,7 +92,7 @@ public class SQLServerNotificationDAOImpl extends AbstractNotificationDAOImpl {
|
||||
"TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " +
|
||||
"AND TENANT_ID = ?";
|
||||
|
||||
sql = sql + " OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
sql = sql + " ORDER BY n1.NOTIFICATION_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
|
||||
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, tenantId);
|
||||
|
||||
@ -131,6 +131,8 @@ public class NotificationDAOUtil {
|
||||
notification.setOperationId(rs.getInt("OPERATION_ID"));
|
||||
notification.setDescription(rs.getString("DESCRIPTION"));
|
||||
notification.setStatus(rs.getString("STATUS"));
|
||||
notification.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
|
||||
notification.setDeviceType(rs.getString("DEVICE_TYPE"));
|
||||
return notification;
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,10 +24,7 @@ import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.*;
|
||||
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
||||
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.operation.mgt.OperationManager;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.*;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
|
||||
@ -90,22 +87,29 @@ public class OperationManagerImpl implements OperationManager {
|
||||
|
||||
@Override
|
||||
public Activity addOperation(Operation operation,
|
||||
List<DeviceIdentifier> deviceIds) throws OperationManagementException, InvalidDeviceException {
|
||||
List<DeviceIdentifier> deviceIds)
|
||||
throws OperationManagementException, InvalidDeviceException {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("operation:[" + operation.toString() + "]");
|
||||
for (DeviceIdentifier deviceIdentifier : deviceIds) {
|
||||
log.debug("device identifier id:[" + deviceIdentifier.getId() + "] type:[" +
|
||||
deviceIdentifier.getType() + "]");
|
||||
deviceIdentifier.getType() + "]");
|
||||
}
|
||||
}
|
||||
try {
|
||||
DeviceIDHolder deviceIDHolder = DeviceManagerUtil.validateDeviceIdentifiers(deviceIds);
|
||||
List<DeviceIdentifier> validDeviceIds = deviceIDHolder.getValidDeviceIDList();
|
||||
DeviceIDHolder deviceValidationResult = DeviceManagerUtil.validateDeviceIdentifiers(deviceIds);
|
||||
List<DeviceIdentifier> validDeviceIds = deviceValidationResult.getValidDeviceIDList();
|
||||
if (validDeviceIds.size() > 0) {
|
||||
List<DeviceIdentifier> authorizedDeviceList = this.getAuthorizedDevices(operation, deviceIds);
|
||||
DeviceIDHolder deviceAuthorizationResult = this.authorizeDevices(operation, validDeviceIds);
|
||||
List<DeviceIdentifier> authorizedDeviceList = deviceAuthorizationResult.getValidDeviceIDList();
|
||||
if (authorizedDeviceList.size() <= 0) {
|
||||
log.info("User : " + getUser() + " is not authorized to perform operations on given device-list.");
|
||||
return null;
|
||||
Activity activity = new Activity();
|
||||
//Send the operation statuses only for admin triggered operations
|
||||
String deviceType = validDeviceIds.get(0).getType();
|
||||
activity.setActivityStatus(this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult,
|
||||
deviceType));
|
||||
return activity;
|
||||
}
|
||||
|
||||
OperationManagementDAOFactory.beginTransaction();
|
||||
@ -117,13 +121,13 @@ public class OperationManagerImpl implements OperationManager {
|
||||
boolean hasExistingTaskOperation;
|
||||
int enrolmentId;
|
||||
if (operationDto.getControl() ==
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT) {
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT) {
|
||||
isNotRepeated = true;
|
||||
}
|
||||
|
||||
//TODO have to create a sql to load device details from deviceDAO using single query.
|
||||
String operationCode = operationDto.getCode();
|
||||
for (DeviceIdentifier deviceId : deviceIds) {
|
||||
for (DeviceIdentifier deviceId : authorizedDeviceList) {
|
||||
Device device = getDevice(deviceId);
|
||||
enrolmentId = device.getEnrolmentInfo().getId();
|
||||
//Do not repeat the task operations
|
||||
@ -134,8 +138,8 @@ public class OperationManagerImpl implements OperationManager {
|
||||
}
|
||||
} else if (isNotRepeated) {
|
||||
operationDAO.updateEnrollmentOperationsStatus(enrolmentId, operationCode,
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING,
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.REPEATED);
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING,
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.REPEATED);
|
||||
operationMappingDAO.addOperationMapping(operationId, enrolmentId);
|
||||
} else {
|
||||
operationMappingDAO.addOperationMapping(operationId, enrolmentId);
|
||||
@ -145,8 +149,8 @@ public class OperationManagerImpl implements OperationManager {
|
||||
notificationStrategy.execute(new NotificationContext(deviceId, operation));
|
||||
} catch (PushNotificationExecutionFailedException e) {
|
||||
log.error("Error occurred while sending push notifications to " +
|
||||
deviceId.getType() + " device carrying id '" +
|
||||
deviceId + "'", e);
|
||||
deviceId.getType() + " device carrying id '" +
|
||||
deviceId + "'", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -157,6 +161,12 @@ public class OperationManagerImpl implements OperationManager {
|
||||
activity.setCode(operationCode);
|
||||
activity.setCreatedTimeStamp(new Date().toString());
|
||||
activity.setType(Activity.Type.valueOf(operationDto.getType().toString()));
|
||||
//For now set the operation statuses only for admin triggered operations
|
||||
if (!isScheduledOperation) {
|
||||
//Get the device-type from 1st valid DeviceIdentifier. We know the 1st element is definitely there.
|
||||
String deviceType = validDeviceIds.get(0).getType();
|
||||
activity.setActivityStatus(this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult, deviceType));
|
||||
}
|
||||
return activity;
|
||||
} else {
|
||||
throw new InvalidDeviceException("Invalid device Identifiers found.");
|
||||
@ -171,21 +181,64 @@ public class OperationManagerImpl implements OperationManager {
|
||||
}
|
||||
}
|
||||
|
||||
private List<DeviceIdentifier> getAuthorizedDevices(
|
||||
private List<ActivityStatus> getActivityStatus(DeviceIDHolder deviceIdValidationResult, DeviceIDHolder deviceAuthResult,
|
||||
String deviceType) {
|
||||
List<ActivityStatus> activityStatuses = new ArrayList<>();
|
||||
ActivityStatus activityStatus;
|
||||
//Add the invalid DeviceIds
|
||||
for (String id : deviceIdValidationResult.getErrorDeviceIdList()) {
|
||||
activityStatus = new ActivityStatus();
|
||||
activityStatus.setDeviceIdentifier(new DeviceIdentifier(id,deviceType));
|
||||
activityStatus.setStatus(ActivityStatus.Status.INVALID);
|
||||
activityStatuses.add(activityStatus);
|
||||
}
|
||||
|
||||
//Add the unauthorized DeviceIds
|
||||
for (String id : deviceAuthResult.getErrorDeviceIdList()) {
|
||||
activityStatus = new ActivityStatus();
|
||||
activityStatus.setDeviceIdentifier(new DeviceIdentifier(id, deviceType));
|
||||
activityStatus.setStatus(ActivityStatus.Status.UNAUTHORIZED);
|
||||
activityStatuses.add(activityStatus);
|
||||
}
|
||||
|
||||
//Add the authorized DeviceIds
|
||||
for (DeviceIdentifier id : deviceAuthResult.getValidDeviceIDList()) {
|
||||
activityStatus = new ActivityStatus();
|
||||
activityStatus.setDeviceIdentifier(id);
|
||||
activityStatus.setStatus(ActivityStatus.Status.PENDING);
|
||||
activityStatuses.add(activityStatus);
|
||||
}
|
||||
return activityStatuses;
|
||||
}
|
||||
|
||||
private DeviceIDHolder authorizeDevices(
|
||||
Operation operation, List<DeviceIdentifier> deviceIds) throws OperationManagementException {
|
||||
List<DeviceIdentifier> authorizedDeviceList;
|
||||
List<String> unAuthorizedDeviceList = new ArrayList<>();
|
||||
DeviceIDHolder deviceIDHolder = new DeviceIDHolder();
|
||||
try {
|
||||
if (operation != null && isAuthenticationSkippedOperation(operation)) {
|
||||
authorizedDeviceList = deviceIds;
|
||||
} else {
|
||||
authorizedDeviceList = DeviceManagementDataHolder.getInstance().
|
||||
getDeviceAccessAuthorizationService().isUserAuthorized(deviceIds).getAuthorizedDevices();
|
||||
boolean isAuthorized;
|
||||
authorizedDeviceList = new ArrayList<>();
|
||||
for (DeviceIdentifier devId : deviceIds) {
|
||||
isAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
||||
isUserAuthorized(devId);
|
||||
if (isAuthorized) {
|
||||
authorizedDeviceList.add(devId);
|
||||
} else {
|
||||
unAuthorizedDeviceList.add(devId.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
throw new OperationManagementException("Error occurred while authorizing access to the devices for user :" +
|
||||
this.getUser(), e);
|
||||
this.getUser(), e);
|
||||
}
|
||||
return authorizedDeviceList;
|
||||
deviceIDHolder.setValidDeviceIDList(authorizedDeviceList);
|
||||
deviceIDHolder.setErrorDeviceIdList(unAuthorizedDeviceList);
|
||||
return deviceIDHolder;
|
||||
}
|
||||
|
||||
private Device getDevice(DeviceIdentifier deviceId) throws OperationManagementException {
|
||||
@ -195,7 +248,7 @@ public class OperationManagerImpl implements OperationManager {
|
||||
return deviceDAO.getDevice(deviceId, tenantId);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementException("Error occurred while opening a connection the data " +
|
||||
"source", e);
|
||||
"source", e);
|
||||
} catch (DeviceManagementDAOException e) {
|
||||
OperationManagementDAOFactory.rollbackTransaction();
|
||||
throw new OperationManagementException(
|
||||
@ -211,7 +264,8 @@ public class OperationManagerImpl implements OperationManager {
|
||||
|
||||
if (!isActionAuthorized(deviceId)) {
|
||||
throw new OperationManagementException("User '" + getUser() + "' is not authorized to access the '" +
|
||||
deviceId.getType() + "' device, which carries the identifier '" + deviceId.getId() + "'");
|
||||
deviceId.getType() + "' device, which carries the identifier '" +
|
||||
deviceId.getId() + "'");
|
||||
}
|
||||
|
||||
int enrolmentId = this.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE);
|
||||
@ -231,8 +285,8 @@ public class OperationManagerImpl implements OperationManager {
|
||||
}
|
||||
} catch (OperationManagementDAOException e) {
|
||||
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
||||
"operations assigned for '" + deviceId.getType() +
|
||||
"' device '" + deviceId.getId() + "'", e);
|
||||
"operations assigned for '" + deviceId.getType() +
|
||||
"' device '" + deviceId.getId() + "'", e);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementException(
|
||||
"Error occurred while opening a connection to the data source", e);
|
||||
@ -250,14 +304,15 @@ public class OperationManagerImpl implements OperationManager {
|
||||
|
||||
if (!isActionAuthorized(deviceId)) {
|
||||
throw new OperationManagementException("User '" + getUser() + "' is not authorized to access the '" +
|
||||
deviceId.getType() + "' device, which carries the identifier '" + deviceId.getId() + "'");
|
||||
deviceId.getType() + "' device, which carries the identifier '" +
|
||||
deviceId.getId() + "'");
|
||||
}
|
||||
|
||||
int enrolmentId = this.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE);
|
||||
if (enrolmentId < 0) {
|
||||
throw new OperationManagementException("Device not found for given device " +
|
||||
"Identifier:" + deviceId.getId() + " and given type" +
|
||||
deviceId.getType());
|
||||
"Identifier:" + deviceId.getId() + " and given type" +
|
||||
deviceId.getType());
|
||||
}
|
||||
|
||||
try {
|
||||
@ -275,8 +330,8 @@ public class OperationManagerImpl implements OperationManager {
|
||||
paginationResult.setRecordsFiltered(count);
|
||||
} catch (OperationManagementDAOException e) {
|
||||
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
||||
"operations assigned for '" + deviceId.getType() +
|
||||
"' device '" + deviceId.getId() + "'", e);
|
||||
"operations assigned for '" + deviceId.getType() +
|
||||
"' device '" + deviceId.getId() + "'", e);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementException(
|
||||
"Error occurred while opening a connection to the data source", e);
|
||||
@ -289,7 +344,7 @@ public class OperationManagerImpl implements OperationManager {
|
||||
|
||||
@Override
|
||||
public List<? extends Operation> getPendingOperations(DeviceIdentifier deviceId) throws
|
||||
OperationManagementException {
|
||||
OperationManagementException {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Device identifier id:[" + deviceId.getId() + "] type:[" + deviceId.getType() + "]");
|
||||
}
|
||||
@ -298,14 +353,15 @@ public class OperationManagerImpl implements OperationManager {
|
||||
|
||||
if (!isActionAuthorized(deviceId)) {
|
||||
throw new OperationManagementException("User '" + getUser() + "' is not authorized to access the '" +
|
||||
deviceId.getType() + "' device, which carries the identifier '" + deviceId.getId() + "'");
|
||||
deviceId.getType() + "' device, which carries the identifier '" +
|
||||
deviceId.getId() + "'");
|
||||
}
|
||||
|
||||
int enrolmentId = this.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE);
|
||||
if (enrolmentId < 0) {
|
||||
throw new OperationManagementException("Device not found for the given device Identifier:" +
|
||||
deviceId.getId() + " and given type:" +
|
||||
deviceId.getType());
|
||||
deviceId.getId() + " and given type:" +
|
||||
deviceId.getType());
|
||||
}
|
||||
|
||||
try {
|
||||
@ -326,8 +382,8 @@ public class OperationManagerImpl implements OperationManager {
|
||||
Collections.sort(operations, new OperationCreateTimeComparator());
|
||||
} catch (OperationManagementDAOException e) {
|
||||
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
||||
"pending operations assigned for '" + deviceId.getType() +
|
||||
"' device '" + deviceId.getId() + "'", e);
|
||||
"pending operations assigned for '" + deviceId.getType() +
|
||||
"' device '" + deviceId.getId() + "'", e);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementException(
|
||||
"Error occurred while opening a connection to the data source", e);
|
||||
@ -346,36 +402,37 @@ public class OperationManagerImpl implements OperationManager {
|
||||
|
||||
if (!isActionAuthorized(deviceId)) {
|
||||
throw new OperationManagementException("User '" + getUser() + "' is not authorized to access the '" +
|
||||
deviceId.getType() + "' device, which carries the identifier '" + deviceId.getId() + "'");
|
||||
deviceId.getType() + "' device, which carries the identifier '" +
|
||||
deviceId.getId() + "'");
|
||||
}
|
||||
|
||||
int enrolmentId = this.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE);
|
||||
if (enrolmentId < 0) {
|
||||
throw new OperationManagementException("Device not found for given device " +
|
||||
"Identifier:" + deviceId.getId() + " and given type" +
|
||||
deviceId.getType());
|
||||
"Identifier:" + deviceId.getId() + " and given type" +
|
||||
deviceId.getType());
|
||||
}
|
||||
|
||||
try {
|
||||
OperationManagementDAOFactory.openConnection();
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO.
|
||||
getNextOperation(enrolmentId);
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO.getNextOperation(
|
||||
enrolmentId);
|
||||
if (dtoOperation != null) {
|
||||
if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND.
|
||||
equals(dtoOperation.getType())) {
|
||||
if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND.equals(dtoOperation.getType()
|
||||
)) {
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
|
||||
commandOperation =
|
||||
(org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
|
||||
getOperation(dtoOperation.getId());
|
||||
getOperation(dtoOperation.getId());
|
||||
dtoOperation.setEnabled(commandOperation.isEnabled());
|
||||
} else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG.
|
||||
equals(dtoOperation.getType())) {
|
||||
} else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG.equals(dtoOperation.
|
||||
getType())) {
|
||||
dtoOperation = configOperationDAO.getOperation(dtoOperation.getId());
|
||||
} else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.PROFILE.
|
||||
equals(dtoOperation.getType())) {
|
||||
} else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.PROFILE.equals(dtoOperation.
|
||||
getType())) {
|
||||
dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId());
|
||||
} else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.POLICY.
|
||||
equals(dtoOperation.getType())) {
|
||||
} else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.POLICY.equals(dtoOperation.
|
||||
getType())) {
|
||||
dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId());
|
||||
}
|
||||
operation = OperationDAOUtil.convertOperation(dtoOperation);
|
||||
@ -400,7 +457,8 @@ public class OperationManagerImpl implements OperationManager {
|
||||
|
||||
if (!isActionAuthorized(deviceId)) {
|
||||
throw new OperationManagementException("User '" + getUser() + "' is not authorized to access the '" +
|
||||
deviceId.getType() + "' device, which carries the identifier '" + deviceId.getId() + "'");
|
||||
deviceId.getType() + "' device, which carries the identifier '" +
|
||||
deviceId.getId() + "'");
|
||||
}
|
||||
|
||||
int enrolmentId = this.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE);
|
||||
@ -410,8 +468,10 @@ public class OperationManagerImpl implements OperationManager {
|
||||
boolean isUpdated = false;
|
||||
if (operation.getStatus() != null) {
|
||||
isUpdated = operationDAO.updateOperationStatus(enrolmentId, operationId,
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.
|
||||
valueOf(operation.getStatus().toString()));
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status
|
||||
.
|
||||
valueOf(operation.getStatus()
|
||||
.toString()));
|
||||
}
|
||||
if (isUpdated && operation.getOperationResponse() != null) {
|
||||
operationDAO.addOperationResponse(enrolmentId, operationId, operation.getOperationResponse());
|
||||
@ -421,7 +481,7 @@ public class OperationManagerImpl implements OperationManager {
|
||||
OperationManagementDAOFactory.rollbackTransaction();
|
||||
throw new OperationManagementException(
|
||||
"Error occurred while updating the operation: " + operationId + " status:" +
|
||||
operation.getStatus(), e);
|
||||
operation.getStatus(), e);
|
||||
} catch (TransactionManagementException e) {
|
||||
throw new OperationManagementException("Error occurred while initiating a transaction", e);
|
||||
} finally {
|
||||
@ -456,30 +516,35 @@ public class OperationManagerImpl implements OperationManager {
|
||||
Operation operation = null;
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Operation Id: " + operationId + " Device Type: " + deviceId.getType() + " Device Identifier: " +
|
||||
deviceId.getId());
|
||||
deviceId.getId());
|
||||
}
|
||||
|
||||
if (!isActionAuthorized(deviceId)) {
|
||||
throw new OperationManagementException("User '" + getUser() + "' is not authorized to access the '" +
|
||||
deviceId.getType() + "' device, which carries the identifier '" + deviceId.getId() + "'");
|
||||
deviceId.getType() + "' device, which carries the identifier '" +
|
||||
deviceId.getId() + "'");
|
||||
}
|
||||
|
||||
int enrolmentId = this.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE);
|
||||
if (enrolmentId < 0) {
|
||||
throw new OperationManagementException("Device not found for given device identifier: " +
|
||||
deviceId.getId() + " type: " + deviceId.getType());
|
||||
deviceId.getId() + " type: " + deviceId.getType());
|
||||
}
|
||||
|
||||
try {
|
||||
OperationManagementDAOFactory.openConnection();
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO.
|
||||
getOperationByDeviceAndId(enrolmentId, operationId);
|
||||
getOperationByDeviceAndId(
|
||||
enrolmentId,
|
||||
operationId);
|
||||
if (dtoOperation.getType().
|
||||
equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
|
||||
commandOperation =
|
||||
(org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
|
||||
getOperation(dtoOperation.getId());
|
||||
getOperation(
|
||||
dtoOperation
|
||||
.getId());
|
||||
dtoOperation.setEnabled(commandOperation.isEnabled());
|
||||
} else if (dtoOperation.getType().
|
||||
equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
|
||||
@ -494,16 +559,16 @@ public class OperationManagerImpl implements OperationManager {
|
||||
|
||||
if (dtoOperation == null) {
|
||||
throw new OperationManagementException("Operation not found for operation Id:" + operationId +
|
||||
" device id:" + deviceId.getId());
|
||||
" device id:" + deviceId.getId());
|
||||
}
|
||||
operation = OperationDAOUtil.convertOperation(dtoOperation);
|
||||
} catch (OperationManagementDAOException e) {
|
||||
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
||||
"operations assigned for '" + deviceId.getType() +
|
||||
"' device '" + deviceId.getId() + "'", e);
|
||||
"operations assigned for '" + deviceId.getType() +
|
||||
"' device '" + deviceId.getId() + "'", e);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementException("Error occurred while opening connection to the data source",
|
||||
e);
|
||||
e);
|
||||
} finally {
|
||||
OperationManagementDAOFactory.closeConnection();
|
||||
}
|
||||
@ -519,14 +584,15 @@ public class OperationManagerImpl implements OperationManager {
|
||||
|
||||
if (!isActionAuthorized(deviceId)) {
|
||||
throw new OperationManagementException("User '" + getUser() + "' is not authorized to access the '" +
|
||||
deviceId.getType() + "' device, which carries the identifier '" + deviceId.getId() + "'");
|
||||
deviceId.getType() + "' device, which carries the identifier '" +
|
||||
deviceId.getId() + "'");
|
||||
}
|
||||
|
||||
int enrolmentId = this.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE);
|
||||
if (enrolmentId < 0) {
|
||||
throw new OperationManagementException(
|
||||
"Device not found for device id:" + deviceId.getId() + " " + "type:" +
|
||||
deviceId.getType());
|
||||
deviceId.getType());
|
||||
}
|
||||
|
||||
try {
|
||||
@ -535,11 +601,11 @@ public class OperationManagerImpl implements OperationManager {
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.valueOf(status.toString());
|
||||
dtoOperationList.addAll(commandOperationDAO.getOperationsByDeviceAndStatus(enrolmentId, dtoOpStatus));
|
||||
dtoOperationList.addAll(configOperationDAO.getOperationsByDeviceAndStatus(enrolmentId,
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING));
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING));
|
||||
dtoOperationList.addAll(profileOperationDAO.getOperationsByDeviceAndStatus(enrolmentId,
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING));
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING));
|
||||
dtoOperationList.addAll(policyOperationDAO.getOperationsByDeviceAndStatus(enrolmentId,
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING));
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING));
|
||||
|
||||
Operation operation;
|
||||
|
||||
@ -550,9 +616,9 @@ public class OperationManagerImpl implements OperationManager {
|
||||
|
||||
} catch (OperationManagementDAOException e) {
|
||||
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
||||
"operations assigned for '" + deviceId.getType() +
|
||||
"' device '" +
|
||||
deviceId.getId() + "' and status:" + status.toString(), e);
|
||||
"operations assigned for '" + deviceId.getType() +
|
||||
"' device '" +
|
||||
deviceId.getId() + "' and status:" + status.toString(), e);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementException(
|
||||
"Error occurred while opening a connection to the data source", e);
|
||||
@ -568,31 +634,35 @@ public class OperationManagerImpl implements OperationManager {
|
||||
try {
|
||||
OperationManagementDAOFactory.openConnection();
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO.
|
||||
getOperation(operationId);
|
||||
getOperation(
|
||||
operationId);
|
||||
if (dtoOperation == null) {
|
||||
throw new OperationManagementException("Operation not found for given Id:" + operationId);
|
||||
}
|
||||
|
||||
if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
|
||||
if (dtoOperation.getType()
|
||||
.equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
|
||||
commandOperation =
|
||||
(org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
|
||||
getOperation(dtoOperation.getId());
|
||||
getOperation(
|
||||
dtoOperation
|
||||
.getId());
|
||||
dtoOperation.setEnabled(commandOperation.isEnabled());
|
||||
} else if (dtoOperation.getType().
|
||||
equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
|
||||
dtoOperation = configOperationDAO.getOperation(dtoOperation.getId());
|
||||
} else if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.
|
||||
PROFILE)) {
|
||||
PROFILE)) {
|
||||
dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId());
|
||||
} else if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.
|
||||
POLICY)) {
|
||||
POLICY)) {
|
||||
dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId());
|
||||
}
|
||||
operation = OperationDAOUtil.convertOperation(dtoOperation);
|
||||
} catch (OperationManagementDAOException e) {
|
||||
throw new OperationManagementException("Error occurred while retrieving the operation with operation Id '" +
|
||||
operationId, e);
|
||||
operationId, e);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementException("Error occurred while opening a connection to the data source", e);
|
||||
} finally {
|
||||
@ -601,61 +671,61 @@ public class OperationManagerImpl implements OperationManager {
|
||||
return operation;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Operation getOperationByActivityId(String activity) throws OperationManagementException {
|
||||
// // This parses the operation id from activity id (ex : ACTIVITY_23) and converts to the integer.
|
||||
// Operation operation;
|
||||
// int enrollmentOpMappingId = Integer.parseInt(
|
||||
// activity.replace(DeviceManagementConstants.OperationAttributes.ACTIVITY, ""));
|
||||
// if (enrollmentOpMappingId == 0) {
|
||||
// throw new IllegalArgumentException("Operation ID cannot be null or zero (0).");
|
||||
// }
|
||||
// try {
|
||||
// OperationManagementDAOFactory.openConnection();
|
||||
// org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation =
|
||||
// operationDAO.getOperationFromEnrollment(enrollmentOpMappingId);
|
||||
//
|
||||
// if (dtoOperation == null) {
|
||||
// throw new OperationManagementException("Operation not found for given activity Id:" + activity);
|
||||
// }
|
||||
// org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status status = dtoOperation.getStatus();
|
||||
// if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
|
||||
// org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
|
||||
// commandOperation =
|
||||
// (org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
|
||||
// getOperation(dtoOperation.getId());
|
||||
// dtoOperation.setEnabled(commandOperation.isEnabled());
|
||||
// } else if (dtoOperation.getType().
|
||||
// equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
|
||||
// dtoOperation = configOperationDAO.getOperation(dtoOperation.getId());
|
||||
// } else if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.
|
||||
// PROFILE)) {
|
||||
// dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId());
|
||||
// } else if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.
|
||||
// POLICY)) {
|
||||
// dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId());
|
||||
// }
|
||||
// operation = OperationDAOUtil.convertOperation(dtoOperation);
|
||||
// int enrolmentId = operationDAO.getEnrolmentIdFromMappingId(enrollmentOpMappingId);
|
||||
// if (enrolmentId != 0) {
|
||||
// operation.setResponses(operationDAO.getOperationResponses(enrolmentId, operation.getId()));
|
||||
// }
|
||||
//
|
||||
// operation.setStatus(Operation.Status.valueOf(status.toString()));
|
||||
// operation.setActivityId(activity);
|
||||
//
|
||||
// } catch (SQLException e) {
|
||||
// throw new OperationManagementException("Error occurred while opening a connection to the data source", e);
|
||||
// } catch (OperationManagementDAOException e) {
|
||||
// throw new OperationManagementException("Error occurred while retrieving the operation with activity Id '" +
|
||||
// activity, e);
|
||||
// } finally {
|
||||
// OperationManagementDAOFactory.closeConnection();
|
||||
// }
|
||||
//
|
||||
// // return this.getOperation(operationId);
|
||||
// return operation;
|
||||
// }
|
||||
// @Override
|
||||
// public Operation getOperationByActivityId(String activity) throws OperationManagementException {
|
||||
// // This parses the operation id from activity id (ex : ACTIVITY_23) and converts to the integer.
|
||||
// Operation operation;
|
||||
// int enrollmentOpMappingId = Integer.parseInt(
|
||||
// activity.replace(DeviceManagementConstants.OperationAttributes.ACTIVITY, ""));
|
||||
// if (enrollmentOpMappingId == 0) {
|
||||
// throw new IllegalArgumentException("Operation ID cannot be null or zero (0).");
|
||||
// }
|
||||
// try {
|
||||
// OperationManagementDAOFactory.openConnection();
|
||||
// org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation =
|
||||
// operationDAO.getOperationFromEnrollment(enrollmentOpMappingId);
|
||||
//
|
||||
// if (dtoOperation == null) {
|
||||
// throw new OperationManagementException("Operation not found for given activity Id:" + activity);
|
||||
// }
|
||||
// org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status status = dtoOperation.getStatus();
|
||||
// if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
|
||||
// org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
|
||||
// commandOperation =
|
||||
// (org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
|
||||
// getOperation(dtoOperation.getId());
|
||||
// dtoOperation.setEnabled(commandOperation.isEnabled());
|
||||
// } else if (dtoOperation.getType().
|
||||
// equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
|
||||
// dtoOperation = configOperationDAO.getOperation(dtoOperation.getId());
|
||||
// } else if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.
|
||||
// PROFILE)) {
|
||||
// dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId());
|
||||
// } else if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.
|
||||
// POLICY)) {
|
||||
// dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId());
|
||||
// }
|
||||
// operation = OperationDAOUtil.convertOperation(dtoOperation);
|
||||
// int enrolmentId = operationDAO.getEnrolmentIdFromMappingId(enrollmentOpMappingId);
|
||||
// if (enrolmentId != 0) {
|
||||
// operation.setResponses(operationDAO.getOperationResponses(enrolmentId, operation.getId()));
|
||||
// }
|
||||
//
|
||||
// operation.setStatus(Operation.Status.valueOf(status.toString()));
|
||||
// operation.setActivityId(activity);
|
||||
//
|
||||
// } catch (SQLException e) {
|
||||
// throw new OperationManagementException("Error occurred while opening a connection to the data source", e);
|
||||
// } catch (OperationManagementDAOException e) {
|
||||
// throw new OperationManagementException("Error occurred while retrieving the operation with activity Id '" +
|
||||
// activity, e);
|
||||
// } finally {
|
||||
// OperationManagementDAOFactory.closeConnection();
|
||||
// }
|
||||
//
|
||||
// // return this.getOperation(operationId);
|
||||
// return operation;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Activity getOperationByActivityId(String activity) throws OperationManagementException {
|
||||
@ -672,7 +742,7 @@ public class OperationManagerImpl implements OperationManager {
|
||||
throw new OperationManagementException("Error occurred while opening a connection to the data source.", e);
|
||||
} catch (OperationManagementDAOException e) {
|
||||
throw new OperationManagementException("Error occurred while retrieving the operation with activity Id '" +
|
||||
activity, e);
|
||||
activity, e);
|
||||
} finally {
|
||||
OperationManagementDAOFactory.closeConnection();
|
||||
}
|
||||
@ -692,7 +762,7 @@ public class OperationManagerImpl implements OperationManager {
|
||||
throw new OperationManagementException("Error occurred while opening a connection to the data source.", e);
|
||||
} catch (OperationManagementDAOException e) {
|
||||
throw new OperationManagementException("Error occurred while getting the activity list changed after a " +
|
||||
"given time.", e);
|
||||
"given time.", e);
|
||||
} finally {
|
||||
OperationManagementDAOFactory.closeConnection();
|
||||
}
|
||||
@ -708,7 +778,7 @@ public class OperationManagerImpl implements OperationManager {
|
||||
throw new OperationManagementException("Error occurred while opening a connection to the data source.", e);
|
||||
} catch (OperationManagementDAOException e) {
|
||||
throw new OperationManagementException("Error occurred while getting the activity list changed after a " +
|
||||
"given time.", e);
|
||||
"given time.", e);
|
||||
} finally {
|
||||
OperationManagementDAOFactory.closeConnection();
|
||||
}
|
||||
@ -723,7 +793,7 @@ public class OperationManagerImpl implements OperationManager {
|
||||
throw new OperationManagementException("Error occurred while opening a connection to the data source.", e);
|
||||
} catch (OperationManagementDAOException e) {
|
||||
throw new OperationManagementException("Error occurred while getting the activity count changed after a " +
|
||||
"given time.", e);
|
||||
"given time.", e);
|
||||
} finally {
|
||||
OperationManagementDAOFactory.closeConnection();
|
||||
}
|
||||
@ -805,8 +875,8 @@ public class OperationManagerImpl implements OperationManager {
|
||||
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, status, tenantId);
|
||||
} catch (DeviceManagementDAOException e) {
|
||||
throw new OperationManagementException("Error occurred while retrieving metadata of '" +
|
||||
deviceId.getType() + "' device carrying the identifier '" +
|
||||
deviceId.getId() + "'", e);
|
||||
deviceId.getType() + "' device carrying the identifier '" +
|
||||
deviceId.getId() + "'", e);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementException(
|
||||
"Error occurred while opening a connection to the data source", e);
|
||||
|
||||
@ -28,7 +28,6 @@ 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.util.DeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.*;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.operation.H2OperationDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.operation.MySQLOperationDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.operation.OracleOperationDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.operation.PostgreSQLOperationDAOImpl;
|
||||
@ -77,7 +76,7 @@ public class OperationManagementDAOFactory {
|
||||
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_POSTGRESQL:
|
||||
return new PostgreSQLOperationDAOImpl();
|
||||
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2:
|
||||
return new H2OperationDAOImpl();
|
||||
return new GenericOperationDAOImpl();
|
||||
case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MYSQL:
|
||||
return new MySQLOperationDAOImpl();
|
||||
default:
|
||||
|
||||
@ -406,30 +406,36 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
||||
// sql = sql + " OFFSET ?";
|
||||
// }
|
||||
|
||||
String sql = "SELECT feom.ENROLMENT_ID, feom.OPERATION_ID, feom.CREATED_TIMESTAMP, o.TYPE AS OPERATION_TYPE, " +
|
||||
"o.OPERATION_CODE, orsp.OPERATION_RESPONSE, orsp.LATEST_RECEIVED_TIMESTAMP AS RECEIVED_TIMESTAMP, " +
|
||||
"orsp.ID AS OP_RES_ID, feom.STATUS, feom.UPDATED_TIMESTAMP, feom.DEVICE_IDENTIFICATION, " +
|
||||
"feom.DEVICE_TYPE FROM (SELECT eom.ENROLMENT_ID, eom.OPERATION_ID, eom.STATUS, eom.CREATED_TIMESTAMP, " +
|
||||
"eom.UPDATED_TIMESTAMP, fe.DEVICE_IDENTIFICATION, fe.DEVICE_TYPE FROM " +
|
||||
"(SELECT ENROLMENT_ID, OPERATION_ID, STATUS, CREATED_TIMESTAMP, UPDATED_TIMESTAMP " +
|
||||
"FROM DM_ENROLMENT_OP_MAPPING WHERE UPDATED_TIMESTAMP > ? ORDER BY OPERATION_ID LIMIT ? OFFSET ?) eom " +
|
||||
"LEFT OUTER JOIN (SELECT e.ID AS ENROLMENT_ID, d.ID AS DEVICE_ID, d.DEVICE_IDENTIFICATION, " +
|
||||
"t.NAME AS DEVICE_TYPE FROM DM_ENROLMENT e LEFT OUTER JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
|
||||
"LEFT OUTER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID WHERE d.TENANT_ID = ? AND " +
|
||||
"e.TENANT_ID = ?) fe ON fe.ENROLMENT_ID = eom.ENROLMENT_ID) feom LEFT OUTER JOIN DM_OPERATION o " +
|
||||
"ON feom.OPERATION_ID = o.ID LEFT OUTER JOIN (SELECT ID, ENROLMENT_ID, OPERATION_ID, " +
|
||||
"OPERATION_RESPONSE, MAX(RECEIVED_TIMESTAMP) LATEST_RECEIVED_TIMESTAMP " +
|
||||
"FROM DM_DEVICE_OPERATION_RESPONSE GROUP BY ENROLMENT_ID , OPERATION_ID) orsp " +
|
||||
"ON o.ID = orsp.OPERATION_ID AND feom.ENROLMENT_ID = orsp.ENROLMENT_ID GROUP BY feom.ENROLMENT_ID";
|
||||
|
||||
String sql = "SELECT opm.ENROLMENT_ID, opm.CREATED_TIMESTAMP, opm.UPDATED_TIMESTAMP, opm.OPERATION_ID,\n" +
|
||||
"op.OPERATION_CODE, op.TYPE as OPERATION_TYPE, opm.STATUS, en.DEVICE_ID,\n" +
|
||||
"ops.RECEIVED_TIMESTAMP, ops.ID as OP_RES_ID, ops.OPERATION_RESPONSE,\n" +
|
||||
"de.DEVICE_IDENTIFICATION, dt.NAME as DEVICE_TYPE\n" +
|
||||
"FROM DM_ENROLMENT_OP_MAPPING AS opm\n" +
|
||||
"LEFT JOIN DM_OPERATION AS op ON opm.OPERATION_ID = op.ID \n" +
|
||||
"LEFT JOIN DM_ENROLMENT as en ON opm.ENROLMENT_ID = en.ID \n" +
|
||||
"LEFT JOIN DM_DEVICE as de ON en.DEVICE_ID = de.ID \n" +
|
||||
"LEFT JOIN DM_DEVICE_TYPE as dt ON dt.ID = de.DEVICE_TYPE_ID \n" +
|
||||
"LEFT JOIN DM_DEVICE_OPERATION_RESPONSE as ops ON \n" +
|
||||
"opm.ENROLMENT_ID = ops.ENROLMENT_ID AND opm.OPERATION_ID = ops.OPERATION_ID \n" +
|
||||
"WHERE opm.UPDATED_TIMESTAMP > ? \n" +
|
||||
"AND de.TENANT_ID = ? \n";
|
||||
|
||||
if(timestamp == 0){
|
||||
sql += "ORDER BY opm.OPERATION_ID LIMIT ? OFFSET ?;";
|
||||
}else{
|
||||
sql += "ORDER BY opm.UPDATED_TIMESTAMP asc LIMIT ? OFFSET ?";
|
||||
}
|
||||
|
||||
|
||||
|
||||
stmt = conn.prepareStatement(sql);
|
||||
|
||||
stmt.setLong(1, timestamp);
|
||||
stmt.setInt(2, limit);
|
||||
stmt.setInt(3, offset);
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
stmt.setInt(4, tenantId);
|
||||
stmt.setInt(5, tenantId);
|
||||
stmt.setInt(2, tenantId);
|
||||
stmt.setInt(3, limit);
|
||||
stmt.setInt(4, offset);
|
||||
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
|
||||
@ -1,174 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016a, 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.operation.mgt.dao.impl.operation;
|
||||
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.ActivityStatus;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationResponse;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.GenericOperationDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class holds the implementation of OperationDAO which can be used to support H2 db syntax.
|
||||
*/
|
||||
public class H2OperationDAOImpl extends GenericOperationDAOImpl {
|
||||
|
||||
@Override
|
||||
public List<Activity> getActivitiesUpdatedAfter(long timestamp, int limit, int offset) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
List<Activity> activities = new ArrayList<>();
|
||||
try {
|
||||
Connection conn = OperationManagementDAOFactory.getConnection();
|
||||
String sql = "SELECT feom.ENROLMENT_ID, feom.OPERATION_ID, feom.CREATED_TIMESTAMP, o.TYPE AS OPERATION_TYPE, " +
|
||||
"o.OPERATION_CODE, orsp.OPERATION_RESPONSE, orsp.LATEST_RECEIVED_TIMESTAMP AS RECEIVED_TIMESTAMP, " +
|
||||
"orsp.ID AS OP_RES_ID, feom.STATUS, feom.UPDATED_TIMESTAMP, feom.DEVICE_IDENTIFICATION, " +
|
||||
"feom.DEVICE_TYPE FROM (SELECT eom.ENROLMENT_ID, eom.OPERATION_ID, eom.STATUS, eom.CREATED_TIMESTAMP, " +
|
||||
"eom.UPDATED_TIMESTAMP, fe.DEVICE_IDENTIFICATION, fe.DEVICE_TYPE FROM " +
|
||||
"(SELECT ENROLMENT_ID, OPERATION_ID, STATUS, CREATED_TIMESTAMP, UPDATED_TIMESTAMP " +
|
||||
"FROM DM_ENROLMENT_OP_MAPPING WHERE UPDATED_TIMESTAMP > ? ORDER BY OPERATION_ID LIMIT ? OFFSET ?) eom " +
|
||||
"LEFT OUTER JOIN (SELECT e.ID AS ENROLMENT_ID, d.ID AS DEVICE_ID, d.DEVICE_IDENTIFICATION, " +
|
||||
"t.NAME AS DEVICE_TYPE FROM DM_ENROLMENT e LEFT OUTER JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
|
||||
"LEFT OUTER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID WHERE d.TENANT_ID = ? AND " +
|
||||
"e.TENANT_ID = ?) fe ON fe.ENROLMENT_ID = eom.ENROLMENT_ID) feom LEFT OUTER JOIN DM_OPERATION o " +
|
||||
"ON feom.OPERATION_ID = o.ID LEFT OUTER JOIN (SELECT ID, ENROLMENT_ID, OPERATION_ID, " +
|
||||
"OPERATION_RESPONSE, MAX(RECEIVED_TIMESTAMP) LATEST_RECEIVED_TIMESTAMP " +
|
||||
"FROM DM_DEVICE_OPERATION_RESPONSE GROUP BY ENROLMENT_ID , OPERATION_ID) orsp " +
|
||||
"ON o.ID = orsp.OPERATION_ID AND feom.ENROLMENT_ID = orsp.ENROLMENT_ID GROUP BY feom.ENROLMENT_ID, " +
|
||||
"feom.OPERATION_ID, feom.CREATED_TIMESTAMP, o.TYPE, o.OPERATION_CODE, orsp.OPERATION_RESPONSE, " +
|
||||
"orsp.LATEST_RECEIVED_TIMESTAMP, orsp.ID, feom.STATUS, feom.UPDATED_TIMESTAMP, " +
|
||||
"feom.DEVICE_IDENTIFICATION, feom.DEVICE_TYPE";
|
||||
|
||||
stmt = conn.prepareStatement(sql);
|
||||
|
||||
stmt.setLong(1, timestamp);
|
||||
stmt.setInt(2, limit);
|
||||
stmt.setInt(3, offset);
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
stmt.setInt(4, tenantId);
|
||||
stmt.setInt(5, tenantId);
|
||||
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
int operationId = 0;
|
||||
int enrolmentId = 0;
|
||||
int responseId = 0;
|
||||
Activity activity = null;
|
||||
ActivityStatus activityStatus = null;
|
||||
while (rs.next()) {
|
||||
|
||||
if (operationId != rs.getInt("OPERATION_ID")) {
|
||||
activity = new Activity();
|
||||
activities.add(activity);
|
||||
List<ActivityStatus> statusList = new ArrayList<>();
|
||||
activityStatus = new ActivityStatus();
|
||||
|
||||
operationId = rs.getInt("OPERATION_ID");
|
||||
enrolmentId = rs.getInt("ENROLMENT_ID");
|
||||
|
||||
activity.setType(Activity.Type.valueOf(rs.getString("OPERATION_TYPE")));
|
||||
activity.setCreatedTimeStamp(new java.util.Date(rs.getLong(("CREATED_TIMESTAMP")) * 1000).toString());
|
||||
activity.setCode(rs.getString("OPERATION_CODE"));
|
||||
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
||||
deviceIdentifier.setType(rs.getString("DEVICE_TYPE"));
|
||||
activityStatus.setDeviceIdentifier(deviceIdentifier);
|
||||
|
||||
activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS")));
|
||||
|
||||
List<OperationResponse> operationResponses = new ArrayList<>();
|
||||
if (rs.getInt("UPDATED_TIMESTAMP") != 0) {
|
||||
activityStatus.setUpdatedTimestamp(new java.util.Date(
|
||||
rs.getLong(("UPDATED_TIMESTAMP")) * 1000).toString());
|
||||
|
||||
}
|
||||
if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) {
|
||||
operationResponses.add(OperationDAOUtil.getOperationResponse(rs));
|
||||
responseId = rs.getInt("OP_RES_ID");
|
||||
}
|
||||
activityStatus.setResponses(operationResponses);
|
||||
statusList.add(activityStatus);
|
||||
activity.setActivityStatus(statusList);
|
||||
activity.setActivityId(OperationDAOUtil.getActivityId(rs.getInt("OPERATION_ID")));
|
||||
|
||||
}
|
||||
|
||||
if (operationId == rs.getInt("OPERATION_ID") && enrolmentId != rs.getInt("ENROLMENT_ID")) {
|
||||
activityStatus = new ActivityStatus();
|
||||
|
||||
activity.setType(Activity.Type.valueOf(rs.getString("OPERATION_TYPE")));
|
||||
activity.setCreatedTimeStamp(new java.util.Date(rs.getLong(("CREATED_TIMESTAMP")) * 1000).toString());
|
||||
activity.setCode(rs.getString("OPERATION_CODE"));
|
||||
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION"));
|
||||
deviceIdentifier.setType(rs.getString("DEVICE_TYPE"));
|
||||
activityStatus.setDeviceIdentifier(deviceIdentifier);
|
||||
|
||||
activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS")));
|
||||
|
||||
List<OperationResponse> operationResponses = new ArrayList<>();
|
||||
if (rs.getInt("UPDATED_TIMESTAMP") != 0) {
|
||||
activityStatus.setUpdatedTimestamp(new java.util.Date(
|
||||
rs.getLong(("UPDATED_TIMESTAMP")) * 1000).toString());
|
||||
}
|
||||
if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) {
|
||||
operationResponses.add(OperationDAOUtil.getOperationResponse(rs));
|
||||
responseId = rs.getInt("OP_RES_ID");
|
||||
}
|
||||
activityStatus.setResponses(operationResponses);
|
||||
activity.getActivityStatus().add(activityStatus);
|
||||
|
||||
enrolmentId = rs.getInt("ENROLMENT_ID");
|
||||
}
|
||||
|
||||
if (rs.getInt("OP_RES_ID") != 0 && responseId != rs.getInt("OP_RES_ID")) {
|
||||
if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) {
|
||||
activityStatus.getResponses().add(OperationDAOUtil.getOperationResponse(rs));
|
||||
responseId = rs.getInt("OP_RES_ID");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementDAOException("Error occurred while getting the operation details from " +
|
||||
"the database.", e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new OperationManagementDAOException("Error occurred while converting the operation response to string.", e);
|
||||
} catch (IOException e) {
|
||||
throw new OperationManagementDAOException("IO exception occurred while converting the operations responses.", e);
|
||||
} finally {
|
||||
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return activities;
|
||||
}
|
||||
}
|
||||
@ -53,9 +53,11 @@ public class PermissionManagerServiceImpl implements PermissionManagerService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(Permission permission) throws PermissionManagementException {
|
||||
public boolean addPermission(Permission permission) throws PermissionManagementException {
|
||||
// adding a permission to the tree
|
||||
permission.setPath(PermissionUtils.getAbsolutePermissionPath(permission.getPath()));
|
||||
permissionTree.addPermission(permission);
|
||||
return PermissionUtils.putPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -66,24 +66,23 @@ public class PermissionUtils {
|
||||
return contextPath + url;
|
||||
}
|
||||
|
||||
// public static Permission getPermission(String path) throws PermissionManagementException {
|
||||
// try {
|
||||
// Resource resource = PermissionUtils.getGovernanceRegistry().get(path);
|
||||
// Permission permission = new Permission();
|
||||
// permission.setName(resource.getProperty(PERMISSION_PROPERTY_NAME));
|
||||
// permission.setPath(resource.getPath());
|
||||
// return permission;
|
||||
// } catch (RegistryException e) {
|
||||
// throw new PermissionManagementException("Error in retrieving registry resource : " +
|
||||
// e.getMessage(), e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
public static boolean putPermission(String permissionPath)
|
||||
throws PermissionManagementException {
|
||||
public static Permission getPermission(String path) throws PermissionManagementException {
|
||||
try {
|
||||
Resource resource = PermissionUtils.getGovernanceRegistry().get(path);
|
||||
Permission permission = new Permission();
|
||||
permission.setName(resource.getProperty(PERMISSION_PROPERTY_NAME));
|
||||
permission.setPath(resource.getPath());
|
||||
return permission;
|
||||
} catch (RegistryException e) {
|
||||
throw new PermissionManagementException("Error in retrieving registry resource : " +
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean putPermission(Permission permission) throws PermissionManagementException {
|
||||
boolean status;
|
||||
try {
|
||||
StringTokenizer tokenizer = new StringTokenizer(permissionPath, "/");
|
||||
StringTokenizer tokenizer = new StringTokenizer(permission.getPath(), "/");
|
||||
String lastToken = "", currentToken, tempPath;
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
currentToken = tokenizer.nextToken();
|
||||
@ -95,7 +94,8 @@ public class PermissionUtils {
|
||||
}
|
||||
status = true;
|
||||
} catch (RegistryException e) {
|
||||
throw new PermissionManagementException("Error occurred while persisting permission", e);
|
||||
throw new PermissionManagementException("Error occurred while persisting permission : " +
|
||||
permission.getName(), e);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@ -116,17 +116,17 @@ public class PermissionUtils {
|
||||
return PermissionUtils.getGovernanceRegistry().resourceExists(path);
|
||||
}
|
||||
|
||||
public static Document convertToDocument(File file) throws PermissionManagementException {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
try {
|
||||
DocumentBuilder docBuilder = factory.newDocumentBuilder();
|
||||
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
|
||||
return docBuilder.parse(file);
|
||||
} catch (Exception e) {
|
||||
throw new PermissionManagementException("Error occurred while parsing file, while converting " +
|
||||
"to a org.w3c.dom.Document", e);
|
||||
}
|
||||
}
|
||||
public static Document convertToDocument(File file) throws PermissionManagementException {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
try {
|
||||
DocumentBuilder docBuilder = factory.newDocumentBuilder();
|
||||
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
|
||||
return docBuilder.parse(file);
|
||||
} catch (Exception e) {
|
||||
throw new PermissionManagementException("Error occurred while parsing file, while converting " +
|
||||
"to a org.w3c.dom.Document", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ public interface DeviceManagementProviderService {
|
||||
* @return true if the user owns the device else will return false.
|
||||
* @throws DeviceManagementException If some unusual behaviour is observed while fetching the device.
|
||||
*/
|
||||
public boolean isEnrolled(DeviceIdentifier deviceId, String user) throws DeviceManagementException;
|
||||
boolean isEnrolled(DeviceIdentifier deviceId, String user) throws DeviceManagementException;
|
||||
|
||||
License getLicense(String deviceType, String languageCode) throws DeviceManagementException;
|
||||
|
||||
|
||||
@ -342,12 +342,10 @@ public final class DeviceManagerUtil {
|
||||
if (isValidDeviceIdentifier(deviceIdentifier)) {
|
||||
validDeviceIDList.add(deviceIdentifier);
|
||||
} else {
|
||||
errorDeviceIdList.add(String.format(OperationMgtConstants.DeviceConstants.
|
||||
DEVICE_ID_NOT_FOUND, deviceID));
|
||||
errorDeviceIdList.add(deviceID);
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
errorDeviceIdList.add(String.format(OperationMgtConstants.DeviceConstants.DEVICE_ID_SERVICE_NOT_FOUND,
|
||||
deviceIDCounter));
|
||||
errorDeviceIdList.add(deviceID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -28,13 +28,15 @@
|
||||
<baseDirectory>${basedir}/src</baseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<!-- CDMF base app -->
|
||||
<directory>${basedir}/src/main/resources/jaggeryapps/devicemgt</directory>
|
||||
<outputDirectory>/jaggeryapps/devicemgt-cdmf/</outputDirectory>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<!-- UUF framework app -->
|
||||
<directory>${basedir}/src/main/resources/jaggeryapps/uuf-template-app</directory>
|
||||
<outputDirectory>/jaggeryapps/devicemgt-cdmf/</outputDirectory>
|
||||
<outputDirectory>/jaggeryapps/uuf-template-app/</outputDirectory>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
|
||||
@ -152,7 +152,7 @@ if (!user) {
|
||||
result = responsePayload.responseText;
|
||||
});
|
||||
} else if (uriMatcher.match("/{context}/api/devices/")) {
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/admin/devices/list")) {
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/list")) {
|
||||
result = deviceModule.listDevices();
|
||||
} else {
|
||||
response.sendError(403);
|
||||
@ -161,7 +161,7 @@ if (!user) {
|
||||
elements = uriMatcher.elements();
|
||||
deviceId = elements.deviceId;
|
||||
type = elements.type;
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/admin/devices/list")) {
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/list")) {
|
||||
result = deviceModule.viewDevice(type, deviceId);
|
||||
}else {
|
||||
response.sendError(403);
|
||||
@ -171,7 +171,7 @@ if (!user) {
|
||||
deviceId = elements.deviceId;
|
||||
type = elements.type;
|
||||
operation = elements.operation;
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/admin/devices/operation")) {
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/operation")) {
|
||||
result = deviceModule.performOperation(deviceId, operation, [], type);
|
||||
} else {
|
||||
response.sendError(403);
|
||||
|
||||
@ -98,7 +98,7 @@ if (uriMatcher.match("/{context}/api/user/authenticate")) {
|
||||
/*
|
||||
@Deprecated
|
||||
*/
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/admin/user/invite")) {
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/user/invite")) {
|
||||
elements = uriMatcher.elements();
|
||||
username = elements.username;
|
||||
userModule.inviteUser(username);
|
||||
@ -109,7 +109,7 @@ if (uriMatcher.match("/{context}/api/user/authenticate")) {
|
||||
/*
|
||||
@Deprecated
|
||||
*/
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/admin/user/add")) {
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/user/add")) {
|
||||
addUserFormData = request.getContent();
|
||||
username = addUserFormData.username;
|
||||
firstname = addUserFormData.firstname;
|
||||
@ -160,7 +160,7 @@ if (uriMatcher.match("/{context}/api/user/authenticate")) {
|
||||
/*
|
||||
@Deprecated
|
||||
*/
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/admin/user/remove")) {
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/user/remove")) {
|
||||
elements = uriMatcher.elements();
|
||||
username = elements.username;
|
||||
try {
|
||||
|
||||
@ -30,21 +30,22 @@ under the License. --}}
|
||||
</head>
|
||||
<body>
|
||||
<!--modal-->
|
||||
<div class="wr-modalpopup">
|
||||
<div class="modalpopup-container">
|
||||
<div class="modalpopup-close-btn" onclick="hidePopup();">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-left-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
GO BACK
|
||||
</div>
|
||||
<div class="modalpopup-content">
|
||||
<!-- dynamic content -->
|
||||
<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modalDemo">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content clearfix">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modalpopup-bg"></div>
|
||||
</div>
|
||||
|
||||
<!--modal-->
|
||||
|
||||
{{defineZone "header"}}
|
||||
@ -58,8 +59,10 @@ under the License. --}}
|
||||
<!-- page-content-wrapper -->
|
||||
<div class="page-content-wrapper">
|
||||
{{defineZone "contentTitle"}}
|
||||
<div class="container-fluid body-wrapper">
|
||||
{{defineZone "content"}}
|
||||
<div class="container-fluid ">
|
||||
<div class="body-wrapper">
|
||||
{{defineZone "content"}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /page-content-wrapper -->
|
||||
|
||||
@ -40,7 +40,7 @@ deviceModule = function () {
|
||||
|
||||
// var deviceCloudService = devicemgtProps["httpsURL"] + "/common/device_manager";
|
||||
|
||||
/**
|
||||
/**
|
||||
* Only GET method is implemented for now since there are no other type of methods used this method.
|
||||
* @param url - URL to call the backend without the host
|
||||
* @param method - HTTP Method (GET, POST)
|
||||
@ -273,6 +273,9 @@ deviceModule = function () {
|
||||
deviceObject[constants["DEVICE_PROPERTIES"]] = properties;
|
||||
response["content"] = deviceObject;
|
||||
return response;
|
||||
} else if (backendResponse.status == 401) {
|
||||
response["status"] = "unauthorized";
|
||||
return response;
|
||||
} else {
|
||||
response["status"] = "error";
|
||||
return response;
|
||||
@ -295,20 +298,20 @@ deviceModule = function () {
|
||||
var url;
|
||||
if (uiPermissions.LIST_DEVICES) {
|
||||
url = devicemgtProps["httpsURL"] +
|
||||
devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/count";
|
||||
devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices?offset=0&limit=1";
|
||||
} else if (uiPermissions.LIST_OWN_DEVICES) {
|
||||
url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
|
||||
"/devices/user/" + carbonUser.username + "/count";
|
||||
"/devices?offset=0&limit=1&user=" + carbonUser.username;
|
||||
} else {
|
||||
log.error("Access denied for user: " + carbonUser.username);
|
||||
return -1;
|
||||
}
|
||||
return serviceInvokers.XMLHttp.get(
|
||||
url, function (responsePayload) {
|
||||
return responsePayload;
|
||||
return parse(responsePayload["responseText"])["count"];
|
||||
},
|
||||
function (responsePayload) {
|
||||
log.error(responsePayload);
|
||||
log.error(responsePayload["responseText"]);
|
||||
return -1;
|
||||
}
|
||||
);
|
||||
|
||||
@ -45,7 +45,12 @@ policyModule = function () {
|
||||
policyObjectToView["priorityId"] = policyObjectFromRestEndpoint["priorityId"];
|
||||
policyObjectToView["name"] = policyObjectFromRestEndpoint["policyName"];
|
||||
policyObjectToView["platform"] = policyObjectFromRestEndpoint["profile"]["deviceType"];
|
||||
policyObjectToView["icon"] = utility.getDeviceThumb(policyObjectToView["platform"]);
|
||||
if (policyObjectToView["platform"] == "ios") {
|
||||
policyObjectToView["deviceTypeIcon"] = "apple";
|
||||
} else {
|
||||
policyObjectToView["deviceTypeIcon"] = policyObjectToView["platform"];
|
||||
}
|
||||
//policyObjectToView["icon"] = utility.getDeviceThumb(policyObjectToView["platform"]);
|
||||
policyObjectToView["ownershipType"] = policyObjectFromRestEndpoint["ownershipType"];
|
||||
|
||||
var assignedRoleCount = policyObjectFromRestEndpoint["roles"].length;
|
||||
@ -74,14 +79,14 @@ policyModule = function () {
|
||||
policyObjectToView["status"] = "Active/Updated";
|
||||
isUpdated = true;
|
||||
} else if (policyObjectFromRestEndpoint["active"] == true &&
|
||||
policyObjectFromRestEndpoint["updated"] == false) {
|
||||
policyObjectFromRestEndpoint["updated"] == false) {
|
||||
policyObjectToView["status"] = "Active";
|
||||
} else if (policyObjectFromRestEndpoint["active"] == false &&
|
||||
policyObjectFromRestEndpoint["updated"] == true) {
|
||||
policyObjectFromRestEndpoint["updated"] == true) {
|
||||
policyObjectToView["status"] = "Inactive/Updated";
|
||||
isUpdated = true;
|
||||
} else if (policyObjectFromRestEndpoint["active"] == false &&
|
||||
policyObjectFromRestEndpoint["updated"] == false) {
|
||||
policyObjectFromRestEndpoint["updated"] == false) {
|
||||
policyObjectToView["status"] = "Inactive";
|
||||
}
|
||||
// push view-objects to list
|
||||
@ -126,13 +131,39 @@ policyModule = function () {
|
||||
}
|
||||
try {
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
|
||||
"/policies?offset=0&limit=100";
|
||||
"/policies?offset=0&limit=100";
|
||||
return serviceInvokers.XMLHttp.get(url, privateMethods.handleGetAllPoliciesResponse);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Get policies count from backend services.
|
||||
*/
|
||||
publicMethods.getPoliciesCount = function () {
|
||||
var carbonUser = session.get(constants["USER_SESSION_KEY"]);
|
||||
if (!carbonUser) {
|
||||
log.error("User object was not found in the session");
|
||||
throw constants["ERRORS"]["USER_NOT_FOUND"];
|
||||
}
|
||||
try {
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
|
||||
"/policies?offset=0&limit=1";
|
||||
return serviceInvokers.XMLHttp.get(
|
||||
url, function (responsePayload) {
|
||||
return parse(responsePayload["responseText"])["count"];
|
||||
},
|
||||
function (responsePayload) {
|
||||
log.error(responsePayload["responseText"]);
|
||||
return -1;
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
@Updated - used by getAllPolicies
|
||||
*/
|
||||
|
||||
@ -59,17 +59,17 @@ var userModule = function () {
|
||||
privateMethods.callBackend = function (url, method) {
|
||||
if (constants["HTTP_GET"] == method) {
|
||||
return serviceInvokers.XMLHttp.get(url,
|
||||
function (backendResponse) {
|
||||
var response = {};
|
||||
response.content = backendResponse.responseText;
|
||||
if (backendResponse.status == 200) {
|
||||
response.status = "success";
|
||||
} else if (backendResponse.status == 400 || backendResponse.status == 401 ||
|
||||
backendResponse.status == 404 || backendResponse.status == 500) {
|
||||
response.status = "error";
|
||||
}
|
||||
return response;
|
||||
}
|
||||
function (backendResponse) {
|
||||
var response = {};
|
||||
response.content = backendResponse.responseText;
|
||||
if (backendResponse.status == 200) {
|
||||
response.status = "success";
|
||||
} else if (backendResponse.status == 400 || backendResponse.status == 401 ||
|
||||
backendResponse.status == 404 || backendResponse.status == 500) {
|
||||
response.status = "error";
|
||||
}
|
||||
return response;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
log.error("Runtime error : This method only support HTTP GET requests.");
|
||||
@ -141,6 +141,35 @@ var userModule = function () {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Get users count from backend services.
|
||||
*/
|
||||
publicMethods.getUsersCount = function () {
|
||||
var carbonUser = session.get(constants["USER_SESSION_KEY"]);
|
||||
var utility = require("/app/modules/utility.js")["utility"];
|
||||
if (!carbonUser) {
|
||||
log.error("User object was not found in the session");
|
||||
throw constants["ERRORS"]["USER_NOT_FOUND"];
|
||||
}
|
||||
try {
|
||||
utility.startTenantFlow(carbonUser);
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users?offset=0&limit=1";
|
||||
return serviceInvokers.XMLHttp.get(
|
||||
url, function (responsePayload) {
|
||||
return parse(responsePayload["responseText"])["count"];
|
||||
},
|
||||
function (responsePayload) {
|
||||
log.error(responsePayload["responseText"]);
|
||||
return -1;
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
utility.endTenantFlow();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a User object from the backend by calling the JAX-RS
|
||||
* @param username
|
||||
@ -151,7 +180,7 @@ var userModule = function () {
|
||||
try {
|
||||
utility.startTenantFlow(carbonUser);
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" +
|
||||
encodeURIComponent(username);
|
||||
encodeURIComponent(username);
|
||||
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
|
||||
response["content"] = parse(response.content);
|
||||
response["userDomain"] = carbonUser.domain;
|
||||
@ -173,7 +202,7 @@ var userModule = function () {
|
||||
try {
|
||||
utility.startTenantFlow(carbonUser);
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" +
|
||||
encodeURIComponent(username) + "/roles";
|
||||
encodeURIComponent(username) + "/roles";
|
||||
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
|
||||
if (response.status == "success") {
|
||||
response.content = parse(response.content).roles;
|
||||
@ -223,7 +252,7 @@ var userModule = function () {
|
||||
try {
|
||||
utility.startTenantFlow(carbonUser);
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
|
||||
"/roles?offset=0&limit=100";
|
||||
"/roles?offset=0&limit=100";
|
||||
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
|
||||
if (response.status == "success") {
|
||||
response.content = parse(response.content).roles;
|
||||
@ -236,6 +265,36 @@ var userModule = function () {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get User Roles count from user store (Internal roles not included).
|
||||
*/
|
||||
publicMethods.getRolesCount = function () {
|
||||
var carbonUser = session.get(constants["USER_SESSION_KEY"]);
|
||||
var utility = require("/app/modules/utility.js")["utility"];
|
||||
if (!carbonUser) {
|
||||
log.error("User object was not found in the session");
|
||||
throw constants["ERRORS"]["USER_NOT_FOUND"];
|
||||
}
|
||||
try {
|
||||
utility.startTenantFlow(carbonUser);
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
|
||||
"/roles?offset=0&limit=1";
|
||||
return serviceInvokers.XMLHttp.get(
|
||||
url, function (responsePayload) {
|
||||
return parse(responsePayload["responseText"])["count"];
|
||||
},
|
||||
function (responsePayload) {
|
||||
log.error(responsePayload["responseText"]);
|
||||
return -1;
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
utility.endTenantFlow();
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
@Updated
|
||||
*/
|
||||
@ -253,7 +312,7 @@ var userModule = function () {
|
||||
try {
|
||||
utility.startTenantFlow(carbonUser);
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
|
||||
"/roles?user-store=" + userStore + "&limit=100";
|
||||
"/roles?user-store=" + userStore + "&limit=100";
|
||||
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
|
||||
if (response.status == "success") {
|
||||
response.content = parse(response.content).roles;
|
||||
@ -270,7 +329,7 @@ var userModule = function () {
|
||||
* Get Platforms.
|
||||
* @deprecated moved this device module under getDeviceTypes.
|
||||
*/
|
||||
//TODO Move this piece of logic out of user.js to somewhere else appropriate.
|
||||
//TODO Move this piece of logic out of user.js to somewhere else appropriate.
|
||||
publicMethods.getPlatforms = function () {
|
||||
var carbonUser = session.get(constants["USER_SESSION_KEY"]);
|
||||
var utility = require("/app/modules/utility.js")["utility"];
|
||||
@ -306,9 +365,11 @@ var userModule = function () {
|
||||
try {
|
||||
utility.startTenantFlow(carbonUser);
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
|
||||
"/roles/" + encodeURIComponent(roleName);
|
||||
"/roles/" + encodeURIComponent(roleName);
|
||||
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
|
||||
response.content = parse(response.content);
|
||||
if (response.status == "success") {
|
||||
response.content = parse(response.content);
|
||||
}
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
@ -394,25 +455,25 @@ var userModule = function () {
|
||||
|
||||
publicMethods.getUIPermissions = function () {
|
||||
var permissions = {};
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/devices/list")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/list")) {
|
||||
permissions["LIST_DEVICES"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/list")) {
|
||||
permissions["LIST_OWN_DEVICES"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/groups/list")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/list")) {
|
||||
permissions["LIST_ALL_GROUPS"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/groups/list")) {
|
||||
permissions["LIST_GROUPS"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/users/list")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/list")) {
|
||||
permissions["LIST_USERS"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/roles/list")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/roles/list")) {
|
||||
permissions["LIST_ROLES"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/policies/list")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/policies/list")) {
|
||||
permissions["LIST_ALL_POLICIES"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/policies/list")) {
|
||||
@ -424,28 +485,28 @@ var userModule = function () {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/groups/add")) {
|
||||
permissions["ADD_GROUP"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/users/add")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/add")) {
|
||||
permissions["ADD_USER"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/users/remove")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/remove")) {
|
||||
permissions["REMOVE_USER"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/roles/add")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/roles/add")) {
|
||||
permissions["ADD_ROLE"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/policies/add")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/policies/add")) {
|
||||
permissions["ADD_ADMIN_POLICY"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/policies/add")) {
|
||||
permissions["ADD_POLICY"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/policies/priority")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/policies/priority")) {
|
||||
permissions["CHANGE_POLICY_PRIORITY"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/dashboard/view")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/dashboard/view")) {
|
||||
permissions["VIEW_DASHBOARD"] = true;
|
||||
}
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/platform-configs/view")) {
|
||||
if (publicMethods.isAuthorized("/permission/admin/device-mgt/platform-configs/view")) {
|
||||
permissions["TENANT_CONFIGURATION"] = true;
|
||||
}
|
||||
|
||||
|
||||
@ -45,9 +45,9 @@ var invokers = function () {
|
||||
* If the token pair is not set in the session, this will return null.
|
||||
*/
|
||||
privateMethods.getAccessToken = function () {
|
||||
var tokenPair = parse(session.get(constants["TOKEN_PAIR"]));
|
||||
var tokenPair = session.get(constants["TOKEN_PAIR"]);
|
||||
if (tokenPair) {
|
||||
return tokenPair["accessToken"];
|
||||
return parse(tokenPair)["accessToken"];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -23,77 +23,87 @@
|
||||
<i class="icon fw fw-home"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{@app.context}}/certificates">
|
||||
Certificates
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{@app.context}}/certificates/add">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-document fw-stack-1x"></i>
|
||||
</span>
|
||||
Add Certificate
|
||||
Add
|
||||
</a>
|
||||
</li>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "content"}}
|
||||
<!-- content/body -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- content -->
|
||||
<div id="certificate-create-form" class="container col-centered wr-content">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Add Certificate</p>
|
||||
<p>Please note that * sign represents required fields of data.</p>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div id="certificate-create-error-msg" class="alert alert-danger hidden" role="alert">
|
||||
<i class="icon fw fw-error"></i><span></span>
|
||||
</div>
|
||||
{{#if isAuthorized}}
|
||||
<!-- content/body -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- content -->
|
||||
<div id="certificate-create-form" class="container col-centered wr-content">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Add Certificate</p>
|
||||
<p>Please note that * sign represents required fields of data.</p>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div id="certificate-create-error-msg" class="alert alert-danger hidden" role="alert">
|
||||
<i class="icon fw fw-error"></i><span></span>
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label ">
|
||||
Serial Number *
|
||||
</label>
|
||||
<br>
|
||||
<div id="serialNoInputField" class="form-group wr-input-control">
|
||||
<input type="text" id="serialNo" class="form-control"/>
|
||||
</div>
|
||||
<label class="wr-input-label">Certificate *</label>
|
||||
<div id="certificateField" class="form-group wr-input-control">
|
||||
<input type="file" id="certificate" class="form-control"/>
|
||||
<label class="wr-input-label ">
|
||||
Serial Number *
|
||||
</label>
|
||||
<br>
|
||||
<div id="serialNoInputField" class="form-group wr-input-control">
|
||||
<input type="text" id="serialNo" class="form-control"/>
|
||||
</div>
|
||||
<label class="wr-input-label">Certificate *</label>
|
||||
<div id="certificateField" class="form-group wr-input-control">
|
||||
<input type="file" id="certificate" class="form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<button id="add-certificate-btn" class="wr-btn">Add Certificate</button>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<button id="add-certificate-btn" class="wr-btn">Add Certificate</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="certificate-created-msg" class="container col-centered wr-content hidden">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Certificate was added successfully.</p>
|
||||
<br>
|
||||
<br>Please click <b>"Add Another Certificate"</b>, if you wish to add another certificate or
|
||||
<div id="certificate-created-msg" class="container col-centered wr-content hidden">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Certificate was added successfully.</p>
|
||||
<br>
|
||||
<br>Please click <b>"Add Another Certificate"</b>, if you wish to add another certificate or
|
||||
click
|
||||
<b>"View Certificate List"</b> to complete the process and go back to the certificate list.
|
||||
<hr/>
|
||||
<button class="wr-btn" onclick="window.location.href='/emm/certificates'">View Certificate List
|
||||
</button>
|
||||
<a href="/emm/certificates/add" class="cu-btn-inner">
|
||||
<b>"View Certificate List"</b> to complete the process and go back to the certificate list.
|
||||
<hr/>
|
||||
<button class="wr-btn" onclick="window.location.href='/emm/certificates'">View Certificate List
|
||||
</button>
|
||||
<a href="/emm/certificates/add" class="cu-btn-inner">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-add fw-stack-1x"></i>
|
||||
</span>
|
||||
Add Another Certificate
|
||||
</a>
|
||||
Add Another Certificate
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /content -->
|
||||
</div>
|
||||
<!-- /content -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /content/body -->
|
||||
<!-- /content/body -->
|
||||
{{else}}
|
||||
<h1 class="page-sub-title">
|
||||
Permission Denied
|
||||
</h1>
|
||||
<br>
|
||||
You not authorized to enter Certificate Management Section.
|
||||
<br>
|
||||
{{/if}}
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "bottomJs"}}
|
||||
|
||||
@ -19,27 +19,28 @@
|
||||
/**
|
||||
* Returns the dynamic state to be populated by add-user page.
|
||||
*
|
||||
* @param context Object that gets updated with the dynamic state of this page to be presented
|
||||
* @returns {*} A context object that returns the dynamic state of this page to be presented
|
||||
* @param viewModel Object that gets updated with the dynamic state of this page to be presented
|
||||
* @returns {*} A viewModel object that returns the dynamic state of this page to be presented
|
||||
*/
|
||||
function onRequest(context) {
|
||||
// var log = new Log("units/user-create/create.js");
|
||||
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
||||
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
|
||||
|
||||
var viewModel = {};
|
||||
viewModel.isAuthorized = userModule.isAuthorized("/permission/admin/device-mgt/certificates/manage");
|
||||
var response = userModule.getRolesByUserStore();
|
||||
if (response["status"] == "success") {
|
||||
context["roles"] = response["content"];
|
||||
viewModel["roles"] = response["content"];
|
||||
}
|
||||
|
||||
context["charLimit"] = mdmProps["usernameLength"];
|
||||
context["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"];
|
||||
context["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"];
|
||||
context["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"];
|
||||
context["firstnameJSRegEx"] = mdmProps["userValidationConfig"]["firstnameJSRegEx"];
|
||||
context["firstnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["firstnameRegExViolationErrorMsg"];
|
||||
context["lastnameJSRegEx"] = mdmProps["userValidationConfig"]["lastnameJSRegEx"];
|
||||
context["lastnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["lastnameRegExViolationErrorMsg"];
|
||||
viewModel["charLimit"] = mdmProps["usernameLength"];
|
||||
viewModel["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"];
|
||||
viewModel["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"];
|
||||
viewModel["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"];
|
||||
viewModel["firstnameJSRegEx"] = mdmProps["userValidationConfig"]["firstnameJSRegEx"];
|
||||
viewModel["firstnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["firstnameRegExViolationErrorMsg"];
|
||||
viewModel["lastnameJSRegEx"] = mdmProps["userValidationConfig"]["lastnameJSRegEx"];
|
||||
viewModel["lastnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["lastnameRegExViolationErrorMsg"];
|
||||
|
||||
return context;
|
||||
return viewModel;
|
||||
}
|
||||
@ -15,6 +15,7 @@
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
}}
|
||||
|
||||
{{unit "cdmf.unit.ui.title" pageTitle="Add Certificate"}}
|
||||
|
||||
{{#zone "breadcrumbs"}}
|
||||
@ -24,14 +25,26 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{@app.context}}/certificates/add">
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/certificates">
|
||||
Certificates
|
||||
</a>
|
||||
</li>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "navbarActions"}}
|
||||
{{#if removePermitted}}
|
||||
<li>
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/certificates/add">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-document fw-stack-1x"></i>
|
||||
</span>
|
||||
Add Certificate
|
||||
</a>
|
||||
</li>
|
||||
Add Certificate
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "content"}}
|
||||
@ -87,10 +100,7 @@
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
<tbody id="ast-container">
|
||||
|
||||
<br class="c-both"/>
|
||||
</tbody>
|
||||
<tbody id="ast-container"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<br class="c-both"/>
|
||||
@ -121,57 +131,58 @@
|
||||
</div>
|
||||
|
||||
<div id="remove-certificate-success-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Done. Certificate was successfully removed.</h3>
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-certificate-success-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">Done. Certificate was successfully removed.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="remove-certificate-error-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>An unexpected error occurred. Please try again later.</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">An unexpected error occurred. Please try again later.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-certificate-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="errorCertificateView" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-error fw-stack-1x"></i>
|
||||
</span>
|
||||
Unauthorized action!
|
||||
</h3>
|
||||
</div>
|
||||
Unauthorized action!
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "bottomJs"}}
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<script id="certificate-listing" data-current-user="{{@user.username}}"
|
||||
src="{{@page.publicUri}}/templates/certificate-listing.hbs"
|
||||
type="text/x-handlebars-template"></script>
|
||||
|
||||
{{js "/js/certificate-listing.js"}}
|
||||
{{/zone}}
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
function onRequest(context) {
|
||||
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
||||
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
|
||||
var viewModel = {};
|
||||
|
||||
context["permissions"] = userModule.getUIPermissions();
|
||||
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/certificate/Get")) {
|
||||
context["removePermitted"] = true;
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/certificates/manage")) {
|
||||
viewModel["removePermitted"] = true;
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/certificate/Get")) {
|
||||
context["viewPermitted"] = true;
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/certificates/view")) {
|
||||
viewModel["viewPermitted"] = true;
|
||||
}
|
||||
context["adminUser"] = mdmProps.adminUser;
|
||||
return context;
|
||||
|
||||
viewModel.adminUser = mdmProps.adminUser;
|
||||
return viewModel;
|
||||
}
|
||||
@ -12,9 +12,9 @@ $(function () {
|
||||
$(sortableElem).disableSelection();
|
||||
});
|
||||
|
||||
var modalPopup = ".wr-modalpopup";
|
||||
var modalPopupContainer = modalPopup + " .modalpopup-container";
|
||||
var modalPopupContent = modalPopup + " .modalpopup-content";
|
||||
var modalPopup = ".modal";
|
||||
var modalPopupContainer = modalPopup + " .modal-content";
|
||||
var modalPopupContent = modalPopup + " .modal-content";
|
||||
var body = "body";
|
||||
var isInit = true;
|
||||
|
||||
@ -34,8 +34,7 @@ function setPopupMaxHeight() {
|
||||
* show popup function.
|
||||
*/
|
||||
function showPopup() {
|
||||
$(modalPopup).show();
|
||||
setPopupMaxHeight();
|
||||
$(modalPopup).modal('show');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -43,7 +42,9 @@ function showPopup() {
|
||||
*/
|
||||
function hidePopup() {
|
||||
$(modalPopupContent).html('');
|
||||
$(modalPopup).hide();
|
||||
$(modalPopup).modal('hide');
|
||||
$('body').removeClass('modal-open').css('padding-right','0px');
|
||||
$('.modal-backdrop').remove();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -36,10 +36,12 @@ function onRequest() {
|
||||
page.permissions = permissions;
|
||||
page.enrollmentURL = devicemgtProps.enrollmentURL;
|
||||
page.device_count = deviceModule.getDevicesCount();
|
||||
page.group_count = groupModule.getGroupCount();
|
||||
page.user_count = userModule.getUsers()["content"].length;
|
||||
page.policy_count = policyModule.getAllPolicies()["content"].length;
|
||||
page.role_count = userModule.getRoles()["content"].length;
|
||||
//TODO: Enable Group Management Service API on CDMF
|
||||
//page.group_count = groupModule.getGroupCount();
|
||||
page.group_count = -1;
|
||||
page.user_count = userModule.getUsersCount();
|
||||
page.policy_count = policyModule.getPoliciesCount();
|
||||
page.role_count = userModule.getRolesCount();
|
||||
|
||||
return page;
|
||||
}
|
||||
}
|
||||
@ -229,61 +229,83 @@
|
||||
</div>
|
||||
|
||||
<div id="remove-device-modal-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Do you really want to remove this device from your Devices List?</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
Do you really want to remove this device from your Devices List?
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-device-yes-link" class="btn-operations">
|
||||
Yes
|
||||
</a>
|
||||
|
||||
<a href="#" id="remove-device-cancel-link" class="btn-operations">
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-device-yes-link" class="btn-operations">
|
||||
Yes
|
||||
</a>
|
||||
|
||||
<a href="#" id="remove-device-cancel-link" class="btn-operations">
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="remove-device-200-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Device was successfully removed.</h3>
|
||||
</div>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
Device was successfully removed.
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">Ok</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="edit-device-modal-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Please enter new name for the device?</h3>
|
||||
<br/>
|
||||
|
||||
<div>
|
||||
<input id="edit-device-name" style="color:#3f3f3f;padding:5px" type="text"
|
||||
value=""
|
||||
placeholder="Type here" size="60">
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<a href="#" id="edit-device-yes-link" class="btn-operations">
|
||||
Rename
|
||||
</a>
|
||||
|
||||
<a href="#" id="edit-device-cancel-link" class="btn-operations">
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
Please enter new name for the device?
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<input id="edit-device-name" style="color:#3f3f3f;padding:5px" type="text"
|
||||
value=""
|
||||
placeholder="Type here" size="60">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="edit-device-yes-link" class="btn-operations">
|
||||
Rename
|
||||
</a>
|
||||
|
||||
<a href="#" id="edit-device-cancel-link" class="btn-operations">
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="edit-device-200-content" class="hide">
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
Device was successfully updated.
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
|
||||
<div id="edit-device-200-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
|
||||
@ -438,9 +438,9 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
var modalPopup = ".wr-modalpopup";
|
||||
var modalPopupContainer = modalPopup + " .modalpopup-container";
|
||||
var modalPopupContent = modalPopup + " .modalpopup-content";
|
||||
var modalPopup = ".modal";
|
||||
var modalPopupContainer = modalPopup + " .modal-content";
|
||||
var modalPopupContent = modalPopup + " .modal-content";
|
||||
var body = "body";
|
||||
|
||||
/*
|
||||
@ -455,8 +455,7 @@ function setPopupMaxHeight() {
|
||||
* show popup function.
|
||||
*/
|
||||
function showPopup() {
|
||||
$(modalPopup).show();
|
||||
setPopupMaxHeight();
|
||||
$(modalPopup).modal('show');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -464,7 +463,9 @@ function showPopup() {
|
||||
*/
|
||||
function hidePopup() {
|
||||
$(modalPopupContent).html('');
|
||||
$(modalPopup).hide();
|
||||
$(modalPopup).modal('hide');
|
||||
$('body').removeClass('modal-open').css('padding-right','0px');
|
||||
$('.modal-backdrop').remove();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -251,9 +251,9 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
var modalPopup = ".wr-modalpopup";
|
||||
var modalPopupContainer = modalPopup + " .modalpopup-container";
|
||||
var modalPopupContent = modalPopup + " .modalpopup-content";
|
||||
var modalPopup = ".modal";
|
||||
var modalPopupContainer = modalPopup + " .modal-content";
|
||||
var modalPopupContent = modalPopup + " .modal-content";
|
||||
var body = "body";
|
||||
|
||||
/*
|
||||
@ -268,8 +268,7 @@ function setPopupMaxHeight() {
|
||||
* show popup function.
|
||||
*/
|
||||
function showPopup() {
|
||||
$(modalPopup).show();
|
||||
setPopupMaxHeight();
|
||||
$(modalPopup).modal('show');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -277,7 +276,9 @@ function showPopup() {
|
||||
*/
|
||||
function hidePopup() {
|
||||
$(modalPopupContent).html('');
|
||||
$(modalPopup).hide();
|
||||
$(modalPopup).modal('hide');
|
||||
$('body').removeClass('modal-open').css('padding-right','0px');
|
||||
$('.modal-backdrop').remove();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "navbarActions"}}
|
||||
{{#if permissions.ADD_ADMIN_POLICY}}
|
||||
{{#if managePermitted}}
|
||||
<li>
|
||||
<a href="{{@app.context}}/policy/add" class="cu-btn">
|
||||
<span class="icon fw-stack">
|
||||
@ -50,8 +50,6 @@
|
||||
Add Policy
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#if permissions.CHANGE_POLICY_PRIORITY}}
|
||||
{{#equal noPolicy false}}
|
||||
<li>
|
||||
<a href="{{@app.context}}/policy/priority" class="cu-btn">
|
||||
@ -81,7 +79,7 @@
|
||||
<div class="ctrl-info-panel col-centered text-center wr-login">
|
||||
<h2>You don't have any policy at the moment.</h2>
|
||||
<br/>
|
||||
{{#if permissions.ADD_ADMIN_POLICY}}
|
||||
{{#if managePermitted}}
|
||||
<p class="text-center">
|
||||
<a href="{{@app.context}}/policy/add" class="wr-btn">
|
||||
<span class="fw-stack">
|
||||
@ -142,7 +140,7 @@
|
||||
<tr class="bulk-action-row">
|
||||
<th colspan="9">
|
||||
<ul class="tiles">
|
||||
{{#if removePermitted}}
|
||||
{{#if managePermitted}}
|
||||
<li class="square">
|
||||
<a href="#" data-click-event="remove-form"
|
||||
class="btn square-element policy-remove-link"
|
||||
@ -258,378 +256,379 @@
|
||||
</div>
|
||||
|
||||
<div id="remove-policy-modal-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Do you really want to remove the selected policy(s)?</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">Do you really want to remove the selected policy(s)?</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-policy-yes-link" class="btn-operations">
|
||||
Remove
|
||||
</a>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-policy-yes-link" class="btn-operations">
|
||||
Remove
|
||||
</a>
|
||||
|
||||
<a href="#" id="remove-policy-cancel-link" class="btn-operations">
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<a href="#" id="remove-policy-cancel-link" class="btn-operations">
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="remove-policy-success-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Done. Selected policy was successfully removed.</h3>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-policy-success-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">Done. Selected policy was successfully removed.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-policy-success-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="remove-policy-error-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>An unexpected error occurred. Please try again later.</h3>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-policy-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">An unexpected error occurred. Please try again later.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-policy-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="remove-policy-error-devices" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>You cannot remove policies that are already applied to devices. Please deselect
|
||||
them and try
|
||||
again.</h3>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-policy-error-devices" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">Cannot Remove Policies.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<h4>You cannot remove policies that are already applied to devices. Please deselect
|
||||
them and try
|
||||
again.</h4>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="remove-policy-error-devices" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="publish-policy-modal-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Do you really want to publish the selected policy(s)?</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">Do you really want to publish the selected policy(s)?</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="publish-policy-yes-link" class="btn-operations">Yes</a>
|
||||
<a href="#" id="publish-policy-cancel-link" class="btn-operations">No</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="publish-policy-yes-link" class="btn-operations">Yes</a>
|
||||
<a href="#" id="publish-policy-cancel-link" class="btn-operations">No</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="publish-policy-success-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Done. Selected policy was successfully published.</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">Done. Selected policy was successfully published.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="publish-policy-success-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="publish-policy-success-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="publish-policy-error-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>An unexpected error occurred. Please try again later.</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">An unexpected error occurred. Please try again later.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="publish-policy-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="publish-policy-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="unpublish-policy-modal-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Do you really want to unpublish the selected policy(s)?</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">Do you really want to unpublish the selected policy(s)?</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="unpublish-policy-yes-link" class="btn-operations">
|
||||
Yes
|
||||
</a>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="unpublish-policy-yes-link" class="btn-operations">
|
||||
Yes
|
||||
</a>
|
||||
|
||||
<a href="#" id="unpublish-policy-cancel-link" class="btn-operations">
|
||||
No
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<a href="#" id="unpublish-policy-cancel-link" class="btn-operations">
|
||||
No
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="unpublish-policy-success-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Done. Selected policy was successfully unpublished.</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">Done. Selected policy was successfully unpublished.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="unpublish-policy-success-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="unpublish-policy-success-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="unpublish-policy-error-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>An unexpected error occurred. Please try again later.</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">An unexpected error occurred. Please try again later.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="unpublish-policy-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="unpublish-policy-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="save-policy-priorities-success-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Done. New Policy priorities were successfully updated.</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">Done. New Policy priorities were successfully updated.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="save-policy-priorities-success-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="save-policy-priorities-success-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="save-policy-priorities-error-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>An unexpected error occurred. Please try again later.</h3>
|
||||
<h4 class="message-from-server"></h4>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">An unexpected error occurred. Please try again later.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="save-policy-priorities-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="save-policy-priorities-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="change-policy-modal-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Do you really want to apply changes to all policies?</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">Do you really want to apply changes to all policies?</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="change-policy-yes-link" class="btn-operations">
|
||||
Yes
|
||||
</a>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="change-policy-yes-link" class="btn-operations">
|
||||
Yes
|
||||
</a>
|
||||
|
||||
<a href="#" id="change-policy-cancel-link" class="btn-operations">
|
||||
No
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<a href="#" id="change-policy-cancel-link" class="btn-operations">
|
||||
No
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="change-policy-success-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Done. Changes applied successfully.</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">Done. Changes applied successfully.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="change-policy-success-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="change-policy-success-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="change-policy-error-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>An unexpected error occurred. Please try again later.</h3>
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">An unexpected error occurred. Please try again later.</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
|
||||
<div class="buttons">
|
||||
<a href="#" id="change-policy-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="#" id="change-policy-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="errorPolicyUnPublish" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>
|
||||
<span class="fw-stack">
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-error fw-stack-1x"></i>
|
||||
</span>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<h4>
|
||||
Please select a policy or a list of policies to unpublish.
|
||||
</h4>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<h4>Please select a policy or a list of policies to unpublish.</h4>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="errorPolicyUnPublishSelection" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>
|
||||
<span class="fw-stack">
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-error fw-stack-1x"></i>
|
||||
</span>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<h4>
|
||||
You cannot select already inactive policies. Please deselect inactive policies
|
||||
and try again.
|
||||
</h4>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<h4>You cannot select already inactive policies. Please deselect inactive policies
|
||||
and try again.</h4>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="errorPolicyPublishSelection" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>
|
||||
<span class="fw-stack">
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-error fw-stack-1x"></i>
|
||||
</span>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<h4>
|
||||
You cannot select already active policies. Please deselect active policies and
|
||||
try again.
|
||||
</h4>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<h4>You cannot select already active policies. Please deselect active policies and
|
||||
try again.</h4>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="errorPolicyPublish" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>
|
||||
<span class="fw-stack">
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-error fw-stack-1x"></i>
|
||||
</span>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<h4>
|
||||
Please select a policy or a list of policies to publish.
|
||||
</h4>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<h4>Please select a policy or a list of policies to publish.</h4>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="errorPolicy" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>
|
||||
<span class="fw-stack">
|
||||
<div class="modal-header">
|
||||
<h3 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-error fw-stack-1x"></i>
|
||||
</span>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<h4>
|
||||
Please select a policy or a list of policies to remove.
|
||||
</h4>
|
||||
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
Operation cannot be performed !
|
||||
</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<h4>Please select a policy or a list of policies to remove.</h4>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -56,15 +56,8 @@ function onRequest(context) {
|
||||
page["noPolicy"] = true;
|
||||
}
|
||||
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/policies/delete")) {
|
||||
page["removePermitted"] = true;
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/policies/manage")) {
|
||||
page.managePermitted = true;
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/policies/remove")) {
|
||||
page["removePermitted"] = true;
|
||||
}
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/policies/update")) {
|
||||
page["editPermitted"] = true;
|
||||
}
|
||||
page.permissions = userModule.getUIPermissions();
|
||||
return page;
|
||||
}
|
||||
|
||||
@ -61,9 +61,9 @@ var sortElements = function () {
|
||||
* Modal related stuff are as follows.
|
||||
*/
|
||||
|
||||
var modalPopup = ".wr-modalpopup";
|
||||
var modalPopupContainer = modalPopup + " .modalpopup-container";
|
||||
var modalPopupContent = modalPopup + " .modalpopup-content";
|
||||
var modalPopup = ".modal";
|
||||
var modalPopupContainer = modalPopup + " .modal-content";
|
||||
var modalPopupContent = modalPopup + " .modal-content";
|
||||
var body = "body";
|
||||
|
||||
/*
|
||||
@ -81,8 +81,7 @@ function setPopupMaxHeight() {
|
||||
* show popup function.
|
||||
*/
|
||||
function showPopup() {
|
||||
$(modalPopup).show();
|
||||
setPopupMaxHeight();
|
||||
$(modalPopup).modal('show');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -90,7 +89,9 @@ function showPopup() {
|
||||
*/
|
||||
function hidePopup() {
|
||||
$(modalPopupContent).html('');
|
||||
$(modalPopup).hide();
|
||||
$(modalPopup).modal('hide');
|
||||
$('body').removeClass('modal-open').css('padding-right','0px');
|
||||
$('.modal-backdrop').remove();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -38,5 +38,14 @@
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "content"}}
|
||||
{{unit "cdmf.unit.policy.priority"}}
|
||||
{{#if isAuthorized}}
|
||||
{{unit "cdmf.unit.policy.priority"}}
|
||||
{{else}}
|
||||
<h1 class="page-sub-title">
|
||||
Permission Denied
|
||||
</h1>
|
||||
<br>
|
||||
You not authorized to enter Policy Management Section.
|
||||
<br>
|
||||
{{/if}}
|
||||
{{/zone}}
|
||||
@ -26,4 +26,7 @@ function onRequest(context){
|
||||
return options.fn(this);
|
||||
}
|
||||
});
|
||||
var viewModel = {};
|
||||
viewModel.isAuthorized = userModule.isAuthorized("/permission/admin/device-mgt/policies/manage");
|
||||
return viewModel;
|
||||
}
|
||||
@ -24,17 +24,128 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/roles">
|
||||
Roles
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{@app.context}}/roles/add-role">
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/role/add">
|
||||
Add
|
||||
</a>
|
||||
</li>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "content"}}
|
||||
{{unit "cdmf.unit.role.create"}}
|
||||
{{#if canManage}}
|
||||
<!-- content/body -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- content -->
|
||||
<div id="role-create-form" class="container col-centered wr-content">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Add Role</p>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="wr-steps">
|
||||
<div class="col-md-6 col-xs-6">
|
||||
<div class="itm-wiz itm-wiz-current" data-step="policy-platform">
|
||||
<div class="wiz-no">1</div>
|
||||
<div class="wiz-lbl hidden-xs"><span>Add a role</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xs-6">
|
||||
<div class="itm-wiz" data-step="policy-profile">
|
||||
<div class="wiz-no">2</div>
|
||||
<div class="wiz-lbl hidden-xs"><span>Assign permissions</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
<br /><br />
|
||||
<hr />
|
||||
<div id="role-create-error-msg" class="alert alert-danger hidden" role="alert">
|
||||
<i class="icon fw fw-error"></i><span></span>
|
||||
</div>
|
||||
<label class="wr-input-label">User Store Domain</label>
|
||||
<div class="wr-input-control">
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<select id="domain" class="form-control select">
|
||||
<option>PRIMARY</option>
|
||||
{{#each userStores}}
|
||||
<option>{{this}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label">
|
||||
Role Name *
|
||||
</label>
|
||||
<br>
|
||||
<label class="wr-input-label">
|
||||
( {{roleNameHelpText}} )
|
||||
</label>
|
||||
|
||||
<div id="roleNameField" class="form-group wr-input-control">
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<input type="text" id="roleName" data-regex="{{roleNameJSRegEx}}"
|
||||
data-error-msg="{{roleNameRegExViolationErrorMsg}}" class="form-control" />
|
||||
<span class="roleNameError hidden glyphicon glyphicon-remove form-control-feedback"></span>
|
||||
<label class="error roleNameEmpty hidden" for="summary">
|
||||
Role name is required, should be in minimum 3 characters long and not include any whitespaces.
|
||||
</label>
|
||||
</div>
|
||||
{{#if canViewUsers}}
|
||||
<label class="wr-input-label">
|
||||
User list
|
||||
</label>
|
||||
|
||||
<div class="wr-input-control">
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<select id="users" class="form-control select2" multiple="multiple"></select>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button id="add-role-btn" class="wr-btn">Add Role</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="role-created-msg" class="container col-centered wr-content hidden">
|
||||
<div class="wr-form">
|
||||
<p class="page-sub-title">Role was added successfully.</p>
|
||||
<br>Please click <b>"Add Another Role"</b>, if you wish to add another role or click
|
||||
<b>"View Role List"</b> to complete the process and go back to the role list.
|
||||
<hr />
|
||||
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/roles'">
|
||||
View Role List
|
||||
</button>
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/role/add" class="cu-btn-inner">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-add fw-stack-1x"></i>
|
||||
</span>
|
||||
Add Another Role
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /content -->
|
||||
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /content/body -->
|
||||
{{else}}
|
||||
<h1 class="page-sub-title">
|
||||
Permission Denied
|
||||
</h1>
|
||||
<br>
|
||||
You not authorized to enter Role Management Section.
|
||||
<br>
|
||||
{{/if}}
|
||||
{{/zone}}
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "js/bottomJs.js"}}
|
||||
{{/zone}}
|
||||
@ -20,19 +20,24 @@
|
||||
* Returns the dynamic state to be populated by add-user page.
|
||||
*
|
||||
* @param context Object that gets updated with the dynamic state of this page to be presented
|
||||
* @returns {*} A context object that returns the dynamic state of this page to be presented
|
||||
* @returns {*} A displayData object that returns the dynamic state of this page to be presented
|
||||
*/
|
||||
function onRequest(context) {
|
||||
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
||||
var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
||||
var response = userModule.getRoles();
|
||||
if (response["status"] == "success") {
|
||||
context["roles"] = response["content"];
|
||||
var displayData = {};
|
||||
|
||||
displayData["userStores"] = userModule.getSecondaryUserStores();
|
||||
displayData["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"];
|
||||
displayData["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"];
|
||||
displayData["roleNameRegExViolationErrorMsg"] = deviceMgtProps["roleValidationConfig"]["roleNameRegExViolationErrorMsg"];
|
||||
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/roles/manage")) {
|
||||
displayData.canManage = true;
|
||||
}
|
||||
var userStores = userModule.getSecondaryUserStores();
|
||||
context["userStores"] = userStores;
|
||||
context["roleNameJSRegEx"] = deviceMgtProps.roleValidationConfig.rolenameJSRegEx;
|
||||
context["roleNameHelpText"] = deviceMgtProps.roleValidationConfig.rolenameHelpMsg;
|
||||
context["roleNameRegExViolationErrorMsg"] = deviceMgtProps.roleValidationConfig.rolenameRegExViolationErrorMsg;
|
||||
return context;
|
||||
if (userModule.isAuthorized("/permission/admin/device-mgt/users/view")) {
|
||||
displayData.canViewUsers = true;
|
||||
}
|
||||
|
||||
return displayData;
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"uri": "/roles/add-role",
|
||||
"uri": "/role/add",
|
||||
"layout": "cdmf.layout.default"
|
||||
}
|
||||
@ -73,19 +73,19 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
|
||||
*clear inline validation messages.
|
||||
*/
|
||||
clearInline["role-name"] = function () {
|
||||
disableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
|
||||
disableInlineError("roleNameField", "roleNameEmpty", "roleNameError");
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Validate if provided rolename is valid against RegEx configures.
|
||||
* Validate if provided role-name is valid against RegEx configures.
|
||||
*/
|
||||
validateInline["role-name"] = function () {
|
||||
var rolenameinput = $("input#rolename");
|
||||
if (inputIsValid( rolenameinput.data("regex"), rolenameinput.val())) {
|
||||
disableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
|
||||
var roleNameInput = $("input#roleName");
|
||||
if (inputIsValid( roleNameInput.data("regex"), roleNameInput.val())) {
|
||||
disableInlineError("roleNameField", "roleNameEmpty", "roleNameError");
|
||||
} else {
|
||||
enableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
|
||||
enableInlineError("roleNameField", "roleNameEmpty", "roleNameError");
|
||||
}
|
||||
};
|
||||
|
||||
@ -97,16 +97,16 @@ function formatRepo (user) {
|
||||
return;
|
||||
}
|
||||
var markup = '<div class="clearfix">' +
|
||||
'<div clas="col-sm-8">' +
|
||||
'<div class="col-sm-8">' +
|
||||
'<div class="clearfix">' +
|
||||
'<div class="col-sm-3">' + user.username + '</div>';
|
||||
if (user.firstname) {
|
||||
markup += '<div class="col-sm-3"><i class="fa fa-code-fork"></i> ' + user.firstname + '</div>';
|
||||
'<div class="col-sm-3">User : ' + user.username + '</div>';
|
||||
if (user.name) {
|
||||
markup += '<div class="col-sm-3"> ' + user.name + '</div>';
|
||||
}
|
||||
if (user.emailAddress) {
|
||||
markup += '<div class="col-sm-2"><i class="fa fa-star"></i> ' + user.emailAddress + '</div></div>';
|
||||
markup += '<div class="col-sm-3"> ' + user.emailAddress + '</div>';
|
||||
}
|
||||
markup += '</div></div>';
|
||||
markup += '</div></div></div>';
|
||||
return markup;
|
||||
}
|
||||
|
||||
@ -129,17 +129,19 @@ $(document).ready(function () {
|
||||
},
|
||||
data: function (params) {
|
||||
var postData = {};
|
||||
postData.actionMethod = "GET";
|
||||
postData.actionUrl = apiBasePath + "/users/search/usernames?filter=" + params.term;
|
||||
postData.actionPayload = null;
|
||||
postData.requestMethod = "GET";
|
||||
postData.requestURL = "/api/device-mgt/v1.0/users/search/usernames?filter=" + params.term;
|
||||
postData.requestPayload = null;
|
||||
return JSON.stringify(postData);
|
||||
},
|
||||
processResults: function (data, page) {
|
||||
processResults: function (data) {
|
||||
var newData = [];
|
||||
$.each(data, function (index, value) {
|
||||
var user = {};
|
||||
user.username = value.username;
|
||||
user.id = value.username;
|
||||
user.username = value.username;
|
||||
user.name = value.firstname + " " + value.lastname;
|
||||
user.emailAddress = value.emailAddress;
|
||||
newData.push(user);
|
||||
});
|
||||
return {
|
||||
@ -159,10 +161,10 @@ $(document).ready(function () {
|
||||
* when a user clicks on "Add Role" button
|
||||
* on Add Role page in WSO2 MDM Console.
|
||||
*/
|
||||
$("button#add-role-btn").click(function() {
|
||||
var rolenameInput = $("input#rolename");
|
||||
var roleName = rolenameInput.val();
|
||||
$("button#add-role-btn").click(function () {
|
||||
var domain = $("#domain").val();
|
||||
var roleNameInput = $("input#roleName");
|
||||
var roleName = roleNameInput.val();
|
||||
var users = $("#users").val();
|
||||
|
||||
var errorMsgWrapper = "#role-create-error-msg";
|
||||
@ -170,8 +172,8 @@ $(document).ready(function () {
|
||||
if (!roleName) {
|
||||
$(errorMsg).text("Role name is a required field. It cannot be empty.");
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
} else if (!inputIsValid(rolenameInput.data("regex"), roleName)) {
|
||||
$(errorMsg).text(rolenameInput.data("errormsg"));
|
||||
} else if (!inputIsValid(roleNameInput.data("regex"), roleName)) {
|
||||
$(errorMsg).text(roleNameInput.data("error-msg"));
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
} else if (!domain) {
|
||||
$(errorMsg).text("Domain is a required field. It cannot be empty.");
|
||||
@ -181,13 +183,11 @@ $(document).ready(function () {
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
} else {
|
||||
var addRoleFormData = {};
|
||||
|
||||
addRoleFormData.roleName = roleName;
|
||||
|
||||
if (domain != "PRIMARY"){
|
||||
addRoleFormData.roleName = domain + "/" + roleName;
|
||||
}
|
||||
if (users == null){
|
||||
if (users == null) {
|
||||
users = [];
|
||||
}
|
||||
addRoleFormData.users = users;
|
||||
@ -197,37 +197,31 @@ $(document).ready(function () {
|
||||
invokerUtil.post(
|
||||
addRoleAPI,
|
||||
addRoleFormData,
|
||||
function (data) {
|
||||
data = JSON.parse(data);
|
||||
if (data.errorMessage) {
|
||||
$(errorMsg).text("Selected user store prompted an error : " + data.errorMessage);
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
} else {
|
||||
function (data, textStatus, jqXHR) {
|
||||
if (jqXHR.status == 201) {
|
||||
// Clearing user input fields.
|
||||
//$("input#rolename").val("");
|
||||
//$("#domain").val("");
|
||||
//// Refreshing with success message
|
||||
//$("#role-create-form").addClass("hidden");
|
||||
//$("#role-created-msg").removeClass("hidden");
|
||||
window.location.href = appContext + '/role/edit-permission/' + roleName;
|
||||
$("input#roleName").val("");
|
||||
$("#domain").val("PRIMARY");
|
||||
$("#users").val("");
|
||||
window.location.href = appContext + "/role/edit-permission/" + roleName;
|
||||
}
|
||||
}, function (data) {
|
||||
if (JSON.parse(data).errorMessage.indexOf("RoleExisting") > -1) {
|
||||
$(errorMsg).text("Role name : " + roleName + " already exists. Pick another role name.");
|
||||
} else {
|
||||
$(errorMsg).text(JSON.parse(data.responseText).errorMessage);
|
||||
},
|
||||
function (jqXHR) {
|
||||
if (jqXHR.status == 500) {
|
||||
$(errorMsg).text("Either role already exists or unexpected error.");
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
}
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$("#rolename").focus(function() {
|
||||
var roleNameInputElement = "#roleName";
|
||||
$(roleNameInputElement).focus(function() {
|
||||
clearInline["role-name"]();
|
||||
});
|
||||
|
||||
$("#rolename").blur(function() {
|
||||
$(roleNameInputElement).blur(function() {
|
||||
validateInline["role-name"]();
|
||||
});
|
||||
});
|
||||
@ -26,6 +26,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/roles">
|
||||
Roles
|
||||
</a>
|
||||
|
||||
@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.
|
||||
*/
|
||||
|
||||
var loadRoleBasedActionURL = function (action, rolename) {
|
||||
var href = $("#ast-container").data("app-context") + "role/" + action + "/" + rolename;
|
||||
$(location).attr('href', href);
|
||||
};
|
||||
|
||||
$(function () {
|
||||
var sortableElem = '.wr-sortable';
|
||||
$(sortableElem).sortable({
|
||||
beforeStop: function () {
|
||||
$(this).sortable('toArray');
|
||||
}
|
||||
});
|
||||
$(sortableElem).disableSelection();
|
||||
});
|
||||
|
||||
var apiBasePath = "/api/device-mgt/v1.0";
|
||||
var modalPopup = ".modal";
|
||||
var modalPopupContainer = modalPopup + " .modal-content";
|
||||
var modalPopupContent = modalPopup + " .modal-content";
|
||||
var body = "body";
|
||||
var isInit = true;
|
||||
$(".icon .text").res_text(0.2);
|
||||
|
||||
|
||||
/*
|
||||
* set popup maximum height function.
|
||||
*/
|
||||
function setPopupMaxHeight() {
|
||||
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
|
||||
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
|
||||
}
|
||||
|
||||
/*
|
||||
* show popup function.
|
||||
*/
|
||||
function showPopup() {
|
||||
$(modalPopup).modal('show');
|
||||
//setPopupMaxHeight();
|
||||
}
|
||||
|
||||
/*
|
||||
* hide popup function.
|
||||
*/
|
||||
function hidePopup() {
|
||||
$(modalPopupContent).html('');
|
||||
$(modalPopup).modal('hide');
|
||||
$('body').removeClass('modal-open').css('padding-right','0px');
|
||||
$('.modal-backdrop').remove();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Following function would execute
|
||||
* when a user clicks on the list item
|
||||
* initial mode and with out select mode.
|
||||
*/
|
||||
function InitiateViewOption() {
|
||||
$(location).attr('href', $(this).data("url"));
|
||||
}
|
||||
|
||||
function loadRoles() {
|
||||
var loadingContent = $("#loading-content");
|
||||
loadingContent.show();
|
||||
|
||||
var dataFilter = function (data) {
|
||||
data = JSON.parse(data);
|
||||
|
||||
var objects = [];
|
||||
|
||||
$(data.roles).each(function( index ) {
|
||||
objects.push(
|
||||
{
|
||||
name: data.roles[index],
|
||||
DT_RowId: "role-" + data.roles[index]
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
var json = {
|
||||
"recordsTotal": data.count,
|
||||
"recordsFiltered": data.count,
|
||||
"data": objects
|
||||
};
|
||||
|
||||
return JSON.stringify(json);
|
||||
};
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
var fnCreatedRow = function (nRow, aData, iDataIndex) {
|
||||
$(nRow).attr('data-type', 'selectable');
|
||||
};
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
var columns = [
|
||||
{
|
||||
class: "remove-padding icon-only content-fill",
|
||||
data: null,
|
||||
defaultContent: "<div class='thumbnail icon'>" +
|
||||
"<i class='square-element text fw fw-bookmark' style='font-size: 30px;'></i>" +
|
||||
"</div>"
|
||||
},
|
||||
{
|
||||
class: "fade-edge",
|
||||
data: "name",
|
||||
render: function (name, type, row, meta) {
|
||||
return '<h4> ' + name + ' role</h4>';
|
||||
}
|
||||
},
|
||||
{
|
||||
class: "text-right content-fill text-left-on-grid-view no-wrap",
|
||||
data: null,
|
||||
render: function (data, type, row, meta) {
|
||||
return ' ' +
|
||||
'<a onclick="javascript:loadRoleBasedActionURL(\'edit\', \'' + data.name + '\')" ' +
|
||||
'data-role="' + data.name + '" ' +
|
||||
'data-click-event="edit-form" ' +
|
||||
'class="btn padding-reduce-on-grid-view edit-role-link">' +
|
||||
'<span class="fw-stack">' +
|
||||
'<i class="fw fw-ring fw-stack-2x"></i>' +
|
||||
'<i class="fw fw-bookmark fw-stack-1x"></i>' +
|
||||
'<span class="fw-stack fw-move-right fw-move-bottom">' +
|
||||
'<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
|
||||
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i>' +
|
||||
'</span>' +
|
||||
'</span>' +
|
||||
'<span class="hidden-xs hidden-on-grid-view"> Edit</span>' +
|
||||
'</a>' +
|
||||
' <a onclick="javascript:loadRoleBasedActionURL(\'edit-permission\', \'' + data.name + '\')" ' +
|
||||
'data-role="' + data.name + '" ' +
|
||||
'data-click-event="edit-form" ' +
|
||||
'class="btn padding-reduce-on-grid-view edit-permission-link">' +
|
||||
'<span class="fw-stack">' +
|
||||
'<i class="fw fw-ring fw-stack-2x"></i>' +
|
||||
'<i class="fw fw-security-policy fw-stack-1x"></i>' +
|
||||
'<span class="fw-stack fw-move-right fw-move-bottom">' +
|
||||
'<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
|
||||
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i>' +
|
||||
'</span>' +
|
||||
'</span>' +
|
||||
'<span class="hidden-xs hidden-on-grid-view"> Edit Permission</span>' +
|
||||
'</a>' +
|
||||
' <a data-role="' + data.name + '" ' +
|
||||
'data-click-event="remove-form" ' +
|
||||
'class="btn padding-reduce-on-grid-view remove-role-link">' +
|
||||
'<span class="fw-stack">' +
|
||||
'<i class="fw fw-ring fw-stack-2x"></i>' +
|
||||
'<i class="fw fw-delete fw-stack-1x"></i>' +
|
||||
'</span>' +
|
||||
'<span class="hidden-xs hidden-on-grid-view"> Remove</span>' +
|
||||
'</a>';
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
var options = {
|
||||
"placeholder": "Search By Role Name",
|
||||
"searchKey" : "filter"
|
||||
};
|
||||
|
||||
$('#role-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/roles', dataFilter, columns, fnCreatedRow, null, options);
|
||||
loadingContent.hide();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Following click function would execute
|
||||
* when a user clicks on "Remove" link
|
||||
* on Role Listing page in WSO2 Devicemgt Console.
|
||||
*/
|
||||
$("#role-grid").on("click", ".remove-role-link", function () {
|
||||
var role = $(this).data("role");
|
||||
var removeRoleAPI = apiBasePath + "/roles/" + role;
|
||||
|
||||
$(modalPopupContent).html($('#remove-role-modal-content').html());
|
||||
showPopup();
|
||||
|
||||
$("a#remove-role-yes-link").click(function () {
|
||||
invokerUtil.delete(
|
||||
removeRoleAPI,
|
||||
function () {
|
||||
$("#role-" + role).remove();
|
||||
$(modalPopupContent).html($('#remove-role-success-content').html());
|
||||
$("a#remove-role-success-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
},
|
||||
function () {
|
||||
$(modalPopupContent).html($('#remove-role-error-content').html());
|
||||
$("a#remove-role-error-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("a#remove-role-cancel-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
loadRoles();
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user