forked from community/device-mgt-core
Merge pull request #803 from ayyoob/devicetype-3.1.0
Adding Device type API Implementationrevert-70aa11f8
commit
63c8e87d98
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.extensions.device.type.deployer;
|
||||
|
||||
import org.apache.axis2.context.ConfigurationContext;
|
||||
import org.apache.axis2.deployment.AbstractDeployer;
|
||||
import org.apache.axis2.deployment.DeploymentException;
|
||||
import org.apache.axis2.deployment.repository.util.DeploymentFileData;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.utils.CarbonUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* This is the device deployer that will read and deploy the device type ui files from
|
||||
* "deployment/server/devicetypes-ui"
|
||||
* directory.
|
||||
*/
|
||||
public class DeviceTypeUIDeployer extends AbstractDeployer {
|
||||
|
||||
private static Log log = LogFactory.getLog(DeviceTypeUIDeployer.class);
|
||||
protected Map<String, String> deviceTypeDeployedUIMap = new ConcurrentHashMap<String, String>();
|
||||
private static final String DEVICEMGT_JAGGERY_APP_PATH = CarbonUtils.getCarbonRepository() + File.separator
|
||||
+ "jaggeryapps" + File.separator + "devicemgt" + File.separator + "app" + File.separator + "units"
|
||||
+ File.separator;
|
||||
|
||||
private static final String UNIT_PREFIX = "cdmf.unit.device.type";
|
||||
|
||||
@Override
|
||||
public void init(ConfigurationContext configurationContext) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirectory(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExtension(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
|
||||
if (!deploymentFileData.getFile().isDirectory()) {
|
||||
return;
|
||||
}
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
|
||||
if (tenantDomain != null && !tenantDomain.isEmpty()) {
|
||||
File jaggeryAppPath = new File(
|
||||
DEVICEMGT_JAGGERY_APP_PATH + tenantDomain + "." + deploymentFileData.getName());
|
||||
try {
|
||||
if (!jaggeryAppPath.exists()) {
|
||||
FileUtils.forceMkdir(jaggeryAppPath);
|
||||
FileUtils.copyDirectory(deploymentFileData.getFile(), jaggeryAppPath);
|
||||
File[] listOfFiles = jaggeryAppPath.listFiles();
|
||||
|
||||
for (int i = 0; i < listOfFiles.length; i++) {
|
||||
if (listOfFiles[i].isFile()) {
|
||||
String content = FileUtils.readFileToString(listOfFiles[i]);
|
||||
FileUtils.writeStringToFile(listOfFiles[i], content.replaceAll(UNIT_PREFIX
|
||||
, tenantDomain + "." + UNIT_PREFIX));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.debug("units already exists " + deploymentFileData.getName());
|
||||
}
|
||||
this.deviceTypeDeployedUIMap.put(deploymentFileData.getAbsolutePath(),
|
||||
jaggeryAppPath.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
if (jaggeryAppPath.exists()) {
|
||||
try {
|
||||
FileUtils.deleteDirectory(jaggeryAppPath);
|
||||
} catch (IOException e1) {
|
||||
log.error("Failed to delete directory " + jaggeryAppPath.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
log.error("Cannot deploy deviceType ui : " + deploymentFileData.getName(), e);
|
||||
throw new DeploymentException(
|
||||
"Device type ui file " + deploymentFileData.getName() + " is not deployed ", e);
|
||||
}
|
||||
|
||||
} else {
|
||||
log.error("Cannot deploy deviceType ui: " + deploymentFileData.getName());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undeploy(String filePath) throws DeploymentException {
|
||||
try {
|
||||
String jaggeryUnitPath = this.deviceTypeDeployedUIMap.remove(filePath);
|
||||
FileUtils.deleteDirectory(new File(jaggeryUnitPath));
|
||||
log.info("Device Type units un deployed successfully.");
|
||||
} catch (IOException e) {
|
||||
throw new DeploymentException("Failed to remove the units: " + filePath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.annotation.XmlElementDecl;
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* This object contains factory methods for each
|
||||
* Java content interface and Java element interface
|
||||
* generated in the org.wso2.carbon package.
|
||||
* <p>An ObjectFactory allows you to programatically
|
||||
* construct new instances of the Java representation
|
||||
* for XML content. The Java representation of XML
|
||||
* content can consist of schema derived interfaces
|
||||
* and classes representing the binding of schema
|
||||
* type definitions, element declarations and model
|
||||
* groups. Factory methods for each of these are
|
||||
* provided in this class.
|
||||
*
|
||||
*/
|
||||
@XmlRegistry
|
||||
public class ObjectFactory {
|
||||
|
||||
private final static QName _DeviceTypeConfiguration_QNAME = new QName("", "DeviceTypeConfiguration");
|
||||
|
||||
/**
|
||||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.wso2.carbon
|
||||
*
|
||||
*/
|
||||
public ObjectFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link DeviceTypeConfiguration }
|
||||
*
|
||||
*/
|
||||
public DeviceTypeConfiguration createDeviceTypeConfiguration() {
|
||||
return new DeviceTypeConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Operation }
|
||||
*
|
||||
*/
|
||||
public Operation createOperation() {
|
||||
return new Operation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Attributes }
|
||||
*
|
||||
*/
|
||||
public Attributes createAttributes() {
|
||||
return new Attributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link ProvisioningConfig }
|
||||
*
|
||||
*/
|
||||
public ProvisioningConfig createProvisioningConfig() {
|
||||
return new ProvisioningConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link TableConfig }
|
||||
*
|
||||
*/
|
||||
public TableConfig createTableConfig() {
|
||||
return new TableConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Table }
|
||||
*
|
||||
*/
|
||||
public Table createTable() {
|
||||
return new Table();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Property }
|
||||
*
|
||||
*/
|
||||
public Property createProperty() {
|
||||
return new Property();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JndiConfig }
|
||||
*
|
||||
*/
|
||||
public JndiConfig createJndiConfig() {
|
||||
return new JndiConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link FormParameters }
|
||||
*
|
||||
*/
|
||||
public FormParameters createFormParameters() {
|
||||
return new FormParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Features }
|
||||
*
|
||||
*/
|
||||
public Features createFeatures() {
|
||||
return new Features();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link Feature }
|
||||
*
|
||||
*/
|
||||
public Feature createFeature() {
|
||||
return new Feature();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link PushNotificationProvider }
|
||||
*
|
||||
*/
|
||||
public PushNotificationProvider createPushNotificationProvider() {
|
||||
return new PushNotificationProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link DataSource }
|
||||
*
|
||||
*/
|
||||
public DataSource createDataSource() {
|
||||
return new DataSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link ConfigProperties }
|
||||
*
|
||||
*/
|
||||
public ConfigProperties createConfigProperties() {
|
||||
return new ConfigProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link License }
|
||||
*
|
||||
*/
|
||||
public License createLicense() {
|
||||
return new License();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link DeviceDetails }
|
||||
*
|
||||
*/
|
||||
public DeviceDetails createDeviceDetails() {
|
||||
return new DeviceDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link QueryParameters }
|
||||
*
|
||||
*/
|
||||
public QueryParameters createQueryParameters() {
|
||||
return new QueryParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of {@link JAXBElement }{@code <}{@link DeviceTypeConfiguration }{@code >}}
|
||||
*
|
||||
*/
|
||||
@XmlElementDecl(namespace = "", name = "DeviceTypeConfiguration")
|
||||
public JAXBElement<DeviceTypeConfiguration> createDeviceTypeConfiguration(DeviceTypeConfiguration value) {
|
||||
return new JAXBElement<DeviceTypeConfiguration>(_DeviceTypeConfiguration_QNAME, DeviceTypeConfiguration.class, null, value);
|
||||
}
|
||||
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
<DeviceTypeConfiguration name="samples">
|
||||
|
||||
<DeviceDetails table-id="SAMPLE_DEVICE_1"/>
|
||||
|
||||
<Features>
|
||||
<Feature code="abc">
|
||||
<Name>abc</Name>
|
||||
<Description>this is a feature</Description>
|
||||
<Operation context="/bulb/{state}" method="PUT" type="application/json">
|
||||
<QueryParameters>
|
||||
<Parameter>deviceId</Parameter>
|
||||
</QueryParameters>
|
||||
<FormParameters>
|
||||
<Parameter>test</Parameter>
|
||||
</FormParameters>
|
||||
</Operation>
|
||||
</Feature>
|
||||
</Features>
|
||||
|
||||
<Claimable enabled="true"/>
|
||||
|
||||
<Sensors table-id="SAMPLE_DEVICE_2">
|
||||
<Sensor code="CPU_Temperature">
|
||||
<Name>temperature sensor fitted</Name>
|
||||
<StreamDefinition>org.wso2.temperature.stream</StreamDefinition>
|
||||
<Description>this is a sensor</Description>
|
||||
<SensorStaticProperties>
|
||||
<Property name="unit">celcius</Property>
|
||||
<Property name="model_number">atmeggga11234</Property>
|
||||
</SensorStaticProperties>
|
||||
</Sensor>
|
||||
<Sensor code="DHT11_Temperature">
|
||||
<Name>temperature sensor fitted</Name>
|
||||
<StreamDefinition>org.wso2.temperature.stream</StreamDefinition>
|
||||
<Description>this is a sensor</Description>
|
||||
<SensorStaticProperties>
|
||||
<Property name="unit">celcius</Property>
|
||||
</SensorStaticProperties>
|
||||
<SensorDynamicProperties>
|
||||
<Property name="model_number"/>
|
||||
</SensorDynamicProperties>
|
||||
</Sensor>
|
||||
</Sensors>
|
||||
|
||||
<ProvisioningConfig>
|
||||
<SharedWithAllTenants>false</SharedWithAllTenants>
|
||||
</ProvisioningConfig>
|
||||
|
||||
<DeviceAuthorizationConfig>
|
||||
<authorizationRequired>true</authorizationRequired>
|
||||
</DeviceAuthorizationConfig>
|
||||
|
||||
<PushNotificationProvider type="MQTT">
|
||||
<FileBasedProperties>true</FileBasedProperties>
|
||||
<!--if file based properties is set to false then the configuration will be picked from platform configuration-->
|
||||
<ConfigProperties>
|
||||
<Property Name="mqttAdapterName">sample.mqtt.adapter</Property>
|
||||
<Property Name="url">tcp://localhost:1883</Property>
|
||||
<Property Name="username">admin</Property>
|
||||
<Property Name="password">admin</Property>
|
||||
<Property Name="qos">0</Property>
|
||||
<Property Name="scopes"/>
|
||||
<Property Name="clearSession">true</Property>
|
||||
</ConfigProperties>
|
||||
</PushNotificationProvider>
|
||||
|
||||
<PolicyMonitoring enabled="true"/>
|
||||
|
||||
<License>
|
||||
<Language>en_US</Language>
|
||||
<Version>1.0.0</Version>
|
||||
<Text>This is license text</Text>
|
||||
</License>
|
||||
|
||||
<TaskConfiguration>
|
||||
<Enable>true</Enable>
|
||||
<Frequency>600000</Frequency>
|
||||
<Operations>
|
||||
<Operation>
|
||||
<Name>DEVICE_INFO</Name>
|
||||
<RecurrentTimes>1</RecurrentTimes>
|
||||
</Operation>
|
||||
<Operation>
|
||||
<Name>APPLICATION_LIST</Name>
|
||||
<RecurrentTimes>5</RecurrentTimes>
|
||||
</Operation>
|
||||
<Operation>
|
||||
<Name>DEVICE_LOCATION</Name>
|
||||
<RecurrentTimes>1</RecurrentTimes>
|
||||
</Operation>
|
||||
</Operations>
|
||||
</TaskConfiguration>
|
||||
|
||||
<DataSource>
|
||||
<jndiConfig>
|
||||
<name>jdbc/SampleDM_DB</name>
|
||||
</jndiConfig>
|
||||
<tableConfig>
|
||||
<Table name="SAMPLE_DEVICE_1">
|
||||
<PrimaryKey>SAMPLE_DEVICE_ID</PrimaryKey>
|
||||
<Attributes>
|
||||
<Attribute>column1</Attribute>
|
||||
<Attribute>column2</Attribute>
|
||||
</Attributes>
|
||||
</Table>
|
||||
</tableConfig>
|
||||
</DataSource>
|
||||
|
||||
<InitialOperationConfig>
|
||||
<Operations>
|
||||
<Operation>DEVICE_INFO</Operation>
|
||||
<Operation>APPLICATION_LIST</Operation>
|
||||
<Operation>DEVICE_LOCATION</Operation>
|
||||
</Operations>
|
||||
</InitialOperationConfig>
|
||||
|
||||
<!--This configures the Task service for the device-type. Given below are the property definitions.
|
||||
<RequireStatusMonitoring> - This will enable or disable status monitoring for that particular device-type.
|
||||
<Frequency> - The time interval (in seconds) in which the task should run for this device-type
|
||||
<IdleTimeToMarkInactive> - The time duration (in seconds) in which the device can be moved to inactive status
|
||||
which means the device will be moved to inactive status if that device does not
|
||||
contact the server within that time period.
|
||||
<IdleTimeToMarkUnreachable> - The time duration (in seconds) in which the device can be moved to unreachable status
|
||||
which means the device will be moved to unreachable status if that device does not
|
||||
contact the server within that time period.
|
||||
-->
|
||||
<DeviceStatusTaskConfig>
|
||||
<RequireStatusMonitoring>false</RequireStatusMonitoring>
|
||||
<Frequency>300</Frequency>
|
||||
<IdleTimeToMarkInactive>600</IdleTimeToMarkInactive>
|
||||
<IdleTimeToMarkUnreachable>300</IdleTimeToMarkUnreachable>
|
||||
</DeviceStatusTaskConfig>
|
||||
</DeviceTypeConfiguration>
|
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<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/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>3.0.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.mgt.extensions.pull.notification</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - Pull Notification Provider Implementation</name>
|
||||
<description>WSO2 Carbon - Pull Notification Provider Implementation</description>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||
<Bundle-Description>Pull Notification Provider Bundle</Bundle-Description>
|
||||
<Export-Package>
|
||||
!org.wso2.carbon.device.mgt.extensions.pull.notification.internal,
|
||||
org.wso2.carbon.device.mgt.extensions.pull.notification.*
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.apache.commons.logging,
|
||||
org.wso2.carbon.device.mgt.common.*,
|
||||
org.wso2.carbon.device.mgt.core.service
|
||||
org.wso2.carbon.policy.mgt.core.*,
|
||||
org.wso2.carbon.policy.mgt.core,
|
||||
com.google.gson,
|
||||
org.wso2.carbon.device.mgt.core.service.*
|
||||
</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.extensions.pull.notification;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||
import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecutionFailedException;
|
||||
import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationSubscriber;
|
||||
import org.wso2.carbon.device.mgt.extensions.pull.notification.internal.PullNotificationDataHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PullNotificationSubscriberImpl implements PullNotificationSubscriber {
|
||||
|
||||
public final class OperationCodes {
|
||||
private OperationCodes() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static final String POLICY_MONITOR = "POLICY_MONITOR";
|
||||
}
|
||||
|
||||
|
||||
private static final Log log = LogFactory.getLog(PullNotificationSubscriberImpl.class);
|
||||
|
||||
public void init(Map<String, String> properties) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(DeviceIdentifier deviceIdentifier, Operation operation) throws PullNotificationExecutionFailedException {
|
||||
try {
|
||||
if (!Operation.Status.ERROR.equals(operation.getStatus()) && operation.getCode() != null &&
|
||||
OperationCodes.POLICY_MONITOR.equals(operation.getCode())) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info("Received compliance status from POLICY_MONITOR operation ID: " + operation.getId());
|
||||
}
|
||||
List<ComplianceFeature> features = getComplianceFeatures(operation.getPayLoad());
|
||||
PullNotificationDataHolder.getInstance().getPolicyManagerService()
|
||||
.checkCompliance(deviceIdentifier, features);
|
||||
|
||||
} else {
|
||||
PullNotificationDataHolder.getInstance().getDeviceManagementProviderService().updateOperation(
|
||||
deviceIdentifier, operation);
|
||||
}
|
||||
} catch (OperationManagementException e) {
|
||||
throw new PullNotificationExecutionFailedException(e);
|
||||
} catch (PolicyComplianceException e) {
|
||||
throw new PullNotificationExecutionFailedException("Invalid payload format compliant feature", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void clean() {
|
||||
|
||||
}
|
||||
|
||||
private static List<ComplianceFeature> getComplianceFeatures(Object compliancePayload) throws
|
||||
PolicyComplianceException {
|
||||
String compliancePayloadString = new Gson().toJson(compliancePayload);
|
||||
if (compliancePayload == null) {
|
||||
return null;
|
||||
}
|
||||
// Parsing json string to get compliance features.
|
||||
JsonElement jsonElement = new JsonParser().parse(compliancePayloadString);
|
||||
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
||||
Gson gson = new Gson();
|
||||
ComplianceFeature complianceFeature;
|
||||
List<ComplianceFeature> complianceFeatures = new ArrayList<ComplianceFeature>(jsonArray.size());
|
||||
|
||||
for (JsonElement element : jsonArray) {
|
||||
complianceFeature = gson.fromJson(element, ComplianceFeature.class);
|
||||
complianceFeatures.add(complianceFeature);
|
||||
}
|
||||
return complianceFeatures;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.extensions.pull.notification.internal;
|
||||
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||
|
||||
public class PullNotificationDataHolder {
|
||||
|
||||
private DeviceManagementProviderService deviceManagementProviderService;
|
||||
private PolicyManagerService policyManagerService;
|
||||
|
||||
private static PullNotificationDataHolder thisInstance = new PullNotificationDataHolder();
|
||||
|
||||
public static PullNotificationDataHolder getInstance() {
|
||||
return thisInstance;
|
||||
}
|
||||
|
||||
public DeviceManagementProviderService getDeviceManagementProviderService() {
|
||||
return deviceManagementProviderService;
|
||||
}
|
||||
|
||||
public void setDeviceManagementProviderService(DeviceManagementProviderService deviceManagementProviderService) {
|
||||
this.deviceManagementProviderService = deviceManagementProviderService;
|
||||
}
|
||||
|
||||
public PolicyManagerService getPolicyManagerService() {
|
||||
return policyManagerService;
|
||||
}
|
||||
|
||||
public void setPolicyManagerService(PolicyManagerService policyManagerService) {
|
||||
this.policyManagerService = policyManagerService;
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.extensions.pull.notification.internal;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||
|
||||
/**
|
||||
* @scr.component name="org.wso2.carbon.device.mgt.extensions.pull.notification.internal.PullNotificationServiceComponent" immediate="true"
|
||||
* @scr.reference name="carbon.device.mgt.provider"
|
||||
* interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService"
|
||||
* cardinality="1..1"
|
||||
* policy="dynamic"
|
||||
* bind="setDeviceManagementProviderService"
|
||||
* unbind="unsetDeviceManagementProviderService"
|
||||
* @scr.reference name="org.wso2.carbon.policy.mgt.core"
|
||||
* interface="org.wso2.carbon.policy.mgt.core.PolicyManagerService"
|
||||
* cardinality="1..1"
|
||||
* policy="dynamic"
|
||||
* bind="setPolicyManagerService"
|
||||
* unbind="unsetPolicyManagerService"
|
||||
*/
|
||||
public class PullNotificationServiceComponent {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PullNotificationServiceComponent.class);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected void activate(ComponentContext componentContext) {
|
||||
try {
|
||||
//Do nothing
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("pull notification provider implementation bundle has been successfully " +
|
||||
"initialized");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error("Error occurred while initializing pull notification provider " +
|
||||
"implementation bundle", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void deactivate(ComponentContext componentContext) {
|
||||
//Do nothing
|
||||
}
|
||||
|
||||
protected void setDeviceManagementProviderService(DeviceManagementProviderService deviceManagementProviderService) {
|
||||
PullNotificationDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
|
||||
}
|
||||
|
||||
protected void unsetDeviceManagementProviderService(DeviceManagementProviderService deviceManagementProviderService) {
|
||||
PullNotificationDataHolder.getInstance().setDeviceManagementProviderService(null);
|
||||
}
|
||||
|
||||
protected void setPolicyManagerService(PolicyManagerService policyManagerService) {
|
||||
PullNotificationDataHolder.getInstance().setPolicyManagerService(policyManagerService);
|
||||
}
|
||||
|
||||
protected void unsetPolicyManagerService(PolicyManagerService policyManagerService) {
|
||||
PullNotificationDataHolder.getInstance().setPolicyManagerService(null);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<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/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>3.0.8-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.http</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - HTTP Based Push Notification Provider Implementation</name>
|
||||
<description>WSO2 Carbon - HTTP Based Push Notification Provider Implementation</description>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.governance</groupId>
|
||||
<artifactId>org.wso2.carbon.governance.api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
|
||||
<artifactId>axiom</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.orbit.org.scannotation</groupId>
|
||||
<artifactId>scannotation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.tomcat</groupId>
|
||||
<artifactId>tomcat</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.tomcat</groupId>
|
||||
<artifactId>tomcat-servlet-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang.wso2</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json.wso2</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||
<Bundle-Description>MQTT Based Push Notification Provider Bundle</Bundle-Description>
|
||||
<Export-Package>
|
||||
!org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.internal,
|
||||
org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.*
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
org.apache.commons.logging,
|
||||
org.osgi.service.component,
|
||||
org.wso2.carbon.context,
|
||||
org.wso2.carbon.device.mgt.common.operation.mgt,
|
||||
org.wso2.carbon.device.mgt.common.push.notification,
|
||||
org.wso2.carbon.device.mgt.common,
|
||||
org.wso2.carbon.device.mgt.core.service,
|
||||
org.osgi.framework,
|
||||
org.wso2.carbon.device.mgt.core.operation.mgt,
|
||||
org.wso2.carbon.core,
|
||||
com.google.gson,
|
||||
org.apache.commons.httpclient.*
|
||||
</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
26
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAOManager.java → components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/http/HTTPBasedPushNotificationProvider.java
26
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAOManager.java → components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/http/HTTPBasedPushNotificationProvider.java
@ -0,0 +1,94 @@
|
||||
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.http;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.apache.commons.httpclient.HostConfiguration;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.InvalidConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public class HTTPMessageExecutor implements Runnable {
|
||||
|
||||
private String url;
|
||||
private String authorizationHeader;
|
||||
private String payload;
|
||||
private HostConfiguration hostConfiguration;
|
||||
private HttpClient httpClient;
|
||||
private static final String APPLIATION_JSON = "application/json";
|
||||
private static final String AUTHORIZATION_HEADER = "Authorization";
|
||||
private static final Log log = LogFactory.getLog(HTTPMessageExecutor.class);
|
||||
|
||||
public HTTPMessageExecutor(NotificationContext notificationContext, String authorizationHeader, String url
|
||||
, HostConfiguration hostConfiguration, HttpClient httpClient) {
|
||||
this.url = url;
|
||||
this.authorizationHeader = authorizationHeader;
|
||||
Gson gson = new Gson();
|
||||
this.payload = gson.toJson(notificationContext);
|
||||
this.hostConfiguration = hostConfiguration;
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getAuthorizationHeader() {
|
||||
return authorizationHeader;
|
||||
}
|
||||
|
||||
public void setAuthorizationHeader(String authorizationHeader) {
|
||||
this.authorizationHeader = authorizationHeader;
|
||||
}
|
||||
|
||||
public String getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void setPayload(String payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public HttpClient getHttpClient() {
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
public void setHttpClient(HttpClient httpClient) {
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
EntityEnclosingMethod method = null;
|
||||
|
||||
try {
|
||||
method = new PostMethod(this.getUrl());
|
||||
method.setRequestEntity(new StringRequestEntity(this.getPayload(), APPLIATION_JSON, "UTF-8"));
|
||||
if (authorizationHeader != null && authorizationHeader.isEmpty()) {
|
||||
method.setRequestHeader(AUTHORIZATION_HEADER, authorizationHeader);
|
||||
}
|
||||
|
||||
this.getHttpClient().executeMethod(hostConfiguration, method);
|
||||
|
||||
} catch (UnknownHostException e) {
|
||||
log.error("Push Notification message dropped " + url, e);
|
||||
throw new InvalidConfigurationException("invalid host: url", e);
|
||||
} catch (Throwable e) {
|
||||
log.error("Push Notification message dropped ", e);
|
||||
throw new InvalidConfigurationException("Push Notification message dropped, " + e.getMessage(), e);
|
||||
} finally {
|
||||
if (method != null) {
|
||||
method.releaseConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.http;
|
||||
|
||||
import org.apache.commons.httpclient.HostConfiguration;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.InvalidConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
public class HTTPNotificationStrategy implements NotificationStrategy {
|
||||
|
||||
private static final Log log = LogFactory.getLog(HTTPNotificationStrategy.class);
|
||||
private final PushNotificationConfig config;
|
||||
private static final String URL_PROPERTY = "url";
|
||||
private static final String AUTHORIZATION_HEADER_PROPERTY = "authorization";
|
||||
private String endpoint;
|
||||
private static ExecutorService executorService;
|
||||
private HttpClient httpClient = null;
|
||||
private HostConfiguration hostConfiguration;
|
||||
private String authorizationHeaderValue;
|
||||
private String uri;
|
||||
|
||||
public HTTPNotificationStrategy(PushNotificationConfig config) {
|
||||
this.config = config;
|
||||
if (this.config == null) {
|
||||
throw new InvalidConfigurationException("Properties Cannot be found");
|
||||
}
|
||||
endpoint = config.getProperties().get(URL_PROPERTY);
|
||||
if (endpoint == null || endpoint.isEmpty()) {
|
||||
throw new InvalidConfigurationException("Property - 'url' cannot be found");
|
||||
}
|
||||
try {
|
||||
this.uri = endpoint;
|
||||
URL url = new URL(endpoint);
|
||||
hostConfiguration = new HostConfiguration();
|
||||
hostConfiguration.setHost(url.getHost(), url.getPort(), url.getProtocol());
|
||||
this.authorizationHeaderValue = config.getProperties().get(AUTHORIZATION_HEADER_PROPERTY);
|
||||
executorService = Executors.newFixedThreadPool(1);
|
||||
httpClient = new HttpClient();
|
||||
} catch (MalformedURLException e) {
|
||||
throw new InvalidConfigurationException("Property - 'url' is malformed.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
|
||||
try {
|
||||
executorService.submit(new HTTPMessageExecutor(ctx, authorizationHeaderValue, uri, hostConfiguration
|
||||
, httpClient));
|
||||
} catch (RejectedExecutionException e) {
|
||||
log.error("Failed to publish to external endpoint url: " + endpoint, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationContext buildContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undeploy() {
|
||||
executorService.shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PushNotificationConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.internal;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
|
||||
/**
|
||||
* @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.internal.HTTPPushNotificationServiceComponent" immediate="true"
|
||||
*/
|
||||
public class HTTPPushNotificationServiceComponent {
|
||||
|
||||
private static final Log log = LogFactory.getLog(HTTPPushNotificationServiceComponent.class);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected void activate(ComponentContext componentContext) {
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Initializing HTTP based push notification provider implementation bundle");
|
||||
}
|
||||
//Do nothing
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("HTTP based push notification provider implementation bundle has been successfully " +
|
||||
"initialized");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error("Error occurred while initializing HTTP based push notification provider " +
|
||||
"implementation bundle", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "OperationRequest", description = "Operation details together with deviceIdentifier")
|
||||
public class OperationRequest {
|
||||
|
||||
@ApiModelProperty(name = "deviceIdentifiers", value = "list of devices that needs to be verified against the user", required = true)
|
||||
List<String> deviceIdentifiers;
|
||||
@ApiModelProperty(name = "operation", value = "operation data", required = false)
|
||||
Operation operation;
|
||||
|
||||
public List<String> getDeviceIdentifiers() {
|
||||
return deviceIdentifiers;
|
||||
}
|
||||
|
||||
public void setDeviceIdentifiers(List<String> deviceIdentifiers) {
|
||||
this.deviceIdentifiers = deviceIdentifiers;
|
||||
}
|
||||
|
||||
public Operation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Operation operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans.analytics;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* This hold the attribute definition.
|
||||
*/
|
||||
public class Attribute {
|
||||
|
||||
@ApiModelProperty(value = "Event Attribute Name")
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "Event Attribute Type")
|
||||
@JsonProperty("type")
|
||||
private AttributeType type;
|
||||
|
||||
public Attribute() {
|
||||
|
||||
}
|
||||
|
||||
public Attribute(String name, AttributeType attributeType) {
|
||||
this.name = name;
|
||||
this.type = attributeType;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public AttributeType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(AttributeType type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans.analytics;
|
||||
|
||||
/**
|
||||
* This hold the definition of the attribute type for the attributes.
|
||||
*/
|
||||
public enum AttributeType {
|
||||
STRING, LONG, BOOL, INT, FLOAT, DOUBLE;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans.analytics;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* This hold stats data record
|
||||
*/
|
||||
public class DeviceTypeEvent {
|
||||
|
||||
private EventAttributeList eventAttributes;
|
||||
private TransportType transport;
|
||||
|
||||
@ApiModelProperty(value = "Attributes related to device type event")
|
||||
@JsonProperty("eventAttributes")
|
||||
public EventAttributeList getEventAttributeList() {
|
||||
return eventAttributes;
|
||||
}
|
||||
|
||||
public void setEventAttributeList(
|
||||
EventAttributeList eventAttributes) {
|
||||
this.eventAttributes = eventAttributes;
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "Transport to be used for device to server communication.")
|
||||
@JsonProperty("transport")
|
||||
public TransportType getTransportType() {
|
||||
return transport;
|
||||
}
|
||||
|
||||
public void setTransportType(TransportType transport) {
|
||||
this.transport = transport;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans.analytics;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.BasePaginatedResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This holds event attributes
|
||||
*/
|
||||
public class EventAttributeList {
|
||||
|
||||
private List<Attribute> attributes = new ArrayList<>();
|
||||
|
||||
@ApiModelProperty(value = "List of Event Attributes")
|
||||
@JsonProperty("attributes")
|
||||
public List<Attribute> getList() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public void setList(List<Attribute> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans.analytics;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.wso2.carbon.analytics.datasource.commons.Record;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.BasePaginatedResult;
|
||||
|
||||
/**
|
||||
* This hold stats data record
|
||||
*/
|
||||
public class EventRecords extends BasePaginatedResult {
|
||||
|
||||
private List<Record> records = new ArrayList<>();
|
||||
|
||||
@ApiModelProperty(value = "List of records returned")
|
||||
@JsonProperty("records")
|
||||
public List<Record> getRecord() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public void setList(List<Record> records) {
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{\n");
|
||||
|
||||
sb.append(" count: ").append(getCount()).append(",\n");
|
||||
sb.append(" records: [").append(records).append("\n");
|
||||
sb.append("]}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans.analytics;
|
||||
|
||||
/**
|
||||
* This hold the default transport types support by the server.
|
||||
*/
|
||||
public enum TransportType {
|
||||
HTTP, MQTT;
|
||||
}
|
||||
|
@ -0,0 +1,608 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
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.Device;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.OperationList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SwaggerDefinition(
|
||||
info = @Info(
|
||||
version = "1.0.0",
|
||||
title = "",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = "name", value = "DeviceAgent Service"),
|
||||
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/device/agent"),
|
||||
})
|
||||
}
|
||||
),
|
||||
tags = {
|
||||
@Tag(name = "device_agent, device_management", description = "")
|
||||
}
|
||||
)
|
||||
@Api(value = "Device Agent", description = "Device Agent Service")
|
||||
@Path("/device/agent")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Scopes(
|
||||
scopes = {
|
||||
@Scope(
|
||||
name = "Enroll Device",
|
||||
description = "Register a device",
|
||||
key = "perm:device:enroll",
|
||||
permissions = {"/device-mgt/devices/owning-device/add"}
|
||||
),
|
||||
@Scope(
|
||||
name = "Modify Device",
|
||||
description = "Modify a device",
|
||||
key = "perm:device:modify",
|
||||
permissions = {"/device-mgt/devices/owning-device/modify"}
|
||||
),
|
||||
@Scope(
|
||||
name = "Disenroll Device",
|
||||
description = "Disenroll a device",
|
||||
key = "perm:device:disenroll",
|
||||
permissions = {"/device-mgt/devices/owning-device/remove"}
|
||||
),
|
||||
@Scope(
|
||||
name = "Publish Event",
|
||||
description = "publish device event",
|
||||
key = "perm:device:publish-event",
|
||||
permissions = {"/device-mgt/devices/owning-device/event"}
|
||||
),
|
||||
@Scope(
|
||||
name = "Getting Device Operation Details",
|
||||
description = "Getting Device Operation Details",
|
||||
key = "perm:device:operations",
|
||||
permissions = {"/device-mgt/devices/owning-device/view"}
|
||||
)
|
||||
}
|
||||
)
|
||||
public interface DeviceAgentService {
|
||||
|
||||
@POST
|
||||
@Path("/enroll")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "POST",
|
||||
value = "Create a device instance",
|
||||
notes = "Create a device Instance",
|
||||
tags = "Device Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:enroll")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully created a device instance.",
|
||||
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 = 304,
|
||||
message = "Not Modified. Empty body because the client already has the latest version" +
|
||||
" of the requested resource.\n"),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid request or validation error.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found. \n A deviceType with the specified device type was not found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while retrieving the device details.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
Response enrollDevice(@ApiParam(name = "device", value = "Device object with data.", required = true)
|
||||
@Valid Device device);
|
||||
|
||||
@DELETE
|
||||
@Path("/enroll/{type}/{id}")
|
||||
@ApiOperation(
|
||||
httpMethod = "DELETE",
|
||||
value = "Unregistering a Device",
|
||||
notes = "Use this REST API to unregister a device.",
|
||||
tags = "Device Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:disenroll")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully disenrolled the device."),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found. \n The specified resource does not exist."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while dis-enrolling the device.")
|
||||
})
|
||||
Response disEnrollDevice(
|
||||
@ApiParam(name = "type", value = "The unique device identifier.") @PathParam("type") String type,
|
||||
@ApiParam(name = "id", value = "The unique device identifier.") @PathParam("id") String id);
|
||||
|
||||
@PUT
|
||||
@Path("/enroll/{type}/{id}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "PUT",
|
||||
value = "modify device",
|
||||
notes = "modify device",
|
||||
tags = "Device Agent Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:modify")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully updated device instance.",
|
||||
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 = 304,
|
||||
message = "Not Modified. Empty body because the client already has the latest version" +
|
||||
" of the requested resource.\n"),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid request or validation error.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found. \n A deviceType with the specified device type was not found.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while retrieving the device details.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
Response updateDevice(@ApiParam(name = "type", value = "The device type, such as ios, android or windows....etc", required = true)
|
||||
@PathParam("type") String type,
|
||||
@ApiParam(name = "id", value = "The device id.", required = true)
|
||||
@PathParam("id") String deviceId,
|
||||
@ApiParam(name = "device", value = "Device object with data.", required = true)
|
||||
@Valid Device updateDevice);
|
||||
|
||||
@POST
|
||||
@Path("/events/publish/{type}/{deviceId}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "POST",
|
||||
value = "Publishing Events",
|
||||
notes = "Publish events received by the device client to the WSO2 Data Analytics Server (DAS) using this API.",
|
||||
tags = "Device Agent Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:publish-event")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully published the event",
|
||||
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 = 303,
|
||||
message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Location",
|
||||
description = "The Source URL of the document.")}),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid request or validation error."),
|
||||
@ApiResponse(
|
||||
code = 415,
|
||||
message = "Unsupported media type. \n The format of the requested entity was not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while publishing events.")
|
||||
})
|
||||
Response publishEvents(
|
||||
@ApiParam(
|
||||
name = "payloadData",
|
||||
value = "Information of the agent event to be published on DAS.")
|
||||
@Valid
|
||||
Map<String, Object> payloadData,
|
||||
@ApiParam(
|
||||
name = "type",
|
||||
value = "name of the device type")
|
||||
@PathParam("type") String type,
|
||||
@ApiParam(
|
||||
name = "deviceId",
|
||||
value = "deviceId of the device")
|
||||
@PathParam("deviceId") String deviceId);
|
||||
|
||||
@POST
|
||||
@Path("/events/publish/data/{type}/{deviceId}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "POST",
|
||||
value = "Publishing Events data only",
|
||||
notes = "Publish events received by the device client to the WSO2 Data Analytics Server (DAS) using this API.",
|
||||
tags = "Device Agent Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:publish-event")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully published the event",
|
||||
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 = 303,
|
||||
message = "See Other. \n The source can be retrieved from the URL specified in the location header.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Location",
|
||||
description = "The Source URL of the document.")}),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid request or validation error."),
|
||||
@ApiResponse(
|
||||
code = 415,
|
||||
message = "Unsupported media type. \n The format of the requested entity was not supported."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while publishing events.")
|
||||
})
|
||||
Response publishEvents(
|
||||
@ApiParam(
|
||||
name = "payloadData",
|
||||
value = "Information of the agent event to be published on DAS.")
|
||||
@Valid
|
||||
List<Object> payloadData,
|
||||
@ApiParam(
|
||||
name = "type",
|
||||
value = "name of the device type")
|
||||
@PathParam("type") String type,
|
||||
@ApiParam(
|
||||
name = "deviceId",
|
||||
value = "deviceId of the device")
|
||||
@PathParam("deviceId") String deviceId);
|
||||
|
||||
@GET
|
||||
@Path("/pending/operations/{type}/{id}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Get pending operation of the given device",
|
||||
notes = "Returns the Operations.",
|
||||
tags = "Device Agent Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:operations")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully retrieved the operations.",
|
||||
response = OperationList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. Empty body because the client already has the latest " +
|
||||
"version of the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid request or validation error.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found. \n No device is found under the provided type and id.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while retrieving information requested device.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
Response getPendingOperations(@ApiParam(name = "type", value = "The device type, such as ios, android or windows.", required = true)
|
||||
@PathParam("type") String type,
|
||||
@ApiParam(name = "id", value = "The device id.", required = true)
|
||||
@PathParam("id") String deviceId);
|
||||
|
||||
@GET
|
||||
@Path("/next-pending/operation/{type}/{id}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Get pending operation of the given device",
|
||||
notes = "Returns the Operation.",
|
||||
tags = "Device Agent Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:operations")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully retrieved the operation.",
|
||||
response = Operation.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. Empty body because the client already has the latest " +
|
||||
"version of the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid request or validation error.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found. \n No device is found under the provided type and id.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while retrieving information requested device.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
Response getNextPendingOperation(@ApiParam(name = "type", value = "The device type, such as ios, android or windows.", required = true)
|
||||
@PathParam("type") String type,
|
||||
@ApiParam(name = "id", value = "The device id.", required = true)
|
||||
@PathParam("id") String deviceId);
|
||||
|
||||
@PUT
|
||||
@Path("/operations/{type}/{id}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "PUT",
|
||||
value = "Update Operation",
|
||||
notes = "Update the Operations.",
|
||||
tags = "Device Agent Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:operations")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully updated the operations.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. Empty body because the client already has the latest " +
|
||||
"version of the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid request or validation error.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found. \n No device is found under the provided type and id.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while retrieving information requested device.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
Response updateOperation(@ApiParam(name = "type", value = "The device type, such as ios, android or windows.", required = true)
|
||||
@PathParam("type") String type,
|
||||
@ApiParam(name = "id", value = "The device id.", required = true)
|
||||
@PathParam("id") String deviceId,
|
||||
@ApiParam(name = "operation", value = "Operation object with data.", required = true)
|
||||
@Valid Operation operation);
|
||||
|
||||
@GET
|
||||
@Path("/status/operations/{type}/{id}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Get pending operation of the given device",
|
||||
notes = "Returns the Operations.",
|
||||
tags = "Device Agent Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device:operations")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully retrieved the operations.",
|
||||
response = OperationList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource has been modified the last time.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. Empty body because the client already has the latest " +
|
||||
"version of the requested resource."),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid request or validation error.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found. \n No device is found under the provided type and id.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n " +
|
||||
"Server error occurred while retrieving information requested device.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
Response getOperationsByDeviceAndStatus(@ApiParam(name = "type", value = "The device type, such as ios, android or windows.", required = true)
|
||||
@PathParam("type") String type,
|
||||
@ApiParam(name = "id", value = "The device id.", required = true)
|
||||
@PathParam("id") String deviceId,
|
||||
@ApiParam(name = "status", value = "status of the operation.", required = true)
|
||||
@QueryParam("status")Operation.Status status);
|
||||
|
||||
}
|
@ -0,0 +1,347 @@
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
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.jaxrs.beans.DeviceTypeList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.DeviceTypeEvent;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventAttributeList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventRecords;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.TransportType;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@SwaggerDefinition(
|
||||
info = @Info(
|
||||
version = "1.0.0",
|
||||
title = "",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = "name", value = "DeviceEventManagement"),
|
||||
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/events"),
|
||||
})
|
||||
}
|
||||
),
|
||||
tags = {
|
||||
@Tag(name = "device_management", description = "")
|
||||
}
|
||||
)
|
||||
@Scopes(
|
||||
scopes = {
|
||||
@Scope(
|
||||
name = "Add or Delete Event Definition for device type",
|
||||
description = "Add or Delete Event Definition for device type",
|
||||
key = "perm:device-types:events",
|
||||
permissions = {"/device-mgt/device-type/add"}
|
||||
),
|
||||
@Scope(
|
||||
name = "Get Events Details of a Device Type",
|
||||
description = "Get Events Details of a Device Type",
|
||||
key = "perm:device-types:events:view",
|
||||
permissions = {"/device-mgt/devices/owning-device/view"}
|
||||
)
|
||||
}
|
||||
)
|
||||
@Path("/events")
|
||||
@Api(value = "Device Event Management", description = "This API corresponds to all tasks related to device " +
|
||||
"event management")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public interface DeviceEventManagementService {
|
||||
|
||||
@POST
|
||||
@Path("/{type}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "POST",
|
||||
value = "Add Event Type Defnition",
|
||||
notes = "Add the event definition for the device.",
|
||||
tags = "Device Event Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully added the event defintion.",
|
||||
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. \n"),
|
||||
@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 fetching the " +
|
||||
"list of supported device types.",
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
Response deployDeviceTypeEventDefinition(@ApiParam(name = "type", value = "name of the device type", required = false)
|
||||
@PathParam("type")String deviceType,
|
||||
@ApiParam(name = "deviceTypeEvent", value = "DeviceTypeEvent object with data.", required = true)
|
||||
@Valid DeviceTypeEvent deviceTypeEvent);
|
||||
|
||||
@DELETE
|
||||
@Path("/{type}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "DELETE",
|
||||
value = "Delete Event Type Defnition",
|
||||
notes = "Delete the event definition for the device.",
|
||||
tags = "Device Event Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully deleted the event definition.",
|
||||
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. \n"),
|
||||
@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 fetching the " +
|
||||
"list of supported device types.",
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
Response deleteDeviceTypeEventDefinitions(@ApiParam(name = "type", value = "name of the device type", required = false)
|
||||
@PathParam("type")String deviceType);
|
||||
|
||||
@GET
|
||||
@Path("/{type}/{deviceId}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Getting Device Events",
|
||||
notes = "Get the events for the device.",
|
||||
tags = "Device Event Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the event definition.",
|
||||
response = EventRecords.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description =
|
||||
"Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}
|
||||
),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message =
|
||||
"Bad Request. \n"),
|
||||
@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 fetching the " +
|
||||
"list of supported device types.",
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
Response getData(@ApiParam(name = "deviceId", value = "id of the device ", required = false)
|
||||
@PathParam("deviceId") String deviceId,
|
||||
@ApiParam(name = "from", value = "unix timestamp to retrieve", required = false)
|
||||
@QueryParam("from") long from,
|
||||
@ApiParam(name = "to", value = "unix time to retrieve", required = false)
|
||||
@QueryParam("to") long to,
|
||||
@ApiParam(name = "type", value = "name of the device type", required = false)
|
||||
@PathParam("type") String deviceType,
|
||||
@ApiParam(name = "offset", value = "offset of the records that needs to be picked up", required = false)
|
||||
@QueryParam("offset") int offset,
|
||||
@ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false)
|
||||
@QueryParam("limit") int limit);
|
||||
|
||||
@GET
|
||||
@Path("last-known/{type}/{deviceId}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Getting Last Known Device Events",
|
||||
notes = "Get the Last Known events for the device.",
|
||||
tags = "Device Event Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the event.",
|
||||
response = EventRecords.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description =
|
||||
"Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}
|
||||
),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message =
|
||||
"Bad Request. \n"),
|
||||
@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 fetching the " +
|
||||
"list of supported device types.",
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
Response getLastKnownData(@ApiParam(name = "deviceId", value = "id of the device ", required = false)
|
||||
@PathParam("deviceId") String deviceId,
|
||||
@ApiParam(name = "type", value = "name of the device type", required = false)
|
||||
@PathParam("type") String deviceType);
|
||||
|
||||
@GET
|
||||
@Path("/{type}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Getting Event Type Defnition",
|
||||
notes = "Get the event definition for the device.",
|
||||
tags = "Device Event Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the event defintion.",
|
||||
response = DeviceTypeEvent.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description =
|
||||
"Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}
|
||||
),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message =
|
||||
"Bad Request. \n"),
|
||||
@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 fetching the " +
|
||||
"list of supported device types.",
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
Response getDeviceTypeEventDefinition(@ApiParam(name = "type", value = "name of the device type", required = false)
|
||||
@PathParam("type")String deviceType) ;
|
||||
|
||||
}
|
@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
|
||||
|
||||
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.Device;
|
||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceTypeList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
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 = "DeviceTypeManagementAdminService"),
|
||||
@ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/admin/device-types"),
|
||||
})
|
||||
}
|
||||
),
|
||||
tags = {
|
||||
@Tag(name = "device_management", description = "")
|
||||
}
|
||||
)
|
||||
@Path("/admin/device-types")
|
||||
@Api(value = "Device Type Management Administrative Service", description = "This an API intended to be used by " +
|
||||
"'internal' components to log in as an admin user and do a selected number of operations. " +
|
||||
"Further, this is strictly restricted to admin users only ")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Scopes(
|
||||
scopes = {
|
||||
@Scope(
|
||||
name = "Getting Details of a Device",
|
||||
description = "Getting Details of a Device",
|
||||
key = "perm:admin:device-type",
|
||||
permissions = {"/device-mgt/admin/device-type"}
|
||||
)
|
||||
}
|
||||
)
|
||||
public interface DeviceTypeManagementAdminService {
|
||||
|
||||
@GET
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Getting the Supported Device Type with Meta Definition",
|
||||
notes = "Get the list of device types supported by WSO2 IoT.",
|
||||
tags = "Device Type Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:admin:device-type")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the list of supported device types.",
|
||||
response = DeviceTypeList.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description =
|
||||
"Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}
|
||||
),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message =
|
||||
"Not Modified. \n Empty body because the client already has the latest version " +
|
||||
"of the requested resource.\n"),
|
||||
@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 fetching the " +
|
||||
"list of supported device types.",
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
Response getDeviceTypes();
|
||||
|
||||
@POST
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "POST",
|
||||
value = "Add a Device Type",
|
||||
notes = "Add the details of a device type.",
|
||||
tags = "Device Type Management Administrative Service",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:admin:device-type")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully added the device type.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body")
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. Empty body because the client already has the latest version of the " +
|
||||
"requested resource.\n"),
|
||||
@ApiResponse(
|
||||
code = 401,
|
||||
message = "Unauthorized.\n The unauthorized access to the requested resource.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found.\n The specified device does not exist",
|
||||
response = ErrorResponse.class),
|
||||
@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 fetching the device list.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
Response addDeviceType(@ApiParam(
|
||||
name = "type",
|
||||
value = "The device type such as ios, android, windows or fire-alarm.",
|
||||
required = true)DeviceType deviceType);
|
||||
|
||||
@PUT
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "PUT",
|
||||
value = "Update Device Type",
|
||||
notes = "Update the details of a device type.",
|
||||
response = DeviceType.class,
|
||||
tags = "Device Type Management Administrative Service",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:admin:device-type")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK. \n Successfully updated the device type.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body")
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 304,
|
||||
message = "Not Modified. Empty body because the client already has the latest version of the " +
|
||||
"requested resource.\n"),
|
||||
@ApiResponse(
|
||||
code = 401,
|
||||
message = "Unauthorized.\n The unauthorized access to the requested resource.",
|
||||
response = ErrorResponse.class),
|
||||
@ApiResponse(
|
||||
code = 404,
|
||||
message = "Not Found.\n The specified device does not exist",
|
||||
response = ErrorResponse.class),
|
||||
@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 fetching the device list.",
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
Response updateDeviceType(@ApiParam(
|
||||
name = "type",
|
||||
value = "The device type such as ios, android, windows or fire-alarm.",
|
||||
required = true) DeviceType deviceType);
|
||||
|
||||
}
|
@ -0,0 +1,574 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.apache.axis2.AxisFault;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.InvalidConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
|
||||
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMgtConstants;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.OperationList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Attribute;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AttributeType;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventAttributeList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceAgentService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||
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 javax.validation.Valid;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Path("/device/agent")
|
||||
public class DeviceAgentServiceImpl implements DeviceAgentService {
|
||||
private static final Log log = LogFactory.getLog(DeviceAgentServiceImpl.class);
|
||||
private static final String POLICY_MONITOR = "POLICY_MONITOR";
|
||||
@POST
|
||||
@Path("/enroll")
|
||||
@Override
|
||||
public Response enrollDevice(@Valid Device device) {
|
||||
if (device == null) {
|
||||
String errorMessage = "The payload of the device enrollment is incorrect.";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
}
|
||||
try {
|
||||
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||
if (device.getType() == null || device.getDeviceIdentifier() == null) {
|
||||
String errorMessage = "The payload of the device enrollment is incorrect.";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
}
|
||||
Device existingDevice = dms.getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
||||
if (existingDevice != null && existingDevice.getEnrolmentInfo() != null && existingDevice
|
||||
.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.ACTIVE)) {
|
||||
String errorMessage = "An active enrolment exists";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
}
|
||||
device.getEnrolmentInfo().setOwner(DeviceMgtAPIUtils.getAuthenticatedUser());
|
||||
device.getEnrolmentInfo().setDateOfEnrolment(System.currentTimeMillis());
|
||||
device.getEnrolmentInfo().setDateOfLastUpdate(System.currentTimeMillis());
|
||||
boolean status = dms.enrollDevice(device);
|
||||
return Response.status(Response.Status.OK).entity(status).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while enrolling the device, which carries the id '" +
|
||||
device.getDeviceIdentifier() + "'";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (InvalidConfigurationException e) {
|
||||
log.error("failed to add operation", e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/enroll/{type}/{id}")
|
||||
@Override
|
||||
public Response disEnrollDevice(@PathParam("type") String type, @PathParam("id") String id) {
|
||||
boolean result;
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(id, type);
|
||||
try {
|
||||
result = DeviceMgtAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
||||
if (result) {
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} else {
|
||||
return Response.status(Response.Status.NO_CONTENT).entity(type + " device that carries id '" + id +
|
||||
"' has not been dis-enrolled").build();
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while enrolling the device, which carries the id '" + id + "'";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/enroll/{type}/{id}")
|
||||
@Override
|
||||
public Response updateDevice(@PathParam("type") String type, @PathParam("id") String id, @Valid Device updateDevice) {
|
||||
Device device;
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(id);
|
||||
deviceIdentifier.setType(type);
|
||||
try {
|
||||
device = DeviceMgtAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while getting enrollment details of the device that carries the id '" +
|
||||
id + "'";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
|
||||
if (updateDevice == null) {
|
||||
String errorMessage = "The payload of the device enrollment is incorrect.";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
}
|
||||
if (device == null) {
|
||||
String errorMessage = "The device to be modified doesn't exist.";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.NOT_FOUND).entity(errorMessage).build();
|
||||
}
|
||||
if (device.getEnrolmentInfo().getStatus() == EnrolmentInfo.Status.ACTIVE ) {
|
||||
DeviceAccessAuthorizationService deviceAccessAuthorizationService =
|
||||
DeviceMgtAPIUtils.getDeviceAccessAuthorizationService();
|
||||
boolean status;
|
||||
try {
|
||||
status = deviceAccessAuthorizationService.isUserAuthorized(new DeviceIdentifier(id, type));
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
String msg = "Error occurred while modifying enrollment of the Android device that carries the id '" +
|
||||
id + "'";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
if (!status) {
|
||||
return Response.status(Response.Status.UNAUTHORIZED).build();
|
||||
}
|
||||
}
|
||||
if(updateDevice.getEnrolmentInfo() != null) {
|
||||
device.getEnrolmentInfo().setDateOfLastUpdate(System.currentTimeMillis());
|
||||
device.setEnrolmentInfo(device.getEnrolmentInfo());
|
||||
}
|
||||
device.getEnrolmentInfo().setOwner(DeviceMgtAPIUtils.getAuthenticatedUser());
|
||||
if(updateDevice.getDeviceInfo() != null) {
|
||||
device.setDeviceInfo(updateDevice.getDeviceInfo());
|
||||
}
|
||||
device.setDeviceIdentifier(id);
|
||||
if(updateDevice.getDescription() != null) {
|
||||
device.setDescription(updateDevice.getDescription());
|
||||
}
|
||||
if(updateDevice.getName() != null) {
|
||||
device.setName(updateDevice.getName());
|
||||
}
|
||||
if(updateDevice.getFeatures() != null) {
|
||||
device.setFeatures(updateDevice.getFeatures());
|
||||
}
|
||||
if(updateDevice.getProperties() != null) {
|
||||
device.setProperties(updateDevice.getProperties());
|
||||
}
|
||||
boolean result;
|
||||
try {
|
||||
device.setType(type);
|
||||
result = DeviceMgtAPIUtils.getDeviceManagementService().modifyEnrollment(device);
|
||||
if (result) {
|
||||
return Response.status(Response.Status.ACCEPTED).build();
|
||||
} else {
|
||||
return Response.status(Response.Status.NOT_MODIFIED).build();
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while modifying enrollment of the Android device that carries the id '" +
|
||||
id + "'";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/events/publish/{type}/{deviceId}")
|
||||
@Override
|
||||
public Response publishEvents(@Valid Map<String, Object> payload, @PathParam("type") String type
|
||||
, @PathParam("deviceId") String deviceId) {
|
||||
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
EventStreamAdminServiceStub eventStreamAdminServiceStub = null;
|
||||
try {
|
||||
if (payload == null) {
|
||||
String msg = "invalid payload structure";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
} else {
|
||||
boolean authorized = DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized
|
||||
(new DeviceIdentifier(type, deviceId));
|
||||
if (!authorized) {
|
||||
String msg = "Does not have permission to access the device.";
|
||||
return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
|
||||
}
|
||||
}
|
||||
Object metaData[] = new Object[1];
|
||||
metaData[0] = deviceId;
|
||||
EventAttributeList eventAttributeList = DeviceMgtAPIUtils.getDynamicEventCache().get(type);
|
||||
if (eventAttributeList == null) {
|
||||
String streamName = DeviceMgtAPIUtils.getStreamDefinition(type, tenantDomain);
|
||||
eventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub();
|
||||
EventStreamDefinitionDto eventStreamDefinitionDto = eventStreamAdminServiceStub.getStreamDefinitionDto(
|
||||
streamName + ":" + Constants.DEFAULT_STREAM_VERSION);
|
||||
if (eventStreamDefinitionDto == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
} else {
|
||||
EventStreamAttributeDto[] eventStreamAttributeDtos = eventStreamDefinitionDto.getPayloadData();
|
||||
List<Attribute> attributes = new ArrayList<>();
|
||||
for (EventStreamAttributeDto eventStreamAttributeDto : eventStreamAttributeDtos) {
|
||||
attributes.add(new Attribute(eventStreamAttributeDto.getAttributeName()
|
||||
, AttributeType.valueOf(eventStreamAttributeDto.getAttributeType().toUpperCase())));
|
||||
|
||||
}
|
||||
if (payload.size() != attributes.size()) {
|
||||
String msg = "Payload does not match with the stream definition";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
}
|
||||
eventAttributeList = new EventAttributeList();
|
||||
eventAttributeList.setList(attributes);
|
||||
DeviceMgtAPIUtils.getDynamicEventCache().put(type, eventAttributeList);
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
Object[] payloadData = new Object[eventAttributeList.getList().size()];
|
||||
for (Attribute attribute : eventAttributeList.getList()) {
|
||||
if (attribute.getType() == AttributeType.INT) {
|
||||
payloadData[i] = ((Double) payload.get(attribute.getName())).intValue();
|
||||
} else if (attribute.getType() == AttributeType.LONG) {
|
||||
payloadData[i] = ((Double) payload.get(attribute.getName())).longValue();
|
||||
} else {
|
||||
payloadData[i] = payload.get(attribute.getName());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
|
||||
, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
|
||||
, Constants.DEFAULT_STREAM_VERSION, metaData
|
||||
, null, payloadData)) {
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} else {
|
||||
String msg = "Error occurred while publishing the event.";
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
} catch (DataPublisherConfigurationException e) {
|
||||
String msg = "Error occurred while publishing the event.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
String msg = "Error occurred when checking for authorization";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (AxisFault e) {
|
||||
log.error("Failed to retrieve 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:" + 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, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} finally {
|
||||
if (eventStreamAdminServiceStub != null) {
|
||||
try {
|
||||
eventStreamAdminServiceStub.cleanup();
|
||||
} catch (AxisFault axisFault) {
|
||||
log.warn("Failed to clean eventStreamAdminServiceStub");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/events/publish/data/{type}/{deviceId}")
|
||||
@Override
|
||||
public Response publishEvents(@Valid List<Object> payload, @PathParam("type") String type
|
||||
, @PathParam("deviceId") String deviceId) {
|
||||
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
EventStreamAdminServiceStub eventStreamAdminServiceStub = null;
|
||||
try {
|
||||
if (payload == null) {
|
||||
String msg = "Invalid payload structure";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
} else {
|
||||
boolean authorized = DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized
|
||||
(new DeviceIdentifier(type, deviceId));
|
||||
if (!authorized) {
|
||||
String msg = "Does not have permission to access the device.";
|
||||
return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
|
||||
}
|
||||
}
|
||||
Object metaData[] = new Object[1];
|
||||
metaData[0] = deviceId;
|
||||
EventAttributeList eventAttributeList = DeviceMgtAPIUtils.getDynamicEventCache().get(type);
|
||||
if (eventAttributeList == null) {
|
||||
String streamName = DeviceMgtAPIUtils.getStreamDefinition(type, tenantDomain);
|
||||
eventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub();
|
||||
EventStreamDefinitionDto eventStreamDefinitionDto = eventStreamAdminServiceStub.getStreamDefinitionDto(
|
||||
streamName + ":" + Constants.DEFAULT_STREAM_VERSION);
|
||||
if (eventStreamDefinitionDto == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
} else {
|
||||
EventStreamAttributeDto[] eventStreamAttributeDtos = eventStreamDefinitionDto.getPayloadData();
|
||||
List<Attribute> attributes = new ArrayList<>();
|
||||
for (EventStreamAttributeDto eventStreamAttributeDto : eventStreamAttributeDtos) {
|
||||
attributes.add(new Attribute(eventStreamAttributeDto.getAttributeName()
|
||||
, AttributeType.valueOf(eventStreamAttributeDto.getAttributeType().toUpperCase())));
|
||||
|
||||
}
|
||||
if (payload.size() != attributes.size()) {
|
||||
String msg = "Payload does not match with the stream definition";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
}
|
||||
eventAttributeList = new EventAttributeList();
|
||||
eventAttributeList.setList(attributes);
|
||||
DeviceMgtAPIUtils.getDynamicEventCache().put(type, eventAttributeList);
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
Object[] payloadData = new Object[eventAttributeList.getList().size()];
|
||||
for (Attribute attribute : eventAttributeList.getList()) {
|
||||
if (attribute.getType() == AttributeType.INT) {
|
||||
payloadData[i] = ((Double) payload.get(i)).intValue();
|
||||
} else if (attribute.getType() == AttributeType.LONG) {
|
||||
payloadData[i] = ((Double) payload.get(i)).longValue();
|
||||
} else {
|
||||
payloadData[i] = payload.get(i);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
|
||||
, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
|
||||
, Constants.DEFAULT_STREAM_VERSION, metaData
|
||||
, null, payloadData)) {
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} else {
|
||||
String msg = "Error occurred while publishing the event.";
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
} catch (DataPublisherConfigurationException e) {
|
||||
String msg = "Error occurred while publishing the event.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
String msg = "Error occurred when checking for authorization";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (AxisFault e) {
|
||||
log.error("Failed to retrieve 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:" + 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, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} finally {
|
||||
if (eventStreamAdminServiceStub != null) {
|
||||
try {
|
||||
eventStreamAdminServiceStub.cleanup();
|
||||
} catch (AxisFault axisFault) {
|
||||
log.warn("Failed to clean eventStreamAdminServiceStub");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/pending/operations/{type}/{id}")
|
||||
public Response getPendingOperations(@PathParam("type") String type, @PathParam("id") String deviceId) {
|
||||
try {
|
||||
if (!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(type)) {
|
||||
String errorMessage = "Device identifier list is empty";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, type);
|
||||
if (!DeviceMgtAPIUtils.isValidDeviceIdentifier(deviceIdentifier)) {
|
||||
String msg = "Device not found for identifier '" + deviceId + "'";
|
||||
log.error(msg);
|
||||
return Response.status(Response.Status.NO_CONTENT).entity(msg).build();
|
||||
}
|
||||
List<? extends Operation> operations = DeviceMgtAPIUtils.getDeviceManagementService().getPendingOperations(
|
||||
deviceIdentifier);
|
||||
OperationList operationsList = new OperationList();
|
||||
operationsList.setList(operations);
|
||||
operationsList.setCount(operations.size());
|
||||
return Response.status(Response.Status.OK).entity(operationsList).build();
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
log.error(errorMessage, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving deivce management service instance";
|
||||
log.error(errorMessage, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/next-pending/operation/{type}/{id}")
|
||||
public Response getNextPendingOperation(@PathParam("type") String type, @PathParam("id") String deviceId) {
|
||||
try {
|
||||
if (!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(type)) {
|
||||
String errorMessage = "Device type is invalid";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, type);
|
||||
if (!DeviceMgtAPIUtils.isValidDeviceIdentifier(deviceIdentifier)) {
|
||||
String msg = "Device not found for identifier '" + deviceId + "'";
|
||||
log.error(msg);
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
}
|
||||
Operation operation = DeviceMgtAPIUtils.getDeviceManagementService().getNextPendingOperation(
|
||||
deviceIdentifier);
|
||||
return Response.status(Response.Status.OK).entity(operation).build();
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
log.error(errorMessage, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving deivce management service instance";
|
||||
log.error(errorMessage, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
}
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/operations/{type}/{id}")
|
||||
public Response updateOperation(@PathParam("type") String type, @PathParam("id") String deviceId, @Valid Operation operation) {
|
||||
try {
|
||||
if (!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(type)) {
|
||||
String errorMessage = "Device type is invalid";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
if (operation == null) {
|
||||
String errorMessage = "Operation cannot empty";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, type);
|
||||
if (!DeviceMgtAPIUtils.isValidDeviceIdentifier(deviceIdentifier)) {
|
||||
String msg = "Device not found for identifier '" + deviceId + "'";
|
||||
log.error(msg);
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
}
|
||||
if (!Operation.Status.ERROR.equals(operation.getStatus()) && operation.getCode() != null &&
|
||||
POLICY_MONITOR.equals(operation.getCode())) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info("Received compliance status from POLICY_MONITOR operation ID: " + operation.getId());
|
||||
}
|
||||
List<ComplianceFeature> features = getComplianceFeatures(operation.getPayLoad());
|
||||
DeviceMgtAPIUtils.getPolicyManagementService().checkCompliance(deviceIdentifier, features);
|
||||
|
||||
} else {
|
||||
DeviceMgtAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation);
|
||||
}
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
log.error(errorMessage, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving deivce management service instance";
|
||||
log.error(errorMessage, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
} catch (PolicyComplianceException e) {
|
||||
String errorMessage = "Issue in retrieving deivce management service instance";
|
||||
log.error(errorMessage, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/status/operations/{type}/{id}")
|
||||
public Response getOperationsByDeviceAndStatus(@PathParam("type") String type, @PathParam("id") String deviceId,
|
||||
@QueryParam("status") Operation.Status status) {
|
||||
if (status == null) {
|
||||
String errorMessage = "Status is empty";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
|
||||
try {
|
||||
if (!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(type)) {
|
||||
String errorMessage = "Invalid Device Type";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
List<? extends Operation> operations = DeviceMgtAPIUtils.getDeviceManagementService()
|
||||
.getOperationsByDeviceAndStatus(new DeviceIdentifier(deviceId, type), status);
|
||||
OperationList operationsList = new OperationList();
|
||||
operationsList.setList(operations);
|
||||
operationsList.setCount(operations.size());
|
||||
return Response.status(Response.Status.OK).entity(operationsList).build();
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
log.error(errorMessage, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service";
|
||||
log.error(errorMessage, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
}
|
||||
}
|
||||
|
||||
private static List<ComplianceFeature> getComplianceFeatures(Object compliancePayload) throws
|
||||
PolicyComplianceException {
|
||||
String compliancePayloadString = new Gson().toJson(compliancePayload);
|
||||
if (compliancePayload == null) {
|
||||
return null;
|
||||
}
|
||||
// Parsing json string to get compliance features.
|
||||
JsonElement jsonElement = new JsonParser().parse(compliancePayloadString);
|
||||
|
||||
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
||||
Gson gson = new Gson();
|
||||
ComplianceFeature complianceFeature;
|
||||
List<ComplianceFeature> complianceFeatures = new ArrayList<ComplianceFeature>(jsonArray.size());
|
||||
|
||||
for (JsonElement element : jsonArray) {
|
||||
complianceFeature = gson.fromJson(element, ComplianceFeature.class);
|
||||
complianceFeatures.add(complianceFeature);
|
||||
}
|
||||
return complianceFeatures;
|
||||
}
|
||||
}
|
@ -0,0 +1,590 @@
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
||||
|
||||
import org.apache.axis2.AxisFault;
|
||||
import org.apache.axis2.client.Stub;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
|
||||
import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.SortType;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub
|
||||
.EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTable;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTableRecord;
|
||||
import org.wso2.carbon.base.MultitenantConstants;
|
||||
import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.DeviceTypeEvent;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventRecords;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Attribute;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AttributeType;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventAttributeList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.TransportType;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceEventManagementService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||
import org.wso2.carbon.event.publisher.stub.EventPublisherAdminServiceCallbackHandler;
|
||||
import org.wso2.carbon.event.publisher.stub.EventPublisherAdminServiceStub;
|
||||
import org.wso2.carbon.event.receiver.stub.EventReceiverAdminServiceCallbackHandler;
|
||||
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.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.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
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.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is used for device type integration with DAS, to create streams and receiver dynamically and a common endpoint
|
||||
* to retrieve data.
|
||||
*/
|
||||
@Path("/events")
|
||||
public class DeviceEventManagementServiceImpl implements DeviceEventManagementService {
|
||||
|
||||
private static final Log log = LogFactory.getLog(DeviceEventManagementServiceImpl.class);
|
||||
|
||||
private static final String DEFAULT_EVENT_STORE_NAME = "EVENT_STORE";
|
||||
private static final String DEFAULT_WEBSOCKET_PUBLISHER_ADAPTER_TYPE = "secured-websocket";
|
||||
private static final String OAUTH_MQTT_ADAPTER_TYPE = "oauth-mqtt";
|
||||
private static final String THRIFT_ADAPTER_TYPE = "iot-event";
|
||||
private static final String DEFAULT_DEVICE_ID_ATTRIBUTE = "deviceId";
|
||||
private static final String DEFAULT_META_DEVICE_ID_ATTRIBUTE = "meta_deviceId";
|
||||
private static final String MQTT_CONTENT_TRANSFORMER = "device-meta-transformer";
|
||||
private static final String MQTT_CONTENT_TRANSFORMER_TYPE = "contentTransformer";
|
||||
private static final String MQTT_CONTENT_VALIDATOR_TYPE = "contentValidator";
|
||||
private static final String MQTT_CONTENT_VALIDATOR = "default";
|
||||
private static final String TIMESTAMP_FIELD_NAME = "_timestamp";
|
||||
|
||||
/**
|
||||
* Retrieves the stream definition from das for the given device type.
|
||||
* @return dynamic event attribute list
|
||||
*/
|
||||
@GET
|
||||
@Path("/{type}")
|
||||
@Override
|
||||
public Response getDeviceTypeEventDefinition(@PathParam("type") String deviceType) {
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
EventStreamAdminServiceStub eventStreamAdminServiceStub = null;
|
||||
EventReceiverAdminServiceStub eventReceiverAdminServiceStub = null;
|
||||
try {
|
||||
if (deviceType == null ||
|
||||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
String errorMessage = "Invalid device type";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain);
|
||||
eventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub();
|
||||
EventStreamDefinitionDto eventStreamDefinitionDto = eventStreamAdminServiceStub.getStreamDefinitionDto(
|
||||
streamName + ":" + Constants.DEFAULT_STREAM_VERSION);
|
||||
if (eventStreamDefinitionDto == null) {
|
||||
return Response.status(Response.Status.NO_CONTENT).build();
|
||||
}
|
||||
|
||||
EventStreamAttributeDto[] eventStreamAttributeDtos = eventStreamDefinitionDto.getPayloadData();
|
||||
EventAttributeList eventAttributeList = new EventAttributeList();
|
||||
List<Attribute> attributes = new ArrayList<>();
|
||||
for (EventStreamAttributeDto eventStreamAttributeDto : eventStreamAttributeDtos) {
|
||||
attributes.add(new Attribute(eventStreamAttributeDto.getAttributeName()
|
||||
, AttributeType.valueOf(eventStreamAttributeDto.getAttributeType().toUpperCase())));
|
||||
}
|
||||
eventAttributeList.setList(attributes);
|
||||
|
||||
DeviceTypeEvent deviceTypeEvent = new DeviceTypeEvent();
|
||||
deviceTypeEvent.setEventAttributeList(eventAttributeList);
|
||||
deviceTypeEvent.setTransportType(TransportType.HTTP);
|
||||
eventReceiverAdminServiceStub = DeviceMgtAPIUtils.getEventReceiverAdminServiceStub();
|
||||
EventReceiverConfigurationDto eventReceiverConfigurationDto = eventReceiverAdminServiceStub
|
||||
.getActiveEventReceiverConfiguration(getReceiverName(deviceType, tenantDomain, TransportType.MQTT));
|
||||
if (eventReceiverConfigurationDto != null) {
|
||||
deviceTypeEvent.setTransportType(TransportType.MQTT);
|
||||
}
|
||||
return Response.ok().entity(deviceTypeEvent).build();
|
||||
} catch (AxisFault e) {
|
||||
log.error("Failed to retrieve 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:" + 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, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} finally {
|
||||
cleanup(eventStreamAdminServiceStub);
|
||||
cleanup(eventReceiverAdminServiceStub);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy Event Stream, Receiver, Publisher and Store Configuration.
|
||||
*/
|
||||
@POST
|
||||
@Path("/{type}")
|
||||
@Override
|
||||
public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType,
|
||||
@Valid DeviceTypeEvent deviceTypeEvent) {
|
||||
TransportType transportType = deviceTypeEvent.getTransportType();
|
||||
EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList();
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
try {
|
||||
if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 ||
|
||||
deviceType == null || transportType == null ||
|
||||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
String errorMessage = "Invalid Payload";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain);
|
||||
String streamNameWithVersion = streamName + ":" + Constants.DEFAULT_STREAM_VERSION;
|
||||
publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
|
||||
publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, deviceType);
|
||||
publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes);
|
||||
publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType);
|
||||
try {
|
||||
PrivilegedCarbonContext.startTenantFlow();
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
|
||||
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
|
||||
if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
|
||||
publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
|
||||
publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, deviceType);
|
||||
}
|
||||
} finally {
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
}
|
||||
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:" + 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, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException e) {
|
||||
log.error("Failed to create event store for, tenantDomain: " + tenantDomain + " deviceType" + deviceType,
|
||||
e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete device type specific artifacts from DAS.
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/{type}")
|
||||
@Override
|
||||
public Response deleteDeviceTypeEventDefinitions(@PathParam("type") String deviceType) {
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
EventReceiverAdminServiceStub eventReceiverAdminServiceStub = null;
|
||||
EventPublisherAdminServiceStub eventPublisherAdminServiceStub = null;
|
||||
EventStreamAdminServiceStub eventStreamAdminServiceStub = null;
|
||||
|
||||
EventReceiverAdminServiceStub tenantBasedEventReceiverAdminServiceStub = null;
|
||||
EventStreamAdminServiceStub tenantBasedEventStreamAdminServiceStub = null;
|
||||
try {
|
||||
if (deviceType == null ||
|
||||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
String errorMessage = "Invalid device type";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
}
|
||||
String eventPublisherName = deviceType.trim().replace(" ", "_") + "_websocket_publisher";
|
||||
String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain);
|
||||
eventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub();
|
||||
if (eventStreamAdminServiceStub.getStreamDefinitionDto(streamName + ":" + Constants.DEFAULT_STREAM_VERSION) == null) {
|
||||
return Response.status(Response.Status.NO_CONTENT).build();
|
||||
}
|
||||
eventStreamAdminServiceStub.removeEventStreamDefinition(streamName, Constants.DEFAULT_STREAM_VERSION);
|
||||
EventReceiverAdminServiceCallbackHandler eventReceiverAdminServiceCallbackHandler =
|
||||
new EventReceiverAdminServiceCallbackHandler() {};
|
||||
EventPublisherAdminServiceCallbackHandler eventPublisherAdminServiceCallbackHandler =
|
||||
new EventPublisherAdminServiceCallbackHandler() {};
|
||||
|
||||
|
||||
String eventReceiverName = getReceiverName(deviceType, tenantDomain, TransportType.MQTT);
|
||||
eventReceiverAdminServiceStub = DeviceMgtAPIUtils.getEventReceiverAdminServiceStub();
|
||||
if (eventReceiverAdminServiceStub.getInactiveEventReceiverConfigurationContent(eventReceiverName) == null) {
|
||||
eventReceiverName = getReceiverName(deviceType, tenantDomain, TransportType.HTTP);
|
||||
}
|
||||
eventReceiverAdminServiceStub.startundeployInactiveEventReceiverConfiguration(eventReceiverName
|
||||
, eventReceiverAdminServiceCallbackHandler);
|
||||
|
||||
eventPublisherAdminServiceStub = DeviceMgtAPIUtils.getEventPublisherAdminServiceStub();
|
||||
eventPublisherAdminServiceStub.startundeployInactiveEventPublisherConfiguration(eventPublisherName
|
||||
, eventPublisherAdminServiceCallbackHandler);
|
||||
|
||||
try {
|
||||
PrivilegedCarbonContext.startTenantFlow();
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
|
||||
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
|
||||
if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
|
||||
tenantBasedEventReceiverAdminServiceStub = DeviceMgtAPIUtils.getEventReceiverAdminServiceStub();
|
||||
tenantBasedEventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub();
|
||||
tenantBasedEventStreamAdminServiceStub.removeEventStreamDefinition(streamName,
|
||||
Constants.DEFAULT_STREAM_VERSION);
|
||||
|
||||
tenantBasedEventReceiverAdminServiceStub.startundeployInactiveEventReceiverConfiguration(
|
||||
eventReceiverName, eventReceiverAdminServiceCallbackHandler);
|
||||
|
||||
}
|
||||
} finally {
|
||||
cleanup(tenantBasedEventReceiverAdminServiceStub);
|
||||
cleanup(tenantBasedEventStreamAdminServiceStub);
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
}
|
||||
return Response.ok().build();
|
||||
} catch (AxisFault e) {
|
||||
log.error("Failed to delete 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:" + 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, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} finally {
|
||||
cleanup(eventStreamAdminServiceStub);
|
||||
cleanup(eventPublisherAdminServiceStub);
|
||||
cleanup(eventReceiverAdminServiceStub);
|
||||
cleanup(eventReceiverAdminServiceStub);
|
||||
cleanup(eventStreamAdminServiceStub);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns device specific data for the give period of time.
|
||||
*/
|
||||
@GET
|
||||
@Path("/{type}/{deviceId}")
|
||||
@Override
|
||||
public Response getData(@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
|
||||
@QueryParam("to") long to, @PathParam("type") String deviceType, @QueryParam("offset")
|
||||
int offset, @QueryParam("limit") int limit) {
|
||||
if (from == 0 || to == 0) {
|
||||
String errorMessage = "Invalid values for from/to";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
}
|
||||
String fromDate = String.valueOf(from);
|
||||
String toDate = String.valueOf(to);
|
||||
String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId
|
||||
+ " AND _timestamp : [" + fromDate + " TO " + toDate + "]";
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
|
||||
try {
|
||||
if (deviceType == null ||
|
||||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
String errorMessage = "Invalid device type";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
|
||||
new DeviceIdentifier(deviceId, deviceType))) {
|
||||
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
}
|
||||
List<SortByField> sortByFields = new ArrayList<>();
|
||||
SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
|
||||
sortByFields.add(sortByField);
|
||||
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, offset, limit);
|
||||
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
||||
} catch (AnalyticsException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
log.error(e.getErrorMessage(), e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last know data point of the device type.
|
||||
*/
|
||||
@GET
|
||||
@Path("/last-known/{type}/{deviceId}")
|
||||
@Override
|
||||
public Response getLastKnownData(@PathParam("deviceId") String deviceId, @PathParam("type") String deviceType) {
|
||||
String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId;
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
|
||||
try {
|
||||
if (deviceType == null ||
|
||||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
String errorMessage = "Invalid device type";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
|
||||
new DeviceIdentifier(deviceId, deviceType))) {
|
||||
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
}
|
||||
List<SortByField> sortByFields = new ArrayList<>();
|
||||
SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
|
||||
sortByFields.add(sortByField);
|
||||
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1);
|
||||
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
||||
} catch (AnalyticsException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
log.error(e.getErrorMessage(), e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
}
|
||||
}
|
||||
|
||||
private void publishEventReceivers(String streamNameWithVersion, TransportType transportType
|
||||
, String requestedTenantDomain, String deviceType)
|
||||
throws RemoteException, UserStoreException, JWTClientException {
|
||||
EventReceiverAdminServiceStub receiverAdminServiceStub = DeviceMgtAPIUtils.getEventReceiverAdminServiceStub();
|
||||
try {
|
||||
TransportType transportTypeToBeRemoved = TransportType.HTTP;
|
||||
if (transportType == TransportType.HTTP) {
|
||||
transportTypeToBeRemoved = TransportType.MQTT;
|
||||
}
|
||||
String eventRecieverNameTobeRemoved = getReceiverName(deviceType, requestedTenantDomain, transportTypeToBeRemoved);
|
||||
EventReceiverConfigurationDto eventReceiverConfigurationDto = receiverAdminServiceStub
|
||||
.getActiveEventReceiverConfiguration(eventRecieverNameTobeRemoved);
|
||||
if (eventReceiverConfigurationDto != null) {
|
||||
EventReceiverAdminServiceCallbackHandler eventReceiverAdminServiceCallbackHandler =
|
||||
new EventReceiverAdminServiceCallbackHandler() {};
|
||||
receiverAdminServiceStub.startundeployActiveEventReceiverConfiguration(eventRecieverNameTobeRemoved
|
||||
, eventReceiverAdminServiceCallbackHandler);
|
||||
}
|
||||
|
||||
String adapterType = OAUTH_MQTT_ADAPTER_TYPE;
|
||||
BasicInputAdapterPropertyDto basicInputAdapterPropertyDtos[];
|
||||
if (transportType == TransportType.MQTT) {
|
||||
basicInputAdapterPropertyDtos = new BasicInputAdapterPropertyDto[3];
|
||||
basicInputAdapterPropertyDtos[0] = getBasicInputAdapterPropertyDto("topic", requestedTenantDomain
|
||||
+ "/" + deviceType + "/+/events");
|
||||
basicInputAdapterPropertyDtos[1] = getBasicInputAdapterPropertyDto(MQTT_CONTENT_TRANSFORMER_TYPE
|
||||
, MQTT_CONTENT_TRANSFORMER);
|
||||
basicInputAdapterPropertyDtos[2] = getBasicInputAdapterPropertyDto(MQTT_CONTENT_VALIDATOR_TYPE
|
||||
, MQTT_CONTENT_VALIDATOR);
|
||||
} else {
|
||||
adapterType = THRIFT_ADAPTER_TYPE;
|
||||
basicInputAdapterPropertyDtos = new BasicInputAdapterPropertyDto[1];
|
||||
basicInputAdapterPropertyDtos[0] = getBasicInputAdapterPropertyDto("events.duplicated.in.cluster", "false");
|
||||
}
|
||||
String eventRecieverName = getReceiverName(deviceType, requestedTenantDomain, transportType);
|
||||
if (receiverAdminServiceStub.getActiveEventReceiverConfiguration(eventRecieverName) == null) {
|
||||
if (transportType == TransportType.MQTT) {
|
||||
receiverAdminServiceStub.deployJsonEventReceiverConfiguration(eventRecieverName, streamNameWithVersion
|
||||
, adapterType, null, basicInputAdapterPropertyDtos, false);
|
||||
} else {
|
||||
receiverAdminServiceStub.deployWso2EventReceiverConfiguration(eventRecieverName, streamNameWithVersion
|
||||
, adapterType, null, null, null, basicInputAdapterPropertyDtos, false, null);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
cleanup(receiverAdminServiceStub);
|
||||
}
|
||||
}
|
||||
|
||||
private void publishStreamDefinitons(String streamName, String version, String deviceType
|
||||
, EventAttributeList eventAttributes)
|
||||
throws RemoteException, UserStoreException, JWTClientException {
|
||||
EventStreamAdminServiceStub eventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub();
|
||||
try {
|
||||
EventStreamDefinitionDto eventStreamDefinitionDto = new EventStreamDefinitionDto();
|
||||
eventStreamDefinitionDto.setName(streamName);
|
||||
eventStreamDefinitionDto.setVersion(version);
|
||||
EventStreamAttributeDto eventStreamAttributeDtos[] =
|
||||
new EventStreamAttributeDto[eventAttributes.getList().size()];
|
||||
EventStreamAttributeDto metaStreamAttributeDtos[] =
|
||||
new EventStreamAttributeDto[1];
|
||||
int i = 0;
|
||||
for (Attribute attribute : eventAttributes.getList()) {
|
||||
EventStreamAttributeDto eventStreamAttributeDto = new EventStreamAttributeDto();
|
||||
eventStreamAttributeDto.setAttributeName(attribute.getName());
|
||||
eventStreamAttributeDto.setAttributeType(attribute.getType().toString());
|
||||
eventStreamAttributeDtos[i] = eventStreamAttributeDto;
|
||||
i++;
|
||||
}
|
||||
|
||||
EventStreamAttributeDto eventStreamAttributeDto = new EventStreamAttributeDto();
|
||||
eventStreamAttributeDto.setAttributeName(DEFAULT_DEVICE_ID_ATTRIBUTE);
|
||||
eventStreamAttributeDto.setAttributeType(AttributeType.STRING.toString());
|
||||
metaStreamAttributeDtos[0] = eventStreamAttributeDto;
|
||||
eventStreamDefinitionDto.setPayloadData(eventStreamAttributeDtos);
|
||||
eventStreamDefinitionDto.setMetaData(metaStreamAttributeDtos);
|
||||
String streamId = streamName + ":" + version;
|
||||
if (eventStreamAdminServiceStub.getStreamDefinitionDto(streamId) != null) {
|
||||
eventStreamAdminServiceStub.editEventStreamDefinitionAsDto(eventStreamDefinitionDto, streamId);
|
||||
} else {
|
||||
eventStreamAdminServiceStub.addEventStreamDefinitionAsDto(eventStreamDefinitionDto);
|
||||
}
|
||||
} finally {
|
||||
cleanup(eventStreamAdminServiceStub);
|
||||
}
|
||||
}
|
||||
|
||||
private void publishEventStore(String streamName, String version, EventAttributeList eventAttributes)
|
||||
throws RemoteException, UserStoreException, JWTClientException,
|
||||
EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException {
|
||||
EventStreamPersistenceAdminServiceStub eventStreamPersistenceAdminServiceStub =
|
||||
DeviceMgtAPIUtils.getEventStreamPersistenceAdminServiceStub();
|
||||
try {
|
||||
AnalyticsTable analyticsTable = new AnalyticsTable();
|
||||
analyticsTable.setRecordStoreName(DEFAULT_EVENT_STORE_NAME);
|
||||
analyticsTable.setStreamVersion(version);
|
||||
analyticsTable.setTableName(streamName);
|
||||
analyticsTable.setMergeSchema(false);
|
||||
analyticsTable.setPersist(true);
|
||||
AnalyticsTableRecord analyticsTableRecords[] = new AnalyticsTableRecord[eventAttributes.getList().size() + 1];
|
||||
int i = 0;
|
||||
for (Attribute attribute : eventAttributes.getList()) {
|
||||
AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
|
||||
analyticsTableRecord.setColumnName(attribute.getName());
|
||||
analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase());
|
||||
analyticsTableRecord.setFacet(false);
|
||||
analyticsTableRecord.setIndexed(false);
|
||||
analyticsTableRecord.setPersist(true);
|
||||
analyticsTableRecord.setPrimaryKey(false);
|
||||
analyticsTableRecord.setScoreParam(false);
|
||||
analyticsTableRecords[i] = analyticsTableRecord;
|
||||
i++;
|
||||
}
|
||||
AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
|
||||
analyticsTableRecord.setColumnName(DEFAULT_META_DEVICE_ID_ATTRIBUTE);
|
||||
analyticsTableRecord.setColumnType(AttributeType.STRING.toString().toUpperCase());
|
||||
analyticsTableRecord.setFacet(false);
|
||||
analyticsTableRecord.setIndexed(true);
|
||||
analyticsTableRecord.setPersist(true);
|
||||
analyticsTableRecord.setPrimaryKey(false);
|
||||
analyticsTableRecord.setScoreParam(false);
|
||||
analyticsTableRecords[i] = analyticsTableRecord;
|
||||
analyticsTable.setAnalyticsTableRecords(analyticsTableRecords);
|
||||
eventStreamPersistenceAdminServiceStub.addAnalyticsTable(analyticsTable);
|
||||
} finally {
|
||||
cleanup(eventStreamPersistenceAdminServiceStub);
|
||||
}
|
||||
}
|
||||
|
||||
private void publishWebsocketPublisherDefinition(String streamNameWithVersion, String deviceType)
|
||||
throws RemoteException, UserStoreException, JWTClientException {
|
||||
EventPublisherAdminServiceStub eventPublisherAdminServiceStub = DeviceMgtAPIUtils
|
||||
.getEventPublisherAdminServiceStub();
|
||||
try {
|
||||
String eventPublisherName = deviceType.trim().replace(" ", "_") + "_websocket_publisher";
|
||||
if (eventPublisherAdminServiceStub.getActiveEventPublisherConfiguration(eventPublisherName) == null) {
|
||||
eventPublisherAdminServiceStub.deployJsonEventPublisherConfiguration(eventPublisherName
|
||||
, streamNameWithVersion, DEFAULT_WEBSOCKET_PUBLISHER_ADAPTER_TYPE, null, null
|
||||
, null, false);
|
||||
}
|
||||
} finally {
|
||||
cleanup(eventPublisherAdminServiceStub);
|
||||
}
|
||||
}
|
||||
|
||||
private BasicInputAdapterPropertyDto getBasicInputAdapterPropertyDto(String key, String value) {
|
||||
BasicInputAdapterPropertyDto basicInputAdapterPropertyDto = new BasicInputAdapterPropertyDto();
|
||||
basicInputAdapterPropertyDto.setKey(key);
|
||||
basicInputAdapterPropertyDto.setValue(value);
|
||||
return basicInputAdapterPropertyDto;
|
||||
}
|
||||
|
||||
private String getTableName(String streamName) {
|
||||
return streamName.toUpperCase().replace('.', '_');
|
||||
}
|
||||
|
||||
private String getReceiverName(String deviceType, String tenantDomain, TransportType transportType) {
|
||||
return deviceType.replace(" ", "_").trim() + "-" + tenantDomain + "-" + transportType.toString() + "-receiver";
|
||||
}
|
||||
|
||||
private static AnalyticsDataAPI getAnalyticsDataAPI() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
AnalyticsDataAPI analyticsDataAPI =
|
||||
(AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
|
||||
if (analyticsDataAPI == null) {
|
||||
String msg = "Analytics api service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return analyticsDataAPI;
|
||||
}
|
||||
|
||||
private static EventRecords getAllEventsForDevice(String tableName, String query, List<SortByField> sortByFields
|
||||
, int offset, int limit) throws AnalyticsException {
|
||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
|
||||
EventRecords eventRecords = new EventRecords();
|
||||
int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
|
||||
if (eventCount == 0) {
|
||||
eventRecords.setCount(0);
|
||||
}
|
||||
List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, offset, limit,
|
||||
sortByFields);
|
||||
List<String> recordIds = getRecordIds(resultEntries);
|
||||
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
|
||||
eventRecords.setCount(eventCount);
|
||||
eventRecords.setList(AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response));
|
||||
return eventRecords;
|
||||
}
|
||||
|
||||
private static List<String> getRecordIds(List<SearchResultEntry> searchResults) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (SearchResultEntry searchResult : searchResults) {
|
||||
ids.add(searchResult.getId());
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
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,124 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.InvalidConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
|
||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceTypeManagementAdminService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Path("/admin/device-types")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class DeviceTypeManagementAdminServiceImpl implements DeviceTypeManagementAdminService {
|
||||
|
||||
private static final Log log = LogFactory.getLog(DeviceTypeManagementAdminServiceImpl.class);
|
||||
private static final String DEVICETYPE_REGEX_PATTERN = "^[^ /]+$";
|
||||
private static final Pattern patternMatcher = Pattern.compile(DEVICETYPE_REGEX_PATTERN);
|
||||
|
||||
@GET
|
||||
@Override
|
||||
public Response getDeviceTypes() {
|
||||
try {
|
||||
List<DeviceType> deviceTypes = DeviceMgtAPIUtils.getDeviceManagementService().getDeviceTypes();
|
||||
return Response.status(Response.Status.OK).entity(deviceTypes).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while fetching the list of device types.";
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@POST
|
||||
public Response addDeviceType(DeviceType deviceType) {
|
||||
if (deviceType != null && deviceType.getDeviceTypeMetaDefinition() != null) {
|
||||
try {
|
||||
if (DeviceMgtAPIUtils.getDeviceManagementService().getDeviceType(deviceType.getName()) != null) {
|
||||
String msg = "Device type already available, " + deviceType.getName();
|
||||
return Response.status(Response.Status.CONFLICT).entity(msg).build();
|
||||
}
|
||||
Matcher matcher = patternMatcher.matcher(deviceType.getName());
|
||||
if(matcher.find()) {
|
||||
DeviceManagementService httpDeviceTypeManagerService =
|
||||
DeviceMgtAPIUtils.getDeviceTypeGeneratorService()
|
||||
.populateDeviceManagementService(deviceType.getName(),
|
||||
deviceType.getDeviceTypeMetaDefinition());
|
||||
DeviceMgtAPIUtils.getDeviceManagementService().registerDeviceType(httpDeviceTypeManagerService);
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} else {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity("Device type name does not match the pattern "
|
||||
+ DEVICETYPE_REGEX_PATTERN).build();
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred at server side while adding a device type.";
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(msg).build();
|
||||
} catch (InvalidConfigurationException e) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
|
||||
}
|
||||
} else {
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@PUT
|
||||
public Response updateDeviceType(DeviceType deviceType) {
|
||||
if (deviceType != null && deviceType.getDeviceTypeMetaDefinition() != null) {
|
||||
try {
|
||||
if (DeviceMgtAPIUtils.getDeviceManagementService().getDeviceType(deviceType.getName()) == null) {
|
||||
String msg = "Device type does not exist, " + deviceType.getName();
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
}
|
||||
DeviceManagementService httpDeviceTypeManagerService = DeviceMgtAPIUtils.getDeviceTypeGeneratorService()
|
||||
.populateDeviceManagementService(deviceType.getName(), deviceType.getDeviceTypeMetaDefinition());
|
||||
DeviceMgtAPIUtils.getDeviceManagementService().registerDeviceType(httpDeviceTypeManagerService);
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred at server side while updating the device type.";
|
||||
log.error(msg, e);
|
||||
return Response.serverError().entity(msg).build();
|
||||
} catch (InvalidConfigurationException e) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
|
||||
}
|
||||
} else {
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
}
|
||||
}
|
4
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/InvalidConfigurationException.java → components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/InvalidConfigurationException.java
4
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/InvalidConfigurationException.java → components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/InvalidConfigurationException.java
21
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/InvalidConfigurationException.java → components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/pull/notification/PullNotificationExecutionFailedException.java
21
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/InvalidConfigurationException.java → components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/pull/notification/PullNotificationExecutionFailedException.java
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.common.pull.notification;
|
||||
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This will handle the execution flow when a device sends a payload to IoT Server.
|
||||
*/
|
||||
public interface PullNotificationSubscriber {
|
||||
|
||||
void init(Map<String, String> properties);
|
||||
|
||||
void execute(DeviceIdentifier deviceIdentifier, Operation operation) throws PullNotificationExecutionFailedException;
|
||||
|
||||
void clean();
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package org.wso2.carbon.device.mgt.common.spi;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeMetaDefinition;
|
||||
|
||||
/**
|
||||
* This implementation populates device management service.
|
||||
*/
|
||||
public interface DeviceTypeGeneratorService {
|
||||
|
||||
DeviceManagementService populateDeviceManagementService(String deviceTypeName
|
||||
, DeviceTypeMetaDefinition deviceTypeMetaDefinition);
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.common.type.mgt;
|
||||
|
||||
public interface DeviceTypeDefinitionProvider {
|
||||
|
||||
DeviceTypeMetaDefinition getDeviceTypeMetaDefinition();
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package org.wso2.carbon.device.mgt.common.type.mgt;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.Feature;
|
||||
import org.wso2.carbon.device.mgt.common.InitialOperationConfig;
|
||||
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
|
||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceTypeMetaDefinition {
|
||||
|
||||
private List<String> properties;
|
||||
private List<Feature> features;
|
||||
private boolean claimable;
|
||||
private PushNotificationConfig pushNotificationConfig;
|
||||
private boolean policyMonitoringEnabled;
|
||||
private InitialOperationConfig initialOperationConfig;
|
||||
private License license;
|
||||
private String description;
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<String> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<String> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public List<Feature> getFeatures() {
|
||||
return features;
|
||||
}
|
||||
|
||||
public void setFeatures(List<Feature> features) {
|
||||
this.features = features;
|
||||
}
|
||||
|
||||
public boolean isClaimable() {
|
||||
return claimable;
|
||||
}
|
||||
|
||||
public void setClaimable(boolean isClaimable) {
|
||||
this.claimable = isClaimable;
|
||||
}
|
||||
|
||||
public PushNotificationConfig getPushNotificationConfig() {
|
||||
return pushNotificationConfig;
|
||||
}
|
||||
|
||||
public void setPushNotificationConfig(
|
||||
PushNotificationConfig pushNotificationConfig) {
|
||||
this.pushNotificationConfig = pushNotificationConfig;
|
||||
}
|
||||
|
||||
public boolean isPolicyMonitoringEnabled() {
|
||||
return policyMonitoringEnabled;
|
||||
}
|
||||
|
||||
public void setPolicyMonitoringEnabled(boolean policyMonitoringEnabled) {
|
||||
this.policyMonitoringEnabled = policyMonitoringEnabled;
|
||||
}
|
||||
|
||||
public InitialOperationConfig getInitialOperationConfig() {
|
||||
return initialOperationConfig;
|
||||
}
|
||||
|
||||
public void setInitialOperationConfig(InitialOperationConfig initialOperationConfig) {
|
||||
this.initialOperationConfig = initialOperationConfig;
|
||||
}
|
||||
|
||||
public License getLicense() {
|
||||
return license;
|
||||
}
|
||||
|
||||
public void setLicense(License license) {
|
||||
this.license = license;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.core.config.pull.notification;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* This class is for Pull notification related Configurations
|
||||
*/
|
||||
@XmlRootElement(name = "PullNotificationConfiguration")
|
||||
public class PullNotificationConfiguration {
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
@XmlElement(name = "Enabled", required = true)
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.core.dto;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||
|
||||
/**
|
||||
* This holds the information of the registered device management service against the device type
|
||||
* definition loaded timestamp. This is used to handle device type update scenario.
|
||||
*/
|
||||
public class DeviceManagementServiceHolder {
|
||||
|
||||
private DeviceManagementService deviceManagementService;
|
||||
private long timestamp;
|
||||
|
||||
public DeviceManagementServiceHolder(DeviceManagementService deviceManagementService) {
|
||||
this.deviceManagementService = deviceManagementService;
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public DeviceManagementService getDeviceManagementService() {
|
||||
return deviceManagementService;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeConfigIdentifier.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeConfigIdentifier.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeConfigIdentifier.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeConfigIdentifier.java
@ -0,0 +1,14 @@
|
||||
package org.wso2.carbon.device.mgt.extensions.device.type.template;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
|
||||
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeMetaDefinition;
|
||||
|
||||
public class DeviceTypeGeneratorServiceImpl implements DeviceTypeGeneratorService {
|
||||
|
||||
@Override
|
||||
public DeviceManagementService populateDeviceManagementService(String deviceTypeName
|
||||
, DeviceTypeMetaDefinition deviceTypeMetaDefinition) {
|
||||
return new HTTPDeviceTypeManagerService(deviceTypeName, deviceTypeMetaDefinition);
|
||||
}
|
||||
}
|
32
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManager.java
32
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManager.java
69
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java
69
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.extensions.device.type.template;
|
||||
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.Feature;
|
||||
import org.wso2.carbon.device.mgt.common.InitialOperationConfig;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeDefinitionProvider;
|
||||
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeMetaDefinition;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Claimable;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.ConfigProperties;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceDetails;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceTypeConfiguration;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Features;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.License;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PolicyMonitoring;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Properties;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Property;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.ProvisioningConfig;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PullNotificationSubscriberConfig;
|
||||
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PushNotificationProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This inherits the capabiliy that is provided through the file based device type manager service.
|
||||
* This will create and instance of device management service through a json payload.
|
||||
*/
|
||||
public class HTTPDeviceTypeManagerService extends DeviceTypeManagerService implements DeviceTypeDefinitionProvider {
|
||||
|
||||
private DeviceTypeMetaDefinition deviceTypeMetaDefinition;
|
||||
private static final String DEFAULT_PULL_NOTIFICATION_CLASS_NAME = "org.wso2.carbon.device.mgt.extensions.pull.notification.PullNotificationSubscriberImpl";
|
||||
|
||||
public HTTPDeviceTypeManagerService(String deviceTypeName, DeviceTypeMetaDefinition deviceTypeMetaDefinition) {
|
||||
super(getDeviceTypeConfigIdentifier(deviceTypeName), getDeviceTypeConfiguration(
|
||||
deviceTypeName, deviceTypeMetaDefinition));
|
||||
this.deviceTypeMetaDefinition = deviceTypeMetaDefinition;
|
||||
}
|
||||
|
||||
private static DeviceTypeConfiguration getDeviceTypeConfiguration(String deviceTypeName, DeviceTypeMetaDefinition
|
||||
deviceTypeMetaDefinition) {
|
||||
DeviceTypeConfiguration deviceTypeConfiguration = new DeviceTypeConfiguration();
|
||||
|
||||
if (deviceTypeMetaDefinition != null) {
|
||||
Claimable claimable = new Claimable();
|
||||
claimable.setEnabled(deviceTypeMetaDefinition.isClaimable());
|
||||
deviceTypeConfiguration.setClaimable(claimable);
|
||||
|
||||
if (deviceTypeMetaDefinition.getProperties() != null &&
|
||||
deviceTypeMetaDefinition.getProperties().size() > 0) {
|
||||
DeviceDetails deviceDetails = new DeviceDetails();
|
||||
Properties properties = new Properties();
|
||||
properties.addProperties(deviceTypeMetaDefinition.getProperties());
|
||||
deviceDetails.setProperties(properties);
|
||||
deviceTypeConfiguration.setDeviceDetails(deviceDetails);
|
||||
}
|
||||
if (deviceTypeMetaDefinition.getFeatures() != null && deviceTypeMetaDefinition.getFeatures().size() > 0) {
|
||||
Features features = new Features();
|
||||
List<org.wso2.carbon.device.mgt.extensions.device.type.template.config.Feature> featureList
|
||||
= new ArrayList<>();
|
||||
for (Feature feature : deviceTypeMetaDefinition.getFeatures()) {
|
||||
org.wso2.carbon.device.mgt.extensions.device.type.template.config.Feature configFeature = new org
|
||||
.wso2.carbon.device.mgt.extensions.device.type.template.config.Feature();
|
||||
if (feature.getCode() != null && feature.getName() != null) {
|
||||
configFeature.setCode(feature.getCode());
|
||||
configFeature.setDescription(feature.getDescription());
|
||||
configFeature.setName(feature.getName());
|
||||
if (feature.getMetadataEntries() != null && feature.getMetadataEntries().size() > 0) {
|
||||
List<String> metaValues = new ArrayList<>();
|
||||
for (Feature.MetadataEntry metadataEntry : feature.getMetadataEntries()) {
|
||||
metaValues.add(metadataEntry.getValue().toString());
|
||||
}
|
||||
configFeature.setMetaData(metaValues);
|
||||
}
|
||||
featureList.add(configFeature);
|
||||
}
|
||||
}
|
||||
features.addFeatures(featureList);
|
||||
deviceTypeConfiguration.setFeatures(features);
|
||||
}
|
||||
|
||||
deviceTypeConfiguration.setName(deviceTypeName);
|
||||
//TODO: Add it to the license management service.
|
||||
// if (deviceTypeMetaDefinition.getLicense() != null) {
|
||||
// License license = new License();
|
||||
// license.setLanguage(deviceTypeMetaDefinition.getLicense().getLanguage());
|
||||
// license.setText(deviceTypeMetaDefinition.getLicense().getText());
|
||||
// license.setVersion(deviceTypeMetaDefinition.getLicense().getVersion());
|
||||
// deviceTypeConfiguration.setLicense(license);
|
||||
// }
|
||||
PolicyMonitoring policyMonitoring = new PolicyMonitoring();
|
||||
policyMonitoring.setEnabled(deviceTypeMetaDefinition.isPolicyMonitoringEnabled());
|
||||
deviceTypeConfiguration.setPolicyMonitoring(policyMonitoring);
|
||||
|
||||
ProvisioningConfig provisioningConfig = new ProvisioningConfig();
|
||||
provisioningConfig.setSharedWithAllTenants(false);
|
||||
deviceTypeConfiguration.setProvisioningConfig(provisioningConfig);
|
||||
|
||||
PushNotificationConfig pushNotificationConfig = deviceTypeMetaDefinition.getPushNotificationConfig();
|
||||
if (pushNotificationConfig != null) {
|
||||
PushNotificationProvider pushNotificationProvider = new PushNotificationProvider();
|
||||
pushNotificationProvider.setType(pushNotificationConfig.getType());
|
||||
//default schedule value will be true.
|
||||
pushNotificationProvider.setScheduled(true);
|
||||
if (pushNotificationConfig.getProperties() != null &&
|
||||
pushNotificationConfig.getProperties().size() > 0) {
|
||||
ConfigProperties configProperties = new ConfigProperties();
|
||||
List<Property> properties = new ArrayList<>();
|
||||
for (Map.Entry<String, String> entry : pushNotificationConfig.getProperties().entrySet()) {
|
||||
Property property = new Property();
|
||||
property.setName(entry.getKey());
|
||||
property.setValue(entry.getValue());
|
||||
properties.add(property);
|
||||
}
|
||||
configProperties.addProperties(properties);
|
||||
pushNotificationProvider.setConfigProperties(configProperties);
|
||||
}
|
||||
pushNotificationProvider.setFileBasedProperties(true);
|
||||
deviceTypeConfiguration.setPushNotificationProvider(pushNotificationProvider);
|
||||
}
|
||||
|
||||
// This is commented until the task registration handling issue is solved
|
||||
// OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceTypeMetaDefinition.getTaskConfig();
|
||||
// if (operationMonitoringTaskConfig != null) {
|
||||
// TaskConfiguration taskConfiguration = new TaskConfiguration();
|
||||
// taskConfiguration.setEnabled(operationMonitoringTaskConfig.isEnabled());
|
||||
// taskConfiguration.setFrequency(operationMonitoringTaskConfig.getFrequency());
|
||||
// if (operationMonitoringTaskConfig.getMonitoringOperation() != null) {
|
||||
// List<TaskConfiguration.Operation> operations = new ArrayList<>();
|
||||
// for (MonitoringOperation monitoringOperation : operationMonitoringTaskConfig
|
||||
// .getMonitoringOperation()) {
|
||||
// TaskConfiguration.Operation operation = new TaskConfiguration.Operation();
|
||||
// operation.setOperationName(monitoringOperation.getTaskName());
|
||||
// operation.setRecurrency(monitoringOperation.getRecurrentTimes());
|
||||
// operations.add(operation);
|
||||
// }
|
||||
// taskConfiguration.setOperations(operations);
|
||||
// }
|
||||
// deviceTypeConfiguration.setTaskConfiguration(taskConfiguration);
|
||||
// }
|
||||
|
||||
if (deviceTypeMetaDefinition.getInitialOperationConfig() != null) {
|
||||
InitialOperationConfig initialOperationConfig = deviceTypeMetaDefinition.getInitialOperationConfig();
|
||||
deviceTypeConfiguration.setOperations(initialOperationConfig.getOperations());
|
||||
}
|
||||
}
|
||||
PullNotificationSubscriberConfig pullNotificationSubscriber = new PullNotificationSubscriberConfig();
|
||||
pullNotificationSubscriber.setClassName(DEFAULT_PULL_NOTIFICATION_CLASS_NAME);
|
||||
deviceTypeConfiguration.setPullNotificationSubscriberConfig(pullNotificationSubscriber);
|
||||
return deviceTypeConfiguration;
|
||||
}
|
||||
|
||||
private static DeviceTypeConfigIdentifier getDeviceTypeConfigIdentifier(String deviceType) {
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
return new DeviceTypeConfigIdentifier(deviceType, tenantDomain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceTypeMetaDefinition getDeviceTypeMetaDefinition() {
|
||||
return deviceTypeMetaDefinition;
|
||||
}
|
||||
}
|
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Attributes.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Attributes.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Attributes.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Attributes.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Claimable.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Claimable.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Claimable.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Claimable.java
6
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/ConfigProperties.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/ConfigProperties.java
6
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/ConfigProperties.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/ConfigProperties.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DataSource.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DataSource.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DataSource.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DataSource.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceAuthorizationConfig.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceAuthorizationConfig.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceAuthorizationConfig.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceAuthorizationConfig.java
46
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceDetails.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceDetails.java
46
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceDetails.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceDetails.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceStatusTaskConfiguration.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceStatusTaskConfiguration.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceStatusTaskConfiguration.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceStatusTaskConfiguration.java
32
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java
32
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java
16
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Feature.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Feature.java
16
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Feature.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Feature.java
6
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Features.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Features.java
6
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Features.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Features.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/FormParameters.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/FormParameters.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/FormParameters.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/FormParameters.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/InitialOperationConfig.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/InitialOperationConfig.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/InitialOperationConfig.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/InitialOperationConfig.java
@ -1,4 +1,4 @@
|
||||
package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config;
|
||||
package org.wso2.carbon.device.mgt.extensions.device.type.template.config;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
import java.util.List;
|
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/JndiConfig.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/JndiConfig.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/JndiConfig.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/JndiConfig.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/License.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/License.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/License.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/License.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Operation.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Operation.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Operation.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Operation.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PolicyMonitoring.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PolicyMonitoring.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PolicyMonitoring.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PolicyMonitoring.java
@ -0,0 +1,80 @@
|
||||
|
||||
package org.wso2.carbon.device.mgt.extensions.device.type.template.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for Properties complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="Properties">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="Property" maxOccurs="unbounded" minOccurs="0">
|
||||
* <simpleType>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
|
||||
* <enumeration value="attr1"/>
|
||||
* <enumeration value="attr2"/>
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* </element>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "Properties", propOrder = {
|
||||
"property"
|
||||
})
|
||||
public class Properties {
|
||||
|
||||
@XmlElement(name = "Property")
|
||||
protected List<String> property;
|
||||
|
||||
/**
|
||||
* Gets the value of the property property.
|
||||
*
|
||||
* <p>
|
||||
* This accessor method returns a reference to the live list,
|
||||
* not a snapshot. Therefore any modification you make to the
|
||||
* returned list will be present inside the JAXB object.
|
||||
* This is why there is not a <CODE>set</CODE> method for the property property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getProperty().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link String }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<String> getProperty() {
|
||||
if (property == null) {
|
||||
property = new ArrayList<String>();
|
||||
}
|
||||
return this.property;
|
||||
}
|
||||
|
||||
public void addProperties(List<String> property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
}
|
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Property.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Property.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Property.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/Property.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/ProvisioningConfig.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/ProvisioningConfig.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/ProvisioningConfig.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/ProvisioningConfig.java
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.extensions.device.type.template.config;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for PullNotificationSubscriberConfig complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="PullNotificationSubscriberConfig">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="ConfigProperties" type="{}ConfigProperties"/>
|
||||
* </sequence>
|
||||
* <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "PullNotificationSubscriberConfig", propOrder = {
|
||||
"configProperties"
|
||||
})
|
||||
public class PullNotificationSubscriberConfig {
|
||||
@XmlElement(name = "ConfigProperties", required = true)
|
||||
protected ConfigProperties configProperties;
|
||||
@XmlAttribute(name = "className")
|
||||
protected String className;
|
||||
|
||||
/**
|
||||
* Gets the value of the configProperties property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link ConfigProperties }
|
||||
*
|
||||
*/
|
||||
public ConfigProperties getConfigProperties() {
|
||||
return configProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the configProperties property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link ConfigProperties }
|
||||
*
|
||||
*/
|
||||
public void setConfigProperties(ConfigProperties value) {
|
||||
this.configProperties = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the type property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the type property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setClassName(String value) {
|
||||
this.className = value;
|
||||
}
|
||||
|
||||
}
|
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PushNotificationProvider.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PushNotificationProvider.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PushNotificationProvider.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/PushNotificationProvider.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/QueryParameters.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/QueryParameters.java
2
components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/QueryParameters.java → components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/QueryParameters.java
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue