Merge pull request #158 from sidias/master

resolving pom issues
application-manager-new
Ruwan 9 years ago
commit 0ebfe2b8c0

@ -19,7 +19,7 @@
<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>
<artifactId>connectedlap</artifactId>
<artifactId>connectedlap-component</artifactId>
<groupId>org.wso2</groupId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>

@ -1,100 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.agent</groupId>
<artifactId>connectedlap</artifactId>
<name>connectedlap</name>
<version>1.0</version>
<url>http://maven.apache.org</url>
<build>
<finalName>ConnectedLap</finalName>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/log4j.properties</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.wso2.agent.main.JavaApp</mainClass>
<classpathPrefix>dependency-jars/</classpathPrefix>
</manifest>
</archive>
<outputDirectory>${project.build.directory}/../../../feature/feature/src/main/resources/agent/</outputDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer>
<mainClass>org.wso2.agent.main.JavaApp</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<jdk.version>1.7</jdk.version>
</properties>
</project>

@ -1,7 +1,7 @@
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.agent</groupId>
<groupId>org.wso2</groupId>
<artifactId>connectedlap</artifactId>
<packaging>jar</packaging>
<version>1.0</version>

@ -1,3 +1,21 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.agent.common;
import java.security.GeneralSecurityException;

@ -1,3 +1,21 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.agent.config;
import java.io.FileInputStream;

@ -1,3 +1,21 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.agent.datasense;
import java.io.IOException;

