forked from community/device-mgt-core
commit
3ee767f1b2
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.impl.config;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.util.MobileDeviceManagerUtil;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||
import org.wso2.carbon.utils.CarbonUtils;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Class responsible for the mobile device manager configuration initialization
|
||||
*/
|
||||
public class MobileDeviceConfigurationManager {
|
||||
|
||||
private static final String MOBILE_DEVICE_CONFIG_XML_NAME = "mobile-config.xml";
|
||||
private MobileDeviceManagementConfig currentMobileDeviceConfig;
|
||||
private static MobileDeviceConfigurationManager mobileDeviceConfigManager;
|
||||
|
||||
private final String mobileDeviceMgtConfigXMLPath =
|
||||
CarbonUtils.getCarbonConfigDirPath() + File.separator +
|
||||
MOBILE_DEVICE_CONFIG_XML_NAME;
|
||||
|
||||
public static MobileDeviceConfigurationManager getInstance() {
|
||||
if (mobileDeviceConfigManager == null) {
|
||||
synchronized (MobileDeviceConfigurationManager.class) {
|
||||
if (mobileDeviceConfigManager == null) {
|
||||
mobileDeviceConfigManager = new MobileDeviceConfigurationManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return mobileDeviceConfigManager;
|
||||
}
|
||||
|
||||
public synchronized void initConfig() throws DeviceManagementException {
|
||||
try {
|
||||
File mobileDeviceMgtConfig = new File(mobileDeviceMgtConfigXMLPath);
|
||||
Document doc = MobileDeviceManagerUtil.convertToDocument(mobileDeviceMgtConfig);
|
||||
JAXBContext mobileDeviceMgmtContext =
|
||||
JAXBContext.newInstance(MobileDeviceManagementConfig.class);
|
||||
Unmarshaller unmarshaller = mobileDeviceMgmtContext.createUnmarshaller();
|
||||
this.currentMobileDeviceConfig =
|
||||
(MobileDeviceManagementConfig) unmarshaller.unmarshal(doc);
|
||||
} catch (Exception e) {
|
||||
throw new DeviceManagementException(
|
||||
"Error occurred while initializing Mobile Device Management config", e);
|
||||
}
|
||||
}
|
||||
|
||||
public MobileDeviceManagementConfig getMobileDeviceManagementConfig() {
|
||||
return currentMobileDeviceConfig;
|
||||
}
|
||||
|
||||
public MobileDataSourceConfig getMobileDataSourceConfig() {
|
||||
return currentMobileDeviceConfig.getMobileDeviceMgtRepository().getMobileDataSourceConfig();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.mobile.impl.config;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Represents Mobile Device Mgt configuration.
|
||||
*/
|
||||
@XmlRootElement(name = "MobileDeviceMgtConfiguration")
|
||||
public final class MobileDeviceManagementConfig {
|
||||
|
||||
private MobileDeviceManagementRepository mobileDeviceMgtRepository;
|
||||
|
||||
@XmlElement(name = "ManagementRepository", nillable = false)
|
||||
public MobileDeviceManagementRepository getMobileDeviceMgtRepository() {
|
||||
return mobileDeviceMgtRepository;
|
||||
}
|
||||
|
||||
public void setMobileDeviceMgtRepository(
|
||||
MobileDeviceManagementRepository mobileDeviceMgtRepository) {
|
||||
this.mobileDeviceMgtRepository = mobileDeviceMgtRepository;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.mobile.impl.config;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Class for holding management repository data
|
||||
*/
|
||||
@XmlRootElement(name = "ManagementRepository")
|
||||
public class MobileDeviceManagementRepository {
|
||||
|
||||
private MobileDataSourceConfig mobileDataSourceConfig;
|
||||
|
||||
@XmlElement(name = "DataSourceConfiguration", nillable = false)
|
||||
public MobileDataSourceConfig getMobileDataSourceConfig() {
|
||||
return mobileDataSourceConfig;
|
||||
}
|
||||
|
||||
public void setMobileDataSourceConfig(MobileDataSourceConfig mobileDataSourceConfig) {
|
||||
this.mobileDataSourceConfig = mobileDataSourceConfig;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.impl.config.datasource;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class for hold JndiLookupDefinition of mobile-config.xml at parsing with JAXB
|
||||
*/
|
||||
@XmlRootElement(name = "JndiLookupDefinition")
|
||||
public class JNDILookupDefinition {
|
||||
|
||||
private String jndiName;
|
||||
private List<JNDIProperty> jndiProperties;
|
||||
|
||||
@XmlElement(name = "Name", nillable = false)
|
||||
public String getJndiName() {
|
||||
return jndiName;
|
||||
}
|
||||
|
||||
public void setJndiName(String jndiName) {
|
||||
this.jndiName = jndiName;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "Environment", nillable = 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,39 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.impl.config.datasource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Class for holding data source configuration in mobile-config.xml at parsing with JAXB
|
||||
*/
|
||||
@XmlRootElement(name = "DataSourceConfiguration")
|
||||
public class MobileDataSourceConfig {
|
||||
|
||||
private JNDILookupDefinition jndiLookupDefintion;
|
||||
|
||||
@XmlElement(name = "JndiLookupDefinition", nillable = true)
|
||||
public JNDILookupDefinition getJndiLookupDefintion() {
|
||||
return jndiLookupDefintion;
|
||||
}
|
||||
|
||||
public void setJndiLookupDefintion(JNDILookupDefinition jndiLookupDefintion) {
|
||||
this.jndiLookupDefintion = jndiLookupDefintion;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.mobile.impl.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.DataSourceListener;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceModelDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceVendorDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileOSVersionDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.util.MobileDeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.internal.MobileDeviceManagementBundleActivator;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
public class MobileDeviceDAOFactory implements DataSourceListener {
|
||||
|
||||
private static DataSource dataSource;
|
||||
|
||||
public MobileDeviceDAOFactory() {
|
||||
MobileDeviceManagementBundleActivator.registerDataSourceListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyObserver() {
|
||||
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource();
|
||||
}
|
||||
|
||||
public static MobileDeviceDAO getMobileDeviceDAO() {
|
||||
return new MobileDeviceDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static MobileDeviceModelDAO getMobileDeviceModelDAO() {
|
||||
return new MobileDeviceModelDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static MobileDeviceVendorDAO getMobileDeviceVendorDAO() {
|
||||
return new MobileDeviceVendorDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static MobileOSVersionDAO getMobileOSVersionDAO() {
|
||||
return new MobileOSVersionDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.impl.dao;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.JNDILookupDefinition;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceModelDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceVendorDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileOSVersionDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.util.MobileDeviceManagementDAOUtil;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Factory class used to create MobileDeviceManagement related DAO objects.
|
||||
*/
|
||||
public class MobileDeviceManagementDAOFactory {
|
||||
|
||||
private static DataSource dataSource;
|
||||
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class);
|
||||
|
||||
public static MobileDeviceDAO getMobileDeviceDAO() {
|
||||
return new MobileDeviceDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static MobileDeviceModelDAO getMobileDeviceModelDAO() {
|
||||
return new MobileDeviceModelDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static MobileDeviceVendorDAO getMobileDeviceVendorDAO() {
|
||||
return new MobileDeviceVendorDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static MobileOSVersionDAO getMobileOSVersionDAO() {
|
||||
return new MobileOSVersionDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static void init(MobileDataSourceConfig config) {
|
||||
dataSource = resolveDataSource(config);
|
||||
}
|
||||
|
||||
public static void init(DataSource dtSource) {
|
||||
dataSource = dtSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve data source from the data source definition
|
||||
*
|
||||
* @param config data source configuration
|
||||
* @return data source resolved from the data source definition
|
||||
*/
|
||||
private static DataSource resolveDataSource(MobileDataSourceConfig config) {
|
||||
DataSource dataSource = null;
|
||||
if (config == null) {
|
||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||
"is null and thus, is not initialized");
|
||||
}
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
||||
if (jndiConfig != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||
"Lookup Definition");
|
||||
}
|
||||
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
|
||||
jndiConfig.getJndiProperties();
|
||||
if (jndiPropertyList != null) {
|
||||
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
|
||||
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||
jndiProperties.put(prop.getName(), prop.getValue());
|
||||
}
|
||||
dataSource =
|
||||
MobileDeviceManagementDAOUtil
|
||||
.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
||||
} else {
|
||||
dataSource = MobileDeviceManagementDAOUtil
|
||||
.lookupDataSource(jndiConfig.getJndiName(), null);
|
||||
}
|
||||
}
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
public static DataSource getDataSource() {
|
||||
return dataSource;
|
||||
}
|
||||
}
|
14
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java → components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelDAOImpl.java
14
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java → components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelDAOImpl.java
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.impl.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||
import org.wso2.carbon.utils.CarbonUtils;
|
||||
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreator {
|
||||
|
||||
private static final Log log = LogFactory.getLog(MobileDeviceManagementSchemaInitializer.class);
|
||||
private static final String setupSQLScriptBaseLocation =
|
||||
CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator + "cdm" +
|
||||
File.separator + "plugins";
|
||||
|
||||
public MobileDeviceManagementSchemaInitializer(MobileDataSourceConfig config) {
|
||||
super(MobileDeviceManagerUtil.resolveDataSource(config));
|
||||
}
|
||||
|
||||
protected String getDbScriptLocation(String databaseType) {
|
||||
String scriptName = databaseType + ".sql";
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Loading database script from :" + scriptName);
|
||||
}
|
||||
return setupSQLScriptBaseLocation.replaceFirst("DBTYPE", databaseType) + scriptName;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.impl.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.JNDILookupDefinition;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.util.MobileDeviceManagementDAOUtil;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.File;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by harshan on 12/15/14.
|
||||
*/
|
||||
public class MobileDeviceManagerUtil {
|
||||
|
||||
private static final Log log = LogFactory.getLog(MobileDeviceManagerUtil.class);
|
||||
|
||||
public static Document convertToDocument(File file) throws DeviceManagementException {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
try {
|
||||
DocumentBuilder docBuilder = factory.newDocumentBuilder();
|
||||
return docBuilder.parse(file);
|
||||
} catch (Exception e) {
|
||||
throw new DeviceManagementException(
|
||||
"Error occurred while parsing file, while converting " +
|
||||
"to a org.w3c.dom.Document : " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve data source from the data source definition
|
||||
*
|
||||
* @param config data source configuration
|
||||
* @return data source resolved from the data source definition
|
||||
*/
|
||||
public static DataSource resolveDataSource(MobileDataSourceConfig config) {
|
||||
DataSource dataSource = null;
|
||||
if (config == null) {
|
||||
throw new RuntimeException(
|
||||
"Mobile Device Management Repository data source configuration " +
|
||||
"is null and thus, is not initialized");
|
||||
}
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
||||
if (jndiConfig != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(
|
||||
"Initializing Mobile Device Management Repository data source using the JNDI " +
|
||||
"Lookup Definition");
|
||||
}
|
||||
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
|
||||
jndiConfig.getJndiProperties();
|
||||
if (jndiPropertyList != null) {
|
||||
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
|
||||
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||
jndiProperties.put(prop.getName(), prop.getValue());
|
||||
}
|
||||
dataSource =
|
||||
MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(),
|
||||
jndiProperties);
|
||||
} else {
|
||||
dataSource = MobileDeviceManagementDAOUtil
|
||||
.lookupDataSource(jndiConfig.getJndiName(), null);
|
||||
}
|
||||
}
|
||||
return dataSource;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.policy.mgt.core.config;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||
import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig;
|
||||
import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants;
|
||||
import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil;
|
||||
import org.wso2.carbon.utils.CarbonUtils;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Class responsible for the rss manager configuration initialization
|
||||
*/
|
||||
public class PolicyConfigurationManager {
|
||||
|
||||
private PolicyManagementConfig currentPolicyConfig;
|
||||
private static PolicyConfigurationManager policyConfigurationManager;
|
||||
|
||||
private final String deviceMgtConfigXMLPath = CarbonUtils.getCarbonConfigDirPath() + File.separator +
|
||||
PolicyManagementConstants.DEVICE_CONFIG_XML_NAME;
|
||||
|
||||
public static PolicyConfigurationManager getInstance() {
|
||||
if (policyConfigurationManager == null) {
|
||||
synchronized (PolicyConfigurationManager.class) {
|
||||
if (policyConfigurationManager == null) {
|
||||
policyConfigurationManager = new PolicyConfigurationManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return policyConfigurationManager;
|
||||
}
|
||||
|
||||
public synchronized void initConfig() throws PolicyManagementException {
|
||||
try {
|
||||
File deviceMgtConfig = new File(deviceMgtConfigXMLPath);
|
||||
Document doc = PolicyManagerUtil.convertToDocument(deviceMgtConfig);
|
||||
|
||||
/* Un-marshaling Device Management configuration */
|
||||
JAXBContext rssContext = JAXBContext.newInstance(PolicyManagementConfig.class);
|
||||
Unmarshaller unmarshaller = rssContext.createUnmarshaller();
|
||||
this.currentPolicyConfig = (PolicyManagementConfig) unmarshaller.unmarshal(doc);
|
||||
} catch (Exception e) {
|
||||
throw new PolicyManagementException("Error occurred while initializing RSS config", e);
|
||||
}
|
||||
}
|
||||
|
||||
public PolicyManagementConfig getDeviceManagementConfig() {
|
||||
return currentPolicyConfig;
|
||||
}
|
||||
|
||||
public DataSourceConfig getDataSourceConfig() {
|
||||
return currentPolicyConfig.getPolicyManagementRepository().getDataSourceConfig();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.policy.mgt.core.config;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Represents Device Mgt configuration.
|
||||
*/
|
||||
@XmlRootElement(name = "DeviceMgtConfiguration")
|
||||
public final class PolicyManagementConfig {
|
||||
|
||||
private PolicyManagementRepository policyManagementRepository;
|
||||
|
||||
@XmlElement(name = "ManagementRepository", nillable = false)
|
||||
public PolicyManagementRepository getPolicyManagementRepository() {
|
||||
return policyManagementRepository;
|
||||
}
|
||||
|
||||
public void setPolicyMgtRepository(PolicyManagementRepository policyManagementRepository) {
|
||||
this.policyManagementRepository = policyManagementRepository;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.policy.mgt.core.config;
|
||||
|
||||
import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Class for holding management repository data
|
||||
*/
|
||||
@XmlRootElement(name = "ManagementRepository")
|
||||
public class PolicyManagementRepository {
|
||||
|
||||
private DataSourceConfig dataSourceConfig;
|
||||
|
||||
@XmlElement(name = "DataSourceConfiguration", nillable = false)
|
||||
public DataSourceConfig getDataSourceConfig() {
|
||||
return dataSourceConfig;
|
||||
}
|
||||
|
||||
public void setDataSourceConfig(DataSourceConfig dataSourceConfig) {
|
||||
this.dataSourceConfig = dataSourceConfig;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.wso2.carbon.policy.mgt.core.internal;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
import org.wso2.carbon.policy.mgt.core.config.PolicyConfigurationManager;
|
||||
import org.wso2.carbon.policy.mgt.core.config.PolicyManagementConfig;
|
||||
import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig;
|
||||
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
|
||||
import org.wso2.carbon.user.core.service.RealmService;
|
||||
|
||||
/**
|
||||
* @scr.component name="org.wso2.carbon.policy.manager" immediate="true"
|
||||
* @scr.reference name="user.realmservice.default"
|
||||
* interface="org.wso2.carbon.user.core.service.RealmService"
|
||||
* cardinality="1..1"
|
||||
* policy="dynamic"
|
||||
* bind="setRealmService"
|
||||
* unbind="unsetRealmService"
|
||||
*/
|
||||
|
||||
public class PolicyManagementServiceComponent {
|
||||
|
||||
private static Log log = LogFactory.getLog(PolicyManagementServiceComponent.class);
|
||||
|
||||
protected void activate(ComponentContext componentContext) {
|
||||
|
||||
try {
|
||||
|
||||
PolicyConfigurationManager.getInstance().initConfig();
|
||||
|
||||
PolicyManagementConfig config = PolicyConfigurationManager.getInstance().getDeviceManagementConfig();
|
||||
|
||||
DataSourceConfig dsConfig = config.getPolicyManagementRepository().getDataSourceConfig();
|
||||
PolicyManagementDAOFactory.init(dsConfig);
|
||||
|
||||
|
||||
} catch (Throwable t) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets Realm Service
|
||||
*
|
||||
* @param realmService An instance of RealmService
|
||||
*/
|
||||
protected void setRealmService(RealmService realmService) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Setting Realm Service");
|
||||
}
|
||||
PolicyManagementDataHolder.getInstance().setRealmService(realmService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets Realm Service
|
||||
*
|
||||
* @param realmService An instance of RealmService
|
||||
*/
|
||||
protected void unsetRealmService(RealmService realmService) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Unsetting Realm Service");
|
||||
}
|
||||
PolicyManagementDataHolder.getInstance().setRealmService(null);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.policy.mgt.core.util;
|
||||
|
||||
public final class PolicyManagementConstants {
|
||||
|
||||
public static final String DEVICE_CONFIG_XML_NAME = "cdm-config.xml";
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.policy.mgt.core.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||
import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig;
|
||||
import org.wso2.carbon.policy.mgt.core.config.datasource.JNDILookupDefinition;
|
||||
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.File;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
public class PolicyManagerUtil {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PolicyManagerUtil.class);
|
||||
|
||||
public static Document convertToDocument(File file) throws PolicyManagementException {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
try {
|
||||
DocumentBuilder docBuilder = factory.newDocumentBuilder();
|
||||
return docBuilder.parse(file);
|
||||
} catch (Exception e) {
|
||||
throw new PolicyManagementException("Error occurred while parsing file, while converting " +
|
||||
"to a org.w3c.dom.Document : " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve data source from the data source definition
|
||||
*
|
||||
* @param config data source configuration
|
||||
* @return data source resolved from the data source definition
|
||||
*/
|
||||
public static DataSource resolveDataSource(DataSourceConfig config) {
|
||||
DataSource dataSource = null;
|
||||
if (config == null) {
|
||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||
"is null and thus, is not initialized");
|
||||
}
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
||||
if (jndiConfig != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||
"Lookup Definition");
|
||||
}
|
||||
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
|
||||
jndiConfig.getJndiProperties();
|
||||
if (jndiPropertyList != null) {
|
||||
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
|
||||
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||
jndiProperties.put(prop.getName(), prop.getValue());
|
||||
}
|
||||
dataSource =
|
||||
PolicyManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
||||
} else {
|
||||
dataSource = PolicyManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null);
|
||||
}
|
||||
}
|
||||
return dataSource;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<MobileDeviceMgtConfiguration>
|
||||
<ManagementRepository>
|
||||
<DataSourceConfiguration>
|
||||
<JndiLookupDefinition>
|
||||
<Name>jdbc/WSO2MOBILE_DB</Name>
|
||||
</JndiLookupDefinition>
|
||||
</DataSourceConfiguration>
|
||||
</ManagementRepository>
|
||||
</MobileDeviceMgtConfiguration>
|
@ -0,0 +1,2 @@
|
||||
instructions.configure = \
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/conf/mobile-config.xml,target:${installFolder}/../../conf/mobile-config.xml,overwrite:true);\
|
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>policy-mgt-feature</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.server.feature</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<name>WSO2 Carbon - Policy Management Server Feature</name>
|
||||
<url>http://wso2.org</url>
|
||||
<description>This feature contains the core bundles required for Back-end Devvice Management functionality
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.equinox</groupId>
|
||||
<artifactId>org.eclipse.equinox.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>src/main/resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>resources</directory>
|
||||
<includes>
|
||||
<include>build.properties</include>
|
||||
<include>p2.inf</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.wso2.maven</groupId>
|
||||
<artifactId>carbon-p2-plugin</artifactId>
|
||||
<version>${carbon.p2.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>p2-feature-generation</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>p2-feature-gen</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<id>org.wso2.carbon.policy.mgt.server</id>
|
||||
<propertiesFile>../../../features/etc/feature.properties</propertiesFile>
|
||||
<adviceFile>
|
||||
<properties>
|
||||
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
|
||||
<propertyDef>org.eclipse.equinox.p2.type.group:false</propertyDef>
|
||||
</properties>
|
||||
</adviceFile>
|
||||
<bundles>
|
||||
<bundleDef>org.wso2.carbon:org.wso2.carbon.policy.mgt.core:${project.version}
|
||||
</bundleDef>
|
||||
<bundleDef>org.wso2.carbon:org.wso2.carbon.policy.mgt.common:${project.version}
|
||||
</bundleDef>
|
||||
</bundles>
|
||||
<importFeatures>
|
||||
<importFeatureDef>org.wso2.carbon.core.server:${carbon.platform.version}
|
||||
</importFeatureDef>
|
||||
</importFeatures>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1 @@
|
||||
custom = true
|
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<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>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>wso2cdm-parent</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>policy-mgt-feature</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WSO2 Carbon - Policy Management Feature</name>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<modules>
|
||||
<module>org.wso2.carbon.policy.mgt.server.feature</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
@ -0,0 +1,38 @@
|
||||
CREATE TABLE IF NOT EXISTS MBL_OS_VERSION
|
||||
(
|
||||
VERSION_ID INT NOT NULL AUTO_INCREMENT,
|
||||
NAME VARCHAR(45) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (VERSION_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS MBL_DEVICE_MODEL
|
||||
(
|
||||
MODEL_ID INT NOT NULL AUTO_INCREMENT,
|
||||
MODEL VARCHAR(45) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (MODEL_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS MBL_VENDOR
|
||||
(
|
||||
VENDOR_ID INT NOT NULL AUTO_INCREMENT,
|
||||
VENDOR VARCHAR(45) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (VENDOR_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS MBL_DEVICE
|
||||
(
|
||||
MOBILE_DEVICE_ID VARCHAR(45) NOT NULL,
|
||||
REG_ID VARCHAR(45) NOT NULL,
|
||||
IMEI VARCHAR(45) NOT NULL,
|
||||
IMSI VARCHAR(45) NOT NULL,
|
||||
OS_VERSION_ID INT NOT NULL,
|
||||
DEVICE_MODEL_ID INT NOT NULL,
|
||||
VENDOR_ID INT NOT NULL,
|
||||
PRIMARY KEY (MOBILE_DEVICE_ID),
|
||||
CONSTRAINT fk_DEVICE_OS_VERSION1 FOREIGN KEY (OS_VERSION_ID )
|
||||
REFERENCES MBL_OS_VERSION (VERSION_ID ) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT fk_DEVICE_DEVICE_MODEL2 FOREIGN KEY (DEVICE_MODEL_ID )
|
||||
REFERENCES MBL_DEVICE_MODEL (MODEL_ID ) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT fk_DEVICE_VENDOR1 FOREIGN KEY (VENDOR_ID )
|
||||
REFERENCES MBL_VENDOR (VENDOR_ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
@ -0,0 +1,63 @@
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_OS_VERSION`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_OS_VERSION` (
|
||||
`VERSION_ID` INT NOT NULL AUTO_INCREMENT,
|
||||
`VERSION` VARCHAR(45) NULL,
|
||||
PRIMARY KEY (`VERSION_ID`))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_DEVICE_MODEL`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_MODEL` (
|
||||
`MODEL_ID` INT NOT NULL AUTO_INCREMENT,
|
||||
`MODEL` VARCHAR(45) NULL,
|
||||
PRIMARY KEY (`MODEL_ID`))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_VENDOR`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_VENDOR` (
|
||||
`VENDOR_ID` INT NOT NULL AUTO_INCREMENT,
|
||||
`VENDOR` VARCHAR(45) NULL,
|
||||
PRIMARY KEY (`VENDOR_ID`))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_DEVICE`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
|
||||
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL,
|
||||
`REG_ID` VARCHAR(45) NULL,
|
||||
`IMEI` VARCHAR(45) NULL,
|
||||
`IMSI` VARCHAR(45) NULL,
|
||||
`OS_VERSION_ID` INT NOT NULL,
|
||||
`DEVICE_MODEL_ID` INT NOT NULL,
|
||||
`VENDOR_ID` INT NOT NULL,
|
||||
PRIMARY KEY (`MOBILE_DEVICE_ID`),
|
||||
INDEX `fk_DEVICE_OS_VERSION1_idx` (`OS_VERSION_ID` ASC),
|
||||
INDEX `fk_DEVICE_DEVICE_MODEL2_idx` (`DEVICE_MODEL_ID` ASC),
|
||||
INDEX `fk_DEVICE_VENDOR1_idx` (`VENDOR_ID` ASC),
|
||||
CONSTRAINT `fk_DEVICE_OS_VERSION1`
|
||||
FOREIGN KEY (`OS_VERSION_ID`)
|
||||
REFERENCES `MBL_OS_VERSION` (`VERSION_ID`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_DEVICE_DEVICE_MODEL2`
|
||||
FOREIGN KEY (`DEVICE_MODEL_ID`)
|
||||
REFERENCES `MBL_DEVICE_MODEL` (`MODEL_ID`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_DEVICE_VENDOR1`
|
||||
FOREIGN KEY (`VENDOR_ID`)
|
||||
REFERENCES `MBL_VENDOR` (`VENDOR_ID`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
Loading…
Reference in new issue