forked from community/device-mgt-plugins
parent
e4d6070bee
commit
ad10426c11
@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.dto.MobileDeviceModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class represents the key operations associated with persisting mobile-device model related
|
|
||||||
* information.
|
|
||||||
*/
|
|
||||||
public interface MobileDeviceModelDAO {
|
|
||||||
|
|
||||||
MobileDeviceModel getDeviceModel(String modelId) throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
void addDeviceModel(MobileDeviceModel deviceModel) throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
void updateDeviceModel(MobileDeviceModel deviceModel) throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
void deleteDeviceModel(String modelId) throws MobileDeviceManagementDAOException;
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.dto.MobileDeviceVendor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class represents the key operations associated with persisting mobile-device vendor
|
|
||||||
* related information.
|
|
||||||
*/
|
|
||||||
public interface MobileDeviceVendorDAO {
|
|
||||||
|
|
||||||
MobileDeviceVendor getDeviceModel(String vendorId) throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
void addDeviceVendor(MobileDeviceVendor deviceVendor) throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
void updateDeviceVendor(MobileDeviceVendor deviceVendor)
|
|
||||||
throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
void deleteDeviceVendor(String vendorId) throws MobileDeviceManagementDAOException;
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.dto.MobileOSVersion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class represents the key operations associated with persisting mobile-device OS version
|
|
||||||
* related information.
|
|
||||||
*/
|
|
||||||
public interface MobileOSVersionDAO {
|
|
||||||
|
|
||||||
MobileOSVersion getMobileOSVersion(String versionId) throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
void addMobileOSVersion(MobileOSVersion osVersion) throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
void updateMobileOSVersion(MobileOSVersion osVersion) throws MobileDeviceManagementDAOException;
|
|
||||||
|
|
||||||
void deleteMobileOSVersion(String versionId) throws MobileDeviceManagementDAOException;
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceModelDAO;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceModel;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of MobileDeviceModel.
|
|
||||||
*/
|
|
||||||
public class MobileDeviceModelDAOImpl implements MobileDeviceModelDAO {
|
|
||||||
|
|
||||||
private DataSource dataSource;
|
|
||||||
private static final Log log = LogFactory.getLog(MobileDeviceModelDAOImpl.class);
|
|
||||||
|
|
||||||
public MobileDeviceModelDAOImpl(DataSource dataSource) {
|
|
||||||
this.dataSource = dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MobileDeviceModel getDeviceModel(String modelId)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addDeviceModel(MobileDeviceModel deviceModel)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateDeviceModel(MobileDeviceModel deviceModel)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteDeviceModel(String modelId)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceVendorDAO;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceVendor;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of MobileDeviceVendorDAO.
|
|
||||||
*/
|
|
||||||
public class MobileDeviceVendorDAOImpl implements MobileDeviceVendorDAO {
|
|
||||||
|
|
||||||
private DataSource dataSource;
|
|
||||||
private static final Log log = LogFactory.getLog(MobileDeviceVendorDAOImpl.class);
|
|
||||||
|
|
||||||
public MobileDeviceVendorDAOImpl(DataSource dataSource) {
|
|
||||||
this.dataSource = dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MobileDeviceVendor getDeviceModel(String vendorId)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addDeviceVendor(MobileDeviceVendor deviceVendor)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateDeviceVendor(MobileDeviceVendor deviceVendor)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteDeviceVendor(String vendorId)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileOSVersionDAO;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileOSVersion;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of MobileOSVersionDAO.
|
|
||||||
*/
|
|
||||||
public class MobileOSVersionDAOImpl implements MobileOSVersionDAO {
|
|
||||||
|
|
||||||
private DataSource dataSource;
|
|
||||||
private static final Log log = LogFactory.getLog(MobileOSVersionDAOImpl.class);
|
|
||||||
|
|
||||||
public MobileOSVersionDAOImpl(DataSource dataSource) {
|
|
||||||
this.dataSource = dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public MobileOSVersion getMobileOSVersion(String versionId)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void addMobileOSVersion(MobileOSVersion osVersion)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void updateMobileOSVersion(MobileOSVersion osVersion)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void deleteMobileOSVersion(String versionId)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.dto;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DTO of MobileDeviceModel.
|
|
||||||
*/
|
|
||||||
public class MobileDeviceModel implements Serializable {
|
|
||||||
|
|
||||||
private int modelId;
|
|
||||||
private String model;
|
|
||||||
|
|
||||||
public int getModelId() {
|
|
||||||
return modelId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModelId(int modelId) {
|
|
||||||
this.modelId = modelId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModel() {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModel(String model) {
|
|
||||||
this.model = model;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.dto;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DTO of MobileVendor.
|
|
||||||
*/
|
|
||||||
public class MobileDeviceVendor implements Serializable {
|
|
||||||
|
|
||||||
private int vendorId;
|
|
||||||
private String vendor;
|
|
||||||
|
|
||||||
public int getVendorId() {
|
|
||||||
return vendorId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVendorId(int vendorId) {
|
|
||||||
this.vendorId = vendorId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVendor() {
|
|
||||||
return vendor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVendor(String vendor) {
|
|
||||||
this.vendor = vendor;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.dto;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DTO of MobileOSVersion.
|
|
||||||
*/
|
|
||||||
public class MobileOSVersion implements Serializable {
|
|
||||||
|
|
||||||
private int osVersionId;
|
|
||||||
private String osVersion;
|
|
||||||
|
|
||||||
public int getOsVersionId() {
|
|
||||||
return osVersionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOsVersionId(int osVersionId) {
|
|
||||||
this.osVersionId = osVersionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOsVersion() {
|
|
||||||
return osVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOsVersion(String osVersion) {
|
|
||||||
this.osVersion = osVersion;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
* 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.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides utility methods required by the mobile device management bundle.
|
||||||
|
*/
|
||||||
|
public class MobileDeviceManagementUtil {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(MobileDeviceManagementUtil.class);
|
||||||
|
private static final String MOBILE_DEVICE_IMEI = "imei";
|
||||||
|
private static final String MOBILE_DEVICE_IMSI = "imsi";
|
||||||
|
private static final String MOBILE_DEVICE_REG_ID = "regId";
|
||||||
|
private static final String MOBILE_DEVICE_VENDOR = "vendor";
|
||||||
|
private static final String MOBILE_DEVICE_OS_VERSION = "osVersion";
|
||||||
|
private static final String MOBILE_DEVICE_MODEL = "model";
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getPropertyValue(Device device, String property) {
|
||||||
|
for (Device.Property prop : device.getProperties()) {
|
||||||
|
if (property.equals(prop.getName())) {
|
||||||
|
return prop.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Device.Property getProperty(String property, String value) {
|
||||||
|
Device.Property prop = null;
|
||||||
|
if(property != null){
|
||||||
|
prop = new Device.Property();
|
||||||
|
prop.setName(property);
|
||||||
|
prop.setValue(value);
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MobileDevice convertToMobileDevice(Device device) {
|
||||||
|
MobileDevice mobileDevice = null;
|
||||||
|
if (device != null) {
|
||||||
|
mobileDevice = new MobileDevice();
|
||||||
|
mobileDevice.setMobileDeviceId(device.getDeviceIdentifier());
|
||||||
|
mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI));
|
||||||
|
mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI));
|
||||||
|
mobileDevice.setRegId(getPropertyValue(device, MOBILE_DEVICE_REG_ID));
|
||||||
|
mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL));
|
||||||
|
mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION));
|
||||||
|
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
|
||||||
|
}
|
||||||
|
return mobileDevice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Device convertToDevice(MobileDevice mobileDevice) {
|
||||||
|
Device device = null;
|
||||||
|
if(mobileDevice!=null){
|
||||||
|
device = new Device();
|
||||||
|
List<Device.Property> propertyList = new ArrayList<Device.Property>();
|
||||||
|
propertyList.add(getProperty(MOBILE_DEVICE_IMEI,mobileDevice.getImei()));
|
||||||
|
propertyList.add(getProperty(MOBILE_DEVICE_IMSI,mobileDevice.getImsi()));
|
||||||
|
propertyList.add(getProperty(MOBILE_DEVICE_REG_ID,mobileDevice.getRegId()));
|
||||||
|
propertyList.add(getProperty(MOBILE_DEVICE_MODEL,mobileDevice.getModel()));
|
||||||
|
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION,mobileDevice.getOsVersion()));
|
||||||
|
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR,mobileDevice.getVendor()));
|
||||||
|
device.setProperties(propertyList);
|
||||||
|
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
|
||||||
|
}
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
}
|
@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +1,11 @@
|
|||||||
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
|
CREATE TABLE IF NOT EXISTS MBL_DEVICE
|
||||||
(
|
(
|
||||||
MOBILE_DEVICE_ID VARCHAR(45) NOT NULL,
|
MOBILE_DEVICE_ID VARCHAR(45) NOT NULL,
|
||||||
REG_ID VARCHAR(45) NOT NULL,
|
REG_ID VARCHAR(45) NOT NULL,
|
||||||
IMEI VARCHAR(45) NOT NULL,
|
IMEI VARCHAR(45) NOT NULL,
|
||||||
IMSI VARCHAR(45) NOT NULL,
|
IMSI VARCHAR(45) NOT NULL,
|
||||||
OS_VERSION_ID INT NOT NULL,
|
OS_VERSION VARCHAR(45) NOT NULL,
|
||||||
DEVICE_MODEL_ID INT NOT NULL,
|
DEVICE_MODEL VARCHAR(45) NOT NULL,
|
||||||
VENDOR_ID INT NOT NULL,
|
VENDOR VARCHAR(45) NOT NULL,
|
||||||
PRIMARY KEY (MOBILE_DEVICE_ID),
|
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
|
|
||||||
);
|
);
|
Loading…
Reference in new issue