forked from community/device-mgt-core
Merge pull request #871 from Megala21/application-mgt
Merging with master and adding some java-doc commentsfeature/appm-store/pbac
commit
b872ea2cf4
@ -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.application.mgt.core.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.utils.CarbonUtils;
|
||||
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* ApplicationMgtDatabaseCreator is responsible for creating the Application Management related tables.
|
||||
*/
|
||||
public class ApplicationMgtDatabaseCreator extends DatabaseCreator {
|
||||
private static final Log log = LogFactory.getLog(ApplicationMgtDatabaseCreator.class);
|
||||
private static final String setupSQLScriptBaseLocation =
|
||||
CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator + "cdm" + File.separator
|
||||
+ "application-mgt" + File.separator;
|
||||
|
||||
public ApplicationMgtDatabaseCreator(DataSource dataSource) {
|
||||
super(dataSource);
|
||||
}
|
||||
|
||||
protected String getDbScriptLocation(String databaseType) {
|
||||
String scriptName = databaseType + ".sql";
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Loading application management database script from :" + scriptName);
|
||||
}
|
||||
return setupSQLScriptBaseLocation + scriptName;
|
||||
}
|
||||
}
|
@ -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,128 +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>
|
||||
|
||||
</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.46-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);
|
||||
}
|
||||
|
||||
}
|
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();
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue