Commit 63205f6a 63205f6ae1ad9916edc8d6617b174afbcabc235c by root

save

1 parent 2fae680f
Showing 48 changed files with 794 additions and 11 deletions
1 45d762803bf23878b394494e9b8ec966
...\ No newline at end of file ...\ No newline at end of file
1 bcb512bc2d6ea81f72c6b9fb5c9fab866bf8ed55
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="UTF-8"?>
2 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4 <modelVersion>4.0.0</modelVersion>
5 <groupId>org.emercit</groupId>
6 <artifactId>pckutils</artifactId>
7 <version>1.0</version>
8 </project>
1 885411a907233888727ee8797896488d
...\ No newline at end of file ...\ No newline at end of file
1 874189a2aabf491b3e6aaf5513c400e2cc932899
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="UTF-8"?>
2 <metadata>
3 <groupId>org.emercit</groupId>
4 <artifactId>pckutils</artifactId>
5 <versioning>
6 <release>1.0</release>
7 <versions>
8 <version>1.0</version>
9 </versions>
10 <lastUpdated>20150717143732</lastUpdated>
11 </versioning>
12 </metadata>
1 beef9eced655ee313a03e264529f4e5e
...\ No newline at end of file ...\ No newline at end of file
1 0881c3d87e83e58e68094f807bd594933d746940
...\ No newline at end of file ...\ No newline at end of file
1 7d9bb10da29a2caf08c23ffbbcfb52be
...\ No newline at end of file ...\ No newline at end of file
1 be97790e794cf9b556b068004587c23704d96f8e
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="UTF-8"?>
2 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4 <modelVersion>4.0.0</modelVersion>
5 <groupId>org.emercit</groupId>
6 <artifactId>remoteservers</artifactId>
7 <version>1.0</version>
8 </project>
1 780810c93c8564aabd3cebc4484e5540
...\ No newline at end of file ...\ No newline at end of file
1 8b9cc53d81b3225e50dfd89bc3c6c591aa89ed60
...\ No newline at end of file ...\ No newline at end of file
1 501d8feba852973bad1a075673f004d6
...\ No newline at end of file ...\ No newline at end of file
1 b3d6fbfdc94cd983a8be46aa551bf5c24d2c544b
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="UTF-8"?>
2 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4 <modelVersion>4.0.0</modelVersion>
5 <groupId>org.emercit</groupId>
6 <artifactId>remoteservers</artifactId>
7 <version>1.1</version>
8 </project>
1 da7c4688cce5db79d016a7c08cc3978c
...\ No newline at end of file ...\ No newline at end of file
1 54e2dfd71e5891beb9de05d8b08e94838c531e67
...\ No newline at end of file ...\ No newline at end of file
1 0aaacdd678213463d1a396d9a763b42a
...\ No newline at end of file ...\ No newline at end of file
1 62d904bfbb0265201fba27bddf9869c078afd404
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="UTF-8"?>
2 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4 <modelVersion>4.0.0</modelVersion>
5 <groupId>org.emercit</groupId>
6 <artifactId>remoteservers</artifactId>
7 <version>1.2</version>
8 </project>
1 d93eaf68258dca65064ee513d74aa15d
...\ No newline at end of file ...\ No newline at end of file
1 9ce077d872a701a9ee8b69ee7cb723759fe0b440
...\ No newline at end of file ...\ No newline at end of file
1 dad2a569361e36bb2d09b474b0d9850b
...\ No newline at end of file ...\ No newline at end of file
1 99a77174b3c51fa27c3af37d7441361e1bb5fa92
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="UTF-8"?>
2 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4 <modelVersion>4.0.0</modelVersion>
5 <groupId>org.emercit</groupId>
6 <artifactId>remoteservers</artifactId>
7 <version>1.3</version>
8 </project>
1 55620e80d7aeb6a4cc2fed99bb5c5f1c
...\ No newline at end of file ...\ No newline at end of file
1 429b1101db8e9268630aaeca78b4e1ed88b44a15
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="UTF-8"?>
2 <metadata>
3 <groupId>org.emercit</groupId>
4 <artifactId>remoteservers</artifactId>
5 <versioning>
6 <release>1.3</release>
7 <versions>
8 <version>1.0</version>
9 <version>1.1</version>
10 <version>1.2</version>
11 <version>1.3</version>
12 </versions>
13 <lastUpdated>20150717110442</lastUpdated>
14 </versioning>
15 </metadata>
1 9b8e334c8cfa36ac553251e1f35a02e2
...\ No newline at end of file ...\ No newline at end of file
1 774541070a9ee120430dcc491d4aadb30ced2f25
...\ No newline at end of file ...\ No newline at end of file
1 package org.emercit.devtools.app;
2
3
4 import java.util.Locale;
5
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
8 import org.springframework.web.bind.annotation.RequestMapping;
9 import org.springframework.web.bind.annotation.RequestMethod;
10 import org.springframework.beans.factory.annotation.Autowired;
11
12 import javax.servlet.http.*;
13 import javax.servlet.ServletContext;
14
15 import java.io.*;
16
17 import org.springframework.stereotype.Controller;
18 import org.springframework.validation.BindingResult;
19 import org.springframework.web.bind.annotation.ModelAttribute;
20 import org.springframework.web.bind.annotation.PathVariable;
21 import org.springframework.web.bind.annotation.RequestMapping;
22 import org.springframework.web.bind.annotation.RequestMethod;
23 import org.springframework.web.bind.annotation.RequestParam;
24 import org.springframework.stereotype.Controller;
25 import org.springframework.web.bind.annotation.RequestMapping;
26 import org.springframework.web.bind.annotation.RequestMethod;
27 import org.springframework.web.bind.annotation.ResponseBody;
28 import org.springframework.web.bind.annotation.RequestBody;
29
30 import java.util.Vector;
31
32 import org.emercit.devtools.service.EthService;
33 import org.emercit.devtools.service.RemoteServerManager;
34 import org.emercit.ethmanager.model.EthBean;
35 import org.emercit.remoteservers.model.RemoteServerBean;
36
37
38
39 @Controller
40 @RequestMapping("api")
41 public class RemoteServerController {
42
43
44
45
46 @RequestMapping(value = "remoteserver/bytype/{type}", method = RequestMethod.GET)
47 public @ResponseBody RemoteServerBean getRemoteServerByType(@PathVariable String type) {
48
49 return RemoteServerManager.INSTANCE.getByType(type);
50
51 }
52
53
54
55
56 @RequestMapping(value="remoteserver/update" , method = RequestMethod.POST)
57 public @ResponseBody boolean update(@RequestBody RemoteServerBean b) {
58
59 return RemoteServerManager.INSTANCE.Update(b);
60
61 }
62 }
63
1
2 package org.emercit.devtools.app;
3
4 import java.util.Locale;
5
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
8 import org.springframework.web.bind.annotation.RequestMapping;
9 import org.springframework.web.bind.annotation.RequestMethod;
10 import org.springframework.beans.factory.annotation.Autowired;
11
12 import javax.servlet.http.*;
13 import javax.servlet.ServletContext;
14
15 import java.io.*;
16
17 import org.springframework.stereotype.Controller;
18 import org.springframework.validation.BindingResult;
19 import org.springframework.web.bind.annotation.ModelAttribute;
20 import org.springframework.web.bind.annotation.PathVariable;
21 import org.springframework.web.bind.annotation.ResponseBody;
22 import org.springframework.web.bind.annotation.RequestBody;
23
24 import java.util.Vector;
25
26 import org.emercit.ethmanager.model.EthBean;
27 import org.emercit.proxymanager.model.ProxyBean;
28 import org.emercit.devtools.service.DnsService;
29 import org.emercit.devtools.service.EthService;
30 import org.emercit.dnsmanager.model.DnsBean;
31
32 import java.util.ArrayList;
33 import java.util.List;
34
35 import org.emercit.devtools.service.UtilsService;
36
37 @Controller
38 @RequestMapping("api")
39 public class UtilsController {
40
41 @RequestMapping(value="utils/ping" , method = RequestMethod.POST)
42 public @ResponseBody Vector<String> getResultPing(@RequestBody String host) {
43
44
45
46 return UtilsService.INSTANCE.Ping(host);
47 /*
48 Vector<String> results=new Vector<String>();
49
50
51 results.add("result1");
52 results.add("result2");
53 results.add("result3");
54
55
56
57 return results;
58 */
59
60
61 }
62
63 }
64
65
66
67
68
69
70
1
2 package org.emercit.devtools.service;
3
4
5 import org.emercit.model.IPAddressValidator;
6
7 import java.util.Vector;
8
9
10 import org.emercit.remoteservers.model.RemoteServerBean;
11 import org.emercit.remoteserver.service.RemoteServerDB;
12
13
14
15 public enum RemoteServerManager {
16
17 INSTANCE;
18
19 private RemoteServerDB store=new RemoteServerDB();
20
21 private Vector<RemoteServerBean> beans;
22
23
24 public Vector<RemoteServerBean> getAll() {
25 return store.SelectServers();
26
27 }
28
29
30 public RemoteServerBean getByType(String type) {
31
32 beans=store.SelectServers();
33
34 for (RemoteServerBean b:beans) {
35
36 if (b.getType().equals(type)) {
37 return b;
38 }
39 }
40
41 return null;
42 }
43
44
45 public boolean Update(RemoteServerBean b) {
46
47 beans=store.SelectServers();
48
49 for (RemoteServerBean bean:beans) {
50
51
52 if (bean.getId()==b.getId()) {
53
54 bean.setName(b.getName());
55 bean.setTitle(b.getTitle());
56 bean.setIp(b.getIp());
57 bean.setPort(b.getPort());
58
59 return store.Update(beans);
60
61 }
62
63
64 }
65 return false;
66 }
67 }
68
69
...\ No newline at end of file ...\ No newline at end of file
1 package org.emercit.devtools.service;
2
3
4 import org.emercit.model.IPAddressValidator;
5
6 import java.util.Vector;
7
8 import org.emercit.pckutils.cmd.CmdExec;
9
10 public enum UtilsService {
11
12 INSTANCE;
13
14 private CmdExec cmdexec=new CmdExec();
15
16 public Vector<String> Ping(String host) {
17
18 try {
19
20 Vector<String> result=cmdexec.Run("ping -c 7 "+host);
21
22 return result;
23
24 }catch(Exception e) {
25
26 return new Vector<String>();
27 }
28
29 }
30
31
32 }
...\ No newline at end of file ...\ No newline at end of file
1 Ext.define('App.controller.RemoteServer', {
2 extend : 'Ext.app.Controller',
3
4 init : function() {
5
6
7 this.control({
8 'toolbar button[action=saveRemoteServer]' : {
9 click : this.onSave
10 },
11
12 'toolbar button[action=loadRemoteServer]' : {
13 click : this.onLoad
14 }
15 });
16
17 this.onLoad();
18
19 },
20
21 onLoad:function() {
22
23
24 //mask
25 //Ext.getCmp('formremoteserver').mask("Загрузка...");
26
27 Ext.Ajax.request({
28 method: "GET",
29 url: 'api/remoteserver/bytype/szs',
30 headers: {
31 'Accept': 'application/json',
32 'Content-Type': 'application/json'
33 },
34
35 success: function(response, opts) {
36
37 var result = Ext.JSON.decode(response.responseText);
38
39 var remoteServerView = Ext.getCmp('formremoteserver');
40
41 remoteServerView.down('#TitleRemoteServer').setValue(result.title);
42 remoteServerView.down('#PortRemoteServer').setValue(result.port);
43 remoteServerView.down('#IpRemoteServer').setValue(result.ip);
44 remoteServerView.down('#NameRemoteServer').setValue(result.name);
45
46 remoteServerView.down('#IdRemoteServer').setValue(result.id);
47
48
49
50
51
52 /*
53 Ext.getCmp('guid').setValue(result.guid);
54 Ext.getCmp('title').setValue(result.description);
55 */
56 }, failure: function(response, opts) {
57 }
58 });
59
60 // Ext.getCmp('formremoteserver').unmask();
61
62 },
63
64
65 onSave : function() {
66
67 var formremoteserver=Ext.getCmp('formremoteserver');
68
69
70 var TitleRemoteServer=formremoteserver.down('#TitleRemoteServer').getValue();
71 var PortRemoteServer=formremoteserver.down('#PortRemoteServer').getValue();
72 var IpRemoteServer=formremoteserver.down('#IpRemoteServer').getValue();
73 var NameRemoteServer=formremoteserver.down('#NameRemoteServer').getValue();
74 var IdRemoteServer=formremoteserver.down('#IdRemoteServer').setValue();
75
76
77 remoteserver = {
78 id:1,
79 name:NameRemoteServer,
80 ip:IpRemoteServer,
81 port:parseInt(PortRemoteServer),
82 type:"",
83 title:TitleRemoteServer,
84 };
85
86
87 var data=Ext.util.JSON.encode(remoteserver);
88
89 Ext.Ajax.request({
90 method: "POST",
91 url: 'api/remoteserver/update',
92 headers: {
93 'Accept': 'application/json',
94 'Content-Type': 'application/json'
95 },
96 params: data,
97 success: function(response, opts) {
98
99 var result = Ext.JSON.decode(response.responseText);
100
101
102 if(result) {
103 Ext.Msg.alert('Success', 'Обновление конфигурации выполнено!');
104 //record.commit();
105 }
106 else
107 {
108 Ext.Msg.alert('Failure', 'Обновление конфигурации не выполнено!');
109 }
110
111
112
113 }, failure: function(response, opts) {
114 Ext.Msg.alert('Failure', 'Обновление конфигурации не выполнено!');
115 }
116 });
117
118 }
119 });
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
1 Ext.define('App.view.RemoteServer', {
2 extend : 'Ext.form.Panel',
3 xtype : 'mvvm-RemoteServerView',
4 // requires : [
5 // 'App.view.RemoteServerViewModel'
6 // ],
7
8 frame : true,
9 padding : 10,
10
11 bind : {
12 },
13
14 viewModel: {
15 type: 'remoteserverform'
16 },
17
18 bbar: {items: [{
19 xtype: 'button',
20 iconCls:'save',
21 itemId: 'RemoteServerButton',
22 text: 'Сохранить',
23 action: 'saveRemoteServer',
24 disabled:false
25 },
26 {
27 xtype: 'button',
28 iconCls:'load',
29 itemId: 'LoadRemoteServerButton',
30 text: 'Обновить',
31 action: 'loadRemoteServer',
32 disabled:false
33 }]
34 },
35
36 items:[{
37 xtype : 'textfield',
38 fieldLabel : '',
39 itemId:'IdRemoteServer',
40 disable:true,
41 width:500,
42 hidden:true,
43 margin:'5 5 10 3'
44 },
45 {
46 xtype : 'textfield',
47 fieldLabel : 'НАЗВАНИЕ',
48 itemId:'NameRemoteServer',
49 disable:true,
50 width:500,
51 margin:'5 5 10 3'
52 },{
53 xtype : 'textfield',
54 fieldLabel : 'IP адрес',
55 itemId:'IpRemoteServer',
56 disable:true,
57 width:500,
58 margin:'5 5 10 3'
59 },{
60 xtype : 'textfield',
61 fieldLabel : 'ПОРТ',
62 itemId:'PortRemoteServer',
63 disable:true,
64 width:500,
65 margin:'5 5 10 3'
66 },{
67 xtype : 'textarea',
68 itemId:'TitleRemoteServer',
69 fieldLabel : 'ОПИСАНИЕ',
70 height:50,
71 width:500,
72 margin:'5 5 10 3'
73 }]
74 });
...\ No newline at end of file ...\ No newline at end of file
...@@ -15,11 +15,37 @@ ...@@ -15,11 +15,37 @@
15 </properties> 15 </properties>
16 16
17 <dependencies> 17 <dependencies>
18
19
18 <dependency> 20 <dependency>
19 <groupId>junit</groupId> 21 <groupId>net.sourceforge.argparse4j</groupId>
20 <artifactId>junit</artifactId> 22 <artifactId>argparse4j</artifactId>
21 <version>3.8.1</version> 23 <version>0.6.0</version>
22 <scope>test</scope> 24 </dependency>
23 </dependency> 25
26
27 <dependency>
28 <groupId>log4j</groupId>
29 <artifactId>log4j</artifactId>
30 <version>1.2.17</version>
31 </dependency>
32
33 <dependency>
34 <groupId>junit</groupId>
35 <artifactId>junit</artifactId>
36 <version>4.12</version>
37 </dependency>
38
39
40 <dependency>
41 <groupId>com.cedarsoftware</groupId>
42 <artifactId>json-io</artifactId>
43 <version>4.0.0</version>
44 </dependency>
45
46
47
48
49
24 </dependencies> 50 </dependencies>
25 </project> 51 </project>
......
1 package org.emercit.remoteserver.service;
2
3
4 import java.util.Vector;
5
6 import org.emercit.remoteservers.model.RemoteServerBean;
7
8 public interface IRemoteServerDB {
9
10
11 public Vector<RemoteServerBean> SelectServers();
12
13 public boolean Update(Vector<RemoteServerBean> beans);
14
15 public boolean CreateDB();
16
17
18 }
1 package org.emercit.remoteserver.service;
2
3 import java.util.Vector;
4 import java.beans.XMLEncoder;
5 import java.beans.XMLDecoder;
6 import java.io.BufferedOutputStream;
7 import java.io.BufferedInputStream;
8 import java.io.FileOutputStream;
9 import java.io.FileInputStream;
10
11 import org.apache.log4j.Logger;
12 import org.emercit.remoteserver.service.IRemoteServerDB;
13 import org.emercit.remoteservers.model.RemoteServerBean;
14
15 public class RemoteServerDB implements IRemoteServerDB {
16
17 private static final Logger log = Logger.getLogger(RemoteServerDB.class);
18
19 public boolean Update(Vector<RemoteServerBean> beans) {
20
21 boolean result=true;
22 try {
23 FileOutputStream fos = new FileOutputStream("/opt/devtools/beans/RemoteServerBeans.xml");
24 BufferedOutputStream bos = new BufferedOutputStream(fos);
25 XMLEncoder xmlEncoder = new XMLEncoder(bos);
26 xmlEncoder.writeObject(beans);
27 xmlEncoder.close();
28 }catch(Exception e) {
29 log.error(e.getMessage());
30 result=false;
31 }
32 return result;
33 }
34
35 public Vector<RemoteServerBean> SelectServers() {
36
37 Vector<RemoteServerBean> result=new Vector<RemoteServerBean>();
38
39 try {
40 XMLDecoder d = new XMLDecoder(
41
42 new BufferedInputStream(
43 new FileInputStream("/opt/devtools/beans/RemoteServerBeans.xml")));
44 result=(Vector<RemoteServerBean>)d.readObject();
45 d.close();
46 }catch(Exception e) {
47 log.error(e.getMessage());
48 result=null;
49 }
50 return result;
51 }
52
53
54
55 public boolean CreateDB() {
56
57
58
59 boolean result=true;
60 try {
61
62 Vector<RemoteServerBean> beans=new Vector<RemoteServerBean>();
63
64 RemoteServerBean rsb=new RemoteServerBean();
65
66 rsb.setId(1);
67 rsb.setIp("127.0.0.1");
68 rsb.setPort(80);
69 rsb.setName("");
70 rsb.setType("szs");
71 rsb.setTitle("");
72
73 beans.add(rsb);
74
75
76 FileOutputStream fos = new FileOutputStream("/opt/devtools/beans/RemoteServerBeans.xml");
77 BufferedOutputStream bos = new BufferedOutputStream(fos);
78 XMLEncoder xmlEncoder = new XMLEncoder(bos);
79 xmlEncoder.writeObject(beans);
80 xmlEncoder.close();
81 }catch(Exception e) {
82 log.error(e.getMessage());
83 result=false;
84 }
85 return result;
86 }
87
88
89
90 }
91
92
93
94
95
96
97
98
99
1 package org.emercit.remoteservers; 1 package org.emercit.remoteservers;
2 2
3 /** 3
4 * Hello world! 4 import org.emercit.remoteserver.service.RemoteServerDB;
5 * 5
6 */
7 public class App 6 public class App
8 { 7 {
9 public static void main( String[] args ) 8 public static void main( String[] args )
10 { 9 {
11 System.out.println( "Hello World!" ); 10
11 RemoteServerDB sv=new RemoteServerDB();
12 sv.CreateDB();
12 } 13 }
13 } 14 }
......
1 package org.emercit.remoteservers.model;
2
3
4
5
6 import java.io.Serializable;
7 import java.util.Vector;
8
9 public class RemoteServerBean implements Serializable {
10
11 private static final long serialVersionUID = 1L;
12
13
14 private int id;
15
16 private String name;
17
18 private String ip;
19
20 private int port;
21
22 private String type;
23
24 private String title;
25
26 public RemoteServerBean() {
27
28 }
29
30 /*
31 * SET
32 */
33
34 public void setId(int value) {
35 this.id=value;
36 }
37
38 public void setIp(String value) {
39 this.ip=value;
40 }
41
42
43 public void setPort(int value) {
44 this.port=value;
45 }
46
47
48 public void setName(String value) {
49 this.name=value;
50 }
51
52
53 public void setType(String value) {
54
55 this.type=value;
56 }
57
58 public void setTitle(String value) {
59 this.title=value;
60 }
61
62
63
64 /*
65 * GET
66 */
67
68 public int getId() {
69 return id;
70 }
71
72
73 public String getIp() {
74 return ip;
75 }
76
77 public int getPort() {
78 return port;
79 }
80
81 public String getName() {
82 return name;
83 }
84
85 public String getType() {
86 return type;
87 }
88
89
90 public String getTitle() {
91 return title;
92 }
93
94 }
95
96
1 package HardwareConfig.RemoteServers; 1 package org.emercit.remoteservers;
2 2
3 import junit.framework.Test; 3 import junit.framework.Test;
4 import junit.framework.TestCase; 4 import junit.framework.TestCase;
......