@ -1,6 +1,25 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.agent.main;
import java.io.BufferedReader;
import java.io.Console;
import java.io.File;
import java.io.InputStreamReader;
import java.util.ArrayList;
@ -18,99 +37,101 @@ import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
/**
* Created by amila on 5/17/16.
*/
public class JavaApp {
final static int TIMEINTERVAL=10000;//ms
public static String SUPASSWORD="";
static int TIMECOUNTER=0;// 5 minute interval sender tracker;
final static int TIMEINTERVAL = 10000;//ms
public static String SUPASSWORD = "";
static int TIMECOUNTER = 0;// 5 minute interval sender tracker;
public static String deviceid;
public static void main(String args[]) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Super User Password");
System.out.print("Enter Password:");
try{
JavaApp.SUPASSWORD = String.valueOf(br.readLine());
}catch(Exception e){
System.out.println("Retreving Password Failed!");
}finally{
try{
BufferedReader br = null;
try {
Console console = System.console();
//String username = console.readLine("Username: ");
char[] password = console.readPassword("Password: ");
JavaApp.SUPASSWORD = String.valueOf(password);
//br = new BufferedReader(new InputStreamReader(System.in));
//JavaApp.SUPASSWORD = String.valueOf(br.readLine());
} catch (Exception e) {
System.out.println("Retrieving Password Failed!");
} finally {
try {
br.close();
}catch(Exception e){}
} catch (Exception e) {
}
}
if(!new Configuration().checkRegistered()){
SystemSpec spec=new Monitor().getSysInfo(JavaApp.SUPASSWORD);
String devicetoken=new String();
String devicerefreshtoken=new String();
Configuration config=new Configuration();
if (!new Configuration().checkRegistered()) {
SystemSpec spec = new Monitor().getSysInfo(JavaApp.SUPASSWORD);
String devicetoken = new String();
String devicerefreshtoken = new String();
Configuration config = new Configuration();
try {
String token=String.valueOf(config.getInitProperty("auth-token"));
String token = String.valueOf(config.getInitProperty("auth-token"));
//token="9c7a1b4d6625cdd936b894cc0e7c7390";
String refreshtoken=String.valueOf(config.getInitProperty("refresh-token"));
String device_name=String.valueOf(config.getInitProperty("device-name"));
String refreshtoken = String.valueOf(config.getInitProperty("refresh-token"));
String device_name = String.valueOf(config.getInitProperty("device-name"));
Client client = Client.create(Common.configureClient());
client.setConnectTimeout(50000);
WebResource webResource = client.resource("https://localhost:9443/CONNECTEDLAP/device/register");
String mac = spec.getMacaddress().replaceAll("\\:", "");
deviceid = mac;
String request="{"
String request = "{"
+ "\"owner\":\"admin\","
+"\"deviceId\":\""+mac+"\","
+"\"deviceName\": \""+device_name+"\","
+"\"discSpace\":"+spec.getStorage()+","
+"\"memory\":"+spec.getRamsize()+","
+"\"cpuInfo\":\""+spec.getProcessor_speed()+"\","
+ "\"networkType\":\""+spec.getNetworktype()+"\","
+"\"cpucorecount\":\""+spec.getProcessor_cores()+"\""
+ "\"deviceId\":\"" + mac + "\","
+ "\"deviceName\": \"" + device_name + "\","
+ "\"discSpace\":" + spec.getStorage() + ","
+ "\"memory\":" + spec.getRamsize() + ","
+ "\"cpuInfo\":\"" + spec.getProcessor_speed() + "\","
+ "\"networkType\":\"" + spec.getNetworktype() + "\","
+ "\"cpucorecount\":\"" + spec.getProcessor_cores() + "\""
+ "}";
ClientResponse response = (ClientResponse)webResource.type("application/json").header("Authorization", "Bearer "+token).post(ClientResponse.class,request);
ClientResponse response = (ClientResponse) webResource.type("application/json").header("Authorization", "Bearer " + token).post(ClientResponse.class, request);
System.out.println("Output from Server .... \n");
String output = (String)response.getEntity(String.class);
String output = (String) response.getEntity(String.class);
System.out.println(output);
JSONObject outputJson= new JSONObject(output);
devicetoken=outputJson.getString("accessToken");
devicerefreshtoken=outputJson.getString("refreshToken");
JSONObject outputJson = new JSONObject(output);
devicetoken = outputJson.getString("accessToken");
devicerefreshtoken = outputJson.getString("refreshToken");
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
}
config.SaveRegistration(spec,devicetoken,devicerefreshtoken);
}
catch (Exception e) {
config.SaveRegistration(spec, devicetoken, devicerefreshtoken);
} catch (Exception e) {
//e.printStackTrace();
throw e;
}
}
//String deviceid=String.valueOf(new Configuration().getProperty("deviceid"));
String owner=String.valueOf(new Configuration().getInitProperty("owner"));
String devicetoken=String.valueOf(new Configuration().getProperty("devicetoken"));
String devicerefreshtoken=String.valueOf(new Configuration().getProperty("devicerefreshtoken"));
String owner = String.valueOf(new Configuration().getInitProperty("owner"));
String devicetoken = String.valueOf(new Configuration().getProperty("devicetoken"));
String devicerefreshtoken = String.valueOf(new Configuration().getProperty("devicerefreshtoken"));
while(true) {
while (true) {
try {
new RecordStore().saveData(new Monitor().getSysUsage(JavaApp.SUPASSWORD));
JavaApp.TIMECOUNTER+=TIMEINTERVAL;
if(JavaApp.TIMECOUNTER>=10000){
ArrayList<SystemUsage> sysUsageList=new RecordStore().readData();
JavaApp.TIMECOUNTER += TIMEINTERVAL;
if (JavaApp.TIMECOUNTER >= 10000) {
ArrayList<SystemUsage> sysUsageList = new RecordStore().readData();
for (SystemUsage systemUsage : sysUsageList) {
new PushSystemUsage().pushData(systemUsage,deviceid,owner,devicetoken);
new PushSystemUsage().pushData(systemUsage, deviceid, owner, devicetoken);
}
File file = new File("usagelog");
if(file.delete()){
if (file.delete()) {
System.out.println(file.getName() + " is deleted!");
}else{
} else {
System.out.println("Delete operation is failed.");
}
}
Thread.sleep(JavaApp.TIMEINTERVAL);
} catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}

@ -1,3 +1,21 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.agent.resourcemonitor;
import org.wso2.agent.resourcemonitor.infocollector.Collector;

@ -1,3 +1,21 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.agent.resourcemonitor.exception;
@SuppressWarnings("serial")

@ -1,3 +1,21 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.agent.resourcemonitor.infocollector;
import javax.management.OperationsException;

@ -1,3 +1,21 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.agent.resourcemonitor.pojo;
public class SystemSpec {

@ -1,3 +1,21 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.agent.resourcemonitor.pojo;
public class SystemUsage {

@ -1,3 +1,21 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.agent.store;
import java.io.BufferedReader;

Loading…
Cancel
Save