First Commit - Source Code from Reply

This commit is contained in:
vincenzofariello
2024-05-13 12:54:14 +02:00
parent 73e32a5020
commit a15aee1f08
11184 changed files with 1065913 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
package conf;
import java.util.*;
import java.io.*;
public class CanaleVenditaBit {
private static List canaliVendita= new ArrayList();
public CanaleVenditaBit() {
}
public static String getNextDescrizioneCanaleVendita(){
Random randomGen= new Random();
int numCan= canaliVendita.size();
int indice = randomGen.nextInt(numCan+1);
if(indice==0)
indice=1;
if(indice==numCan)
indice=numCan-1;
String canale = (String)canaliVendita.get(indice);
return canale;
}
static {
BufferedReader br;
String path = System.getProperty("canaliVenditaBIT_file", "");
if (path == null || path.length() == 0) {
System.out.println("ERRORE NELLE VARIABILI DI AMBIENTE DELLA JVM. MANCA IL PARAMETRO 'canaliVenditaBIT_file'");
} else {
try {
File f = new File(path);
if (f.exists()) {
br = new BufferedReader(new FileReader(f));
String fileLine;
while ( (fileLine = br.readLine()) != null) {
canaliVendita.add(fileLine);
}
}
}catch (FileNotFoundException e) {
System.err.println("Impossibile trovare il file d'inizializzazione per Canali Vendita BIT : " + System.getProperty("canaliVenditaBIT_file", ""));
System.err.println("Tutti i sistemi conosciuti daranno codice e descrizione vuoti!");
}catch (IOException ex) {
System.err.println("Errore di lettura durante l'inizializzazione!");
}
}
}
}

View File

@@ -0,0 +1,114 @@
/*
* Created on Feb 11, 2005
*
* MNP [project sim]
* Copyright (c) 2005
*
* @author Giovanni Amici
* @version 1.0
*/
package conf;
import java.util.Properties;
/**
* @author Giovanni
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class FTPProperties {
/**
* @return Returns the hostname.
*/
public static String getHostname() {
return hostname;
}
/**
* @param hostname The hostname to set.
*/
public static void setHostname(String hostname) {
FTPProperties.hostname = hostname;
}
/**
* @return Returns the password.
*/
public static String getPassword() {
return password;
}
/**
* @param password The password to set.
*/
public static void setPassword(String password) {
FTPProperties.password = password;
}
/**
* @return Returns the username.
*/
public static String getUsername() {
return username;
}
/**
* @param username The username to set.
*/
public static void setUsername(String username) {
FTPProperties.username = username;
}
static FTPProperties _instance = null;
static private String hostname;
static private String username;
static private String password;
//private Vector _listaDirectory = new Vector();
private FTPProperties() {
try {
loadFileProperties();
//createDefaultDirectory();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public static FTPProperties getInstance() {
if (_instance == null)
_instance = new FTPProperties();
return _instance;
}
/**
* Carica le proprietà
* @throws Exception
*/
private void loadFileProperties() throws Exception {
Properties properties = SimConfFile.getInstance().ReadSection("FTP");
setHostname(properties.getProperty("hostname"));
setUsername(properties.getProperty("username"));
setPassword(properties.getProperty("password"));
//setTxmode(properties.getProperty("txmode"));
}
}

View File

@@ -0,0 +1,95 @@
/*
* Created on Feb 4, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package conf;
import java.io.File;
import java.util.Properties;
import java.util.Vector;
/**
* @author Giovanni
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class GeneralProperties {
static GeneralProperties _instance = null;
static private String _PATH_TEST;
static private String _PATH_TEST_UPCO;
private Vector _listaDirectory = new Vector();
private GeneralProperties() {
try {
loadFileProperties();
createDefaultDirectory();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public static GeneralProperties getInstance() {
if (_instance == null)
_instance = new GeneralProperties();
return _instance;
}
/**
* Carica le proprietà
* @throws Exception
*/
private void loadFileProperties() throws Exception {
Properties properties = SimConfFile.getInstance().ReadSection("BIT");
set_PATH_TEST(properties.getProperty("test"));
set_PATH_TEST_UPCO(get_PATH_TEST() + "/" + properties.getProperty("nameDirBIT"));
//set_PATH_TEST_CU(get_PATH_TEST() + "/" + properties.getProperty("nameDirCU"));
//set_PATH_TEST_BIT(get_PATH_TEST() + "/" + properties.getProperty("nameDirBIT"));
loadListaDirectory();
}
/**
* Carica la lista delle directory
*/
private void loadListaDirectory() {
_listaDirectory.addElement(get_PATH_TEST());
_listaDirectory.addElement(get_PATH_TEST_UPCO());
}
/**
* Crea le directory in cui salvare i file creati
*/
private void createDefaultDirectory() {
for (int i = 0; i < _listaDirectory.size(); i++) {
String nameDir = (String) _listaDirectory.elementAt(i);
if (! (new File(nameDir).exists())) {
boolean success = new File(nameDir).mkdir();
if (!success)
System.out.println("Errore nella creazione della directory: " + nameDir);
}
}
}
public String get_PATH_TEST() {
return _PATH_TEST;
}
public void set_PATH_TEST(String __PATH_TEST) {
_PATH_TEST = __PATH_TEST;
}
public String get_PATH_TEST_UPCO() {
return _PATH_TEST_UPCO;
}
public void set_PATH_TEST_UPCO(String __PATH_TEST_UPCO) {
_PATH_TEST_UPCO = __PATH_TEST_UPCO;
}
}

View File

