Commit 6b37c21e 6b37c21e433b57fcf27b37e163fbd5b3abaa06e1 by root

save

1 parent d7c44780
...@@ -16,6 +16,19 @@ ...@@ -16,6 +16,19 @@
16 <dependencies> 16 <dependencies>
17 <!-- Spring --> 17 <!-- Spring -->
18 18
19 <dependency>
20 <groupId>commons-io</groupId>
21 <artifactId>commons-io</artifactId>
22 <version>2.4</version>
23 </dependency>
24
25 <dependency>
26 <groupId>commons-fileupload</groupId>
27 <artifactId>commons-fileupload</artifactId>
28 <version>1.2.1</version> <!-- makesure correct version here -->
29 </dependency>
30
31
19 <dependency> 32 <dependency>
20 <groupId>org.codehaus.jackson</groupId> 33 <groupId>org.codehaus.jackson</groupId>
21 <artifactId>jackson-mapper-asl</artifactId> 34 <artifactId>jackson-mapper-asl</artifactId>
...@@ -135,7 +148,7 @@ ...@@ -135,7 +148,7 @@
135 <dependency> 148 <dependency>
136 <groupId>org.emercit</groupId> 149 <groupId>org.emercit</groupId>
137 <artifactId>utilstools</artifactId> 150 <artifactId>utilstools</artifactId>
138 <version>1.21</version> 151 <version>1.22</version>
139 </dependency> 152 </dependency>
140 153
141 <dependency> 154 <dependency>
...@@ -315,28 +328,3 @@ http://repo.maven.apache.org/maven2 ...@@ -315,28 +328,3 @@ http://repo.maven.apache.org/maven2
315 328
316 </build> 329 </build>
317 </project> 330 </project>
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
......
1 25d332fbd0c12163ad293b4bc5f77d53
...\ No newline at end of file ...\ No newline at end of file
1 d94a29af148beaaf24bcb8de9e1caa741bf84082
...\ 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>utilstools</artifactId>
7 <version>1.22</version>
8 </project>
1 7082734e826fce32e566331beb798e51
...\ No newline at end of file ...\ No newline at end of file
1 5168382b2c0c0305c3b491de7877f66ebb11c269
...\ No newline at end of file ...\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
3 <groupId>org.emercit</groupId> 3 <groupId>org.emercit</groupId>
4 <artifactId>utilstools</artifactId> 4 <artifactId>utilstools</artifactId>
5 <versioning> 5 <versioning>
6 <release>1.21</release> 6 <release>1.22</release>
7 <versions> 7 <versions>
8 <version>1.0</version> 8 <version>1.0</version>
9 <version>1.1</version> 9 <version>1.1</version>
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
27 <version>1.19</version> 27 <version>1.19</version>
28 <version>1.20</version> 28 <version>1.20</version>
29 <version>1.21</version> 29 <version>1.21</version>
30 <version>1.22</version>
30 </versions> 31 </versions>
31 <lastUpdated>20150804023457</lastUpdated> 32 <lastUpdated>20150804090803</lastUpdated>
32 </versioning> 33 </versioning>
33 </metadata> 34 </metadata>
......
1 c9b18dea54a893e48d929c6b566329b1
...\ No newline at end of file ...\ No newline at end of file
1 d3cc127db852d356f6369653233badc8
...\ No newline at end of file ...\ No newline at end of file
......
1 68228ae65b16d9fbc4558423f27c44a7e54d4b93
...\ No newline at end of file ...\ No newline at end of file
1 3a98161da9ae3de4390b837d2853af35cd5c60c2
...\ No newline at end of file ...\ No newline at end of file
......
1 package org.emercit.devtools.app;
2
3
4
5 import java.io.File;
6 import java.io.FileInputStream;
7 import java.io.IOException;
8 import java.io.OutputStream;
9 import java.util.Vector;
10
11 import javax.servlet.ServletContext;
12 import javax.servlet.http.HttpServletRequest;
13 import javax.servlet.http.HttpServletResponse;
14 import javax.xml.bind.JAXBContext;
15 import javax.xml.bind.JAXBException;
16
17 import org.apache.commons.io.IOUtils;
18 import org.emercit.devtools.service.DnsService;
19 import org.emercit.dnsmanager.model.DnsBean;
20 import org.springframework.beans.factory.annotation.Autowired;
21 import org.springframework.http.MediaType;
22 import org.springframework.stereotype.Controller;
23 import org.springframework.ui.ModelMap;
24 import org.springframework.web.bind.annotation.RequestBody;
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.emercit.utilstools.service.Settings;
29 import org.emercit.utilstools.model.SettingsBean;
30
31 @Controller
32 public class DownloadFileController {
33
34
35 private Settings settings=new Settings();
36
37 private SettingsBean bean;
38
39
40
41
42 @ResponseBody
43 @RequestMapping(value = "/settings",
44
45 //produces={"application/json", "application/xml"},
46 produces={"application/xml"},
47 method = RequestMethod.GET)
48 public SettingsBean getStudent(HttpServletRequest request, HttpServletResponse response) {
49
50
51 bean=settings.make();
52
53
54 return bean;
55
56 }
57
58
59
60
61
62
63
64
65
66
67 }
1 package org.emercit.devtools.app;
2
3
4 import java.beans.XMLDecoder;
5 import java.io.BufferedInputStream;
6 import java.io.BufferedOutputStream;
7 import java.io.ByteArrayInputStream;
8 import java.io.ByteArrayOutputStream;
9 import java.io.File;
10 import java.io.FileInputStream;
11 import java.io.FileOutputStream;
12 import java.io.IOException;
13 import java.io.ObjectInputStream;
14 import java.io.ObjectOutputStream;
15
16 import org.springframework.stereotype.Controller;
17 import org.springframework.validation.BindingResult;
18 import org.springframework.validation.ObjectError;
19 import org.springframework.web.bind.annotation.RequestMapping;
20 import org.springframework.web.bind.annotation.RequestMethod;
21 import org.springframework.web.bind.annotation.ResponseBody;
22 import org.apache.log4j.Logger;
23 import org.codehaus.jackson.map.ObjectMapper;
24 import org.emercit.devtools.model.ExtJSFormResult;
25 import org.emercit.devtools.model.FileUploadBean;
26 import org.emercit.devtools.service.SvService;
27 import org.emercit.utilstools.model.SettingsBean;
28 import org.emercit.utilstools.service.Settings;
29
30 @Controller
31 @RequestMapping(value = "/upload.action")
32 public class FileUploadController {
33 private static final Logger log = Logger.getLogger(FileUploadController.class);
34
35 @RequestMapping(method = RequestMethod.POST)
36 public @ResponseBody String create(FileUploadBean uploadItem, BindingResult result){
37
38 ExtJSFormResult extjsFormResult = new ExtJSFormResult();
39
40 if (result.hasErrors()){
41 for(ObjectError error : result.getAllErrors()){
42 log.error("Error: " + error.getCode() + " - " + error.getDefaultMessage());
43 }
44
45 extjsFormResult.setSuccess(false);
46
47 return extjsFormResult.toString();
48 }
49
50
51 log.info("-------------------------------------------");
52 log.info(" " + uploadItem.getFileSettings().getOriginalFilename());
53 log.info("-------------------------------------------");
54
55
56
57 FileOutputStream outputStream = null;
58
59 String filePath = System.getProperty("java.io.tmpdir") + "/" + uploadItem.getFileSettings().getOriginalFilename();
60 try {
61 outputStream = new FileOutputStream(new File(filePath));
62 outputStream.write(uploadItem.getFileSettings().getBytes());
63 outputStream.close();
64 } catch (Exception e) {
65 System.out.println("Error while saving file");
66 return "FileUploadForm";
67 }
68
69
70 try {
71 //XMLDecoder d = new XMLDecoder(
72 // new BufferedInputStream(
73 // new FileInputStream(filePath)));
74 //Object obj=(Object)d.readObject();
75
76
77 ObjectMapper mapper = new ObjectMapper();
78 SettingsBean settingsBean = mapper.readValue(new File(filePath), SettingsBean.class);
79
80
81
82 Settings setting=new Settings();
83
84 setting.configuring(settingsBean);
85
86
87
88 }catch(Exception e) {
89 log.error(e.getMessage());
90 }
91
92
93
94 extjsFormResult.setSuccess(true);
95
96 return extjsFormResult.toString();
97
98 }
99
100
101
102
103
104
105
106
107
108 }
1 package org.emercit.devtools.model;
2
3
4 public class ExtJSFormResult {
5
6 private boolean success;
7
8 public boolean isSuccess() {
9 return success;
10 }
11 public void setSuccess(boolean success) {
12 this.success = success;
13 }
14
15 public String toString(){
16 return "{success:"+this.success+"}";
17 }
18 }
1 package org.emercit.devtools.model;
2
3
4
5 import org.springframework.web.multipart.commons.CommonsMultipartFile;
6
7 public class FileUploadBean {
8
9 private CommonsMultipartFile fileSettings;
10
11 public CommonsMultipartFile getFileSettings() {
12 return fileSettings;
13 }
14
15 public void setFileSettings(CommonsMultipartFile fileSettings) {
16 this.fileSettings = fileSettings;
17 }
18 }
...@@ -20,9 +20,6 @@ import org.emercit.pckutils.checkservice.STService; ...@@ -20,9 +20,6 @@ import org.emercit.pckutils.checkservice.STService;
20 public enum SvService { 20 public enum SvService {
21 21
22 22
23
24
25
26 INSTANCE; 23 INSTANCE;
27 24
28 private static final Logger log = Logger.getLogger(SvService.class); 25 private static final Logger log = Logger.getLogger(SvService.class);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
25 25
26 <context:component-scan base-package="org.emercit.devtools.app" /> 26 <context:component-scan base-package="org.emercit.devtools.app" />
27 27
28 <!-- Transporting JSON - Data --> 28
29 <beans:bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> 29 <beans:bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
30 <beans:property name="mediaTypes"> 30 <beans:property name="mediaTypes">
31 <beans:map> 31 <beans:map>
...@@ -41,4 +41,12 @@ ...@@ -41,4 +41,12 @@
41 </beans:property> 41 </beans:property>
42 </beans:bean> 42 </beans:bean>
43 43
44
45 <!-- Configure the multipart resolver -->
46 <beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
47 <!-- one of the properties available; the maximum file size in bytes -->
48 <beans:property name="maxUploadSize" value="500000"/>
49 </beans:bean>
50
51
44 </beans:beans> 52 </beans:beans>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -5,4 +5,6 @@ ...@@ -5,4 +5,6 @@
5 5
6 6
7 7
8
9
8 </beans> 10 </beans>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -21,7 +21,8 @@ Ext.application({ ...@@ -21,7 +21,8 @@ Ext.application({
21 'RemoteServer', 21 'RemoteServer',
22 'DeviceControl', 22 'DeviceControl',
23 'Log', 23 'Log',
24 'Sv' 24 'Sv',
25 'ToolsXml'
25 26
26 27
27 28
...@@ -233,15 +234,12 @@ Ext.application({ ...@@ -233,15 +234,12 @@ Ext.application({
233 }, 234 },
234 235
235 { 236 {
236 title: 'НАСТРОЙКИ В XML', 237 title: 'НАСТРОЙКИ В JSON',
237 items:[ 238 items:[
238 { 239 {
239 region: 'center', 240 xtype :'mvvm-ToolsXmlView',
240 xtype: 'tabpanel', 241 id:'formtoolsxml',
241 items: [ 242 width:600
242
243 ]
244
245 } 243 }
246 ] 244 ]
247 }, 245 },
...@@ -250,18 +248,12 @@ Ext.application({ ...@@ -250,18 +248,12 @@ Ext.application({
250 title: 'ЖУРНАЛ', 248 title: 'ЖУРНАЛ',
251 items:[ 249 items:[
252 { 250 {
253 region: 'center',
254 xtype: 'tabpanel',
255 items: [{
256 xtype : 'mvvm-LogView', 251 xtype : 'mvvm-LogView',
257 id:'formlog' 252 id:'formlog'
258 253
259 254
260 } 255 }
261 ] 256 ]
262
263 }
264 ]
265 }, 257 },
266 258
267 /* 259 /*
......
...@@ -23,8 +23,6 @@ Ext.define('App.controller.Gprs', { ...@@ -23,8 +23,6 @@ Ext.define('App.controller.Gprs', {
23 23
24 var selected=Ext.getCmp('internetGprs').getValue(); 24 var selected=Ext.getCmp('internetGprs').getValue();
25 25
26
27
28 var data=Ext.util.JSON.encode(selected); 26 var data=Ext.util.JSON.encode(selected);
29 27
30 Ext.Ajax.request({ 28 Ext.Ajax.request({
......
1 Ext.define('App.view.ToolsXml', {
2 extend : 'Ext.form.Panel',
3 xtype : 'mvvm-ToolsXmlView',
4 frame : true,
5 width:600,
6 padding : 10,
7 viewModel: {
8 type: 'toolsxmlform'
9 },
10
11 items:[{ xtype: 'filefield',
12 name: 'fileSettings',
13 fieldLabel: 'Конфиг',
14 labelWidth: 50,
15 width:575,
16 msgTarget: 'side',
17 allowBlank: false,
18 //anchor: '100%',
19 buttonText: 'Выберите файл...'
20 }],
21 buttons: [
22 {
23 text: 'Применить',
24 handler: function() {
25 var form = this.up('form').getForm();
26 if (form.isValid()) {
27 form.submit({
28 url: 'upload.action',
29 waitMsg: 'Загрузка файла и применение конфигурации...',
30 success: function(fp, o) {
31 Ext.Msg.alert('Успешно', 'Настройки применены');
32 }
33 });
34 }
35 }
36 }
37 ]
38
39 });
...\ No newline at end of file ...\ No newline at end of file
1 package org.emercit.utilstools; 1 package org.emercit.utilstools;
2 2
3 3
4 import org.emercit.ethmanager.model.EthBean; 4 import org.emercit.utilstools.model.SettingsBean;
5 import org.emercit.ethmanager.service.EthLinux; 5 import org.emercit.utilstools.service.Settings;
6 6
7 import java.util.Vector; 7 import java.util.Vector;
8 8
...@@ -14,14 +14,21 @@ public class App ...@@ -14,14 +14,21 @@ public class App
14 14
15 15
16 16
17 private static EthLinux ethlinux=new EthLinux(); 17
18 18
19 public static void main( String[] args ) 19 public static void main( String[] args )
20 { 20 {
21 Vector<EthBean> neans=ethlinux.getEthBeans();
22 21
23 22
24 EthBean bb=ethlinux.getEthByName("eth0"); 23
24 Settings remserv=new Settings();
25
26 remserv.init();
27
28 SettingsBean settingsbean=remserv.make();
29
30
31 remserv.set(settingsbean);
25 32
26 33
27 System.out.println(""); 34 System.out.println("");
......
...@@ -37,7 +37,7 @@ public class SettingsBean implements Serializable { ...@@ -37,7 +37,7 @@ public class SettingsBean implements Serializable {
37 } 37 }
38 38
39 //Set 39 //Set
40 public void setDevInfoBean(DevInfoBean model){ 40 public void setDevinfobean(DevInfoBean model){
41 41
42 this.devinfobean=model; 42 this.devinfobean=model;
43 } 43 }
...@@ -47,22 +47,22 @@ public class SettingsBean implements Serializable { ...@@ -47,22 +47,22 @@ public class SettingsBean implements Serializable {
47 this.dnsbeans=models; 47 this.dnsbeans=models;
48 } 48 }
49 49
50 public void setDateInfo(DateInfo model) { 50 public void setDateinfo(DateInfo model) {
51 51
52 this.dateinfobean=model; 52 this.dateinfobean=model;
53 } 53 }
54 54
55 public void setGSMBean(GSMBean model) { 55 public void setGsmbean(GSMBean model) {
56 56
57 this.gsmbean=model; 57 this.gsmbean=model;
58 } 58 }
59 59
60 public void setEthBeans(Vector<EthBean> models) { 60 public void setEthbeans(Vector<EthBean> models) {
61 61
62 this.ethbeans=models; 62 this.ethbeans=models;
63 } 63 }
64 64
65 public void setProxyBeans(Vector<ProxyBean> models) { 65 public void setProxybeans(Vector<ProxyBean> models) {
66 66
67 this.proxybeans=models; 67 this.proxybeans=models;
68 } 68 }
...@@ -80,7 +80,7 @@ public class SettingsBean implements Serializable { ...@@ -80,7 +80,7 @@ public class SettingsBean implements Serializable {
80 80
81 //Get 81 //Get
82 82
83 public DevInfoBean getDevInfoBean(){ 83 public DevInfoBean getDevinfobean(){
84 84
85 return devinfobean; 85 return devinfobean;
86 } 86 }
...@@ -90,22 +90,22 @@ public class SettingsBean implements Serializable { ...@@ -90,22 +90,22 @@ public class SettingsBean implements Serializable {
90 return dnsbeans; 90 return dnsbeans;
91 } 91 }
92 92
93 public DateInfo getDateInfo() { 93 public DateInfo getDateinfo() {
94 94
95 return dateinfobean; 95 return dateinfobean;
96 } 96 }
97 97
98 public GSMBean getGSMBean() { 98 public GSMBean getGsmbean() {
99 99
100 return gsmbean; 100 return gsmbean;
101 } 101 }
102 102
103 public Vector<EthBean> getEthBeans() { 103 public Vector<EthBean> getEthbeans() {
104 104
105 return ethbeans; 105 return ethbeans;
106 } 106 }
107 107
108 public Vector<ProxyBean> getProxyBeans() { 108 public Vector<ProxyBean> getProxybeans() {
109 109
110 return proxybeans; 110 return proxybeans;
111 } 111 }
......
...@@ -63,20 +63,20 @@ public class Settings implements ISettings { ...@@ -63,20 +63,20 @@ public class Settings implements ISettings {
63 */ 63 */
64 public void configuring(SettingsBean model) { 64 public void configuring(SettingsBean model) {
65 65
66 devinfo.set(model.getDevInfoBean()); 66 devinfo.set(model.getDevinfobean());
67 dnslinux.Config(model.getDnsbeans()); 67 dnslinux.Config(model.getDnsbeans());
68 68
69 DateInfo dateinfo=model.getDateInfo(); 69 DateInfo dateinfo=model.getDateinfo();
70 ntplinux.setUsNtpServer(dateinfo.getNtp()); 70 ntplinux.setUsNtpServer(dateinfo.getNtp());
71 71
72 gsm.set(model.getGSMBean()); 72 gsm.set(model.getGsmbean());
73 73
74 for (EthBean eb:model.getEthBeans()) { 74 for (EthBean eb:model.getEthbeans()) {
75 75
76 ethlinux.Update(eb); 76 ethlinux.Update(eb);
77 } 77 }
78 78
79 proxylinux.Config(model.getProxyBeans()); 79 proxylinux.Config(model.getProxybeans());
80 80
81 remserv.set(model.getRserverbeans()); 81 remserv.set(model.getRserverbeans());
82 } 82 }
...@@ -86,7 +86,7 @@ public class Settings implements ISettings { ...@@ -86,7 +86,7 @@ public class Settings implements ISettings {
86 sb=new SettingsBean(); 86 sb=new SettingsBean();
87 87
88 88
89 sb.setDevInfoBean(devinfo.get()); 89 sb.setDevinfobean(devinfo.get());
90 sb.setDnsbeans(dnslinux.getAllDns()); 90 sb.setDnsbeans(dnslinux.getAllDns());
91 91
92 92
...@@ -94,12 +94,13 @@ public class Settings implements ISettings { ...@@ -94,12 +94,13 @@ public class Settings implements ISettings {
94 dateInfo.setDt(""); 94 dateInfo.setDt("");
95 dateInfo.setNtp(ntplinux.getUseNtpServer()); 95 dateInfo.setNtp(ntplinux.getUseNtpServer());
96 96
97 sb.setDateInfo(dateInfo); 97 sb.setDateinfo(dateInfo);
98 98
99 sb.setGSMBean(gsm.get()); 99 sb.setGsmbean(gsm.get());
100 sb.setEthBeans(ethlinux.getEthBeans()); 100 sb.setEthbeans(ethlinux.getEthBeans());
101 sb.setProxyBeans(proxylinux.getProxyBeans()); 101 sb.setProxybeans(proxylinux.getProxyBeans());
102 sb.setRserverbeans(remserv.get()); 102 sb.setRserverbeans(remserv.get());
103 sb.setSvbeans(sv.get());
103 104
104 return sb; 105 return sb;
105 } 106 }
...@@ -114,6 +115,7 @@ public class Settings implements ISettings { ...@@ -114,6 +115,7 @@ public class Settings implements ISettings {
114 ethlinux.setDefaults(); 115 ethlinux.setDefaults();
115 proxylinux.init(); 116 proxylinux.init();
116 remserv.init(); 117 remserv.init();
118 sv.init();
117 119
118 sb=new SettingsBean(); 120 sb=new SettingsBean();
119 121
......