Commit d27f4cd8 d27f4cd89508b48c58c231764a74c4429fe88293 by root

save

1 parent f386613f
Showing 46 changed files with 356 additions and 325 deletions
......@@ -30,7 +30,6 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
......
......@@ -136,7 +136,7 @@
<dependency>
<groupId>org.emercit</groupId>
<artifactId>utilstools</artifactId>
<version>1.2</version>
<version>1.3</version>
</dependency>
</dependencies>
......
74c6c5b63f8da617444229f8115ec1bd
\ No newline at end of file
adffdb38630255374c6e833e66beb25472a984fe
\ 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.3</version>
</project>
322188dde72994362c060bd891722a5f
\ No newline at end of file
3af39bb14b1b7340a0a316a5f8f7168b8e114b6b
\ No newline at end of file
......@@ -3,12 +3,13 @@
<groupId>org.emercit</groupId>
<artifactId>utilstools</artifactId>
<versioning>
<release>1.2</release>
<release>1.3</release>
<versions>
<version>1.0</version>
<version>1.1</version>
<version>1.2</version>
<version>1.3</version>
</versions>
<lastUpdated>20150729141622</lastUpdated>
<lastUpdated>20150730083754</lastUpdated>
</versioning>
</metadata>
......
257acae17b94e3780bb730b4a34a7be6
\ No newline at end of file
f694c82e4fbd3e4132fed50768c031e6
\ No newline at end of file
......
a822e807f8f47856f57c62d6d43e7213053d06d9
\ No newline at end of file
500d42766cac423c8bf0bbead4ea70c1483b96f8
\ No newline at end of file
......
......@@ -11,7 +11,9 @@
</appender>
<appender name="file" class="org.apache.log4j.FileAppender">
<param name="File" value="/var/log/devtools.log" />
<param name="File" value="/var/log/devtools.log" />
<param name="MaxFileSize" value="10KB"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-7p %d [%t] %c %x - %m%n"/>
</layout>
......
......@@ -9,10 +9,10 @@ import java.io.FileOutputStream;
import org.apache.log4j.Logger;
import org.emercit.devinfo.model.DevInfoBean;
import org.emercit.utilstools.config.DefSettings;
import org.emercit.utilstools.config.Msg;
import org.emercit.utilstools.config.Paths;
import org.emercit.xmldbmanager.service.Db;
import org.emercit.projecttools.constants.Paths;
import org.emercit.projecttools.constants.Msg;
public class DevInfo implements IDevInfo {
......@@ -22,7 +22,7 @@ public class DevInfo implements IDevInfo {
private DevInfoBean devinfobean;
public Msg set(DevInfoBean m) {
public int set(DevInfoBean m) {
return db.create(m);
}
......@@ -32,11 +32,11 @@ public class DevInfo implements IDevInfo {
}
public Msg init() {
public int init() {
devinfobean=new DevInfoBean();
devinfobean.setDescription("Описание устройства");
devinfobean.setGuid("00000000-0000-0000-0000-000000000000");
devinfobean.setDescription(DefSettings.DevInfo_Description);
devinfobean.setGuid(DefSettings.DevInfo_Guid);
return set(devinfobean);
......
......@@ -7,16 +7,15 @@ import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.emercit.projecttools.constants.Msg;
import org.emercit.utilstools.config.Msg;
import org.emercit.devinfo.model.DevInfoBean;
public interface IDevInfo {
public Msg set(DevInfoBean m);
public int set(DevInfoBean m);
public DevInfoBean get();
public Msg init();
public int init();
}
......
package org.emercit.displaycalibrator.service;
import org.emercit.projecttools.constants.Msg;
import org.emercit.utilstools.config.Msg;
public interface DCalibrator {
public Msg Run(String cmd);
public int Run(String cmd);
}
......
......@@ -10,7 +10,7 @@ import java.util.Vector;
import org.apache.log4j.Logger;
import org.emercit.devinfo.service.DevInfo;
import org.emercit.pckutils.cmd.CmdExec;
import org.emercit.projecttools.constants.Msg;
import org.emercit.utilstools.config.Msg;
public class DCalibratorBB implements DCalibrator {
......@@ -21,7 +21,7 @@ public class DCalibratorBB implements DCalibrator {
//Run("/home/debian/start-xinput-config.sh");
public Msg Run(String cmd) {
public int Run(String cmd) {
try {
Vector<String> params=cmdExec.Run(cmd);
......@@ -44,12 +44,12 @@ public class DCalibratorBB implements DCalibrator {
}
bw.close();
log.info(Msg.CalibrSucc);
return Msg.CalibrSucc;
log.info(Msg.CalibrSucc.getDescription());
return Msg.CalibrSucc.getCode();
}catch(Exception e) {
log.error(Msg.CalibrError);
return Msg.CalibrError;
log.error(e.getMessage());
return Msg.CalibrError.getCode();
}
}
......
......@@ -8,8 +8,9 @@ import java.util.Vector;
import org.apache.log4j.Logger;
import org.emercit.dnsmanager.model.DnsBean;
import org.emercit.pckutils.cmd.CmdExec;
import org.emercit.utilstools.config.DefSettings;
import org.emercit.utilstools.config.Msg;
public class DnsLinux implements IDns{
......@@ -22,21 +23,17 @@ public class DnsLinux implements IDns{
private DnsBean db;
public void Add (String value){
public int Add (String value){
dbs=getAllDns();
db=new DnsBean();
db.setIp(value);
dbs.add(db);
Config(dbs);
return Config(dbs);
}
public void Delete(String value) {
public int Delete(String value) {
dbs=getAllDns();
for (DnsBean db:dbs) {
......@@ -46,21 +43,16 @@ public class DnsLinux implements IDns{
break;
}
}
Config(dbs);
return Config(dbs);
}
public boolean Update(Vector<DnsBean> beans) {
public int Update(Vector<DnsBean> beans) {
return Config(beans);
}
public Vector<DnsBean> getAllDns() {
dbs=new Vector<DnsBean>();
......@@ -77,16 +69,14 @@ public class DnsLinux implements IDns{
dbs.add(db);
i++;
}
log.info(Msg.LoadFileSucc);
} catch(Exception e) {
log.error(e.getMessage());
}
return dbs;
}
public boolean Config(Vector<DnsBean> dbs) {
public int Config(Vector<DnsBean> dbs) {
try {
File file = new File("/etc/resolv.conf");
......@@ -108,26 +98,23 @@ public class DnsLinux implements IDns{
}
bw.close();
return true;
log.info(Msg.SaveFileSucc.getDescription());
return Msg.SaveFileSucc.getCode();
} catch (IOException e) {
log.error(e.getMessage());
return Msg.SaveFileError.getCode();
}
return false;
}
public void init() {
public int init() {
dbs=new Vector<DnsBean>();
db=new DnsBean();
db.setIp("8.8.8.8");
db.setIp(DefSettings.Dns_host);
dbs.add(db);
Config(dbs);
return Config(dbs);
}
......
......@@ -6,16 +6,11 @@ import java.util.Vector;
public interface IDns {
public void Add (String value);
public void Delete(String value);
public boolean Config(Vector<DnsBean> dbs);
public int Add (String value);
public int Delete(String value);
public int Config(Vector<DnsBean> dbs);
public Vector<DnsBean> getAllDns();
public void init();
public int init();
}
......
package org.emercit.dtmanager.service;
public interface INtp {
public String getUseNtpServer();
public boolean setUsNtpServer(String value);
public void init();
public String getUseNtpServer();
public int setUsNtpServer(String value);
public int init();
}
......
......@@ -5,27 +5,30 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.emercit.pckutils.cmd.CmdExec;
import org.emercit.utilstools.config.Msg;
import org.emercit.utilstools.config.DefSettings;
public class NtpLinux implements INtp {
private static final Logger log = Logger.getLogger(NtpLinux.class);
private CmdExec cmdexec=new CmdExec();
public String getUseNtpServer() {
try {
return cmdexec.Run("cat /etc/ntp.conf | grep server | awk '{print $2}'").firstElement();
try {
return cmdexec.Run("cat /etc/ntp.conf | grep server | awk '{print $2}'").firstElement();
}catch(Exception e) {
log.error(e.getMessage());
return null;
}
}
public boolean setUsNtpServer(String value) {
public int setUsNtpServer(String value) {
try {
File file = new File("/etc/ntp.conf");
......@@ -58,16 +61,17 @@ public class NtpLinux implements INtp {
bw.write("\n");
bw.close();
log.info(Msg.SaveFileSucc.getDescription());
} catch (IOException e) {
return false;
log.error(e.getMessage());
return Msg.SaveFileError.getCode();
}
return true;
return Msg.SaveFileError.getCode();
}
public void init() {
setUsNtpServer("127.0.0.1");
public int init() {
return setUsNtpServer(DefSettings.Ntp_host);
}
......
......@@ -2,18 +2,15 @@ package org.emercit.ethmanager.service;
import org.apache.log4j.Logger;
import org.emercit.ethmanager.model.EthBean;
import java.util.Vector;
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import org.emercit.utilstools.config.Paths;
import org.emercit.utilstools.config.DefSettings;
import org.emercit.utilstools.config.Msg;
import org.emercit.xmldbmanager.service.Db;
import org.emercit.projecttools.constants.Paths;
import org.emercit.pckutils.cmd.CmdExec;
public class EthLinux implements IEth {
......@@ -22,7 +19,6 @@ public class EthLinux implements IEth {
private CmdExec cmdexec=new CmdExec();
private Vector<EthBean> ebs=new Vector<EthBean>();
private Db db=new Db(Paths.BEAN_ETH);
......@@ -31,8 +27,6 @@ public class EthLinux implements IEth {
private String mac;
private EthBean emp;
public EthLinux() {
......@@ -66,18 +60,13 @@ public class EthLinux implements IEth {
}
}
}catch(Exception e) {
log.error(e.getMessage());
}
return result;
}
public EthBean getEthByName(String name) {
ebs=(Vector<EthBean>)db.select();
......@@ -106,20 +95,17 @@ public class EthLinux implements IEth {
}
return eb;
}catch(Exception e) {
log.error(e.getMessage());
}
}
}
return null;
}
public boolean Update(EthBean m) {
public int Update(EthBean m) {
ebs=(Vector<EthBean>)db.select();
......@@ -136,17 +122,12 @@ public class EthLinux implements IEth {
break;
}
}
Config(ebs);
return true;
}
return Config(ebs);
}
private void Config(Vector<EthBean> ebs) {
private int Config(Vector<EthBean> ebs) {
try {
File file = new File("/etc/network/interfaces");
......@@ -199,16 +180,16 @@ public class EthLinux implements IEth {
bw.close();
db.create(ebs);
return db.create(ebs);
} catch (IOException e) {
log.error(e.getMessage());
return Msg.SaveFileError.getCode();
}
}
public void setDefaults() {
public int setDefaults() {
ebs=(Vector<EthBean>)db.select();
......@@ -218,38 +199,35 @@ public class EthLinux implements IEth {
ebs=new Vector<EthBean>();
EthBean NewEb=new EthBean();
//Eth0
NewEb.setName("eth0");
NewEb.setBroadcast("");
NewEb.setDhcp(false);
NewEb.setIp("192.168.99.1");
NewEb.setNetmask("255.255.255.0");
NewEb.setGateway("192.168.99.2");
NewEb.setName(DefSettings.Eth0_name);
NewEb.setBroadcast(DefSettings.Eth0_broadcast);
NewEb.setDhcp(DefSettings.Eth1_dhcp);
NewEb.setIp(DefSettings.Eth0_ip);
NewEb.setNetmask(DefSettings.Eth0_netmask);
NewEb.setGateway(DefSettings.Eth0_gateway);
NewEb.setInfo(v);
NewEb.setId(0);
NewEb.setId(DefSettings.Eth0_id);
ebs.add(NewEb);
//Eth1
NewEb=new EthBean();
NewEb.setName("eth1");
NewEb.setDhcp(true);
NewEb.setIp("");
NewEb.setNetmask("");
NewEb.setGateway("");
NewEb.setBroadcast("");
NewEb.setMac("");
NewEb.setId(1);
NewEb.setName(DefSettings.Eth1_name);
NewEb.setDhcp(DefSettings.Eth1_dhcp);
NewEb.setIp(DefSettings.Eth1_ip);
NewEb.setNetmask(DefSettings.Eth1_netmask);
NewEb.setGateway(DefSettings.Eth1_gateway);
NewEb.setBroadcast(DefSettings.Eth1_broadcast);
NewEb.setMac(DefSettings.Eth1_mac);
NewEb.setId(DefSettings.Eth1_id);
NewEb.setInfo(v);
ebs.add(NewEb);
}
Config(ebs);
return Config(ebs);
}
}
......
......@@ -6,14 +6,10 @@ import java.util.Vector;
import org.emercit.ethmanager.model.*;
public interface IEth {
public void setDefaults();
public boolean Update(EthBean m);
public int setDefaults();
public int Update(EthBean m);
public EthBean getEthByName(String name);
public Vector<String> getListEth();
}
......
package org.emercit.gsmmanager.service;
import org.emercit.gsmmanager.model.GSMBean;
import org.emercit.utilstools.config.Paths;
import org.emercit.xmldbmanager.service.Db;
import org.emercit.projecttools.constants.Paths;
import org.emercit.utilstools.config.DefSettings;
import org.emercit.utilstools.config.Paths;
import org.emercit.utilstools.config.Msg;
public class Gsm implements IGsm {
......@@ -15,19 +17,19 @@ public class Gsm implements IGsm {
return (GSMBean)db.select();
}
public boolean set(GSMBean m) {
return db.create(m);
public int set(GSMBean m) {
return db.create(m);
}
/*
* Создание нового файла с параметрами - defaults
* @see org.emercit.gsmmanager.service.IGsm#init()
*/
public void init() {
public int init() {
m=new GSMBean();
m.setOperator("megafon");
db.create(m);
return db.create(m);
}
......
......@@ -5,12 +5,6 @@ import org.emercit.gsmmanager.model.GSMBean;
public interface IGsm {
public GSMBean get();
public boolean set(GSMBean m);
public void init();
public int set(GSMBean m);
public int init();
}
......
package org.emercit.logreader;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.Vector;
import org.emercit.utilstools.config.Paths;
public class Reader {
public Vector<String> read() {
Vector<String> result=new Vector<String>();
FileInputStream fis = null;
BufferedReader reader = null;
try {
fis = new FileInputStream(Paths.UTILSTOOLS_LOGFILE);
reader = new BufferedReader(new InputStreamReader(fis));
String line = reader.readLine();
while(line != null){
System.out.println(line);
line = reader.readLine();
}
} catch (FileNotFoundException ex) {
Logger.getLogger(Reader.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Reader.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
reader.close();
fis.close();
} catch (IOException ex) {
Logger.getLogger(Reader.class.getName()).log(Level.SEVERE, null, ex);
}
}
return result;
}
}
/**
*
*/
/**
* @author root
*
*/
package org.emercit.logreader;
\ No newline at end of file
package org.emercit.pckutils.checkservice;
import org.emercit.pckutils.cmd.CmdExec;
import org.emercit.projecttools.constants.Paths;
import org.emercit.utilstools.config.Paths;
import java.util.Vector;
......@@ -14,9 +13,7 @@ public class STService {
public boolean IsRun(String service) throws Exception {
Vector<String> values=cmd.Run(Paths.FINDPROCESS_SCRIPT+" "+service);
return Boolean.valueOf(values.firstElement());
}
}
......
......@@ -26,13 +26,11 @@ public class CmdExec {
Process proc = run.exec(new String[]{"/bin/sh", "-c",cmd});
proc.waitFor();
BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
while(br.ready()) {
while(br.ready()) {
String message=br.readLine();
v.add(message);
log.info(message);
}
return v;
}
}
\ No newline at end of file
......
......@@ -2,11 +2,7 @@ package org.emercit.proxymanager.service;
public interface IProxy {
public void ApplyConfig (String p, Object v);
public void InfoByName(String name);
public void init();
public int init();
......
......@@ -5,16 +5,16 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Vector;
import org.apache.log4j.Logger;
import org.emercit.proxymanager.model.ProxyBean;
import org.emercit.utilstools.config.Paths;
import org.emercit.utilstools.config.Msg;
import org.emercit.utilstools.config.DefSettings;
import org.emercit.xmldbmanager.service.Db;
import org.emercit.projecttools.constants.Paths;
public class ProxyLinux {
public class ProxyLinux implements IProxy {
private static final Logger log = Logger.getLogger(ProxyLinux.class);
......@@ -24,8 +24,6 @@ public class ProxyLinux {
private boolean found;
private Object obj;
private ProxyBean pmp;
......@@ -43,9 +41,8 @@ public class ProxyLinux {
public Vector<ProxyBean> getProxyBeans() {
return (Vector<ProxyBean>)db.select();
}
public void Config(Vector<ProxyBean> pbs) {
public int Config(Vector<ProxyBean> pbs) {
try {
File file = new File("/etc/environment");
......@@ -71,67 +68,52 @@ public class ProxyLinux {
}
bw.write("\n");
bw.close();
db.create(pbs);
return db.create(pbs);
} catch (IOException e) {
log.error(e.getMessage());
return Msg.SaveFileError.getCode();
}
}
public void init() {
public int init() {
pbs= new Vector<ProxyBean>();
//HTTP PROXY
pmp=new ProxyBean();
pmp.setEnabled(false);
pmp.setProtocol("http");
pmp.setHost("127.0.0.1");
pmp.setPort(3632);
pmp.setLogin("root");
pmp.setPass("root");
pmp.setUseAuth(false);
pmp=new ProxyBean();
pmp.setEnabled(DefSettings.Proxy_http_enabled);
pmp.setProtocol(DefSettings.Proxy_http_protocol);
pmp.setHost(DefSettings.Proxy_http_host);
pmp.setPort(DefSettings.Proxy_http_port);
pmp.setLogin(DefSettings.Proxy_http_login);
pmp.setPass(DefSettings.Proxy_http_pass);
pmp.setUseAuth(DefSettings.Proxy_http_useauth);
pbs.add(pmp);
//HTTPS PROXY
pmp=new ProxyBean();
pmp.setEnabled(false);
pmp.setProtocol("https");
pmp.setHost("127.0.0.1");
pmp.setPort(3632);
pmp.setLogin("root");
pmp.setPass("root");
pmp.setUseAuth(false);
pmp.setEnabled(DefSettings.Proxy_https_enabled);
pmp.setProtocol(DefSettings.Proxy_https_protocol);
pmp.setHost(DefSettings.Proxy_https_host);
pmp.setPort(DefSettings.Proxy_https_port);
pmp.setLogin(DefSettings.Proxy_https_login);
pmp.setPass(DefSettings.Proxy_https_pass);
pmp.setUseAuth(DefSettings.Proxy_https_useauth);
pbs.add(pmp);
//FTP PROXY
pmp=new ProxyBean();
pmp.setEnabled(false);
pmp.setProtocol("ftp");
pmp.setHost("127.0.0.1");
pmp.setPort(3632);
pmp.setLogin("root");
pmp.setPass("root");
pmp.setUseAuth(false);
pmp.setEnabled(DefSettings.Proxy_ftp_enabled);
pmp.setProtocol(DefSettings.Proxy_ftp_protocol);
pmp.setHost(DefSettings.Proxy_ftp_host);
pmp.setPort(DefSettings.Proxy_ftp_port);
pmp.setLogin(DefSettings.Proxy_ftp_login);
pmp.setPass(DefSettings.Proxy_ftp_pass);
pmp.setUseAuth(DefSettings.Proxy_ftp_useauth);
pbs.add(pmp);
Config(pbs);
return Config(pbs);
}
......
......@@ -6,13 +6,10 @@ import java.util.Vector;
import org.emercit.servers.model.ServerBean;
public interface IServers {
public Vector<ServerBean> get();
public boolean set(Vector<ServerBean> beans);
public void init();
public int set(Vector<ServerBean> beans);
public int init();
}
......
......@@ -11,8 +11,9 @@ import java.io.FileInputStream;
import org.apache.log4j.Logger;
import org.emercit.servers.model.ServerBean;
import org.emercit.servers.service.IServers;
import org.emercit.utilstools.config.Paths;
import org.emercit.utilstools.config.DefSettings;
import org.emercit.xmldbmanager.service.Db;
import org.emercit.projecttools.constants.Paths;
public class Servers implements IServers {
......@@ -20,35 +21,32 @@ public class Servers implements IServers {
private Db db=new Db(Paths.BEAN_REMOTESERVER);
public boolean set(Vector<ServerBean> beans) {
public int set(Vector<ServerBean> beans) {
return db.create(beans);
}
public Vector<ServerBean> get() {
return (Vector<ServerBean>)db.select();
}
public void init() {
Vector<ServerBean> beans=new Vector<ServerBean>();
ServerBean rsb=new ServerBean();
public int init() {
rsb.setId(1);
rsb.setIp("127.0.0.1");
rsb.setPort(80);
rsb.setName("");
rsb.setType("szs");
rsb.setTitle("");
beans.add(rsb);
set(beans);
}
Vector<ServerBean> beans=new Vector<ServerBean>();
ServerBean rsb=new ServerBean();
rsb.setId(DefSettings.Server_id);
rsb.setIp(DefSettings.Server_ip);
rsb.setPort(DefSettings.Server_port);
rsb.setName(DefSettings.Server_name);
rsb.setType(DefSettings.Server_type);
rsb.setTitle(DefSettings.Server_title);
beans.add(rsb);
return set(beans);
}
}
......
......@@ -6,11 +6,11 @@ import java.util.Vector;
public interface ISv {
public void set(Vector<SvBean> m);
public int set(Vector<SvBean> m);
public Vector<SvBean> get();
public void init();
public int init();
}
......
......@@ -2,15 +2,10 @@ package org.emercit.svmanager.service;
public interface ISvControl {
public boolean start();
public boolean stop();
public boolean restart();
public boolean addAutoRun();
public boolean delAutoRun();
public int start();
public int stop();
public int restart();
public int addAutoRun();
public int delAutoRun();
}
......
......@@ -4,9 +4,8 @@ import java.util.Vector;
import org.emercit.svmanager.model.SvBean;
import org.emercit.xmldbmanager.service.Db;
import org.emercit.projecttools.constants.Paths;
import org.emercit.svmanager.service.SvControl;
import org.emercit.utilstools.config.Paths;
public class Sv {
......@@ -19,9 +18,9 @@ public class Sv {
private SvControl svcontrol;
public void set(Vector<SvBean> m) {
public int set(Vector<SvBean> m) {
db.create(m);
return db.create(m);
}
public Vector<SvBean> get() {
......@@ -29,7 +28,7 @@ public class Sv {
return (Vector<SvBean>)db.select();
}
public void init() {
public int init() {
svbeans=new Vector<SvBean>();
......@@ -49,7 +48,7 @@ public class Sv {
svbean.setIsrun(true);
svbeans.add(svbean);
set(svbeans);
int res=set(svbeans);
for (SvBean sv:svbeans ) {
......@@ -61,5 +60,6 @@ public class Sv {
svcontrol.delAutoRun();
}
}
return res;
}
}
......
......@@ -2,8 +2,8 @@ package org.emercit.svmanager.service;
import org.emercit.pckutils.cmd.CmdExec;
import org.emercit.projecttools.constants.Paths;
import org.emercit.utilstools.config.Paths;
import org.emercit.utilstools.config.Msg;
public class SvControl implements ISvControl {
......@@ -16,39 +16,39 @@ public class SvControl implements ISvControl {
this.process=process;
}
public boolean stop() {
public int stop() {
try { cmdexec.Run(Paths.dirInit_d+" "+process+" "+"stop"); }catch(Exception e) { return false; };
try { cmdexec.Run(Paths.dirInit_d+" "+process+" "+"stop"); }catch(Exception e) { return Msg.ProcessStopError.getCode(); };
return true;
return Msg.ProcessStopSucc.getCode();
}
public boolean start() {
public int start() {
try { cmdexec.Run(Paths.dirInit_d+process+" "+"start"); }catch(Exception e) { return false; };
try { cmdexec.Run(Paths.dirInit_d+process+" "+"start"); }catch(Exception e) { return Msg.ProcessStartError.getCode(); };
return true;
return Msg.ProcessStartSucc.getCode();
}
public boolean restart() {
public int restart() {
try { cmdexec.Run(Paths.dirInit_d+process+" "+"restart"); }catch(Exception e) { return false; };
try { cmdexec.Run(Paths.dirInit_d+process+" "+"restart"); }catch(Exception e) { return Msg.ProcessRestartError.getCode(); };
return true;
return Msg.ProcessRestartSucc.getCode();
}
public boolean addAutoRun() {
public int addAutoRun() {
try { cmdexec.Run("update-rc.d "+process+" default"); }catch(Exception e) { return false; };
try { cmdexec.Run("update-rc.d "+process+" default"); }catch(Exception e) { return Msg.ProcessAddAutoRunError.getCode(); };
return true;
return Msg.ProcessAddAutoRunSucc.getCode();
}
public boolean delAutoRun() {
public int delAutoRun() {
try { cmdexec.Run("update-rc.d -f "+process+" remove"); }catch(Exception e) { return false; };
try { cmdexec.Run("update-rc.d -f "+process+" remove"); }catch(Exception e) { return Msg.ProcessDelAutoRunError.getCode(); };
return true;
return Msg.ProcessDelAutoRunSucc.getCode();
}
......
package org.emercit.projecttools.constants;
package org.emercit.utilstools.config;
import java.util.Vector;
import org.emercit.proxymanager.model.ProxyBean;
public class DefSettings {
//DevInfo
......@@ -33,11 +35,38 @@ public class DefSettings {
public static final String Eth1_extinfo="";
//GSM
public static final String gsm_operator="megafon";
//PROXY HTTP
public static final String Proxy_http_protocol="http";
public static final String Proxy_http_host="127.0.0.1";
public static final int Proxy_http_port=3612;
public static final String Proxy_http_login="user";
public static final String Proxy_http_pass="user";
public static final boolean Proxy_http_enabled=false;
public static final boolean Proxy_http_useauth=false;
//PROXY HTTPS
public static final String Proxy_https_protocol="https";
public static final String Proxy_https_host="127.0.0.1";
public static final int Proxy_https_port=3612;
public static final String Proxy_https_login="user";
public static final String Proxy_https_pass="user";
public static final boolean Proxy_https_enabled=false;
public static final boolean Proxy_https_useauth=false;
//PROXY FTP
public static final String Proxy_ftp_protocol="ftp";
public static final String Proxy_ftp_host="127.0.0.1";
public static final int Proxy_ftp_port=3612;
public static final String Proxy_ftp_login="user";
public static final String Proxy_ftp_pass="user";
public static final boolean Proxy_ftp_enabled=false;
public static final boolean Proxy_ftp_useauth=false;
//REMOTE SERVERS
public static final int Server_id=0;
public static final String Server_name="Локальный сервер";
public static final String Server_ip="127.0.0.1";
public static final int Server_port=80;
public static final String Server_type="СЗС";
public static final String Server_title="";
}
......
package org.emercit.projecttools.constants;
package org.emercit.utilstools.config;
import org.emercit.projecttools.constants.TypeMsg;
import org.emercit.utilstools.config.TypeMsg;
public enum Msg {
......@@ -16,11 +16,24 @@ public enum Msg {
CalibrSucc(7,TypeMsg.INFO,"Выполнена калибровка экрана"),
CalibrError(8,TypeMsg.ERROR,"Калибровка экрана не выполнена"),
InitSucc(9,TypeMsg.INFO,"Выполнена инициализация"),
InitError(10,TypeMsg.ERROR,"Инициализация не выполнена");
InitError(10,TypeMsg.ERROR,"Инициализация не выполнена"),
ProcessStopSucc(11,TypeMsg.INFO,"Выполнена остановка процесса"),
ProcessStopError(12,TypeMsg.ERROR,"Ошибка при выполнении остановки процесса"),
ProcessStartSucc(13,TypeMsg.INFO,"Выполнена остановка процесса"),
ProcessStartError(14,TypeMsg.ERROR,"Ошибка при выполнеии запуска процесса"),
ProcessRestartSucc(15,TypeMsg.INFO,"Выполнена перезагрузка процесса"),
ProcessRestartError(16,TypeMsg.ERROR,"Ошибка при перезагрузки процесса"),
ProcessAddAutoRunSucc(17,TypeMsg.INFO,"Процесс успешно добалвен в автозагрузку"),
ProcessDelAutoRunSucc(18,TypeMsg.INFO,"Процесс удален из автозагрузки"),
ProcessAddAutoRunError(19,TypeMsg.INFO,"Ошибка при добавлении процесса в автозагрузку"),
ProcessDelAutoRunError(20,TypeMsg.INFO,"Ошибка при удалении процесса из автозагрузки");
private int code;
......@@ -50,8 +63,8 @@ public enum Msg {
public TypeMsg getTypeVariable() {
return this.type;
}
public TypeMsg getDescription() {
return this.type;
public String getDescription() {
return this.description;
}
......
package org.emercit.projecttools.constants;
package org.emercit.utilstools.config;
public class Paths {
......@@ -22,5 +22,7 @@ public class Paths {
//PROCESS
public static final String JETTY="jetty";
public static final String CTRLPNL="ctrlpnl";
public static final String UTILSTOOLS_LOGFILE="/var/log/devtools.log";
}
......
package org.emercit.projecttools.constants;
package org.emercit.utilstools.config;
public enum TypeMsg implements TypeVariable {
......
package org.emercit.projecttools.constants;
package org.emercit.utilstools.config;
public interface TypeVariable {};
\ No newline at end of file
......
/**
*
*/
/**
* @author root
*
*/
package org.emercit.utilstools.config;
\ No newline at end of file
......@@ -2,20 +2,14 @@ package org.emercit.utilstools.service;
import java.util.Vector;
import org.emercit.utilstools.config.Msg;
import org.emercit.utilstools.model.SettingsBean;
import org.emercit.projecttools.constants.Msg;
public interface ISettings {
//public SettingsBean get();
public Msg set(SettingsBean bean);
public boolean configuring(SettingsBean model);
public int set(SettingsBean bean);
public void configuring(SettingsBean model);
public SettingsBean make();
public void init();
public int init();
}
......
......@@ -2,15 +2,12 @@ package org.emercit.utilstools.service;
import java.util.Vector;
import org.emercit.utilstools.config.Msg;
import org.emercit.utilstools.config.Paths;
import org.emercit.utilstools.model.SettingsBean;
import org.emercit.xmldbmanager.service.Db;
import org.emercit.projecttools.constants.Paths;
import org.emercit.dtmanager.model.DateInfo;
import org.emercit.ethmanager.model.EthBean;
import org.emercit.devinfo.service.DevInfo;
import org.emercit.dnsmanager.service.DnsLinux;
import org.emercit.dtmanager.service.NtpLinux;
......@@ -20,7 +17,8 @@ import org.emercit.proxymanager.service.ProxyLinux;
import org.emercit.servers.service.Servers;
import org.emercit.svmanager.service.Sv;
import org.emercit.projecttools.constants.Msg;
import org.emercit.utilstools.config.Msg;
public class Settings implements ISettings {
......@@ -54,7 +52,7 @@ public class Settings implements ISettings {
}
*/
public Msg set(SettingsBean bean) {
public int set(SettingsBean bean) {
return db.create(bean);
}
......@@ -63,7 +61,7 @@ public class Settings implements ISettings {
* Применение конфигурации из карты настроек
* @see org.emercit.utilstools.service.ISettings#configuring()
*/
public boolean configuring(SettingsBean model) {
public void configuring(SettingsBean model) {
devinfo.set(model.getDevInfoBean());
dnslinux.Config(model.getDnsbeans());
......@@ -80,10 +78,11 @@ public class Settings implements ISettings {
proxylinux.Config(model.getProxyBeans());
remserv.set(model.getRserverbeans());
return true;
}
public SettingsBean make() {
......@@ -110,7 +109,7 @@ public class Settings implements ISettings {
}
public void init(){
public int init(){
devinfo.init();
dnslinux.init();
......@@ -124,9 +123,8 @@ public class Settings implements ISettings {
sb=make();
set(sb);
return set(sb);
}
......
......@@ -9,8 +9,8 @@ import java.io.FileOutputStream;
import org.apache.log4j.Logger;
import org.emercit.devinfo.service.DevInfo;
import org.emercit.projecttools.constants.Paths;
import org.emercit.projecttools.constants.Msg;
import org.emercit.utilstools.config.Msg;
import org.emercit.utilstools.config.Paths;
public class Db implements IDb {
......@@ -26,7 +26,7 @@ public class Db implements IDb {
* Создает или перезаписывает сущетсвующий файл
* @see org.emercit.xmldbmanager.service.IDb#create(java.lang.Object)
*/
public Msg create(Object o) {
public int create(Object o) {
boolean result=true;
try {
......@@ -35,10 +35,12 @@ public class Db implements IDb {
XMLEncoder xmlEncoder = new XMLEncoder(bos);
xmlEncoder.writeObject(o);
xmlEncoder.close();
log.error(Msg.SaveFileSucc.getDescription());
}catch(Exception e) {
return Msg.SaveFileError;
log.error(e.getMessage());
return Msg.SaveFileError.getCode();
}
return Msg.SaveFileSucc;
return Msg.SaveFileSucc.getCode();
}
......@@ -53,10 +55,10 @@ public class Db implements IDb {
new FileInputStream(pathfile)));
Object result=(Object)d.readObject();
d.close();
log.error(Msg.LoadFileSucc);
log.info(Msg.LoadFileSucc.getDescription());
return result;
}catch(Exception e) {
log.error(Msg.LoadFileError);
log.error(e.getMessage());
return null;
}
}
......
package org.emercit.xmldbmanager.service;
import org.emercit.projecttools.constants.Msg;
import org.emercit.utilstools.config.Msg;
public interface IDb {
public Msg create(Object obj);
public int create(Object obj);
public Object select();
......