@@ -0,0 +1,639 @@
package conf;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Properties;
/**
* <b><p>Description:</b><br>
* JIniFile stores and retrieves application-specific information and settings from INI files.
* <br><br>
* JIniFile enables handling the storage and retrieval of application-specific information
* and settings in a standard INI file. The INI file text format is a standard introduced
* in Windows 3.x for storing and retrieving application settings from session to session.
* An INI file stores information in logical groupings, called "sections." For example,
* the WIN.INI file contains a section called "[Desktop]". Within each section, actual data
* values are stored in named keys. Keys take the form:
* <br><br>
* &lt;keyname&gt;=&lt;value&gt;<br>
* A FileName is passed to the JIniFile constructor and identifies the INI file that the object accesses.</p>
* @author Andreas Norman
* @version 1.0
*
*/
public class JIniFile extends ArrayList {
private File userFileName;
//private static Logger logger = Logger.getLogger("phco.init");
/**
* Constructor JIniFile
*
* Creates a JIniFile object for an application. Create assigns the FileName parameter
* to the FileName property, which is used to specify the name of the INI file to use.
* <p>
* <b>Note:</b> By default the INI files are stored in the Application directory. To work with an INI file in another
* location, specify the full path name of the file in FileName.
*/
public JIniFile(String name) {
System.out.println("ini-file LOADING " + name);
clear();
this.userFileName = new File(name);
if (userFileName.exists()) {
System.out.println("ini-file READING ");
try {
BufferedReader inbuf = new BufferedReader(new FileReader(this.userFileName));
while (true) {
String s = inbuf.readLine();
if (s == null) {
break;
}
add(s);
}
inbuf.close();
System.out.println("ini-file READING OK");
} catch ( IOException ex ) {
System.out.println("ini-file FILE " + name + " reading exception: " + ex);
}
} else {
System.out.println("ini-file FILE " + name + " DOES NOT EXIST");
}
}
/**
* Call ReadSections to retrieve the names of all sections in the INI file into an ArrayList object.
*
* @return an ArrayList holding the sections
*
*/
public ArrayList ReadSections() {
ArrayList list = new ArrayList();
String s;
for (int i=0; i < size(); i++) {
s = get(i).toString();
if (s.startsWith("[") && s.endsWith("]")) {
list.add(s.substring(1,(s.length()-1)));
}
}
return list;
}
/**
* Call UpdateFile to flush buffered reads from and writes to the INI file to disk.
*
* @return returns <code>true</code> if sucessful
*
*/
public boolean UpdateFile() {
try {
BufferedWriter outbuf = new BufferedWriter(new FileWriter(this.userFileName.toString(), false));
int i=0;
while (i<size()) {
String s = get(i).toString();
if (s == null) {
break;
}
outbuf.write(s);
outbuf.newLine();
i++;
}
outbuf.close();
return true;
} catch ( IOException ioe ) {
return false;
}
}
/**
* Call ReadString to read a string value from an INI file. Section identifies the
* section in the file that contains the desired key. key is the name of the key
* from which to retrieve the value. defaultValue is the string value to return if the:<br>
* - Section does not exist.<br>
* - Key does not exist.<br>
* - Data value for the key is not assigned.<br>
*
* @param Section the section name
* @param key the key name
* @param defaultValue default value if no value is found
*
* @return returns the value. If empty or nonexistent it will return the default value
*
*/
public String ReadString(String Section, String key, String defaultValue) {
String value=defaultValue;
if (ValuePosition(Section, key) > 0) {
int strLen = key.length()+1;
value = get(ValuePosition(Section, key)).toString().substring(strLen, get(ValuePosition(Section, key)).toString().length());
}
return value;
}
public String ReadStringRemapped(String Section, String key, String defaultValue, JIniFile remapFile) {
String value=defaultValue;
if (ValuePosition(Section, key) > 0) {
int strLen = key.length()+1;
String realValue = get(ValuePosition(Section, key)).toString().substring(strLen, get(ValuePosition(Section, key)).toString().length());
if ((realValue != null) && (realValue.length() > 0)) {
value=remapFile.ReadString(key, realValue, defaultValue);
}
}
return value;
}
/**
* Call ReadSectionValues to read the keys, and the values from all keys, within a specified
* section of an INI file into an ArrayList object. Section identifies the section in the file
* from which to read key values.
*
* @param Section the section name
*
* @return an ArrayList holding the values in the specified section.
*
*/
public ArrayList ReadSectionValues(String Section) {
ArrayList myList = new ArrayList();
int start = this.SectionPosition(Section)+1;
String s;
if (this.SectionPosition(Section) > -1) {
for (int i=start; i < size(); i++) {
s = get(i).toString().substring(get(i).toString().indexOf("=")+1, get(i).toString().length());
if (s.startsWith("[") && s.endsWith("]")) {
break;
} else {
myList.add(s);
}
}
}
return myList;
}
/**
* Call ReadSection to read the keys, and the values from all keys, within a specified
* section of an INI file into an Properties object. Section identifies the section in the file
* from which to read key-value pairs.
*
* @param Section the section name
*
* @return a Properties holding the key-value pairs in the specified section.
*
*/
public Properties ReadSection(String Section) {
Properties myList = new Properties();
int start = this.SectionPosition(Section)+1;
String line,key="",val="";
if (this.SectionPosition(Section) > -1) {
for (int i=start; i < size(); i++) {
line = get(i).toString();
if (line.startsWith("[") && line.endsWith("]")) {
break;
}
else if((!line.equals(""))&&(line.indexOf("=")!=-1)){
val = line.substring(line.indexOf("=")+1, line.length());
key = line.substring(0,line.indexOf("="));
myList.setProperty(key,val);
}
}
}
return myList;
}
/**
* Call ReadSection to read the keys, and the values from all keys, within a specified
* section of an INI file into an Properties object. Section identifies the section in the file
* from which to read key-value pairs.
*
* @param Section the section name
*
* @return a ArrayList holding the key-value pairs in sequence key1,value1,key2,value2 etc.
*
*/
public ArrayList ReadSectionAsArray(String Section) {
ArrayList myList = new ArrayList();
int start = this.SectionPosition(Section)+1;
String line,key="",val="";
if (this.SectionPosition(Section) > -1) {
for (int i=start; i < size(); i++) {
line = get(i).toString();
if (line.startsWith("[") && line.endsWith("]")) {
break;
}
else if((!line.equals(""))&&(line.indexOf("=")!=-1)){
val = line.substring(line.indexOf("=")+1, line.length());
key = line.substring(0,line.indexOf("="));
myList.add(key);
myList.add(val);
}
}
}
return myList;
}
public String ReturnSectionAsString(String Section){
String line,res="";
int start = this.SectionPosition(Section)+1;
if (this.SectionPosition(Section) > -1) {
for (int i=start; i < size(); i++) {
line = get(i).toString();
if (line.startsWith("[") && line.endsWith("]")) {
break;
}
else res=res+line;
}
}
return res;
}
/**
* Call ReadInteger to read a string value from an INI file. Section identifies the
* section in the file that contains the desired key. key is the name of the key
* from which to retrieve the value. defaultValue is the integer value to return if the:<br>
* - Section does not exist.<br>
* - Key does not exist.<br>
* - Data value for the key is not assigned.<br>
*
* @param Section the section name
* @param key the key name
* @param defaultValue default value if no value is found
*
* @return returns the value. If empty or nonexistent it will return the default value
*
*/
public int ReadInteger(String Section, String key, int defaultValue) {
int value=defaultValue;
if (ValuePosition(Section, key) > 0) {
int strLen = key.length()+1;
value = Integer.parseInt(get(ValuePosition(Section, key)).toString().substring(strLen, get(ValuePosition(Section, key)).toString().length()));
}
return value;
}
/**
* Call ReadFloat to read a string value from an INI file. Section identifies the
* section in the file that contains the desired key. key is the name of the key
* from which to retrieve the value. defaultValue is the float value to return if the:<br>
* - Section does not exist.<br>
* - Key does not exist.<br>
* - Data value for the key is not assigned.<br>
*
* @param Section the section name
* @param key the key name
* @param defaultValue default value if no value is found
*
* @return returns the value. If empty or nonexistent it will return the default value
*
*/
public Float ReadFloat(String Section, String key, Float defaultValue) {
Float value = new Float(0f);
value = defaultValue;
if (ValuePosition(Section, key) > 0) {
int strLen = key.length()+1;
value = Float.valueOf(get(ValuePosition(Section, key)).toString().substring(strLen, get(ValuePosition(Section, key)).toString().length()));
}
return value;
}
/**
* Call Readbool to read a string value from an INI file. Section identifies the
* section in the file that contains the desired key. key is the name of the key
* from which to retrieve the value. defaultValue is the boolean value to return if the:<br>
* - Section does not exist.<br>
* - Key does not exist.<br>
* - Data value for the key is not assigned.<br>
*
* @param Section the section name
* @param key the key name
* @param defaultValue default value if no value is found
*
* @return returns the value. If empty or nonexistent it will return the default value
*
*/
public boolean ReadBool(String Section, String key, boolean defaultValue) {
boolean value=defaultValue;
if (ValuePosition(Section, key) > 0) {
int strLen = key.length()+1;
value = Boolean.getBoolean(get(ValuePosition(Section, key)).toString().substring(strLen, get(ValuePosition(Section, key)).toString().length()));
}
return value;
}
/**
* SectionExists is used internally to determine the position of a section within the INI file
* specified in FileName.
* <p>
* Section is the INI file section SectionExists determines the position of.
* <p>
* SectionExists returns an Integer value that indicates the position of the section in question.
*
* @param Section the section name
*
* @return will return the position of the section. Returns -1 not found.
*
*/
private int SectionPosition(String Section) {
String s;
int pos = -1;
for (int i=0; i < size(); i++) {
s = get(i).toString();
if (s.equals("["+Section+"]")) {
pos = i;
break;
}
}
return pos;
}
/**
* Use SectionExists to determine whether a section exists within the INI file specified in FileName.
* <p>
* Section is the INI file section SectionExists determines the existence of.
* <p>
* SectionExists returns a Boolean value that indicates whether the section in question exists.
*
* @param Section the section name
*
* @return returns <code>true</code> if the section exists.
*
*/
public boolean SectionExist(String Section) {
String s;
boolean val = false;
for (int i=0; i < size(); i++) {
s = get(i).toString();
if (s.equals("["+Section+"]")) {
val = true;
break;
}
}
return val;
}
/**
* Call EraseSection to remove a section, all its keys, and their data values from
* an INI file. Section identifies the INI file section to remove.
*
* @param Section the section name
*
*/
public void EraseSection(String Section) {
String s;
int start = this.SectionPosition(Section)+1;
if (this.SectionPosition(Section) > -1) {
for (int i=start; i < size(); i++) {
s = get(i).toString();
if (s.startsWith("[") && s.endsWith("]")) {
break;
} else {
remove(i);
i--;
}
}
remove(this.SectionPosition(Section));
}
}
/**
* Call ReadSection to retrieve the names of all keys within a specified section of an
* INI file into an ArrayList object.
*
* @param Section the section name
*
* @return an ArrayList holding all key names.
*
*/
public ArrayList ReadSectionKeys(String Section) {
String s;
ArrayList myList = new ArrayList();
int start = this.SectionPosition(Section)+1;
if (this.SectionPosition(Section) > -1) {
for (int i=start; i < size(); i++) {
s = get(i).toString();
if (s.startsWith("[") && s.endsWith("]")) {
break;
}
else if(s.compareTo("")==0){
continue;
}
else {
s=s.substring(0, s.indexOf("="));
myList.add(s);
}
}
}
return myList;
}
/**
* Use ValueExist to determine whether a key exists in the INI file specified in FileName.<br>
* Section is the section in the INI file in which to search for the key.<br>
* key is the name of the key to search for.<br>
* ValueExist returns a Boolean value that indicates whether the key exists in the specified section.<br>
*
* @param Section the section name
* @param key the key name
*
* @return returns <code>true</code> if value exists
*
*/
public boolean ValueExist(String Section, String key) {
int start = SectionPosition(Section);
String s;
boolean val = false;
int strLen = key.length()+1;;
for (int i=start+1; i < size(); i++) {
s = get(i).toString();
if (s.startsWith(key+"=")) {
val = true;
break;
} else if (s.startsWith("[") && s.endsWith("]")) {
break;
}
}
return val;
}
/**
* ValuePosition is used internally to determine the position of a in the INI file specified in FileName.
* <P>
* Section is the section in the INI file in which to search for the key.
* <P>
* key is the name of the key to search for.
* <P>
* ValuePosition returns an Integer value that indicates the position of the key in the INI file.
*
* @param Section the section name
* @param key the key name
*
* @return returns the position of the Value. If not found it will return -1
*
*/
private int ValuePosition(String Section, String key) {
int start = SectionPosition(Section);
String s;
int pos =-1;
int strLen = key.length()+1;;
for (int i=start+1; i < size(); i++) {
s = get(i).toString();
if (s.startsWith(key+"=")) {
pos = i;
break;
} else if (s.startsWith("[") && s.endsWith("]")) {
break;
}
}
return pos;
}
/**
* Call DeleteKey to erase an INI file entry. Section is string containing the name
* of an INI file section, and key is a string containing the name of the key from
* for which to set a nil value.
* <p>
* <b>Note:</b> Attempting to delete a key in a nonexistent section or attempting to delete a
* nonexistent key are not errors. In these cases, DeleteKey does nothing.
*
* @param Section the section name
* @param key the key name
*
*/
public void DeleteKey(String Section, String key) {
if (this.ValuePosition(Section, key) > 0) {
remove(this.ValuePosition(Section, key));
}
}
/**
* Call WriteString to write a string value to an INI file. Section identifies the section in the
* file that contain the key to which to write. key is the name of the key for which to set a value.
* value is the string value to write.
* <p>
* <b>Note:</b> Attempting to write a data value to a nonexistent section or attempting to write data to a nonexistent
* key are not errors. In these cases, WriteString creates the section and key and sets its initial value
* to value.
*
* @param Section the section name
* @param key the key name
* @param value the value
*
*/
public void WriteString(String Section, String key, String value) {
String s = key+"="+value;
this.addToList(Section, key, s);
}
/**
* Call WriteBool to write a boolean value to an INI file. Section identifies the section in the
* file that contain the key to which to write. key is the name of the key for which to set a value.
* value is the boolean value to write.
* <p>
* <b>Note:</b> Attempting to write a data value to a nonexistent section or attempting to write data to a nonexistent
* key are not errors. In these cases, WriteBool creates the section and key and sets its initial value
* to value.
*
* @param Section the section name
* @param key the key name
* @param value the value
*
*/
public void WriteBool(String Section, String key, Boolean value) {
String s = key+"="+value.toString();
this.addToList(Section, key, s);
}
/**
* Call WriteFloat to write a float value to an INI file. Section identifies the section in the
* file that contain the key to which to write. key is the name of the key for which to set a value.
* value is the float value to write.
* <p>
* <b>Note:</b> Attempting to write a data value to a nonexistent section or attempting to write data to a nonexistent
* key are not errors. In these cases, WriteFloat creates the section and key and sets its initial value
* to value.
*
* @param Section the section name
* @param key the key name
* @param value the value
*
*/
public void WriteFloat(String Section, String key, float value) {
String s = key+"="+Float.toString(value);
this.addToList(Section, key, s);
}
/**
* Call WriteInteger to write an integer value to an INI file. Section identifies the section in the
* file that contain the key to which to write. key is the name of the key for which to set a value.
* value is the integer value to write.
* <p>
* <b>Note:</b> Attempting to write a data value to a nonexistent section or attempting to write data to a nonexistent
* key are not errors. In these cases, WriteInteger creates the section and key and sets its initial value
* to value.
*
* @param Section the section name
* @param key the key name
* @param value the value
*
*/
public void WriteInteger(String Section, String key, int value) {
String s = key+"="+Integer.toString(value);
this.addToList(Section, key, s);
}
/**
* addToList is used internally to add values to the INI file specified in FileName.
* <p>
* Section is the section in the INI file in which to search for the key.
* <p>
* key is the name of the key to search for.
* <p>
* value is the name of the value to write
* <p>
* <b>Note:</b> Attempting to write a data value to a nonexistent section or attempting to write data to a nonexistent
* key are not errors. In these cases, addToList creates the section and key and sets its initial value
* to value.
*
* @param Section the section name
* @param key the key name
* @param value the value
*
*/
private void addToList(String Section, String key, String value) {
if (this.SectionExist((Section))) {
if (this.ValueExist(Section, key)) {
int pos = this.ValuePosition(Section, key);
remove(pos);
add(pos, value);
} else {
add(/*(this.SectionPosition(Section)+1) l'ho tolto io!!!!*/value);
}
} else {
add("["+Section+"]");
add(value);
}
}
public void addSpace(){
add("");
}
}

View File

@@ -0,0 +1,76 @@
package conf;
import java.util.*;
import java.io.*;
/**
* <p>Title: Simulatori sistema MNP</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: TeleAp</p>
* @author Ambra Parati
* @version 1.0
*/
public class MSSProperties {
static private String _PATH_TEST = null;
static private String _PATH_TEST_MSS = null;
static MSSProperties _instance = null;
private MSSProperties() {
try {
loadFileProperties();
createDefaultDirectory();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public static MSSProperties getInstance() {
if (_instance == null)
_instance = new MSSProperties();
return _instance;
}
/**
* Carica le proprietà
* @throws Exception
*/
private void loadFileProperties() throws Exception {
Properties properties = SimConfFile.getInstance().ReadSection("MSS");
set_PATH_TEST(properties.getProperty("test"));
set_PATH_TEST_MSS(get_PATH_TEST() + "/" + properties.getProperty("nameDirMSS"));
}
/**
* Crea la directory su cui salvare il file
*/
private void createDefaultDirectory() {
String nameDir = (String) get_PATH_TEST_MSS();
if (! (new File(nameDir).exists())) {
boolean success = new File(nameDir).mkdir();
if (!success)
System.out.println("Errore nella creazione della directory: " + nameDir);
}
}
public String get_PATH_TEST() {
return _PATH_TEST;
}
public void set_PATH_TEST(String _PATH_TEST) {
this._PATH_TEST = _PATH_TEST;
}
public void set_PATH_TEST_MSS(String _PATH_TEST_MSS) {
this._PATH_TEST_MSS = _PATH_TEST_MSS;
}
public String get_PATH_TEST_MSS() {
return _PATH_TEST_MSS;
}
}

View File

@@ -0,0 +1,54 @@
package conf;
import java.util.Properties;
public class PitagoraProperties {
static PitagoraProperties _instance = null;
static private String _PATH_TEST;
static private String _PATH_TEST_NOTIFICA;
public String get_PATH_TEST_NOTIFICA() {
return _PATH_TEST_NOTIFICA;
}
public void set_PATH_TEST(String _PATH_TEST) {
this._PATH_TEST = _PATH_TEST;
}
public void set_PATH_TEST_NOTIFICA(String _PATH_TEST_NOTIFICA) {
this._PATH_TEST_NOTIFICA = _PATH_TEST_NOTIFICA;
}
public String get_PATH_TEST() {
return _PATH_TEST;
}
private PitagoraProperties() {
try {
loadFileProperties();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public static PitagoraProperties getInstance() {
if (_instance == null)
_instance = new PitagoraProperties();
return _instance;
}
/**
* Carica le proprietà
* @throws Exception
*/
private void loadFileProperties() throws Exception {
Properties properties = SimConfFile.getInstance().ReadSection("NOTIFICAZIONE PITAGORA");
set_PATH_TEST(properties.getProperty("test"));
set_PATH_TEST_NOTIFICA(get_PATH_TEST() + "/" + properties.getProperty("notifica") + "/");
}
}

View File

@@ -0,0 +1,252 @@
package conf;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Random;
import java.util.Set;
import java.util.Vector;
/**
* @author Melec
*
*/
public class ProfiliTariffari {
private static Hashtable[] profili = {new Hashtable(), new Hashtable(), new Hashtable()};
private static Random random = new Random(System.currentTimeMillis());
private static Set profiliSet = new HashSet(), profiliComplessiSet = new HashSet();
private static String[] profiloTariffario = {""};
private static String[] splittedLine(String line) {
String[] fields = line.split("\t");
Vector vTemp = new Vector();
for (int i = 0; i < fields.length; i++) {
//decommentare se si vuole evitare codice(o descrizione) null associato a descrizione(o codice) non null
//if (fields[i].length() != 0) {
vTemp.add(fields[i]);
//}
}
return (String[]) vTemp.toArray(new String[]{});
}
private static String[] Validate(String[] terna) {
// controlla innanzitutto che la lunghezza sia >= 3;
if (terna == null)
return new String[]{"","",""};
switch (terna.length) {
case 0: return new String[]{"","",""};
case 1: return new String[]{terna[0], "", ""};
// coppie di cui uno tra codice e descrizione può essere null
case 2: return new String[]{terna[0], terna[1], ""};
default :return new String[]{terna[0], terna[1], terna[2]};
// coppie di cui entrambi i membri della coppia sono null
//case 2: return new String[]{terna[0], "", ""};
//default :
// if (terna[1].length() == 0 || terna[2].length == 0)
// return new String[]{terna[0], "", ""};
// return new String[]{terna[0], terna[1], terna[2]};
}
}
// INIZIALIZZAZIONE
static {
profiliSet.add("MSC");
profiliSet.add("MSP");
// profiliSet.add("SID");
profiliSet.add("BIT");
profiliSet.add("MSPCOOP");
profiliComplessiSet.add("BIT");
BufferedReader br;
String path = System.getProperty("profiliTariffari_file", "");
if (path == null || path.length() == 0) {
System.out.println("ERRORE NELLE VARIABILI DI AMBIENTE DELLA JVM. MANCA IL PARAMETRO 'profiliTariffari_file'");
System.out.println("Tutti i sistemi conosciuti forniranno codice e descrizione vuoti!");
} else {
try {
File f = new File(path);
if (f.exists()) {
br = new BufferedReader(new FileReader(f));
String fileLine;
while ((fileLine = br.readLine()) != null) {
fileLine = fileLine.trim();
if (fileLine.length() != 0 && !fileLine.startsWith("#")) {
String[] fileFields = splittedLine(fileLine);
fileFields = Validate(fileFields);
if (profiliSet.contains(fileFields[0])) {
setCoupleValues(fileFields, 0);
} else if (profiliComplessiSet.contains(fileFields[0].substring(0, fileFields[0].length() - 2))) {
if (fileFields[0].endsWith("AC")) {
setCoupleValues(fileFields, 2);
} else if (fileFields[0].endsWith("OF")) {
setCoupleValues(fileFields, 1);
}
}
}
}
} else {
System.err.println("Impossibile trovare il file d'inizializzazione per ProfiliTariffari : " + System.getProperty("profiliTariffari_file", ""));
System.err.println("Tutti i sistemi conosciuti daranno codice e descrizione vuoti!");
}
} catch (FileNotFoundException e) {
System.err.println("Impossibile trovare il file d'inizializzazione per ProfiliTariffari : " + System.getProperty("profiliTariffari_file", ""));
System.err.println("Tutti i sistemi conosciuti daranno codice e descrizione vuoti!");
} catch (IOException e) {
System.err.println("Errore di lettura durante l'inizializzazione!");
}
}
}
//restituisce l'iesimo elemento dell'array profiloTariffario se esiste; altrimeni stringa vuota
private static String get(int index) {
if (profiloTariffario.length > index)
return profiloTariffario[index];
return "";
}
/**
* @return il codice del profilo tariffario
*/
public static String getCodiceProfilo() {
return get(0);
}
/**
* @return la descrizione associata al profilo tariffario
*/
public static String getDescrizioneProfilo() {
return get(1);
}
/**
* @return il codice dell'offerta
*/
public static String getCodiceOfferta() {
return get(2);
}
/**
* @return la descrizione dell'offerta
*/
public static String getDescrizioneOfferta() {
return get(3);
}
/**
* @return il codice dell'accordo
*/
public static String getCodiceAccordo() {
return get(4);
}
/**
* @return la descrizione dell'accordo
*/
public static String getDescrizioneAccordo() {
return get(5);
}
/**
* inserisce nell'hashtable corrispondente la coppia codice-descrizione
* Le chiavi dell'hashtable sono i sistemi (BIT, MSC, etc.)
* Le coppie sono memorizzate all'interno di un Vector come array di 2 String.
*/
private static void setCoupleValues(String[] values, int index) {
String key = values[0];
if (index > 0)
key = key.substring(0, key.length() - 2);
Vector vettore = (Vector) profili[index].get(key);
if (vettore == null) {
vettore = new Vector();
}
vettore.add(new String[] {values[1], values[2]});
profili[index].put(key, vettore);
}
/**
* inserisce nell'hashtable corrispondente la coppia codice-descrizione
* Le chiavi dell'hashtable sono i sistemi (BIT, MSC, etc.)
* Le coppie sono memorizzate all'interno di un Vector come array di 2 String.
*/
private static String[] getCodiceDescr(Vector coppiaCodiceDescr) {
if (coppiaCodiceDescr == null || coppiaCodiceDescr.size() == 0)
return new String[]{"",""};
else
return (String[]) coppiaCodiceDescr.elementAt(random.nextInt(coppiaCodiceDescr.size()));
}
/**
* @param type: il tipo di profilo da generare (SID, MSP, MSC, BIT)
* @return un array di stringhe contenenti i dati di un un profilo del tipo specificato.
*/
public static String[] nextProfiloTariffario(String type) {
String[] profilo;
if (profiliComplessiSet.contains(type)) {
profilo = new String[6];
String[] tmp = getCodiceDescr((Vector) profili[0].get(type));
boolean profiloNull = ("".equals(tmp[0]) && "".equals(tmp[1]));
for (int i = 1; i < 4; i++) {
profilo[2 * (i - 1)] = tmp[0];
profilo[2 * i - 1] = tmp[1];
if (!profiloNull && i <3)
tmp = getCodiceDescr((Vector) profili[i].get(type));
}
} else if (profiliSet.contains(type)) {
System.out.println("TYPE: " + type);
profilo = getCodiceDescr((Vector) profili[0].get(type));
} else {
profiloTariffario = new String[] {"","","","","",""};
throw new RuntimeException("Sistema Mittente sconosciuto : " + type);
}
return (String[]) (profiloTariffario = profilo).clone();
}
public static void main(String[] args) {
for (int x = 0; x < 3; x++) {
Enumeration ens = profili[x].keys();
while (ens.hasMoreElements()) {
String s = (String) ens.nextElement();
Vector ss = (Vector) profili[x].get(s);
System.out.println(s);
for (int i = 0; i < ss.size(); i++) {
String[] sss = (String[])ss.elementAt(i);
System.out.print("\t\t");
for (int j = 0; j < sss.length; j++) {
System.out.print("|" + sss[j] + "|\t");
}
System.out.println();
}
System.out.println();
}
}
for (int i = 0; i < 50; i++) {
double r = Math.random();
String sist = (r < 0.24) ? "MSP" : ((r < 0.48) ? "MSC" : ((r < 0.72) ? "BIT" : ((r < 0.9) ? "SID" : "XXX")));
try {
String[] s = nextProfiloTariffario(sist);
System.out.print(sist);
/*for (int j = 0; j < s.length; j++) {
System.out.print("\t" + s[j]);
}*/
System.out.println("CODICE PROFILO :" + getCodiceProfilo()+"; DESCRIZIONE " + getDescrizioneProfilo());
System.out.println("CODICE ACCORDO :" + getCodiceAccordo()+"; DESCRIZIONE " + getDescrizioneAccordo());
System.out.println("CODICE OFFERTA :" + getCodiceOfferta()+"; DESCRIZIONE " + getDescrizioneOfferta());
System.out.println();
System.out.println(sist + "\t" + getCodiceProfilo() + "\t" + getDescrizioneProfilo() + "\t" + getCodiceOfferta() + "\t" + getDescrizioneOfferta() + "\t" + getCodiceAccordo() + "\t" + getDescrizioneAccordo());
} catch (Exception rte) {
System.err.println(rte.getMessage());
}
}
}
}

View File

@@ -0,0 +1,30 @@
/*
* Created on Jan 25, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package conf;
/**
* @author Giovanni
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class SimConfFile {
/**
* Ritorna un'istanza della classe
* @return PropertiesDefault
*/
public static JIniFile _instance =null;
public static JIniFile getInstance() {
if (_instance == null) {
String filepath = System.getProperty("sim_conf_file","");
_instance = new JIniFile(filepath);
}
return _instance;
}
}

View File

@@ -0,0 +1,282 @@
package conf;
import java.io.*;
import java.util.*;
import org.omg.Security.SecEstablishTrustPolicy;
public class XMLProperties {
static private String _URL = null;
static private String _PATH_TEST = null;
static private String _PATH_TEST_ACK = null;
static private String _PATH_TEST_ATTIVAZIONE = null;
static private String _PATH_TEST_ATTIVAZIONE_HOC = null;
static private String _PATH_TEST_VALIDAZIONE = null;
static private String _PATH_TEST_PORTING = null;
static private String _PATH_TEST_PRESAINCARICO = null;
static private String _PATH_TEST_ESPLETAMENTO = null;
static private String _PATH_TEST_CESSAZIONE = null;
static private String _PATH_TEST_TC = null;
static private String _PATH_TEST_SBLOCCO_IMPORTO_TC = null;
static private String _PATH_TEST_SBLOCCO_CREDITO_ANOMALO_TC = null;
static boolean INTERNAL_HTTPS_FLAG=false;
static boolean INTERNAL_SSL_FLAG=false;
static String SSL_KEYSTORE= null;
static String SSL_PRIVATEKEY_ALIAS= null;
static String SSL_PRIVATEKEY_ALIAS_PWD= null;
static XMLProperties _instance = null;
private Vector _listaDirectory = new Vector();
/**
* Carica il file di properties e crea le directory in cui scrivere i file
*/
private XMLProperties() {
try {
loadFileProperties();
createDefaultDirectory();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* Ritorna un'istanza della classe
* @return PropertiesDefault
*/
public static XMLProperties getInstance() {
if (_instance == null)
_instance = new XMLProperties();
return _instance;
}
/**
* Carica il file di properties
* @throws Exception
*/
private void loadFileProperties() throws Exception {
Properties properties = SimConfFile.getInstance().ReadSection("XML");
set_URL(properties.getProperty("url"));
set_PATH_TEST(properties.getProperty("test"));
set_PATH_TEST_ACK(get_PATH_TEST() + "/" + properties.getProperty("nameDirAck"));
set_PATH_TEST_ATTIVAZIONE(get_PATH_TEST() + "/" + properties.getProperty("nameDirAttivazione"));
set_PATH_TEST_ATTIVAZIONE_HOC(get_PATH_TEST() + "/" + properties.getProperty("nameDirAttivazioneHOC"));
set_PATH_TEST_PRESAINCARICO(get_PATH_TEST() + "/" + properties.getProperty("nameDirPresaincarico"));
set_PATH_TEST_VALIDAZIONE(get_PATH_TEST() + "/" + properties.getProperty("nameDirValidazione"));
set_PATH_TEST_ESPLETAMENTO(get_PATH_TEST() + "/" + properties.getProperty("nameDirEspletamento"));
set_PATH_TEST_PORTING(get_PATH_TEST() + "/" + properties.getProperty("nameDirPorting"));
set_PATH_TEST_CESSAZIONE(get_PATH_TEST() + "/" + properties.getProperty("nameDirCessazione"));
set_PATH_TEST_TC(get_PATH_TEST() + "/" + properties.getProperty("nameDirTrasferimentoCredito"));
set_PATH_TEST_SBLOCCO_CREDITO_ANOMALO_TC(get_PATH_TEST() + "/" + properties.getProperty("nameDirSbloccoImporto"));
set_PATH_TEST_SBLOCCO_IMPORTO_TC(get_PATH_TEST() + "/" + properties.getProperty("nameDirSbloccoCreditoAnomalo"));
setINTERNAL_HTTPS_FLAG( new Boolean(properties.getProperty("INTERNAL_HTTPS_FLAG")).booleanValue());
setINTERNAL_SSL_FLAG( new Boolean(properties.getProperty("INTERNAL_SSL_FLAG")).booleanValue());
setSSL_KEYSTORE( properties.getProperty("SSL_KEYSTORE"));
setSSL_PRIVATEKEY_ALIAS( properties.getProperty("SSL_PRIVATEKEY_ALIAS"));
setSSL_PRIVATEKEY_ALIAS_PWD( properties.getProperty("SSL_PRIVATEKEY_ALIAS_PWD"));
loadListaDirectory();
}
/**
* Carica la lista delle directory
*/
private void loadListaDirectory() {
_listaDirectory.addElement(get_PATH_TEST());
_listaDirectory.addElement(get_PATH_TEST_ACK());
_listaDirectory.addElement(get_PATH_TEST_ATTIVAZIONE());
_listaDirectory.addElement(get_PATH_TEST_ATTIVAZIONE_HOC());
_listaDirectory.addElement(get_PATH_TEST_VALIDAZIONE());
_listaDirectory.addElement(get_PATH_TEST_PORTING());
_listaDirectory.addElement(get_PATH_TEST_PRESAINCARICO());
_listaDirectory.addElement(get_PATH_TEST_ESPLETAMENTO());
_listaDirectory.addElement(get_PATH_TEST_CESSAZIONE());
_listaDirectory.addElement(get_PATH_TEST_TC());
_listaDirectory.addElement(get_PATH_TEST_SBLOCCO_CREDITO_ANOMALO_TC());
_listaDirectory.addElement(get_PATH_TEST_SBLOCCO_IMPORTO_TC());
}
/**()
* Crea le directory in cui salvare i file creati
*/
private void createDefaultDirectory() {
for (int i = 0; i < _listaDirectory.size(); i++) {
String nameDir = (String) _listaDirectory.elementAt(i);
if (! (new File(nameDir).exists())) {
boolean success = new File(nameDir).mkdir();
if (!success)
System.out.println("Errore nella creazione della directory: " + nameDir);
}
}
}
public void set_PATH_TEST_ACK(String _PATH_TEST_ACK) {
this._PATH_TEST_ACK = _PATH_TEST_ACK;
}
public String get_PATH_TEST_ATTIVAZIONE() {
return _PATH_TEST_ATTIVAZIONE;
}
public void set_PATH_TEST_ATTIVAZIONE(String _PATH_TEST_ATTIVAZIONE) {
this._PATH_TEST_ATTIVAZIONE = _PATH_TEST_ATTIVAZIONE;
}
public String get_PATH_TEST_ATTIVAZIONE_HOC() {
return _PATH_TEST_ATTIVAZIONE_HOC;
}
public void set_PATH_TEST_ATTIVAZIONE_HOC(String _PATH_TEST_ATTIVAZIONE_HOC) {
this._PATH_TEST_ATTIVAZIONE_HOC = _PATH_TEST_ATTIVAZIONE_HOC;
}
public String get_PATH_TEST_CESSAZIONE() {
return _PATH_TEST_CESSAZIONE;
}
public void set_PATH_TEST_CESSAZIONE(String _PATH_TEST_CESSAZIONE) {
this._PATH_TEST_CESSAZIONE = _PATH_TEST_CESSAZIONE;
}
public String get_PATH_TEST_ESPLETAMENTO() {
return _PATH_TEST_ESPLETAMENTO;
}
public void set_PATH_TEST_ESPLETAMENTO(String _PATH_TEST_ESPLETAMENTO) {
this._PATH_TEST_ESPLETAMENTO = _PATH_TEST_ESPLETAMENTO;
}
public String get_PATH_TEST_PORTING() {
return _PATH_TEST_PORTING;
}
public void set_PATH_TEST_PORTING(String _PATH_TEST_PORTING) {
this._PATH_TEST_PORTING = _PATH_TEST_PORTING;
}
public String get_PATH_TEST_PRESAINCARICO() {
return _PATH_TEST_PRESAINCARICO;
}
public void set_PATH_TEST_PRESAINCARICO(String _PATH_TEST_PRESAINCARICO) {
this._PATH_TEST_PRESAINCARICO = _PATH_TEST_PRESAINCARICO;
}
public String get_PATH_TEST_VALIDAZIONE() {
return _PATH_TEST_VALIDAZIONE;
}
public void set_PATH_TEST_VALIDAZIONE(String _PATH_TEST_VALIDAZIONE) {
this._PATH_TEST_VALIDAZIONE = _PATH_TEST_VALIDAZIONE;
}
public String get_URL() {
return _URL;
}
public void set_URL(String _URL) {
this._URL = _URL;
}
public String get_PATH_TEST() {
return _PATH_TEST;
}
public void set_PATH_TEST(String _PATH_TEST) {
this._PATH_TEST = _PATH_TEST;
}
public String get_PATH_TEST_ACK() {
return _PATH_TEST_ACK;
}
/**
* @return Returns the iNTERNAL_HTTPS_FLAG.
*/
public static boolean isINTERNAL_HTTPS_FLAG() {
return INTERNAL_HTTPS_FLAG;
}
/**
* @param internal_https_flag The iNTERNAL_HTTPS_FLAG to set.
*/
public static void setINTERNAL_HTTPS_FLAG(boolean internal_https_flag) {
INTERNAL_HTTPS_FLAG = internal_https_flag;
}
/**
* @return Returns the iNTERNAL_SSL_FLAG.
*/
public static boolean isINTERNAL_SSL_FLAG() {
return INTERNAL_SSL_FLAG;
}
/**
* @param internal_ssl_flag The iNTERNAL_SSL_FLAG to set.
*/
public static void setINTERNAL_SSL_FLAG(boolean internal_ssl_flag) {
INTERNAL_SSL_FLAG = internal_ssl_flag;
}
/**
* @return Returns the sSL_KEYSTORE.
*/
public static String getSSL_KEYSTORE() {
return SSL_KEYSTORE;
}
/**
* @param ssl_keystore The sSL_KEYSTORE to set.
*/
public static void setSSL_KEYSTORE(String ssl_keystore) {
SSL_KEYSTORE = ssl_keystore;
}
/**
* @return Returns the sSL_PRIVATEKEY_ALIAS.
*/
public static String getSSL_PRIVATEKEY_ALIAS() {
return SSL_PRIVATEKEY_ALIAS;
}
/**
* @param ssl_privatekey_alias The sSL_PRIVATEKEY_ALIAS to set.
*/
public static void setSSL_PRIVATEKEY_ALIAS(String ssl_privatekey_alias) {
SSL_PRIVATEKEY_ALIAS = ssl_privatekey_alias;
}
/**
* @return Returns the sSL_PRIVATEKEY_ALIAS_PWD.
*/
public static String getSSL_PRIVATEKEY_ALIAS_PWD() {
return SSL_PRIVATEKEY_ALIAS_PWD;
}
/**
* @param ssl_privatekey_alias_pwd The sSL_PRIVATEKEY_ALIAS_PWD to set.
*/
public static void setSSL_PRIVATEKEY_ALIAS_PWD(String ssl_privatekey_alias_pwd) {
SSL_PRIVATEKEY_ALIAS_PWD = ssl_privatekey_alias_pwd;
}
/**
* @return the _PATH_TEST_SBLOCCO_CREDITO_ANOMALO_TC
*/
public String get_PATH_TEST_SBLOCCO_CREDITO_ANOMALO_TC() {
return _PATH_TEST_SBLOCCO_CREDITO_ANOMALO_TC;
}
/**
* @param _path_test_sblocco_credito_anomalo_tc the _PATH_TEST_SBLOCCO_CREDITO_ANOMALO_TC to set
*/
public void set_PATH_TEST_SBLOCCO_CREDITO_ANOMALO_TC(String _path_test_sblocco_credito_anomalo_tc) {
_PATH_TEST_SBLOCCO_CREDITO_ANOMALO_TC = _path_test_sblocco_credito_anomalo_tc;
}
/**
* @return the _PATH_TEST_SBLOCCO_IMPORTO_TC
*/
public String get_PATH_TEST_SBLOCCO_IMPORTO_TC() {
return _PATH_TEST_SBLOCCO_IMPORTO_TC;
}
/**
* @param _path_test_sblocco_importo_tc the _PATH_TEST_SBLOCCO_IMPORTO_TC to set
*/
public void set_PATH_TEST_SBLOCCO_IMPORTO_TC(String _path_test_sblocco_importo_tc) {
_PATH_TEST_SBLOCCO_IMPORTO_TC = _path_test_sblocco_importo_tc;
}
/**
* @return the _PATH_TEST_TC
*/
public String get_PATH_TEST_TC() {
return _PATH_TEST_TC;
}
/**
* @param _path_test_tc the _PATH_TEST_TC to set
*/
public void set_PATH_TEST_TC(String _path_test_tc) {
_PATH_TEST_TC = _path_test_tc;
}
}