forked from community/device-mgt-plugins
revert-dabc3590
parent
5dc233baed
commit
5b0748489d
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.iot.virtualfirealarm.plugin.internal.config;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Class for holding data source configuration in malformed-cdm-config-no-mgt-repo.xml at parsing
|
||||
* with JAXB.
|
||||
*/
|
||||
@XmlRootElement(name = "DataSourceConfiguration")
|
||||
public class DataSourceConfig {
|
||||
|
||||
private JNDILookupDefinition jndiLookupDefinition;
|
||||
|
||||
@XmlElement(name = "JndiLookupDefinition", required = true)
|
||||
public JNDILookupDefinition getJndiLookupDefinition() {
|
||||
return jndiLookupDefinition;
|
||||
}
|
||||
|
||||
public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) {
|
||||
this.jndiLookupDefinition = jndiLookupDefinition;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.iot.virtualfirealarm.plugin.internal.config;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Class for holding management repository data.
|
||||
*/
|
||||
@XmlRootElement(name = "ManagementRepository")
|
||||
public class DeviceManagementConfigRepository {
|
||||
|
||||
private DataSourceConfig dataSourceConfig;
|
||||
|
||||
@XmlElement(name = "DataSourceConfiguration", required = true)
|
||||
public DataSourceConfig getDataSourceConfig() {
|
||||
return dataSourceConfig;
|
||||
}
|
||||
|
||||
public void setDataSourceConfig(DataSourceConfig dataSourceConfig) {
|
||||
this.dataSourceConfig = dataSourceConfig;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.iot.virtualfirealarm.plugin.internal.config;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class for hold JndiLookupDefinition of rss-manager.xml at parsing with JAXB.
|
||||
*/
|
||||
@XmlRootElement(name = "JndiLookupDefinition")
|
||||
public class JNDILookupDefinition {
|
||||
|
||||
private String jndiName;
|
||||
private List<JNDIProperty> jndiProperties;
|
||||
|
||||
@XmlElement(name = "Name", required = false)
|
||||
public String getJndiName() {
|
||||
return jndiName;
|
||||
}
|
||||
|
||||
public void setJndiName(String jndiName) {
|
||||
this.jndiName = jndiName;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "Environment", required = false)
|
||||
@XmlElement(name = "Property", nillable = false)
|
||||
public List<JNDIProperty> getJndiProperties() {
|
||||
return jndiProperties;
|
||||
}
|
||||
|
||||
public void setJndiProperties(List<JNDIProperty> jndiProperties) {
|
||||
this.jndiProperties = jndiProperties;
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "Property")
|
||||
public static class JNDIProperty {
|
||||
|
||||
private String name;
|
||||
|
||||
private String value;
|
||||
|
||||
@XmlAttribute(name = "Name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.iot.virtualfirealarm.plugin.internal.config;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name = "PushNotificationConfiguration")
|
||||
public class PushNotificationConfig {
|
||||
|
||||
private List<Property> properties;
|
||||
|
||||
@XmlElementWrapper(name = "Properties", required = true)
|
||||
@XmlElement(name = "Property", required = true)
|
||||
public List<Property> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<Property> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "Property")
|
||||
public static class Property {
|
||||
|
||||
private String name;
|
||||
private String value;
|
||||
|
||||
@XmlAttribute(name = "Name", required = true)
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.iot.virtualfirealarm.plugin.internal.config;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.config.exception.InvalidConfigurationStateException;
|
||||
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.config.exception.VirtualFireAlarmConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.util.VirtualFireAlarmUtil;
|
||||
import org.wso2.carbon.utils.CarbonUtils;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.File;
|
||||
|
||||
@XmlRootElement(name = "DeviceManagementConfiguration")
|
||||
public class VirtualFireAlarmConfig {
|
||||
|
||||
private DeviceManagementConfigRepository deviceManagementConfigRepository;
|
||||
private PushNotificationConfig pushNotificationConfig;
|
||||
private static VirtualFireAlarmConfig config;
|
||||
|
||||
private static final Log log = LogFactory.getLog(VirtualFireAlarmConfig.class);
|
||||
private static final String VIRTUAL_FIRE_ALARM_CONFIG_PATH =
|
||||
CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "device-mgt-plugins" + File.separator +
|
||||
"virtual-fire-alarm" + File.separator + "virtual-fire-alarm-config.xml";
|
||||
|
||||
private VirtualFireAlarmConfig() {
|
||||
}
|
||||
|
||||
public static VirtualFireAlarmConfig getInstance() {
|
||||
if (config == null) {
|
||||
throw new InvalidConfigurationStateException("Webapp Authenticator Configuration is not " +
|
||||
"initialized properly");
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
@XmlElement(name = "ManagementRepository", required = true)
|
||||
public DeviceManagementConfigRepository getDeviceManagementConfigRepository() {
|
||||
return deviceManagementConfigRepository;
|
||||
}
|
||||
|
||||
public void setDeviceManagementConfigRepository(DeviceManagementConfigRepository deviceManagementConfigRepository) {
|
||||
this.deviceManagementConfigRepository = deviceManagementConfigRepository;
|
||||
}
|
||||
|
||||
@XmlElement(name = "PushNotificationConfiguration", required = false)
|
||||
public PushNotificationConfig getPushNotificationConfig() {
|
||||
return pushNotificationConfig;
|
||||
}
|
||||
|
||||
public void setPushNotificationConfig(PushNotificationConfig pushNotificationConfig) {
|
||||
this.pushNotificationConfig = pushNotificationConfig;
|
||||
}
|
||||
|
||||
public static void init() throws VirtualFireAlarmConfigurationException {
|
||||
try {
|
||||
File authConfig = new File(VirtualFireAlarmConfig.VIRTUAL_FIRE_ALARM_CONFIG_PATH);
|
||||
Document doc = VirtualFireAlarmUtil.convertToDocument(authConfig);
|
||||
|
||||
/* Un-marshaling Webapp Authenticator configuration */
|
||||
JAXBContext ctx = JAXBContext.newInstance(VirtualFireAlarmConfig.class);
|
||||
Unmarshaller unmarshaller = ctx.createUnmarshaller();
|
||||
//unmarshaller.setSchema(getSchema());
|
||||
config = (VirtualFireAlarmConfig) unmarshaller.unmarshal(doc);
|
||||
} catch (JAXBException e) {
|
||||
throw new VirtualFireAlarmConfigurationException("Error occurred while un-marshalling Virtual Fire Alarm " +
|
||||
" Config", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.config.exception;
|
||||
|
||||
public class InvalidConfigurationStateException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = -3151279411229070297L;
|
||||
|
||||
public InvalidConfigurationStateException(int errorCode, String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidConfigurationStateException(int errorCode, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public InvalidConfigurationStateException(String msg, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
}
|
||||
|
||||
public InvalidConfigurationStateException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public InvalidConfigurationStateException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public InvalidConfigurationStateException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public InvalidConfigurationStateException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.iot.virtualfirealarm.plugin.internal.config.exception;
|
||||
|
||||
public class VirtualFireAlarmConfigurationException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -3151279431229070297L;
|
||||
|
||||
public VirtualFireAlarmConfigurationException(int errorCode, String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public VirtualFireAlarmConfigurationException(int errorCode, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public VirtualFireAlarmConfigurationException(String msg, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
}
|
||||
|
||||
public VirtualFireAlarmConfigurationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public VirtualFireAlarmConfigurationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public VirtualFireAlarmConfigurationException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public VirtualFireAlarmConfigurationException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.iot.virtualfirealarm.plugin.internal.util;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.config.exception.VirtualFireAlarmConfigurationException;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.File;
|
||||
|
||||
public class VirtualFireAlarmUtil {
|
||||
|
||||
public static Document convertToDocument(File file) throws VirtualFireAlarmConfigurationException {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
try {
|
||||
DocumentBuilder docBuilder = factory.newDocumentBuilder();
|
||||
return docBuilder.parse(file);
|
||||
} catch (Exception e) {
|
||||
throw new VirtualFireAlarmConfigurationException("Error occurred while parsing file, while converting " +
|
||||
"to a org.w3c.dom.Document", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?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.
|
||||
-->
|
||||
<DeviceManagementConfiguration>
|
||||
<ManagementRepository>
|
||||
<DataSourceConfigurations>
|
||||
<DataSourceConfiguration>
|
||||
<JndiLookupDefinition>
|
||||
<Name>jdbc/VirtualFireAlarmDM_DB</Name>
|
||||
</JndiLookupDefinition>
|
||||
</DataSourceConfiguration>
|
||||
</DataSourceConfigurations>
|
||||
</ManagementRepository>
|
||||
<PushNotificationConfiguration>
|
||||
<Properties>
|
||||
<Property Name="url">tcp://${mqtt.broker.host}:${mqtt.broker.port}</Property>
|
||||
<Property Name="username">admin</Property>
|
||||
<Property Name="dcrUrl">https://localhost:${carbon.https.port}/dynamic-client-web/register</Property>
|
||||
<Property Name="qos">0</Property>
|
||||
<Property Name="scopes"/>
|
||||
<Property Name="clearSession">true</Property>
|
||||
</Properties>
|
||||
</PushNotificationConfiguration>
|
||||
</DeviceManagementConfiguration>
|
Loading…
Reference in new issue