forked from community/device-mgt-plugins
Merge branch 'master' of https://github.com/wso2/product-mdm
commit
53c2abd574
@ -0,0 +1,84 @@
|
|||||||
|
/**
|
||||||
|
* 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.mobile;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.apimgt.api.APIManagementException;
|
||||||
|
import org.wso2.carbon.apimgt.api.APIProvider;
|
||||||
|
import org.wso2.carbon.apimgt.impl.APIManagerFactory;
|
||||||
|
import org.wso2.carbon.core.ServerStartupObserver;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
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.util.DeviceManagementAPIPublisherUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MobileDeviceManagementStartupObserver implements ServerStartupObserver {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(MobileDeviceManagementStartupObserver.class);
|
||||||
|
|
||||||
|
public void completingServerStartup() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void completedServerStartup() {
|
||||||
|
try {
|
||||||
|
this.initAPIConfigs();
|
||||||
|
/* Publish all mobile device management related JAX-RS services as APIs */
|
||||||
|
this.publishAPIs();
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
log.error("Error occurred while publishing Mobile Device Management related APIs", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initAPIConfigs() throws DeviceManagementException {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Initializing Mobile Device Management related APIs");
|
||||||
|
}
|
||||||
|
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 {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Publishing Mobile Device Management related APIs");
|
||||||
|
}
|
||||||
|
List<APIConfig> apiConfigs =
|
||||||
|
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
||||||
|
getApiPublisherConfig().getAPIs();
|
||||||
|
for (APIConfig apiConfig : apiConfigs) {
|
||||||
|
DeviceManagementAPIPublisherUtil.publishAPI(apiConfig);
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Successfully published API '" + apiConfig.getName() + "' with the context '" +
|
||||||
|
apiConfig.getContext() + "' and version '" + apiConfig.getVersion() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2009 WSO2, Inc. (http://wso2.com)
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# This is the log4j configuration file used by WSO2 Carbon
|
||||||
|
#
|
||||||
|
# IMPORTANT : Please do not remove or change the names of any
|
||||||
|
# of the Appenders defined here. The layout pattern & log file
|
||||||
|
# can be changed using the WSO2 Carbon Management Console, and those
|
||||||
|
# settings will override the settings in this file.
|
||||||
|
#
|
||||||
|
|
||||||
|
log4j.rootLogger=DEBUG, STD_OUT
|
||||||
|
|
||||||
|
# Redirect log messages to console
|
||||||
|
log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender
|
||||||
|
log4j.appender.STD_OUT.Target=System.out
|
||||||
|
log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
Binary file not shown.
@ -0,0 +1,40 @@
|
|||||||
|
<%
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var verb = request.getMethod();
|
||||||
|
var uri = request.getRequestURI();
|
||||||
|
var callPath=uri.replace("/cdm/api/","");
|
||||||
|
var log = new Log();
|
||||||
|
var deviceModule = require("/modules/device.js");
|
||||||
|
|
||||||
|
if (uri != null) {
|
||||||
|
var uriMatcher = new URIMatcher(callPath);
|
||||||
|
//log.info(callPath);
|
||||||
|
log.info(uriMatcher.match("operation/{type}/{deviceid}/{operation}"));
|
||||||
|
if (uriMatcher.match("operation/{type}/{deviceid}/{operation}")) {
|
||||||
|
|
||||||
|
var deviceId = uriMatcher.elements().deviceid;
|
||||||
|
var type = uriMatcher.elements().type;
|
||||||
|
var operation = uriMatcher.elements().operation;
|
||||||
|
var result = deviceModule.performOperation(deviceId, operation,[],type);
|
||||||
|
<!--log.info(result);-->
|
||||||
|
<!--print(result);-->
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%>
|
@ -1,3 +1,21 @@
|
|||||||
<%
|
<%
|
||||||
// footer includes
|
// footer includes
|
||||||
%>
|
%>
|
||||||
|
<!-- Modal -->
|
||||||
|
<div class="modal fade" id="confirmModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
|
<h4 class="modal-title" id="myModalLabel">Operation Confirmation</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
Do you wish to perform this operation?
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="performOperation()">Confirm</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -1,47 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<artifactType type="application/vnd.wso2-license+xml" shortName="license" singularLabel="License" pluralLabel="Licenses"
|
|
||||||
hasNamespace="false" iconSet="10">
|
|
||||||
<storagePath>/license/@{overview_provider}/@{overview_name}/@{overview_language}/@{overview_version}</storagePath>
|
|
||||||
<nameAttribute>overview_name</nameAttribute>
|
|
||||||
<ui>
|
|
||||||
<list>
|
|
||||||
<column name="Device Type">
|
|
||||||
<data type="path" value="overview_provider" href="@{storagePath}"/>
|
|
||||||
</column>
|
|
||||||
<column name="Name">
|
|
||||||
<data type="path" value="overview_name" href="@{storagePath}"/>
|
|
||||||
</column>
|
|
||||||
<column name="Language">
|
|
||||||
<data type="path" value="overview_language" href="@{storagePath}"/>
|
|
||||||
</column>
|
|
||||||
<column name="Version">
|
|
||||||
<data type="path" value="overview_version" href="@{storagePath}"/>
|
|
||||||
</column>
|
|
||||||
</list>
|
|
||||||
</ui>
|
|
||||||
<content>
|
|
||||||
<table name="Overview">
|
|
||||||
<field type="text" required="true">
|
|
||||||
<name>Provider</name>
|
|
||||||
</field>
|
|
||||||
<field type="text" required="true">
|
|
||||||
<name>Name</name>
|
|
||||||
</field>
|
|
||||||
<field type="text" required="true">
|
|
||||||
<name>Language</name>
|
|
||||||
</field>
|
|
||||||
<field type="text" required="true">
|
|
||||||
<name>Version</name>
|
|
||||||
</field>
|
|
||||||
<field type="text">
|
|
||||||
<name>Validity From</name>
|
|
||||||
</field>
|
|
||||||
<field type="text">
|
|
||||||
<name>Validity To</name>
|
|
||||||
</field>
|
|
||||||
<field type="text-area">
|
|
||||||
<name>License</name>
|
|
||||||
</field>
|
|
||||||
</table>
|
|
||||||
</content>
|
|
||||||
</artifactType>
|
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
* *
|
|
||||||
* * WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* * Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* * in compliance with the License.
|
|
||||||
* * You may obtain a copy of the License at
|
|
||||||
* *
|
|
||||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* *
|
|
||||||
* * Unless required by applicable law or agreed to in writing,
|
|
||||||
* * software distributed under the License is distributed on an
|
|
||||||
* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* * KIND, either express or implied. See the License for the
|
|
||||||
* * specific language governing permissions and limitations
|
|
||||||
* * under the License.
|
|
||||||
* /
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.wso2.cdmserver.mobileservices.android.common.AndroidAgentException;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.mgt.common.License;
|
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
|
||||||
import javax.ws.rs.GET;
|
|
||||||
import javax.ws.rs.Produces;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* License Management related JAX RS APIs
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Produces({ "application/json", "application/xml" })
|
|
||||||
@Consumes({ "application/json", "application/xml" })
|
|
||||||
public class Licenses {
|
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(Licenses.class);
|
|
||||||
|
|
||||||
@GET
|
|
||||||
public License getLicense(String deviceType) throws AndroidAgentException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package org.wso2.cdmserver.mobileservices.android;
|
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.*;
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
|
||||||
import javax.ws.rs.GET;
|
|
||||||
import javax.ws.rs.Path;
|
|
||||||
import javax.ws.rs.Produces;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a Test class
|
|
||||||
*/
|
|
||||||
@Produces({"application/json", "application/xml"})
|
|
||||||
@Consumes({"application/json", "application/xml"})
|
|
||||||
public class Test {
|
|
||||||
|
|
||||||
@GET
|
|
||||||
public List<org.wso2.carbon.device.mgt.common.Device> getAllDevices() throws DeviceManagementException{
|
|
||||||
|
|
||||||
Device dev = new Device();
|
|
||||||
dev.setName("test1");
|
|
||||||
dev.setDateOfEnrolment(11111111L);
|
|
||||||
dev.setDateOfLastUpdate(992093209L);
|
|
||||||
dev.setDescription("sassasaas");
|
|
||||||
|
|
||||||
ArrayList<Device> listdevices = new ArrayList<Device>();
|
|
||||||
listdevices.add(dev);
|
|
||||||
throw new DeviceManagementException("test ex");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue