Commit 6b37c21e 6b37c21e433b57fcf27b37e163fbd5b3abaa06e1 by root

save

1 parent d7c44780
......@@ -16,6 +16,19 @@
<dependencies>
<!-- Spring -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version> <!-- makesure correct version here -->
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
......@@ -135,7 +148,7 @@
<dependency>
<groupId>org.emercit</groupId>
<artifactId>utilstools</artifactId>
<version>1.21</version>
<version>1.22</version>
</dependency>
<dependency>
......@@ -315,28 +328,3 @@ http://repo.maven.apache.org/maven2
</build>
</project>
......
25d332fbd0c12163ad293b4bc5f77d53
\ No newline at end of file
d94a29af148beaaf24bcb8de9e1caa741bf84082
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.emercit</groupId>
<artifactId>utilstools</artifactId>
<version>1.22</version>
</project>
7082734e826fce32e566331beb798e51
\ No newline at end of file
5168382b2c0c0305c3b491de7877f66ebb11c269
\ No newline at end of file
......@@ -3,7 +3,7 @@
<groupId>org.emercit</groupId>
<artifactId>utilstools</artifactId>
<versioning>
<release>1.21</release>
<release>1.22</release>
<versions>
<version>1.0</version>
<version>1.1</version>
......@@ -27,7 +27,8 @@
<version>1.19</version>
<version>1.20</version>
<version>1.21</version>
<version>1.22</version>
</versions>
<lastUpdated>20150804023457</lastUpdated>
<lastUpdated>20150804090803</lastUpdated>
</versioning>
</metadata>
......
c9b18dea54a893e48d929c6b566329b1
\ No newline at end of file
d3cc127db852d356f6369653233badc8
\ No newline at end of file
......
68228ae65b16d9fbc4558423f27c44a7e54d4b93
\ No newline at end of file
3a98161da9ae3de4390b837d2853af35cd5c60c2
\ No newline at end of file
......
package org.emercit.devtools.app;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Vector;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import org.apache.commons.io.IOUtils;
import org.emercit.devtools.service.DnsService;
import org.emercit.dnsmanager.model.DnsBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.emercit.utilstools.service.Settings;
import org.emercit.utilstools.model.SettingsBean;
@Controller
public class DownloadFileController {
private Settings settings=new Settings();
private SettingsBean bean;
@ResponseBody
@RequestMapping(value = "/settings",
//produces={"application/json", "application/xml"},
produces={"application/xml"},
method = RequestMethod.GET)
public SettingsBean getStudent(HttpServletRequest request, HttpServletResponse response) {
bean=settings.make();
return bean;
}
}
package org.emercit.devtools.app;
import java.beans.XMLDecoder;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.apache.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import org.emercit.devtools.model.ExtJSFormResult;
import org.emercit.devtools.model.FileUploadBean;
import org.emercit.devtools.service.SvService;
import org.emercit.utilstools.model.SettingsBean;
import org.emercit.utilstools.service.Settings;
@Controller
@RequestMapping(value = "/upload.action")
public class FileUploadController {
private static final Logger log = Logger.getLogger(FileUploadController.class);
@RequestMapping(method = RequestMethod.POST)
public @ResponseBody String create(FileUploadBean uploadItem, BindingResult result){
ExtJSFormResult extjsFormResult = new ExtJSFormResult();
if (result.hasErrors()){
for(ObjectError error : result.getAllErrors()){
log.error("Error: " + error.getCode() + " - " + error.getDefaultMessage());
}
extjsFormResult.setSuccess(false);
return extjsFormResult.toString();
}
log.info("-------------------------------------------");
log.info(" " + uploadItem.getFileSettings().getOriginalFilename());
log.info("-------------------------------------------");
FileOutputStream outputStream = null;
String filePath = System.getProperty("java.io.tmpdir") + "/" + uploadItem.getFileSettings().getOriginalFilename();
try {
outputStream = new FileOutputStream(new File(filePath));
outputStream.write(uploadItem.getFileSettings().getBytes());
outputStream.close();
} catch (Exception e) {
System.out.println("Error while saving file");
return "FileUploadForm";
}
try {
//XMLDecoder d = new XMLDecoder(
// new BufferedInputStream(
// new FileInputStream(filePath)));
//Object obj=(Object)d.readObject();
ObjectMapper mapper = new ObjectMapper();
SettingsBean settingsBean = mapper.readValue(new File(filePath), SettingsBean.class);
Settings setting=new Settings();
setting.configuring(settingsBean);
}catch(Exception e) {
log.error(e.getMessage());
}
extjsFormResult.setSuccess(true);
return extjsFormResult.toString();
}
}
package org.emercit.devtools.model;
public class ExtJSFormResult {
private boolean success;
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String toString(){
return "{success:"+this.success+"}";
}
}
package org.emercit.devtools.model;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
public class FileUploadBean {
private CommonsMultipartFile fileSettings;
public CommonsMultipartFile getFileSettings() {
return fileSettings;
}
public void setFileSettings(CommonsMultipartFile fileSettings) {
this.fileSettings = fileSettings;
}
}
......@@ -19,9 +19,6 @@ import org.emercit.pckutils.checkservice.STService;
public enum SvService {
INSTANCE;
......
......@@ -22,10 +22,10 @@
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="org.emercit.devtools.app" />
<!-- Transporting JSON - Data -->
<beans:bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<beans:property name="mediaTypes">
<beans:map>
......@@ -41,4 +41,12 @@
</beans:property>
</beans:bean>
</beans:beans>
<!-- Configure the multipart resolver -->
<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- one of the properties available; the maximum file size in bytes -->
<beans:property name="maxUploadSize" value="500000"/>
</beans:bean>
</beans:beans>
\ No newline at end of file
......
......@@ -4,5 +4,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>
\ No newline at end of file
......
......@@ -21,7 +21,8 @@ Ext.application({
'RemoteServer',
'DeviceControl',
'Log',
'Sv'
'Sv',
'ToolsXml'
......@@ -233,34 +234,25 @@ Ext.application({
},
{
title: 'НАСТРОЙКИ В XML',
title: 'НАСТРОЙКИ В JSON',
items:[
{
region: 'center',
xtype: 'tabpanel',
items: [
]
}
{
xtype :'mvvm-ToolsXmlView',
id:'formtoolsxml',
width:600
}
]
},
{
title: 'ЖУРНАЛ',
items:[
{
region: 'center',
xtype: 'tabpanel',
items: [{
xtype : 'mvvm-LogView',
id:'formlog'
}
]
}
{
xtype : 'mvvm-LogView',
id:'formlog'
}
]
},
......
......@@ -23,9 +23,7 @@ Ext.define('App.controller.Gprs', {
var selected=Ext.getCmp('internetGprs').getValue();
var data=Ext.util.JSON.encode(selected);
var data=Ext.util.JSON.encode(selected);
Ext.Ajax.request({
method: "POST",
......
Ext.define('App.view.ToolsXml', {
extend : 'Ext.form.Panel',
xtype : 'mvvm-ToolsXmlView',
frame : true,
width:600,
padding : 10,
viewModel: {
type: 'toolsxmlform'
},
items:[{ xtype: 'filefield',
name: 'fileSettings',
fieldLabel: 'Конфиг',
labelWidth: 50,
width:575,
msgTarget: 'side',
allowBlank: false,
//anchor: '100%',
buttonText: 'Выберите файл...'
}],
buttons: [
{
text: 'Применить',
handler: function() {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
url: 'upload.action',
waitMsg: 'Загрузка файла и применение конфигурации...',
success: function(fp, o) {
Ext.Msg.alert('Успешно', 'Настройки применены');
}
});
}
}
}
]
});
\ No newline at end of file
package org.emercit.utilstools;
import org.emercit.ethmanager.model.EthBean;
import org.emercit.ethmanager.service.EthLinux;
import org.emercit.utilstools.model.SettingsBean;
import org.emercit.utilstools.service.Settings;
import java.util.Vector;
......@@ -13,15 +13,22 @@ public class App
private static final Logger log = Logger.getLogger(App.class);
private static EthLinux ethlinux=new EthLinux();
public static void main( String[] args )
{
Vector<EthBean> neans=ethlinux.getEthBeans();
EthBean bb=ethlinux.getEthByName("eth0");
Settings remserv=new Settings();
remserv.init();
SettingsBean settingsbean=remserv.make();
remserv.set(settingsbean);
System.out.println("");
......
......@@ -37,7 +37,7 @@ public class SettingsBean implements Serializable {
}
//Set
public void setDevInfoBean(DevInfoBean model){
public void setDevinfobean(DevInfoBean model){
this.devinfobean=model;
}
......@@ -47,22 +47,22 @@ public class SettingsBean implements Serializable {
this.dnsbeans=models;
}
public void setDateInfo(DateInfo model) {
public void setDateinfo(DateInfo model) {
this.dateinfobean=model;
}
public void setGSMBean(GSMBean model) {
public void setGsmbean(GSMBean model) {
this.gsmbean=model;
}
public void setEthBeans(Vector<EthBean> models) {
public void setEthbeans(Vector<EthBean> models) {
this.ethbeans=models;
}
public void setProxyBeans(Vector<ProxyBean> models) {
public void setProxybeans(Vector<ProxyBean> models) {
this.proxybeans=models;
}
......@@ -80,7 +80,7 @@ public class SettingsBean implements Serializable {
//Get
public DevInfoBean getDevInfoBean(){
public DevInfoBean getDevinfobean(){
return devinfobean;
}
......@@ -90,22 +90,22 @@ public class SettingsBean implements Serializable {
return dnsbeans;
}
public DateInfo getDateInfo() {
public DateInfo getDateinfo() {
return dateinfobean;
}
public GSMBean getGSMBean() {
public GSMBean getGsmbean() {
return gsmbean;
}
public Vector<EthBean> getEthBeans() {
public Vector<EthBean> getEthbeans() {
return ethbeans;
}
public Vector<ProxyBean> getProxyBeans() {
public Vector<ProxyBean> getProxybeans() {
return proxybeans;
}
......
......@@ -63,20 +63,20 @@ public class Settings implements ISettings {
*/
public void configuring(SettingsBean model) {
devinfo.set(model.getDevInfoBean());
devinfo.set(model.getDevinfobean());
dnslinux.Config(model.getDnsbeans());
DateInfo dateinfo=model.getDateInfo();
DateInfo dateinfo=model.getDateinfo();
ntplinux.setUsNtpServer(dateinfo.getNtp());
gsm.set(model.getGSMBean());
gsm.set(model.getGsmbean());
for (EthBean eb:model.getEthBeans()) {
for (EthBean eb:model.getEthbeans()) {
ethlinux.Update(eb);
}
proxylinux.Config(model.getProxyBeans());
proxylinux.Config(model.getProxybeans());
remserv.set(model.getRserverbeans());
}
......@@ -86,7 +86,7 @@ public class Settings implements ISettings {
sb=new SettingsBean();
sb.setDevInfoBean(devinfo.get());
sb.setDevinfobean(devinfo.get());
sb.setDnsbeans(dnslinux.getAllDns());
......@@ -94,12 +94,13 @@ public class Settings implements ISettings {
dateInfo.setDt("");
dateInfo.setNtp(ntplinux.getUseNtpServer());
sb.setDateInfo(dateInfo);
sb.setDateinfo(dateInfo);
sb.setGSMBean(gsm.get());
sb.setEthBeans(ethlinux.getEthBeans());
sb.setProxyBeans(proxylinux.getProxyBeans());
sb.setGsmbean(gsm.get());
sb.setEthbeans(ethlinux.getEthBeans());
sb.setProxybeans(proxylinux.getProxyBeans());
sb.setRserverbeans(remserv.get());
sb.setSvbeans(sv.get());
return sb;
}
......@@ -114,6 +115,7 @@ public class Settings implements ISettings {
ethlinux.setDefaults();
proxylinux.init();
remserv.init();
sv.init();
sb=new SettingsBean();
......