forked from community/device-mgt-plugins
Merge branch 'master' of https://github.com/geethkokila/product-cdm
commit
f340855916
@ -1,33 +1,60 @@
|
||||
/**
|
||||
* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
/*
|
||||
* Copyright (c) 2015, 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
|
||||
* 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.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.common;
|
||||
|
||||
/**
|
||||
* This class needs to be implemented by all
|
||||
*/
|
||||
public interface Operation {
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Properties;
|
||||
|
||||
@XmlRootElement
|
||||
public class Operation {
|
||||
|
||||
public enum Type {
|
||||
CONFIG, MESSAGE, INFO
|
||||
}
|
||||
|
||||
private String code;
|
||||
private Properties properties;
|
||||
private Type type;
|
||||
|
||||
@XmlElement
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Properties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes any start-up resources required to execute a particular operation
|
||||
*/
|
||||
void init();
|
||||
public void setProperties(Properties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the functionality configured within the method implementation
|
||||
*/
|
||||
void execute();
|
||||
@XmlElement
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -1,75 +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.common;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class OperationData {
|
||||
|
||||
public enum Type {
|
||||
CONFIG, MESSAGE, STATE
|
||||
}
|
||||
|
||||
private String name;
|
||||
private boolean state;
|
||||
private Properties properties;
|
||||
private String text;
|
||||
private Type type;
|
||||
|
||||
public OperationData(String name, Type type) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public OperationData(String name, boolean state) {
|
||||
this.name = name;
|
||||
this.type = Type.STATE;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public OperationData(String name, Properties properties) {
|
||||
this.name = name;
|
||||
this.type = Type.CONFIG;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public OperationData(String name, String text) {
|
||||
this.name = name;
|
||||
this.type = Type.MESSAGE;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public Properties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2012, 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.common;
|
||||
|
||||
public class OperationFactory {
|
||||
|
||||
public static Operation getOperation(String type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
*
|
||||
* * 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.core;
|
||||
|
||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||
|
||||
public class LicenseManager {
|
||||
|
||||
/* public void addLicense(DeviceType deviceType,String langCode, String
|
||||
);*/
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
/**
|
||||
* Copyright (c) 2015, 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.core;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.validation.Schema;
|
||||
import javax.xml.validation.SchemaFactory;
|
||||
import java.io.File;
|
||||
|
||||
public class DeviceManagementConfigTests {
|
||||
|
||||
private static final Log log = LogFactory.getLog(DeviceManagementConfigTests.class);
|
||||
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY =
|
||||
"./src/test/resources/config/malformed-cdm-config-no-mgt-repo.xml";
|
||||
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG =
|
||||
"./src/test/resources/config/malformed-cdm-config-no-ds-config.xml";
|
||||
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG =
|
||||
"./src/test/resources/config/malformed-cdm-config-no-jndi-config.xml";
|
||||
private static final String TEST_CONFIG_SCHEMA_LOCATION =
|
||||
"./src/test/resources/config/schema/DeviceManagementConfigSchema.xsd";
|
||||
|
||||
private Schema schema;
|
||||
|
||||
@BeforeClass
|
||||
private void initSchema() {
|
||||
File deviceManagementSchemaConfig = new File(DeviceManagementConfigTests.TEST_CONFIG_SCHEMA_LOCATION);
|
||||
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
try {
|
||||
schema = factory.newSchema(deviceManagementSchemaConfig);
|
||||
} catch (SAXException e) {
|
||||
Assert.fail("Invalid schema found", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test()
|
||||
public void testMandateManagementRepositoryElement() {
|
||||
File malformedConfig =
|
||||
new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY);
|
||||
this.validateMalformedConfig(malformedConfig);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMandateDataSourceConfigurationElement() {
|
||||
File malformedConfig = new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG);
|
||||
this.validateMalformedConfig(malformedConfig);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMandateJndiLookupDefinitionElement() {
|
||||
File malformedConfig = new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG);
|
||||
this.validateMalformedConfig(malformedConfig);
|
||||
}
|
||||
|
||||
private void validateMalformedConfig(File malformedConfig) {
|
||||
try {
|
||||
JAXBContext ctx = JAXBContext.newInstance(DeviceManagementConfig.class);
|
||||
Unmarshaller um = ctx.createUnmarshaller();
|
||||
um.setSchema(this.getSchema());
|
||||
um.unmarshal(malformedConfig);
|
||||
Assert.assertTrue(false);
|
||||
} catch (JAXBException e) {
|
||||
log.error("Error occurred while unmarsharlling device management config", e);
|
||||
Assert.assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
private Schema getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright (c) 2015, 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.core;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
||||
|
||||
public class DeviceManagementRepositoryTests {
|
||||
|
||||
private DeviceManagementRepository repository;
|
||||
|
||||
@BeforeClass
|
||||
public void initRepository() {
|
||||
this.repository = new DeviceManagementRepository();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddDeviceManagementService() {
|
||||
DeviceManagerService sourceProvider = new TestDeviceManagerService();
|
||||
this.getRepository().addDeviceManagementProvider(sourceProvider);
|
||||
|
||||
DeviceManagerService targetProvider =
|
||||
this.getRepository().getDeviceManagementProvider(TestDeviceManagerService.DEVICE_TYPE_TEST);
|
||||
|
||||
Assert.assertEquals(targetProvider.getProviderType(), sourceProvider.getProviderType());
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testAddDeviceManagementService")
|
||||
public void testRemoveDeviceManagementService() {
|
||||
DeviceManagerService sourceProvider = new TestDeviceManagerService();
|
||||
this.getRepository().removeDeviceManagementProvider(sourceProvider);
|
||||
|
||||
DeviceManagerService targetProvider =
|
||||
this.getRepository().getDeviceManagementProvider(TestDeviceManagerService.DEVICE_TYPE_TEST);
|
||||
|
||||
Assert.assertNull(targetProvider);
|
||||
}
|
||||
|
||||
private DeviceManagementRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Copyright (c) 2012, 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.core;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.OperationManager;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TestDeviceManagerService implements DeviceManagerService {
|
||||
|
||||
public static final String DEVICE_TYPE_TEST = "Test";
|
||||
|
||||
@Override
|
||||
public String getProviderType() {
|
||||
return TestDeviceManagerService.DEVICE_TYPE_TEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getAllDevices() throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationManager getOperationManager() throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) 2012, 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.core;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class TestUtils {
|
||||
|
||||
private static final Log log = LogFactory.getLog(TestUtils.class);
|
||||
|
||||
public static void cleanupResources(Connection conn, Statement stmt, ResultSet rs) {
|
||||
if (rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
log.warn("Error occurred while closing result set", e);
|
||||
}
|
||||
}
|
||||
if (stmt != null) {
|
||||
try {
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
log.warn("Error occurred while closing prepared statement", e);
|
||||
}
|
||||
}
|
||||
if (conn != null) {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
log.warn("Error occurred while closing database connection", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<DeviceMgtConfiguration>
|
||||
<ManagementRepository>
|
||||
<MalformedDataSourceConfiguration>
|
||||
<JndiLookupDefinition>
|
||||
<Name>jdbc/DEVICE_MGT_DS</Name>
|
||||
</JndiLookupDefinition>
|
||||
</MalformedDataSourceConfiguration>
|
||||
</ManagementRepository>
|
||||
</DeviceMgtConfiguration>
|
||||
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<DeviceMgtConfiguration>
|
||||
<ManagementRepository>
|
||||
<DataSourceConfiguration>
|
||||
<MalformedJndiLookupDefinition>
|
||||
<Name>jdbc/DEVICE_MGT_DS</Name>
|
||||
</MalformedJndiLookupDefinition>
|
||||
</DataSourceConfiguration>
|
||||
</ManagementRepository>
|
||||
</DeviceMgtConfiguration>
|
||||
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<DeviceMgtConfiguration>
|
||||
<MalformedManagementRepository>
|
||||
<DataSourceConfiguration>
|
||||
<JndiLookupDefinition>
|
||||
<Name>jdbc/DEVICE_MGT_DS</Name>
|
||||
</JndiLookupDefinition>
|
||||
</DataSourceConfiguration>
|
||||
</MalformedManagementRepository>
|
||||
</DeviceMgtConfiguration>
|
||||
|
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
~ 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.
|
||||
-->
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified">
|
||||
<xs:element name="DeviceMgtConfiguration">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="ManagementRepository" minOccurs="1" maxOccurs="1" type="DataSourceConfigurationType"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:complexType name="JndiLookupDefinitionType">
|
||||
<xs:sequence>
|
||||
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="DataSourceConfigurationType">
|
||||
<xs:sequence>
|
||||
<xs:element name="JndiLookupDefinition" minOccurs="1" maxOccurs="1"
|
||||
type="JndiLookupDefinitionType"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="ManagementRepositoryType">
|
||||
<xs:sequence>
|
||||
<xs:element name="DataSourceConfiguration" minOccurs="1" maxOccurs="1"
|
||||
type="DataSourceConfigurationType"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
@ -1,24 +1,36 @@
|
||||
/**
|
||||
* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
/*
|
||||
* Copyright (c) 2014 - 2015, 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
|
||||
* 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.
|
||||
* 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;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.OperationManager;
|
||||
import org.wso2.carbon.device.mgt.common.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractMobileOperationManager implements OperationManager {
|
||||
|
||||
@Override
|
||||
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addOperation(Operation operation,
|
||||
List<DeviceIdentifier> devices) throws OperationManagementException {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
/**
|
||||
* Copyright (c) 2015, 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.internal;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceRegistration;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
import org.wso2.carbon.apimgt.api.APIManagementException;
|
||||
import org.wso2.carbon.apimgt.api.APIProvider;
|
||||
import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService;
|
||||
import org.wso2.carbon.apimgt.impl.APIManagerFactory;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
||||
import org.wso2.carbon.device.mgt.mobile.config.APIConfig;
|
||||
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager;
|
||||
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig;
|
||||
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService;
|
||||
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService;
|
||||
import org.wso2.carbon.device.mgt.mobile.util.DeviceManagementAPIPublisherUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @scr.component name="org.wso2.carbon.device.mgt.mobile.impl.internal.MobileDeviceManagementServiceComponent"
|
||||
* immediate="true"
|
||||
* @scr.reference name="api.manager.config.service"
|
||||
* interface="org.wso2.carbon.apimgt.impl.APIManagerConfigurationService"
|
||||
* cardinality="1..1"
|
||||
* policy="dynamic"
|
||||
* bind="setAPIManagerConfigurationService"
|
||||
* unbind="unsetAPIManagerConfigurationService"
|
||||
* <p/>
|
||||
* Adding reference to API Manager Configuration service is an unavoidable hack to get rid of NPEs thrown while
|
||||
* initializing APIMgtDAOs attempting to register APIs programmatically. APIMgtDAO needs to be proper cleaned up
|
||||
* to avoid as an ideal fix
|
||||
*/
|
||||
public class MobileDeviceManagementServiceComponent {
|
||||
|
||||
private ServiceRegistration androidServiceRegRef;
|
||||
private ServiceRegistration iOSServiceRegRef;
|
||||
private ServiceRegistration windowsServiceRegRef;
|
||||
|
||||
private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class);
|
||||
|
||||
protected void activate(ComponentContext ctx) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Activating Mobile Device Management Service Component");
|
||||
}
|
||||
try {
|
||||
BundleContext bundleContext = ctx.getBundleContext();
|
||||
|
||||
/* Initialize the datasource configuration */
|
||||
MobileDeviceConfigurationManager.getInstance().initConfig();
|
||||
MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance()
|
||||
.getMobileDeviceManagementConfig();
|
||||
MobileDataSourceConfig dsConfig =
|
||||
config.getMobileDeviceMgtRepository().getMobileDataSourceConfig();
|
||||
|
||||
MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig);
|
||||
|
||||
androidServiceRegRef =
|
||||
bundleContext.registerService(DeviceManagerService.class.getName(),
|
||||
new AndroidDeviceManagerService(), null);
|
||||
iOSServiceRegRef =
|
||||
bundleContext.registerService(DeviceManagerService.class.getName(),
|
||||
new IOSDeviceManagerService(), null);
|
||||
windowsServiceRegRef =
|
||||
bundleContext.registerService(DeviceManagerService.class.getName(),
|
||||
new WindowsDeviceManagerService(), null);
|
||||
|
||||
/* Initialize all API configurations with corresponding API Providers */
|
||||
this.initAPIConfigs();
|
||||
/* Publish all mobile device management related JAX-RS services as APIs */
|
||||
this.publishAPIs();
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Mobile Device Management Service Component has been successfully activated");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error("Error occurred while activating Mobile Device Management Service Component", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void deactivate(ComponentContext ctx) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("De-activating Mobile Device Management Service Component");
|
||||
}
|
||||
try {
|
||||
BundleContext bundleContext = ctx.getBundleContext();
|
||||
|
||||
androidServiceRegRef.unregister();
|
||||
iOSServiceRegRef.unregister();
|
||||
windowsServiceRegRef.unregister();
|
||||
|
||||
/* Removing all APIs published upon start-up for mobile device management related JAX-RS
|
||||
services */
|
||||
this.removeAPIs();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Mobile Device Management Service Component has been successfully de-activated");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error("Error occurred while de-activating Mobile Device Management bundle", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initAPIConfigs() throws DeviceManagementException {
|
||||
List<APIConfig> apiConfigs =
|
||||
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
||||
getApiPublisherConfig().getAPIs();
|
||||
for (APIConfig apiConfig : apiConfigs) {
|
||||
try {
|
||||
APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner());
|
||||
apiConfig.init(provider);
|
||||
} catch (APIManagementException e) {
|
||||
throw new DeviceManagementException("Error occurred while initializing API Config '" +
|
||||
apiConfig.getName() + "'", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void publishAPIs() throws DeviceManagementException {
|
||||
List<APIConfig> apiConfigs =
|
||||
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
||||
getApiPublisherConfig().getAPIs();
|
||||
for (APIConfig apiConfig : apiConfigs) {
|
||||
DeviceManagementAPIPublisherUtil.publishAPI(apiConfig);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeAPIs() throws DeviceManagementException {
|
||||
List<APIConfig> apiConfigs =
|
||||
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
||||
getApiPublisherConfig().getAPIs();
|
||||
for (APIConfig apiConfig : apiConfigs) {
|
||||
DeviceManagementAPIPublisherUtil.removeAPI(apiConfig);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.evaluator.spi;
|
||||
|
||||
|
||||
public interface PDPService {
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.util;
|
||||
|
||||
public final class PolicyManagementConstants {
|
||||
|
||||
public static final String DEVICE_CONFIG_XML_NAME = "cdm-config.xml";
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE
|
||||
(
|
||||
ID INT(11) auto_increment NOT NULL,
|
||||
NAME VARCHAR(300) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE
|
||||
(
|
||||
ID INT auto_increment NOT NULL,
|
||||
DESCRIPTION TEXT NULL DEFAULT NULL,
|
||||
NAME VARCHAR(100) NULL DEFAULT NULL,
|
||||
DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL,
|
||||
DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL,
|
||||
OWNERSHIP VARCHAR(45) NULL DEFAULT NULL,
|
||||
STATUS VARCHAR(15) NULL DEFAULT NULL,
|
||||
DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL,
|
||||
DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL,
|
||||
OWNER VARCHAR(45) NULL DEFAULT NULL,
|
||||
TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (ID),
|
||||
CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID )
|
||||
REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
);
|
||||
-- TO:DO - Remove this INSERT sql statement.
|
||||
Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android');
|
@ -0,0 +1,35 @@
|
||||
-- -----------------------------------------------------
|
||||
-- Table `DM_DEVICE_TYPE`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `DM_DEVICE_TYPE` (
|
||||
`ID` INT(11) NOT NULL ,
|
||||
`NAME` VARCHAR(300) NULL DEFAULT NULL ,
|
||||
PRIMARY KEY (`ID`) )
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `DM_DEVICE`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `DM_DEVICE` (
|
||||
`ID` VARCHAR(20) NOT NULL ,
|
||||
`DESCRIPTION` TEXT NULL DEFAULT NULL ,
|
||||
`NAME` VARCHAR(100) NULL DEFAULT NULL ,
|
||||
`DATE_OF_ENROLLMENT` DATETIME NULL DEFAULT NULL ,
|
||||
`DATE_OF_LAST_UPDATE` DATETIME NULL DEFAULT NULL ,
|
||||
`OWNERSHIP` VARCHAR(45) NULL DEFAULT NULL ,
|
||||
`STATUS` VARCHAR(15) NULL DEFAULT NULL ,
|
||||
`DEVICE_TYPE_ID` INT(11) NULL DEFAULT NULL ,
|
||||
`DEVICE_IDENTIFICATION` VARCHAR(300) NULL DEFAULT NULL ,
|
||||
`OWNER` VARCHAR(45) NULL DEFAULT NULL ,
|
||||
TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (`ID`) ,
|
||||
INDEX `fk_DM_DEVICE_DM_DEVICE_TYPE2_idx` (`DEVICE_TYPE_ID` ASC) ,
|
||||
CONSTRAINT `fk_DM_DEVICE_DM_DEVICE_TYPE2`
|
||||
FOREIGN KEY (`DEVICE_TYPE_ID` )
|
||||
REFERENCES `DM_DEVICE_TYPE` (`ID` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = latin1;
|
@ -1,3 +1,3 @@
|
||||
instructions.configure = \
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\
|
||||
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\
|
||||
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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 cdm.api.android;
|
||||
|
||||
import cdm.api.android.common.AndroidAgentException;
|
||||
import cdm.api.android.util.AndroidAPIUtils;
|
||||
import cdm.api.android.util.Message;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.*;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Android Device Operation REST-API implementation.
|
||||
*/
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@Consumes({ "application/json", "application/xml" })
|
||||
public class Operation {
|
||||
|
||||
private static Log log = LogFactory.getLog(Operation.class);
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
public List<org.wso2.carbon.device.mgt.common.Operation> getAllOperations(
|
||||
@PathParam("id") String id) throws
|
||||
AndroidAgentException {
|
||||
List<org.wso2.carbon.device.mgt.common.Operation> operations;
|
||||
String msg;
|
||||
DeviceManagementService dmService;
|
||||
|
||||
try {
|
||||
dmService = AndroidAPIUtils.getDeviceManagementService();
|
||||
} catch (DeviceManagementServiceException deviceMgtServiceEx) {
|
||||
msg = "Device management service error";
|
||||
log.error(msg, deviceMgtServiceEx);
|
||||
throw new AndroidAgentException(msg, deviceMgtServiceEx);
|
||||
}
|
||||
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||
operations = dmService.getOperationManager(
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID)
|
||||
.getOperations(deviceIdentifier);
|
||||
Response.status(HttpStatus.SC_OK);
|
||||
return operations;
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while fetching the operation manager for the device type.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
} catch (OperationManagementException e) {
|
||||
msg = "Error occurred while fetching the operation list for the device.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@PUT
|
||||
public Message updateOperation() throws
|
||||
AndroidAgentException {
|
||||
String msg;
|
||||
DeviceManagementService dmService;
|
||||
Message responseMsg = new Message();
|
||||
|
||||
try {
|
||||
dmService = AndroidAPIUtils.getDeviceManagementService();
|
||||
|
||||
} catch (DeviceManagementServiceException deviceMgtServiceEx) {
|
||||
msg = "Device management service error";
|
||||
log.error(msg, deviceMgtServiceEx);
|
||||
throw new AndroidAgentException(msg, deviceMgtServiceEx);
|
||||
}
|
||||
|
||||
try {
|
||||
boolean result = dmService.getOperationManager("").addOperation(null, null);
|
||||
if (result) {
|
||||
Response.status(HttpStatus.SC_OK);
|
||||
responseMsg.setResponseMessage("Device has already enrolled");
|
||||
} else {
|
||||
Response.status(HttpStatus.SC_NOT_FOUND);
|
||||
responseMsg.setResponseMessage("Operation not found");
|
||||
}
|
||||
return responseMsg;
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while fetching the operation manager for the device type.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
} catch (OperationManagementException e) {
|
||||
msg = "Error occurred while updating the operation status for the device.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue