forked from community/device-mgt-core
Sync with upstream master See merge request entgra/carbon-device-mgt!240feature/appm-store/pbac
commit
65c462bcd3
@ -0,0 +1,277 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ Entgra (Pvt) Ltd. 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>device-mgt</artifactId>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<version>3.2.9-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>io.entgra.carbon.device.mgt.config.api</artifactId>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
<name>Entgra Carbon - Mobile Device Management Configuration API</name>
|
||||||
|
<description>Entgra Carbon - Mobile Device Management Configuration API</description>
|
||||||
|
<url>https://entgra.io</url>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<packagingExcludes>WEB-INF/lib/*cxf*.jar</packagingExcludes>
|
||||||
|
<warName>api#device-mgt-config#v1.0</warName>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>jacoco-initialize</id>
|
||||||
|
<goals>
|
||||||
|
<goal>prepare-agent</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>jacoco-site</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>report</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
|
||||||
|
<outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<log4j.configuration>file:src/test/resources/log4j.properties</log4j.configuration>
|
||||||
|
</systemPropertyVariables>
|
||||||
|
<suiteXmlFiles>
|
||||||
|
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
|
||||||
|
</suiteXmlFiles>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>deploy</id>
|
||||||
|
<build>
|
||||||
|
<defaultGoal>compile</defaultGoal>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<tasks>
|
||||||
|
<copy todir="${basedir}/../../../repository/deployment/server/webapps" overwrite="true">
|
||||||
|
<fileset dir="${basedir}/target">
|
||||||
|
<include name="api#device-mgt-config#v1.0.war" />
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
|
</tasks>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>client</id>
|
||||||
|
<build>
|
||||||
|
<defaultGoal>test</defaultGoal>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>java</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-transports-http</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.ws.rs</groupId>
|
||||||
|
<artifactId>jsr311-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.axis2.wso2</groupId>
|
||||||
|
<artifactId>axis2-client</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>javassist</groupId>
|
||||||
|
<artifactId>javassist</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon.identity.framework</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.user.mgt</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-core</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.fasterxml.jackson.module</groupId>
|
||||||
|
<artifactId>jackson-module-jaxb-annotations</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-jaxrs</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.fasterxml.jackson.module</groupId>
|
||||||
|
<artifactId>jackson-module-jaxb-annotations</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.ws.rs</groupId>
|
||||||
|
<artifactId>javax.ws.rs-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.powermock</groupId>
|
||||||
|
<artifactId>powermock-module-testng</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.powermock</groupId>
|
||||||
|
<artifactId>powermock-api-mockito</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
|
<artifactId>tomcat</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
|
<artifactId>tomcat-servlet-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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 io.entgra.carbon.device.mgt.config.jaxrs;
|
||||||
|
|
||||||
|
import javax.servlet.Filter;
|
||||||
|
import javax.servlet.FilterChain;
|
||||||
|
import javax.servlet.FilterConfig;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.ServletRequest;
|
||||||
|
import javax.servlet.ServletResponse;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ApiOriginFilter implements Filter {
|
||||||
|
|
||||||
|
public void doFilter(ServletRequest request, ServletResponse response,
|
||||||
|
FilterChain chain) throws IOException, ServletException {
|
||||||
|
HttpServletResponse res = (HttpServletResponse) response;
|
||||||
|
res.addHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
|
||||||
|
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
|
||||||
|
chain.doFilter(request, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(FilterConfig filterConfig) throws ServletException {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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 io.entgra.carbon.device.mgt.config.jaxrs.beans;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ApiModel(description = "")
|
||||||
|
public class ErrorListItem {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String code = null;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String message = null;
|
||||||
|
|
||||||
|
@ApiModelProperty(required = true, value = "")
|
||||||
|
@JsonProperty("code")
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorListItem() {}
|
||||||
|
|
||||||
|
public ErrorListItem(String code, String msg) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description about individual errors occurred
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(required = true, value = "Description about individual errors occurred")
|
||||||
|
@JsonProperty("message")
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("errorItem {\n");
|
||||||
|
|
||||||
|
sb.append(" code: ").append(code).append("\n");
|
||||||
|
sb.append(" message: ").append(message).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,150 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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 io.entgra.carbon.device.mgt.config.jaxrs.beans;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ApiModel(description = "")
|
||||||
|
public class ErrorResponse {
|
||||||
|
|
||||||
|
private Long code = null;
|
||||||
|
private String message = null;
|
||||||
|
private String description = null;
|
||||||
|
private String moreInfo = null;
|
||||||
|
private List<ErrorListItem> errorItems = new ArrayList<>();
|
||||||
|
|
||||||
|
public ErrorResponse() {}
|
||||||
|
|
||||||
|
@JsonProperty(value = "code")
|
||||||
|
@ApiModelProperty(required = true, value = "")
|
||||||
|
public Long getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(Long code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty(value = "message")
|
||||||
|
@ApiModelProperty(required = true, value = "ErrorResponse message.")
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty(value = "description")
|
||||||
|
@ApiModelProperty(value = "A detail description about the error message.")
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty(value = "moreInfo")
|
||||||
|
@ApiModelProperty(value = "Preferably an url with more details about the error.")
|
||||||
|
public String getMoreInfo() {
|
||||||
|
return moreInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoreInfo(String moreInfo) {
|
||||||
|
this.moreInfo = moreInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addErrorListItem(ErrorListItem item) {
|
||||||
|
this.errorItems.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If there are more than one error list them out. For example, list out validation errors by each field.
|
||||||
|
*/
|
||||||
|
@JsonProperty(value = "errorItems")
|
||||||
|
@ApiModelProperty(value = "If there are more than one error list them out. \n" +
|
||||||
|
"For example, list out validation errors by each field.")
|
||||||
|
public List<ErrorListItem> getErrorItems() {
|
||||||
|
return errorItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorItems(List<ErrorListItem> error) {
|
||||||
|
this.errorItems = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ErrorResponseBuilder {
|
||||||
|
|
||||||
|
private Long code = null;
|
||||||
|
private String message = null;
|
||||||
|
private String description = null;
|
||||||
|
private String moreInfo = null;
|
||||||
|
private List<ErrorListItem> error;
|
||||||
|
|
||||||
|
|
||||||
|
public ErrorResponseBuilder() {
|
||||||
|
this.error = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setCode(long code) {
|
||||||
|
this.code = code;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder setMoreInfo(String moreInfo) {
|
||||||
|
this.moreInfo = moreInfo;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponseBuilder addErrorItem(String code, String msg) {
|
||||||
|
ErrorListItem item = new ErrorListItem();
|
||||||
|
item.setCode(code);
|
||||||
|
item.setMessage(msg);
|
||||||
|
this.error.add(item);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponse build() {
|
||||||
|
ErrorResponse errorResponse = new ErrorResponse();
|
||||||
|
errorResponse.setCode(code);
|
||||||
|
errorResponse.setMessage(message);
|
||||||
|
errorResponse.setErrorItems(error);
|
||||||
|
errorResponse.setDescription(description);
|
||||||
|
errorResponse.setMoreInfo(moreInfo);
|
||||||
|
return errorResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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 io.entgra.carbon.device.mgt.config.jaxrs.common;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.MultivaluedMap;
|
||||||
|
import javax.ws.rs.ext.MessageBodyReader;
|
||||||
|
import javax.ws.rs.ext.MessageBodyWriter;
|
||||||
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||||
|
|
||||||
|
@Provider
|
||||||
|
@Produces(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";
|
||||||
|
|
||||||
|
public boolean isReadable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Gson getGson() {
|
||||||
|
if (gson == null) {
|
||||||
|
final GsonBuilder gsonBuilder = new GsonBuilder();
|
||||||
|
gson = gsonBuilder.setDateFormat(DATE_FORMAT).create();
|
||||||
|
}
|
||||||
|
return gson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object readFrom(Class<Object> objectClass, Type type, Annotation[] annotations,
|
||||||
|
MediaType mediaType, MultivaluedMap<String, String> stringStringMultivaluedMap,
|
||||||
|
InputStream entityStream)
|
||||||
|
throws IOException, WebApplicationException {
|
||||||
|
|
||||||
|
InputStreamReader reader = new InputStreamReader(entityStream, "UTF-8");
|
||||||
|
|
||||||
|
try {
|
||||||
|
return getGson().fromJson(reader, type);
|
||||||
|
} finally {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWriteable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSize(Object o, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeTo(Object object, Class<?> aClass, Type type, Annotation[] annotations,
|
||||||
|
MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap,
|
||||||
|
OutputStream entityStream)
|
||||||
|
throws IOException, WebApplicationException {
|
||||||
|
|
||||||
|
OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
|
||||||
|
try {
|
||||||
|
getGson().toJson(object, type, writer);
|
||||||
|
} finally {
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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 io.entgra.carbon.device.mgt.config.jaxrs.service;
|
||||||
|
|
||||||
|
import io.entgra.carbon.device.mgt.config.jaxrs.beans.ErrorResponse;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import io.swagger.annotations.ApiResponse;
|
||||||
|
import io.swagger.annotations.ApiResponses;
|
||||||
|
import io.swagger.annotations.Extension;
|
||||||
|
import io.swagger.annotations.ExtensionProperty;
|
||||||
|
import io.swagger.annotations.Info;
|
||||||
|
import io.swagger.annotations.ResponseHeader;
|
||||||
|
import io.swagger.annotations.SwaggerDefinition;
|
||||||
|
import io.swagger.annotations.Tag;
|
||||||
|
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||||
|
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.DeviceConfiguration;
|
||||||
|
import org.wso2.carbon.device.mgt.common.search.PropertyMap;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.HeaderParam;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@SwaggerDefinition(
|
||||||
|
info = @Info(
|
||||||
|
version = "1.0.0",
|
||||||
|
title = "",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = "name", value = "DeviceManagementConfiguration"),
|
||||||
|
@ExtensionProperty(name = "context",
|
||||||
|
value = "/api/device-mgt-config/v1.0/configurations"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
),
|
||||||
|
tags = {
|
||||||
|
@Tag(name = "device_management", description = "")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@Path("/configurations")
|
||||||
|
@Api(value = "Device Management Configuration")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Scopes(scopes = {
|
||||||
|
@Scope(
|
||||||
|
name = "View configurations",
|
||||||
|
description = "",
|
||||||
|
key = "perm:view-configuration",
|
||||||
|
permissions = {"/device-mgt/platform-configurations/view"}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
public interface DeviceManagementConfigService {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Getting General device Configurations",
|
||||||
|
notes = "This API is responsible for send device configuration data to an IOT device when the " +
|
||||||
|
"device starts provisioning",
|
||||||
|
tags = "Device Management Configuration"
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully fetched the device configurations.",
|
||||||
|
response = DeviceConfiguration.class,
|
||||||
|
responseContainer = "List",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description = "Date and time the resource has been modified " +
|
||||||
|
"the last time.Used by caches, or in " +
|
||||||
|
"conditional requests."),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad request.\n The request contains invalid parameters"),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 401,
|
||||||
|
message = "Unauthorized.\n The requested is not authorized"),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while " +
|
||||||
|
"fetching device configurations.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
})
|
||||||
|
Response getConfiguration(@ApiParam(
|
||||||
|
name = "token",
|
||||||
|
value = "value for identify an already enrolled and authorized device",
|
||||||
|
required = true)
|
||||||
|
@HeaderParam("token")
|
||||||
|
String token,
|
||||||
|
@ApiParam(
|
||||||
|
name = "properties",
|
||||||
|
value = "The properties list using for query a device",
|
||||||
|
required = true)
|
||||||
|
@QueryParam("properties")
|
||||||
|
String properties);
|
||||||
|
}
|
@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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 io.entgra.carbon.device.mgt.config.jaxrs.service.impl;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonParseException;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import io.entgra.carbon.device.mgt.config.jaxrs.beans.ErrorResponse;
|
||||||
|
import io.entgra.carbon.device.mgt.config.jaxrs.service.DeviceManagementConfigService;
|
||||||
|
import io.entgra.carbon.device.mgt.config.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.common.AppRegistrationCredentials;
|
||||||
|
import org.wso2.carbon.device.mgt.common.ApplicationRegistrationException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.AmbiguousConfigurationException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.DeviceConfiguration;
|
||||||
|
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException;
|
||||||
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
||||||
|
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
|
||||||
|
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.HeaderParam;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Path("/configurations")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public class DeviceManagementConfigServiceImpl implements DeviceManagementConfigService {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(DeviceManagementConfigServiceImpl.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@GET
|
||||||
|
public Response getConfiguration(@HeaderParam("token") String token,
|
||||||
|
@QueryParam("properties") String properties) {
|
||||||
|
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||||
|
try {
|
||||||
|
if (token == null || token.isEmpty()) {
|
||||||
|
String msg = "No valid token property found";
|
||||||
|
log.error(msg);
|
||||||
|
return Response.status(Response.Status.UNAUTHORIZED).entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()
|
||||||
|
).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (properties == null || properties.isEmpty()) {
|
||||||
|
String msg = "Devices configuration retrieval criteria cannot be null or empty.";
|
||||||
|
log.error(msg);
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()
|
||||||
|
).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
properties = parseUriParamsToJSON(properties);
|
||||||
|
Map<String, String> deviceProps = mapper.readValue(properties,
|
||||||
|
new TypeReference<Map<String, String>>() {
|
||||||
|
});
|
||||||
|
deviceProps.put("token", token);
|
||||||
|
DeviceConfiguration devicesConfiguration =
|
||||||
|
dms.getDeviceConfiguration(deviceProps);
|
||||||
|
setAccessTokenToDeviceConfigurations(devicesConfiguration);
|
||||||
|
return Response.status(Response.Status.OK).entity(devicesConfiguration).build();
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error occurred while retrieving configurations";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
|
} catch (DeviceNotFoundException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(e.getMessage()).build()).build();
|
||||||
|
} catch (AmbiguousConfigurationException e) {
|
||||||
|
String msg = "Configurations are ambiguous";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
|
} catch (JsonParseException | JsonMappingException e) {
|
||||||
|
String msg = "Malformed device property structure";
|
||||||
|
log.error(msg.concat(" ").concat(properties), e);
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
|
} catch (IOException e) {
|
||||||
|
String msg = "Error occurred while parsing query param JSON data";
|
||||||
|
log.error(msg.concat(" ").concat(properties), e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
|
||||||
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String parseUriParamsToJSON(String uriParams) {
|
||||||
|
uriParams = uriParams.replaceAll("=", "\":\"");
|
||||||
|
uriParams = uriParams.replaceAll("&", "\",\"");
|
||||||
|
return "{\"" + uriParams + "\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAccessTokenToDeviceConfigurations(DeviceConfiguration devicesConfiguration)
|
||||||
|
throws DeviceManagementException {
|
||||||
|
try {
|
||||||
|
AppRegistrationCredentials credentials =
|
||||||
|
DeviceManagerUtil.getApplicationRegistrationCredentials(
|
||||||
|
System.getProperty(DeviceManagementConstants
|
||||||
|
.ConfigurationManagement.IOT_GATEWAY_HOST),
|
||||||
|
System.getProperty(DeviceManagementConstants
|
||||||
|
.ConfigurationManagement.IOT_GATEWAY_HTTPS_PORT),
|
||||||
|
DeviceManagementConstants.ConfigurationManagement.ADMIN_CREDENTIALS);
|
||||||
|
AccessTokenInfo accessTokenForAdmin = DeviceManagerUtil.getAccessTokenForDeviceOwner(
|
||||||
|
DeviceManagementConstants.ConfigurationManagement.SCOPES_FOR_TOKEN,
|
||||||
|
credentials.getClient_id(), credentials.getClient_secret(),
|
||||||
|
devicesConfiguration.getDeviceOwner());
|
||||||
|
devicesConfiguration.setAccessToken(accessTokenForAdmin.getAccessToken());
|
||||||
|
devicesConfiguration.setRefreshToken(accessTokenForAdmin.getRefreshToken());
|
||||||
|
} catch (ApplicationRegistrationException e) {
|
||||||
|
String msg = "Failure on retrieving application registration";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
} catch (JWTClientException e) {
|
||||||
|
String msg = "Error occurred while creating JWT client : " + e.getMessage();
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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 io.entgra.carbon.device.mgt.config.jaxrs.util;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MDMAPIUtils class provides utility function used by CDM REST-API classes.
|
||||||
|
*/
|
||||||
|
public class DeviceMgtAPIUtils {
|
||||||
|
private static Log log = LogFactory.getLog(DeviceMgtAPIUtils.class);
|
||||||
|
|
||||||
|
public static DeviceManagementProviderService getDeviceManagementService() {
|
||||||
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
DeviceManagementProviderService deviceManagementProviderService =
|
||||||
|
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||||
|
if (deviceManagementProviderService == null) {
|
||||||
|
String msg = "DeviceImpl Management provider service has not initialized.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new IllegalStateException(msg);
|
||||||
|
}
|
||||||
|
return deviceManagementProviderService;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ Entgra (Pvt) Ltd. 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- This file contains the list of permissions that are associated with URL end points
|
||||||
|
of the web app. Each permission should contain the name, permission path ,API path
|
||||||
|
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||||
|
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||||
|
For ex:
|
||||||
|
Actual API endpoint: devicemgt_admin/1.0.0/devices/{device-id}
|
||||||
|
URL to be represented here: /devices/*
|
||||||
|
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||||
|
it will result 403 error at the runtime.
|
||||||
|
-->
|
||||||
|
<PermissionConfiguration>
|
||||||
|
<APIVersion></APIVersion>
|
||||||
|
<!--Permission Tree Name-->
|
||||||
|
<Permission>
|
||||||
|
<name>Device Management Configuration</name>
|
||||||
|
<path>/device-mgt-config</path>
|
||||||
|
<url>/</url>
|
||||||
|
<method>GET</method>
|
||||||
|
</Permission>
|
||||||
|
</PermissionConfiguration>
|
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ Entgra (Pvt) Ltd. 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
|
||||||
|
-->
|
||||||
|
<Classloading xmlns="http://wso2.org/projects/as/classloading">
|
||||||
|
|
||||||
|
<!-- Parent-first or child-first. Default behaviour is child-first.-->
|
||||||
|
<ParentFirst>false</ParentFirst>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
|
||||||
|
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
|
||||||
|
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
|
||||||
|
-->
|
||||||
|
<Environments>CXF,Carbon</Environments>
|
||||||
|
</Classloading>
|
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ Entgra (Pvt) Ltd. 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||||
|
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
||||||
|
|
||||||
|
<jaxrs:server id="services-10" address="/">
|
||||||
|
<jaxrs:serviceBeans>
|
||||||
|
<ref bean="configManagementService"/>
|
||||||
|
</jaxrs:serviceBeans>
|
||||||
|
<jaxrs:providers>
|
||||||
|
<ref bean="jsonProvider"/>
|
||||||
|
</jaxrs:providers>
|
||||||
|
</jaxrs:server>
|
||||||
|
|
||||||
|
<bean id="configManagementService"
|
||||||
|
class="io.entgra.carbon.device.mgt.config.jaxrs.service.impl.DeviceManagementConfigServiceImpl"/>
|
||||||
|
<bean id="jsonProvider" class="io.entgra.carbon.device.mgt.config.jaxrs.common.GsonMessageBodyHandler"/>
|
||||||
|
</beans>
|
@ -0,0 +1,126 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ Entgra (Pvt) Ltd. 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.
|
||||||
|
-->
|
||||||
|
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
|
||||||
|
<display-name>Device-Config-Webapp</display-name>
|
||||||
|
<servlet>
|
||||||
|
<description>JAX-WS/JAX-RS Device Configuration Endpoint</description>
|
||||||
|
<display-name>JAX-WS/JAX-RS Servlet</display-name>
|
||||||
|
<servlet-name>CXFServlet</servlet-name>
|
||||||
|
<servlet-class>
|
||||||
|
org.apache.cxf.transport.servlet.CXFServlet
|
||||||
|
</servlet-class>
|
||||||
|
<!-- configure a security filter -->
|
||||||
|
<init-param>
|
||||||
|
<param-name>swagger.security.filter</param-name>
|
||||||
|
<param-value>ApiAuthorizationFilterImpl</param-value>
|
||||||
|
</init-param>
|
||||||
|
<load-on-startup>1</load-on-startup>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>CXFServlet</servlet-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<session-config>
|
||||||
|
<session-timeout>60</session-timeout>
|
||||||
|
</session-config>
|
||||||
|
|
||||||
|
<context-param>
|
||||||
|
<param-name>doAuthentication</param-name>
|
||||||
|
<param-value>true</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
<context-param>
|
||||||
|
<param-name>nonSecuredEndPoints</param-name>
|
||||||
|
<param-value>
|
||||||
|
/api/device-mgt-config/v1.0/configurations
|
||||||
|
</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
<!--publish to apim-->
|
||||||
|
<context-param>
|
||||||
|
<param-name>managed-api-enabled</param-name>
|
||||||
|
<param-value>true</param-value>
|
||||||
|
</context-param>
|
||||||
|
<context-param>
|
||||||
|
<param-name>managed-api-owner</param-name>
|
||||||
|
<param-value>admin</param-value>
|
||||||
|
</context-param>
|
||||||
|
<context-param>
|
||||||
|
<param-name>isSharedWithAllTenants</param-name>
|
||||||
|
<param-value>true</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
<!-- Below configuration is used to redirect http requests to https -->
|
||||||
|
<security-constraint>
|
||||||
|
<web-resource-collection>
|
||||||
|
<web-resource-name>DeviceMgt-Admin</web-resource-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</web-resource-collection>
|
||||||
|
<user-data-constraint>
|
||||||
|
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
|
||||||
|
</user-data-constraint>
|
||||||
|
</security-constraint>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<filter-name>ApiOriginFilter</filter-name>
|
||||||
|
<filter-class>io.entgra.carbon.device.mgt.config.jaxrs.ApiOriginFilter</filter-class>
|
||||||
|
</filter>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<filter-name>HttpHeaderSecurityFilter</filter-name>
|
||||||
|
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
|
||||||
|
<init-param>
|
||||||
|
<param-name>hstsEnabled</param-name>
|
||||||
|
<param-value>false</param-value>
|
||||||
|
</init-param>
|
||||||
|
</filter>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<filter-name>ContentTypeBasedCachePreventionFilter</filter-name>
|
||||||
|
<filter-class>org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter</filter-class>
|
||||||
|
<init-param>
|
||||||
|
<param-name>patterns</param-name>
|
||||||
|
<param-value>text/html" ,application/json" ,text/plain</param-value>
|
||||||
|
</init-param>
|
||||||
|
<init-param>
|
||||||
|
<param-name>filterAction</param-name>
|
||||||
|
<param-value>enforce</param-value>
|
||||||
|
</init-param>
|
||||||
|
<init-param>
|
||||||
|
<param-name>httpHeaders</param-name>
|
||||||
|
<param-value>Cache-Control: no-store, no-cache, must-revalidate, private</param-value>
|
||||||
|
</init-param>
|
||||||
|
</filter>
|
||||||
|
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>HttpHeaderSecurityFilter</filter-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>ContentTypeBasedCachePreventionFilter</filter-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>ApiOriginFilter</filter-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
|
||||||
|
</web-app>
|
@ -0,0 +1,23 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ Entgra (Pvt) Ltd. 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||||
|
|
||||||
|
<suite name="DeviceManagementExtensions">
|
||||||
|
<parameter name="useDefaultListeners" value="false"/>
|
||||||
|
</suite>
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.beans.analytics;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receiver definition including :
|
||||||
|
* Attributes : Name, type, config and attached stream.
|
||||||
|
*/
|
||||||
|
public class Adapter {
|
||||||
|
@ApiModelProperty(value = "Adapter name")
|
||||||
|
private String adapterName;
|
||||||
|
@ApiModelProperty(value = "Attached stream name:version")
|
||||||
|
private String eventStreamWithVersion;
|
||||||
|
@ApiModelProperty(value = "Adapter type")
|
||||||
|
private AdapterType adapterType;
|
||||||
|
@ApiModelProperty(value = "Adapter main configurations")
|
||||||
|
private AdapterConfiguration adapterConfiguration;
|
||||||
|
|
||||||
|
public String getAdapterName() {
|
||||||
|
return adapterName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdapterName(String adapterName) {
|
||||||
|
this.adapterName = adapterName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEventStreamWithVersion() {
|
||||||
|
return eventStreamWithVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEventStreamWithVersion(String eventStreamWithVersion) {
|
||||||
|
this.eventStreamWithVersion = eventStreamWithVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AdapterType getAdapterType() {
|
||||||
|
return adapterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdapterType(AdapterType adapterType) {
|
||||||
|
this.adapterType = adapterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AdapterConfiguration getAdapterConfiguration() {
|
||||||
|
return adapterConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdapterConfiguration(
|
||||||
|
AdapterConfiguration adapterConfiguration) {
|
||||||
|
this.adapterConfiguration = adapterConfiguration;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.beans.analytics;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter main configurations
|
||||||
|
* Attributes : Adapter properties list, custom-mapping flag, mapping configurations
|
||||||
|
*/
|
||||||
|
public class AdapterConfiguration {
|
||||||
|
@ApiModelProperty(value = "Adapter properties list")
|
||||||
|
private List<AdapterProperty> adapterProperties = new ArrayList<>();
|
||||||
|
@ApiModelProperty(value = "Custom-mapping flag")
|
||||||
|
private boolean isCustomMappingEnabled;
|
||||||
|
@ApiModelProperty(value = "Mapping configurations")
|
||||||
|
private AdapterMappingConfiguration adapterMappingConfiguration;
|
||||||
|
|
||||||
|
public List<AdapterProperty> getAdapterProperties() {
|
||||||
|
return adapterProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdapterProperties(
|
||||||
|
List<AdapterProperty> adapterProperties) {
|
||||||
|
this.adapterProperties = adapterProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomMappingEnabled() {
|
||||||
|
return isCustomMappingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomMappingEnabled(boolean customMappingEnabled) {
|
||||||
|
isCustomMappingEnabled = customMappingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AdapterMappingConfiguration getAdapterMappingConfiguration() {
|
||||||
|
return adapterMappingConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdapterMappingConfiguration(
|
||||||
|
AdapterMappingConfiguration adapterMappingConfiguration) {
|
||||||
|
this.adapterMappingConfiguration = adapterMappingConfiguration;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.beans.analytics;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter mapping configuration definition
|
||||||
|
* Attributes : Mapping format and lists for each type of property
|
||||||
|
*/
|
||||||
|
public class AdapterMappingConfiguration {
|
||||||
|
@ApiModelProperty(value = "Mapping format")
|
||||||
|
private MessageFormat messageFormat;
|
||||||
|
@ApiModelProperty(value = "Input mapping for json,text and xml mappings")
|
||||||
|
private String inputMappingString;
|
||||||
|
@ApiModelProperty(value = "Input mapping for json,map and xml mappings")
|
||||||
|
private List<MappingProperty> inputMappingProperties;
|
||||||
|
@ApiModelProperty(value = "Name-scape mapping for xml mapping")
|
||||||
|
private List<MappingProperty> namespaceMappingProperties;
|
||||||
|
@ApiModelProperty(value = "Correlation mapping for wso2 mapping")
|
||||||
|
private List<MappingProperty> correlationMappingProperties;
|
||||||
|
@ApiModelProperty(value = "Payload mapping for wso2 mapping")
|
||||||
|
private List<MappingProperty> payloadMappingProperties;
|
||||||
|
@ApiModelProperty(value = "Meta mapping for wso2 mapping")
|
||||||
|
private List<MappingProperty> metaMappingProperties;
|
||||||
|
|
||||||
|
public MessageFormat getMessageFormat() {
|
||||||
|
return messageFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageFormat(MessageFormat messageFormat) {
|
||||||
|
this.messageFormat = messageFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInputMappingString() {
|
||||||
|
return inputMappingString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInputMappingString(String inputMappingString) {
|
||||||
|
this.inputMappingString = inputMappingString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MappingProperty> getInputMappingProperties() {
|
||||||
|
return inputMappingProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInputMappingProperties(
|
||||||
|
List<MappingProperty> inputMappingProperties) {
|
||||||
|
this.inputMappingProperties = inputMappingProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MappingProperty> getNamespaceMappingProperties() {
|
||||||
|
return namespaceMappingProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNamespaceMappingProperties(
|
||||||
|
List<MappingProperty> namespaceMappingProperties) {
|
||||||
|
this.namespaceMappingProperties = namespaceMappingProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MappingProperty> getCorrelationMappingProperties() {
|
||||||
|
return correlationMappingProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCorrelationMappingProperties(
|
||||||
|
List<MappingProperty> correlationMappingProperties) {
|
||||||
|
this.correlationMappingProperties = correlationMappingProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MappingProperty> getPayloadMappingProperties() {
|
||||||
|
return payloadMappingProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPayloadMappingProperties(
|
||||||
|
List<MappingProperty> payloadMappingProperties) {
|
||||||
|
this.payloadMappingProperties = payloadMappingProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MappingProperty> getMetaMappingProperties() {
|
||||||
|
return metaMappingProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMetaMappingProperties(
|
||||||
|
List<MappingProperty> metaMappingProperties) {
|
||||||
|
this.metaMappingProperties = metaMappingProperties;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.beans.analytics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receiver properties with it's display name(key) and user input(value)
|
||||||
|
*/
|
||||||
|
public class AdapterProperty {
|
||||||
|
private String key;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.beans.analytics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Available adapter types
|
||||||
|
*/
|
||||||
|
public enum AdapterType {
|
||||||
|
EMAIL, FILE_TAIL, HTTP, IOT_EVENT, JMS, KAFKA, MQTT, OAUTH_MQTT, SOAP, WEBSOCKET, WEBSOCKET_LOCAL,
|
||||||
|
WSO2_EVENT, XMPP, UI, RDBMS, SECURED_WEBSOCKET, CASSANDRA, LOGGER;
|
||||||
|
|
||||||
|
public String toStringFormatted() {
|
||||||
|
return super.toString().toLowerCase().replace("_", "-");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.beans.analytics;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
public class EventPublisher {
|
||||||
|
@ApiModelProperty(value = "Publisher definition")
|
||||||
|
private String definition;
|
||||||
|
|
||||||
|
public String getDefinition() {
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefinition(String definition) {
|
||||||
|
this.definition = definition;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.beans.analytics;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
public class EventReceiver {
|
||||||
|
@ApiModelProperty(value = "Stream definition")
|
||||||
|
private String definition;
|
||||||
|
|
||||||
|
public String getDefinition() {
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefinition(String definition) {
|
||||||
|
this.definition = definition;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.beans.analytics;
|
||||||
|
|
||||||
|
import com.sun.istack.NotNull;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stream definition
|
||||||
|
* Attributes : name, version, definition and attribute data
|
||||||
|
*/
|
||||||
|
public class EventStream {
|
||||||
|
@ApiModelProperty(value = "Stream name")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty(value = "Stream version")
|
||||||
|
private String version;
|
||||||
|
@ApiModelProperty(value = "Stream nickName")
|
||||||
|
private String nickName;
|
||||||
|
@ApiModelProperty(value = "Stream description")
|
||||||
|
private String description;
|
||||||
|
@ApiModelProperty(value = "Meta attribute list")
|
||||||
|
private List<Attribute> metaData;
|
||||||
|
@ApiModelProperty(value = "Correlation attribute list")
|
||||||
|
private List<Attribute> correlationData;
|
||||||
|
@ApiModelProperty(value = "Payload attribute list")
|
||||||
|
private List<Attribute> payloadData;
|
||||||
|
@ApiModelProperty(value = "Stream definition") @NotNull @NotEmpty
|
||||||
|
private String definition;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNickName() {
|
||||||
|
return nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickName(String nickName) {
|
||||||
|
this.nickName = nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Attribute> getMetaData() {
|
||||||
|
return metaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMetaData(
|
||||||
|
List<Attribute> metaData) {
|
||||||
|
this.metaData = metaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Attribute> getCorrelationData() {
|
||||||
|
return correlationData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCorrelationData(
|
||||||
|
List<Attribute> correlationData) {
|
||||||
|
this.correlationData = correlationData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Attribute> getPayloadData() {
|
||||||
|
return payloadData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPayloadData(
|
||||||
|
List<Attribute> payloadData) {
|
||||||
|
this.payloadData = payloadData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefinition() {
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefinition(String definition) {
|
||||||
|
this.definition = definition;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.beans.analytics;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapping property data
|
||||||
|
* Attributes : name, data type and mapping value name
|
||||||
|
*/
|
||||||
|
public class MappingProperty {
|
||||||
|
@ApiModelProperty(value = "Property name")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty(value = "Property data type")
|
||||||
|
private String type;
|
||||||
|
@ApiModelProperty(value = "Property mapping value name")
|
||||||
|
private String valueOf;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValueOf() {
|
||||||
|
return valueOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValueOf(String valueOf) {
|
||||||
|
this.valueOf = valueOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.beans.analytics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message protocol types
|
||||||
|
*/
|
||||||
|
public enum MessageFormat {
|
||||||
|
JSON, MAP, XML, WSO2EVENT, TEXT;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString().toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.beans.analytics;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execution plan definition including :
|
||||||
|
* Attributes : Plan data.
|
||||||
|
*/
|
||||||
|
public class SiddhiExecutionPlan {
|
||||||
|
@ApiModelProperty(value = "Execution plan definition")
|
||||||
|
private String definition;
|
||||||
|
|
||||||
|
public String getDefinition() {
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefinition(String definition) {
|
||||||
|
this.definition = definition;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.exception;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||||
|
|
||||||
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
public class InvalidExecutionPlanException extends WebApplicationException {
|
||||||
|
private String message;
|
||||||
|
private static final long serialVersionUID = 7583096344745990515L;
|
||||||
|
|
||||||
|
public InvalidExecutionPlanException(ErrorResponse error) {
|
||||||
|
super(Response.status(Response.Status.NOT_FOUND).entity(error).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidExecutionPlanException(ErrorDTO errorDTO) {
|
||||||
|
super(Response.status(Response.Status.NOT_FOUND)
|
||||||
|
.entity(errorDTO)
|
||||||
|
.header(Constants.DeviceConstants.HEADER_CONTENT_TYPE, Constants.DeviceConstants.APPLICATION_JSON)
|
||||||
|
.build());
|
||||||
|
message = errorDTO.getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,454 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.service.api;
|
||||||
|
|
||||||
|
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||||
|
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Adapter;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventStream;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.SiddhiExecutionPlan;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventPublisher;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventReceiver;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiResponse;
|
||||||
|
import io.swagger.annotations.ApiResponses;
|
||||||
|
import io.swagger.annotations.Extension;
|
||||||
|
import io.swagger.annotations.ExtensionProperty;
|
||||||
|
import io.swagger.annotations.Info;
|
||||||
|
import io.swagger.annotations.ResponseHeader;
|
||||||
|
import io.swagger.annotations.SwaggerDefinition;
|
||||||
|
import io.swagger.annotations.Tag;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
@SwaggerDefinition(
|
||||||
|
info = @Info(
|
||||||
|
version = "1.0.0",
|
||||||
|
title = "",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = "name", value = "AnalyticsArtifactsManagement"),
|
||||||
|
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/analytics/artifacts"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
),
|
||||||
|
tags = {
|
||||||
|
@Tag(name = "analytics_artifacts_management", description = "")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@Scopes(
|
||||||
|
scopes = {
|
||||||
|
@Scope(
|
||||||
|
name = "Create Event Stream Artifact",
|
||||||
|
description = "Create Event Stream Artifact",
|
||||||
|
key = "perm:analytics:artifacts:stream",
|
||||||
|
permissions = {"/device-mgt/analytics/artifacts/stream/add"}
|
||||||
|
),
|
||||||
|
@Scope(
|
||||||
|
name = "Create Event Receiver Artifact",
|
||||||
|
description = "Create Event Receiver Artifact",
|
||||||
|
key = "perm:analytics:artifacts:receiver",
|
||||||
|
permissions = {"/device-mgt/analytics/artifacts/receiver/add"}
|
||||||
|
),
|
||||||
|
@Scope(
|
||||||
|
name = "Create Event Publisher Artifact",
|
||||||
|
description = "Create Event Publisher Artifact",
|
||||||
|
key = "perm:analytics:artifacts:publisher",
|
||||||
|
permissions = {"/device-mgt/analytics/artifacts/publisher/add"}
|
||||||
|
),
|
||||||
|
@Scope(
|
||||||
|
name = "Create Siddhi Script Artifact",
|
||||||
|
description = "Create Siddhi Script Artifact",
|
||||||
|
key = "perm:analytics:artifacts:siddhi",
|
||||||
|
permissions = {"/device-mgt/analytics/artifacts/siddhi-script/add"}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
@Path("/analytics/artifacts")
|
||||||
|
@Api(value = "Analytics Artifacts Management", description = "This API corresponds to services" +
|
||||||
|
" related to Analytics Artifacts management")
|
||||||
|
public interface AnalyticsArtifactsManagementService {
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/stream/{id}")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Create Event Stream Artifact as String",
|
||||||
|
notes = "Deploy a Json Stream Artifact in Analytics server.",
|
||||||
|
tags = "Analytics Artifacts Management",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:analytics:artifacts:stream")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully deployed the Stream Artifact.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description =
|
||||||
|
"Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while deploying the " +
|
||||||
|
"Stream Artifact.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Response deployEventDefinitionAsString(@PathParam("id") String id,
|
||||||
|
@QueryParam("isEdited") boolean isEdited,
|
||||||
|
@Valid EventStream stream);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/stream")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Create Event Stream Artifact as DTO",
|
||||||
|
notes = "Deploy a Json Stream Artifact in Analytics server.",
|
||||||
|
tags = "Analytics Artifacts Management",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:analytics:artifacts:stream")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully deployed the Stream Artifact.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body"),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description =
|
||||||
|
"Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message = "Bad Request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while deploying the " +
|
||||||
|
"Stream Artifact.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Response deployEventDefinitionAsDto(@Valid EventStream stream);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/receiver/{name}")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Create Event Receiver Artifact as String",
|
||||||
|
notes = "Deploy a XML Event Receiver Artifact in Analytics server.",
|
||||||
|
tags = "Analytics Artifacts Management",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:analytics:artifacts:receiver")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully deployed the Receiver Artifact.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description =
|
||||||
|
"Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message =
|
||||||
|
"Bad Request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while deploying the " +
|
||||||
|
"Event Receiver Artifact.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Response deployEventReceiverAsString(@PathParam("name") String name,
|
||||||
|
@QueryParam("isEdited") boolean isEdited,
|
||||||
|
@Valid EventReceiver receiver);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/receiver")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Create Event Receiver Artifact as DTO",
|
||||||
|
notes = "Deploy a JSON Event Receiver Artifact in Analytics server.",
|
||||||
|
tags = "Analytics Artifacts Management",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:analytics:artifacts:receiver")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully deployed the Receiver Artifact.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description =
|
||||||
|
"Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message =
|
||||||
|
"Bad Request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while deploying the " +
|
||||||
|
"Event Receiver Artifact.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Response deployEventReceiverAsDto(@Valid Adapter receiver);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/publisher/{name}")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Create Event Publisher Artifact as String",
|
||||||
|
notes = "Deploy a XML Event Publisher Artifact in Analytics server.",
|
||||||
|
tags = "Analytics Artifacts Management",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:analytics:artifacts:publisher")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully deployed the Publisher Artifact.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description =
|
||||||
|
"Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message =
|
||||||
|
"Bad Request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while deploying the " +
|
||||||
|
"Event Publisher Artifact.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Response deployEventPublisherAsString(@PathParam("name") String name,
|
||||||
|
@QueryParam("isEdited") boolean isEdited,
|
||||||
|
@Valid EventPublisher publisher);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/publisher")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Create Event Publisher Artifact as DTO",
|
||||||
|
notes = "Deploy a JSON Event Publisher Artifact in Analytics server.",
|
||||||
|
tags = "Analytics Artifacts Management",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:analytics:artifacts:publisher")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully deployed the Publisher Artifact.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description =
|
||||||
|
"Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message =
|
||||||
|
"Bad Request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while deploying the " +
|
||||||
|
"Event Publisher Artifact.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Response deployEventPublisherAsDto(@Valid Adapter publisher);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("/siddhi-script/{name}")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Create Siddhi Script Artifact as String",
|
||||||
|
notes = "Deploy a SiddhiQL Siddhi script Artifact in Analytics server.",
|
||||||
|
tags = "Analytics Artifacts Management",
|
||||||
|
extensions = {
|
||||||
|
@Extension(properties = {
|
||||||
|
@ExtensionProperty(name = Constants.SCOPE, value = "perm:analytics:artifacts:siddhi")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ApiResponses(
|
||||||
|
value = {
|
||||||
|
@ApiResponse(
|
||||||
|
code = 200,
|
||||||
|
message = "OK. \n Successfully deployed the Siddhi script Artifact.",
|
||||||
|
responseHeaders = {
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Content-Type",
|
||||||
|
description = "The content type of the body."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "ETag",
|
||||||
|
description = "Entity Tag of the response resource.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
@ResponseHeader(
|
||||||
|
name = "Last-Modified",
|
||||||
|
description =
|
||||||
|
"Date and time the resource was last modified.\n" +
|
||||||
|
"Used by caches, or in conditional requests."),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 400,
|
||||||
|
message =
|
||||||
|
"Bad Request."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 406,
|
||||||
|
message = "Not Acceptable.\n The requested media type is not supported."),
|
||||||
|
@ApiResponse(
|
||||||
|
code = 500,
|
||||||
|
message = "Internal Server Error. \n Server error occurred while " +
|
||||||
|
"deploying the Siddhi script Artifact.",
|
||||||
|
response = ErrorResponse.class)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Response deploySiddhiExecutableScript(
|
||||||
|
@PathParam("name") String name, @QueryParam("isEdited") boolean isEdited,
|
||||||
|
@Valid SiddhiExecutionPlan plan);
|
||||||
|
}
|
@ -0,0 +1,724 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.jaxrs.service.impl;
|
||||||
|
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Attribute;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AdapterMappingConfiguration;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.MappingProperty;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AdapterConfiguration;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AdapterProperty;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.MessageFormat;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.SiddhiExecutionPlan;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventPublisher;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventReceiver;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.exception.ErrorDTO;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.exception.InvalidExecutionPlanException;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.AnalyticsArtifactsManagementService;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Adapter;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventStream;
|
||||||
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
|
import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub;
|
||||||
|
import org.wso2.carbon.event.publisher.stub.EventPublisherAdminServiceStub;
|
||||||
|
import org.wso2.carbon.event.publisher.stub.types.BasicOutputAdapterPropertyDto;
|
||||||
|
import org.wso2.carbon.event.publisher.stub.types.EventPublisherConfigurationDto;
|
||||||
|
import org.wso2.carbon.event.receiver.stub.EventReceiverAdminServiceStub;
|
||||||
|
import org.wso2.carbon.event.receiver.stub.types.BasicInputAdapterPropertyDto;
|
||||||
|
import org.wso2.carbon.event.receiver.stub.types.EventMappingPropertyDto;
|
||||||
|
import org.wso2.carbon.event.receiver.stub.types.EventReceiverConfigurationDto;
|
||||||
|
import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub;
|
||||||
|
import org.wso2.carbon.event.stream.stub.types.EventStreamAttributeDto;
|
||||||
|
import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto;
|
||||||
|
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
|
||||||
|
import org.wso2.carbon.user.api.UserStoreException;
|
||||||
|
|
||||||
|
import org.apache.axis2.AxisFault;
|
||||||
|
import org.apache.axis2.client.Stub;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.rmi.RemoteException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is used to create endpoints to serve the deployment of streams, publishers, receivers,
|
||||||
|
* siddhi scripts to the Analytics server as Artifacts
|
||||||
|
*/
|
||||||
|
@Path("/analytics/artifacts")
|
||||||
|
public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifactsManagementService {
|
||||||
|
private static final Log log = LogFactory.getLog(AnalyticsArtifactsManagementServiceImpl.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stream EventStream object with the properties of the stream
|
||||||
|
* @return A status code depending on the code result
|
||||||
|
* Function - Used to deploy stream as an artifact using a String
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@POST
|
||||||
|
@Path("/stream/{id}")
|
||||||
|
public Response deployEventDefinitionAsString(@PathParam("id") String id,
|
||||||
|
@QueryParam("isEdited") boolean isEdited,
|
||||||
|
@Valid EventStream stream) {
|
||||||
|
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||||
|
EventStreamAdminServiceStub eventStreamAdminServiceStub = null;
|
||||||
|
try {
|
||||||
|
String streamDefinition = new String(stream.getDefinition().getBytes(), StandardCharsets.UTF_8);
|
||||||
|
eventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub();
|
||||||
|
if (!isEdited) {
|
||||||
|
eventStreamAdminServiceStub.addEventStreamDefinitionAsString(streamDefinition);
|
||||||
|
} else {
|
||||||
|
// Find and edit stream
|
||||||
|
if (eventStreamAdminServiceStub.getStreamDetailsForStreamId(id) != null) {
|
||||||
|
eventStreamAdminServiceStub.editEventStreamDefinitionAsString(streamDefinition, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Response.ok().build();
|
||||||
|
} catch (AxisFault e) {
|
||||||
|
log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (JWTClientException e) {
|
||||||
|
log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (UserStoreException e) {
|
||||||
|
log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} finally {
|
||||||
|
cleanup(eventStreamAdminServiceStub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stream EventStream object with the properties of the stream
|
||||||
|
* @return A status code depending on the code result
|
||||||
|
* Function - Used to deploy stream as an artifact using a DTO
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@POST
|
||||||
|
@Path("/stream")
|
||||||
|
public Response deployEventDefinitionAsDto(@Valid EventStream stream) {
|
||||||
|
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||||
|
// Categorize attributes to three lists depending on their type
|
||||||
|
List<Attribute> metaData = stream.getMetaData();
|
||||||
|
List<Attribute> payloadData = stream.getPayloadData();
|
||||||
|
List<Attribute> correlationData = stream.getCorrelationData();
|
||||||
|
|
||||||
|
try {
|
||||||
|
/* Conditions
|
||||||
|
* - At least one list should always be not null
|
||||||
|
*/
|
||||||
|
if (metaData == null && correlationData == null && payloadData == null) {
|
||||||
|
log.error("Invalid payload: event attributes");
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Publish the event stream
|
||||||
|
publishStream(stream, metaData, correlationData, payloadData);
|
||||||
|
return Response.ok().build();
|
||||||
|
}
|
||||||
|
} catch (AxisFault e) {
|
||||||
|
log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (JWTClientException e) {
|
||||||
|
log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (UserStoreException e) {
|
||||||
|
log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name Receiver name
|
||||||
|
* @param isEdited If receiver is created or edited
|
||||||
|
* @param receiver Receiver object with the properties of the receiver
|
||||||
|
* @return A status code depending on the code result
|
||||||
|
* Function - Used to deploy receiver as an artifact using a String
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@POST
|
||||||
|
@Path("/receiver/{name}")
|
||||||
|
public Response deployEventReceiverAsString(@PathParam("name") String name,
|
||||||
|
@QueryParam("isEdited") boolean isEdited,
|
||||||
|
@Valid EventReceiver receiver) {
|
||||||
|
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||||
|
EventReceiverAdminServiceStub eventReceiverAdminServiceStub;
|
||||||
|
try {
|
||||||
|
String receiverDefinition = receiver.getDefinition();
|
||||||
|
eventReceiverAdminServiceStub = DeviceMgtAPIUtils.getEventReceiverAdminServiceStub();
|
||||||
|
if (!isEdited) {
|
||||||
|
eventReceiverAdminServiceStub.deployEventReceiverConfiguration(receiverDefinition);
|
||||||
|
} else {
|
||||||
|
eventReceiverAdminServiceStub.editActiveEventReceiverConfiguration(receiverDefinition, name);
|
||||||
|
}
|
||||||
|
} catch (AxisFault e) {
|
||||||
|
log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (JWTClientException e) {
|
||||||
|
log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (UserStoreException e) {
|
||||||
|
log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
}
|
||||||
|
return Response.ok().entity(name).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param receiver Receiver object with the properties of the receiver
|
||||||
|
* @return A status code depending on the code result
|
||||||
|
* Function - Used to deploy receiver as an artifact using a DTO
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@POST
|
||||||
|
@Path("/receiver")
|
||||||
|
public Response deployEventReceiverAsDto(@Valid Adapter receiver) {
|
||||||
|
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||||
|
String receiverName = receiver.getAdapterName();
|
||||||
|
String adapterType = receiver.getAdapterType().toStringFormatted();
|
||||||
|
AdapterConfiguration adapterConfiguration = receiver.getAdapterConfiguration();
|
||||||
|
AdapterMappingConfiguration adapterMappingConfiguration = adapterConfiguration.getAdapterMappingConfiguration();
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<AdapterProperty> adapterProperties = adapterConfiguration.getAdapterProperties();
|
||||||
|
if (adapterProperties == null) {
|
||||||
|
log.error("Invalid attribute payload");
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean customMapping = adapterConfiguration.isCustomMappingEnabled();
|
||||||
|
List<MappingProperty> inputMappingProperties = adapterMappingConfiguration.getInputMappingProperties();
|
||||||
|
List<MappingProperty> namespaceMappingProperties = adapterMappingConfiguration.getNamespaceMappingProperties();
|
||||||
|
List<MappingProperty> correlationMappingProperties = adapterMappingConfiguration.getCorrelationMappingProperties();
|
||||||
|
List<MappingProperty> payloadMappingProperties = adapterMappingConfiguration.getPayloadMappingProperties();
|
||||||
|
List<MappingProperty> metaMappingProperties = adapterMappingConfiguration.getMetaMappingProperties();
|
||||||
|
MessageFormat messageFormat = adapterMappingConfiguration.getMessageFormat();
|
||||||
|
/*
|
||||||
|
* Conditions
|
||||||
|
* - if CustomMappingEnabled check validity of property lists
|
||||||
|
* - if both inputMappingProperties and namespaceMappingProperties null check remaining property lists
|
||||||
|
* - if all correlationMappingProperties, payloadMappingProperties, metaMappingProperties null log error
|
||||||
|
* - if message format is null change the final result to TRUE
|
||||||
|
* - else continue
|
||||||
|
* */
|
||||||
|
if ((customMapping &&
|
||||||
|
(inputMappingProperties == null && namespaceMappingProperties == null) &&
|
||||||
|
(correlationMappingProperties == null && payloadMappingProperties == null &&
|
||||||
|
metaMappingProperties == null)) || messageFormat == null) {
|
||||||
|
String errMsg = "Invalid mapping payload";
|
||||||
|
log.error(errMsg);
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build();
|
||||||
|
}
|
||||||
|
String eventStreamWithVersion = receiver.getEventStreamWithVersion();
|
||||||
|
|
||||||
|
publishReceiver(receiverName, adapterType, adapterProperties, customMapping, inputMappingProperties,
|
||||||
|
namespaceMappingProperties, correlationMappingProperties, payloadMappingProperties,
|
||||||
|
metaMappingProperties, messageFormat, eventStreamWithVersion);
|
||||||
|
return Response.ok().build();
|
||||||
|
} catch (AxisFault e) {
|
||||||
|
log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (JWTClientException e) {
|
||||||
|
log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (UserStoreException e) {
|
||||||
|
log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name Publisher name
|
||||||
|
* @param isEdited If receiver is created or edited
|
||||||
|
* @param publisher Publisher object with the properties of the publisher
|
||||||
|
* @return A status code depending on the code result
|
||||||
|
* Function - Used to deploy publisher as an artifact using a String
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@POST
|
||||||
|
@Path("/publisher/{name}")
|
||||||
|
public Response deployEventPublisherAsString(@PathParam("name") String name,
|
||||||
|
@QueryParam("isEdited") boolean isEdited,
|
||||||
|
@Valid EventPublisher publisher) {
|
||||||
|
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||||
|
EventPublisherAdminServiceStub eventPublisherAdminServiceStub;
|
||||||
|
|
||||||
|
try {
|
||||||
|
String publisherDefinition = publisher.getDefinition();
|
||||||
|
|
||||||
|
eventPublisherAdminServiceStub = DeviceMgtAPIUtils.getEventPublisherAdminServiceStub();
|
||||||
|
if (!isEdited) {
|
||||||
|
eventPublisherAdminServiceStub.deployEventPublisherConfiguration(publisherDefinition);
|
||||||
|
} else {
|
||||||
|
eventPublisherAdminServiceStub.editActiveEventPublisherConfiguration(publisherDefinition, name);
|
||||||
|
}
|
||||||
|
} catch (AxisFault e) {
|
||||||
|
log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (JWTClientException e) {
|
||||||
|
log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (UserStoreException e) {
|
||||||
|
log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
}
|
||||||
|
return Response.ok().entity(publisher).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param publisher Publisher object with the properties of the publisher
|
||||||
|
* @return A status code depending on the code result
|
||||||
|
* Function - Used to deploy publisher as an artifact using a DTO
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@POST
|
||||||
|
@Path("/publisher")
|
||||||
|
public Response deployEventPublisherAsDto(@Valid Adapter publisher) {
|
||||||
|
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||||
|
String publisherName = publisher.getAdapterName();
|
||||||
|
String adapterType = publisher.getAdapterType().toStringFormatted();
|
||||||
|
AdapterConfiguration adapterConfiguration = publisher.getAdapterConfiguration();
|
||||||
|
AdapterMappingConfiguration adapterMappingConfiguration = adapterConfiguration.getAdapterMappingConfiguration();
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<AdapterProperty> adapterProperties = adapterConfiguration.getAdapterProperties();
|
||||||
|
if (adapterProperties == null) {
|
||||||
|
log.error("Invalid attribute payload");
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean customMapping = adapterConfiguration.isCustomMappingEnabled();
|
||||||
|
String inputMappingString = adapterMappingConfiguration.getInputMappingString();
|
||||||
|
List<MappingProperty> inputMappingProperties = adapterMappingConfiguration.getInputMappingProperties();
|
||||||
|
List<MappingProperty> correlationMappingProperties = adapterMappingConfiguration.getCorrelationMappingProperties();
|
||||||
|
List<MappingProperty> payloadMappingProperties = adapterMappingConfiguration.getPayloadMappingProperties();
|
||||||
|
List<MappingProperty> metaMappingProperties = adapterMappingConfiguration.getMetaMappingProperties();
|
||||||
|
MessageFormat messageFormat = adapterMappingConfiguration.getMessageFormat();
|
||||||
|
/*
|
||||||
|
* Conditions
|
||||||
|
* - if CustomMappingEnabled check validity of property lists
|
||||||
|
* - if all correlationMappingProperties, payloadMappingProperties, metaMappingProperties null log error
|
||||||
|
* - if message format is null change the final result to TRUE
|
||||||
|
* - else continue
|
||||||
|
*/
|
||||||
|
if ((customMapping &&
|
||||||
|
(inputMappingProperties == null && inputMappingString == null) &&
|
||||||
|
(correlationMappingProperties == null && payloadMappingProperties == null &&
|
||||||
|
metaMappingProperties == null)) || messageFormat == null) {
|
||||||
|
String errMsg = "Invalid mapping payload";
|
||||||
|
log.error(errMsg);
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build();
|
||||||
|
}
|
||||||
|
String eventStreamWithVersion = publisher.getEventStreamWithVersion();
|
||||||
|
|
||||||
|
publishPublisher(publisherName, adapterType, adapterProperties, customMapping
|
||||||
|
, inputMappingString, inputMappingProperties, correlationMappingProperties
|
||||||
|
, payloadMappingProperties, metaMappingProperties, messageFormat
|
||||||
|
, eventStreamWithVersion);
|
||||||
|
return Response.ok().build();
|
||||||
|
} catch (AxisFault e) {
|
||||||
|
log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (JWTClientException e) {
|
||||||
|
log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (UserStoreException e) {
|
||||||
|
log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name Siddhi plan name
|
||||||
|
* @param isEdited If receiver is created or edited
|
||||||
|
* @param plan Siddhi plan definition
|
||||||
|
* @return a status code depending on the code execution
|
||||||
|
* Function - Used to deploy Siddhi script as an artifact using a String
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@POST
|
||||||
|
@Path("/siddhi-script/{name}")
|
||||||
|
public Response deploySiddhiExecutableScript(@PathParam("name") String name,
|
||||||
|
@QueryParam("isEdited") boolean isEdited,
|
||||||
|
@Valid SiddhiExecutionPlan plan) {
|
||||||
|
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||||
|
try {
|
||||||
|
publishSiddhiExecutionPlan(name, isEdited, plan.getDefinition());
|
||||||
|
return Response.ok().build();
|
||||||
|
} catch (AxisFault e) {
|
||||||
|
log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (InvalidExecutionPlanException e) {
|
||||||
|
log.error("Invalid Execution plan: " + tenantDomain, e);
|
||||||
|
return e.getResponse();
|
||||||
|
} catch (JWTClientException e) {
|
||||||
|
log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
} catch (UserStoreException e) {
|
||||||
|
log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stream Stream definition
|
||||||
|
* @param metaData Meta attributes of the stream
|
||||||
|
* @param correlationData Correlation attributes of the stream
|
||||||
|
* @param payloadData Payload attributes of the stream
|
||||||
|
* @throws RemoteException exception that may occur during a remote method call
|
||||||
|
* @throws UserStoreException exception that may occur during JWT token generation
|
||||||
|
* @throws JWTClientException exception that may occur during connecting to client store
|
||||||
|
*/
|
||||||
|
private void publishStream(EventStream stream, List<Attribute> metaData,
|
||||||
|
List<Attribute> correlationData, List<Attribute> payloadData)
|
||||||
|
throws RemoteException, UserStoreException, JWTClientException {
|
||||||
|
EventStreamAdminServiceStub eventStreamAdminServiceStub =
|
||||||
|
DeviceMgtAPIUtils.getEventStreamAdminServiceStub();
|
||||||
|
try {
|
||||||
|
EventStreamDefinitionDto eventStreamDefinitionDto = new EventStreamDefinitionDto();
|
||||||
|
eventStreamDefinitionDto.setName(stream.getName());
|
||||||
|
eventStreamDefinitionDto.setVersion(stream.getVersion());
|
||||||
|
eventStreamDefinitionDto.setNickName(stream.getNickName());
|
||||||
|
eventStreamDefinitionDto.setDescription(stream.getDescription());
|
||||||
|
eventStreamDefinitionDto.setMetaData(addEventAttributesToDto(metaData));
|
||||||
|
eventStreamDefinitionDto.setPayloadData(addEventAttributesToDto(payloadData));
|
||||||
|
eventStreamDefinitionDto.setCorrelationData(addEventAttributesToDto(correlationData));
|
||||||
|
String streamId = stream.getName() + ":" + stream.getVersion();
|
||||||
|
if (eventStreamAdminServiceStub.getStreamDefinitionDto(streamId) != null) {
|
||||||
|
eventStreamAdminServiceStub.editEventStreamDefinitionAsDto(eventStreamDefinitionDto, streamId);
|
||||||
|
} else {
|
||||||
|
eventStreamAdminServiceStub.addEventStreamDefinitionAsDto(eventStreamDefinitionDto);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
cleanup(eventStreamAdminServiceStub);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param receiverName Receiver name
|
||||||
|
* @param adapterType Receiver type
|
||||||
|
* @param adapterProperties Receiver properties
|
||||||
|
* @param customMapping Is receiver mapped
|
||||||
|
* @param inputMappingProperties Receiver input attribute mapping
|
||||||
|
* @param namespaceMappingProperties Receiver name-scape attribute mapping
|
||||||
|
* @param correlationMappingProperties Receiver correlation attribute mapping
|
||||||
|
* @param payloadMappingProperties Receiver payload attribute mapping
|
||||||
|
* @param metaMappingProperties Receiver meta attribute mapping
|
||||||
|
* @param messageFormat Receiver mapping format
|
||||||
|
* @param eventStreamWithVersion Attached stream
|
||||||
|
* @throws RemoteException exception that may occur during a remote method call
|
||||||
|
* @throws UserStoreException exception that may occur during JWT token generation
|
||||||
|
* @throws JWTClientException exception that may occur during connecting to client store
|
||||||
|
*/
|
||||||
|
private void publishReceiver(String receiverName, String adapterType,
|
||||||
|
List<AdapterProperty> adapterProperties, boolean customMapping,
|
||||||
|
List<MappingProperty> inputMappingProperties,
|
||||||
|
List<MappingProperty> namespaceMappingProperties,
|
||||||
|
List<MappingProperty> correlationMappingProperties,
|
||||||
|
List<MappingProperty> payloadMappingProperties,
|
||||||
|
List<MappingProperty> metaMappingProperties,
|
||||||
|
MessageFormat messageFormat,
|
||||||
|
String eventStreamWithVersion)
|
||||||
|
throws RemoteException, UserStoreException, JWTClientException {
|
||||||
|
EventReceiverAdminServiceStub eventReceiverAdminServiceStub = DeviceMgtAPIUtils.getEventReceiverAdminServiceStub();
|
||||||
|
|
||||||
|
try {
|
||||||
|
EventReceiverConfigurationDto eventReceiverConfigurationDto = eventReceiverAdminServiceStub
|
||||||
|
.getActiveEventReceiverConfiguration(receiverName);
|
||||||
|
|
||||||
|
// Check if adapter already exists, if so un-deploy it
|
||||||
|
if (eventReceiverConfigurationDto != null) {
|
||||||
|
eventReceiverAdminServiceStub.undeployActiveEventReceiverConfiguration(receiverName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adding attribute properties to DTOs
|
||||||
|
BasicInputAdapterPropertyDto[] basicInputAdapterPropertyDtos =
|
||||||
|
addReceiverConfigToDto(adapterProperties);
|
||||||
|
|
||||||
|
if (eventReceiverAdminServiceStub.getActiveEventReceiverConfiguration(receiverName) == null) {
|
||||||
|
// Call stub deploy methods according to the message format
|
||||||
|
if (!messageFormat.toString().equals("wso2event")) {
|
||||||
|
EventMappingPropertyDto[] inputMappingPropertyDtos =
|
||||||
|
addReceiverMappingToDto(inputMappingProperties);
|
||||||
|
if (messageFormat.toString().equals("xml")) {
|
||||||
|
EventMappingPropertyDto[] namespaceMappingPropertyDtos =
|
||||||
|
addReceiverMappingToDto(namespaceMappingProperties);
|
||||||
|
|
||||||
|
eventReceiverAdminServiceStub.deployXmlEventReceiverConfiguration(receiverName
|
||||||
|
, eventStreamWithVersion, adapterType, null
|
||||||
|
, namespaceMappingPropertyDtos, inputMappingPropertyDtos
|
||||||
|
, basicInputAdapterPropertyDtos, customMapping);
|
||||||
|
} else {
|
||||||
|
if (messageFormat.toString().equals("map")) {
|
||||||
|
eventReceiverAdminServiceStub.deployMapEventReceiverConfiguration(receiverName
|
||||||
|
, eventStreamWithVersion, adapterType, inputMappingPropertyDtos
|
||||||
|
, basicInputAdapterPropertyDtos, customMapping);
|
||||||
|
} else if (messageFormat.toString().equals("text")) {
|
||||||
|
eventReceiverAdminServiceStub.deployTextEventReceiverConfiguration(receiverName
|
||||||
|
, eventStreamWithVersion, adapterType, inputMappingPropertyDtos
|
||||||
|
, basicInputAdapterPropertyDtos, customMapping);
|
||||||
|
} else {
|
||||||
|
eventReceiverAdminServiceStub.deployJsonEventReceiverConfiguration(receiverName
|
||||||
|
, eventStreamWithVersion, adapterType, inputMappingPropertyDtos
|
||||||
|
, basicInputAdapterPropertyDtos, customMapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
EventMappingPropertyDto[] correlationMappingPropertyDtos = addReceiverMappingToDto(correlationMappingProperties);
|
||||||
|
EventMappingPropertyDto[] metaMappingPropertyDtos = addReceiverMappingToDto(metaMappingProperties);
|
||||||
|
EventMappingPropertyDto[] payloadMappingPropertyDtos = addReceiverMappingToDto(payloadMappingProperties);
|
||||||
|
|
||||||
|
eventReceiverAdminServiceStub.deployWso2EventReceiverConfiguration(receiverName
|
||||||
|
, eventStreamWithVersion, adapterType, metaMappingPropertyDtos
|
||||||
|
, correlationMappingPropertyDtos, payloadMappingPropertyDtos
|
||||||
|
, basicInputAdapterPropertyDtos, customMapping
|
||||||
|
, eventStreamWithVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
cleanup(eventReceiverAdminServiceStub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param publisherName Publisher name
|
||||||
|
* @param adapterType Publisher type
|
||||||
|
* @param adapterProperties Publisher properties
|
||||||
|
* @param customMapping Is publisher mapped
|
||||||
|
* @param correlationMappingProperties Publisher correlation attribute mapping
|
||||||
|
* @param payloadMappingProperties Publisher payload attribute mapping
|
||||||
|
* @param metaMappingProperties Publisher meta attribute mapping
|
||||||
|
* @param messageFormat Publisher mapping format
|
||||||
|
* @param eventStreamWithVersion Attached stream
|
||||||
|
* @throws RemoteException exception that may occur during a remote method call
|
||||||
|
* @throws UserStoreException exception that may occur during JWT token generation
|
||||||
|
* @throws JWTClientException exception that may occur during connecting to client store
|
||||||
|
*/
|
||||||
|
private void publishPublisher(String publisherName, String adapterType,
|
||||||
|
List<AdapterProperty> adapterProperties,
|
||||||
|
boolean customMapping,
|
||||||
|
String inputMappingString,
|
||||||
|
List<MappingProperty> inputMappingProperties,
|
||||||
|
List<MappingProperty> correlationMappingProperties,
|
||||||
|
List<MappingProperty> payloadMappingProperties,
|
||||||
|
List<MappingProperty> metaMappingProperties,
|
||||||
|
MessageFormat messageFormat,
|
||||||
|
String eventStreamWithVersion)
|
||||||
|
throws RemoteException, UserStoreException, JWTClientException {
|
||||||
|
EventPublisherAdminServiceStub eventPublisherAdminServiceStub = DeviceMgtAPIUtils.getEventPublisherAdminServiceStub();
|
||||||
|
// Check if adapter already exists, if so un-deploy it
|
||||||
|
try {
|
||||||
|
EventPublisherConfigurationDto eventPublisherConfigurationDto = eventPublisherAdminServiceStub
|
||||||
|
.getActiveEventPublisherConfiguration(publisherName);
|
||||||
|
if (eventPublisherConfigurationDto != null) {
|
||||||
|
eventPublisherAdminServiceStub.undeployActiveEventPublisherConfiguration(publisherName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adding attribute properties to DTOs
|
||||||
|
BasicOutputAdapterPropertyDto[] basicOutputAdapterPropertyDtos =
|
||||||
|
addPublisherConfigToDto(adapterProperties);
|
||||||
|
|
||||||
|
if (eventPublisherAdminServiceStub.getActiveEventPublisherConfiguration(publisherName) == null) {
|
||||||
|
// Call stub deploy methods according to the message format
|
||||||
|
if (!messageFormat.toString().equals("wso2event")) {
|
||||||
|
if (!messageFormat.toString().equals("map")) {
|
||||||
|
if (messageFormat.toString().equals("xml")) {
|
||||||
|
eventPublisherAdminServiceStub.deployXmlEventPublisherConfiguration(publisherName
|
||||||
|
, eventStreamWithVersion, adapterType, inputMappingString
|
||||||
|
, basicOutputAdapterPropertyDtos, eventStreamWithVersion
|
||||||
|
, customMapping);
|
||||||
|
} else if (messageFormat.toString().equals("text")) {
|
||||||
|
eventPublisherAdminServiceStub.deployTextEventPublisherConfiguration(publisherName
|
||||||
|
, eventStreamWithVersion, adapterType, inputMappingString
|
||||||
|
, basicOutputAdapterPropertyDtos, eventStreamWithVersion
|
||||||
|
, customMapping);
|
||||||
|
} else {
|
||||||
|
eventPublisherAdminServiceStub.deployJsonEventPublisherConfiguration(publisherName
|
||||||
|
, eventStreamWithVersion, adapterType, inputMappingString
|
||||||
|
, basicOutputAdapterPropertyDtos, eventStreamWithVersion
|
||||||
|
, customMapping);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] inputMappingPropertyDtos =
|
||||||
|
addPublisherMappingToDto(inputMappingProperties);
|
||||||
|
eventPublisherAdminServiceStub.deployMapEventPublisherConfiguration(publisherName
|
||||||
|
, eventStreamWithVersion, adapterType, inputMappingPropertyDtos
|
||||||
|
, basicOutputAdapterPropertyDtos, customMapping);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] correlationMappingPropertyDtos =
|
||||||
|
addPublisherMappingToDto(correlationMappingProperties);
|
||||||
|
org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] metaMappingPropertyDtos =
|
||||||
|
addPublisherMappingToDto(metaMappingProperties);
|
||||||
|
org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] payloadMappingPropertyDtos =
|
||||||
|
addPublisherMappingToDto(payloadMappingProperties);
|
||||||
|
|
||||||
|
eventPublisherAdminServiceStub.deployWSO2EventPublisherConfiguration(publisherName
|
||||||
|
, eventStreamWithVersion, adapterType, metaMappingPropertyDtos
|
||||||
|
, correlationMappingPropertyDtos, payloadMappingPropertyDtos
|
||||||
|
, basicOutputAdapterPropertyDtos, customMapping
|
||||||
|
, eventStreamWithVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
cleanup(eventPublisherAdminServiceStub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name plan name
|
||||||
|
* @param isEdited is plan edited
|
||||||
|
* @param plan plan data
|
||||||
|
* @throws RemoteException exception that may occur during a remote method call
|
||||||
|
* @throws UserStoreException exception that may occur during JWT token generation
|
||||||
|
* @throws JWTClientException exception that may occur during connecting to client store
|
||||||
|
* @throws InvalidExecutionPlanException exception that may occur if execution plan validation fails
|
||||||
|
*/
|
||||||
|
private void publishSiddhiExecutionPlan(String name, boolean isEdited,
|
||||||
|
String plan)
|
||||||
|
throws RemoteException, UserStoreException, JWTClientException,
|
||||||
|
InvalidExecutionPlanException {
|
||||||
|
EventProcessorAdminServiceStub eventProcessorAdminServiceStub = null;
|
||||||
|
try {
|
||||||
|
eventProcessorAdminServiceStub = DeviceMgtAPIUtils.getEventProcessorAdminServiceStub();
|
||||||
|
// Validate the plan code
|
||||||
|
String validationResponse = eventProcessorAdminServiceStub.validateExecutionPlan(plan);
|
||||||
|
if (validationResponse.equals("success")) {
|
||||||
|
if (!isEdited) {
|
||||||
|
// Create a new plan
|
||||||
|
eventProcessorAdminServiceStub.deployExecutionPlan(plan);
|
||||||
|
} else {
|
||||||
|
// Edit plan
|
||||||
|
eventProcessorAdminServiceStub.editActiveExecutionPlan(plan, name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ErrorDTO errorDTO = new ErrorDTO();
|
||||||
|
errorDTO.setMessage(validationResponse);
|
||||||
|
throw new InvalidExecutionPlanException(errorDTO);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
cleanup(eventProcessorAdminServiceStub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private EventStreamAttributeDto[] addEventAttributesToDto(List<Attribute> attributes) {
|
||||||
|
EventStreamAttributeDto[] eventStreamAttributeDtos = new EventStreamAttributeDto[attributes.size()];
|
||||||
|
for (int i = 0; i < attributes.size(); i++) {
|
||||||
|
EventStreamAttributeDto eventStreamAttributeDto = new EventStreamAttributeDto();
|
||||||
|
eventStreamAttributeDto.setAttributeName(attributes.get(i).getName());
|
||||||
|
eventStreamAttributeDto.setAttributeType(attributes.get(i).getType().toString());
|
||||||
|
eventStreamAttributeDtos[i] = eventStreamAttributeDto;
|
||||||
|
}
|
||||||
|
return eventStreamAttributeDtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private BasicInputAdapterPropertyDto[] addReceiverConfigToDto(
|
||||||
|
List<AdapterProperty> adapterProperties) {
|
||||||
|
BasicInputAdapterPropertyDto[] basicInputAdapterPropertyDtos
|
||||||
|
= new BasicInputAdapterPropertyDto[adapterProperties.size()];
|
||||||
|
for (int i = 0; i < adapterProperties.size(); i++) {
|
||||||
|
BasicInputAdapterPropertyDto basicInputAdapterPropertyDto = new BasicInputAdapterPropertyDto();
|
||||||
|
basicInputAdapterPropertyDto.setKey(adapterProperties.get(i).getKey());
|
||||||
|
basicInputAdapterPropertyDto.setValue(adapterProperties.get(i).getValue());
|
||||||
|
basicInputAdapterPropertyDtos[i] = basicInputAdapterPropertyDto;
|
||||||
|
}
|
||||||
|
return basicInputAdapterPropertyDtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private EventMappingPropertyDto[] addReceiverMappingToDto(List<MappingProperty> mapProperties) {
|
||||||
|
EventMappingPropertyDto[] eventMappingPropertyDtos = new EventMappingPropertyDto[mapProperties.size()];
|
||||||
|
for (int i = 0; i < mapProperties.size(); i++) {
|
||||||
|
EventMappingPropertyDto eventMappingPropertyDto = new EventMappingPropertyDto();
|
||||||
|
eventMappingPropertyDto.setName(mapProperties.get(i).getName());
|
||||||
|
eventMappingPropertyDto.setType(mapProperties.get(i).getType());
|
||||||
|
eventMappingPropertyDto.setValueOf(mapProperties.get(i).getValueOf());
|
||||||
|
eventMappingPropertyDtos[i] = eventMappingPropertyDto;
|
||||||
|
}
|
||||||
|
return eventMappingPropertyDtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BasicOutputAdapterPropertyDto[] addPublisherConfigToDto(
|
||||||
|
List<AdapterProperty> adapterProperties) {
|
||||||
|
BasicOutputAdapterPropertyDto[] basicOutputAdapterPropertyDtos =
|
||||||
|
new BasicOutputAdapterPropertyDto[adapterProperties.size()];
|
||||||
|
for (int i = 0; i < adapterProperties.size(); i++) {
|
||||||
|
BasicOutputAdapterPropertyDto basicOutputAdapterPropertyDto =
|
||||||
|
new BasicOutputAdapterPropertyDto();
|
||||||
|
basicOutputAdapterPropertyDto.setKey(adapterProperties.get(i).getKey());
|
||||||
|
basicOutputAdapterPropertyDto.setValue(adapterProperties.get(i).getValue());
|
||||||
|
basicOutputAdapterPropertyDtos[i] = basicOutputAdapterPropertyDto;
|
||||||
|
}
|
||||||
|
return basicOutputAdapterPropertyDtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] addPublisherMappingToDto
|
||||||
|
(List<MappingProperty> mapProperties) {
|
||||||
|
org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] eventMappingPropertyDtos
|
||||||
|
= new org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[mapProperties.size()];
|
||||||
|
for (int i = 0; i < mapProperties.size(); i++) {
|
||||||
|
org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto eventMappingPropertyDto
|
||||||
|
= new org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto();
|
||||||
|
eventMappingPropertyDto.setName(mapProperties.get(i).getName());
|
||||||
|
eventMappingPropertyDto.setType(mapProperties.get(i).getType());
|
||||||
|
eventMappingPropertyDto.setValueOf(mapProperties.get(i).getValueOf());
|
||||||
|
eventMappingPropertyDtos[i] = eventMappingPropertyDto;
|
||||||
|
}
|
||||||
|
return eventMappingPropertyDtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cleanup(Stub stub) {
|
||||||
|
if (stub != null) {
|
||||||
|
try {
|
||||||
|
stub.cleanup();
|
||||||
|
} catch (AxisFault axisFault) {
|
||||||
|
log.warn("Failed to clean the stub " + stub.getClass());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap application registration response payload
|
||||||
|
*/
|
||||||
|
public class AppRegistrationCredentials {
|
||||||
|
private String client_id;
|
||||||
|
private String client_secret;
|
||||||
|
|
||||||
|
public String getClient_id() {
|
||||||
|
return client_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClient_id(String client_id) {
|
||||||
|
this.client_id = client_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClient_secret() {
|
||||||
|
return client_secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClient_secret(String client_secret) {
|
||||||
|
this.client_secret = client_secret;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.common;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is use to wrap and send
|
||||||
|
* Application registration data to the API publisher
|
||||||
|
* Use only for application registration doing inside the IoTs
|
||||||
|
*/
|
||||||
|
public class ApplicationRegistration {
|
||||||
|
private String applicationName;
|
||||||
|
private List<String> tags;
|
||||||
|
private boolean isAllowedToAllDomains;
|
||||||
|
private long validityPeriod;
|
||||||
|
|
||||||
|
public String getApplicationName() {
|
||||||
|
return applicationName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplicationName(String applicationName) {
|
||||||
|
this.applicationName = applicationName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTags(List<String> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAllowedToAllDomains() {
|
||||||
|
return isAllowedToAllDomains;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowedToAllDomains(boolean allowedToAllDomains) {
|
||||||
|
isAllowedToAllDomains = allowedToAllDomains;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getValidityPeriod() {
|
||||||
|
return validityPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidityPeriod(long validityPeriod) {
|
||||||
|
this.validityPeriod = validityPeriod;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throw this if any errors throw when the application registration API calling
|
||||||
|
*/
|
||||||
|
public class ApplicationRegistrationException extends Exception {
|
||||||
|
private static final long serialVersionUID = 4718132518977041928L;
|
||||||
|
|
||||||
|
public ApplicationRegistrationException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationRegistrationException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationRegistrationException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationRegistrationException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationRegistrationException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws if any arguments send to an API is wrong or invalid
|
||||||
|
*/
|
||||||
|
public class InvalidArgumentException extends Exception {
|
||||||
|
private static final long serialVersionUID = -2365244687985953509L;
|
||||||
|
|
||||||
|
public InvalidArgumentException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidArgumentException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidArgumentException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidArgumentException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidArgumentException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package org.wso2.carbon.device.mgt.common.configuration.mgt;
|
||||||
|
|
||||||
|
public class AmbiguousConfigurationException extends Exception{
|
||||||
|
private static final long serialVersionUID = 7039039961721642766L;
|
||||||
|
|
||||||
|
public AmbiguousConfigurationException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AmbiguousConfigurationException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AmbiguousConfigurationException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AmbiguousConfigurationException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AmbiguousConfigurationException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.common.configuration.mgt;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is use to wrap and send device configuration data
|
||||||
|
* to the device
|
||||||
|
*/
|
||||||
|
@ApiModel(value = "DeviceConfiguration", description = "This class carries all information related to " +
|
||||||
|
"Device configurations required to communicate with " +
|
||||||
|
"the server")
|
||||||
|
public class DeviceConfiguration {
|
||||||
|
@ApiModelProperty(name = "deviceId", value = "ID of the device", required = true)
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "deviceType", value = "Type of the device", required = true)
|
||||||
|
private String deviceType;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "tenantDomain", value = "Tenant which the device owned")
|
||||||
|
private String tenantDomain;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "configurationEntries", value = "Platform Configurations", required = true)
|
||||||
|
private List<ConfigurationEntry> configurationEntries;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "accessToken", value = "Token that can be use to communicate with the server")
|
||||||
|
private String accessToken;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "refreshToken", value = "Token that can be use to communicate with the server")
|
||||||
|
private String refreshToken;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "deviceOwner", value = "Owner of the selected device", required = true)
|
||||||
|
private String deviceOwner;
|
||||||
|
|
||||||
|
public String getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceId(String deviceId) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceType() {
|
||||||
|
return deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceType(String deviceType) {
|
||||||
|
this.deviceType = deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantDomain() {
|
||||||
|
return tenantDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTenantDomain(String tenantDomain) {
|
||||||
|
this.tenantDomain = tenantDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConfigurationEntry> getConfigurationEntries() {
|
||||||
|
return configurationEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigurationEntries(
|
||||||
|
List<ConfigurationEntry> configurationEntries) {
|
||||||
|
this.configurationEntries = configurationEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccessToken() {
|
||||||
|
return accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccessToken(String accessToken) {
|
||||||
|
this.accessToken = accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceOwner() {
|
||||||
|
return deviceOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceOwner(String deviceOwner) {
|
||||||
|
this.deviceOwner = deviceOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRefreshToken() {
|
||||||
|
return refreshToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRefreshToken(String refreshToken) {
|
||||||
|
this.refreshToken = refreshToken;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.common.configuration.mgt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This bean is use for retrieve and wrap device property info get from DB
|
||||||
|
*/
|
||||||
|
public class DevicePropertyInfo {
|
||||||
|
private String deviceIdentifier = "default";
|
||||||
|
private String deviceTypeName = "default";
|
||||||
|
private String tenantId = "default";
|
||||||
|
|
||||||
|
public String getDeviceIdentifier() {
|
||||||
|
return deviceIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceIdentifier(String deviceIdentifier) {
|
||||||
|
this.deviceIdentifier = deviceIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantId() {
|
||||||
|
return tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTenantId(String tenantId) {
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceTypeName() {
|
||||||
|
return deviceTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceTypeName(String deviceTypeName) {
|
||||||
|
this.deviceTypeName = deviceTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj instanceof DevicePropertyInfo) {
|
||||||
|
DevicePropertyInfo devicePropertyInfo = (DevicePropertyInfo)obj;
|
||||||
|
return devicePropertyInfo.getDeviceIdentifier().equals(this.deviceIdentifier)
|
||||||
|
&& devicePropertyInfo.getDeviceTypeName().equals(this.deviceTypeName)
|
||||||
|
&& devicePropertyInfo.getTenantId().equals(this.tenantId);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package org.wso2.carbon.device.mgt.core.dao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws if the querying device is not found in the DB
|
||||||
|
*/
|
||||||
|
public class DeviceNotFoundDAOException extends Exception {
|
||||||
|
private static final long serialVersionUID = 2126172787830234694L;
|
||||||
|
|
||||||
|
public DeviceNotFoundDAOException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceNotFoundDAOException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceNotFoundDAOException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceNotFoundDAOException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceNotFoundDAOException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
108
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-wso2-1.3.0/css/font-wso2.css → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-entgra-1.4.0/css/font-entgra.css
108
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-wso2-1.3.0/css/font-wso2.css → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-entgra-1.4.0/css/font-entgra.css
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 177 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
35
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-wso2-1.3.0/icons.json → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-entgra-1.4.0/icons.json
35
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-wso2-1.3.0/icons.json → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-entgra-1.4.0/icons.json
File diff suppressed because one or more lines are too long
92
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-wso2-1.3.0/scss/_mixin.scss → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-entgra-1.4.0/scss/_mixin.scss
92
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-wso2-1.3.0/scss/_mixin.scss → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/lib/font-entgra-1.4.0/scss/_mixin.scss
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 446 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,4 @@
|
|||||||
instructions.configure = \
|
instructions.configure = \
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
|
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.api_${feature.version}/webapps/api#device-mgt#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt#v1.0.war,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.api_${feature.version}/webapps/api#device-mgt#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt#v1.0.war,overwrite:true);\
|
||||||
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.api_${feature.version}/webapps/api#device-mgt-config#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt-config#v1.0.war,overwrite:true);\
|
||||||
|
Loading…
Reference in new issue