First Commit - Source Code from Reply
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
package it.valueteam.crontab.config;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import it.valueteam.crontab.utility.*;
|
||||
import java.io.*;
|
||||
|
||||
public class ActivationInterval implements Serializable
|
||||
{
|
||||
private String id;
|
||||
private EventTime from;
|
||||
private EventTime to;
|
||||
|
||||
public ActivationInterval(EventTime from, EventTime to, String id)
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static Comparator activationIntervalComparator()
|
||||
{
|
||||
return new Comparator()
|
||||
{
|
||||
public int compare(Object o1, Object o2)
|
||||
{
|
||||
ActivationInterval a1 = (ActivationInterval) o1;
|
||||
ActivationInterval a2 = (ActivationInterval) o2;
|
||||
return (a1.before(a2))? -1: ((a1.after(a2))? 1: 0);
|
||||
}
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return this.getClass().getName().equals(o.getClass().getName());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isInWindowTime(EventTime event)
|
||||
{
|
||||
return (event.after(from) && event.before(to)) || event.equals(from);
|
||||
}
|
||||
|
||||
public boolean after(ActivationInterval wt)
|
||||
{
|
||||
return !isOverlapped(wt) && this.from.after(wt.to);
|
||||
}
|
||||
|
||||
public boolean before(ActivationInterval wt)
|
||||
{
|
||||
return !isOverlapped(wt) && this.to.before(wt.from);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
ActivationInterval wt = (ActivationInterval) obj;
|
||||
return (sameWindow(wt) && this.id.equals(wt.id));
|
||||
}
|
||||
|
||||
public boolean sameWindow(ActivationInterval wt)
|
||||
{
|
||||
return (this.from.equals(wt.from) && this.to.equals(wt.to));
|
||||
}
|
||||
|
||||
public boolean isOverlapped(ActivationInterval wt)
|
||||
{
|
||||
return (wt.from.after(this.to) && wt.to.after(this.to)) || (wt.from.before(this.from) && wt.to.before(this.from));
|
||||
}
|
||||
|
||||
public void setFrom(EventTime value)
|
||||
{
|
||||
this.from = value;
|
||||
}
|
||||
|
||||
public void setTo(EventTime value)
|
||||
{
|
||||
this.to = value;
|
||||
}
|
||||
|
||||
public EventTime getFrom()
|
||||
{
|
||||
return from;
|
||||
}
|
||||
|
||||
/*
|
||||
public EventTime getFrom(EventTime ref)
|
||||
{
|
||||
return from.getRelEvent(ref.get(Calendar.YEAR),
|
||||
ref.get(Calendar.MONTH),
|
||||
ref.get(Calendar.DATE));
|
||||
}
|
||||
*/
|
||||
public EventTime getTo()
|
||||
{
|
||||
return to;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
/*
|
||||
public EventTime getTo(EventTime ref)
|
||||
{
|
||||
return to.getRelEvent(ref.get(Calendar.YEAR),
|
||||
ref.get(Calendar.MONTH),
|
||||
ref.get(Calendar.DATE));
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
package it.valueteam.crontab.config;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import mnp.crontab.config.xml.*;
|
||||
import java.io.*;
|
||||
|
||||
public class ProcessInfo
|
||||
implements Serializable {
|
||||
|
||||
public static class BlockingProcessInfoRef
|
||||
implements Serializable {
|
||||
private String procID = null;
|
||||
|
||||
public BlockingProcessInfoRef(String procID) {
|
||||
this.procID = procID;
|
||||
}
|
||||
|
||||
public BlockingProcessInfoRef(BlockingProcessInfoRef depProcInfoRef) {
|
||||
this.procID = depProcInfoRef.getProcID();
|
||||
}
|
||||
|
||||
public String getProcID() {
|
||||
return this.procID;
|
||||
}
|
||||
|
||||
public void setProcID(String procID) {
|
||||
this.procID = procID;
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream ois) throws
|
||||
ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String desc;
|
||||
private String command;
|
||||
private String params;
|
||||
private String name;
|
||||
private boolean enabled;
|
||||
private TaskInfoList taskRefs = new TaskInfoList();
|
||||
// lista dei processi bloccanti
|
||||
// Array list di BlockingProcessInfoRef
|
||||
protected ArrayList blockingProcessList;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public String getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public boolean getEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEneabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setCommand(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setParams(String params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public ProcessInfo(ProcessDef procDef) {
|
||||
this.id = procDef.getID();
|
||||
this.name = procDef.getName();
|
||||
this.desc = procDef.getDesc();
|
||||
this.command = procDef.getComando();
|
||||
this.params = procDef.getParametri();
|
||||
this.enabled = procDef.getEnabled();
|
||||
this.blockingProcessList = new ArrayList();
|
||||
setBlockingDependentProcessList(procDef);
|
||||
}
|
||||
|
||||
public ProcessInfo(String id, String name, String desc, String command,
|
||||
String params, boolean enabled) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
this.command = command;
|
||||
this.params = params;
|
||||
this.enabled = enabled;
|
||||
this.blockingProcessList = new ArrayList();
|
||||
}
|
||||
|
||||
public ProcessInfo(ProcessInfo procInfo) {
|
||||
this.id = procInfo.id;
|
||||
this.name = procInfo.name;
|
||||
this.desc = procInfo.desc;
|
||||
this.command = procInfo.command;
|
||||
this.params = procInfo.params;
|
||||
this.enabled = procInfo.getEnabled();
|
||||
this.blockingProcessList = new ArrayList(procInfo.blockingProcessList);
|
||||
}
|
||||
|
||||
public boolean hasTaskRefs() {
|
||||
return (taskRefs != null) && (taskRefs.size() > 0);
|
||||
}
|
||||
|
||||
public void addTaskRef(TaskInfo taskInfo) {
|
||||
this.taskRefs.add(taskInfo);
|
||||
}
|
||||
|
||||
public void removeTaskRef(TaskInfo taskInfo) {
|
||||
this.taskRefs.remove(taskInfo);
|
||||
}
|
||||
|
||||
public TaskInfoList getTaskRefs() {
|
||||
return taskRefs;
|
||||
}
|
||||
|
||||
/*** Gestione dependent processList **/
|
||||
|
||||
/**
|
||||
* Imposta la lista dei processi associata dipendenti al processo a partire da una configurazione
|
||||
* @param task Task in configurazione
|
||||
* @param processTable Tabella dei processi
|
||||
*/
|
||||
private void setBlockingDependentProcessList(ProcessDef processDef) {
|
||||
String id = null;
|
||||
BlockingProcessListRefItem[] depProcListRef = null;
|
||||
/** per compatibilità con gli processDef.getBlockingProcessListRef()
|
||||
* potrebbe essere nullo
|
||||
*/
|
||||
if (processDef.getBlockingProcessListRef() != null)
|
||||
depProcListRef = processDef.getBlockingProcessListRef().
|
||||
getBlockingProcessListRefItem();
|
||||
else
|
||||
depProcListRef = new BlockingProcessListRefItem[0];
|
||||
for (int i = 0; i < depProcListRef.length; i++) {
|
||||
id = (String) depProcListRef[i].getBlockingProcessRef().getValue();
|
||||
addBlockingDependentProcess( (id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiunge un processo di cui questo processo è dipendente
|
||||
* @param processID String
|
||||
*/
|
||||
public void addBlockingDependentProcess(String processID) {
|
||||
blockingProcessList.add(new BlockingProcessInfoRef(processID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rimuove un processo dalla lista dei processi dipendenti
|
||||
* @param order numero di sequenza del processo da eliminare.
|
||||
*/
|
||||
public void removeBlockingProcess(String procID) {
|
||||
blockingProcessList.remove(procID);
|
||||
}
|
||||
|
||||
public void removeAllBlockingProcess() {
|
||||
blockingProcessList.clear();
|
||||
}
|
||||
|
||||
public ArrayList getBlockingProcessList() {
|
||||
return blockingProcessList;
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException,
|
||||
IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,335 @@
|
||||
package it.valueteam.crontab.config;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.exolab.castor.types.*;
|
||||
import it.valueteam.crontab.utility.EventTime;
|
||||
import mnp.crontab.config.xml.*;
|
||||
import mnp.crontab.config.xml.types.*;
|
||||
import mnp.crontab.utility.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>: </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Societ<65></b>: ObjectWay S.p.a.</p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*
|
||||
*
|
||||
*
|
||||
* variabili: every, lastStartTime, maxExecFromLastStart | StopEvent | lastStartTime
|
||||
* ------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* 0 0 0 | null | StartEvent
|
||||
* 0 0 1 | startEvent + maxExecFromLastStart | StartEvent
|
||||
* 0 1 1 | lastStartTime + maxExecFromLastStart | lastStartTime
|
||||
* 0 1 0 | null | lastStartTime
|
||||
* 1 0 0 | null | min(23:59, startEvent+every*num)
|
||||
* 1 0 1 | min(23:59, startEvent+every*num) + maxExecFromLastStart | min(23:59, startEvent+every*num)
|
||||
* 1 1 1 | lastStartTime + maxExecFromLastStart | lastSTartTime
|
||||
* 1 1 0 | null | lastSTartTime
|
||||
*
|
||||
*/
|
||||
|
||||
public class RegolaAttivazione implements Serializable {
|
||||
private String id = null;
|
||||
private String idRule = null;
|
||||
private Calendar startTime = null;
|
||||
private Calendar lastStartTime = null;
|
||||
private String startDayOfWeek = null; // null - non specificato
|
||||
private short startDayOfMonth = 0; // 0 - non specificato
|
||||
private int every = 0; // 0 - non periodico, da eseguire una sola volta
|
||||
private int maxExecFromLastStart = 0; // 0 - finestra temporale che non termina
|
||||
|
||||
public RegolaAttivazione() {
|
||||
this.id = Resources.getID_REGOLA_ATTIVAZIONE();
|
||||
}
|
||||
|
||||
public RegolaAttivazione(String idRule, String startDayOfWeek,
|
||||
short startDayOfMonth,
|
||||
short[] from, short[] lastStart, int every,
|
||||
int maxExecFromLastStart) {
|
||||
this.id = Resources.getID_REGOLA_ATTIVAZIONE();
|
||||
this.idRule = idRule;
|
||||
this.startDayOfMonth = startDayOfMonth;
|
||||
this.startDayOfWeek = (startDayOfWeek != null &&
|
||||
startDayOfWeek.length() != 0) ? startDayOfWeek : null;
|
||||
this.every = every;
|
||||
this.startTime = (new Time(from)).toCalendar();
|
||||
this.lastStartTime = (lastStart == null) ? null :
|
||||
(new Time(lastStart)).toCalendar();
|
||||
this.maxExecFromLastStart = maxExecFromLastStart;
|
||||
}
|
||||
|
||||
public RegolaAttivazione(RegolaAttivazione regolaAttivazione) {
|
||||
this.id = Resources.getID_REGOLA_ATTIVAZIONE();
|
||||
this.idRule = regolaAttivazione.idRule;
|
||||
this.startDayOfMonth = regolaAttivazione.startDayOfMonth;
|
||||
this.startDayOfWeek = regolaAttivazione.startDayOfWeek;
|
||||
this.every = regolaAttivazione.every;
|
||||
this.startTime = regolaAttivazione.startTime;
|
||||
this.lastStartTime = regolaAttivazione.lastStartTime;
|
||||
this.maxExecFromLastStart = regolaAttivazione.maxExecFromLastStart;
|
||||
}
|
||||
|
||||
public RegolaAttivazione(SchedulationItem schedItem) {
|
||||
WindowsTime wt = schedItem.getWindowsTime();
|
||||
this.id = Resources.getID_REGOLA_ATTIVAZIONE();
|
||||
this.idRule = wt.getIdRule();
|
||||
this.startDayOfMonth = wt.getStartDayOfMonth();
|
||||
if (wt.getStartDayOfWeek() != null) {
|
||||
this.startDayOfWeek = wt.getStartDayOfWeek().toString();
|
||||
}
|
||||
this.every = wt.getEvery();
|
||||
this.startTime = wt.getStartAt().toCalendar();
|
||||
if (wt.getLastStart() != null) {
|
||||
this.lastStartTime = wt.getLastStart().toCalendar();
|
||||
}
|
||||
this.maxExecFromLastStart = wt.getMaxTimeAfterLastStart();
|
||||
}
|
||||
|
||||
public SchedulationItem toSchedulationItem() {
|
||||
SchedulationItem res = new SchedulationItem();
|
||||
WindowsTime wt = new WindowsTime();
|
||||
wt.setIdRule(this.idRule);
|
||||
wt.setStartDayOfMonth(this.startDayOfMonth);
|
||||
if (this.startDayOfWeek != null) {
|
||||
wt.setStartDayOfWeek(DayOfWeekType.fromValue(this.startDayOfWeek));
|
||||
}
|
||||
wt.setEvery(this.every);
|
||||
short[] from = {
|
||||
(short)this.startTime.get(Calendar.HOUR_OF_DAY),
|
||||
(short)this.startTime.get(Calendar.MINUTE), 0, 0};
|
||||
wt.setStartAt(new Time(from));
|
||||
wt.setMaxTimeAfterLastStart(this.maxExecFromLastStart);
|
||||
if (lastStartTime != null) {
|
||||
short[] lastTime = {
|
||||
(short)this.lastStartTime.get(Calendar.HOUR_OF_DAY),
|
||||
(short) lastStartTime.get(Calendar.MINUTE), 0, 0};
|
||||
wt.setLastStart(new Time(lastTime));
|
||||
}
|
||||
res.setWindowsTime(wt);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fromDate
|
||||
* @param toDate
|
||||
* @return
|
||||
*/
|
||||
private EventTime getStartEvent(EventTime fromDate) {
|
||||
int fromDateDay = fromDate.get(Calendar.DAY_OF_MONTH);
|
||||
int fromDateWeekDay = fromDate.get(Calendar.DAY_OF_WEEK);
|
||||
|
||||
int iStartDayOfWeek = -1;
|
||||
if (startDayOfWeek != null) {
|
||||
//iStartDayOfWeek = DayOfWeekType.valueOf(startDayOfWeek).getType() + 1;
|
||||
iStartDayOfWeek = DayOfWeekType.fromValue(startDayOfWeek).ordinal() + 1;
|
||||
if (iStartDayOfWeek != fromDateWeekDay)
|
||||
return null;
|
||||
}
|
||||
if (startDayOfMonth != 0) {
|
||||
if (startDayOfMonth != fromDateDay)
|
||||
return null;
|
||||
//startEvent.set(Calendar.DAY_OF_MONTH, startDayOfMonth);
|
||||
}
|
||||
|
||||
EventTime startEvent = fromDate.getRelEvent(startTime.get(Calendar.
|
||||
HOUR_OF_DAY), startTime.get(Calendar.MINUTE), 0, 0);
|
||||
|
||||
/*
|
||||
// verifica che l'evento di start trovato sia compreso nell'intervallo specificato e se puo' modificarlo
|
||||
if(every>0 && startEvent.before(fromDate) && startEvent.before(toDate))
|
||||
{
|
||||
// periodicit<69> specificata, puo' essere modificata l'ora di start alla prima dopo l'inizio dell'intervallo.
|
||||
startEvent = ceil(fromDate, startEvent, every);
|
||||
}
|
||||
if(startEvent.before(fromDate) || !startEvent.before(toDate))
|
||||
{
|
||||
// l'ora di start calcolata <20> fuori intervallo di schedulazione va ignorata
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
return startEvent;
|
||||
}
|
||||
|
||||
private EventTime getStopEvent(EventTime lastStart) {
|
||||
EventTime res = null;
|
||||
if (maxExecFromLastStart != 0) {
|
||||
// ora di fine finestra temporale specificata, va calcolata a partire dall'ultima attivazione
|
||||
res = lastStart.getAdded(Calendar.MINUTE, maxExecFromLastStart);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private EventTime getLastEvent(EventTime startEvent) {
|
||||
EventTime lastEvent = null;
|
||||
if (this.lastStartTime == null) {
|
||||
// ora ultima attivazione non specificata
|
||||
if (this.every > 0) {
|
||||
// periodicit<69> specificata, l'ultima attivazione pu<70> essere calcolcata
|
||||
// come la piu' vicina alle 23:59 del giorno in cui si verifica la partenza
|
||||
EventTime ventitreCinquantanove = startEvent.getRelEvent(23, 59, 0, 0);
|
||||
lastEvent = floor(ventitreCinquantanove, startEvent, every);
|
||||
lastEvent = EventTime.min(ventitreCinquantanove, lastEvent);
|
||||
}
|
||||
else {
|
||||
// periodicit<69> non specificata, in questa situazione non esiste un'ora di ultima attivazione
|
||||
lastEvent = null;
|
||||
return lastEvent;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ora ultima attivazione specificata, la calcola come riferimento al giorno di partenza
|
||||
lastEvent = startEvent.getRelEvent(lastStartTime.get(Calendar.HOUR_OF_DAY),
|
||||
lastStartTime.get(Calendar.MINUTE), 0,
|
||||
0);
|
||||
}
|
||||
return lastEvent;
|
||||
}
|
||||
|
||||
private EventTime ceil(EventTime refEvent, EventTime startFrom, int every) {
|
||||
long diff = refEvent.getTimeInMillis() - startFrom.getTimeInMillis();
|
||||
// se la differenza <20> > 0 considera l'evento come il primo distante di un multiplo di every minuti
|
||||
// dalla data di partenza e maggiore di fromDate.
|
||||
int num = (diff > 0) ?
|
||||
(int) Math.ceil( ( (double) diff) / (every * 60 * 1000)) :
|
||||
0;
|
||||
EventTime evt = new EventTime(startFrom);
|
||||
evt.add(Calendar.MINUTE, num * every);
|
||||
return evt;
|
||||
}
|
||||
|
||||
private EventTime floor(EventTime refEvent, EventTime startFrom, int every) {
|
||||
|
||||
long diff = refEvent.getTimeInMillis() - startFrom.getTimeInMillis();
|
||||
// se la differenza <20> > 0 considera l'evento come il primo distante di un multiplo di every minuti
|
||||
// dalla data di partenza e maggiore di fromDate.
|
||||
int num = (diff > 0) ?
|
||||
(int) Math.floor( ( (double) diff) / (every * 60 * 1000)) :
|
||||
0;
|
||||
EventTime evt = new EventTime(startFrom);
|
||||
evt.add(Calendar.MINUTE, num * every);
|
||||
return evt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna l'elenco di tutte le possibili schedulazioni tra le due date specificate.
|
||||
* Si presuppone che le due date sia sempre all'interno delle 24 ore della stessa giornata
|
||||
* @param fromDate
|
||||
* @param toDate
|
||||
* @return
|
||||
*/
|
||||
|
||||
public Set getAllActivationInterval(EventTime fromDate, EventTime toDate) {
|
||||
HashSet set = new HashSet();
|
||||
EventTime startEvent = getStartEvent(fromDate);
|
||||
if (startEvent == null) {
|
||||
// ora di start fuori intervallo di scedulazione, non puo' esserci alcun intervallo di attivazione
|
||||
return set;
|
||||
}
|
||||
EventTime lastEvent = getLastEvent(startEvent);
|
||||
|
||||
if (every == 0) {
|
||||
EventTime stopEvent = getStopEvent( (lastEvent == null) ? startEvent :
|
||||
lastEvent);
|
||||
if (!startEvent.before(fromDate) && startEvent.before(toDate)) {
|
||||
ActivationInterval ai = new ActivationInterval(startEvent, stopEvent,
|
||||
this.id);
|
||||
set.add(ai);
|
||||
}
|
||||
if (lastEvent != null && !lastEvent.before(fromDate) &&
|
||||
lastEvent.before(toDate)) {
|
||||
ActivationInterval ai = new ActivationInterval(lastEvent, stopEvent,
|
||||
this.id);
|
||||
set.add(ai);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (startEvent.after(toDate) || (lastEvent.before(fromDate))) {
|
||||
return set;
|
||||
}
|
||||
if (startEvent.before(fromDate)) {
|
||||
// periodicit<69> specificata, puo' essere modificata l'ora di start alla prima dopo l'inizio dell'intervallo.
|
||||
if (every > 0) {
|
||||
startEvent = ceil(fromDate, startEvent, every);
|
||||
if (startEvent.after(lastEvent)) {
|
||||
return set;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return set;
|
||||
}
|
||||
}
|
||||
EventTime stopEvent = getStopEvent(lastEvent);
|
||||
// lastEvent <20> sicuramente != null dato che <20> null solo quando non <20> specificata la periodicit<69> e
|
||||
// l'ora di ultima attivazione.
|
||||
// viene aggionto un minuto dato che l'iteratore non comprende il massimo valore, mentre lastEvent va considerato
|
||||
EventTime maxEvent = EventTime.min(toDate,
|
||||
lastEvent.getAdded(Calendar.MINUTE, 1));
|
||||
for (Iterator i = EventTime.iterator(startEvent, maxEvent,
|
||||
Calendar.MINUTE, every); i.hasNext(); ) {
|
||||
EventTime evt = (EventTime) i.next();
|
||||
ActivationInterval ai = new ActivationInterval(evt, stopEvent, this.id);
|
||||
set.add(ai);
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* ritorna l'id associato alla regola
|
||||
* @return
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getIdRule() {
|
||||
return this.idRule;
|
||||
}
|
||||
|
||||
/*
|
||||
public String getDesc()
|
||||
{
|
||||
String res = "Partenza alle ore " + startTime.get(Calendar.HOUR_OF_DAY) + ":" + startTime.get(Calendar.MINUTE) +
|
||||
" del giorno "+startDayOfWeek + "/" + startDayOfMonth +
|
||||
" non oltre le ore " + stopTime.get(Calendar.HOUR_OF_DAY) + ":" + stopTime.get(Calendar.MINUTE) +
|
||||
" del giorno "+stopDayOfWeek + "/" + stopDayOfMonth +
|
||||
" frequenza: " + every;
|
||||
return res;
|
||||
}
|
||||
*/
|
||||
public String getStartDayOfWeek() {
|
||||
return this.startDayOfWeek;
|
||||
}
|
||||
|
||||
public int getStartDayOfMonth() {
|
||||
return this.startDayOfMonth;
|
||||
}
|
||||
|
||||
public Calendar getStartTime() {
|
||||
return this.startTime;
|
||||
}
|
||||
|
||||
public Calendar getLastStartTime() {
|
||||
return this.lastStartTime;
|
||||
}
|
||||
|
||||
public int getEvery() {
|
||||
return this.every;
|
||||
}
|
||||
|
||||
public int getMaxExecFromLastStart() {
|
||||
return this.maxExecFromLastStart;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package it.valueteam.crontab.config;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import mnp.crontab.config.xml.*;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>: </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Società</b>: ObjectWay S.p.a.</p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class RegoleAttivazione
|
||||
implements Serializable {
|
||||
private Hashtable tavolaRegole = null;
|
||||
public RegoleAttivazione() {
|
||||
tavolaRegole = new Hashtable();
|
||||
}
|
||||
|
||||
public RegoleAttivazione(Schedulation xmlSchedulation) {
|
||||
tavolaRegole = new Hashtable();
|
||||
SchedulationItem xmlSchedulationItem = null;
|
||||
RegolaAttivazione ra = null;
|
||||
for (Enumeration enu = xmlSchedulation.enumerateSchedulationItem();
|
||||
enu.hasMoreElements(); ) {
|
||||
xmlSchedulationItem = (SchedulationItem) enu.nextElement();
|
||||
ra = new RegolaAttivazione(xmlSchedulationItem);
|
||||
//log.debug("-> Regola di Attivazione con id: " + ra.getId() + " - desc: " + ra.getDesc());
|
||||
tavolaRegole.put(ra.getId(), ra);
|
||||
}
|
||||
}
|
||||
|
||||
public Schedulation toSchedulation() {
|
||||
Schedulation xmlSchedulation = new Schedulation();
|
||||
RegolaAttivazione ra = null;
|
||||
for (Iterator i = tavolaRegole.keySet().iterator(); i.hasNext(); ) {
|
||||
ra = (RegolaAttivazione) tavolaRegole.get(i.next());
|
||||
xmlSchedulation.addSchedulationItem(ra.toSchedulationItem());
|
||||
}
|
||||
return xmlSchedulation;
|
||||
}
|
||||
|
||||
public RegoleAttivazione(RegoleAttivazione regoleAttivazione) {
|
||||
tavolaRegole = new Hashtable(regoleAttivazione.tavolaRegole);
|
||||
}
|
||||
|
||||
public void add(RegolaAttivazione regolaAttivazione) {
|
||||
tavolaRegole.put(regolaAttivazione.getId(), regolaAttivazione);
|
||||
}
|
||||
|
||||
public void addAll(RegoleAttivazione regs) {
|
||||
tavolaRegole.putAll(regs.tavolaRegole);
|
||||
}
|
||||
|
||||
public void remove(String idRegolaAttivazione) {
|
||||
tavolaRegole.remove(idRegolaAttivazione);
|
||||
}
|
||||
|
||||
public Iterator iterator() {
|
||||
return new Iterator() {
|
||||
private Iterator iter = tavolaRegole.keySet().iterator();
|
||||
public boolean hasNext() {
|
||||
return iter.hasNext();
|
||||
}
|
||||
|
||||
public Object next() {
|
||||
return tavolaRegole.get(iter.next());
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
iter.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException,
|
||||
IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package it.valueteam.crontab.config;
|
||||
|
||||
import mnp.crontab.config.gestioneXml.*;
|
||||
import mnp.crontab.config.lnternalSystemXml.*;
|
||||
import mnp.crontab.config.xml.*;
|
||||
import java.io.*;
|
||||
|
||||
public class RuleValidator implements Serializable {
|
||||
public boolean isValid(CrontabConfig config) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isValid(SistemiInterni intern) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isValid(ListFile _listFile) {
|
||||
return true;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
package it.valueteam.crontab.config;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import it.valueteam.crontab.utility.*;
|
||||
import mnp.crontab.config.xml.*;
|
||||
import mnp.crontab.config.xml.types.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>: Rappresenta la descrizione di un task.</p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Società</b>: </p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
public class TaskInfo
|
||||
implements Serializable {
|
||||
private RegoleAttivazione regoleAttivazione = null;
|
||||
public static class ProcessInfoRef
|
||||
implements Serializable {
|
||||
private ProcessInfo procInfo = null;
|
||||
private boolean enabled = false;
|
||||
|
||||
public ProcessInfoRef(ProcessInfo procInfo, boolean enabled) {
|
||||
this.procInfo = procInfo;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public ProcessInfoRef(ProcessInfoRef procInfo) {
|
||||
this.procInfo = new ProcessInfo(procInfo.getProcess());
|
||||
this.enabled = procInfo.isEnabled();
|
||||
}
|
||||
|
||||
public ProcessInfo getProcess() {
|
||||
return this.procInfo;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setProcessInfo(ProcessInfo procInfo) {
|
||||
this.procInfo = procInfo;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream ois) throws
|
||||
ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Costruttore di un oggetto di tipo TaskInfo a partire da una configurazione di task e una tabella di processi
|
||||
* @param task Task in configurazione
|
||||
* @param processTable Tavola dei processi
|
||||
*/
|
||||
public TaskInfo(Task task, Hashtable processTable) {
|
||||
this.id = task.getID();
|
||||
this.name = task.getName();
|
||||
this.desc = task.getDesc();
|
||||
this.note = task.getNote();
|
||||
this.createAt = task.getCreateAt();
|
||||
this.lastUpdate = task.getLastUpdate();
|
||||
this.enabled = task.getEnabled();
|
||||
this.regoleAttivazione = new RegoleAttivazione(task.getSchedulation());
|
||||
this.processList = new ArrayList();
|
||||
setProcessList(task, processTable);
|
||||
}
|
||||
|
||||
public TaskInfo(TaskInfo task) {
|
||||
this.id = task.id;
|
||||
this.name = task.name;
|
||||
this.desc = task.desc;
|
||||
this.note = task.note;
|
||||
this.createAt = task.createAt;
|
||||
this.lastUpdate = task.lastUpdate;
|
||||
this.enabled = task.enabled;
|
||||
this.processList = new ArrayList(task.processList);
|
||||
this.regoleAttivazione = new RegoleAttivazione(task.regoleAttivazione);
|
||||
}
|
||||
|
||||
public TaskInfo(String id,
|
||||
String name,
|
||||
String desc,
|
||||
String note,
|
||||
Date createAt,
|
||||
Date lastUpdate,
|
||||
boolean enabled) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
this.note = note;
|
||||
this.createAt = createAt;
|
||||
this.lastUpdate = lastUpdate;
|
||||
this.enabled = enabled;
|
||||
this.regoleAttivazione = new RegoleAttivazione();
|
||||
this.processList = new ArrayList();
|
||||
}
|
||||
|
||||
public void addRegolaAttivazione(RegolaAttivazione regolaAttivazione) {
|
||||
regoleAttivazione.add(regolaAttivazione);
|
||||
}
|
||||
|
||||
public void removeRegolaAttivazione(String idRegola) {
|
||||
regoleAttivazione.remove(idRegola);
|
||||
}
|
||||
|
||||
public Set getActivationIntervalSet(EventTime from, EventTime to) {
|
||||
HashSet windowSet = new HashSet();
|
||||
boolean bEnd = false;
|
||||
for (Iterator i = regoleAttivazione.iterator(); i.hasNext(); ) {
|
||||
RegolaAttivazione item = (RegolaAttivazione) i.next();
|
||||
Set tmpSet = (Set) item.getAllActivationInterval(from, to);
|
||||
if (!tmpSet.isEmpty()) {
|
||||
windowSet.addAll(tmpSet);
|
||||
}
|
||||
}
|
||||
return windowSet;
|
||||
}
|
||||
|
||||
public RegoleAttivazione getRegoleAttivazione() {
|
||||
return this.regoleAttivazione;
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposta la sequenza dei processi associata al task a partire da una configurazione
|
||||
* @param task Task in configurazione
|
||||
* @param processTable Tabella dei processi
|
||||
*/
|
||||
private void setProcessList(Task task, Hashtable processTable) {
|
||||
ProcessListRefItem[] procListRef = task.getProcessListRef().
|
||||
getProcessListRefItem();
|
||||
String id = null;
|
||||
boolean enabled = false;
|
||||
for (int i = 0; i < procListRef.length; i++) {
|
||||
id = (String) procListRef[i].getProcessRef().getValue();
|
||||
enabled = procListRef[i].getProcessRef().getEnabled();
|
||||
addProcessInfo( (ProcessInfo) processTable.get(id), i, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna l'identificativo del Task
|
||||
* @return identificativo del Task
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il nome del task
|
||||
* @return nome del task
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la descrizione associata al task
|
||||
* @return descrizione associata al task
|
||||
*/
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna le note eventualmente associate al Task
|
||||
* @return Note eventualmente associate al Task
|
||||
*/
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
/**
|
||||
* ritorna l'ora di creazione del Task
|
||||
* @return ora di creazione del Task
|
||||
*/
|
||||
public Date getCreateAt() {
|
||||
return createAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna l'ora dell'ultima modifica alla configurazione del Task
|
||||
* @return ora dell'ultima modifica alla configurazione del Task
|
||||
*/
|
||||
public Date getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna se il task è abilitato o meno
|
||||
* @return true se il task è abilitato
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disabilita/Abilita il Task
|
||||
* @param value stato di abilitazione
|
||||
*/
|
||||
public void setEnabled(boolean value) {
|
||||
this.enabled = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la sequenza dei processi associata al task
|
||||
* @return Sequenza dei processi associata al task
|
||||
*/
|
||||
public ArrayList getProcessList() {
|
||||
return processList;
|
||||
}
|
||||
|
||||
public int getProcessInfoOrder(ProcessInfo procInfo) {
|
||||
int idx = -1;
|
||||
for (int i = 0; i < processList.size(); i++) {
|
||||
if ( ( (ProcessInfoRef) processList.get(i)).getProcess().getId().equals(
|
||||
getId())) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiunge un processo alla lista dei processi di queto task
|
||||
* @param processInfo Processo da aggiungere al Task
|
||||
* @param order numero di sequenza del processo nell'elenco dei processi
|
||||
* @param enabled true se il processo è abilitato in se
|
||||
*/
|
||||
public void addProcessInfo(ProcessInfo processInfo, int order,
|
||||
boolean enabled) {
|
||||
processInfo.addTaskRef(this);
|
||||
processList.add(order, new ProcessInfoRef(processInfo, enabled));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rimuove un processo dalla lista dei processi (viene eliminato anche il riferimento al task dal processo)
|
||||
* @param order numero di sequenza del processo da eliminare.
|
||||
*/
|
||||
public void removeProcessInfo(int order) {
|
||||
if ( (order >= 0) && (order < processList.size())) {
|
||||
ProcessInfo p = ( (ProcessInfoRef) processList.get(order)).getProcess();
|
||||
if (p != null) {
|
||||
p.removeTaskRef(this);
|
||||
processList.remove(order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAllProcessInfoRef() {
|
||||
for (Iterator i = processList.iterator(); i.hasNext(); ) {
|
||||
ProcessInfoRef item = (ProcessInfoRef) i.next();
|
||||
item.getProcess().removeTaskRef(this);
|
||||
}
|
||||
processList.clear();
|
||||
}
|
||||
|
||||
public Map getProcessMapToLog() {
|
||||
Map m = new TreeMap();
|
||||
ListIterator li = processList.listIterator();
|
||||
int cc = 0;
|
||||
while (li.hasNext()) {
|
||||
cc++;
|
||||
String nn = ( (TaskInfo.ProcessInfoRef) li.next()).getProcess().getName();
|
||||
m.put("process" + cc, nn);
|
||||
}
|
||||
return m;
|
||||
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException,
|
||||
IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String desc;
|
||||
protected Date createAt;
|
||||
protected Date lastUpdate;
|
||||
protected String note;
|
||||
protected boolean enabled;
|
||||
protected ArrayList processList;
|
||||
protected final static DayOfWeekType[] dayOfWeeks = {
|
||||
DayOfWeekType.DOM, DayOfWeekType.LUN, DayOfWeekType.MAR,
|
||||
DayOfWeekType.MER, DayOfWeekType.GIO,
|
||||
DayOfWeekType.VEN, DayOfWeekType.SAB};
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package it.valueteam.crontab.config;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>: </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Società</b>: ObjectWay S.p.a.</p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class TaskInfoList
|
||||
extends TreeSet
|
||||
implements Serializable {
|
||||
|
||||
public TaskInfoList() {
|
||||
super(new TaskInfoComparator());
|
||||
}
|
||||
|
||||
public TaskInfoList(SortedSet p0) {
|
||||
super(p0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>: Stabilisce l'ordine tra due Task in base al campo ID </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Società</b>: ObjectWay S.p.a.</p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
public static class TaskInfoComparator
|
||||
implements Comparator, Serializable {
|
||||
public int compare(Object o1, Object o2) {
|
||||
TaskInfo taskInfo1 = (TaskInfo) o1;
|
||||
TaskInfo taskInfo2 = (TaskInfo) o2;
|
||||
return taskInfo1.getId().compareTo(taskInfo2.getId());
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
boolean res = (o != null) && (o instanceof TaskInfoComparator);
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException,
|
||||
IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
package it.valueteam.crontab.config;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import org.exolab.castor.xml.*;
|
||||
import it.valueteam.crontab.engine.exception.*;
|
||||
import mnp.crontab.config.xml.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>:
|
||||
* Rappresenta un'astrazione del file di configurazione del Crontab.
|
||||
* Tutte le operazioni sul file di configurazione vengono effettuate mediante questa classe.
|
||||
* </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Società</b>: Soviet MNP</p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
public class XMLConfig implements Serializable {
|
||||
private static Logger log = Logger.getLogger(XMLConfig.class.getName());
|
||||
//private CrontabConfig crontabConf = null;
|
||||
private String file = null;
|
||||
private Hashtable processTable = new Hashtable();
|
||||
private Hashtable taskTable = new Hashtable();
|
||||
|
||||
/** @link dependency
|
||||
* @stereotype use*/
|
||||
/*# TaskInfo lnkTaskInfo; */
|
||||
|
||||
/** @link dependency
|
||||
* @stereotype use*/
|
||||
/*# ProcessInfo lnkProcessInfo; */
|
||||
|
||||
/** @link dependency
|
||||
* @stereotype use*/
|
||||
/*# RuleValidator lnkRuleValidator; */
|
||||
|
||||
private String name;
|
||||
private String ver;
|
||||
private int subver;
|
||||
public XMLConfig() {
|
||||
this.name = "";
|
||||
this.ver = "0.0";
|
||||
this.subver = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Carica la configurazione specificata nel file passato per parametro.
|
||||
* @params file Filename del file di configurazione.
|
||||
* @throws CrontabException Se si verificano problemi nel parser del file
|
||||
* @throws NotValidCrontabConfigException Se il file specificato non è valido o è inesistente.
|
||||
*/
|
||||
public void open(String file) throws CrontabException,
|
||||
NotValidCrontabConfigException {
|
||||
try {
|
||||
this.file = file;
|
||||
String fileName = new File(file).getName();
|
||||
String fileStr = "";
|
||||
CrontabConfig crontabConf = CrontabConfig.unmarshal(new FileReader(file));
|
||||
RuleValidator ruleValidator = new RuleValidator();
|
||||
if (ruleValidator.isValid(crontabConf)) {
|
||||
loadCrontabConf(crontabConf);
|
||||
fileStr = this.name + "-" + this.ver;
|
||||
if (crontabConf.hasSubver()) {
|
||||
this.subver = crontabConf.getSubver();
|
||||
fileStr += "_" + this.subver;
|
||||
}
|
||||
else {
|
||||
this.subver = 0;
|
||||
}
|
||||
if (fileName.lastIndexOf(".xml") != -1) {
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf(".xml"));
|
||||
}
|
||||
else if (fileName.lastIndexOf(".booted") != -1) {
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf(".booted"));
|
||||
}
|
||||
System.out.println("fileStr: " + fileStr);
|
||||
System.out.println("fileName: " + fileName);
|
||||
if (!fileName.equals(fileStr) &&
|
||||
(subver != 0 || !fileStr.equals(fileName + "_0"))) {
|
||||
System.out.println("Nome file non valido rispetto alla versione");
|
||||
throw new NotValidCrontabConfigException(
|
||||
"Nome del file inconsistente con la versione: " + file +
|
||||
" - ver: " + this.ver + "_" + this.subver);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new NotValidCrontabConfigException();
|
||||
}
|
||||
}
|
||||
catch (ValidationException ex) {
|
||||
throw new NotValidCrontabConfigException(ex);
|
||||
}
|
||||
catch (MarshalException ex) {
|
||||
throw new CrontabException(ex);
|
||||
}
|
||||
catch (FileNotFoundException ex) {
|
||||
throw new NotValidCrontabConfigException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Carica la configurazione specificata passato per parametro.
|
||||
* @param crontabConf CrontabConfig
|
||||
* @throws CrontabException
|
||||
* @throws NotValidCrontabConfigException
|
||||
*/
|
||||
public void loadCrontabConf(CrontabConfig crontabConf) throws CrontabException,
|
||||
NotValidCrontabConfigException {
|
||||
this.clean();
|
||||
this.setProcessTable(crontabConf.getProcessList());
|
||||
this.setTaskTable(crontabConf.getTaskList());
|
||||
this.name = crontabConf.getName();
|
||||
this.ver = crontabConf.getVer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Salva la configurazione in memoria sul file specificato per parametro.
|
||||
* @params file nome del file di configurazione da salvare.
|
||||
* @throws CrontabException Se si verificano problemi a scrivere il file o non è riuscita la conversione in XML
|
||||
* @throws NotValidCrontabConfigException Se la configurazione da salvare non è valida.
|
||||
*/
|
||||
|
||||
public void save(String file) throws CrontabException,
|
||||
NotValidCrontabConfigException {
|
||||
RuleValidator ruleValidator = new RuleValidator();
|
||||
CrontabConfig crontabConf = makeCrontabConf();
|
||||
if (crontabConf.isValid() && ruleValidator.isValid(crontabConf)) {
|
||||
try {
|
||||
crontabConf.marshal(new FileWriter(file));
|
||||
crontabConf = null;
|
||||
}
|
||||
catch (ValidationException ex) {
|
||||
throw new NotValidCrontabConfigException(ex);
|
||||
}
|
||||
catch (MarshalException ex) {
|
||||
throw new CrontabException(ex);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new CrontabException(ex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new NotValidCrontabConfigException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la rappresentazione della configurazione così come viene gestita da Castor.
|
||||
* @return rappresentazione Castor della configurazione.
|
||||
*/
|
||||
public CrontabConfig getConfig() {
|
||||
return makeCrontabConf();
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposta una configurazione Castor
|
||||
* @param crontabConf configurazione crontab
|
||||
/
|
||||
public void setConfig(CrontabConfig crontabConf)
|
||||
{
|
||||
if (crontabConf.isValid())
|
||||
{
|
||||
this.crontabConf = crontabConf;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("not valid");
|
||||
}
|
||||
}
|
||||
*/
|
||||
private CrontabConfig makeCrontabConf() {
|
||||
CrontabConfig crontabConf = new CrontabConfig();
|
||||
|
||||
crontabConf.setName(this.name);
|
||||
crontabConf.setSubver(this.subver);
|
||||
crontabConf.setVer(this.ver);
|
||||
|
||||
ProcessList processList = new ProcessList();
|
||||
ProcessListItem processListItem = null;
|
||||
ProcessDef procDefTmp = null;
|
||||
ProcessInfo procInfoTmp = null;
|
||||
|
||||
for (Enumeration enu = processTable.keys(); enu.hasMoreElements(); ) {
|
||||
String id = (String) enu.nextElement();
|
||||
procDefTmp = new ProcessDef();
|
||||
procInfoTmp = (ProcessInfo) processTable.get(id);
|
||||
procDefTmp.setID(procInfoTmp.getId());
|
||||
procDefTmp.setName(procInfoTmp.getName());
|
||||
procDefTmp.setComando(procInfoTmp.getCommand());
|
||||
procDefTmp.setParametri(procInfoTmp.getParams());
|
||||
procDefTmp.setDesc(procInfoTmp.getDesc());
|
||||
procDefTmp.setEnabled(procInfoTmp.getEnabled());
|
||||
|
||||
// blocking process
|
||||
BlockingProcessListRef dependentProcessListRef = new
|
||||
BlockingProcessListRef();
|
||||
BlockingProcessRef dependentProcRef = null;
|
||||
BlockingProcessListRefItem dependentProcessListRefItem = null;
|
||||
for (Iterator i = procInfoTmp.getBlockingProcessList().iterator();
|
||||
i.hasNext(); ) {
|
||||
ProcessInfo.BlockingProcessInfoRef item = (ProcessInfo.
|
||||
BlockingProcessInfoRef) i.next();
|
||||
dependentProcRef = new BlockingProcessRef();
|
||||
dependentProcRef.setValue(item.getProcID());
|
||||
dependentProcessListRefItem = new BlockingProcessListRefItem();
|
||||
dependentProcessListRefItem.setBlockingProcessRef(dependentProcRef);
|
||||
dependentProcessListRef.addBlockingProcessListRefItem(
|
||||
dependentProcessListRefItem);
|
||||
}
|
||||
// end blocking process
|
||||
procDefTmp.setBlockingProcessListRef(dependentProcessListRef);
|
||||
|
||||
processListItem = new ProcessListItem();
|
||||
processListItem.setProcessDef(procDefTmp);
|
||||
processList.addProcessListItem(processListItem);
|
||||
|
||||
}
|
||||
crontabConf.setProcessList(processList);
|
||||
|
||||
TaskList taskList = makeTaskList();
|
||||
crontabConf.setTaskList(taskList);
|
||||
return crontabConf;
|
||||
}
|
||||
|
||||
private TaskList makeTaskList() {
|
||||
TaskList taskList = new TaskList();
|
||||
TaskListItem taskListItem = null;
|
||||
Task taskTmp = null;
|
||||
TaskInfo taskInfoTmp = null;
|
||||
for (Enumeration enu = taskTable.keys(); enu.hasMoreElements(); ) {
|
||||
String id = (String) enu.nextElement();
|
||||
|
||||
taskTmp = new Task();
|
||||
taskInfoTmp = (TaskInfo) taskTable.get(id);
|
||||
taskTmp.setID(taskInfoTmp.getId());
|
||||
taskTmp.setName(taskInfoTmp.getName());
|
||||
taskTmp.setNote(taskInfoTmp.getNote());
|
||||
taskTmp.setDesc(taskInfoTmp.getDesc());
|
||||
taskTmp.setEnabled(taskInfoTmp.isEnabled());
|
||||
taskTmp.setCreateAt(taskInfoTmp.getCreateAt());
|
||||
taskTmp.setLastUpdate(taskInfoTmp.getLastUpdate());
|
||||
|
||||
ProcessListRef processListRef = new ProcessListRef();
|
||||
ProcessRef procRef = null;
|
||||
ProcessInfo procInfo = null;
|
||||
ProcessListRefItem processListRefItem = null;
|
||||
for (Iterator i = taskInfoTmp.getProcessList().iterator(); i.hasNext(); ) {
|
||||
TaskInfo.ProcessInfoRef item = (TaskInfo.ProcessInfoRef) i.next();
|
||||
procRef = new ProcessRef();
|
||||
procRef.setEnabled(item.isEnabled());
|
||||
procRef.setValue(item.getProcess().getId());
|
||||
processListRefItem = new ProcessListRefItem();
|
||||
processListRefItem.setProcessRef(procRef);
|
||||
processListRef.addProcessListRefItem(processListRefItem);
|
||||
}
|
||||
|
||||
Schedulation schedulation = taskInfoTmp.getRegoleAttivazione().
|
||||
toSchedulation();
|
||||
|
||||
taskTmp.setSchedulation(schedulation);
|
||||
taskTmp.setProcessListRef(processListRef);
|
||||
taskListItem = new TaskListItem();
|
||||
taskListItem.setTask(taskTmp);
|
||||
taskList.addTaskListItem(taskListItem);
|
||||
}
|
||||
return taskList;
|
||||
}
|
||||
|
||||
public void updateConfiguration() {
|
||||
try {
|
||||
CrontabConfig cc = makeCrontabConf();
|
||||
loadCrontabConf(cc);
|
||||
}
|
||||
catch (NotValidCrontabConfigException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
catch (CrontabException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la tabella dei processi presenti nella configurazione corrente
|
||||
* @return Tabella dei processi nella configurazione corrente
|
||||
*/
|
||||
public Hashtable getProcessTable() {
|
||||
return processTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la tabella dei Task configurati per essere schedulati dal Crontab.
|
||||
* @return tabella dei task specificati nel file di configurazione.
|
||||
*/
|
||||
public Hashtable getTaskTable() {
|
||||
return taskTable;
|
||||
}
|
||||
|
||||
private void setProcessTable(ProcessList procList) {
|
||||
ProcessListItem[] pl = procList.getProcessListItem();
|
||||
for (int i = 0; i < pl.length; i++) {
|
||||
ProcessInfo procInfo = new ProcessInfo(pl[i].getProcessDef());
|
||||
processTable.put(procInfo.getId(), procInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTaskTable(TaskList taskList) {
|
||||
TaskListItem[] tl = taskList.getTaskListItem();
|
||||
for (int i = 0; i < tl.length; i++) {
|
||||
TaskInfo taskInfo = new TaskInfo(tl[i].getTask(), this.getProcessTable());
|
||||
log.debug("Impostazione del task: " + taskInfo.getId());
|
||||
taskTable.put(taskInfo.getId(), taskInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteTask(TaskInfo taskInfo) {
|
||||
taskInfo.removeAllProcessInfoRef();
|
||||
taskTable.remove(taskInfo.getId());
|
||||
}
|
||||
|
||||
public void deleteProcess(ProcessInfo processInfo) {
|
||||
if (!processInfo.hasTaskRefs()) {
|
||||
processTable.remove(processInfo.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public void addTask(TaskInfo taskInfo) {
|
||||
taskTable.put(taskInfo.getId(), taskInfo);
|
||||
}
|
||||
|
||||
public void addProcessInfo(ProcessInfo processInfo) {
|
||||
processTable.put(processInfo.getId(), processInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resetta la configurazione. Pulisce la tabella dei processi e dei task.
|
||||
*/
|
||||
public void clean() {
|
||||
taskTable.clear();
|
||||
processTable.clear();
|
||||
}
|
||||
|
||||
public String getVer() {
|
||||
return this.ver;
|
||||
}
|
||||
|
||||
public int getSubVer() {
|
||||
return this.subver;
|
||||
}
|
||||
|
||||
public void setSubVer(int i) {
|
||||
this.subver = i;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,453 @@
|
||||
package it.valueteam.crontab.config.setting;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.engine.exception.*;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>:
|
||||
* Contiene tutte le informazioni di configurazione. E' possibile registrarsi
|
||||
* per avere la notifica dei cambiamenti della configurazione.
|
||||
* </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Società</b>: ObjectWay S.p.a.</p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class Settings implements Serializable {
|
||||
private Vector listeners = new Vector();
|
||||
private static Settings _instance;
|
||||
private String fileCfg = null;
|
||||
private static Logger log = Logger.getLogger(Settings.class.getName());
|
||||
|
||||
private XMLConfig xmlConfig = null;
|
||||
private boolean bSaved = true;
|
||||
|
||||
protected Settings() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna l'istanza di configurazione
|
||||
* @return Istanza di configurazione
|
||||
*/
|
||||
public static Settings getInstance() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton factory. Crea un'istanza di configurazione se già non è stata creata.
|
||||
* Viene gestita una sola configurazione quindi una chiamata a questo metodo dopo
|
||||
* la prima manda in gc l'istanza di configurazione precedente e crea la nuova.
|
||||
* @param fileCfg File di configurazione da leggere
|
||||
* @return Istanza di configurazione associata al file specificato
|
||||
* @throws NotValidCrontabFileException file di configurazione non valido e non presente l'ultima
|
||||
* configurazione valida
|
||||
*/
|
||||
public static Settings getInstance(String fileCfg) throws
|
||||
NotValidCrontabFileException {
|
||||
if (_instance == null) {
|
||||
synchronized (it.valueteam.crontab.config.setting.Settings.class) {
|
||||
if (_instance == null) {
|
||||
_instance = new it.valueteam.crontab.config.setting.Settings();
|
||||
_instance.fileCfg = fileCfg;
|
||||
_instance.load(_instance.fileCfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registra il listener passato per parametro
|
||||
* @param changeSettingListener listener da reggistrare
|
||||
*/
|
||||
public synchronized void register(SettingsChangeListenerIF
|
||||
changeSettingListener) {
|
||||
listeners.add(changeSettingListener);
|
||||
}
|
||||
|
||||
public synchronized ArrayList getTaskList() {
|
||||
ArrayList res = new ArrayList();
|
||||
Hashtable taskTable = xmlConfig.getTaskTable();
|
||||
for (Iterator i = taskTable.keySet().iterator(); i.hasNext(); ) {
|
||||
String key = (String) i.next();
|
||||
res.add(taskTable.get(key));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public synchronized ArrayList getProcessList() {
|
||||
ArrayList res = new ArrayList();
|
||||
Hashtable processTable = xmlConfig.getProcessTable();
|
||||
for (Iterator i = processTable.keySet().iterator(); i.hasNext(); ) {
|
||||
String key = (String) i.next();
|
||||
res.add(processTable.get(key));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la configurazione corrente
|
||||
* @return una modello del file di configurazione
|
||||
|
||||
public synchronized XMLConfig getConfiguration()
|
||||
{
|
||||
return xmlConfig;
|
||||
}
|
||||
/**
|
||||
* Imposta la configurazione passata per parametro.
|
||||
* @param xmlConfig imposta un modello di configurazione
|
||||
|
||||
public void setConfiguration(XMLConfig xmlConfig)
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
backup();
|
||||
this.xmlConfig = xmlConfig;
|
||||
}
|
||||
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
|
||||
IChangeSettingsListener item = (IChangeSettingsListener)i.next();
|
||||
item.onChangeConfiguration(this);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Salva la configurazione corrente sul file passato per parametro
|
||||
* @param file nome del file sul quale salvare la configurazione corrente
|
||||
*/
|
||||
public synchronized String save() {
|
||||
String file = "";
|
||||
try {
|
||||
File dirPath = new File(this.fileCfg).getParentFile();
|
||||
file = dirPath.getAbsolutePath() + File.separatorChar +
|
||||
xmlConfig.getName() + "-" + xmlConfig.getVer() +
|
||||
"_" + xmlConfig.getSubVer() +
|
||||
".xml";
|
||||
this.xmlConfig.save(file);
|
||||
this.fileCfg = file;
|
||||
this.bSaved = true;
|
||||
|
||||
}
|
||||
catch (CrontabException ex) {
|
||||
StringWriter sw = new StringWriter();
|
||||
ex.printStackTrace(new PrintWriter(sw));
|
||||
log.debug(sw.toString());
|
||||
}
|
||||
catch (NotValidCrontabConfigException ex) {
|
||||
StringWriter sw = new StringWriter();
|
||||
ex.printStackTrace(new PrintWriter(sw));
|
||||
log.debug(sw.toString());
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Effettua il backup della configurazione corrente come l'ultima funzionante:
|
||||
* <nomeFile>.booted
|
||||
*/
|
||||
public synchronized void saveAsLastGood() {
|
||||
try {
|
||||
File dirPath = (new File(this.fileCfg)).getParentFile();
|
||||
String filebooted = xmlConfig.getName() + "-" + xmlConfig.getVer() +
|
||||
"_" + xmlConfig.getSubVer() + ".booted";
|
||||
if (dirPath != null) {
|
||||
xmlConfig.save(dirPath.getAbsolutePath() + File.separatorChar +
|
||||
filebooted);
|
||||
}
|
||||
log.info("SAVEAsLastGood: " + dirPath.getAbsolutePath() +
|
||||
File.separatorChar + filebooted);
|
||||
}
|
||||
catch (CrontabException ex) {
|
||||
log.error(ex);
|
||||
}
|
||||
catch (NotValidCrontabConfigException ex) {
|
||||
log.error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Carica la configurazione specificata nel file. Se non riesce a caricare tale configurazione
|
||||
* carica l'ultima configurazione andata a buon fine (sempre uguale a 'CrontabConf.booted') se
|
||||
* esiste altrimenti genera una eccezione NotValidCrontabConfFile.
|
||||
* @param file file di configurazione del crontab
|
||||
* @throws NotValidCrontabFileException file di configurazione non valido e non presente l'ultima
|
||||
* configurazione valida
|
||||
*/
|
||||
public void load(String file) throws NotValidCrontabFileException {
|
||||
synchronized (this) {
|
||||
if (file == null)
|
||||
return; // non c'è nulla da aprire se il file è nullo
|
||||
try {
|
||||
if (xmlConfig == null) { // se non era mai stata creata una configurazione
|
||||
xmlConfig = new XMLConfig(); // crea una configurazione vuota
|
||||
}
|
||||
xmlConfig.open(file); // apre il file di configurazione
|
||||
log.debug("Open successful " + file + " !");
|
||||
if (file.endsWith(".booted")) {
|
||||
file = file.substring(0, file.lastIndexOf(".booted")) + ".xml";
|
||||
}
|
||||
|
||||
this.fileCfg = file;
|
||||
this.bSaved = true;
|
||||
}
|
||||
catch (CrontabException ex) {
|
||||
throw new NotValidCrontabFileException("CrontabException: " +
|
||||
ex.toString());
|
||||
}
|
||||
catch (NotValidCrontabConfigException ex) {
|
||||
throw new NotValidCrontabFileException(
|
||||
"NotValidCrontabConfigException: " + ex.toString());
|
||||
}
|
||||
}
|
||||
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
|
||||
SettingsChangeListenerIF item = (SettingsChangeListenerIF) i.next();
|
||||
item.onChangeConfiguration(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cerca di caricare l'ultima configurazione andata a buon fine: "CrontabConf_verX_subverY.booted"
|
||||
* @throws NotValidCrontabFileException non riesce a caricare l'ultima configurazione
|
||||
* andata a buon fine
|
||||
*/
|
||||
public synchronized void loadLastGood() throws NotValidCrontabFileException {
|
||||
try {
|
||||
File dirPath = (new File(this.fileCfg)).getParentFile();
|
||||
if (dirPath != null) {
|
||||
File[] bootedList = dirPath.listFiles(new FileFilter() {
|
||||
public boolean accept(File pathfile) {
|
||||
return pathfile.getAbsolutePath().endsWith(".booted");
|
||||
}
|
||||
});
|
||||
if (bootedList.length <= 0) {
|
||||
throw new NotValidCrontabFileException(
|
||||
"L'ultima configurazione corretta non esiste");
|
||||
}
|
||||
String filebooted = bootedList[0].getAbsolutePath();
|
||||
filebooted = filebooted.substring(0, filebooted.lastIndexOf(".booted"));
|
||||
this.fileCfg = filebooted;
|
||||
this.bSaved = true;
|
||||
xmlConfig.open(filebooted);
|
||||
}
|
||||
else {
|
||||
throw new NotValidCrontabFileException();
|
||||
}
|
||||
}
|
||||
catch (CrontabException ex1) {
|
||||
throw new NotValidCrontabFileException(ex1.toString());
|
||||
}
|
||||
catch (NotValidCrontabConfigException ex1) {
|
||||
throw new NotValidCrontabFileException(ex1.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il path del file di configurazione
|
||||
* @return path del file di configurazione
|
||||
*/
|
||||
public synchronized String getFileCfg() {
|
||||
return this.fileCfg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il numero di versione del file di configurazione
|
||||
* @return versione del file di configurazione
|
||||
*/
|
||||
public synchronized String getFileCfgVer() {
|
||||
return xmlConfig.getVer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il numero di versione del file di configurazione
|
||||
* @return versione del file di configurazione
|
||||
*/
|
||||
public synchronized int getFileCfgSubVer() {
|
||||
return xmlConfig.getSubVer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il nome della configurazione
|
||||
* @return nome della configurazione.
|
||||
*/
|
||||
public synchronized String getFileCfgName() {
|
||||
return xmlConfig.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiunge un nuovo Task
|
||||
* @param taskInfo nuovo task da aggiungere
|
||||
*/
|
||||
public void addNew(TaskInfo taskInfo) {
|
||||
synchronized (this) {
|
||||
xmlConfig.addTask(taskInfo);
|
||||
xmlConfig.setSubVer(xmlConfig.getSubVer() + 1);
|
||||
bSaved = false;
|
||||
xmlConfig.updateConfiguration();
|
||||
}
|
||||
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
|
||||
SettingsChangeListenerIF item = (SettingsChangeListenerIF) i.next();
|
||||
item.onNewTaskAdded(taskInfo, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il Task che ha id passato per parametro
|
||||
* @param id identificativo del Task richiesto
|
||||
* @return Task richiesto
|
||||
*/
|
||||
public synchronized TaskInfo getTask(String id) {
|
||||
return new TaskInfo( (TaskInfo) xmlConfig.getTaskTable().get(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il Processo che ha l'id specificato per parametro
|
||||
* @param id identificativo del Processo richisto
|
||||
* @return Processo richiesto
|
||||
*/
|
||||
public synchronized ProcessInfo getProcess(String id) {
|
||||
return (ProcessInfo) xmlConfig.getProcessTable().get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rimuove il Task specificato per parametro
|
||||
* @param taskInfo Task da eliminare
|
||||
*/
|
||||
public void remove(String taskInfoId) {
|
||||
TaskInfo taskInfo = null;
|
||||
synchronized (this) {
|
||||
taskInfo = (TaskInfo) xmlConfig.getTaskTable().get(taskInfoId);
|
||||
xmlConfig.deleteTask(taskInfo);
|
||||
xmlConfig.setSubVer(xmlConfig.getSubVer() + 1);
|
||||
xmlConfig.updateConfiguration();
|
||||
bSaved = false;
|
||||
}
|
||||
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
|
||||
SettingsChangeListenerIF item = (SettingsChangeListenerIF) i.next();
|
||||
item.onRemoveTask(taskInfo, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiorna il task specificato per parametro
|
||||
* @param taskInfo Task aggiornato
|
||||
*/
|
||||
public void update(TaskInfo taskInfo) {
|
||||
TaskInfo prevTask = null;
|
||||
synchronized (this) {
|
||||
prevTask = (TaskInfo) xmlConfig.getTaskTable().get(taskInfo.getId());
|
||||
xmlConfig.getTaskTable().put(taskInfo.getId(), taskInfo);
|
||||
xmlConfig.setSubVer(xmlConfig.getSubVer() + 1);
|
||||
xmlConfig.updateConfiguration();
|
||||
bSaved = false;
|
||||
|
||||
}
|
||||
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
|
||||
SettingsChangeListenerIF item = (SettingsChangeListenerIF) i.next();
|
||||
item.onUpdateTask(prevTask, taskInfo, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiunge un nuovo Processo
|
||||
* @param procInfo Processo da aggiungere
|
||||
*/
|
||||
public void addNew(ProcessInfo procInfo) {
|
||||
synchronized (this) {
|
||||
xmlConfig.addProcessInfo(procInfo);
|
||||
xmlConfig.setSubVer(xmlConfig.getSubVer() + 1);
|
||||
bSaved = false;
|
||||
xmlConfig.updateConfiguration();
|
||||
}
|
||||
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
|
||||
SettingsChangeListenerIF item = (SettingsChangeListenerIF) i.next();
|
||||
item.onAddedProcess(procInfo, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rimuove il processo passato per parametro
|
||||
* @param procInfo Processo da eliminare
|
||||
*/
|
||||
public void removeProcess(String procInfoId) {
|
||||
ProcessInfo procInfo = null;
|
||||
ArrayList listaProcBloccati = null;
|
||||
synchronized (this) {
|
||||
procInfo = (ProcessInfo) xmlConfig.getProcessTable().get(procInfoId);
|
||||
// C.P x adesso ho messo una pezza cosi
|
||||
listaProcBloccati = getRefBlockingProcessList(procInfoId);
|
||||
if (listaProcBloccati.size() == 0)
|
||||
xmlConfig.deleteProcess(procInfo);
|
||||
xmlConfig.setSubVer(xmlConfig.getSubVer() + 1);
|
||||
bSaved = false;
|
||||
xmlConfig.updateConfiguration();
|
||||
}
|
||||
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
|
||||
SettingsChangeListenerIF item = (SettingsChangeListenerIF) i.next();
|
||||
item.onRemoveProcess(procInfo, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiorna il processo passato per parametro
|
||||
* @param procInfo Processo passato per parametro
|
||||
*/
|
||||
public void update(ProcessInfo procInfo) {
|
||||
ProcessInfo prevProcInfo = null;
|
||||
synchronized (this) {
|
||||
prevProcInfo = (ProcessInfo) xmlConfig.getProcessTable().get(procInfo.
|
||||
getId());
|
||||
xmlConfig.getProcessTable().put(procInfo.getId(), procInfo);
|
||||
xmlConfig.setSubVer(xmlConfig.getSubVer() + 1);
|
||||
xmlConfig.updateConfiguration();
|
||||
bSaved = false;
|
||||
}
|
||||
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
|
||||
SettingsChangeListenerIF item = (SettingsChangeListenerIF) i.next();
|
||||
item.onUpdateProcess(prevProcInfo, procInfo, this);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean getSaved() {
|
||||
return bSaved;
|
||||
}
|
||||
|
||||
/**
|
||||
* C.P. gestione processi bloccanti
|
||||
* ritorna la lista dei processi bloccati da un processo
|
||||
* @return ArrayList
|
||||
*/
|
||||
public synchronized ArrayList getRefBlockingProcessList(String procID) {
|
||||
ProcessInfo processInfo = null;
|
||||
ProcessInfo.BlockingProcessInfoRef item = null;
|
||||
ArrayList res = new ArrayList();
|
||||
Hashtable processTable = xmlConfig.getProcessTable();
|
||||
for (Iterator i = processTable.keySet().iterator(); i.hasNext(); ) {
|
||||
String key = (String) i.next();
|
||||
processInfo = (ProcessInfo) processTable.get(key);
|
||||
|
||||
for (Iterator iter = processInfo.getBlockingProcessList().iterator();
|
||||
iter.hasNext(); ) {
|
||||
item = (ProcessInfo.BlockingProcessInfoRef) iter.next();
|
||||
if (item.getProcID().equals(procID)) {
|
||||
res.add(processInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package it.valueteam.crontab.config.setting;
|
||||
|
||||
import it.valueteam.crontab.config.*;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP CRONTAB</p>
|
||||
* <p>Description: Interfaccia per la notifica dei cambiamenti alla configurazione del crontab</p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: ValueTeam - TeleAp</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface SettingsChangeListenerIF {
|
||||
/**
|
||||
* viene invocato quando viene aggiunto un nuovo task alla configurazione
|
||||
* @param taskInfo Task che è stato aggiunto
|
||||
* @param settings La configurazione sul quale è stato aggiunto il task.
|
||||
*/
|
||||
public void onNewTaskAdded(TaskInfo taskInfo, Settings settings);
|
||||
|
||||
/**
|
||||
* Viene invocato quando viene modificato un task
|
||||
* @param previuosTask Task prima della modifica
|
||||
* @param newTask Task dopo la modifica
|
||||
* @param settings La configurazione sul quale è stato aggiunto il task
|
||||
*/
|
||||
public void onUpdateTask(TaskInfo previuosTask, TaskInfo newTask,
|
||||
Settings settings);
|
||||
|
||||
/**
|
||||
* Viene invocato quando viene rimosso un Task
|
||||
* @param removedTask Task da rimuovere
|
||||
* @param settings La configurazione sul quale è stato aggiunto il task
|
||||
*/
|
||||
public void onRemoveTask(TaskInfo removedTask, Settings settings);
|
||||
|
||||
/**
|
||||
* Viene invocato quando viene aggiunto un Processo
|
||||
* @param processInfo Processo da aggiungere
|
||||
* @param settings La configurazione sul quale è stato aggiunto il task
|
||||
*/
|
||||
public void onAddedProcess(ProcessInfo processInfo, Settings settings);
|
||||
|
||||
/**
|
||||
* Viene invocato quando viene modificato un processo
|
||||
* @param previusProcess Processo prima della modifica
|
||||
* @param newProcess Processo dopo della modifica
|
||||
* @param settings La configurazione sul quale è stato aggiunto il task
|
||||
*/
|
||||
public void onUpdateProcess(ProcessInfo previusProcess,
|
||||
ProcessInfo newProcess, Settings settings);
|
||||
|
||||
/**
|
||||
* Viene invocato quando viene rimosso un Processo
|
||||
* @param removedProcess Processo da rimuovere
|
||||
* @param settings La configurazione sul quale è stato aggiunto il task
|
||||
*/
|
||||
public void onRemoveProcess(ProcessInfo removedProcess, Settings settings);
|
||||
|
||||
/**
|
||||
* Viene invocato quando viene cambiata la configurazione.
|
||||
* @param settings La configurazione sul quale è stato aggiunto il task
|
||||
*/
|
||||
public void onChangeConfiguration(Settings settings);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package it.valueteam.crontab.config.setting;
|
||||
|
||||
import it.valueteam.crontab.config.*;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP CRONTAB</p>
|
||||
* <p>Description: Contiene tutte le informazioni di configurazione. E' possibile registrarsi
|
||||
* per avere la notifica dei cambiamenti della configurazione.</p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: ValueTeam - TeleAp</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SettingsChangeListeners implements SettingsChangeListenerIF {
|
||||
|
||||
public void onNewTaskAdded(TaskInfo taskInfo, Settings settings) {
|
||||
onChangeConfiguration(settings);
|
||||
}
|
||||
|
||||
public void onUpdateTask(TaskInfo previuosTask, TaskInfo newTask,
|
||||
Settings settings) {
|
||||
onChangeConfiguration(settings);
|
||||
}
|
||||
|
||||
public void onRemoveTask(TaskInfo removedTask, Settings settings) {
|
||||
onChangeConfiguration(settings);
|
||||
}
|
||||
|
||||
public void onAddedProcess(ProcessInfo processInfo, Settings settings) {
|
||||
onChangeConfiguration(settings);
|
||||
}
|
||||
|
||||
public void onUpdateProcess(ProcessInfo previusProcess,
|
||||
ProcessInfo newProcess, Settings settings) {
|
||||
onChangeConfiguration(settings);
|
||||
}
|
||||
|
||||
public void onRemoveProcess(ProcessInfo removedProcess, Settings settings) {
|
||||
onChangeConfiguration(settings);
|
||||
}
|
||||
|
||||
public void onChangeConfiguration(Settings settings) {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,721 @@
|
||||
package it.valueteam.crontab.engine;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.engine.jms.*;
|
||||
import it.valueteam.crontab.obj.engine.*;
|
||||
import it.valueteam.crontab.obj.gui.*;
|
||||
import it.valueteam.crontab.processexecutor.*;
|
||||
import it.valueteam.crontab.processexecutor.utility.*;
|
||||
import it.valueteam.crontab.utility.*;
|
||||
import mnp.crontab.utility.*;
|
||||
import biz.minaret.log4j.DatedFileAppender;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP CRONTAB</p>
|
||||
* <p>Description: Gestisce l'esecuzione di un task e dei sui processi associati</p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: ValueTeam - TeleAp</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class RunnerManager implements MessageAsinchNotificationIF {
|
||||
|
||||
private static Logger log = Logger.getLogger(RunnerManager.class.getName());
|
||||
private static RunnerManager onlyInstance;
|
||||
|
||||
//costante che indica nessun ritorno dal processo chimato
|
||||
public static final int NORETVALUE = -1000;
|
||||
public static final int OKRETVALUE = 0;
|
||||
public static final int KORETVALUE = 1;
|
||||
|
||||
//lista di tutti i RunningTask in esecuzione
|
||||
// la chiave è TaskId
|
||||
private ArrayList listRunnerTask;
|
||||
//lista di tutti i processi in ESECUZIONE
|
||||
// la chiave è getIdRunningProcess
|
||||
private ArrayList listRunnerProcess;
|
||||
|
||||
//Lista ordinata di tutti i task in attesa di esecuzione
|
||||
private LinkedList listWaitingTask;
|
||||
|
||||
//Lista ordinata di tutti i processi in attesa di esecuzione
|
||||
private LinkedList listWaitingProcess;
|
||||
|
||||
/**
|
||||
* Costruttore
|
||||
*/
|
||||
|
||||
private RunnerManager() throws Exception{
|
||||
listRunnerTask = new ArrayList();
|
||||
listRunnerProcess = new ArrayList();
|
||||
listWaitingTask = new LinkedList();
|
||||
listWaitingProcess = new LinkedList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementazione del singleton
|
||||
* @return Scheduler
|
||||
*/
|
||||
public static RunnerManager getInstance() throws Exception {
|
||||
if (onlyInstance == null) {
|
||||
synchronized (Scheduler.class) {
|
||||
if (onlyInstance == null) {
|
||||
onlyInstance = new RunnerManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return onlyInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo utilizzato per chiedere al componente di eseguire un task
|
||||
* @param runningTask RunningTask
|
||||
*/
|
||||
public void executeTask(RunningTask runningTask) {
|
||||
stampaListe();
|
||||
runningTask.setState(RunningTask.STATE_RUN_AS_POSSIBLE);
|
||||
checkTaskExecution(runningTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica se è possibili eseguire il task e lo eseguo/accodo
|
||||
* @param runningTask RunningTask
|
||||
* @return boolean
|
||||
*/
|
||||
private synchronized void checkTaskExecution(RunningTask runningTask) {
|
||||
//controllo finestre temporali
|
||||
log.debug("checkTaskExecution:" + runningTask.getRunningTaskID());
|
||||
if (!runningTask.isInTimeWindow()) {
|
||||
log.info("Esecuzione Task fuori dalle finestre temporali:" +
|
||||
runningTask.getName()
|
||||
+ " stop date:" + runningTask.getStopTime().getTime().toString());
|
||||
runningTask.setState(RunningTask.STATE_IDLE);
|
||||
//notifica al TaskMonitor la non esecuzione del task
|
||||
TaskStateMonitor.getInstance().onAutoEnd(runningTask);
|
||||
listWaitingTask.remove(runningTask);
|
||||
}
|
||||
else {
|
||||
//controllo se in task è da eliminare
|
||||
if (runningTask.isToDestroy()) {
|
||||
log.info("Richiesta di arresto per il task:" + runningTask.getName());
|
||||
boolean bRemove = listWaitingTask.remove(runningTask);
|
||||
if (bRemove) {
|
||||
log.debug("Task:" + runningTask.getStopTime().getTime().toString() +
|
||||
" rimosso dalla waitlist");
|
||||
}
|
||||
/**
|
||||
* la chiamata al taskmonitor è già stata fatta per questo RunningTask
|
||||
*/
|
||||
}
|
||||
else {
|
||||
//controllo se esistono altri task dello stesso tipo in esecuzione
|
||||
RunningTask appRunningTask = searchRunningTaskFromTaskID(runningTask.
|
||||
getTaskId(), listRunnerTask.iterator());
|
||||
if (appRunningTask!=null) {
|
||||
//metto in coda il task
|
||||
//lo stato rimane quello
|
||||
//se il task non è già accodato lo accodo
|
||||
if (!listWaitingTask.contains(runningTask)) {
|
||||
//se un task uguale non è già accodato lo accodo
|
||||
RunningTask rt = searchRunningTaskFromTaskID(runningTask.getTaskId(),
|
||||
listWaitingTask.iterator());
|
||||
if (rt == null) {
|
||||
listWaitingTask.addLast(runningTask);
|
||||
log.info("Accodo Task " + runningTask.toString());
|
||||
}
|
||||
else {
|
||||
log.info("Task:" + runningTask.toString() +
|
||||
" non accodato per già presenza altro task");
|
||||
runningTask.setState(RunningTask.STATE_IDLE);
|
||||
//notifico al TaskStateMonitor
|
||||
TaskStateMonitor.getInstance().onAutoEnd(runningTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//eseguo il task
|
||||
log.info("Eseguo Task " + runningTask.toString());
|
||||
manageTaskToExecute(runningTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica se è possibili eseguire il processo e lo eseguo/accodo
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Verifica se è possibili eseguire il processo e lo eseguo/accodo
|
||||
* Se viene invocato il task sarà sicuramente in uno dei seguenti
|
||||
* stati: STATE_RUNNING,STATE_DESTROYED
|
||||
* @param runningProcess RunningProcess
|
||||
*/
|
||||
private synchronized void checkProcessExecution(RunningProcess runningProcess) {
|
||||
String processName = runningProcess.getProcessInfoRef().getProcess().
|
||||
getName();
|
||||
log.debug("checkProcessExecution:" + runningProcess.getIdRunningProcess());
|
||||
//controllo che il relativo task non sia in stato STATE_DESTROYED
|
||||
RunningTask runningTask = searchRunningTaskFromRunningTaskID(runningProcess.getIdRunningTask(),
|
||||
listRunnerTask.iterator());
|
||||
if (runningTask.getState() == RunningTask.STATE_DESTROY_AS_POSSIBLE) {
|
||||
log.info("Task distrutto:" + runningTask.getName() +
|
||||
" non eseguo processo:" + processName);
|
||||
//solo adesso lo levo dalla lista dei running task
|
||||
notifyEndTaskExecution(runningTask);
|
||||
return;
|
||||
}
|
||||
//controllo se il processo è abilitato all'esecuzione
|
||||
// if ( (!runningProcess.getProcessInfoRef().isEnabled()) ||
|
||||
// (!runningProcess.getProcessInfoRef().getProcess().getEnabled())) {
|
||||
if (!runningProcess.isEnabled()) {
|
||||
log.info("Processo:" + runningProcess.toString() + " non abilitato");
|
||||
//C.P.:lo stato del processo non cambia!!!
|
||||
executeNextTaskProcess(runningTask);
|
||||
return;
|
||||
}
|
||||
//controllo se esistono processi dello stesso tipo in esecuzione
|
||||
RunningProcess rp = searchRunningProcessFromProcessID(
|
||||
runningProcess.getProcessInfoRef().getProcess().getId(),listRunnerProcess.iterator());
|
||||
if (rp!=null) {
|
||||
log.info("Processo:"+runningProcess.toString()+" gia' in esecuzione");
|
||||
//notifico il cambio di stato del processo
|
||||
runningTask.setProcessState(runningProcess.getProcessInfoRef().getProcess().
|
||||
getId(),
|
||||
RunningTask.PROCESS_STATE_RUN_AS_POSSIBLE);
|
||||
//i processi si accodano senza tener conto del numero
|
||||
//se non è già nella lista di wait ce lo metto
|
||||
if (!listWaitingProcess.contains(runningProcess)) {
|
||||
log.info("Accodo processo:" + runningProcess.toString());
|
||||
listWaitingProcess.addLast(runningProcess);
|
||||
//Notifico al TaskStateMonitor l'accodamento del processo
|
||||
TaskStateMonitor.getInstance().onInWaitingForProcess(runningTask,runningProcess.getProcessInfoRef().getProcess());
|
||||
}
|
||||
return;
|
||||
}
|
||||
//controllo se esistono processi propedeutici in esec.
|
||||
RunningProcess rp1 = searchBlockingProcessInExecution(runningProcess,
|
||||
listRunnerProcess);
|
||||
if (rp1 != null) {
|
||||
log.info("Processo :" + runningProcess.toString() +
|
||||
" non puo' essere eseguito " +
|
||||
" perchè è in esecuzione il processo:" +
|
||||
rp1.getProcessInfoRef().getProcess().getName());
|
||||
//notifico il cambio di stato del processo
|
||||
runningTask.setProcessState(runningProcess.getProcessInfoRef().getProcess().
|
||||
getId(),
|
||||
RunningTask.PROCESS_STATE_RUN_AS_POSSIBLE);
|
||||
//i processi si accodano senza tener conto del numero
|
||||
//se non è già nella lista di wait ce lo metto
|
||||
if (!listWaitingProcess.contains(runningProcess)) {
|
||||
log.info("Accodo processo:" + runningProcess.toString());
|
||||
listWaitingProcess.addLast(runningProcess);
|
||||
//Notifico al TaskStateMonitor l'accodamento del processo
|
||||
TaskStateMonitor.getInstance().onInWaitingForProcess(runningTask,runningProcess.getProcessInfoRef().getProcess());
|
||||
}
|
||||
return;
|
||||
}
|
||||
//eseguo il processo
|
||||
manageProcessToExecute(runningProcess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica solo se esiste il prossimo processo da eseguire e ne chiede l'esecuzione
|
||||
* Se non esiste imposta il task come eseguito
|
||||
* IL metodo deve essere chimato solo se il task è in stato Running
|
||||
* @param runningTask RunningTask
|
||||
*/
|
||||
private void executeNextTaskProcess(RunningTask runningTask) {
|
||||
log.debug("executeNextTaskProcess:" + runningTask.toString());
|
||||
RunningProcess nextRunningProcess = runningTask.getNextProcessToExecute();
|
||||
if (nextRunningProcess != null) {
|
||||
checkProcessExecution(nextRunningProcess);
|
||||
}
|
||||
else {
|
||||
notifyEndTaskExecution(runningTask);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Termina il task e verifica se task in attesa possono essere eseguiti
|
||||
* @param runningTask RunningTask
|
||||
*/
|
||||
private synchronized void notifyEndTaskExecution(RunningTask runningTask) {
|
||||
try {
|
||||
log.debug("notifyEndTaskExecution:" + runningTask.toString());
|
||||
if (runningTask.getState() == RunningTask.STATE_RUNNING) {
|
||||
runningTask.setState(RunningTask.STATE_EXECUTED);
|
||||
//notifico al TaskStateMonitor la fine del Task
|
||||
TaskStateMonitor.getInstance().onEndRunning(runningTask);
|
||||
}
|
||||
else if (runningTask.getState() == RunningTask.STATE_DESTROY_AS_POSSIBLE) {
|
||||
runningTask.setState(RunningTask.STATE_DESTROYED);
|
||||
/*già fatto sul set di STATE_DESTROY_AS_POSSIBLE
|
||||
runningTask.setAsToDestroy();
|
||||
*/
|
||||
//notifico al TaskStateMonitor la distruzione del task
|
||||
TaskStateMonitor.getInstance().onDestroy(runningTask);
|
||||
}
|
||||
else {
|
||||
log.error("errore in notifyEndTaskExecution runningTask:"+runningTask.getRunningTaskID()+" in stato:"+runningTask.getState());
|
||||
}
|
||||
listRunnerTask.remove(runningTask);
|
||||
//data fine task
|
||||
runningTask.setStopDate(new EventTime());
|
||||
|
||||
if (listWaitingTask.size() > 0) {
|
||||
RunningTask[] waitTask = new RunningTask[listWaitingTask.size()];
|
||||
waitTask = (RunningTask[]) listWaitingTask.toArray(waitTask);
|
||||
for (int i = 0; i < waitTask.length; i++) {
|
||||
if (waitTask[i].getState() ==
|
||||
RunningTask.STATE_RUN_AS_POSSIBLE) {
|
||||
checkTaskExecution(waitTask[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
log.error("Errore in notifyEndTaskExecution, runningTask:" + runningTask);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Termina il task e verifica se task in attesa possono essere eseguiti
|
||||
* @param runningTask RunningTask
|
||||
*/
|
||||
private synchronized void notifyEndProcessExecution(RunningProcess
|
||||
runningProcess) {
|
||||
RunningTask runningTask = null;
|
||||
try {
|
||||
log.debug("notifyEndProcessExecution:" + runningProcess.toString());
|
||||
listRunnerProcess.remove(runningProcess);
|
||||
//ottengo il runningTask relativo al processo terminato
|
||||
runningTask = searchRunningTaskFromRunningTaskID(runningProcess.
|
||||
getIdRunningTask(), listRunnerTask.iterator());
|
||||
// //recupero l'exitValue del processo
|
||||
// int exitValue=runningTask.getExitValue(runningProcess.getProcessInfoRef().getProcess().getId());
|
||||
//notifico al TaskStateMonitor la fine dell'esecuzione del processo
|
||||
TaskStateMonitor.getInstance().onEndRunningProcess(runningTask,
|
||||
runningProcess.getProcessInfoRef().getProcess());
|
||||
|
||||
//esecuzione dei possibili task in wait
|
||||
if (listWaitingProcess.size() > 0) {
|
||||
log.debug("notifyEndProcessExecution process in wait:" +
|
||||
runningProcess.toString());
|
||||
RunningProcess[] waitProcess = new RunningProcess[listWaitingProcess.size()];
|
||||
waitProcess = (RunningProcess[]) listWaitingProcess.toArray(waitProcess);
|
||||
for (int i = 0; i < waitProcess.length; i++) {
|
||||
checkProcessExecution(waitProcess[i]);
|
||||
}
|
||||
}
|
||||
//eseguo il prossimo processo del task
|
||||
executeNextTaskProcess(runningTask);
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
log.error("Errore in notifyEndProcessExecution, runningProcess:" +
|
||||
runningProcess);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposto esecuzione del TASK
|
||||
* @param runningProcess RunningProcess
|
||||
*/
|
||||
private void manageTaskToExecute(RunningTask runningTask) {
|
||||
log.debug("manageTaskToExecute:" + runningTask.toString());
|
||||
runningTask.setState(RunningTask.STATE_RUNNING);
|
||||
//nella lista ci metto il taskID che è uguale per tutti i task dello stesso tipo
|
||||
listRunnerTask.add(runningTask);
|
||||
|
||||
boolean bRemove = listWaitingTask.remove(runningTask);
|
||||
if (bRemove) {
|
||||
log.debug("Task:" + runningTask.toString() +
|
||||
" rimosso dalla waitlist");
|
||||
}
|
||||
executeNextTaskProcess(runningTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposto l'esecuzione del processo
|
||||
* al messagehandler comunico IdRunningProcess
|
||||
* @param runningProcess RunningProcess
|
||||
*/
|
||||
private void manageProcessToExecute(RunningProcess runningProcess) {
|
||||
log.info("Imposto l'esecuzione del processo:"+runningProcess.toString());
|
||||
listRunnerProcess.add(runningProcess);
|
||||
//Ottengo il runningTask relativo al processo in esecuzione
|
||||
RunningTask runningTask = searchRunningTaskFromRunningTaskID(runningProcess.getIdRunningTask(),listRunnerTask.iterator());
|
||||
//notifico al TaskStateMonitor l'esecuzione del processo
|
||||
TaskStateMonitor.getInstance().onRunningProcess(runningTask,runningProcess.getProcessInfoRef().getProcess());
|
||||
//notifico il cambio di stato del processo
|
||||
runningTask.setProcessState(runningProcess.getProcessInfoRef().getProcess().
|
||||
getId(),
|
||||
RunningTask.PROCESS_STATE_RUNNING);
|
||||
if (listWaitingProcess.contains(runningProcess))
|
||||
listWaitingProcess.remove(runningProcess);
|
||||
//chiamata al messageHandler
|
||||
try {
|
||||
//obj per gestine asincrona dell'esecuzione dei processi
|
||||
MessageHandler messageHandler = new MessageHandler(this,log,true);
|
||||
messageHandler.sendMessage(runningProcess.getIdRunningProcess());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.error("Errore in manageProcessToExecute, runningProcess:" +
|
||||
runningProcess);
|
||||
ex.printStackTrace();
|
||||
//se non va bene vado avanti e setto lo stato di uscita
|
||||
|
||||
runningTask.setProcessState(runningProcess.getProcessInfoRef().getProcess().
|
||||
getId(),
|
||||
RunningTask.PROCESS_STATE_EXITVALUEKO);
|
||||
|
||||
notifyEndProcessExecution(runningProcess);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Esecuzione effettiva del processo
|
||||
* richiamato asincronamente
|
||||
* @param runningProcess RunningProcess
|
||||
*/
|
||||
private void executeProcess(RunningProcess runningProcess, RunningTask runningTask) throws Exception{
|
||||
Logger outLog = null;
|
||||
String processName=null;
|
||||
int exitValue = NORETVALUE;
|
||||
|
||||
try {
|
||||
processName = runningProcess.getProcessInfoRef().getProcess().getName();
|
||||
log.info("Chiamata al processo:" + runningProcess.toString());
|
||||
//creazione del log
|
||||
String procLogDir = Resources.getRecursiveProps("dirLogApp") + "/";
|
||||
Layout layoutLog = new PatternLayout("%d - %c - %m%n");
|
||||
Appender appender = new DatedFileAppender(procLogDir,processName+".",".log");
|
||||
appender.setLayout(layoutLog);
|
||||
outLog = Logger.getLogger(processName);
|
||||
outLog.setAdditivity(false);
|
||||
outLog.setLevel(Level.ALL);
|
||||
outLog.removeAllAppenders();
|
||||
outLog.addAppender(appender);
|
||||
|
||||
|
||||
//fine init log
|
||||
try {
|
||||
outLog.info("Esecuzione processo:"+processName+";parametro:"+runningProcess.getProcessInfoRef().getProcess().getParams());
|
||||
ProcessExecutor processExecutor = new ProcessExecutor();
|
||||
processExecutor.executeProcess(createProcessArgs(runningProcess));
|
||||
//se tutto va bene
|
||||
exitValue = OKRETVALUE;
|
||||
outLog.info("Fine esecuzione processo:"+processName+";parametro:"+runningProcess.getProcessInfoRef().getProcess().getParams());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
//altrimenti
|
||||
exitValue = KORETVALUE;
|
||||
outLog.error("Eccezione processo:"+processName,ex);
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
if (outLog!=null)
|
||||
outLog.removeAllAppenders();
|
||||
}
|
||||
log.info("Esecuzione eseguita del processo:" + runningProcess.toString());
|
||||
}
|
||||
catch (Exception ex1) {
|
||||
//finally
|
||||
log.error("Esecuzione in ERRORE del processo:" + runningProcess.toString());
|
||||
throw ex1;
|
||||
}
|
||||
finally {
|
||||
int processState=exitValue;//inizializzazione fasulla
|
||||
if (exitValue==OKRETVALUE)
|
||||
processState=RunningTask.PROCESS_STATE_EXITVALUEOK;
|
||||
else
|
||||
processState=RunningTask.PROCESS_STATE_EXITVALUEKO;
|
||||
runningTask.setProcessState(runningProcess.getProcessInfoRef().getProcess().
|
||||
getId(),
|
||||
processState);
|
||||
//una volta eseguito vedo se ci sono processi in attesa da svegliare ed eseguo il prossimo processo del task
|
||||
notifyEndProcessExecution(runningProcess);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getEnv
|
||||
*
|
||||
* @return ClusterEnvironment
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Crea l'array contenente gli argomenti necessari all'esecuzione del processo
|
||||
*
|
||||
* @param runningProcess RunningProcess
|
||||
* @return String[]
|
||||
*/
|
||||
private String[] createProcessArgs(RunningProcess runningProcess) {
|
||||
String[] args = new String[2];
|
||||
args[0] = runningProcess.getProcessInfoRef().getProcess().getCommand();
|
||||
args[1] = runningProcess.getProcessInfoRef().getProcess().getParams();
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Esegue l'arresto di tutti i task secondo la seguente policy:
|
||||
* - Se il task è in waiting list viene rimosso dalla lista e il suo stato diventa DESTROYED
|
||||
* - Se il task è in esecuzione lo stato diventa DESTROYED mentre la rimozione è effettuata
|
||||
* al termine del processo correntemente in esecuzione
|
||||
*/
|
||||
public synchronized void stop() {
|
||||
RunningTask runningTask=null;
|
||||
Iterator iter = null;
|
||||
log.info("stop() called");
|
||||
//itero sulla listRunnerTask
|
||||
log.info("Inizio clean listRunnerTask, size : " +listRunnerTask.size());
|
||||
iter = listRunnerTask.iterator();
|
||||
while (iter.hasNext()) {
|
||||
runningTask = (RunningTask)iter.next();
|
||||
destroy(runningTask);
|
||||
}
|
||||
log.info("Fine clean listRunnerTask, size : " +listRunnerTask.size());
|
||||
//itero sulla listWaitingTask
|
||||
log.info("Inizio clean listWaitingTask, size : " +listWaitingTask.size());
|
||||
iter = listWaitingTask.iterator();
|
||||
while (iter.hasNext()) {
|
||||
runningTask = (RunningTask)iter.next();
|
||||
destroy(runningTask);
|
||||
}
|
||||
log.info("Fine clean listWaitingTask, size : " +listWaitingTask.size());
|
||||
//to do verificare che non va fatto
|
||||
TaskStateMonitor.getInstance().onStopRunnerManager();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Eseguo l'arresto forzato di un task
|
||||
* @param rTaskId String
|
||||
*/
|
||||
public synchronized void destroy(String runningTaskID) {
|
||||
RunningTask runningTask = null;
|
||||
log.info("Richieste di distruzione del runningTaskID:"+runningTaskID);
|
||||
runningTask = searchRunningTaskFromRunningTaskID(runningTaskID,listRunnerTask.iterator());
|
||||
if (runningTask==null) {
|
||||
//il task è in wait
|
||||
runningTask = searchRunningTaskFromRunningTaskID(runningTaskID,
|
||||
listWaitingTask.iterator());
|
||||
}
|
||||
destroy(runningTask);
|
||||
}
|
||||
|
||||
private synchronized void destroy(RunningTask runningTask) {
|
||||
if (runningTask!=null) {
|
||||
if (runningTask.getState() == RunningTask.STATE_RUNNING) {
|
||||
//per i task in running lo levo al successivo processo
|
||||
runningTask.setState(RunningTask.STATE_DESTROY_AS_POSSIBLE);
|
||||
runningTask.setAsToDestroy();
|
||||
log.info("runningTask"+runningTask+" set to STATE_DESTROY_AS_POSSIBLE");
|
||||
}
|
||||
else {
|
||||
if (runningTask.getState() == RunningTask.STATE_RUN_AS_POSSIBLE) {
|
||||
runningTask.setState(RunningTask.STATE_DESTROYED);
|
||||
runningTask.setAsToDestroy();
|
||||
runningTask.setStopDate(new EventTime());
|
||||
//per i task in attesa lo levo subito
|
||||
listWaitingTask.remove(runningTask);
|
||||
TaskStateMonitor.getInstance().onDestroy(runningTask);
|
||||
log.info("runningTask"+runningTask+" set to STATE_DESTROYED");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
log.warn("distruzione di runningTask non esistente");
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo di notifica asincrona per l'esecuzione dei processi
|
||||
* non deve essere sincronizzato
|
||||
* @param obj Object- id del running process
|
||||
*/
|
||||
public void notifyAsinchEvent(Object obj) {
|
||||
RunningProcess runningProcess = null;
|
||||
ArrayList cloneListRunningProcess=null;
|
||||
ArrayList cloneListRunningTask=null;
|
||||
RunningTask runningTask=null;
|
||||
try {
|
||||
String idRunningProcess = (String)obj;
|
||||
//syncronizzo per evitare problemi di concorrenza
|
||||
synchronized(this) {
|
||||
cloneListRunningProcess = (ArrayList)listRunnerProcess.clone();
|
||||
cloneListRunningTask = (ArrayList)listRunnerTask.clone();
|
||||
}
|
||||
runningProcess = searchRunningProcessFromIdRunningProcess(
|
||||
idRunningProcess, cloneListRunningProcess.listIterator());
|
||||
runningTask = searchRunningTaskFromRunningTaskID(runningProcess.
|
||||
getIdRunningTask(),
|
||||
cloneListRunningTask.iterator());
|
||||
|
||||
executeProcess(runningProcess, runningTask);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*************** METODI DI RICERCA NELLE LISTE *************************************************/
|
||||
/**
|
||||
* ricerca il task partendo dal RunningTaskID
|
||||
* @param runningTaskID String
|
||||
* @param iter Iterator
|
||||
* @return RunningTask
|
||||
*/
|
||||
private synchronized final RunningTask searchRunningTaskFromRunningTaskID(String runningTaskID,Iterator iter) {
|
||||
RunningTask item=null;
|
||||
|
||||
boolean trovato = false;
|
||||
|
||||
while (iter.hasNext()) {
|
||||
item = (RunningTask)iter.next();
|
||||
|
||||
if (item.getRunningTaskID().equalsIgnoreCase(runningTaskID)) {
|
||||
trovato = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (trovato) {
|
||||
return item;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ricerca il task partendo dal TaskID
|
||||
* @param taskID String
|
||||
* @param iter Iterator
|
||||
* @return RunningTask
|
||||
*/
|
||||
private synchronized final RunningTask searchRunningTaskFromTaskID(String taskID,Iterator iter) {
|
||||
RunningTask item=null;
|
||||
|
||||
boolean trovato = false;
|
||||
while (iter.hasNext()) {
|
||||
item = (RunningTask) iter.next();
|
||||
if (item.getTaskId().equalsIgnoreCase(taskID)) {
|
||||
trovato = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (trovato) {
|
||||
return item;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized final RunningProcess searchRunningProcessFromProcessID(String processID, Iterator iter) {
|
||||
RunningProcess item = null;
|
||||
boolean trovato = false;
|
||||
while (iter.hasNext()) {
|
||||
item = (RunningProcess) iter.next();
|
||||
if (item.getProcessInfoRef().getProcess().getId().equalsIgnoreCase(processID)) {
|
||||
trovato = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (trovato) {
|
||||
return item;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cerca un processo in esecuzione partendo dai processi
|
||||
* bloccanti per un runningprocess
|
||||
* @param runningProcess RunningProcess
|
||||
* @param list HashMap
|
||||
* @return RunningProcess
|
||||
*/
|
||||
private synchronized final RunningProcess searchBlockingProcessInExecution(RunningProcess runningProcess, ArrayList list) {
|
||||
|
||||
ProcessInfo.BlockingProcessInfoRef item = null;
|
||||
boolean trovato = false;
|
||||
|
||||
ArrayList blockingProcessList=null;
|
||||
RunningProcess ret=null;
|
||||
|
||||
blockingProcessList = runningProcess.getProcessInfoRef().getProcess().getBlockingProcessList();
|
||||
if ((blockingProcessList!=null) &&
|
||||
(blockingProcessList.size()>0)) {
|
||||
for (Iterator iter = blockingProcessList.iterator(); iter.hasNext(); ) {
|
||||
item = (ProcessInfo.BlockingProcessInfoRef)iter.next();
|
||||
ret = searchRunningProcessFromProcessID(item.getProcID(),list.iterator());
|
||||
if (ret!=null) {
|
||||
trovato=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trovato) {
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized final RunningProcess searchRunningProcessFromIdRunningProcess(String idRunningProcess, Iterator iter) {
|
||||
RunningProcess item = null;
|
||||
boolean trovato = false;
|
||||
while (iter.hasNext()) {
|
||||
item = (RunningProcess) iter.next();
|
||||
if (item.getIdRunningProcess().equalsIgnoreCase(idRunningProcess)) {
|
||||
trovato = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (trovato)
|
||||
return item;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************************************************/
|
||||
/**
|
||||
* degug stampa delle liste interne
|
||||
*/
|
||||
private synchronized final void stampaListe() {
|
||||
log.debug("listRunnerTask");
|
||||
stampaLista(listRunnerTask);
|
||||
|
||||
log.debug("listWaitingTask");
|
||||
stampaLista(listWaitingTask);
|
||||
|
||||
log.debug("listRunnerProcess");
|
||||
stampaLista(listRunnerProcess);
|
||||
|
||||
log.debug("listWaitingProcess");
|
||||
stampaLista(listWaitingProcess);
|
||||
}
|
||||
|
||||
/**
|
||||
* debug metodo per stampare il contenuto della lista
|
||||
* @param list List
|
||||
*/
|
||||
private final void stampaLista(List list) {
|
||||
log.debug("list.size:"+list.size());
|
||||
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
|
||||
Object item = (Object) iter.next();
|
||||
log.debug("list:" + item.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,552 @@
|
||||
package it.valueteam.crontab.engine;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP CRONTAB</p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: ValueTeam - TeleAp</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
import java.util.*;
|
||||
import javax.management.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.config.setting.*;
|
||||
import it.valueteam.crontab.engine.exception.*;
|
||||
import it.valueteam.crontab.obj.engine.*;
|
||||
import it.valueteam.crontab.obj.gui.*;
|
||||
import it.valueteam.crontab.utility.EventTime;
|
||||
import mnp.crontab.utility.*;
|
||||
import weblogic.management.timer.Timer;
|
||||
|
||||
|
||||
public class Scheduler implements NotificationListener,SchedulerIF {
|
||||
/** tipologia eventi **/
|
||||
//evento di rischedulazione dei task
|
||||
private static final String EVENT_SCHEDULER = "1";
|
||||
//eventi di schedulazione TASK
|
||||
private static final String EVENT_EXECUTE_TASK = "2";
|
||||
/**FINE**/
|
||||
/************* STATI INTERNI ********************/
|
||||
//indica che lo schedule <20> attivo
|
||||
private boolean active = false;
|
||||
//indica che lo schedule <20> master
|
||||
private boolean master = false;
|
||||
//indica che lo scheduler <20> settato per essere startato
|
||||
//questa propriet<65> dipende dal valore della propriet<65> di sistema
|
||||
//CRONTAB_ACTIVE presente sullo start del server, il va<76>lore cambia
|
||||
//anche quando l'utente abilita/disabilita da GUI
|
||||
private boolean userStart = false;
|
||||
|
||||
/************* FINE STATI INTERNI ***************/
|
||||
|
||||
private static Logger log = Logger.getLogger(Scheduler.class.getName());
|
||||
static private Scheduler onlyInstance = null;
|
||||
|
||||
private weblogic.management.timer.Timer timer = null;
|
||||
private Settings settings = null;
|
||||
//
|
||||
private boolean loadConfiguration = true;
|
||||
//to do !!!
|
||||
private boolean invalidated = false;
|
||||
private HashMap scheduledTaskEventList;
|
||||
private Date nextSchedulerTime;
|
||||
private Date lastInvalidate;
|
||||
private Exception endException;
|
||||
private Date lastStartScheduler=null;
|
||||
|
||||
private boolean first=true;
|
||||
|
||||
|
||||
/**
|
||||
* costruttore
|
||||
*/
|
||||
private Scheduler() throws NotValidCrontabFileException{
|
||||
active = false;
|
||||
//settings = Settings.getInstance();
|
||||
try {
|
||||
Settings.getInstance(Resources.getCRONTAB_CONF_FILE());
|
||||
}
|
||||
catch (NotValidCrontabFileException ex) {
|
||||
log.error("Problemi con la configurazione:");
|
||||
log.error(ex);
|
||||
ex.printStackTrace();
|
||||
log.error("Caricamento dell'ultima configurazione valida..");
|
||||
Settings.getInstance().loadLastGood();
|
||||
}
|
||||
settings = Settings.getInstance();
|
||||
settings.register(new SettingsChangeListeners() {
|
||||
public void onChangeConfiguration(Settings settings) {
|
||||
//_instance.settings=settings; non serve perch<63> settings <20> un singleton
|
||||
onlyInstance.invalidate();
|
||||
}
|
||||
});
|
||||
scheduledTaskEventList = new HashMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementazione del singleton
|
||||
* @return Scheduler
|
||||
*/
|
||||
public static Scheduler getInstance() throws NotValidCrontabFileException{
|
||||
if (onlyInstance == null) {
|
||||
synchronized (Scheduler.class) {
|
||||
if (onlyInstance == null) {
|
||||
onlyInstance = new Scheduler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return onlyInstance;
|
||||
}
|
||||
|
||||
/******************** MACRO GESTIONE TIMER ******************/
|
||||
|
||||
private synchronized void initTimerMBean() {
|
||||
if (timer == null) {
|
||||
// Instantiating the Timer MBean
|
||||
/*non usiamo l'implementazione java standard ma l'estensione di weblogic
|
||||
in modo che i thread siano quelli controllati dall'as
|
||||
*/
|
||||
timer = new weblogic.management.timer.Timer();
|
||||
// Registering this class as a listener
|
||||
timer.addNotificationListener(this, null, null);
|
||||
//setto il past notification per le notifiche appena inserite per cui lo start avviene infinitamente dopo
|
||||
timer.setSendPastNotifications(true);
|
||||
// Start Timer MBean
|
||||
timer.start();
|
||||
log.info("Attivazione timer");
|
||||
}
|
||||
else
|
||||
log.info("timer gia' attivato");
|
||||
}
|
||||
|
||||
/**
|
||||
* interfaccia per la distruzione/stop dei Timer interni
|
||||
* l'implementazione generica va bene x tutti
|
||||
*/
|
||||
private synchronized void destroyTimer() throws Exception {
|
||||
if (timer!=null) {
|
||||
timer.stop();
|
||||
log.info("stop del timer eseguito");
|
||||
timer.removeAllNotifications();
|
||||
log.info("rimozione di tutte le schedulazioni eseguita");
|
||||
try {
|
||||
timer.removeNotificationListener(this);
|
||||
log.info("rimozione dell'ascolto sul timer");
|
||||
}
|
||||
catch (ListenerNotFoundException ex) {
|
||||
System.out.println("Eccezione in destroyTimer: " + this.getClass().getName());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
timer=null;
|
||||
}
|
||||
}
|
||||
|
||||
/******************** FINE MACRO GESTIONE TIMER ******************/
|
||||
|
||||
/**
|
||||
* Gestione timer
|
||||
* @param notification Notification
|
||||
* @param object Object
|
||||
*/
|
||||
public void handleNotification(Notification notification, Object object) {
|
||||
RunningTask runningTask = null;
|
||||
String idRunningTask = null;
|
||||
try {
|
||||
/**
|
||||
* il controllo delle finestre temporali/abilitazione task deve farlo solo chi manda in esecuzione
|
||||
* il task
|
||||
*/
|
||||
if (notification.getMessage().equals(EVENT_SCHEDULER)) {
|
||||
//evento di rischedulazione
|
||||
log.info("Rischedulazione evento scheduler");
|
||||
if ((scheduledTaskEventList.size()!=0) ||
|
||||
//per il timer c'<27> la notifica di rischedulazione,quello chye sto eseguendo
|
||||
(timer.getAllNotificationIDs().size()>1)) {
|
||||
log.error("rischedulazione con eventi ancora schedulati");
|
||||
log.error("scheduledTaskEventList.size():" +
|
||||
scheduledTaskEventList.size());
|
||||
log.error("timer.getAllNotificationIDs().size():" +
|
||||
timer.getAllNotificationIDs().size());
|
||||
String item = null;
|
||||
for (Iterator iter = scheduledTaskEventList.keySet().iterator();
|
||||
iter.hasNext(); ) {
|
||||
item = (String) iter.next();
|
||||
log.error("trovato task:" + item);
|
||||
}
|
||||
Vector timerNotVector = timer.getAllNotificationIDs();
|
||||
Integer notID = null;
|
||||
for (Iterator iter = timerNotVector.iterator(); iter.hasNext(); ) {
|
||||
notID = (Integer)iter.next();
|
||||
log.error("trovata not.ID:" + notID);
|
||||
log.error("trovata not.message:" + timer.getNotificationMessage(notID));
|
||||
log.error("trovata not.userData:" + timer.getNotificationUserData(notID));
|
||||
if (timer.getDate(notID)==null)
|
||||
log.error("trovata not.date:null");
|
||||
else
|
||||
log.error("trovata not.date:" + timer.getDate(notID).toString());
|
||||
}
|
||||
log.info("rimozione forzata di tutte le notifiche");
|
||||
timer.removeAllNotifications();
|
||||
scheduledTaskEventList.clear();
|
||||
}
|
||||
reSchedule();
|
||||
}
|
||||
else
|
||||
if (notification.getMessage().equals(EVENT_EXECUTE_TASK)) {
|
||||
idRunningTask = (String)notification.getUserData();
|
||||
log.info("esecuzione notifica:"+notification.getSequenceNumber());
|
||||
log.info("esecuzione evento task:"+idRunningTask);
|
||||
runningTask = (RunningTask)scheduledTaskEventList.get(idRunningTask);
|
||||
if (runningTask==null)
|
||||
log.error("runningtask non trovato!!!HELP!!!:"+notification.getUserData());
|
||||
else {
|
||||
//comunico a chi di dover l'esecuzione del task e lo elimino
|
||||
//dalla lista dei task schedulati
|
||||
synchronized(scheduledTaskEventList) {
|
||||
scheduledTaskEventList.remove(idRunningTask);
|
||||
}
|
||||
log.info("attivo:"+runningTask.toString());
|
||||
RunnerManager.getInstance().executeTask(runningTask);
|
||||
log.info("attivato:"+runningTask.toString());
|
||||
}
|
||||
}
|
||||
else {
|
||||
log.error("Evento di schedulazione non previsto:" +
|
||||
notification.getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.println("Eccezione in handleNotification nel Scheduler: " +
|
||||
this.getClass().getName());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanSchedulation() throws Exception{
|
||||
destroyTimer();
|
||||
initTimerMBean();
|
||||
synchronized(scheduledTaskEventList) {
|
||||
scheduledTaskEventList.clear();
|
||||
}
|
||||
//notifico al TaskStateMonitor il reset dello scheduler
|
||||
TaskStateMonitor.getInstance().onResetScheduled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifica che il file di configurazione <20> stato cambiato.
|
||||
*/
|
||||
public void invalidate() {
|
||||
log.info("Invalidate called");
|
||||
lastInvalidate = new Date();
|
||||
try {
|
||||
//rieseguo tutto solo se il crontab <20> attivo
|
||||
if (active) {
|
||||
cleanSchedulation();
|
||||
timer.stop();
|
||||
reSchedule();
|
||||
timer.start();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rischedulazione giornaliera
|
||||
*/
|
||||
private void reSchedule() throws Exception{
|
||||
log.info("Start rischedulazione");
|
||||
if(userStart){
|
||||
if (master) {
|
||||
//devo essere gi<67> attivo
|
||||
if (active) {
|
||||
try {
|
||||
lastStartScheduler = new Date();
|
||||
nextSchedulerTime = schedule();
|
||||
//aggiungo la schedulazione giornaliera dello scheduler
|
||||
Integer idNotification = timer.addNotification("Next Scheduled Time" + nextSchedulerTime,
|
||||
EVENT_SCHEDULER,
|
||||
null,
|
||||
nextSchedulerTime);
|
||||
log.debug("Aggiunta schedulazione interna id:"+idNotification);
|
||||
}
|
||||
catch (NotValidCrontabFileException ex) {
|
||||
endException = ex;
|
||||
log.error("FILE di CRONTAB non valido" + ex);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
log.error("Scheduler disattivo attivo");
|
||||
}
|
||||
else {
|
||||
log.error("Scheduler start ma non master");
|
||||
}
|
||||
}else{
|
||||
log.error("Lo Scheduler non pu<70> essere startato perch<63> userStart : " + userStart);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* start del timer
|
||||
* @throws Exception
|
||||
*/
|
||||
public synchronized void start() throws Exception {
|
||||
log.info("Chiamata allo 'start' dello scheduler");
|
||||
if(userStart){
|
||||
if (master) {
|
||||
if (!active) {
|
||||
try {
|
||||
if (timer == null) {
|
||||
initTimerMBean();
|
||||
}
|
||||
lastStartScheduler = new Date();
|
||||
nextSchedulerTime = schedule();
|
||||
//aggiungo la schedulazione del task
|
||||
Integer idNotification = timer.addNotification("Next Scheduled Time" + nextSchedulerTime,
|
||||
EVENT_SCHEDULER,
|
||||
null,
|
||||
nextSchedulerTime);
|
||||
active = true;
|
||||
log.info("scheduler settato attivo");
|
||||
log.debug("Aggiunta schedulazione interna id:"+idNotification);
|
||||
}
|
||||
catch (NotValidCrontabFileException ex) {
|
||||
endException = ex;
|
||||
log.error("FILE di CRONTAB non valido" + ex);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
log.info("Scheduler gia' attivo");
|
||||
}
|
||||
else {
|
||||
log.info("Scheduler start ma non master");
|
||||
}
|
||||
}else{
|
||||
log.info("Lo Scheduler non pu<70> essere startato perch<63> userStart : " + userStart);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* carica la configurazione e schedula i task
|
||||
* @throws NotValidCrontabFileException
|
||||
* @throws Exception
|
||||
* @return Date
|
||||
*/
|
||||
private Date schedule() throws NotValidCrontabFileException, Exception {
|
||||
ArrayList taskList = null;
|
||||
//carico la lista dei task da file di cfg
|
||||
if (loadConfiguration) {
|
||||
settings.load(settings.getFileCfg());
|
||||
loadConfiguration = false;
|
||||
}
|
||||
taskList = settings.getTaskList();
|
||||
|
||||
EventTime now = new EventTime();
|
||||
EventTime endOfSchedule = now.getRelEvent(23, 59, 0, 0);
|
||||
endOfSchedule.add(Calendar.MINUTE, 1); // la mezzanotte, 0:00 del giorno successivo
|
||||
if(!Resources.isFestivo(now)) {
|
||||
TaskInfo item = null;
|
||||
try {
|
||||
for (Iterator i = taskList.iterator(); i.hasNext(); ) {
|
||||
item = (TaskInfo) i.next();
|
||||
if (!item.isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
scheduleTaskEvents(now, endOfSchedule, item);
|
||||
log.debug("Aggiunte schedulazioni per il task:" + item.getName());
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
log.error("impossibile eseguire schedulazione");
|
||||
scheduledTaskEventList.clear();
|
||||
throw ex;
|
||||
}
|
||||
|
||||
settings.saveAsLastGood();
|
||||
}
|
||||
else {
|
||||
log.info("GIORNO FESTIVO (" + now.toString() + ") ----------> Schedulazione vuota");
|
||||
}
|
||||
log.info("--------------->| FINE SCHEDULAZIONE at " + (new GregorianCalendar()).getTime().toString());
|
||||
return endOfSchedule.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* aggiunge gli eventi di schedulazione del task
|
||||
* Gli eventi vengono inseriti per ogni intervallo specificato da every partendo dalla
|
||||
* data specificata da from e per finire alla data specificata da to.
|
||||
* @param from EventTime
|
||||
* @param to EventTime
|
||||
* @param taskInfo TaskInfo
|
||||
*/
|
||||
private void scheduleTaskEvents(EventTime from, EventTime to,TaskInfo taskInfo) {
|
||||
Integer idNotification = null;
|
||||
log.debug("addEvents() - Richiesta di tutte le schedulazione del task " + taskInfo.getId() +
|
||||
" dalle " + from.getTime().toString() + " alle " + to.getTime().toString());
|
||||
Set set = taskInfo.getActivationIntervalSet(from,to);
|
||||
if (set.isEmpty()) {
|
||||
log.debug("non c'e' nulla da schedulare");
|
||||
}
|
||||
else {
|
||||
ActivationInterval item=null;
|
||||
for (Iterator i = set.iterator(); i.hasNext(); ) {
|
||||
item = (ActivationInterval) i.next();
|
||||
log.debug("Schedulazione task: " + taskInfo.getId() + " delle " +
|
||||
item.getFrom().getTime().toString());
|
||||
RunningTask runnningTask = new RunningTask(taskInfo, item.getFrom(),item.getTo());
|
||||
//aggiungo la schedulazione del task
|
||||
/**
|
||||
* per adesso non salviamo da nessuna parte il idNotification dato che non esiste nessuna
|
||||
* fuinzionalit<69> che prevede l'arresto di una schedulazione
|
||||
*/
|
||||
idNotification = timer.addNotification("task:"+runnningTask.getRunningTaskID(),
|
||||
EVENT_EXECUTE_TASK,
|
||||
runnningTask.getRunningTaskID(),
|
||||
runnningTask.getScheduledStart().getTime());
|
||||
log.debug("Aggiunto schedulazione interna per task:"+runnningTask.getRunningTaskID()+";data:+"+runnningTask.getScheduledStart().getTime().toString()+";ID:"+idNotification);
|
||||
if (timer.getNotificationMessage(idNotification)==null) {
|
||||
log.error("trovata schedulazione con parametri null");
|
||||
log.error("trovata not.ID:" + idNotification);
|
||||
log.error("trovata not.message:" + timer.getNotificationMessage(idNotification));
|
||||
log.error("trovata not.userData:" + timer.getNotificationUserData(idNotification));
|
||||
if (timer.getDate(idNotification)==null)
|
||||
log.error("trovata not.date:null");
|
||||
else
|
||||
log.error("trovata not.date:" + timer.getDate(idNotification).toString());
|
||||
}
|
||||
//aggiorno lo stato del RunningTask
|
||||
runnningTask.setState(RunningTask.STATE_SCHEDULED);
|
||||
//lo aggiungo alla lista dei task schedulati
|
||||
scheduledTaskEventList.put(runnningTask.getRunningTaskID(),runnningTask);
|
||||
//Notifico al TaskStateMonitor l'avvenuta schedulazione del task
|
||||
TaskStateMonitor.getInstance().onScheduled(runnningTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Esegue lo stop delle schedulazioni
|
||||
* durante lo shutdown dell'applicazione lo stop viene chiamato
|
||||
* sia dal CrontabManager 2 volte
|
||||
* una per invocazione del EarlifeCycleListener e una dal MasterIdentificator
|
||||
* la chiamata del MasterIdentificator per<65> non fa effettivamente lo stop perch<63>
|
||||
* trova gi<67> active=false quindi serve soltanto a settare master=false
|
||||
* nel metodo setMasterInstance
|
||||
* @throws Exception
|
||||
*/
|
||||
public synchronized void stop() throws Exception {
|
||||
log.info("Stop called");
|
||||
if (master) {
|
||||
if (active) {
|
||||
//distruzione dei timer
|
||||
destroyTimer();
|
||||
//pulisco la lista dei task schedulati
|
||||
this.scheduledTaskEventList.clear();
|
||||
active = false;
|
||||
nextSchedulerTime = null;
|
||||
lastInvalidate = null;
|
||||
lastStartScheduler = null;
|
||||
log.info("scheduler settato non attivo");
|
||||
//notifico al TaskStateMonitor il reset dello scheduler
|
||||
TaskStateMonitor.getInstance().onResetScheduled();
|
||||
}
|
||||
else
|
||||
log.info("scheduler gia' non attivo");
|
||||
}
|
||||
else {
|
||||
log.info("Scheduler stop ma non master");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna lo stato di start/stop dello scheduler
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isAlive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
/**
|
||||
* ritorna il prossimo tempo di schedulazione
|
||||
*/
|
||||
public Date getNextSchedTime() {
|
||||
return nextSchedulerTime;
|
||||
}
|
||||
|
||||
public Date getLastInvalidate() {
|
||||
return lastInvalidate;
|
||||
}
|
||||
|
||||
public Exception getEndException() {
|
||||
return endException;
|
||||
}
|
||||
|
||||
public Date getLastStartSchedule() {
|
||||
return lastStartScheduler;
|
||||
}
|
||||
|
||||
public HashMap getScheduledTask() {
|
||||
return scheduledTaskEventList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
|
||||
*
|
||||
* @throws Throwable the <code>Exception</code> raised by this method
|
||||
* @todo Implement this java.lang.Object method
|
||||
*/
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Comunica all'istanza di essere o no in un nodo Master
|
||||
* @throws Exception
|
||||
*/
|
||||
public synchronized void setMasterInstance(boolean isMaster) throws Exception {
|
||||
log.debug("setMasterInstance:"+isMaster);
|
||||
if (this.master!=isMaster) {
|
||||
/**
|
||||
* setto che deve essere ricaricata la configurazione
|
||||
* in questo modo se ho fatto modifiche su un nodo e poi
|
||||
* si attiva l'altro sono allineato
|
||||
*/
|
||||
loadConfiguration=true;
|
||||
//
|
||||
log.info("Nuovo stato Scheduler_Master:"+isMaster);
|
||||
//lo stop lo devo fare prima di cambiare la configurazione altrimenti non funge
|
||||
if (!isMaster)
|
||||
stop();
|
||||
this.master=isMaster;
|
||||
//lo start lo devo fare dopo la configurazione
|
||||
if (isMaster)
|
||||
start();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Setta lo scheduler per essere startato o no
|
||||
* @param start boolean
|
||||
*/
|
||||
public void setSchedulerToStart(boolean userStart) throws Exception {
|
||||
this.userStart = userStart;
|
||||
if (userStart)
|
||||
start();
|
||||
else
|
||||
stop();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package it.valueteam.crontab.engine;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP CRONTAB</p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: ValueTeam - TeleAp</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
import java.util.*;
|
||||
|
||||
public interface SchedulerIF {
|
||||
|
||||
/**
|
||||
* Esegue lo start delle schedulazioni
|
||||
*/
|
||||
public void start() throws Exception;
|
||||
|
||||
/**
|
||||
* Esegue lo stop delle schedulazioni
|
||||
*/
|
||||
public void stop() throws Exception;
|
||||
|
||||
/**
|
||||
* Ritorna lo stato di start/stop dello scheduler
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isAlive();
|
||||
|
||||
/**
|
||||
* ritorna il prossimo tempo di schedulazione
|
||||
*/
|
||||
public Date getNextSchedTime();
|
||||
|
||||
/**
|
||||
* Ritorna l'ultima data in dinvalidazione dello scheduler
|
||||
* @return String
|
||||
*/
|
||||
public Date getLastInvalidate();
|
||||
|
||||
/**
|
||||
* Ritorna l'eccezione in caso di errore dello scheduler
|
||||
* @return String
|
||||
*/
|
||||
public Exception getEndException();
|
||||
|
||||
/**
|
||||
* ritorna l'ultimo tempo di schedulazione
|
||||
* @return String
|
||||
*/
|
||||
public Date getLastStartSchedule();
|
||||
|
||||
/**
|
||||
* Ritorna la lista di tutti i runningtask schedulati
|
||||
*/
|
||||
public HashMap getScheduledTask();
|
||||
|
||||
/**
|
||||
* invalida la schedulazione corrente
|
||||
*/
|
||||
public void invalidate();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package it.valueteam.crontab.engine.exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>: Eccezione generica Crontab.</p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Società</b>: </p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
public class CrontabException
|
||||
extends Exception
|
||||
{
|
||||
public CrontabException()
|
||||
{
|
||||
super("Eccezione Crontab generica");
|
||||
}
|
||||
|
||||
public CrontabException(String msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CrontabException(Exception ex)
|
||||
{
|
||||
super("Eccezione Crontab generica. Tipo: " + ex.getClass() + ", Messaggio: " + ex.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package it.valueteam.crontab.engine.exception;
|
||||
|
||||
/**
|
||||
* <p>Title: </p> <p>Description: Regole crontab non valide.</p> <p>Copyright: Copyright (c) 2003</p> <p>Company: </p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
public class NotValidCrontabConfigException
|
||||
extends Exception {
|
||||
public NotValidCrontabConfigException() {
|
||||
super("Regole di attivazioni Crontab non valide.");
|
||||
}
|
||||
|
||||
public NotValidCrontabConfigException(Exception ex) {
|
||||
super("Regole di attivazioni Crontab non valide. Tipo: " + ex.getClass() +
|
||||
", messagio: " + ex.toString());
|
||||
}
|
||||
|
||||
public NotValidCrontabConfigException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package it.valueteam.crontab.engine.exception;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>:
|
||||
* Viene generata quando il file di configurazione del crontab non è valido o è inesistente e manca anche il file
|
||||
* dell''ultima configurazione andata a buon fine.
|
||||
* </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Società</b>: ObjectWay S.p.a.</p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class NotValidCrontabFileException
|
||||
extends Exception {
|
||||
|
||||
public NotValidCrontabFileException() {
|
||||
super("File di configurazione specificato non valido o non presente");
|
||||
}
|
||||
|
||||
public NotValidCrontabFileException(String msg) {
|
||||
super(
|
||||
"File di configurazione non valido o non presente: piu' precisamente " +
|
||||
msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package it.valueteam.crontab.engine.jms;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP CRONTAB</p>
|
||||
* <p>Description: Interfaccia per la ricezione di eventi asincroni</p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: ValueTeam - TeleAp</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface MessageAsinchNotificationIF {
|
||||
public void notifyAsinchEvent(Object obj);
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package it.valueteam.crontab.engine.jms;
|
||||
|
||||
import javax.jms.*;
|
||||
import javax.naming.*;
|
||||
import org.apache.log4j.*;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP CRONTAB</p>
|
||||
* <p>Description: Listener per l'esecuzione asincrona di eventi </p>
|
||||
* <p>Copyright: Copyright (c) 2007</p>
|
||||
* <p>Company: ValueTeam - TeleAp</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MessageHandler implements MessageListener {
|
||||
private Logger log;
|
||||
public static final String CRONTAB_FACTORY = "jms/crontabFactory";
|
||||
private MessageAsinchNotificationIF msgNot;
|
||||
|
||||
private QueueConnection queueConn;
|
||||
private QueueSession queueSession;
|
||||
private TemporaryQueue temporaryQueue;
|
||||
private QueueReceiver qReceiver;
|
||||
private boolean autoClose=false;
|
||||
|
||||
|
||||
public MessageHandler(MessageAsinchNotificationIF msgNot,Logger log) throws Exception{
|
||||
this(msgNot,log,false);
|
||||
}
|
||||
|
||||
public MessageHandler(MessageAsinchNotificationIF msgNot,Logger log,boolean autoClose) throws Exception{
|
||||
this.msgNot = msgNot;
|
||||
this.log=log;
|
||||
this.autoClose=autoClose;
|
||||
//creazione di connessione,sessione e temporaryQueue
|
||||
try {
|
||||
Context ic = new InitialContext();
|
||||
QueueConnectionFactory qcFactory = (QueueConnectionFactory)ic.lookup(CRONTAB_FACTORY);
|
||||
queueConn = qcFactory.createQueueConnection();
|
||||
queueSession = queueConn.createQueueSession(true,0);
|
||||
|
||||
temporaryQueue = queueSession.createTemporaryQueue();
|
||||
qReceiver = queueSession.createReceiver(temporaryQueue);
|
||||
qReceiver.setMessageListener(this);
|
||||
queueConn.start();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manda un ObjectMessage sulla coda temporanea
|
||||
* @param obj Serializable
|
||||
* @throws Exception
|
||||
*/
|
||||
public void sendMessage(java.io.Serializable obj) throws Exception{
|
||||
ObjectMessage objMessage = null;
|
||||
QueueSender qSender=null;
|
||||
|
||||
qSender = queueSession.createSender(temporaryQueue);
|
||||
objMessage = queueSession.createObjectMessage();
|
||||
objMessage.setObject(obj);
|
||||
qSender.send(objMessage);
|
||||
queueSession.commit();
|
||||
log.debug("Spedizione msg in coda eseguito");
|
||||
qSender.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Riceve un ObjectMessage sulla coda temporanea
|
||||
* @param msg Message
|
||||
*/
|
||||
public void onMessage(Message msg) {
|
||||
ObjectMessage objMsg =null;
|
||||
|
||||
try {
|
||||
objMsg = (ObjectMessage) msg;
|
||||
log.debug("Ricezione msg dalla coda eseguito");
|
||||
msgNot.notifyAsinchEvent(objMsg.getObject());
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
queueSession.commit();
|
||||
}
|
||||
catch (JMSException ex1) {
|
||||
ex1.printStackTrace();
|
||||
}
|
||||
if (autoClose)
|
||||
closeAll();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
|
||||
*
|
||||
* @throws Throwable the <code>Exception</code> raised by this method
|
||||
* @todo Implement this java.lang.Object method
|
||||
*/
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
closeAll();
|
||||
}
|
||||
|
||||
public void closeAll() {
|
||||
try {
|
||||
if (qReceiver!=null) {
|
||||
qReceiver.close();
|
||||
qReceiver=null;
|
||||
}
|
||||
}
|
||||
catch (JMSException ex3) {
|
||||
ex3.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (temporaryQueue!=null) {
|
||||
temporaryQueue.delete();
|
||||
temporaryQueue = null;
|
||||
}
|
||||
}
|
||||
catch (JMSException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (queueSession!=null) {
|
||||
queueSession.close();
|
||||
queueSession = null;
|
||||
}
|
||||
}
|
||||
catch (JMSException ex1) {
|
||||
ex1.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (queueConn!=null) {
|
||||
queueConn.close();
|
||||
queueConn = null;
|
||||
}
|
||||
}
|
||||
catch (JMSException ex2) {
|
||||
ex2.printStackTrace();
|
||||
}
|
||||
log=null;
|
||||
msgNot=null;
|
||||
}
|
||||
|
||||
public boolean isAutoClose() {
|
||||
return autoClose;
|
||||
}
|
||||
public void setAutoClose(boolean autoClose) {
|
||||
this.autoClose = autoClose;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,455 @@
|
||||
package it.valueteam.crontab.engine.mbean;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.config.setting.*;
|
||||
import it.valueteam.crontab.engine.*;
|
||||
import it.valueteam.crontab.engine.exception.*;
|
||||
import it.valueteam.crontab.obj.engine.*;
|
||||
import it.valueteam.crontab.obj.gui.*;
|
||||
import it.valueteam.crontab.utility.*;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP CRONTAB </p>
|
||||
*
|
||||
* <p>Description: MBean di monitoraggio di tutte le attivtà del crontab </p>
|
||||
*
|
||||
* <p>Copyright: Copyright (c) 2006</p>
|
||||
*
|
||||
* <p>Company: Value Team</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
public class TaskManager
|
||||
implements TaskManagerMBean {
|
||||
|
||||
private static Logger log = Logger.getLogger(TaskManager.class.getName());
|
||||
|
||||
private Scheduler scheduler;
|
||||
private TaskStateMonitor taskStateMonitor;
|
||||
private Settings settings;
|
||||
|
||||
/**
|
||||
* costruttore
|
||||
*
|
||||
* @param schedMonitor SchedulerMonitor
|
||||
*/
|
||||
public TaskManager() {
|
||||
//Scheduler, TaskStateMonitor, Settings sono inizializzati in fase di Startup:
|
||||
//l'invocazione al getIstance ritorna un oggetto sicuramente inizializzato
|
||||
try {
|
||||
this.scheduler = Scheduler.getInstance();
|
||||
}
|
||||
catch (NotValidCrontabFileException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
this.taskStateMonitor = TaskStateMonitor.getInstance();
|
||||
this.settings = Settings.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la lista dei task compresi nell'intervallo temporale passato come parametro
|
||||
*
|
||||
* @param from EventTime - estremo inferiore dell'intervallo temporale
|
||||
* @param to EventTime - estremo superiore dell'intervallo temporale
|
||||
* @return ArrayList
|
||||
*/
|
||||
public ArrayList getTaskInInterval(EventTime from, EventTime to) {
|
||||
ArrayList res = new ArrayList();
|
||||
|
||||
ArrayList listTask = settings.getTaskList();
|
||||
for (Iterator iter = listTask.iterator(); iter.hasNext(); ) {
|
||||
TaskInfo taskInfo = (TaskInfo) iter.next();
|
||||
Set set = taskInfo.getActivationIntervalSet(from, to);
|
||||
if ( (set != null) && !set.isEmpty()) {
|
||||
res.add(taskInfo);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la lista di tutti i processi attualmente disponibili
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
public ArrayList getAvailableProcess() {
|
||||
return settings.getProcessList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la lista di tutti i processi non utilizzati per un determinato task
|
||||
* Un processo risulta non utilizzato se appartiene al task ma non è presente
|
||||
* nella configurazione del crontab
|
||||
* @param id String - id del task
|
||||
* @return ArrayList
|
||||
*/
|
||||
public ArrayList getNotUsedProcesses(String id) {
|
||||
TaskInfo task = settings.getTask(id);
|
||||
ArrayList listProcessUsed = task.getProcessList();
|
||||
ArrayList listProcesses = getAvailableProcess();
|
||||
HashSet setProcesses = new HashSet();
|
||||
for (Iterator i = listProcessUsed.iterator(); i.hasNext(); ) {
|
||||
setProcesses.add( ( (TaskInfo.ProcessInfoRef) i.next()).getProcess().
|
||||
getId());
|
||||
}
|
||||
ArrayList res = new ArrayList();
|
||||
for (Iterator i = listProcesses.iterator(); i.hasNext(); ) {
|
||||
ProcessInfo proc = (ProcessInfo) i.next();
|
||||
if (setProcesses.contains(proc.getId()))
|
||||
continue;
|
||||
res.add(proc);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* ritorna la lista dei processi non bloccanti x tale proc
|
||||
* @param procId String - id del processo
|
||||
* @return ArrayList
|
||||
*/
|
||||
public ArrayList getNotUsedBlockingProcesses(String procId) {
|
||||
ProcessInfo processInfo = settings.getProcess(procId);
|
||||
ArrayList listProcessUsed = processInfo.getBlockingProcessList();
|
||||
ArrayList listProcesses = getAvailableProcess();
|
||||
HashSet setProcesses = new HashSet();
|
||||
for (Iterator i = listProcessUsed.iterator(); i.hasNext(); ) {
|
||||
setProcesses.add( ( (ProcessInfo.BlockingProcessInfoRef) i.next()).
|
||||
getProcID());
|
||||
}
|
||||
ArrayList res = new ArrayList();
|
||||
for (Iterator i = listProcesses.iterator(); i.hasNext(); ) {
|
||||
ProcessInfo proc = (ProcessInfo) i.next();
|
||||
if (setProcesses.contains(proc.getId()))
|
||||
continue;
|
||||
//levo se stesso
|
||||
if (proc.getId() != procId)
|
||||
res.add(proc);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la lista di tutti i task attualmente disponibili
|
||||
* @return ArrayList
|
||||
*/
|
||||
public ArrayList getAvailableTaskList() {
|
||||
return settings.getTaskList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la lista dei task attualmente schedulati, a prescindere dallo stato,
|
||||
* con l'esclusione dei task transitati nello stato DESTROYED o EXECUTED
|
||||
* nell'istante t < adesso - 5 minuti
|
||||
* @return ArrayList
|
||||
*/
|
||||
public ArrayList getTaskList() {
|
||||
return taskStateMonitor.getTaskList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna la lista dei task schedulati attualmente nello stato SCHEDULED
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
public ArrayList getScheduledTaskList() {
|
||||
return taskStateMonitor.getScheduledTaskList();
|
||||
}
|
||||
|
||||
/**
|
||||
* itorna la lista dei task schedulati attualmente nello stato RUNNING
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
public ArrayList getActiveTaskList() {
|
||||
return taskStateMonitor.getActiveTaskList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Esegue un Task di Emergenza
|
||||
*
|
||||
* @param taskInfo TaskInfo
|
||||
*/
|
||||
public void runEmergencyTask(TaskInfo taskInfo) {
|
||||
log.info("INIZIO: Esecuzione Task di Emergenza");
|
||||
EmergencyTask et = new EmergencyTask(taskInfo);
|
||||
TaskStateMonitor.getInstance().onScheduled(et);
|
||||
try {
|
||||
RunnerManager.getInstance().executeTask(et);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.println("Eccezione in runEmergencyTask nel TaskManager: " +
|
||||
this.getClass().getName());
|
||||
ex.printStackTrace();
|
||||
|
||||
}
|
||||
log.info("FINE :Esecuzione Task di Emergenza");
|
||||
}
|
||||
|
||||
/**
|
||||
* Esegue l'arresto forzato di un RunningTask
|
||||
*
|
||||
* @param rtaskId String
|
||||
*/
|
||||
public void stopForced(String runningTaskID) {
|
||||
log.info("INIZIO: Stop Forzato di un task: " + runningTaskID);
|
||||
try {
|
||||
RunnerManager.getInstance().destroy(runningTaskID);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.println("Eccezione in stopForced nel TaskManager: " +
|
||||
this.getClass().getName());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
log.info("FINE: Stop Forzato di un task: " + runningTaskID);
|
||||
}
|
||||
|
||||
//eliminato il metodo stopForced(taskId) perchè mai usato
|
||||
//modificato il metodo stopForced(taskId, rtaskid) perchè l'unico parametro che ci
|
||||
//serve è il rtaskid --> modificare chiamata dal command
|
||||
|
||||
public void start() {
|
||||
log.info("INIZIO: Start del TaskManager");
|
||||
try {
|
||||
scheduler.setSchedulerToStart(true);
|
||||
log.info("Start dello Scheduler Effettuato");
|
||||
log.info("FINE: Start del TaskManager");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.error("Errore durante lo start dello Scheduler");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
log.info("INIZIO: Stop del TaskManager");
|
||||
//esegue lo stop dello scheduler con conseguente distruzione dei timer attivi
|
||||
try {
|
||||
log.info("Stop dello Scheduler Effettuato");
|
||||
scheduler.setSchedulerToStart(false);
|
||||
}
|
||||
catch (Exception ex1) {
|
||||
log.error("Errore durante lo Stop dello Scheduler");
|
||||
ex1.printStackTrace();
|
||||
}
|
||||
|
||||
//esegue lo stop del RunnerManager
|
||||
//Attenzione: solo i task non ancora in esecuzione vengono distrutti, per i task aventi
|
||||
//un processo in esecuzione si attende la sua terminazione
|
||||
try {
|
||||
RunnerManager.getInstance().stop();
|
||||
log.info("Stop del RunnerManager");
|
||||
log.info("INIZIO: Stop del TaskManager");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.error("Errore durante lo Stop del RunnerManager");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritrona true se lo scheduler è attivo
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isAlive() {
|
||||
return scheduler.isAlive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiunge un nuovo task all'elenco dei task gestiti dal Crontab
|
||||
*
|
||||
* @param parm1 TaskInfo
|
||||
*/
|
||||
public void add(TaskInfo parm1) {
|
||||
settings.addNew(parm1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rimuove task dall'elenco dei task gestiti dal Crontab
|
||||
*
|
||||
* @param id String
|
||||
*/
|
||||
public void remove(String id) {
|
||||
settings.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rimuove un processo dall'elenco dei Processi gestiti dal Crontab
|
||||
*
|
||||
* @param id String
|
||||
*/
|
||||
public void removeProcess(String id) {
|
||||
settings.removeProcess(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiorna il Task passato come parametro
|
||||
*
|
||||
* @param Task aggiornato
|
||||
*/
|
||||
public void update(TaskInfo parm1) {
|
||||
settings.update(parm1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il Task che ha id passato per parametro
|
||||
*
|
||||
* @param id identificativo del Task richiesto
|
||||
* @return Task richiesto
|
||||
*/
|
||||
public TaskInfo getTask(String parm1) {
|
||||
return (TaskInfo)copy(settings.getTask(parm1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Salva la configurazione corrente
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String save() {
|
||||
String file = settings.save();
|
||||
return file;
|
||||
}
|
||||
|
||||
//eliminato il metodo saveAs perchè vuoto
|
||||
|
||||
|
||||
/**
|
||||
* Carica la configurazione specificata nel file passato come parametro
|
||||
*
|
||||
* @param file di configurazione del crontab
|
||||
* @throws NotValidCrontabFileException
|
||||
*/
|
||||
public void load(String confFile) throws NotValidCrontabFileException {
|
||||
try {
|
||||
settings.load(confFile);
|
||||
}
|
||||
catch (NotValidCrontabFileException ex) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Carica l'ultima configurazione salvata con successo
|
||||
*
|
||||
* @throws NotValidCrontabFileException
|
||||
*/
|
||||
public void loadLastGood() throws NotValidCrontabFileException {
|
||||
try {
|
||||
settings.loadLastGood();
|
||||
}
|
||||
catch (NotValidCrontabFileException ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il path del file di configurazione
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getFileCfg() {
|
||||
return settings.getFileCfg();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il numero di versione del file di configurazione
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getCfgVer() {
|
||||
return settings.getFileCfgVer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il subversion del file di configurazione
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getCfgSubVer() {
|
||||
return "" + settings.getFileCfgSubVer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il nome della configurazione
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getCfgName() {
|
||||
return settings.getFileCfgName();
|
||||
}
|
||||
|
||||
/**
|
||||
* getSaved
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean getSaved() {
|
||||
return settings.getSaved();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna un processo dall'elenco dei Processi gestiti dal Crontab
|
||||
* @param id String
|
||||
* @return ProcessInfo
|
||||
*/
|
||||
public ProcessInfo getProcess(String id) {
|
||||
return (ProcessInfo)copy(settings.getProcess(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update di un processo dall'elenco dei Processi gestiti dal Crontab
|
||||
* @param procInfo ProcessInfo
|
||||
*/
|
||||
public void update(ProcessInfo procInfo) {
|
||||
settings.update(procInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiunge un processo dall'elenco dei Processi gestiti dal Crontab
|
||||
* @param procInfo ProcessInfo
|
||||
*/
|
||||
public void addNew(ProcessInfo procInfo) {
|
||||
settings.addNew(procInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the object, or null if the object cannot
|
||||
* be serialized.
|
||||
*/
|
||||
public static Object copy(Object orig) {
|
||||
Object obj = null;
|
||||
try {
|
||||
// Write the object out to a byte array
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(bos);
|
||||
out.writeObject(orig);
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
// Make an input stream from the byte array and read
|
||||
// a copy of the object back in.
|
||||
ObjectInputStream in = new ObjectInputStream(
|
||||
new ByteArrayInputStream(bos.toByteArray()));
|
||||
obj = in.readObject();
|
||||
}
|
||||
catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(ClassNotFoundException cnfe) {
|
||||
cnfe.printStackTrace();
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package it.valueteam.crontab.engine.mbean;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.engine.exception.*;
|
||||
import it.valueteam.crontab.utility.*;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>:
|
||||
* Consenti di gestire i Task del crontab. In pratica è possibile avere la lista
|
||||
* dei task disponibili assiciati al loro stato, creare un nuovo Task, modificare
|
||||
* un task, eliminare un Task sapere in che stato si trova uno specificao Task, forzare
|
||||
* la partenza e l'arresto di un task, avere una lista di operazioni possibili su un
|
||||
* task in un dato istante e verificare se una operazione è possbile su un task in un
|
||||
* determinato istante.
|
||||
* </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Società</b>: ObjectWay S.p.a.</p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface TaskManagerMBean {
|
||||
/**
|
||||
* Ritora la lista di tutti i task configurati nel crontab e per ognuno viene
|
||||
* associato lo stato corrente
|
||||
* @return ArrayList di TaskState
|
||||
*/
|
||||
public ArrayList getAvailableTaskList();
|
||||
|
||||
public ArrayList getTaskList();
|
||||
|
||||
public ArrayList getScheduledTaskList();
|
||||
|
||||
public ArrayList getActiveTaskList();
|
||||
|
||||
public ArrayList getAvailableProcess();
|
||||
|
||||
public ArrayList getNotUsedProcesses(String id);
|
||||
|
||||
//C.P.
|
||||
public ArrayList getNotUsedBlockingProcesses(String procId);
|
||||
|
||||
public ArrayList getTaskInInterval(EventTime from, EventTime to);
|
||||
|
||||
public void runEmergencyTask(TaskInfo taskInfo);
|
||||
|
||||
//public void stopForced(String taskId);
|
||||
//public void stopForced(String rTaskId, String taskId);
|
||||
public void stopForced(String rtaskId);
|
||||
|
||||
public void start();
|
||||
|
||||
public void stop();
|
||||
|
||||
public boolean isAlive();
|
||||
|
||||
public void add(TaskInfo task);
|
||||
|
||||
public void remove(String taskId);
|
||||
|
||||
public void update(TaskInfo task);
|
||||
|
||||
public TaskInfo getTask(String id);
|
||||
|
||||
public void load(String confFile) throws NotValidCrontabFileException;
|
||||
|
||||
public void loadLastGood() throws NotValidCrontabFileException;
|
||||
|
||||
public String getFileCfg();
|
||||
|
||||
public boolean getSaved();
|
||||
|
||||
public String getCfgVer();
|
||||
|
||||
public String getCfgSubVer();
|
||||
|
||||
public String getCfgName();
|
||||
|
||||
public String save();
|
||||
|
||||
/*GESTIONE PROCESSI*/
|
||||
public ProcessInfo getProcess(String id);
|
||||
|
||||
public void update(ProcessInfo procInfo);
|
||||
|
||||
public void addNew(ProcessInfo procInfo);
|
||||
|
||||
public void removeProcess(String id);
|
||||
/*******************/
|
||||
}
|
||||
@@ -0,0 +1,439 @@
|
||||
package it.valueteam.crontab.engine.mbean.client;
|
||||
|
||||
import it.valueteam.crontab.config.ProcessInfo;
|
||||
import it.valueteam.crontab.config.TaskInfo;
|
||||
import it.valueteam.crontab.engine.exception.NotValidCrontabFileException;
|
||||
import it.valueteam.crontab.engine.mbean.TaskManagerMBean;
|
||||
import it.valueteam.crontab.utility.EventTime;
|
||||
import it.valueteam.crontab.utility.cluster.MasterIdentificator;
|
||||
import mnp.crontab.exception.MasterNotActiveException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.management.MBeanException;
|
||||
import javax.management.MBeanServerConnection;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.naming.NamingException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>: </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Societ<65></b>: ObjectWay S.p.a.</p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class TaskManagerClient implements TaskManagerMBean {
|
||||
private static Logger log = Logger.getLogger(TaskManagerClient.class.getName());
|
||||
private MBeanServerConnection mbs = null;
|
||||
private ObjectName name = null;
|
||||
|
||||
public TaskManagerClient(String name) throws Exception {
|
||||
|
||||
try{
|
||||
this.mbs = MasterIdentificator.getInstance().getMasterMBeanServer();
|
||||
}catch(NamingException nex){
|
||||
nex.printStackTrace();
|
||||
//questa eccezione viene catchiata per risollevare una custom
|
||||
//da visualizzare a livello di GUI. E' stata fatta perch<63> quando il master cade
|
||||
//c'<27> un periodo di due minuti (al massimo) in cui nessuno <20> master e il
|
||||
//master token non si trova sul jndi
|
||||
throw new MasterNotActiveException("Nessun nodo master attivo. Riprovare tra qualche secondo...");
|
||||
}
|
||||
try {
|
||||
this.name = new ObjectName(name);
|
||||
}
|
||||
catch (MalformedObjectNameException ex) {
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public ArrayList getNotUsedProcesses(String id) {
|
||||
ArrayList res = null;
|
||||
try {
|
||||
Object[] paramValue = {id};
|
||||
String[] signature = {"java.lang.String"};
|
||||
res = (ArrayList) mbs.invoke(name, "getNotUsedProcesses", paramValue,signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// C.P x processi bloccanti
|
||||
public ArrayList getNotUsedBlockingProcesses(String procId) {
|
||||
ArrayList res = null;
|
||||
try {
|
||||
Object[] paramValue = {procId};
|
||||
String[] signature = {"java.lang.String"};
|
||||
res = (ArrayList) mbs.invoke(name, "getNotUsedBlockingProcesses",paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList getAvailableProcess() {
|
||||
ArrayList res = null;
|
||||
try {
|
||||
res = (ArrayList) mbs.getAttribute(name, "AvailableProcess");
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public ArrayList getTaskInInterval(EventTime from, EventTime to) {
|
||||
ArrayList res = null;
|
||||
try {
|
||||
Object[] paramValue = {from, to};
|
||||
String[] signature = {"it.valueteam.crontab.utility.EventTime", "it.valueteam.crontab.utility.EventTime"};
|
||||
res = (ArrayList) mbs.invoke(name, "getTaskInInterval", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public ArrayList getAvailableTaskList() {
|
||||
ArrayList res = null;
|
||||
try {
|
||||
res = (ArrayList) mbs.getAttribute(name, "AvailableTaskList");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public ArrayList getTaskList() {
|
||||
ArrayList res = null;
|
||||
try {
|
||||
res = (ArrayList) mbs.getAttribute(name, "TaskList");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public ArrayList getScheduledTaskList() {
|
||||
ArrayList res = null;
|
||||
try {
|
||||
res = (ArrayList) mbs.getAttribute(name, "ScheduledTaskList");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList getActiveTaskList() {
|
||||
System.out.println("Calling getActiveTaskList().... with name: " + name);
|
||||
|
||||
ArrayList res = null;
|
||||
try {
|
||||
/*System.out.println("OBJ: ["+mbs.getObjectInstance(name).hashCode()+"]");
|
||||
MBeanInfo info = mbs.getMBeanInfo(name);
|
||||
|
||||
System.out.println("*************************************");
|
||||
System.out.println("Metodi per ["+name+"] class ["+info.getClassName()+"]");
|
||||
MBeanOperationInfo[] operations = info.getOperations();
|
||||
for (MBeanOperationInfo oper: operations) {
|
||||
System.out.println(" oper ["+oper.getName()+"]");
|
||||
}
|
||||
System.out.println("*************************************");
|
||||
|
||||
System.out.println("*************************************");
|
||||
System.out.println("Attributi per ["+name+"] class ["+info.getClassName()+"]");
|
||||
MBeanAttributeInfo[] attributi = info.getAttributes();
|
||||
for (MBeanAttributeInfo attr: attributi) {
|
||||
System.out.println(" attr ["+attr.getName()+"]");
|
||||
}
|
||||
System.out.println("*************************************");*/
|
||||
res = (ArrayList) mbs.getAttribute(name, "ActiveTaskList");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
public void runEmergencyTask(TaskInfo taskInfo) {
|
||||
try {
|
||||
Object[] paramValue = {taskInfo};
|
||||
String[] signature = {"it.valueteam.crontab.config.TaskInfo"};
|
||||
mbs.invoke(name, "runEmergencyTask", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void startForced(String parm1) {
|
||||
try {
|
||||
Object[] paramValue = {parm1};
|
||||
String[] signature = {"java.lang.String"};
|
||||
mbs.invoke(name, "startForced", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
try {
|
||||
Object[] paramValue = {};
|
||||
String[] signature = {};
|
||||
mbs.invoke(name, "start", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
try {
|
||||
Object[] paramValue = {};
|
||||
String[] signature = {};
|
||||
mbs.invoke(name, "stop", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
Boolean res = Boolean.FALSE;
|
||||
|
||||
try {
|
||||
Object resObj = mbs.getAttribute(name, "Alive");
|
||||
log.debug("isAlive:" + resObj);
|
||||
res = (Boolean) resObj;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
public void stopForced(String rTaskId, String taskId) {
|
||||
try {
|
||||
Object[] paramValue = {rTaskId, taskId};
|
||||
String[] signature = {"java.lang.String", "java.lang.String"};
|
||||
mbs.invoke(name, "stopForced", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopForced(String taskId) {
|
||||
try {
|
||||
Object[] paramValue = {taskId};
|
||||
String[] signature = {"java.lang.String"};
|
||||
mbs.invoke(name, "stopForced", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void add(TaskInfo parm1) {
|
||||
try {
|
||||
Object[] paramValue = {parm1};
|
||||
String[] signature = {"it.valueteam.crontab.config.TaskInfo"};
|
||||
mbs.invoke(name, "add", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(String parm1) {
|
||||
try {
|
||||
Object[] paramValue = {parm1};
|
||||
String[] signature = {"java.lang.String"};
|
||||
mbs.invoke(name, "remove", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeProcess(String id) {
|
||||
try {
|
||||
Object[] paramValue = {id};
|
||||
String[] signature = {"java.lang.String"};
|
||||
mbs.invoke(name, "removeProcess", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(TaskInfo parm2) {
|
||||
try {
|
||||
Object[] paramValue = {parm2};
|
||||
String[] signature = {"it.valueteam.crontab.config.TaskInfo"};
|
||||
mbs.invoke(name, "update", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public TaskInfo getTask(String parm1) {
|
||||
TaskInfo res = null;
|
||||
try {
|
||||
Object[] paramValue = {parm1};
|
||||
String[] signature = {"java.lang.String"};
|
||||
res = (TaskInfo) mbs.invoke(name, "getTask", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void load(String confFile) throws NotValidCrontabFileException {
|
||||
try {
|
||||
Object[] paramValue = {confFile};
|
||||
String[] signature = {"java.lang.String"};
|
||||
mbs.invoke(name, "load", paramValue, signature);
|
||||
}
|
||||
catch (MBeanException ex) {
|
||||
throw new NotValidCrontabFileException();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadLastGood() throws NotValidCrontabFileException {
|
||||
try {
|
||||
mbs.getAttribute(name, "loadLastGood");
|
||||
}
|
||||
catch (MBeanException ex) {
|
||||
throw new NotValidCrontabFileException();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getFileCfg() {
|
||||
String res = null;
|
||||
try {
|
||||
res = (String) mbs.getAttribute(name, "FileCfg");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean getSaved() {
|
||||
Boolean res = Boolean.FALSE;
|
||||
try {
|
||||
Object resObj = mbs.getAttribute(name, "Saved");
|
||||
log.debug("getSaved:" + resObj);
|
||||
res = (Boolean) resObj;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public String getCfgVer() {
|
||||
String res = null;
|
||||
try {
|
||||
res = (String) mbs.getAttribute(name, "CfgVer");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public String getCfgSubVer() {
|
||||
String res = null;
|
||||
try {
|
||||
res = (String) mbs.getAttribute(name, "CfgSubVer");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public String getCfgName() {
|
||||
String res = null;
|
||||
try {
|
||||
res = (String) mbs.getAttribute(name, "CfgName");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public String save() {
|
||||
Object o = null;
|
||||
try {
|
||||
Object[] paramValue = {};
|
||||
String[] signature = {};
|
||||
o = mbs.invoke(name, "save", paramValue, signature);
|
||||
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return (String) o;
|
||||
}
|
||||
|
||||
public ProcessInfo getProcess(String id) {
|
||||
ProcessInfo ret = null;
|
||||
try {
|
||||
Object[] paramValue = {id};
|
||||
String[] signature = {"java.lang.String"};
|
||||
ret = (ProcessInfo) mbs.invoke(name, "getProcess", paramValue,signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void update(ProcessInfo procInfo) {
|
||||
try {
|
||||
Object[] paramValue = {
|
||||
procInfo};
|
||||
String[] signature = {
|
||||
"it.valueteam.crontab.config.ProcessInfo"};
|
||||
mbs.invoke(name, "update", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addNew(ProcessInfo procInfo) {
|
||||
try {
|
||||
Object[] paramValue = {
|
||||
procInfo};
|
||||
String[] signature = {
|
||||
"it.valueteam.crontab.config.ProcessInfo"};
|
||||
mbs.invoke(name, "addNew", paramValue, signature);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
package it.valueteam.crontab.init;
|
||||
|
||||
import javax.management.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import it.valueteam.crontab.engine.*;
|
||||
import it.valueteam.crontab.engine.mbean.*;
|
||||
import it.valueteam.crontab.obj.gui.*;
|
||||
import it.valueteam.crontab.utility.cluster.*;
|
||||
import mnp.crontab.utility.*;
|
||||
import weblogic.management.*;
|
||||
import it.valueteam.crontab.engine.mbean.client.TaskManagerClient;
|
||||
import mnp.crontab.command.CrontabCostants;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP-Crontab</p>
|
||||
*
|
||||
* <p>Description: Classe che esegue le operazioni di start/stop del crontab </p>
|
||||
*
|
||||
* <p>Copyright: Copyright (c) 2006</p>
|
||||
*
|
||||
* <p>Company: ValueTeam</p>
|
||||
*
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
public class CrontabManager implements MasterIdentificatorNotificationListenerIF {
|
||||
|
||||
private static Logger log = Logger.getLogger(CrontabManager.class.getName());
|
||||
private static CrontabManager onlyInstance;
|
||||
|
||||
//Coordinate di accesso al MBEAN Server
|
||||
private String userName;
|
||||
private String passwd;
|
||||
private String weblogicURL;
|
||||
private String serverName;
|
||||
private int masterNotificationState = MasterIdentificator.INITIAL_STATE;
|
||||
//Decide se lo scheduler deve essere startato anche se Master,
|
||||
//dipende dal valore della proprietà CRONTAB_ACTIVE presente sullo start del server
|
||||
private boolean toStart=false;
|
||||
|
||||
/**
|
||||
* costruttore privato
|
||||
*/
|
||||
private CrontabManager() {
|
||||
|
||||
//inizializzo variabili di accesso al MBean Server
|
||||
userName = Resources.getUSER_MBEAN()!=null?Resources.getUSER_MBEAN():"weblogic";
|
||||
passwd = Resources.getPASSWORD_MBEAN()!=null?Resources.getPASSWORD_MBEAN():"weblogic";
|
||||
weblogicURL = System.getProperty("server_url","")!=null?System.getProperty("server_url",""):"t3://localhost:7101";
|
||||
serverName = System.getProperty("weblogic.Name","")!=null?System.getProperty("weblogic.Name",""):"serverMnp";
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna l'unica istanza della classe
|
||||
*
|
||||
* @return CrontabManager
|
||||
*/
|
||||
public static CrontabManager getInstance() {
|
||||
if (onlyInstance == null) {
|
||||
synchronized (CrontabManager.class) {
|
||||
if (onlyInstance == null) {
|
||||
onlyInstance = new CrontabManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return onlyInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Esegue l'inizializzazione del crontab e la registrazione dei componenti di monitoraggio
|
||||
*
|
||||
* @throws NotValidCrontabFileException
|
||||
* @throws InstanceAlreadyExistsException
|
||||
* @throws MBeanRegistrationException
|
||||
* @throws NotCompliantMBeanException
|
||||
* @throws MalformedObjectNameException
|
||||
*/
|
||||
public void init(boolean toStart) throws Exception {
|
||||
|
||||
log.info("Procedura di startup del Crontab...");
|
||||
|
||||
Scheduler.getInstance().setSchedulerToStart(toStart);
|
||||
RunnerManager.getInstance();
|
||||
TaskStateMonitor.getInstance();
|
||||
|
||||
//CREAZIONE MBEAN CRONTAB
|
||||
TaskManager taskManager = new TaskManager();
|
||||
log.info("TaskManager created.");
|
||||
|
||||
//Registrazione MBEAN
|
||||
log.debug("Registering Crontab objects..");
|
||||
log.debug("username: " + userName);
|
||||
//log.debug("password: " + passwd);
|
||||
log.debug("weblogic URL: " + weblogicURL);
|
||||
log.debug("server name: " + serverName);
|
||||
//Registrazione MBEAN
|
||||
ObjectName taskManagerName = new ObjectName(CrontabCostants.OBJECT_TASK_MANAGER_MBEAN_CLIENT);
|
||||
|
||||
log.info("\t taskManagerMonitor name: " + taskManagerName);
|
||||
//registrazione effettiva del task manager
|
||||
RemoteMBeanServer mBeanSrv =getLocalMBeanServer();
|
||||
mBeanSrv.registerMBean(taskManager, taskManagerName);
|
||||
log.info("Crontab toStart: " + toStart);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Esegue lo start del Crontab
|
||||
*
|
||||
* @throws MalformedObjectNameException
|
||||
*/
|
||||
public void start() throws Exception {
|
||||
Scheduler.getInstance().start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Esegue lo stop del crontab
|
||||
*
|
||||
* @throws MalformedObjectNameException
|
||||
*/
|
||||
public void stop() throws Exception {
|
||||
Scheduler.getInstance().stop();
|
||||
RunnerManager.getInstance().stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Esegue la de-registrazione dei componenti di monitoraggio
|
||||
*
|
||||
* @throws MalformedObjectNameException
|
||||
* @throws MBeanRegistrationException
|
||||
* @throws InstanceNotFoundException
|
||||
*/
|
||||
public void shutdown() throws Exception{
|
||||
ObjectName taskManagerName = null;
|
||||
|
||||
log.info("Procedura di shutdown del Crontab...");
|
||||
log.debug("username: " + userName);
|
||||
//log.debug("password: " + passwd);
|
||||
log.debug("weblogic URL: " + weblogicURL);
|
||||
log.debug("server name: " + serverName);
|
||||
//stop del core
|
||||
stop();
|
||||
//unregisterMBean
|
||||
log.info("-> Inizio de-registrazione del TaskManagerMonitor");
|
||||
taskManagerName = new ObjectName(CrontabCostants.OBJECT_TASK_MANAGER_MBEAN_CLIENT);
|
||||
try{
|
||||
getLocalMBeanServer().unregisterMBean(taskManagerName);
|
||||
log.info("MBean de-registrati dal server JMX");
|
||||
}catch(javax.management.InstanceNotFoundException ix){
|
||||
System.out.println("Istanza del TaskManagerMonitor non trovata");
|
||||
log.info("Istanza del TaskManagerMonitor non trovata");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gestine notifica combio stato cluster
|
||||
* @param state int
|
||||
* @throws Exception
|
||||
*/
|
||||
public void handleMasterNotificationChange(int state) throws Exception {
|
||||
|
||||
System.out.println("CrontabManager.handleMasterNotificationChange state:" +
|
||||
state);
|
||||
|
||||
switch (state) {
|
||||
case MasterIdentificatorNotificationListenerIF.STATE_MASTER:
|
||||
comunicateMasterInstance(true);
|
||||
masterNotificationState = state;
|
||||
break;
|
||||
case MasterIdentificatorNotificationListenerIF.STATE_SLAVE:
|
||||
case MasterIdentificatorNotificationListenerIF.STATE_SHUTDOWN:
|
||||
case MasterIdentificatorNotificationListenerIF.STATE_UNKNOW:
|
||||
if (masterNotificationState ==
|
||||
MasterIdentificatorNotificationListenerIF.STATE_MASTER)
|
||||
comunicateMasterInstance(false);
|
||||
masterNotificationState = state;
|
||||
break;
|
||||
default:
|
||||
System.out.println(
|
||||
"CrontabManager.handleMasterNotificationChange:valore non valido:" +
|
||||
state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* comunico a tutti i componenti necessari la notizia
|
||||
* il RunnerManager e il TaskStateMonitor non vengono toccati per non creare
|
||||
* inconsistenze nei dati
|
||||
* Tutte le schedulazioni sul questo nodo verranno annullate
|
||||
* Tutti i task in running finiranno
|
||||
* @param isMaster boolean
|
||||
* @throws Exception
|
||||
*/
|
||||
private void comunicateMasterInstance(boolean isMaster) throws Exception {
|
||||
//comunico allo scheduler la notizia
|
||||
Scheduler.getInstance().setMasterInstance(isMaster);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop invocato dallo script crontabStop.sh
|
||||
* @throws Exception
|
||||
*/
|
||||
public void stopByShell() throws Exception{
|
||||
|
||||
log.info("Inizio procedura di stop del Crontab...");
|
||||
getTaskManagerClient().stop();
|
||||
log.info("Fine procedura di stop del Crontab...");
|
||||
}
|
||||
|
||||
/**
|
||||
* Start invocato dallo script crontabStart.sh
|
||||
* @throws Exception
|
||||
*/
|
||||
public void startByShell() throws Exception{
|
||||
|
||||
log.info("Inizio procedura di start del Crontab...");
|
||||
getTaskManagerClient().start();
|
||||
log.info("Fine procedura di start del Crontab...");
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo di utilità per il reperimento del RemoteMBeanServer sul server localhost:7501
|
||||
* @throws Exception
|
||||
* @return RemoteMBeanServer
|
||||
*/
|
||||
private RemoteMBeanServer getLocalMBeanServer()throws Exception{
|
||||
|
||||
MBeanHome mbh = Helper.getMBeanHome(
|
||||
userName,
|
||||
passwd,
|
||||
weblogicURL,
|
||||
serverName
|
||||
);
|
||||
|
||||
// MBeanHome mbh = Helper.getMBeanHome("weblogic" , "weblogic", "t3://localhost:7101" , "serverMnp" );
|
||||
return mbh.getMBeanServer();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo di utilità per il reperimento del TaskManagerMBean sul server localhost:7501
|
||||
* @throws Exception
|
||||
* @return TaskManagerMBean
|
||||
*/
|
||||
private TaskManagerMBean getTaskManagerClient() throws Exception{
|
||||
|
||||
return new TaskManagerClient(CrontabCostants.OBJECT_TASK_MANAGER_MBEAN_CLIENT);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package it.valueteam.crontab.init;
|
||||
|
||||
import java.io.*;
|
||||
import org.apache.log4j.*;
|
||||
import mnp.crontab.utility.*;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>: </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Società</b>: ObjectWay S.p.a.</p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class CrontabStarter {
|
||||
private static Logger log = Logger.getLogger(CrontabStarter.class.getName());
|
||||
public CrontabStarter() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
PropertyConfigurator.configure(Resources.getLOG_CONF_FILE());
|
||||
CrontabManager.getInstance().startByShell();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
StringWriter sw = new StringWriter();
|
||||
ex.printStackTrace(new PrintWriter(sw));
|
||||
log.error("Impossibile eseguire lo start del crontab: " + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package it.valueteam.crontab.init;
|
||||
|
||||
import java.io.*;
|
||||
import org.apache.log4j.*;
|
||||
import mnp.crontab.utility.*;
|
||||
import it.valueteam.crontab.processexecutor.ProcessIF;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
* <p><b>Descrizione</b>: </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2003</p>
|
||||
* <p><b>Società</b>: ObjectWay S.p.a.</p>
|
||||
* @author Lvk@ Lorenzon
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class CrontabStopper{
|
||||
private static Logger log = Logger.getLogger(CrontabStopper.class.getName());
|
||||
public CrontabStopper() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
PropertyConfigurator.configure(Resources.getLOG_CONF_FILE());
|
||||
CrontabManager.getInstance().stopByShell();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
StringWriter sw = new StringWriter();
|
||||
ex.printStackTrace(new PrintWriter(sw));
|
||||
log.error("Impossibile eseguire lo stop del crontab: " + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* requiredTX
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean requiredTX() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
package it.valueteam.crontab.jms;
|
||||
|
||||
/**
|
||||
* <p>Title: Progetto Gateway OLO MNP</p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2002</p>
|
||||
* <p>Company: </p>
|
||||
* @author Marco Palmini
|
||||
* @version 1.0
|
||||
* @version 1.1 - C.P - 18/08/05 - Diventato un Singleton - implem. Service Locator
|
||||
*/
|
||||
|
||||
import java.util.Properties;
|
||||
import java.io.*;
|
||||
import javax.naming.*;
|
||||
import javax.jms.*;
|
||||
import javax.jms.*;
|
||||
|
||||
import java.util.*;
|
||||
import mnp.crontab.utility.Resources;
|
||||
import mnp.crontab.config.am.*;
|
||||
|
||||
public class AppConfigurationMessageHandler {
|
||||
|
||||
//singleton
|
||||
private static AppConfigurationMessageHandler onlyInstance=null;
|
||||
|
||||
// TopicConnectionFactory e Topic sono Thead Safe quindi vengono cachate
|
||||
private static final String TopicConnectionFactoryCacheName = "TopicConnectionFactory";
|
||||
private HashMap topicCache = new HashMap();
|
||||
private HashMap tcfCache = new HashMap();
|
||||
private static final String TOPIC_CONN_FACTORY = "jms/ConnectionFactory";
|
||||
private static final String TOPIC_JNDI_NAME = "jms/MessageTopicAppConfiguration";
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param transaction
|
||||
* @throws FileNotFoundException
|
||||
* @throws IOException
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
private AppConfigurationMessageHandler() {
|
||||
}
|
||||
|
||||
public static AppConfigurationMessageHandler getInstance() throws Exception{
|
||||
if (onlyInstance==null) {
|
||||
synchronized(AppConfigurationMessageHandler.class) {
|
||||
if (onlyInstance==null) {
|
||||
onlyInstance = new AppConfigurationMessageHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return onlyInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il contesto
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private Context getInitialContext() throws Exception {
|
||||
|
||||
// String user = "";
|
||||
// String password = "";
|
||||
|
||||
try {
|
||||
// Properties properties = new Properties();
|
||||
// properties.put(Context.INITIAL_CONTEXT_FACTORY, Resources.getWLServerContextFactory());
|
||||
// properties.put(Context.PROVIDER_URL, Resources.getWLServerDbcUrl());
|
||||
// user = Resources.getWLServerGuestUser();
|
||||
// password = Resources.getWLServerGuestPwd();
|
||||
//
|
||||
// if ((user!=null)&&(!user.equals(""))) {
|
||||
// properties.put(Context.SECURITY_PRINCIPAL, user);
|
||||
// properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
|
||||
// }
|
||||
// return new InitialContext(properties);
|
||||
return new InitialContext();
|
||||
}
|
||||
catch(Exception e) {
|
||||
// System.out.println("I parametri di configurazione del Context sono : \n");
|
||||
// System.out.println("context.factory : ["+Resources.getWLServerContextFactory()+"]");
|
||||
// System.out.println("url : ["+ Resources.getWLServerDbcUrl()+"]");
|
||||
// System.out.println("user [" +user+"]");
|
||||
// System.out.println("password [" +password+"]");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Inserisce un oggetto di tipo XMLControllerConfigIF/InternalSystemControllerConfigIF nella topic
|
||||
* con le varie property
|
||||
* @throws Exception
|
||||
*/
|
||||
public void insertTopic(Object message) throws Exception {
|
||||
TopicConnection tcon = null;
|
||||
TopicSession tsession = null;
|
||||
TopicPublisher tpublisher = null;
|
||||
ObjectMessage objMsg = null;
|
||||
try {
|
||||
tcon = getTopicConnection();
|
||||
tsession = getTopicSession(tcon);
|
||||
tpublisher = getTopicPublisher(tsession);
|
||||
|
||||
//creare un messaggio di tipologia ObjectMessage: msg
|
||||
if (message instanceof XMLControllerConfigIF) {
|
||||
objMsg=tsession.createObjectMessage((XMLControllerConfig)message);
|
||||
}
|
||||
else if (message instanceof InternalSystemControllerConfigIF) {
|
||||
objMsg=tsession.createObjectMessage((InternalSystemControllerConfig)message);
|
||||
}
|
||||
else
|
||||
throw new Exception("Config-Type not recognized");
|
||||
// if (prop != null) {
|
||||
// Enumeration keys = prop.keys();
|
||||
// while (keys.hasMoreElements()) {
|
||||
// String key = (String) keys.nextElement();
|
||||
// objMsg.setStringProperty(key, (String) prop.get(key));
|
||||
// }
|
||||
// }
|
||||
tcon.start();
|
||||
//invia il messaggio sulla coda
|
||||
tpublisher.publish(objMsg);
|
||||
}
|
||||
catch (NamingException ne) {
|
||||
clearCache();
|
||||
throw ne;
|
||||
}
|
||||
catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
// cancello la cache perchè in caso di failure potrebbe essere invalidata
|
||||
// la destination
|
||||
clearCache();
|
||||
throw new Exception(e.toString());
|
||||
}
|
||||
finally {
|
||||
//chiudere sender,sessione,connection
|
||||
close(tcon, tsession, tpublisher);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancella le cache
|
||||
*/
|
||||
private void clearCache() {
|
||||
tcfCache.clear();
|
||||
topicCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Chiude gli oggetti JMS
|
||||
* sender,session e connection
|
||||
*/
|
||||
private void close(TopicConnection tcon,TopicSession tsession,TopicPublisher topicPublisher) {
|
||||
try {topicPublisher.close();} catch (Exception jms){jms.toString();}
|
||||
try {tsession.close();} catch (Exception jms){jms.toString();}
|
||||
try {tcon.close();} catch (Exception jms){jms.toString();}
|
||||
}
|
||||
|
||||
private void closeCTX(Context initialcontext) {
|
||||
if (initialcontext != null)
|
||||
try {
|
||||
initialcontext.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("Impossibile chiudere initialcontext");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il nome della classe
|
||||
* @return
|
||||
*/
|
||||
private String getClassName() { return this.getClass().getName()+" "; }
|
||||
|
||||
/**
|
||||
* cache della ConnectionFactory
|
||||
*/
|
||||
private final TopicConnectionFactory createTopicConnectionFactory() throws Exception {
|
||||
Context initialcontext = null;
|
||||
TopicConnectionFactory tconFactory=null;
|
||||
tconFactory = (TopicConnectionFactory) tcfCache.get(TopicConnectionFactoryCacheName);
|
||||
if (tconFactory==null) {
|
||||
synchronized (this) {
|
||||
tconFactory = (TopicConnectionFactory) tcfCache.get(TopicConnectionFactoryCacheName);
|
||||
if (tconFactory == null) {
|
||||
try {
|
||||
System.out.println("MessageHandler:prendo la TopicConnectionFactory");
|
||||
initialcontext = getInitialContext();
|
||||
// ottengo la jms factory
|
||||
tconFactory = (TopicConnectionFactory) initialcontext.lookup(TOPIC_CONN_FACTORY);
|
||||
tcfCache.put(TopicConnectionFactoryCacheName,tconFactory);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
closeCTX(initialcontext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tconFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* ritorna una QueueConnection
|
||||
* @throws Exception
|
||||
* @return TopicConnection
|
||||
*/
|
||||
private TopicConnection getTopicConnection() throws Exception{
|
||||
TopicConnection tcon = null;
|
||||
TopicConnectionFactory tconFactory = null;
|
||||
tconFactory = createTopicConnectionFactory();
|
||||
// Creo connessione fisica a JMS
|
||||
try {
|
||||
tcon = tconFactory.createTopicConnection();
|
||||
}
|
||||
catch (JMSException ex) {
|
||||
throw ex;
|
||||
}
|
||||
return tcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* ritorna una TopicConnection
|
||||
* @throws Exception
|
||||
* @return TopicConnection
|
||||
*/
|
||||
private TopicSession getTopicSession(TopicConnection tcon) throws Exception {
|
||||
TopicSession tsession = null;
|
||||
// creare un oggetto session: session
|
||||
// se il metodo viene richiamato in transazione il parametro tx=true altrimenti false(JTA)
|
||||
tsession = tcon.createTopicSession(false, Session.CLIENT_ACKNOWLEDGE);
|
||||
return tsession;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inizializza la topic e il topicPublisher
|
||||
* @param message
|
||||
* @throws Exception
|
||||
*/
|
||||
private TopicPublisher getTopicPublisher(TopicSession tsession) throws Exception {
|
||||
TopicPublisher topicPublisher=null;
|
||||
Topic topic=null;
|
||||
Context initialcontext=null;
|
||||
|
||||
topic = (Topic) topicCache.get(TOPIC_JNDI_NAME);
|
||||
if (topic==null) {
|
||||
synchronized(this) {
|
||||
topic = (Topic) topicCache.get(TOPIC_JNDI_NAME);
|
||||
if (topic==null) {
|
||||
try {
|
||||
System.out.println("MessageHandler:prendo la Topic:"+TOPIC_JNDI_NAME);
|
||||
initialcontext = getInitialContext();
|
||||
// ottengo la destination
|
||||
topic = (Topic) initialcontext.lookup(TOPIC_JNDI_NAME);
|
||||
// la metto in cache
|
||||
topicCache.put(TOPIC_JNDI_NAME,topic);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
closeCTX(initialcontext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// fine topic
|
||||
|
||||
//creare un oggetto topicPublisher (eventualmente prioritario)
|
||||
topicPublisher = tsession.createPublisher(topic);
|
||||
|
||||
return topicPublisher;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* finalize
|
||||
* @throws Throwable
|
||||
*/
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
System.out.println("finalize MessageHandler");
|
||||
clearCache();
|
||||
tcfCache=null;
|
||||
topicCache=null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package it.valueteam.crontab.obj.engine;
|
||||
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.utility.EventTime;
|
||||
import mnp.crontab.utility.*;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP-Crontab</p>
|
||||
*
|
||||
* <p>Description: </p>
|
||||
*
|
||||
* <p>Copyright: Copyright (c) 2006</p>
|
||||
*
|
||||
* <p>Company: Value Team</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
public class EmergencyTask extends RunningTask {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String NOME="TASK_EMERGENZA";
|
||||
|
||||
public EmergencyTask(TaskInfo taskInfo) {
|
||||
super(taskInfo, new EventTime(), null);
|
||||
this.taskId = Resources.getID_TASK_EMERGENZA();
|
||||
//C.P. 18/10/2007 modificato da null->NOME
|
||||
this.nome = NOME;
|
||||
//itero sulla running process list per forzare il running task id al valore
|
||||
//Resources.getID_TASK_EMERGENZA
|
||||
if (!taskInfo.getId().equalsIgnoreCase(Resources.getID_TASK_EMERGENZA())) {
|
||||
Iterator iter = this.listProcessToExecute.iterator();
|
||||
RunningProcess rp = null;
|
||||
while (iter.hasNext()) {
|
||||
rp = (RunningProcess) iter.next();
|
||||
rp.setIdRunningTask(getRunningTaskID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInTimeWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package it.valueteam.crontab.obj.engine;
|
||||
import java.io.*;
|
||||
|
||||
import it.valueteam.crontab.config.*;
|
||||
/**
|
||||
* Istanza di un process da eseguire
|
||||
* il runningProcess è aggegato all'interno del RunningTask che gestisce la sua vita
|
||||
* la gestoine degli stati interni viene fatta dal RunningTask
|
||||
* <p>Title: MNP CRONTAB</p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: ValueTeam - TeleAp</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
public class RunningProcess implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String idRunningTask;
|
||||
private TaskInfo.ProcessInfoRef processInfoRef;
|
||||
|
||||
public RunningProcess(String idRunningTask,TaskInfo.ProcessInfoRef processInfoRef) {
|
||||
this.idRunningTask=idRunningTask;
|
||||
this.processInfoRef=processInfoRef;
|
||||
}
|
||||
|
||||
public String getIdRunningTask() {
|
||||
return idRunningTask;
|
||||
}
|
||||
public void setIdRunningTask(String idRunningTask) {
|
||||
this.idRunningTask = idRunningTask;
|
||||
}
|
||||
public String getIdRunningProcess() {
|
||||
return idRunningTask+processInfoRef.getProcess().getId();
|
||||
}
|
||||
public TaskInfo.ProcessInfoRef getProcessInfoRef() {
|
||||
return processInfoRef;
|
||||
}
|
||||
public void setProcessInfoRef(TaskInfo.ProcessInfoRef processInfoRef) {
|
||||
this.processInfoRef = processInfoRef;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the object.
|
||||
*
|
||||
* @return a string representation of the object.
|
||||
* @todo Implement this java.lang.Object method
|
||||
*/
|
||||
public String toString() {
|
||||
return processInfoRef.getProcess().getName()+"-"+getIdRunningProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica che il processo sia abilitato sia per il task che per il processo stesso
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
//controllo se il processo è abilitato all'esecuzione
|
||||
if ( (!getProcessInfoRef().isEnabled()) ||
|
||||
(!getProcessInfoRef().getProcess().getEnabled()))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
package it.valueteam.crontab.obj.engine;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import it.valueteam.crontab.utility.*;
|
||||
import it.valueteam.crontab.config.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP CRONTAB</p>
|
||||
*
|
||||
* <p>Description: Rappresenta la singola schedulazione/esecuzione del task</p>
|
||||
*
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
*
|
||||
* <p>Company: ValueTeam - TeleAp</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
public class RunningTask implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
//stato iniziale
|
||||
public final static int STATE_UNKNOWN = -1;
|
||||
//quando sono fuori dalle finestre temporali
|
||||
//quando ho già un task accodato e non lo eseguo
|
||||
public final static int STATE_IDLE = 0;
|
||||
//quando il task è schedulato
|
||||
public final static int STATE_SCHEDULED = 1;
|
||||
//quando per il task è richiesta l'esecuzione
|
||||
public final static int STATE_RUN_AS_POSSIBLE = 2;
|
||||
//quando il task viene eseguito
|
||||
public final static int STATE_RUNNING = 3;
|
||||
//quando viene richiesta da GUI l'arresto
|
||||
public final static int STATE_DESTROYED = 4;
|
||||
//quando il task è stato eseguito
|
||||
public final static int STATE_EXECUTED = 6;
|
||||
//task settato per il detroy ma con processo in runnning
|
||||
public final static int STATE_DESTROY_AS_POSSIBLE = 8;
|
||||
//public final static int STATE_RUN_WAITING_FOR_BUSY_PROCESS=7;
|
||||
//stati usati dalla GUI ( da verificare se serve)
|
||||
public final static int STATE_DISABLED = 5;
|
||||
// gestione dei processi
|
||||
public static final int PROCESS_STATE_UNKNOWN = -1;
|
||||
public static final int PROCESS_STATE_RUN_AS_POSSIBLE = 1;
|
||||
public static final int PROCESS_STATE_RUNNING = 2;
|
||||
public static final int PROCESS_STATE_EXITVALUEOK = 3;
|
||||
public static final int PROCESS_STATE_EXITVALUEKO = 4;
|
||||
public static final int PROCESS_STATE_DISABLED = 5;
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
protected LinkedList processList;
|
||||
protected int state;
|
||||
protected final EventTime stopDate;
|
||||
protected final EventTime scheduledStart;
|
||||
protected EventTime endDate;
|
||||
protected String runProcess;
|
||||
protected Hashtable processState;
|
||||
protected boolean bToDestroy = false;
|
||||
protected String taskId = null;
|
||||
protected String nome = null;
|
||||
protected String id = null;
|
||||
// rappresenta la lista dei processi da eseguire
|
||||
// ogni volta che viene chiesto il prossimo processo
|
||||
// si aggiorna
|
||||
protected LinkedList listProcessToExecute;
|
||||
|
||||
public RunningTask(final TaskInfo taskInfo, final EventTime instant,
|
||||
final EventTime stopDate) {
|
||||
this.taskId = taskInfo.getId();
|
||||
this.nome = taskInfo.getName();
|
||||
this.scheduledStart = instant;
|
||||
this.stopDate = stopDate;
|
||||
this.processState = new Hashtable();
|
||||
this.setState(STATE_UNKNOWN);
|
||||
this.processList = new LinkedList();
|
||||
TaskInfo.ProcessInfoRef item=null;
|
||||
TaskInfo.ProcessInfoRef newItem=null;
|
||||
RunningProcess runningProcess=null;
|
||||
listProcessToExecute = new LinkedList();
|
||||
for (Iterator i = taskInfo.getProcessList().iterator(); i.hasNext(); ) {
|
||||
item = (TaskInfo.ProcessInfoRef) i.next();
|
||||
newItem = new TaskInfo.ProcessInfoRef(item);
|
||||
//lista dei processi per GUI
|
||||
processList.add(newItem);
|
||||
//lista dei processi per gestione esecuzione
|
||||
runningProcess = new RunningProcess(getRunningTaskID(),newItem);
|
||||
listProcessToExecute.add(runningProcess);
|
||||
if (runningProcess.isEnabled())
|
||||
processState.put(newItem.getProcess().getId(), new Integer(PROCESS_STATE_UNKNOWN));
|
||||
else
|
||||
processState.put(newItem.getProcess().getId(), new Integer(PROCESS_STATE_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return nome;
|
||||
}
|
||||
|
||||
public String getRunningTaskID() {
|
||||
return taskId + "_" + getScheduledStart().getTime().toString();
|
||||
}
|
||||
|
||||
public EventTime getScheduledStart() {
|
||||
return scheduledStart;
|
||||
}
|
||||
|
||||
public EventTime getStopTime() {
|
||||
return stopDate;
|
||||
}
|
||||
|
||||
public LinkedList getProcessList() {
|
||||
return processList;
|
||||
}
|
||||
|
||||
public boolean isInTimeWindow() {
|
||||
boolean res = false;
|
||||
EventTime now = new EventTime();
|
||||
if (stopDate == null)return true;
|
||||
res = (now.after(scheduledStart) || now.equals(scheduledStart)) &&
|
||||
now.before(stopDate);
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean isToDestroy() {
|
||||
return bToDestroy;
|
||||
}
|
||||
|
||||
public void setAsToDestroy() {
|
||||
bToDestroy = true;
|
||||
}
|
||||
|
||||
public void setState(int value) {
|
||||
this.state = value;
|
||||
}
|
||||
|
||||
public EventTime getEndDate() {
|
||||
return this.endDate;
|
||||
}
|
||||
|
||||
public void setStopDate(EventTime time) {
|
||||
this.endDate = time;
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public String getRunningProcessId() {
|
||||
return runProcess;
|
||||
}
|
||||
|
||||
public void setRunningProcess(String value) {
|
||||
runProcess = value;
|
||||
}
|
||||
|
||||
public void setProcessState(String procId, int i) {
|
||||
if (processState != null) {
|
||||
processState.put(procId, new Integer(i));
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList getProcessStateList() {
|
||||
ArrayList res = new ArrayList();
|
||||
for (Iterator i = processList.iterator(); i.hasNext(); ) {
|
||||
TaskInfo.ProcessInfoRef procRef = (TaskInfo.ProcessInfoRef) i.next();
|
||||
String procId = procRef.getProcess().getId();
|
||||
Integer istate = (Integer)processState.get(procId);
|
||||
res.add(istate);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il prossimo process da Eseguire
|
||||
* Compresi quelli disabilitati
|
||||
* @return ProcessInfo
|
||||
*/
|
||||
public RunningProcess getNextProcessToExecute() {
|
||||
if (listProcessToExecute.isEmpty())
|
||||
return null;
|
||||
else
|
||||
return (RunningProcess)listProcessToExecute.removeFirst();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string representation of the object.
|
||||
*
|
||||
* @return a string representation of the object.
|
||||
* @todo Implement this java.lang.Object method
|
||||
*/
|
||||
public String toString() {
|
||||
return getName()+"-"+getTaskId()+"-"+getRunningTaskID();
|
||||
}
|
||||
|
||||
private TaskInfo.ProcessInfoRef findInternalProcess(String id) {
|
||||
TaskInfo.ProcessInfoRef procRef=null;
|
||||
String procId=null;
|
||||
for (Iterator i = processList.iterator(); i.hasNext(); ) {
|
||||
procRef = (TaskInfo.ProcessInfoRef) i.next();
|
||||
procId = procRef.getProcess().getId();
|
||||
if (procId.equals(id)) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
procRef=null;
|
||||
}
|
||||
}
|
||||
return procRef;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package it.valueteam.crontab.obj.gui;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import it.valueteam.crontab.obj.engine.*;
|
||||
import it.valueteam.crontab.utility.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* <p><b>Descrizione: Rappresenta una vista su Running Task</b>: </p>
|
||||
* <p><b>Copyright</b>: Copyright (c) 2007</p>
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class TaskState implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private EventTime scheduledAt = null;
|
||||
private EventTime stopTime = null;
|
||||
private int state = RunningTask.STATE_UNKNOWN;
|
||||
private ArrayList procesStateList = null;
|
||||
private ArrayList processList = null;
|
||||
private String id = null;
|
||||
private String taskId = null;
|
||||
private String nome = null;
|
||||
|
||||
public TaskState(RunningTask rt) {
|
||||
this.id = rt.getRunningTaskID();
|
||||
this.nome = rt.getName();
|
||||
this.scheduledAt = rt.getScheduledStart();
|
||||
this.stopTime = rt.getStopTime();
|
||||
this.taskId = rt.getTaskId();
|
||||
this.state = rt.getState();
|
||||
this.processList = new ArrayList(rt.getProcessList());
|
||||
procesStateList = rt.getProcessStateList();
|
||||
}
|
||||
|
||||
public ArrayList getProcessStateList() {
|
||||
return this.procesStateList;
|
||||
}
|
||||
|
||||
public ArrayList getProcessList() {
|
||||
return this.processList;
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public EventTime getSchedulation() {
|
||||
return scheduledAt;
|
||||
}
|
||||
|
||||
public EventTime getStopTime() {
|
||||
return stopTime;
|
||||
}
|
||||
|
||||
public boolean isState(int state) {
|
||||
return this.state == state;
|
||||
}
|
||||
|
||||
public int updateState(int state) {
|
||||
int prevState = this.state;
|
||||
this.state = state;
|
||||
return prevState;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getTaskId() {
|
||||
return this.taskId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.nome;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
package it.valueteam.crontab.obj.gui;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.config.setting.*;
|
||||
import it.valueteam.crontab.obj.engine.*;
|
||||
import it.valueteam.crontab.utility.*;
|
||||
|
||||
/**
|
||||
* <p>Title: Crontab</p>
|
||||
*
|
||||
* <p>Description: Classe che monitorizza lo stato corrente di tutti i task/processi schedulati</p>
|
||||
*
|
||||
* <p>Copyright: Copyright (c) 2006</p>
|
||||
*
|
||||
* <p>Company: Value Team</p>
|
||||
*
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
public class TaskStateMonitor{
|
||||
// log
|
||||
private static Logger log = Logger.getLogger(TaskStateMonitor.class.getName());
|
||||
|
||||
// Contiene tutti i runningTask attualmente schedulati
|
||||
private Hashtable runningTaskTable = new Hashtable();
|
||||
//Contiene tutti i runningTask in attesa per il lancio di un processo attualmente in
|
||||
//esecuzione da parte di un'altro task
|
||||
private Hashtable taskWaitingBusyProcess = new Hashtable();
|
||||
// Contiene tutti i runningTask che stanno eseguendo un processo
|
||||
private Hashtable taskRunningProcess = new Hashtable();
|
||||
// Contiene il running task al quale è associato il processo in running
|
||||
private Hashtable processRunningOnTask = new Hashtable();
|
||||
|
||||
private Settings settings = null;
|
||||
private static TaskStateMonitor _instance = null;
|
||||
|
||||
private TaskStateMonitor() {
|
||||
}
|
||||
|
||||
public static TaskStateMonitor getInstance() {
|
||||
if (_instance == null) {
|
||||
synchronized (it.valueteam.crontab.obj.gui.TaskStateMonitor.class) {
|
||||
if (_instance == null) {
|
||||
_instance = new it.valueteam.crontab.obj.gui.TaskStateMonitor();
|
||||
}
|
||||
}
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset dello stato del monitor
|
||||
*/
|
||||
public void clear() {
|
||||
taskRunningProcess.clear();
|
||||
processRunningOnTask.clear();
|
||||
taskWaitingBusyProcess.clear();
|
||||
runningTaskTable.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiunge il task passato come parametro alla lista dei task schedulati
|
||||
*
|
||||
* @param runnerTask RunningTask
|
||||
*/
|
||||
public synchronized void onScheduled(RunningTask runnerTask) {
|
||||
runningTaskTable.put(runnerTask.getRunningTaskID(), runnerTask);
|
||||
}
|
||||
|
||||
public synchronized void onRunningProcess(RunningTask runnerTask, ProcessInfo procInfo) {
|
||||
|
||||
if (runnerTask.getState() == RunningTask.STATE_RUNNING) {
|
||||
if (runningTaskTable.containsKey(runnerTask.getRunningTaskID())) {
|
||||
if (taskWaitingBusyProcess.containsKey(runnerTask.getRunningTaskID())) {
|
||||
taskWaitingBusyProcess.remove(runnerTask.getRunningTaskID());
|
||||
}
|
||||
taskRunningProcess.put(runnerTask.getRunningTaskID(), procInfo);
|
||||
processRunningOnTask.put(procInfo.getId(), runnerTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void onInWaitingForProcess(RunningTask runnerTask,
|
||||
ProcessInfo procInfo) {
|
||||
if (runnerTask.getState() == RunningTask.STATE_RUNNING) {
|
||||
if (runningTaskTable.containsKey(runnerTask.getRunningTaskID())) {
|
||||
taskWaitingBusyProcess.put(runnerTask.getRunningTaskID(), procInfo);
|
||||
log.info("Task: " + runnerTask.getRunningTaskID() + " in waiting for process: " +
|
||||
procInfo.getId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void onEndRunningProcess(RunningTask runnerTask,
|
||||
ProcessInfo procInfo) {
|
||||
if (runnerTask.getState() == RunningTask.STATE_RUNNING) {
|
||||
if (runningTaskTable.containsKey(runnerTask.getRunningTaskID())) {
|
||||
ProcessInfo proc = (ProcessInfo) taskRunningProcess.get(runnerTask.
|
||||
getRunningTaskID());
|
||||
RunningTask rt = (RunningTask) processRunningOnTask.get(procInfo.getId());
|
||||
if (proc.getId().equals(procInfo.getId()) &&
|
||||
rt.getRunningTaskID().equals(runnerTask.getRunningTaskID())) {
|
||||
taskRunningProcess.remove(runnerTask.getRunningTaskID());
|
||||
processRunningOnTask.remove(procInfo.getId());
|
||||
log.info("Task: " + runnerTask.getRunningTaskID() + " end Running process: " +
|
||||
procInfo.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void onEndRunning(RunningTask runnerTask) {
|
||||
boolean rimosso = false;
|
||||
if ( (runnerTask.getState() == RunningTask.STATE_EXECUTED) ||
|
||||
(runnerTask.getState() == RunningTask.STATE_DESTROYED)) {
|
||||
for (Iterator i = runningTaskTable.keySet().iterator(); i.hasNext(); ) {
|
||||
RunningTask item = (RunningTask) runningTaskTable.get(i.next());
|
||||
if ( ( (item.getState() == RunningTask.STATE_EXECUTED) ||
|
||||
(item.getState() == RunningTask.STATE_DESTROYED)) &&
|
||||
(item.getTaskId().equals(runnerTask.getTaskId())) &&
|
||||
(item != runnerTask)) {
|
||||
rimosso=true;
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
if (rimosso)
|
||||
log.info("STATO TASK: " + runnerTask.getRunningTaskID() +
|
||||
" END RUNNING: eliminato dalla coda di esecuzione");
|
||||
else
|
||||
log.info("STATO TASK: " + runnerTask.getRunningTaskID() +
|
||||
" END RUNNING: NON eliminato dalla coda di esecuzione");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void onAutoEnd(RunningTask runnerTask) {
|
||||
if (runningTaskTable.containsKey(runnerTask.getRunningTaskID())) {
|
||||
runningTaskTable.remove(runnerTask.getRunningTaskID());
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void onDestroy(RunningTask runnerTask) {
|
||||
|
||||
if (runnerTask.getState() == RunningTask.STATE_DESTROYED) {
|
||||
if (taskWaitingBusyProcess.containsKey(runnerTask.getRunningTaskID())) {
|
||||
taskWaitingBusyProcess.remove(runnerTask.getRunningTaskID());
|
||||
}
|
||||
if (taskRunningProcess.containsKey(runnerTask.getRunningTaskID())) {
|
||||
ProcessInfo proc = (ProcessInfo) taskRunningProcess.get(runnerTask.
|
||||
getRunningTaskID());
|
||||
taskRunningProcess.remove(runnerTask.getRunningTaskID());
|
||||
processRunningOnTask.remove(proc.getId());
|
||||
}
|
||||
}
|
||||
/** @todo Verificare il motivo per il quale eseguo la seguente iterazione
|
||||
* e controllo il task id*/
|
||||
for (Iterator i = runningTaskTable.keySet().iterator(); i.hasNext(); ) {
|
||||
RunningTask item = (RunningTask) runningTaskTable.get(i.next());
|
||||
if ( ( (item.getState() == RunningTask.STATE_EXECUTED) ||
|
||||
(item.getState() == RunningTask.STATE_DESTROYED)) &&
|
||||
(item.getTaskId().equals(runnerTask.getTaskId())) &&
|
||||
(item != runnerTask)) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized ArrayList getTaskList() {
|
||||
|
||||
ArrayList res = new ArrayList();
|
||||
EventTime before5FromNow = new EventTime();
|
||||
before5FromNow.add(Calendar.MINUTE, -5);
|
||||
for (Iterator i = runningTaskTable.keySet().iterator(); i.hasNext(); ) {
|
||||
RunningTask item = (RunningTask) runningTaskTable.get(i.next());
|
||||
if ( ( (item.getState() == RunningTask.STATE_EXECUTED) ||
|
||||
(item.getState() == RunningTask.STATE_DESTROYED)) &&
|
||||
(item.getEndDate() != null) &&
|
||||
(item.getEndDate().before(before5FromNow))) {
|
||||
i.remove();
|
||||
continue;
|
||||
}
|
||||
res.add(new TaskState(item));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private synchronized ArrayList getOnlyOfState(int state) {
|
||||
ArrayList res = new ArrayList();
|
||||
for (Iterator i = runningTaskTable.keySet().iterator(); i.hasNext(); ) {
|
||||
RunningTask item = (RunningTask) runningTaskTable.get(i.next());
|
||||
if (item.getState() == state) {
|
||||
res.add(new TaskState(item));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public ArrayList getActiveProcessList() {
|
||||
ArrayList res = new ArrayList();
|
||||
for (Iterator i = processRunningOnTask.keySet().iterator(); i.hasNext(); ) {
|
||||
String procId = (String) i.next();
|
||||
String taskId = (String) processRunningOnTask.get(procId);
|
||||
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public synchronized ArrayList getScheduledTaskList() {
|
||||
return getOnlyOfState(RunningTask.STATE_SCHEDULED);
|
||||
}
|
||||
|
||||
public synchronized ArrayList getActiveTaskList() {
|
||||
ArrayList res = getOnlyOfState(RunningTask.STATE_RUNNING);
|
||||
return res;
|
||||
}
|
||||
|
||||
public synchronized void onResetScheduled() {
|
||||
for (Iterator i = runningTaskTable.keySet().iterator(); i.hasNext(); ) {
|
||||
RunningTask item = (RunningTask) runningTaskTable.get(i.next());
|
||||
if (item.getState() == RunningTask.STATE_SCHEDULED) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Elimina tutti i task in stato EXECUTED dalla RunningTaskTable
|
||||
* quando lo schedulatore viene disabilitato
|
||||
*/
|
||||
public void onStopRunnerManager() {
|
||||
for (Iterator i = runningTaskTable.keySet().iterator(); i.hasNext(); ) {
|
||||
RunningTask item = (RunningTask) runningTaskTable.get(i.next());
|
||||
if (item.getState() == RunningTask.STATE_EXECUTED) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package it.valueteam.crontab.processexecutor;
|
||||
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: </p>
|
||||
* @author Carlo Poccia
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ProcessException extends Exception {
|
||||
|
||||
public ProcessException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public ProcessException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public ProcessException(Throwable e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public ProcessException(String msg, Exception e) {
|
||||
super(msg, e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package it.valueteam.crontab.processexecutor;
|
||||
|
||||
import it.valueteam.crontab.processexecutor.ejb.ProcessServer;
|
||||
import it.valueteam.crontab.processexecutor.ejb.ProcessServerHome;
|
||||
import it.valueteam.crontab.utility.ClusterServiceLocator;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Title: Mobile Number Portability </p>
|
||||
* <p>Description: Classe client per l'esecuzione di processi </p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: </p>
|
||||
* @author Carlo Poccia
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ProcessExecutor {
|
||||
|
||||
private static final String JNDI_NAME ="ejb/processServer";
|
||||
|
||||
public ProcessExecutor() {}
|
||||
|
||||
/**
|
||||
* Esegue un processo invocato da un client esterno all'application server
|
||||
*
|
||||
* @param args String[] - Parametri di esecuzione del processo
|
||||
* @param env Properties - Contiene le environment variables per la connessione al server
|
||||
* @throws ProcessException - Eccezione applicativa rilanciata al client
|
||||
*/
|
||||
public void executeProcess(String[] args,Properties env) throws ProcessException {
|
||||
|
||||
ProcessServerHome processServerHome = null;
|
||||
ProcessServer processServer = null;
|
||||
|
||||
try {
|
||||
System.out.println("Esecuzione del processo ");
|
||||
processServerHome = (ProcessServerHome)new ClusterServiceLocator(env).getRemoteEJB(JNDI_NAME, ProcessServerHome.class);
|
||||
processServer = processServerHome.create();
|
||||
processServer.executeProcess(args);
|
||||
System.out.println("Esecuzione terminata.");
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
throw new ProcessException("Impossibile eseguire il processo: " + args[0] + (args.length>1?" con parametro " + args[1]:""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Esegue un processo invocato da un client interno all'application server
|
||||
*
|
||||
* @param args String[] - Parametri di esecuzione del processo
|
||||
* @throws ProcessException - Eccezione applicativa rilanciata al client
|
||||
*/
|
||||
public void executeProcess(String[] args) throws ProcessException {
|
||||
ProcessServerHome processServerLocalHome = null;
|
||||
ProcessServer processServer = null;
|
||||
|
||||
try {
|
||||
processServerLocalHome = (ProcessServerHome)new ClusterServiceLocator(null).getRemoteEJB(JNDI_NAME, ProcessServerHome.class);
|
||||
processServer = processServerLocalHome.create();
|
||||
processServer.executeProcess(args);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
throw new ProcessException("Impossibile eseguire il processo: " + args[0] +
|
||||
(args.length > 1 ? " con parametro " + args[1] :
|
||||
""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Esegue la jndi lookup del ProcessServerBean al quale delegare l'esecuzione del processo.
|
||||
*
|
||||
* @param env Properties - Contiene le environment variables per la creazione del jndi context
|
||||
* @return ProcessServerHome - Home Interface del ProcessServerBean
|
||||
* @throws Exception
|
||||
*/
|
||||
// private ProcessServerHome lookup(Properties env) throws Exception {
|
||||
//
|
||||
// Context ctx = null;
|
||||
// ProcessServerHome processServerHome = null;
|
||||
//
|
||||
// try {
|
||||
// if (env==null)
|
||||
// ctx = new InitialContext();
|
||||
// else
|
||||
// ctx = new InitialContext(env);
|
||||
// Object ref = ctx.lookup(JNDI_NAME);
|
||||
// processServerHome = (ProcessServerHome)PortableRemoteObject.narrow(ref, ProcessServerHome.class);
|
||||
// }
|
||||
// catch (Exception ex) {
|
||||
// System.out.println("ECCEZIONE durante il reperimento dell'istanza del EJB: " + this.JNDI_NAME);
|
||||
// ex.printStackTrace();
|
||||
// throw ex;
|
||||
// }
|
||||
// finally {
|
||||
// try {
|
||||
// if (ctx != null) {
|
||||
// ctx.close();
|
||||
// }
|
||||
// }
|
||||
// catch (NamingException ex) {
|
||||
// System.out.println("InitialContext gi<67> chiuso");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return processServerHome;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package it.valueteam.crontab.processexecutor;
|
||||
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: </p>
|
||||
* @author Carlo Poccia
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface ProcessIF {
|
||||
public void execute(String[] args) throws Exception;
|
||||
public boolean requiredTX();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package it.valueteam.crontab.processexecutor.client;
|
||||
|
||||
import it.valueteam.crontab.processexecutor.*;
|
||||
import it.valueteam.crontab.processexecutor.utility.ProcessResources;
|
||||
import java.util.Properties;
|
||||
import javax.naming.Context;
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
*
|
||||
* <p>Description: Classe che si occupa di invocare il modulo di esecuzione dei processi </p>
|
||||
*
|
||||
* <p>Copyright: Copyright (c) 2006</p>
|
||||
*
|
||||
* <p>Company: Valuetean </p>
|
||||
* @author Mario Giurlanda
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SimpleRunProcess {
|
||||
public static void main(String args[]) {
|
||||
SimpleRunProcess runner = new SimpleRunProcess();
|
||||
runner.run(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* run
|
||||
*/
|
||||
private static void run(String args[]) {
|
||||
|
||||
//Creo un istanza del ProcessExecutor al quale delegare l'esecuzione del processo
|
||||
ProcessExecutor exec = new ProcessExecutor();
|
||||
try {
|
||||
System.out.println("Inizio esecuzione processo");
|
||||
Properties env = new Properties();
|
||||
env.put(Context.PROVIDER_URL,ProcessResources.getWLServerUrl());
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY,ProcessResources.getWLServerContextFactory());
|
||||
env.put(Context.SECURITY_PRINCIPAL,ProcessResources.getWLServerConnectionUser());
|
||||
env.put(Context.SECURITY_CREDENTIALS,ProcessResources.getWLServerConnectionPwd());
|
||||
exec.executeProcess(args,env);
|
||||
}
|
||||
catch (ProcessException ex) {
|
||||
System.out.println(ex.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package it.valueteam.crontab.processexecutor.ejb;
|
||||
|
||||
import javax.ejb.EJBObject;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import it.valueteam.crontab.processexecutor.ProcessException;
|
||||
|
||||
public interface ProcessServer extends EJBObject {
|
||||
public void executeProcess(String[] processArgs) throws RemoteException,ProcessException;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package it.valueteam.crontab.processexecutor.ejb;
|
||||
|
||||
import javax.ejb.SessionBean;
|
||||
import javax.ejb.SessionContext;
|
||||
import javax.ejb.CreateException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import it.valueteam.crontab.processexecutor.*;
|
||||
import javax.transaction.UserTransaction;
|
||||
import javax.transaction.*;
|
||||
import javax.transaction.*;
|
||||
import javax.naming.*;
|
||||
import it.valueteam.crontab.processexecutor.utility.*;
|
||||
|
||||
public class ProcessServerBean implements SessionBean {
|
||||
SessionContext sessionContext;
|
||||
public static Logger logger = Logger.getLogger(ProcessServerBean.class);
|
||||
|
||||
public void ejbCreate() throws CreateException {
|
||||
System.out.println("-> ProcessServerBean.ejbCreate() HC: " + hashCode());
|
||||
}
|
||||
|
||||
public void ejbRemove() {
|
||||
System.out.println("-> ProcessServerBean.ejbRemove() HC: " + hashCode());
|
||||
}
|
||||
|
||||
public void ejbActivate() {
|
||||
}
|
||||
|
||||
public void ejbPassivate() {
|
||||
}
|
||||
|
||||
|
||||
public void setSessionContext(SessionContext sessionContext) {
|
||||
this.sessionContext = sessionContext;
|
||||
}
|
||||
|
||||
public void executeProcess(String[] processArgs) throws ProcessException{
|
||||
ProcessIF process=null;
|
||||
String args[]=null;
|
||||
UserTransaction utx=null;
|
||||
|
||||
try {
|
||||
logger.info("Esecuzione Processo");
|
||||
for (int i = 0; i < processArgs.length; i++)
|
||||
logger.info("i parametri sono: " + processArgs[i]);
|
||||
process = ProcessFactory.getProcess(processArgs[0]);
|
||||
// prendo i parametri del processo;
|
||||
args = new String[processArgs.length - 1];
|
||||
System.arraycopy(processArgs, 1, args, 0, processArgs.length - 1);
|
||||
// controllo se il process deve essere chiamato in transazione;
|
||||
if (process.requiredTX()) {
|
||||
//prendo la transazione dal Service locator
|
||||
//e chiamo il process in transazione
|
||||
utx = getUserTransaction();
|
||||
try {
|
||||
utx.begin();
|
||||
process.execute(args);
|
||||
utx.commit();
|
||||
}
|
||||
catch (Throwable ex1) {
|
||||
logger.info("Fine esecuzione processo con eccezioni");
|
||||
if (utx!=null)
|
||||
utx.rollback();
|
||||
throw ex1;
|
||||
}
|
||||
} else {
|
||||
process.execute(args);
|
||||
logger.info("Fine esecuzione processo");
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
logger.info("Fine esecuzione processo con eccezioni");
|
||||
|
||||
ex.printStackTrace();
|
||||
throw new ProcessException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getUserTransaction
|
||||
*
|
||||
* @return UserTransaction
|
||||
*/
|
||||
private UserTransaction getUserTransaction() throws NamingException {
|
||||
|
||||
try {
|
||||
Context ic = new InitialContext();
|
||||
|
||||
UserTransaction utx = (UserTransaction) ic.lookup(
|
||||
"javax.transaction.UserTransaction");
|
||||
return utx;
|
||||
}
|
||||
catch (NamingException ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package it.valueteam.crontab.processexecutor.ejb;
|
||||
|
||||
import javax.ejb.EJBHome;
|
||||
import javax.ejb.CreateException;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
public interface ProcessServerHome extends EJBHome {
|
||||
public ProcessServer create() throws CreateException, RemoteException;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package it.valueteam.crontab.processexecutor.utility;
|
||||
|
||||
/**
|
||||
* /**
|
||||
* <p>Title: Mobile Number Portability </p>
|
||||
* <p>Description:</p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: Valueteam </p>
|
||||
|
||||
* @author Mario Giurlanda
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ClusterEnvironment {
|
||||
|
||||
private String initialContextFactory;
|
||||
private String securityPrincipal;
|
||||
private String securityCrendential;
|
||||
//indirizzi dei nodi del cluster
|
||||
private String cluster_address;
|
||||
|
||||
public ClusterEnvironment(String iCf, String sP, String sC, String cA) {
|
||||
this.initialContextFactory = iCf;
|
||||
this.securityPrincipal = sP;
|
||||
this.securityCrendential = sC;
|
||||
this.cluster_address = cA;
|
||||
}
|
||||
|
||||
public String getSecurityCrendential() {
|
||||
return securityCrendential;
|
||||
}
|
||||
|
||||
public String getSecurityPrincipal() {
|
||||
return securityPrincipal;
|
||||
}
|
||||
|
||||
public String getCluster_address() {
|
||||
return cluster_address;
|
||||
}
|
||||
|
||||
public void setInitialContextFactory(String initialContextFactory) {
|
||||
this.initialContextFactory = initialContextFactory;
|
||||
}
|
||||
|
||||
public void setSecurityCrendential(String securityCrendential) {
|
||||
this.securityCrendential = securityCrendential;
|
||||
}
|
||||
|
||||
public void setSecurityPrincipal(String securityPrincipal) {
|
||||
this.securityPrincipal = securityPrincipal;
|
||||
}
|
||||
|
||||
public void setCluster_address(String cluster_address) {
|
||||
this.cluster_address = cluster_address;
|
||||
}
|
||||
|
||||
public String getInitialContextFactory() {
|
||||
return initialContextFactory;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package it.valueteam.crontab.processexecutor.utility;
|
||||
|
||||
import it.valueteam.crontab.processexecutor.*;
|
||||
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: </p>
|
||||
* @author Carlo Poccia
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ProcessFactory {
|
||||
|
||||
private ProcessFactory() {
|
||||
}
|
||||
|
||||
public static ProcessIF getProcess(String processArgs) throws
|
||||
ProcessException {
|
||||
ProcessIF process = null;
|
||||
Class c = null;
|
||||
try {
|
||||
if ( (processArgs == null)){// || (processArgs.length == 0)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
c = Class.forName(processArgs.trim());
|
||||
process = (ProcessIF) c.newInstance();
|
||||
return process;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.println("CAUSA : "+ex.getCause());
|
||||
System.out.println("LOCALIZED MESSAGE : "+ex.getLocalizedMessage());
|
||||
ex.printStackTrace();
|
||||
throw new ProcessException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package it.valueteam.crontab.processexecutor.utility;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import it.valueteam.securityutility.CryptoUtility;
|
||||
|
||||
public class ProcessResources {
|
||||
private static Properties props = null;
|
||||
|
||||
//private static Logger log;
|
||||
|
||||
private static String propertiesPath = null;
|
||||
|
||||
static {
|
||||
init();
|
||||
}
|
||||
|
||||
private ProcessResources() {
|
||||
}
|
||||
|
||||
private static void init() {
|
||||
FileInputStream f = null;
|
||||
Properties appProps = new Properties();
|
||||
try {
|
||||
|
||||
propertiesPath = System.getProperty("proc_exec_path_properties", "");
|
||||
System.out.println("Path delle Properties per il process executor ottenuto: " + propertiesPath);
|
||||
f = new FileInputStream(propertiesPath);
|
||||
//load del file di Properties
|
||||
appProps.load(f);
|
||||
//decifro gli eventuali valore cifrati
|
||||
try {
|
||||
props = CryptoUtility.getInstance().getCleanProperties(appProps);
|
||||
}
|
||||
catch (Exception ex1) {
|
||||
System.out.println("ERRORE nella creazione del properties crifrato per il process executor");
|
||||
ex1.printStackTrace();
|
||||
f = new FileInputStream(propertiesPath);
|
||||
props = new Properties();
|
||||
props.load(f);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.out.println("ERRORE nella creazione del properties per il process executor.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (f != null)
|
||||
f.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* context factory x wls
|
||||
* @return String
|
||||
*/
|
||||
public static String getWLServerContextFactory() {
|
||||
if (props == null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("WLSERVER.CONTEXT.FACTORY"));
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
* url di connessione a dbc
|
||||
* @return String
|
||||
*/
|
||||
public static String getWLServerUrl() {
|
||||
if (props == null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("WLSERVER.URL"));
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
* username x utente guest
|
||||
* @return String
|
||||
*/
|
||||
public static String getWLServerConnectionUser() {
|
||||
if (props == null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("WLSERVER.CONN.USER"));
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
* Password dell'utente guest
|
||||
* @return String
|
||||
*/
|
||||
public static String getWLServerConnectionPwd() {
|
||||
if (props == null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("{3DES}WLSERVER.CONN.PWD"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String getWLClusterServerName() {
|
||||
if (props == null)
|
||||
init();
|
||||
String ret = Trim(props.getProperty("WLCLUSTER.SERVERNAME"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Utility per eliminare gli spazi dalle properties
|
||||
* @param valore String
|
||||
* @return String
|
||||
*/
|
||||
private static final String Trim(String valore){
|
||||
if (valore!=null)
|
||||
return valore.trim();
|
||||
else return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
package it.valueteam.crontab.utility;
|
||||
|
||||
import java.util.*;
|
||||
import javax.naming.*;
|
||||
import javax.rmi.*;
|
||||
import org.apache.log4j.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Title: ClusterRoundRobinServiceLocator </p>
|
||||
* <p>Description: Questa classe di utilità viene utilizzata
|
||||
* per il reperimento dell'istanza del TimerExecutorEJB secondo
|
||||
* l'algoritmo RoundRobin eliminando la server affinity del cluster BEA</p>
|
||||
* <p>Copyright: Copyright (c) 2006</p>
|
||||
* <p>Company: </p>
|
||||
* @author C.A.
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ClusterRoundRobinServiceLocator {
|
||||
|
||||
// unica istanza del componente
|
||||
private static ClusterRoundRobinServiceLocator onlyInstance;
|
||||
|
||||
private String initial_context_factory;
|
||||
private String user;
|
||||
private String password;
|
||||
//indirizzi dei nodi del cluster
|
||||
private List server_address;
|
||||
//indice che mantiene lo stato dell'ultimo server chiamato all'interno del List server_address
|
||||
private int indexOfServerName;
|
||||
|
||||
private static Logger log = Logger.getLogger(ClusterRoundRobinServiceLocator.class.getName());
|
||||
|
||||
/**
|
||||
* il costruttore è privato perchè è un Singleton
|
||||
*/
|
||||
private ClusterRoundRobinServiceLocator(String contextFactory, String user,
|
||||
String pwd, String cluster_address) throws
|
||||
Exception {
|
||||
|
||||
if (!checkParameter(contextFactory, user, pwd, cluster_address)){
|
||||
log.error("Errore durante l'inizializzazione del componente. I parametri in ingresso "
|
||||
+ "non sono valorizzati corretamente");
|
||||
throw new Exception(
|
||||
"Errore durante l'inizializzazione del componente. I parametri in ingresso "
|
||||
+ "non sono valorizzati corretamente");
|
||||
}
|
||||
init(contextFactory, user, pwd, cluster_address);
|
||||
}
|
||||
|
||||
/**
|
||||
* ritorna l'unica istanza del ClusterRoundRobinServiceLocator
|
||||
* @return ClusterRoundRobinServiceLocator
|
||||
*/
|
||||
public static ClusterRoundRobinServiceLocator getInstance(String
|
||||
contextFactory, String user, String pwd, String cluster_address) throws
|
||||
Exception {
|
||||
if (onlyInstance == null)
|
||||
onlyInstance = new ClusterRoundRobinServiceLocator(contextFactory, user,
|
||||
pwd, cluster_address);
|
||||
return onlyInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* ritorna l'unica istanza del ClusterRoundRobinServiceLocator
|
||||
* invocato da un client esterno all'aplication server
|
||||
* @return ClusterRoundRobinServiceLocator
|
||||
*/
|
||||
public static ClusterRoundRobinServiceLocator getInstance(Properties env) throws
|
||||
Exception {
|
||||
if (onlyInstance == null)
|
||||
onlyInstance = new ClusterRoundRobinServiceLocator(env.getProperty(Context.INITIAL_CONTEXT_FACTORY), env.getProperty(Context.SECURITY_PRINCIPAL),
|
||||
Context.SECURITY_CREDENTIALS, env.getProperty(Context.PROVIDER_URL));
|
||||
return onlyInstance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ritorna l'home interface del TimerExecutorEJB secondo l'algoritmo RoundRobin
|
||||
* eliminando la server affinity del cluster BEA
|
||||
* @return Object : l'home interface del TimerExecutorEJB
|
||||
*/
|
||||
public synchronized java.lang.Object getRemoteEJB(String jndiName, Class homeClass) throws
|
||||
Exception {
|
||||
|
||||
Object home = null;
|
||||
for (int i = 0; i < server_address.size(); i++) {
|
||||
home = getEJBHome(getNextServerCall(), jndiName,homeClass);
|
||||
if (home != null)
|
||||
break;
|
||||
}
|
||||
|
||||
if (home == null)
|
||||
throw new Exception(
|
||||
"Impossibile recuperare l'istanza del componente " + jndiName);
|
||||
|
||||
return home;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* inizializza la classe con i dati per il reperimento del context
|
||||
*
|
||||
* @param contextFactory String
|
||||
* @param user String
|
||||
* @param pwd String
|
||||
* @param cluster_ad String
|
||||
* @param server_ads String[]
|
||||
*/
|
||||
private void init(String contextFactory, String user, String pwd,
|
||||
String cluster_ad) {
|
||||
|
||||
String address_prefix = "t3://";
|
||||
//init degli indirizzi dei nodi del cluster
|
||||
server_address = new ArrayList();
|
||||
StringTokenizer strTok = new StringTokenizer(cluster_ad, ",");
|
||||
int i = 0;
|
||||
while (strTok.hasMoreElements()) {
|
||||
if (i == 0)
|
||||
server_address.add(strTok.nextElement());
|
||||
else
|
||||
server_address.add(address_prefix + strTok.nextElement());
|
||||
i++;
|
||||
}
|
||||
|
||||
this.initial_context_factory = contextFactory;
|
||||
this.user = user;
|
||||
this.password = pwd;
|
||||
indexOfServerName = -1;
|
||||
log.info("Cluster configurato : " + server_address.toString());
|
||||
log.info("USER :" +user);
|
||||
log.info("PASSWORD :" +pwd);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Controlla che i parametri passati siano validi
|
||||
*
|
||||
* @param contextFactory String
|
||||
* @param user String
|
||||
* @param pwd String
|
||||
* @param cluster_ad String
|
||||
* @param server_ads String[]
|
||||
*/
|
||||
private boolean checkParameter(String contextFactory, String user, String pwd,
|
||||
String cluster_ad) {
|
||||
|
||||
if (contextFactory == null || user == null || pwd == null || cluster_ad == null)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il prossimo nodo su cui recuperare il servizio TimerExecutorEJB
|
||||
* @throws Exception
|
||||
*/
|
||||
private String getNextServerCall() throws Exception {
|
||||
indexOfServerName++;
|
||||
if (indexOfServerName >= server_address.size())
|
||||
indexOfServerName = 0;
|
||||
return ( (String) server_address.get(indexOfServerName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il contesto del nodo su cui richiamare il servizio EJB
|
||||
* @throws NamingException
|
||||
* @return Context
|
||||
*/
|
||||
private Context getServerContext(String url_provider) throws Exception {
|
||||
|
||||
Hashtable ht = new Hashtable();
|
||||
Context ctx = null;
|
||||
|
||||
ht.put(Context.INITIAL_CONTEXT_FACTORY, initial_context_factory);
|
||||
ht.put(Context.SECURITY_PRINCIPAL, user);
|
||||
ht.put(Context.SECURITY_CREDENTIALS, password);
|
||||
ht.put(Context.PROVIDER_URL, url_provider);
|
||||
ctx = new InitialContext(ht);
|
||||
|
||||
return ctx;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna l'home interface del TimerExecutorEJB
|
||||
* @param url_provider String
|
||||
* @return Object
|
||||
*/
|
||||
private Object getEJBHome(String url_provider, String jndiName,
|
||||
Class homeClass) {
|
||||
|
||||
Context ctx = null;
|
||||
Object obj = null;
|
||||
|
||||
try {
|
||||
log.info("server called : " + url_provider);
|
||||
ctx = getServerContext(url_provider);
|
||||
Object ref = ctx.lookup(jndiName);
|
||||
obj = PortableRemoteObject.narrow(ref, homeClass);
|
||||
log.debug("EJBHome Ottenuta");
|
||||
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.error(
|
||||
"ECCEZIONE durante il reperimento dell'istanza del EJB: " + jndiName +
|
||||
" sul nodo : " + url_provider);
|
||||
log.error(ex);
|
||||
System.out.println("ATTENZIONE Il nodo " + url_provider + " potrebbe NON essere attivo!");
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (ctx != null) {
|
||||
ctx.close();
|
||||
}
|
||||
}
|
||||
catch (NamingException ex) {
|
||||
log.error("InitialContext già chiuso");
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package it.valueteam.crontab.utility;
|
||||
|
||||
import it.valueteam.crontab.processexecutor.utility.ProcessResources;
|
||||
import org.apache.log4j.*;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.rmi.PortableRemoteObject;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
|
||||
public class ClusterServiceLocator {
|
||||
|
||||
private String icf = null;
|
||||
//pattern layout per il console appender
|
||||
private static String PATTERN_LOGGER = "[THREAD %t] - %d{DATE} - [LINE %L] - [ %-5p] - %m %n";
|
||||
|
||||
private static Logger log = Logger.getLogger(ClusterServiceLocator.class.getName());
|
||||
|
||||
/**
|
||||
* Questo metodo verra' invocato dall'esterno
|
||||
*
|
||||
* @param jmxConnectionEnv
|
||||
*/
|
||||
public ClusterServiceLocator(Properties jmxConnectionEnv) {
|
||||
checkLogger();
|
||||
if (jmxConnectionEnv == null) {
|
||||
jmxConnectionEnv = new Properties();
|
||||
jmxConnectionEnv.put(Context.PROVIDER_URL, ProcessResources.getWLServerUrl());
|
||||
jmxConnectionEnv.put(Context.INITIAL_CONTEXT_FACTORY, ProcessResources.getWLServerContextFactory());
|
||||
jmxConnectionEnv.put(Context.SECURITY_PRINCIPAL, ProcessResources.getWLServerConnectionUser());
|
||||
jmxConnectionEnv.put(Context.SECURITY_CREDENTIALS, ProcessResources.getWLServerConnectionPwd());
|
||||
}
|
||||
|
||||
this.icf = jmxConnectionEnv.getProperty(Context.INITIAL_CONTEXT_FACTORY);
|
||||
}
|
||||
|
||||
public java.lang.Object getRemoteEJB(String jndiName, Class homeClass) throws Exception {
|
||||
Object home = getEJBHome(ProcessResources.getWLServerUrl(), jndiName, homeClass);
|
||||
|
||||
if (home == null) {
|
||||
throw new Exception("Impossibile recuperare l'istanza del componente " + jndiName);
|
||||
}
|
||||
return home;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna l'home interface del TimerExecutorEJB
|
||||
*
|
||||
* @param url_provider String
|
||||
* @return Object
|
||||
*/
|
||||
private Object getEJBHome(String url_provider, String jndiName, Class homeClass) {
|
||||
Context ctx = null;
|
||||
Object obj = null;
|
||||
|
||||
try {
|
||||
log.info("server called : " + url_provider + " with jndiName: " + jndiName);
|
||||
ctx = getServerContext(url_provider);
|
||||
Object ref = ctx.lookup(jndiName);
|
||||
obj = PortableRemoteObject.narrow(ref, homeClass);
|
||||
log.debug("EJBHome Ottenuta ["+obj+"]");
|
||||
log.info("##############################");
|
||||
} catch (Exception ex) {
|
||||
log.error("ECCEZIONE durante il reperimento dell'istanza del EJB: " + jndiName + " sul nodo : " + url_provider);
|
||||
log.error(ex);
|
||||
System.out.println("ATTENZIONE Il nodo " + url_provider + " potrebbe NON essere attivo!");
|
||||
} finally {
|
||||
try {
|
||||
if (ctx != null) {
|
||||
ctx.close();
|
||||
}
|
||||
} catch (NamingException ex) {
|
||||
log.error("InitialContext gia' chiuso");
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il contesto del nodo su cui richiamare il servizio EJB
|
||||
*
|
||||
* @return Context
|
||||
* @throws NamingException
|
||||
*/
|
||||
private Context getServerContext(String url_provider) throws Exception {
|
||||
Hashtable ht = new Hashtable();
|
||||
Context ctx;
|
||||
if (url_provider == null) {
|
||||
ctx = new InitialContext();
|
||||
} else {
|
||||
if (icf != null) {
|
||||
ht.put(Context.INITIAL_CONTEXT_FACTORY, icf);
|
||||
}
|
||||
|
||||
ht.put(Context.PROVIDER_URL, url_provider);
|
||||
ctx = new InitialContext(ht);
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Questo metodo controlla se esiste il logger per questa classe poiche' se
|
||||
* il processo parte da fuori il logger non e' configurato. Se non esiste
|
||||
* crea il logger sara' un ConsoleAppender per scrivere sul log del server
|
||||
*/
|
||||
private void checkLogger() {
|
||||
if (!log.getAllAppenders().hasMoreElements()) {
|
||||
Layout lay = new PatternLayout(PATTERN_LOGGER);
|
||||
Appender app = new ConsoleAppender(lay);
|
||||
log.addAppender(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package it.valueteam.crontab.utility;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class EventTime
|
||||
implements Serializable {
|
||||
public EventTime(Date d) {
|
||||
this.cal = new GregorianCalendar();
|
||||
this.cal.setTime(d);
|
||||
}
|
||||
|
||||
public EventTime(long timeInMillis) {
|
||||
this.cal = new GregorianCalendar();
|
||||
this.cal.setTime(new Date(timeInMillis));
|
||||
}
|
||||
|
||||
public EventTime(Calendar cal) {
|
||||
this.cal = new GregorianCalendar();
|
||||
this.cal.setTime(cal.getTime());
|
||||
}
|
||||
|
||||
public EventTime() {
|
||||
this.cal = new GregorianCalendar();
|
||||
}
|
||||
|
||||
public EventTime(int year, int mounth, int date) {
|
||||
this.cal = new GregorianCalendar();
|
||||
this.cal.set(year, mounth, date);
|
||||
}
|
||||
|
||||
public EventTime(int hour, int minute, int second, int milli) {
|
||||
this.cal = new GregorianCalendar();
|
||||
this.cal.set(Calendar.HOUR_OF_DAY, hour);
|
||||
this.cal.set(Calendar.MINUTE, minute);
|
||||
this.cal.set(Calendar.SECOND, second);
|
||||
}
|
||||
|
||||
public EventTime(EventTime evt) {
|
||||
this.cal = new GregorianCalendar();
|
||||
this.cal.setTime(evt.getTime());
|
||||
}
|
||||
|
||||
public void approxToMinute() {
|
||||
this.cal.set(Calendar.SECOND, 0);
|
||||
this.cal.set(Calendar.MILLISECOND, 0);
|
||||
}
|
||||
|
||||
public boolean before(EventTime evt) {
|
||||
return this.cal.before(evt.cal);
|
||||
}
|
||||
|
||||
public boolean equals(EventTime evt) {
|
||||
return this.cal.equals(evt.cal);
|
||||
}
|
||||
|
||||
public boolean after(EventTime evt) {
|
||||
return this.cal.after(evt.cal);
|
||||
}
|
||||
|
||||
public static EventTime max(EventTime evt1, EventTime evt2) {
|
||||
long v1 = evt1.getTimeInMillis();
|
||||
long v2 = evt2.getTimeInMillis();
|
||||
|
||||
return (v1 < v2) ? evt2 : evt1;
|
||||
}
|
||||
|
||||
public static EventTime min(EventTime evt1, EventTime evt2) {
|
||||
long v1 = evt1.getTimeInMillis();
|
||||
long v2 = evt2.getTimeInMillis();
|
||||
|
||||
return (v1 < v2) ? evt1 : evt2;
|
||||
}
|
||||
|
||||
public EventTime getRelEvent(int field, int value) {
|
||||
EventTime newEvt = new EventTime(this);
|
||||
newEvt.set(field, value);
|
||||
return newEvt;
|
||||
}
|
||||
|
||||
public EventTime getRelEvent(int hour, int minute, int second, int millis) {
|
||||
EventTime newEvt = new EventTime(this);
|
||||
newEvt.set(Calendar.HOUR_OF_DAY, hour);
|
||||
newEvt.set(Calendar.MINUTE, minute);
|
||||
newEvt.set(Calendar.SECOND, second);
|
||||
newEvt.set(Calendar.MILLISECOND, millis);
|
||||
return newEvt;
|
||||
}
|
||||
|
||||
public EventTime getRelEvent(int year, int month, int date) {
|
||||
EventTime newEvt = new EventTime(this);
|
||||
newEvt.set(Calendar.YEAR, year);
|
||||
newEvt.set(Calendar.MONTH, month);
|
||||
newEvt.set(Calendar.DATE, date);
|
||||
return newEvt;
|
||||
}
|
||||
|
||||
public EventTime getAdded(int field, int value) {
|
||||
EventTime evt = new EventTime(this);
|
||||
evt.cal.add(field, value);
|
||||
return evt;
|
||||
}
|
||||
|
||||
public void add(int field, int value) {
|
||||
this.cal.add(field, value);
|
||||
}
|
||||
|
||||
public void set(int field, int value) {
|
||||
this.cal.set(field, value);
|
||||
}
|
||||
|
||||
public static Iterator iterator(EventTime min, EventTime max, int field,
|
||||
int step) {
|
||||
return new EventTimeIterator(min, max, field, step);
|
||||
}
|
||||
|
||||
public int get(int field) {
|
||||
return this.cal.get(field);
|
||||
}
|
||||
|
||||
public long getTimeInMillis() {
|
||||
return this.cal.getTime().getTime();
|
||||
}
|
||||
|
||||
public void truncAtMinute() {
|
||||
this.cal.set(Calendar.SECOND, 0);
|
||||
this.cal.set(Calendar.MILLISECOND, 0);
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return this.cal.getTime();
|
||||
}
|
||||
|
||||
protected static class EventTimeIterator
|
||||
implements Iterator {
|
||||
private final EventTime min;
|
||||
private final EventTime max;
|
||||
private EventTime cursor = null;
|
||||
private final int step;
|
||||
private final int field;
|
||||
|
||||
public EventTimeIterator(final EventTime min, final EventTime max,
|
||||
final int field, final int step) {
|
||||
this.cursor = new EventTime(min);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.field = field;
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
if (cursor == null)return false;
|
||||
return cursor.before(max);
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Object next() {
|
||||
if (cursor == null)return null;
|
||||
EventTime res = new EventTime(cursor.cal);
|
||||
cursor.add(field, step);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
private GregorianCalendar cal = null;
|
||||
|
||||
/**
|
||||
* Metodo per aggiungere giorni solari alla data passata in input (formato yyyy-MM-dd)
|
||||
* @param inputDate
|
||||
* @param numGiorni
|
||||
* @return
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
public static java.util.Date aggiungiGiorniSolari(java.util.Date data,
|
||||
int numGiorni) throws Exception {
|
||||
try {
|
||||
|
||||
//Impostazione del timezone
|
||||
TimeZone tz = TimeZone.getTimeZone("Europe/Rome");
|
||||
Calendar calendar = new GregorianCalendar(tz);
|
||||
|
||||
//Calendario impostato alla data in input
|
||||
calendar.setTime(data);
|
||||
//Giorni aggiunti
|
||||
calendar.add(calendar.DAY_OF_MONTH, numGiorni);
|
||||
|
||||
// System.out.println("DATA : " + calendar.getTime());
|
||||
|
||||
return calendar.getTime();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,489 @@
|
||||
package it.valueteam.crontab.utility.cluster;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.*;
|
||||
import javax.naming.*;
|
||||
import weblogic.management.*;
|
||||
import mnp.crontab.utility.Resources;
|
||||
import weblogic.jndi.WLContext;
|
||||
import javax.management.NotificationListener;
|
||||
import javax.management.Notification;
|
||||
import javax.management.ListenerNotFoundException;
|
||||
import org.apache.log4j.Logger;
|
||||
/**
|
||||
* <p>Title: MNP CRONTAB</p>
|
||||
* <p>Description: Classe che gestisce lo stato del nodo Master/Slave</p>
|
||||
* <p>Copyright: Copyright (c) 2005</p>
|
||||
* <p>Company: ValueTeam - TeleAp</p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class MasterIdentificator implements NotificationListener{
|
||||
public static final int INITIAL_STATE = MasterIdentificatorNotificationListenerIF.STATE_SHUTDOWN;
|
||||
//stato interno
|
||||
// BISOGNA ACCEDERCI CON I GET E SET
|
||||
private int state = INITIAL_STATE;
|
||||
|
||||
private ArrayList listaListerner = new ArrayList();
|
||||
|
||||
private static MasterIdentificator onlyInstance = null;
|
||||
|
||||
//di default posso diventare master
|
||||
private boolean mnp_forever_slave = false;
|
||||
|
||||
//Nome dell'oggetto MasterIdentificatorInfo sul JNDI
|
||||
private static final String MASTER_TOKEN_JNDI_NAME = "MasterToken";
|
||||
|
||||
//proprietà sullo start del server
|
||||
private static String SERVER_URL =System.getProperty("server_url","");
|
||||
private static String SERVER_NAME =System.getProperty("weblogic.Name","");
|
||||
//nome delle property dell'hashMap contenete le info sul nodo master
|
||||
private static final String HASH_NAME_SERVER_URL="SERVER_URL";
|
||||
private static final String HASH_NAME_SERVER_NAME="SERVER_NAME";
|
||||
|
||||
//istanza del Timer per la notifica del checkMaster
|
||||
private weblogic.management.timer.Timer timer = null;
|
||||
|
||||
private static Logger log = Logger.getLogger(MasterIdentificator.class.getName());
|
||||
|
||||
private MasterIdentificator() {
|
||||
//per sicurezza e altro controlliamo la properties si sistema
|
||||
// per attivare o no il nodo a essere master
|
||||
String sMnp_forever_slave = System.getProperty("mnp_forever_slave","false");
|
||||
if (sMnp_forever_slave.equalsIgnoreCase("true")) {
|
||||
mnp_forever_slave = true;
|
||||
log.info("MasterIdentificator mnp_forever_slave ATTIVATO");
|
||||
}
|
||||
else
|
||||
mnp_forever_slave = false;
|
||||
//fine gestione di sicurezza
|
||||
}
|
||||
|
||||
public static MasterIdentificator getInstance() {
|
||||
if (onlyInstance==null) {
|
||||
synchronized(MasterIdentificator.class) {
|
||||
if (onlyInstance==null) {
|
||||
onlyInstance = new MasterIdentificator();
|
||||
}
|
||||
}
|
||||
}
|
||||
return onlyInstance;
|
||||
}
|
||||
|
||||
public void init(boolean defaultMaster) throws Exception{
|
||||
log.info("init() MasterIdentificator called ,server " +SERVER_NAME);
|
||||
log.info("state : " + state +" ,server " +SERVER_NAME);
|
||||
log.info(defaultMaster?"I am default Master":"I am temporarily Slave ,server " +SERVER_NAME);
|
||||
setState(MasterIdentificatorNotificationListenerIF.STATE_SLAVE);
|
||||
//per adesso chiamo direttamente il il checkmaster che setta lo stato a Master
|
||||
//poi ci sarà il Timer;
|
||||
try {
|
||||
//la proprietà defaultMaster è stata inserita perchè potrebbe capitare
|
||||
//ch tutte e due le istanze provino a fare il bind del MasterToken
|
||||
//contemporaneamente e che quindi non si abbia il tempo di propagare sul
|
||||
//cluster il bind di tale oggetto, in questo caso tutti e due sarebbero master,
|
||||
//il che non è bello!
|
||||
if(defaultMaster){
|
||||
checkMaster();
|
||||
}else{
|
||||
initTimerMBean();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.error("Errore durante il checkMaster ,server " +SERVER_NAME);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
try {
|
||||
setState(MasterIdentificatorNotificationListenerIF.STATE_SHUTDOWN);
|
||||
// se ho i timer attivi li distruggo
|
||||
destroyTimer();
|
||||
onlyInstance=null;
|
||||
}
|
||||
catch (Exception ex1) {
|
||||
ex1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna l'indirizzo del nodo master
|
||||
* @throws Exception
|
||||
* @return String
|
||||
*/
|
||||
public String getMasterNodeUrl() throws Exception {
|
||||
HashMap mt = getMasterToken();
|
||||
return (String) mt.get(HASH_NAME_SERVER_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il nome del nodo server bea
|
||||
* @throws Exception
|
||||
* @return String
|
||||
*/
|
||||
public String getMasterNodeName() throws Exception {
|
||||
HashMap mt = getMasterToken();
|
||||
return (String) mt.get(HASH_NAME_SERVER_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna l'MBeanServer del nodo master
|
||||
* @throws Exception
|
||||
* @return RemoteMBeanServer
|
||||
*/
|
||||
public RemoteMBeanServer getMasterMBeanServer() throws Exception {
|
||||
log.info("getMasterMBeanServer() called");
|
||||
HashMap mt = getMasterToken();
|
||||
log.info("MASTER TOKEN : " + mt.toString());
|
||||
MBeanHome home = Helper.getMBeanHome(Resources.getUSER_MBEAN(),
|
||||
Resources.getPASSWORD_MBEAN(),
|
||||
(String) mt.get(HASH_NAME_SERVER_URL),
|
||||
(String) mt.get(HASH_NAME_SERVER_NAME));
|
||||
return home.getMBeanServer();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ritorna lo stato corrente
|
||||
* @return int
|
||||
*/
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiunge un nuovo listener alla lista degli oggetti a cui notificare il cambiamento di stato
|
||||
* @param minl MasterIdentificatorNotificationListenerIF
|
||||
* @throws Exception
|
||||
*/
|
||||
public void addNotificationListener(MasterIdentificatorNotificationListenerIF minl) throws Exception{
|
||||
if (minl != null) {
|
||||
listaListerner.add(minl);
|
||||
}
|
||||
else
|
||||
throw new Exception("MasterIdentificator:Listerner NULL!!!");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica se posso diventare Master altrimenti sono SLAVE
|
||||
* @throws Exception
|
||||
*/
|
||||
private synchronized void checkMaster() throws Exception{
|
||||
int newState = state;
|
||||
log.info("checkMaster() called ,server " +SERVER_NAME);
|
||||
if (!mnp_forever_slave){
|
||||
try {
|
||||
HashMap mtJndi = getMasterToken();
|
||||
log.info("MASTER TOKEN : " + mtJndi.toString());
|
||||
//inizializzo i timer nel caso in cui non siano attivi
|
||||
//per il checkMaster
|
||||
initTimerMBean();
|
||||
}
|
||||
catch (NamingException ex1) {
|
||||
//mastertoken non trovato
|
||||
//provo a diventare MASTER
|
||||
try {
|
||||
bindMasterToken();
|
||||
log.info("Binding del MasterToken effettuato ,server " +
|
||||
SERVER_NAME);
|
||||
newState = MasterIdentificatorNotificationListenerIF.STATE_MASTER;
|
||||
//distruggo i timer per il checkMaster
|
||||
destroyTimer();
|
||||
}
|
||||
catch (NamingException ex) {
|
||||
//inizializzo i timer nel caso non riesca a fare il bind
|
||||
initTimerMBean();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
newState = MasterIdentificatorNotificationListenerIF.STATE_SLAVE;
|
||||
log.info("MasterIdentificator mnp_forever_slave ATTIVATO");
|
||||
}
|
||||
// fine parte da rifare
|
||||
if (newState != state) {
|
||||
log.info("MasterIdentificator:Nuovo stato:"+newState+" da vecchio stato:"+state +",server " +SERVER_NAME);
|
||||
setState(newState);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifica il cambiamento di stato ai listener, attualmente il CrontabManager
|
||||
* e l'MNPController
|
||||
* @throws Exception
|
||||
*/
|
||||
private synchronized void notificaCambiamentoStato() throws Exception{
|
||||
MasterIdentificatorNotificationListenerIF minl = null;
|
||||
for (Iterator iter = listaListerner.iterator(); iter.hasNext(); ) {
|
||||
minl = (MasterIdentificatorNotificationListenerIF)iter.next();
|
||||
try {
|
||||
log.info("notificaCambiamentoStato state "+state +" to : " +minl.getClass().getName()+" ,server " + SERVER_NAME);
|
||||
minl.handleMasterNotificationChange(state);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
log.error("MasterIdentificator:Impossibile notificare a :"+minl.getClass().getName()+" stato:"+state +",server " + SERVER_NAME);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setta lo stato nel masterIdentificator e notifica il cambiamento di stato
|
||||
* @param state int
|
||||
* @throws Exception
|
||||
*/
|
||||
private synchronized void setState(int state) throws Exception{
|
||||
int oldState = this.state;
|
||||
try {
|
||||
this.state = state;
|
||||
if (oldState != state) {
|
||||
// se ho eccezione durante la notifica del cambiamento di stato da MASTER ad un altro
|
||||
//posso trovarmi un una situazione in cui ho alcuni servizi attivi e alcuni stoppati
|
||||
//quindi prima tento di notificare e poi faccio l'unbind
|
||||
//comunque è una situazione anomala
|
||||
notificaCambiamentoStato();
|
||||
if (oldState == MasterIdentificatorNotificationListenerIF.STATE_MASTER) {
|
||||
unbindMasterToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.error("!!!!!!!!!!!! ATTENZIONE STATO DEL NODO INCONSISTENTE !!!!!!!!!!!!!!!!!!!!");
|
||||
log.error("Passaggio da stato:"+oldState+" a state:"+state);
|
||||
state = MasterIdentificatorNotificationListenerIF.STATE_UNKNOW;
|
||||
try{ //TO DO verificare se deve riprovare a fare unbind
|
||||
notificaCambiamentoStato();
|
||||
//può darsi che adesso riesco a notificare a tutti lo stato STATE_UNKNOW
|
||||
// e che tutti i servizi vengano stoppati quindi provo a fare l'unbind
|
||||
//perchè prima non l'ho fatto adto che l'eccezione mi ha fatto saltare
|
||||
//dentro il blocco catch
|
||||
unbindMasterToken();
|
||||
}catch(Exception ex1){
|
||||
log.error("Errore durante la notifica dello stato : STATE_UNKNOW");
|
||||
ex1.printStackTrace();
|
||||
}
|
||||
destroyTimer();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna l'oggetto contenete le informazioni sul nodo master
|
||||
* @throws NamingException
|
||||
* @return HashMap
|
||||
*/
|
||||
|
||||
private HashMap getMasterToken() throws NamingException {
|
||||
HashMap mii = null;
|
||||
try {
|
||||
InitialContext ctx = new InitialContext();
|
||||
mii = (HashMap) ctx.lookup(MASTER_TOKEN_JNDI_NAME);
|
||||
}
|
||||
catch (NamingException ex) {
|
||||
log.warn("Impossibile reperire l'istanza del MasterToken sul Cluster Wide JNDI");
|
||||
mii = getSingleInstanceMasterToken();
|
||||
}
|
||||
return mii;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna l'oggetto contenete le informazioni sul nodo master
|
||||
* andondolo a cercare sui singoli nodi
|
||||
* @throws NamingException
|
||||
* @return HashMap
|
||||
*/
|
||||
|
||||
private HashMap getSingleInstanceMasterToken() throws NamingException {
|
||||
HashMap mii = null;
|
||||
boolean trovato = false;
|
||||
try {
|
||||
String[] addList = Resources.getMasterIdentificatorCheckList();
|
||||
for (int i = 0; i < addList.length; i++) {
|
||||
String address = addList[i];
|
||||
Hashtable ht = new Hashtable();
|
||||
ht.put(WLContext.PROVIDER_URL, address);
|
||||
InitialContext ctx = null;
|
||||
try {
|
||||
ctx = new InitialContext(ht);
|
||||
}
|
||||
catch (NamingException ex1) {
|
||||
log.info("Impossibile creare contesto per address:" + address);
|
||||
ctx = null;
|
||||
}
|
||||
if (ctx != null) {
|
||||
try {
|
||||
mii = (HashMap) ctx.lookup(MASTER_TOKEN_JNDI_NAME);
|
||||
trovato = true;
|
||||
}
|
||||
catch (NamingException ex1) {
|
||||
log.warn("Impossibile trovare MasterToken per address:" +
|
||||
address);
|
||||
}
|
||||
}
|
||||
if (ctx != null) {
|
||||
try {
|
||||
ctx.close();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
if (trovato)
|
||||
break;
|
||||
}
|
||||
if (!trovato)
|
||||
throw new NamingException();
|
||||
}
|
||||
catch (NamingException ex) {
|
||||
log.warn(
|
||||
"Impossibile reperire l'istanza del MasterToken sul JNDI delle singole istanze");
|
||||
throw ex;
|
||||
}
|
||||
return mii;
|
||||
}
|
||||
|
||||
/*/**
|
||||
* Registra il MasterIdentificatorInfo sul JNDI
|
||||
* @param mii MasterIdentificatorInfo
|
||||
*/
|
||||
private void bindMasterToken() throws Exception {
|
||||
InitialContext ctx =null;
|
||||
try{
|
||||
Hashtable ht = new Hashtable();
|
||||
//MasterToken
|
||||
HashMap mt = new HashMap();
|
||||
mt.put(HASH_NAME_SERVER_URL,SERVER_URL);
|
||||
mt.put(HASH_NAME_SERVER_NAME,SERVER_NAME);
|
||||
//turn on binding replication
|
||||
ht.put(WLContext.REPLICATE_BINDINGS, "true");
|
||||
ctx = new InitialContext(ht);
|
||||
ctx.bind(MASTER_TOKEN_JNDI_NAME,mt);
|
||||
}catch(NamingException ex){
|
||||
log.info("Impossibile registrare l'istanza del MasterToken sul JNDI. Probabile nodo Master attivo ");
|
||||
try{
|
||||
HashMap mtJndi = getMasterToken();
|
||||
log.info("MASTER TOKEN : " + mtJndi.toString());
|
||||
}catch(NamingException nex){
|
||||
log.error("Nessun nodo master trovato");
|
||||
}
|
||||
throw ex;
|
||||
}finally{
|
||||
try{
|
||||
if (ctx != null)
|
||||
ctx.close();
|
||||
}catch(Exception ex){
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Deregistra il MasterToken dal JNDI quando da stato Master
|
||||
* passo ad un altro stato
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
private void unbindMasterToken() {
|
||||
InitialContext ctx =null;
|
||||
try{
|
||||
ctx = new InitialContext();
|
||||
ctx.unbind(MASTER_TOKEN_JNDI_NAME);
|
||||
log.info("Unbinding MasterToken effettuato con successo, server " + SERVER_NAME);
|
||||
}catch(NamingException ex){
|
||||
log.error("FATAL ERROR !!");
|
||||
log.error("FATAL ERROR Impossibile deregistrare l'istanza del MasterToken sul JNDI ,server " +SERVER_NAME);
|
||||
}finally{
|
||||
try{
|
||||
if (ctx != null)
|
||||
ctx.close();
|
||||
}catch(Exception ex){
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* handleNotification
|
||||
* Fa il check per diventare master
|
||||
* @param notification Notification
|
||||
* @param object Object
|
||||
*/
|
||||
public void handleNotification(Notification notification, Object object) {
|
||||
try{
|
||||
checkMaster();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/******************** MACRO GESTIONE TIMER ******************/
|
||||
|
||||
private synchronized void initTimerMBean() {
|
||||
if (timer == null) {
|
||||
log.info("initTimerMBean() called ,server " +SERVER_NAME);
|
||||
// Instantiating the Timer MBean
|
||||
/*non usiamo l'implementazione java standard ma l'estensione di weblogic
|
||||
in modo che i thread siano quelli controllati dall'as
|
||||
*/
|
||||
//intervallo di tempo per il checkMaster
|
||||
long masterIdChkInterval = Resources.getMasterIdentificator_Timer_Check();
|
||||
Date checkMasterStartDate = new Date(new Date().getTime()+masterIdChkInterval);
|
||||
timer = new weblogic.management.timer.Timer();
|
||||
// Registering this class as a listener
|
||||
timer.addNotificationListener(this, null, null);
|
||||
// Start Timer MBean
|
||||
timer.start();
|
||||
//aggiungo la notifica da ripetere indefinitivamente
|
||||
Integer idNot = timer.addNotification(null, null, null,
|
||||
checkMasterStartDate,
|
||||
masterIdChkInterval);
|
||||
log.info("Attivazione timer, server " +SERVER_NAME);
|
||||
}
|
||||
else
|
||||
log.info("timer gia' attivato, server " +SERVER_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* interfaccia per la distruzione/stop dei Timer interni
|
||||
* l'implementazione generica va bene x tutti
|
||||
*/
|
||||
private synchronized void destroyTimer() throws Exception {
|
||||
if (timer!=null) {
|
||||
timer.stop();
|
||||
log.info("stop del timer eseguito ,server " +SERVER_NAME);
|
||||
timer.removeAllNotifications();
|
||||
log.info("rimozione di tutte le schedulazioni eseguita, server " +SERVER_NAME);
|
||||
try {
|
||||
timer.removeNotificationListener(this);
|
||||
log.info("rimozione dell'ascolto sul timer ,server " +SERVER_NAME);
|
||||
}
|
||||
catch (ListenerNotFoundException ex) {
|
||||
log.error("Eccezione in destroyTimer: " + this.getClass().getName() +",server " +SERVER_NAME);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
timer=null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* finalize
|
||||
*
|
||||
* @throws Throwable
|
||||
* @todo Implement this java.lang.Object method
|
||||
*/
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
log.info("finalize called, server " + SERVER_NAME);
|
||||
System.out.println("finalize MasterIdentificator");
|
||||
}
|
||||
|
||||
/******************** FINE MACRO GESTIONE TIMER ******************/
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package it.valueteam.crontab.utility.cluster;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Title: progetto cluster applicativo fase 1 step 1</p>
|
||||
* <p>Description: Interfaccia utilizzata per la notifica
|
||||
* di cambiamento del nodo master </p>
|
||||
* <p>Copyright: Copyright (c) 2006</p>
|
||||
* <p>Company: </p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface MasterIdentificatorNotificationListenerIF {
|
||||
|
||||
public static final int STATE_UNKNOW = -1;
|
||||
public static final int STATE_SHUTDOWN = 0;
|
||||
public static final int STATE_SLAVE = 1;
|
||||
public static final int STATE_MASTER = 2;
|
||||
|
||||
/**
|
||||
* Metodo richiamato dal componente MasterIdentificator
|
||||
* per notificare al MNPController il cambiamento del nodo master
|
||||
* sul cluster, in modo da inizializzare i timer
|
||||
* @param state int
|
||||
* @throws Exception
|
||||
*/
|
||||
public void handleMasterNotificationChange(int state) throws Exception;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package it.valueteam.crontab.utility.cluster;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Title: MasterIdentificatorInfo</p>
|
||||
* <p>Description: Classe contenente le informazioni sul nodo master
|
||||
* Questo oggetto viene messo sul JNDI del cluster cosicchè tutti
|
||||
* possano accedere a tali informazioni</p>
|
||||
* <p>Copyright: Copyright (c) 05-11-2007</p>
|
||||
* <p>Company: </p>
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
public class MasterToken implements Serializable{
|
||||
|
||||
private String masterNodeUrl;
|
||||
private String masterNodeName;
|
||||
public final static long serialVersionUID = 42L;
|
||||
|
||||
public MasterToken() {
|
||||
}
|
||||
|
||||
public MasterToken(String mNodeUrl,String mNodeName) {
|
||||
this.masterNodeName=mNodeName;
|
||||
this.masterNodeUrl=mNodeUrl;
|
||||
}
|
||||
public String getMasterNodeName() {
|
||||
return masterNodeName;
|
||||
}
|
||||
public String getMasterNodeUrl() {
|
||||
return masterNodeUrl;
|
||||
}
|
||||
public void setMasterNodeName(String masterNodeName) {
|
||||
this.masterNodeName = masterNodeName;
|
||||
}
|
||||
public void setMasterNodeUrl(String masterNodeUrl) {
|
||||
this.masterNodeUrl = masterNodeUrl;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(masterNodeUrl).append(", ").append(masterNodeName);
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* hashCode
|
||||
*
|
||||
* @return int
|
||||
* @todo Implement this java.lang.Object method
|
||||
*/
|
||||
public int hashCode() {
|
||||
return toString().hashCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package it.valueteam.crontab.utility.ejbrouter;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class ServerRuntimeInfo implements
|
||||
Serializable {
|
||||
private String serverName;
|
||||
private long freeMemory;
|
||||
private String serverAddress;
|
||||
private int pendingRequest;
|
||||
private int idleThread;
|
||||
|
||||
|
||||
public String getServerAddress() {
|
||||
return serverAddress;
|
||||
}
|
||||
|
||||
public long getFreeMemory() {
|
||||
return freeMemory;
|
||||
}
|
||||
|
||||
public ServerRuntimeInfo(String serverName,String serverAddress, long freeMemory, int pendingRequest, int idleThread) {
|
||||
this.serverAddress = serverAddress;
|
||||
this.freeMemory = freeMemory;
|
||||
this.pendingRequest= pendingRequest;
|
||||
this.idleThread=idleThread;
|
||||
this.serverName=serverName;
|
||||
}
|
||||
|
||||
|
||||
public int getPendingRequest() {
|
||||
return pendingRequest;
|
||||
}
|
||||
public int getIdleThread() {
|
||||
return idleThread;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
return buffer.append("SERVER : ").append(
|
||||
serverName).append(", ").append(serverAddress).append(", ").append(
|
||||
"FREE MEMORY : ").append(freeMemory).append(", ").append(
|
||||
"IDLE THREAD : ").append(idleThread).append(", ").append("PENDING REQUEST : ").append(
|
||||
pendingRequest).toString();
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
return serverName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
import it.valueteam.logging.Azione;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import mnp.crontab.command.CommandIF;
|
||||
|
||||
public class AbstractCommand implements CommandIF {
|
||||
|
||||
private Azione actionLog=null;
|
||||
|
||||
public String execute(HttpServletRequest request, HttpServletResponse res) throws Exception{
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setActionLog(Azione actionLog) {
|
||||
this.actionLog = actionLog;
|
||||
}
|
||||
|
||||
public Azione getActionLog() {
|
||||
return actionLog;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
*
|
||||
* <p>Description: Mapping tra le azioni di logging e la loro descrizione</p>
|
||||
*
|
||||
* <p>Copyright: Copyright (c) 2006</p>
|
||||
*
|
||||
* <p>Company: ValueTeam</p>
|
||||
*
|
||||
* @author Mario Giurlanda
|
||||
* @version 1.0 - Kit Ottobre 06
|
||||
* @version 1.1 - Kit Dicembre 06 - Inserite le azioni per il logging M2M
|
||||
* @version 1.2 - M.G. Extra Kit Dicembre 06 - Integrazione PCS - Eliminate le azioni di logging relative alle
|
||||
* funzionalità di gestione utente: DisabilitazioneUtente = 25 AbilitazioneUtente = 26 EliminazioneUtente = 27
|
||||
* NuovoUtente = 28 ModificaUtente = 29 AssociaFunzionalita = 30 DisassociaFunzionalita = 31 CambioPassword = 32
|
||||
*/
|
||||
public class ActionLogMapping {
|
||||
|
||||
public static int ArrestoTask = 1;
|
||||
public static int EsecuzioneTaskEmergenza = 2;
|
||||
public static int EsecuzioneNuovoTaskEmergenza = 3;
|
||||
public static int AbilitazioneSchedulatore = 4;
|
||||
public static int DisabilitazioneSchedulatore = 5;
|
||||
public static int RestartSchedulatore = 6;
|
||||
public static int RicercaTaskGiornalieri = 7;
|
||||
public static int DisabilitaTask = 8;
|
||||
public static int AbilitaTask = 9;
|
||||
public static int EliminaTask = 10;
|
||||
public static int NuovoTask = 11;
|
||||
public static int ModificaTask = 12;
|
||||
public static int DisabilitaProcesso = 13;
|
||||
public static int AbilitaProcesso = 14;
|
||||
public static int EliminaProcesso = 15;
|
||||
public static int NuovoProcesso = 16;
|
||||
public static int ModificaProcesso = 17;
|
||||
public static int SalvataggioConfigurazione = 18;
|
||||
public static int RipristinoConfigurazione = 19;
|
||||
public static int DisabilitaGateway = 20;
|
||||
public static int AbilitaGateway = 21;
|
||||
public static int AbilitazioneSistemaInterno = 22;
|
||||
public static int SalvaDatiSistemaXML = 24;
|
||||
public static int RicercaRichieste = 33;
|
||||
public static int RicercaRichiesteDonor = 34;
|
||||
public static int RicercaRichiesteRecipient = 35;
|
||||
public static int RicercaRichiesteCessazione = 36;
|
||||
public static int RicercaRichiesteCessazioneVolontaria = 37;
|
||||
public static int RicercaRichiesteTerzaParte = 38;
|
||||
public static int AnnullaRichiesta = 39;
|
||||
public static int SbloccaRichiestaDonor = 40;
|
||||
public static int BloccaRichiestaDonor = 41;
|
||||
public static int DownloadReport = 42;
|
||||
public static int DownloadReportCrontab = 43;
|
||||
public static int EsecuzioneReport = 44;
|
||||
public static int AcquisizioneFileCanaleAlternativo = 45;
|
||||
public static int InviaFileCanaleAlternativo = 46;
|
||||
public static int RinviaFileCanaleAlternativo = 47;
|
||||
public static int CreaListaFileCanaleAlternativo = 48;
|
||||
public static int SimulazioneRichiestaMSS = 49;
|
||||
public static int StatoRichiesteDonor = 50;
|
||||
public static int StatoRichiesteRecipient = 51;
|
||||
public static int StatoRichiesteTerzaParte = 52;
|
||||
public static int Login = 53;
|
||||
public static int Logout = 54;
|
||||
public static int SbloccaRichiestaRecipient = 55;
|
||||
public static int BloccaRichiestaRecipient = 56;
|
||||
public static int AcquisizioneFileForzaturaPrevalidazione = 57;
|
||||
public static int AcquisizioneFileRecuperoFuoriStandard = 58;
|
||||
public static int RicezioneEsitiGISP = 59;
|
||||
public static int InvioEsitiGISP = 60;
|
||||
public static int InvioCessazioneEsitiGISP = 61;
|
||||
|
||||
//M2M
|
||||
public static int InvioFileXml = 1001;
|
||||
public static int RicezioneFileXml = 1002;
|
||||
public static int InvioNotificaInfobus = 1003;
|
||||
public static int RicezioneNotificaInfobus = 1004;
|
||||
public static int InvioFileSFTP = 1005;
|
||||
public static int NotificheRichiesteDonorDBCGO = 1006;
|
||||
public static int NotificheRichiesteRecipientDBCGO = 1007;
|
||||
public static int NotificheRichiestePortingDBCGO = 1008;
|
||||
public static int ModificaPercentualeBUDonor = 1009;
|
||||
public static int ModificaMovimentazioneRecipient = 1010;
|
||||
public static int ModificaPrioritaRichiesta = 1011;
|
||||
public static int NotificheRichiesteDonorTCDBCGO = 1012;
|
||||
public static int NotificheRichiesteRecipientTCDBCGO = 1013;
|
||||
public static int NotificheRichiesteDonorVirtualeDBCGO = 1014;
|
||||
public static int NotificheRichiesteRecipientVirtualeDBCGO = 1015;
|
||||
public static int NotificheRichiesteRecipientVirtualeMvno2MvnoDBCGO = 1016;
|
||||
public static int NotificheRichiesteDonorVirtTCDBCGO = 1017;
|
||||
public static int NotificheRichiesteRecipientVirtTCDBCGO = 1018;
|
||||
public static int NotificheRichiesteRecipientVirtM2MTCDBCGO = 1019;
|
||||
public static int VerificaCessazioneMSS = 1020;
|
||||
|
||||
//log security
|
||||
public static final String LOG_RESULT_CODE_OK = "OK";
|
||||
public static final String LOG_RESULT_CODE_KO = "KO";
|
||||
public static final int LOG_RESULT_CODE_DETAIL_OK = 0;
|
||||
public static final int LOG_RESULT_CODE_DETAIL_KO = -1;
|
||||
|
||||
//LOV
|
||||
public static final String LOV_LOG_ACTION = "LOG_ACTION";
|
||||
public static final String LOV_LOG_RETURN_CODE = "LOG_RETURN_CODE";
|
||||
|
||||
private ActionLogMapping() {};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
//
|
||||
// Classi di Variabili statiche per la numerazione dei Link
|
||||
// delle Jsp sviluppate
|
||||
|
||||
// FNC da 1....99 per ogni FUNZIONALITA'
|
||||
// indica una funzione di transito per la chiamata di un'altra Jsp
|
||||
|
||||
// CMD da 100...199 per ogni COMANDO
|
||||
// indica una funzione o comando per una chiamata di un metodo che accede a DB
|
||||
|
||||
|
||||
public class AmministrazioneCostants {
|
||||
|
||||
|
||||
public AmministrazioneCostants() {
|
||||
}
|
||||
|
||||
// Variabili globali
|
||||
|
||||
// Variabili valide per messaggistica CLIENT
|
||||
// Globali
|
||||
|
||||
|
||||
// VARIABILI PER AMMINISTRAZIONE GUI MNP
|
||||
public static final String OBJECT_LOGINBEAN_SESSION =
|
||||
"LoginBean";
|
||||
|
||||
public static final String OBJECT_MANAGER_SESSION =
|
||||
"SessionManager";
|
||||
|
||||
public static final String CMD_OPERAZIONE =
|
||||
"COMANDO OPERAZIONE";
|
||||
|
||||
|
||||
|
||||
// Variabili valide per oggetto INTERFACCE
|
||||
|
||||
public static final int FNC_LOGOUT = 1;
|
||||
public static final int FNC_CRONTAB = 3;
|
||||
public static final int FNC_APPLICATION_MANAGER = 4;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
//
|
||||
// Classi di Variabili statiche per la numerazione dei Link
|
||||
// delle Jsp sviluppate
|
||||
|
||||
// FNC da 1....99 per ogni FUNZIONALITA'
|
||||
// indica una funzione di transito per la chiamata di un'altra Jsp
|
||||
|
||||
// CMD da 100...199 per ogni COMANDO
|
||||
// indica una funzione o comando per una chiamata di un metodo che accede a DB
|
||||
import mnp.crontab.engine.mbean.*;
|
||||
import org.apache.log4j.*;
|
||||
|
||||
public class ApplicationManagerCostants {
|
||||
|
||||
private static Logger log = Logger.getLogger(ApplicationManagerCostants.class.
|
||||
getName());
|
||||
|
||||
public ApplicationManagerCostants() {
|
||||
}
|
||||
|
||||
// Variabili globali
|
||||
public static final String OBJECT_RESULT_BEAN = "resultBean";
|
||||
public static final String OBJECT_MANAGER_SESSION = "managerSession";
|
||||
public static final String OBJECT_SESSION_CCRM = "ccrmSession";
|
||||
public static final String OBJECT_SESSION_XML = "xmlSession";
|
||||
public static final String OBJECT_SESSION_SISTEMI = "SistemSession";
|
||||
public static final String CAMPO_ELEMENT_CHECKED = "elementoChecked";
|
||||
public static final String OBJECT_NOME_FILE= "objectName";
|
||||
public static final String SESSION_NOME_FILE= "objectNameSession";
|
||||
|
||||
public static final String XML_BINDING_NAME="Controller:name=XMLController";
|
||||
public static final String APPL_CONTROLLER_BINDING_NAME= "Controller:name=ApplicationController";
|
||||
public static final String SISTEMI_BINDING_NAME ="SistemiInterni:name=SistemiInterniController";
|
||||
|
||||
|
||||
// Variabili valide per messaggistica CLIENT
|
||||
// Globali
|
||||
|
||||
// TIPO FILE
|
||||
public static final String TIPO_FILE_ACK = "ACK";
|
||||
public static final String TIPO_FILE_NO_ACK = "NO_ACK";
|
||||
// Sistema CCRM
|
||||
public static final String MESSAGE_CONFIRM_UPDATE_XML = "APPLICATE TUTTE LE MODIFICHE AI VARI FILE XML";
|
||||
public static final String MESSAGE_CONFIRM_UPDATE_SISTEMI = "APPLICATE TUTTE LE MODIFICHE AI VARI SISTEMI INTERNI";
|
||||
|
||||
// Variabili valide per oggetto CCRMCommand
|
||||
|
||||
public static final int FNC_CONFIGURAZIONE_CCRM = 1;
|
||||
public static final int FNC_MODIFICA_FLUSSI_CCRM = 2;
|
||||
public static final int FNC_MODIFICA_SCHEDULAZIONE_CCRM = 3;
|
||||
public static final int FNC_BACK_CONFIGURAZIONE_CCRM = 4;
|
||||
|
||||
public static final int CMD_AGGIORNA_DATIFLUSSI_CCRM = 100;
|
||||
public static final int CMD_AGGIORNA_DATISISTEMA_CCRM = 101;
|
||||
public static final int CMD_ABILITA_SCHEDULAZIONE_CCRM = 102;
|
||||
public static final int CMD_DISABILITA_SCHEDULAZIONE_CCRM = 103;
|
||||
public static final int CMD_MODIFICA_SCHEDULAZIONE_CCRM = 104;
|
||||
public static final int CMD_APPLY_ALL_CCRM = 105;
|
||||
|
||||
// Variabili valide per oggetto XMLCommand
|
||||
|
||||
public static final int FNC_CONFIGURAZIONE_XML = 1;
|
||||
public static final int FNC_MODIFICA_FILE_XML = 2;
|
||||
public static final int FNC_MODIFICA_OPERATORE_XML = 3;
|
||||
public static final int FNC_MODIFICA_SCHEDULAZIONE_XML = 4;
|
||||
public static final int FNC_CONFIGURAZIONE_SISTEMI_INTERNI = 5;
|
||||
public static final int FNC_BACK_CONFIGURAZIONE_XML = 6;
|
||||
public static final int FNC_LISTA_FILE_ACK = 7;
|
||||
public static final int FNC_OPERATORE_ACK = 8;
|
||||
public static final int FNC_SCHEDULAZIONE_ACK = 9;
|
||||
public static final int FNC_BACK_XML=10;
|
||||
|
||||
public static final int FNC_LOGOUT_APPLICATION = 11;
|
||||
public static final int FNC_LOGOUT=12;
|
||||
public static final int FNC_MODIFICA_PRIORITA_XML=13;
|
||||
public static final int FNC_MODIFICA_PRIORITA_ACK_XML=14;
|
||||
public static final int FNC_MODIFICA_PRIORITA_XML_IN=15;
|
||||
|
||||
public static final int CMD_AGGIORNA_FILE_XML = 100;
|
||||
public static final int CMD_AGGIORNA_OPERATORE_XML = 101;
|
||||
public static final int CMD_AGGIORNA_SCHEDULAZIONE_XML = 102;
|
||||
public static final int CMD_APPLY_ALL_XML = 103;
|
||||
|
||||
public static final int CMD_APPLY_SISTEMI_INTERNI = 106;
|
||||
public static final int CMD_AGGIORNA_OPERATORE_ACK = 107;
|
||||
public static final int CMD_AGGIORNA_SCHEDULAZIONE_ACK = 108;
|
||||
public static final int CMD_AGGIORNA_PRIORITA_XML=109;
|
||||
public static final int CMD_AGGIORNA_PRIORITA_XML_IN=110;
|
||||
|
||||
//log security
|
||||
public static final String LOG_CLIENT_APP_NAME= "MNP-WEB";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import mnp.crontab.exception.*;
|
||||
|
||||
public class CommandFactory {
|
||||
|
||||
private static HashMap commandMap = new HashMap();
|
||||
|
||||
public static AbstractCommand getCommand(String commandName) throws CommandNotFoundException {
|
||||
AbstractCommand command = null;
|
||||
Class c = null;
|
||||
try {
|
||||
if (commandName != null) {
|
||||
if (commandMap.get(commandName) != null) {
|
||||
c = (Class)commandMap.get(commandName);
|
||||
} else {
|
||||
c = Class.forName(commandName);
|
||||
synchronized(commandMap) {
|
||||
commandMap.put(commandName, c);
|
||||
}
|
||||
}
|
||||
command = (AbstractCommand)c.newInstance();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Impossibile instanziare il comando associato alla request.....");
|
||||
throw new CommandNotFoundException();
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
import it.valueteam.logging.Azione;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
|
||||
//Command InterFace
|
||||
public interface CommandIF {
|
||||
|
||||
public String execute(HttpServletRequest req, HttpServletResponse res) throws Exception;
|
||||
|
||||
public Azione getActionLog();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP Project</p>
|
||||
* <p>Description: Progetto per Mobile Number Portability</p>
|
||||
* <p>Copyright: Copyright (c) 2002</p>
|
||||
* <p>Company: OW</p>
|
||||
* @author Gian Luca Paloni
|
||||
* @version 1.0
|
||||
*/
|
||||
import java.util.*;
|
||||
import mnp.crontab.utility.Resources;
|
||||
|
||||
public class CommandsDef {
|
||||
|
||||
private static HashMap mapCmd2JSP;
|
||||
|
||||
private static String dbcgoLoginUrl=Resources.getHTTP_LOGIN_DBCGO();
|
||||
|
||||
/// def. jsp
|
||||
public static final String LOGIN_DO = "SecurityInfoClient.do";
|
||||
public static final String LOGOUT_DO = "Logout.do";
|
||||
public static final String HOME_CRONTAB_DO = "HomeCrontab.do";
|
||||
public static final String PAGE_ESITO = "Index.do";
|
||||
public static final String LISTA_TASKS = "IndexTask.do";
|
||||
public static final String LISTA_PROCESS = "IndexProcess.do";
|
||||
public static final String INSERT_TASK = "InsertTask.do";
|
||||
public static final String LISTA_INTERVALLI = "ListaIntervalli.do";
|
||||
public static final String INSERT_INTERVALLO = "InsertIntervallo.do";
|
||||
public static final String PROCESSI_ASSOCIATI = "ProcessiAssociati.do";
|
||||
public static final String PROCESSI_DISPONIBILI = "ProcessiDisponibili.do";
|
||||
// C.P processi bloccanti
|
||||
public static final String PROCESSI_BLOCCANTI = "ProcessiBloccanti.do";
|
||||
public static final String PROCESSI_BLOCCATI_DISPONIBILI = "ProcessiBloccantiDisponibili.do";
|
||||
//
|
||||
public static final String SCHEDA_TASK = "SchedaTask.do";
|
||||
public static final String ATTIVITA_GIORNALIERA = "AttivitaGiornaliera.do";
|
||||
public static final String CONFIGURAZIONE_XML = "Configurazione.do";
|
||||
public static final String SCHEDA_PROCESSO = "SchedaProcesso.do";
|
||||
public static final String INSERT_PROCESSO = "InserimentoProcesso.do";
|
||||
public static final String GESTIONE_GATEWAY = "GestoneGateway.do";
|
||||
public static final String SESSIONE_INATTIVA = "SessioneInattiva.do";
|
||||
public static final String ERROR_DO = "Error.do";
|
||||
public static final String TASK_EMERGENZA = "TaskEmergenza.do";
|
||||
public static final String LISTA_TASK_AS_EMERGENZA = "TaskAsEmergenza.do";
|
||||
public static final String LISTA_TASK_SCHEDULATI = "ListaTaskSchedulati.do";
|
||||
|
||||
public static final String PRESENTAZIONE_APPLICATION =
|
||||
"PresentazioneApplication.do";
|
||||
public static final String ESITO_APPLICATION = "EsitoApplication.do";
|
||||
public static final String CCRM_CONFIGURATION = "CCRMConfiguration.do";
|
||||
public static final String CCRM_CONF_FLUSSO = "InsCCRMConfFlusso.do";
|
||||
public static final String SISTEMI_CONFIGURATION = "SistemiConfiguration.do";
|
||||
|
||||
public static final String XML_CONFIGURATION = "XMLConfiguration.do";
|
||||
public static final String XML_CONF_FILE ="InsXMLFileConf.do";
|
||||
public static final String XML_CONF_SCHEDULAZIONE ="InsCCRMConfSchedulazione.do";
|
||||
public static final String XML_STATO_OPERATORE ="InsStatoOperatore.do";
|
||||
public static final String XML_CONFIGURATION_ACK="ListaFileAck.do";
|
||||
|
||||
public static final String XML_PRIORITY="InsPriorityXML.do";
|
||||
public static final String XML_PRIORITY_IN="InsPriorityXMLIn.do";
|
||||
public static final String XML_PRIORITY_ACK="InsPriorityXMLAck.do";
|
||||
|
||||
// COSTANTI PER AMMINISTRAZIONE
|
||||
|
||||
public static final String PRESENTAZIONE_INTERFACCE="PresentazioneInterfacce.do";
|
||||
public static final String PRESENTAZIONE_AMMINISTRAZIONE = "PresentazioneAmministrazione.do";
|
||||
|
||||
|
||||
//TO DBCGO
|
||||
public static final String LOGIN_DBCGO="LoginDBCGO.do";
|
||||
|
||||
static {
|
||||
mapCmd2JSP = new HashMap();
|
||||
// inserimento nella mappa
|
||||
|
||||
mapCmd2JSP.put(LOGIN_DO, "/jsp/GUI/SecurityInfoClient.jsp");
|
||||
mapCmd2JSP.put(LOGOUT_DO, "/jsp/GUI/Logout.jsp");
|
||||
mapCmd2JSP.put(HOME_CRONTAB_DO, "/jsp/GUI/Presentazione.jsp");
|
||||
mapCmd2JSP.put(PAGE_ESITO, "/jsp/GUI/EsitoCrontab.jsp");
|
||||
mapCmd2JSP.put(LISTA_TASKS, "/jsp/GUI/ListaTasksDisponibili.jsp");
|
||||
mapCmd2JSP.put(LISTA_PROCESS, "/jsp/GUI/ListaProcessiDisponibili.jsp");
|
||||
mapCmd2JSP.put(INSERT_TASK, "/jsp/GUI/InserimentoTask.jsp");
|
||||
mapCmd2JSP.put(LISTA_INTERVALLI, "/jsp/GUI/PopUpListaIntervalli.jsp");
|
||||
mapCmd2JSP.put(INSERT_INTERVALLO, "/jsp/GUI/PopUpInserimentoIntervallo.jsp");
|
||||
mapCmd2JSP.put(PROCESSI_ASSOCIATI, "/jsp/GUI/PopUpProcessiAssociati.jsp");
|
||||
mapCmd2JSP.put(PROCESSI_BLOCCANTI, "/jsp/GUI/PopUpProcessiBloccanti.jsp");
|
||||
mapCmd2JSP.put(PROCESSI_DISPONIBILI,
|
||||
"/jsp/GUI/PopUpProcessiDisponibili.jsp");
|
||||
mapCmd2JSP.put(PROCESSI_BLOCCATI_DISPONIBILI,
|
||||
"/jsp/GUI/PopUpProcessiBloccatiDisponibili.jsp");
|
||||
mapCmd2JSP.put(ATTIVITA_GIORNALIERA, "/jsp/GUI/AttivitaGiornaliera.jsp");
|
||||
mapCmd2JSP.put(SCHEDA_TASK, "/jsp/GUI/SchedaTask.jsp");
|
||||
mapCmd2JSP.put(ERROR_DO, "/jsp/GUI/ErrorJSP.jsp");
|
||||
mapCmd2JSP.put(CONFIGURAZIONE_XML, "/jsp/GUI/Configurazione.jsp");
|
||||
mapCmd2JSP.put(SCHEDA_PROCESSO, "/jsp/GUI/SchedaProcesso.jsp");
|
||||
mapCmd2JSP.put(INSERT_PROCESSO, "/jsp/GUI/InserimentoProcesso.jsp");
|
||||
mapCmd2JSP.put(GESTIONE_GATEWAY, "/jsp/GUI/GestioneGateway.jsp");
|
||||
mapCmd2JSP.put(SESSIONE_INATTIVA, "/jsp/GUI/sessioneInattivaProject.jsp");
|
||||
mapCmd2JSP.put(TASK_EMERGENZA, "/jsp/GUI/InserimentoTaskEmergenza.jsp");
|
||||
mapCmd2JSP.put(LISTA_TASK_AS_EMERGENZA, "/jsp/GUI/ListaTaskASEmergenza.jsp");
|
||||
mapCmd2JSP.put(LISTA_TASK_SCHEDULATI, "/jsp/GUI/ListaTaskSchedulati.jsp");
|
||||
|
||||
// Mappa per APPLICATION MANAGER
|
||||
mapCmd2JSP.put(PRESENTAZIONE_APPLICATION,
|
||||
"/jsp/PresentazioneApplicationManager.jsp");
|
||||
mapCmd2JSP.put(ESITO_APPLICATION, "/jsp/EsitoApplication.jsp");
|
||||
mapCmd2JSP.put(CCRM_CONFIGURATION, "/jsp/CCRMConfigurazione.jsp");
|
||||
mapCmd2JSP.put(CCRM_CONF_FLUSSO, "/jsp/InsCCRMConfFlusso.jsp");
|
||||
mapCmd2JSP.put(XML_CONF_SCHEDULAZIONE, "/jsp/InsCCRMConfSchedulazione.jsp");
|
||||
mapCmd2JSP.put(XML_CONFIGURATION, "/jsp/XMLConfigurazione.jsp");
|
||||
mapCmd2JSP.put(SISTEMI_CONFIGURATION, "/jsp/SistemiConfigurazione.jsp");
|
||||
mapCmd2JSP.put(XML_CONF_FILE, "/jsp/InsXMLFileConf.jsp");
|
||||
mapCmd2JSP.put(XML_STATO_OPERATORE, "/jsp/InsStatoOperatore.jsp");
|
||||
mapCmd2JSP.put(XML_CONFIGURATION_ACK, "/jsp/ListaFileAck.jsp");
|
||||
mapCmd2JSP.put(XML_PRIORITY, "/jsp/InsPriorityXML.jsp");
|
||||
mapCmd2JSP.put(XML_PRIORITY_IN, "/jsp/InsPriorityXMLIn.jsp");
|
||||
mapCmd2JSP.put(XML_PRIORITY_ACK, "/jsp/InsPriorityXMLAck.jsp");
|
||||
|
||||
// Mappa per AMMINISTRAZIONE
|
||||
|
||||
mapCmd2JSP.put(PRESENTAZIONE_INTERFACCE, "/jsp/PresentazioneInterfacce.jsp");
|
||||
mapCmd2JSP.put(PRESENTAZIONE_AMMINISTRAZIONE, "/jsp/PresentazioneAmministrazione.jsp");
|
||||
|
||||
|
||||
// Mappa per DBCGO
|
||||
mapCmd2JSP.put(LOGIN_DBCGO, dbcgoLoginUrl);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il path completo della classe che si occupa di eseguire il comando in funzione
|
||||
* dell'URL ricevuto dal client
|
||||
* */
|
||||
|
||||
public static String getCommandClassByCommandName(String str_do) {
|
||||
// get name of command
|
||||
String commandClass = null;
|
||||
if (str_do == null)
|
||||
return null;
|
||||
|
||||
int index = str_do.indexOf(".do");
|
||||
|
||||
if (index != -1)
|
||||
commandClass = str_do.substring(0, index);
|
||||
else
|
||||
return null;
|
||||
|
||||
return "mnp.crontab.command." + commandClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il path completo della classe che si occupa di eseguire il comando in funzione
|
||||
* dell'URL ricevuto dal client
|
||||
* */
|
||||
public static String getJSPPageByCommandName(String str_do) {
|
||||
return (String) mapCmd2JSP.get(str_do);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
//
|
||||
// Classi di Variabili statiche per la numerazione dei Link
|
||||
// delle Jsp sviluppate
|
||||
|
||||
// FNC da 1....99 per ogni FUNZIONALITA'
|
||||
// indica una funzione di transito per la chiamata di un'altra Jsp
|
||||
|
||||
// CMD da 100...199 per ogni COMANDO
|
||||
// indica una funzione o comando per una chiamata di un metodo che accede a DB
|
||||
|
||||
public class CrontabCostants {
|
||||
|
||||
public CrontabCostants() {
|
||||
}
|
||||
|
||||
// Variabili GLOBALI
|
||||
|
||||
public static final String CAMPO_HIDDEN_FUNCTION = "JSP_FUNCTION";
|
||||
public static final String CAMPO_ELEMENT_CHECKED = "elementoChecked";
|
||||
public static final String CAMPO_ELEMENT_CHECKED_PARAM =
|
||||
"elementoCheckedParam";
|
||||
public static final String TIPO_OPERAZIONE = "typeOperation";
|
||||
|
||||
public static final String MESSAGGIO_CONFERMA = "msgConfirm";
|
||||
|
||||
public static final String XML_CONF_VER = "xmlConfVer";
|
||||
public static final String XML_CONF_SUBVER = "xmlConfSubVer";
|
||||
public static final String XML_CONF_NAME = "xmlConfName";
|
||||
|
||||
public static final String OBJECT_RESULT_BEAN = "resultBean";
|
||||
public static final String OBJECT_CRONTAB_SESSION = "CrontabSession";
|
||||
public static final String OBJECT_RESULT_BEAN_INTERVALLO =
|
||||
"resultBeanIntervallo";
|
||||
public static final String OBJECT_MBEAN_SESSION = "MBEANSession";
|
||||
public static final String OBJECT_INTERVALLI_SESSION = "IntervalliSession";
|
||||
public static final String OBJECT_PROCESSI_ASSOCIATI =
|
||||
"ProcessiAssociatiSession";
|
||||
public static final String OBJECT_PROCESSI_DISPONIBILI =
|
||||
"ProcessiDisponibiliSession";
|
||||
// C.P. processi bloccanti
|
||||
public static final String OBJECT_PROCESSI_BLOCCANTI =
|
||||
"ProcessiBloccantiSession";
|
||||
public static final String OBJECT_PROCESSI_BLOCCANTI_DISPONIBILI =
|
||||
"ProcessiBloccantiDisponibiliSession";
|
||||
|
||||
// public static final String OBJECT_SCHEDULER_SESSION = "SchedulerSession";
|
||||
// public static final String OBJECT_TASK_TIMER_SESSION = "TaskTimerSession";
|
||||
public static final String OBJECT_TASK_MANAGER_SESSION = "TaskManagerSession";
|
||||
public static final String OBJECT_TASK_MANAGER_MBEAN_CLIENT="Crontab:name=TaskManagerMonitor";
|
||||
// public static final String OBJECT_EXECUTION_MANAGER_SESSION =
|
||||
// "ExecutionManagerSession";
|
||||
// public static final String OBJECT_MEMORY_SESSION = "MemorySession";
|
||||
|
||||
/*** stringhe stati****/
|
||||
public static final String MODALITA_RUNNING = "Running";
|
||||
public static final String MODALITA_STANDBY = "Standby";
|
||||
public static final String MODALITA_SCHEDULED = "Scheduled";
|
||||
public static final String MODALITA_IN_PARTENZA = "Run as possible";
|
||||
public static final String MODALITA_EXECUTED = "Executed";
|
||||
public static final String MODALITA_DESTROYED = "Destroyed";
|
||||
public static final String MODALITA_IN_DISTRUZIONE = "Destroy as possible";
|
||||
|
||||
public static final String MODALITA_DISABLED = "Disabilitato";
|
||||
public static final String MODALITA_ABLE = "Abilitato";
|
||||
/**stati processi**/
|
||||
public static final String PROCESS_STATE_UNKNOWN_DESC = "N.D.";
|
||||
public static final String PROCESS_STATE_RUN_AS_POSSIBLE_DESC = "Waiting";
|
||||
public static final String PROCESS_STATE_RUNNING_DESC = "Running";
|
||||
public static final String PROCESS_STATE_EXITVALUEOK_DESC = "Executed";
|
||||
public static final String PROCESS_STATE_EXITVALUEKO_DESC = "Execution Error";
|
||||
public static final String PROCESS_STATE_DISABLED_DESC = "Disabled";
|
||||
/**/
|
||||
|
||||
public static final String STATO_SCHEDULATORE_RUNNING =
|
||||
"SCHEDULATORE ABILITATO";
|
||||
public static final String STATO_SCHEDULATORE_STANDBY =
|
||||
"SCHEDULATORE DISABILITATO";
|
||||
public static final String STATO_PROCESSO_ABILITATO = "Abilitato";
|
||||
public static final String STATO_PROCESSO_DISABILITATO = "Disabilitato";
|
||||
|
||||
public static final String USER_AMMINISTRATORE = "A";
|
||||
public static final String USER_VISUALIZZATORE = "V";
|
||||
|
||||
public static final String LABEL_OPERAZIONE_NUOVO_TASK =
|
||||
"INSERIMENTO NUOVO TASK";
|
||||
public static final String LABEL_OPERAZIONE_TASK_EMERGENZA = "TASK EMERGENZA";
|
||||
public static final String LABEL_OPERAZIONE_MODIFICA_TASK = "MODIFICA TASK";
|
||||
public static final String LABEL_OPERAZIONE_DETTAGLIO_TASK = "SCHEDA TASK";
|
||||
public static final String LABEL_OPERAZIONE_DETTAGLIO_PROCESSO =
|
||||
"SCHEDA PROCESSO";
|
||||
public static final String LABEL_OPERAZIONE_NUOVO_PROCESSO =
|
||||
"INSERIMENTO NUOVO PROCESSO";
|
||||
public static final String LABEL_OPERAZIONE_MODIFICA_PROCESSO =
|
||||
"MODIFICA PROCESSO";
|
||||
|
||||
// Variabili valide per chiamata di PopUp
|
||||
|
||||
public static final String OPEN_POPUP_INTERVALLI_ATTIVAZIONE =
|
||||
"jsp/GUI/PopUpListaIntervalli.jsp";
|
||||
public static final String OPEN_POPUP_PROCESSI_ASSOCIATI =
|
||||
"jsp/GUI/PopUpProcessiAssociati.jsp";
|
||||
// C.P x processi bloccanti
|
||||
public static final String OPEN_POPUP_PROCESSI_BLOCCANTI =
|
||||
"jsp/GUI/PopUpProcessiBloccanti.jsp";
|
||||
|
||||
// Variabili valide per messaggistica CLIENT
|
||||
|
||||
public static final String ABILITA_MOTORE =
|
||||
"SCHEDULATORE ABILITATO AD ESEGUIRE LE ATTIVITA'";
|
||||
public static final String DISABILITA_MOTORE =
|
||||
"SCHEDULATORE DISABILITATO AD ESEGUIRE LE ATTIVITA'";
|
||||
public static final String RESTART_MOTORE = "SCHEDULATORE REINIZIALIZZATO <br> VERRANNO RICALCOLATE LE ATTIVITA' DA SVOLGERE";
|
||||
public static final String FILE_XML_SALVATO =
|
||||
"SALVATAGGIO FILE XML EFFETTUATO.";
|
||||
public static final String FILE_XML_RIPRISTINATO =
|
||||
"RIPRISTINO FILE XML EFFETTUATO.";
|
||||
public static final String GATEWAY_ABILITATO = "GATEWAY ABILITATO.";
|
||||
public static final String GATEWAY_DISABILITATO = "GATEWAY DISABILITATO.";
|
||||
public static final String GATEWAY_ERRORE_DI_COMUNICAZIONE = " GATEWAY ERRORE DI COMUNICAZIONE :";
|
||||
public static final String UTENTE_NON_ABILITATO =
|
||||
"UTENTE NON ABILITATO AD ESEGUIRE IL COMANDO.";
|
||||
public static final String TASK_EMERGENZA_NO_CORRECT =
|
||||
"IMPOSSIBILE ESEGUIRE UN TASK D'EMERGENZA SENZA PROCESSI ASSOCIATI.";
|
||||
// Variabili valide per oggetto Index
|
||||
|
||||
public static final int FNC_GESTIONE_TASK = 1;
|
||||
public static final int FNC_GESTIONE_PROCESSI = 2;
|
||||
public static final int FNC_LOGOUT = 3;
|
||||
public static final int FNC_ATTIVITA_GIORNALIERE = 4;
|
||||
public static final int FNC_HOME_PRESENTAZIONE = 5;
|
||||
public static final int FNC_CONFIGURAZIONE_XML = 6;
|
||||
public static final int FNC_GESTIONE_GATEWAY = 7;
|
||||
public static final int FNC_APPLICATION_MANAGER = 8;
|
||||
public static final int FNC_LISTA_TASK_SCHEDULATI = 9;
|
||||
public static final int FNC_LOGOUT_CRONTAB =10;
|
||||
|
||||
public static final int CMD_ABILITAZIONE_SCHED = 100;
|
||||
public static final int CMD_DISABILITAZIONE_SCHED = 101;
|
||||
public static final int CMD_RESTART_SCHED = 102;
|
||||
public static final int CMD_SAVE_XML = 103;
|
||||
public static final int CMD_RELOAD_XML = 104;
|
||||
public static final int CMD_ABILITA_GATEWAY = 106;
|
||||
public static final int CMD_DISABILITA_GATEWAY = 107;
|
||||
public static final int CMD_LISTA_TASK_SCHEDULATI = 108;
|
||||
|
||||
// Variabili valide per oggetto TaskCommand
|
||||
|
||||
public static final int FNC_NUOVO_TASK = 1;
|
||||
public static final int FNC_MODIFICA_TASK = 2;
|
||||
public static final int FNC_DETTAGLIO_TASK = 3;
|
||||
public static final int FNC_NUOVO_INTERVALLO = 4;
|
||||
public static final int FNC_MODIFICA_INTERVALLO = 5;
|
||||
public static final int FNC_ASSOCIA_PROCESSO = 6;
|
||||
public static final int FNC_TASK_EMERGENZA = 7;
|
||||
public static final int FNC_LANCIA_TASK_EMERGENZA = 8;
|
||||
|
||||
public static final int CMD_NUOVO_TASK = 100;
|
||||
public static final int CMD_MODIFICA_TASK = 101;
|
||||
public static final int CMD_ABILITA_TASK = 102;
|
||||
public static final int CMD_START_TASK = 103;
|
||||
public static final int CMD_DISABILITA_TASK = 104;
|
||||
public static final int CMD_ARRESTA_TASK = 105;
|
||||
public static final int CMD_ELIMINA_TASK = 106;
|
||||
public static final int CMD_NUOVO_INTERVALLO = 107;
|
||||
public static final int CMD_MODIFICA_INTERVALLO = 108;
|
||||
public static final int CMD_ELIMINA_INTERVALLO = 109;
|
||||
public static final int CMD_ASSOCIA_PROCESSO = 110;
|
||||
public static final int CMD_DISASSOCIA_PROCESSO = 111;
|
||||
public static final int CMD_DISABILITA_PROCESSO_ASSOCIATO = 112;
|
||||
public static final int CMD_ABILITA_PROCESSO_ASSOCIATO = 113;
|
||||
public static final int CMD_TASK_EMERGENZA = 114;
|
||||
public static final int CMD_LANCIA_TASK_EMERGENZA = 115;
|
||||
// Variabili valide per oggetto ProcessCommand
|
||||
|
||||
public static final int FNC_NUOVO_PROCESSO = 1;
|
||||
public static final int FNC_MODIFICA_PROCESSO = 2;
|
||||
public static final int FNC_DETTAGLIO_PROCESSO = 3;
|
||||
//C.P gestione processi bloccanti
|
||||
public static final int FNC_ASSOCIA_PROCESSO_BLOCCANTE = 4;
|
||||
//
|
||||
|
||||
public static final int CMD_NUOVO_PROCESSO = 100;
|
||||
public static final int CMD_MODIFICA_PROCESSO = 101;
|
||||
public static final int CMD_ABILITA_PROCESSO = 102;
|
||||
public static final int CMD_START_PROCESSO = 103;
|
||||
public static final int CMD_DISABILITA_PROCESSO = 104;
|
||||
public static final int CMD_ARRESTA_PROCESSO = 105;
|
||||
public static final int CMD_ELIMINA_PROCESSO = 106;
|
||||
//C.P gestione processi bloccanti
|
||||
public static final int CMD_ASSOCIA_PROCESSO_BLOCCANTE = 107;
|
||||
public static final int CMD_DISASSOCIA_PROCESSO_BLOCCANTE = 108;
|
||||
//
|
||||
|
||||
public static final String STATO_CONFIGURAZIONE =
|
||||
"statoConfigurazioneCrontab";
|
||||
|
||||
//DBCGO
|
||||
public static final String DBCGO_DOMAIN_CODE = "GO";
|
||||
|
||||
//log security
|
||||
public static final String LOG_CLIENT_APP_NAME = "MNP-CRONTAB-WEB";
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
/**
|
||||
* <p>Title: </p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: </p>
|
||||
* @author not attributable
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class CrontabSession {
|
||||
private String stato_Schedulatore;
|
||||
private String taskId;
|
||||
private String processId;
|
||||
private String labelOperazione;
|
||||
private int cmdOperazione;
|
||||
private String user;
|
||||
private java.util.Date dataCreazione;
|
||||
private mnp.crontab.config.ui.ProfileConfig profileConfiguration;
|
||||
public CrontabSession() {
|
||||
}
|
||||
public String getStato_Schedulatore() {
|
||||
return stato_Schedulatore;
|
||||
}
|
||||
public void setStato_Schedulatore(String stato_Schedulatore) {
|
||||
this.stato_Schedulatore = stato_Schedulatore;
|
||||
}
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
public String getProcessId() {
|
||||
return processId;
|
||||
}
|
||||
public void setProcessId(String processId) {
|
||||
this.processId = processId;
|
||||
}
|
||||
public String getLabelOperazione() {
|
||||
return labelOperazione;
|
||||
}
|
||||
public void setLabelOperazione(String labelOperazione) {
|
||||
this.labelOperazione = labelOperazione;
|
||||
}
|
||||
public int getCmdOperazione() {
|
||||
return cmdOperazione;
|
||||
}
|
||||
public void setCmdOperazione(int cmdOperazione) {
|
||||
this.cmdOperazione = cmdOperazione;
|
||||
}
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
public java.util.Date getDataCreazione() {
|
||||
return dataCreazione;
|
||||
}
|
||||
public void setDataCreazione(java.util.Date dataCreazione) {
|
||||
this.dataCreazione = dataCreazione;
|
||||
}
|
||||
public mnp.crontab.config.ui.ProfileConfig getProfileConfiguration() {
|
||||
return profileConfiguration;
|
||||
}
|
||||
public void setProfileConfiguration(mnp.crontab.config.ui.ProfileConfig profileConfiguration) {
|
||||
this.profileConfiguration = profileConfiguration;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
/**
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
import mnp.crontab.command.CrontabCostants;
|
||||
|
||||
public class ExecutionProfile {
|
||||
public ExecutionProfile() {
|
||||
}
|
||||
public static boolean valideCommandIndex(String user,int command) throws Exception {
|
||||
//// METODO PER COMMAND INDEX
|
||||
//// metodo che controlla che un dato metodo comando possa essere eseguito o meno
|
||||
//// in base al tipo di user che accede all'applicazione
|
||||
//// se user è 'A'=amministratore non c'è nessuna limitazione d'accesso
|
||||
//// se user è 'V'=visualizzatori c'è la limitazione di accesso ai soli comandi di visualizzazione
|
||||
|
||||
boolean valide = false;
|
||||
/// SE USER é AMMINISTRATORE
|
||||
if (user.equals(CrontabCostants.USER_AMMINISTRATORE))
|
||||
return valide;
|
||||
/// SE USER è VISUALIZZATORE, controllo il comando
|
||||
|
||||
switch(command) {
|
||||
case CrontabCostants.CMD_ABILITAZIONE_SCHED: return true;
|
||||
case CrontabCostants.CMD_DISABILITAZIONE_SCHED: return true;
|
||||
case CrontabCostants.CMD_RESTART_SCHED: return true;
|
||||
case CrontabCostants.CMD_SAVE_XML: return true;
|
||||
case CrontabCostants.CMD_RELOAD_XML: return true;
|
||||
case CrontabCostants.CMD_ABILITA_GATEWAY: return true;
|
||||
case CrontabCostants.CMD_DISABILITA_GATEWAY: return true;
|
||||
|
||||
/// per default
|
||||
/// il comando è di visualizzazione
|
||||
default: return valide;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean valideCommandTask(String user,int command) throws Exception {
|
||||
//// METODO PER COMMAND TaskCommand
|
||||
//// metodo che controlla che un dato metodo comando possa essere eseguito o meno
|
||||
//// in base al tipo di user che accede all'applicazione
|
||||
//// se user è 'A'=amministratore non c'è nessuna limitazione d'accesso
|
||||
//// se user è 'V'=visualizzatori c'è la limitazione di accesso ai soli comandi di visualizzazione
|
||||
|
||||
boolean valide = false;
|
||||
/// SE USER é AMMINISTRATORE
|
||||
if (user.equals(CrontabCostants.USER_AMMINISTRATORE))
|
||||
return valide;
|
||||
/// SE USER è VISUALIZZATORE, controllo il comando
|
||||
|
||||
switch(command) {
|
||||
case CrontabCostants.CMD_NUOVO_TASK: return true;
|
||||
case CrontabCostants.CMD_MODIFICA_TASK: return true;
|
||||
case CrontabCostants.CMD_ABILITA_TASK: return true;
|
||||
case CrontabCostants.CMD_START_TASK: return true;
|
||||
case CrontabCostants.CMD_DISABILITA_TASK: return true;
|
||||
case CrontabCostants.CMD_ARRESTA_TASK: return true;
|
||||
case CrontabCostants.CMD_ELIMINA_TASK: return true;
|
||||
case CrontabCostants.CMD_NUOVO_INTERVALLO: return true;
|
||||
case CrontabCostants.CMD_MODIFICA_INTERVALLO: return true;
|
||||
case CrontabCostants.CMD_ELIMINA_INTERVALLO: return true;
|
||||
case CrontabCostants.CMD_ASSOCIA_PROCESSO: return true;
|
||||
case CrontabCostants.CMD_DISASSOCIA_PROCESSO: return true;
|
||||
case CrontabCostants.CMD_DISABILITA_PROCESSO_ASSOCIATO: return true;
|
||||
case CrontabCostants.CMD_ABILITA_PROCESSO_ASSOCIATO: return true;
|
||||
case CrontabCostants.FNC_TASK_EMERGENZA: return true;
|
||||
/// per default
|
||||
/// il comando è di visualizzazione
|
||||
default: return valide;
|
||||
|
||||
}
|
||||
}
|
||||
public static boolean valideCommandProcess(String user,int command) throws Exception {
|
||||
//// METODO PER COMMAND ProcessCommand
|
||||
//// metodo che controlla che un dato metodo comando possa essere eseguito o meno
|
||||
//// in base al tipo di user che accede all'applicazione
|
||||
//// se user è 'A'=amministratore non c'è nessuna limitazione d'accesso
|
||||
//// se user è 'V'=visualizzatori c'è la limitazione di accesso ai soli comandi di visualizzazione
|
||||
|
||||
boolean valide = false;
|
||||
/// SE USER é AMMINISTRATORE
|
||||
if (user.equals(CrontabCostants.USER_AMMINISTRATORE))
|
||||
return valide;
|
||||
/// SE USER è VISUALIZZATORE, controllo il comando
|
||||
|
||||
switch(command) {
|
||||
case CrontabCostants.CMD_NUOVO_PROCESSO: return true;
|
||||
case CrontabCostants.CMD_MODIFICA_PROCESSO: return true;
|
||||
case CrontabCostants.CMD_ABILITA_PROCESSO: return true;
|
||||
case CrontabCostants.CMD_START_PROCESSO: return true;
|
||||
case CrontabCostants.CMD_DISABILITA_PROCESSO: return true;
|
||||
case CrontabCostants.CMD_ARRESTA_PROCESSO: return true;
|
||||
case CrontabCostants.CMD_ELIMINA_PROCESSO: return true;
|
||||
|
||||
/// per default
|
||||
/// il comando è di visualizzazione
|
||||
default: return valide;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean valideCommandSistemi(String user,int command) throws Exception {
|
||||
//// METODO PER COMMAND SistemiCommand
|
||||
//// metodo che controlla che un dato metodo comando possa essere eseguito o meno
|
||||
//// in base al tipo di user che accede all'applicazione
|
||||
//// se user è 'A'=amministratore non c'è nessuna limitazione d'accesso
|
||||
//// se user è 'V'=visualizzatori c'è la limitazione di accesso ai soli comandi di visualizzazione
|
||||
|
||||
boolean valide = false;
|
||||
/// SE USER é AMMINISTRATORE
|
||||
if (user.equals(CrontabCostants.USER_AMMINISTRATORE))
|
||||
return valide;
|
||||
/// SE USER è VISUALIZZATORE, controllo il comando
|
||||
|
||||
switch(command) {
|
||||
case ApplicationManagerCostants.CMD_APPLY_SISTEMI_INTERNI: return true;
|
||||
|
||||
/// per default
|
||||
/// il comando è di visualizzazione
|
||||
default: return valide;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean valideCommandXML(String user,int command) throws Exception {
|
||||
//// METODO PER COMMAND XMLCommand
|
||||
//// metodo che controlla che un dato metodo comando possa essere eseguito o meno
|
||||
//// in base al tipo di user che accede all'applicazione
|
||||
//// se user è 'A'=amministratore non c'è nessuna limitazione d'accesso
|
||||
//// se user è 'V'=visualizzatori c'è la limitazione di accesso ai soli comandi di visualizzazione
|
||||
|
||||
boolean valide = false;
|
||||
/// SE USER é AMMINISTRATORE
|
||||
if (user.equals(CrontabCostants.USER_AMMINISTRATORE))
|
||||
return valide;
|
||||
/// SE USER è VISUALIZZATORE, controllo il comando
|
||||
|
||||
switch(command) {
|
||||
case ApplicationManagerCostants.CMD_APPLY_ALL_XML: return true;
|
||||
|
||||
/// per default
|
||||
/// il comando è di visualizzazione
|
||||
default: return valide;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,893 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
/**
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
/// oggetti java
|
||||
// oggetti back end
|
||||
import java.text.*;
|
||||
// oggetti client
|
||||
import java.util.*;
|
||||
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.engine.mbean.*;
|
||||
import it.valueteam.crontab.obj.engine.*;
|
||||
import it.valueteam.crontab.obj.gui.*;
|
||||
import it.valueteam.crontab.utility.EventTime;
|
||||
import mnp.crontab.config.xml.types.*;
|
||||
import mnp.crontab.objects.*;
|
||||
// oggetti back end
|
||||
import mnp.crontab.objects.ui.*;
|
||||
import mnp.crontab.utility.*;
|
||||
|
||||
|
||||
public class FormatterCommand
|
||||
{
|
||||
static java.text.SimpleDateFormat orario = new java.text.SimpleDateFormat(
|
||||
"HH:mm");
|
||||
public FormatterCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public static ListaTasks formatterListaTask(TaskManagerMBean
|
||||
taskManagerMonitor)
|
||||
{
|
||||
// metodo che formatta un ArrayList, di ritono dal metodo di task manager monitor,
|
||||
// in un ListaTasks per il client
|
||||
TaskInfo aTask = null;
|
||||
ListaTasks aLista = new ListaTasks();
|
||||
|
||||
ArrayList arrTask = listaTaskOrdinati(taskManagerMonitor.getAvailableTaskList()); //getTaskList();
|
||||
TaskBean[] aTaskBean = new TaskBean[arrTask.size()]; ;
|
||||
|
||||
for (int i = 0; i < arrTask.size(); i++)
|
||||
{
|
||||
aTask = (TaskInfo) arrTask.get(i);
|
||||
aTaskBean[i] = new TaskBean();
|
||||
|
||||
/// ID
|
||||
aTaskBean[i].setIdTask(aTask.getId());
|
||||
/// Nome
|
||||
aTaskBean[i].setNome(aTask.getName());
|
||||
//// Modalita
|
||||
if (aTask.isEnabled())
|
||||
{
|
||||
aTaskBean[i].setModalita(CrontabCostants.MODALITA_ABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
aTaskBean[i].setModalita(CrontabCostants.MODALITA_DISABLED);
|
||||
|
||||
/// Ora Partenza - in Lista Task non c'<27> +
|
||||
/* if (aTask.getSchedulation()==null)
|
||||
aTaskBean[i].setOraPartenza("");
|
||||
else
|
||||
aTaskBean[i].setOraPartenza(orario.format(aTask.getSchedulation().getTime()));
|
||||
*/
|
||||
/// Modalita - in Lista Task non c'<27> +
|
||||
// aTaskBean[i].setModalita(getModalitaTask(aTask. getState()));
|
||||
/// Processi
|
||||
}
|
||||
aTaskBean[i].setLabelProcessAssociati(getLabelProcessAssociate(aTask.
|
||||
getProcessList()));
|
||||
|
||||
}
|
||||
aLista.setListaTaskBean(aTaskBean);
|
||||
return aLista;
|
||||
}
|
||||
|
||||
public static ListaTasks formatterListaTask(TaskManagerMBean
|
||||
taskManagerMonitor,EventTime et_from,EventTime et_to)
|
||||
{
|
||||
// metodo che formatta un ArrayList, di ritono dal metodo di task manager monitor,
|
||||
// in un ListaTasks per il client
|
||||
TaskInfo aTask = null;
|
||||
ListaTasks aLista = new ListaTasks();
|
||||
|
||||
ArrayList arrTask = listaTaskOrdinati(taskManagerMonitor.getTaskInInterval(et_from,et_to)); //getTaskList();
|
||||
TaskBean[] aTaskBean = new TaskBean[arrTask.size()]; ;
|
||||
|
||||
for (int i = 0; i < arrTask.size(); i++)
|
||||
{
|
||||
aTask = (TaskInfo) arrTask.get(i);
|
||||
aTaskBean[i] = new TaskBean();
|
||||
|
||||
/// ID
|
||||
aTaskBean[i].setIdTask(aTask.getId());
|
||||
/// Nome
|
||||
aTaskBean[i].setNome(aTask.getName());
|
||||
|
||||
aTaskBean[i].setLabelProcessAssociati(getLabelProcessAssociate(aTask.
|
||||
getProcessList()));
|
||||
|
||||
}
|
||||
aLista.setListaTaskBean(aTaskBean);
|
||||
return aLista;
|
||||
}
|
||||
|
||||
public static ListaProcessi formatterListaProcessi(TaskManagerMBean
|
||||
taskManagerMonitor)
|
||||
{
|
||||
// metodo che formatta un ArrayList, di ritono dal metodo di task manager monitor,
|
||||
// in un ListaProcessi per il client
|
||||
|
||||
ArrayList arrProcess = listaProcessiOrdinati(taskManagerMonitor.getAvailableProcess());
|
||||
|
||||
|
||||
|
||||
ProcessBean[] aProcess = new ProcessBean[arrProcess.size()];
|
||||
ProcessInfo aProcessInfo = null;
|
||||
ListaProcessi aLista = new ListaProcessi();
|
||||
|
||||
for (int i = 0; i < arrProcess.size(); i++)
|
||||
{
|
||||
aProcessInfo = (ProcessInfo) arrProcess.get(i);
|
||||
aProcess[i] = new ProcessBean();
|
||||
|
||||
/// ID
|
||||
aProcess[i].setProcessId(aProcessInfo.getId());
|
||||
/// Nome
|
||||
aProcess[i].setNome(aProcessInfo.getName());
|
||||
|
||||
/// Modalita
|
||||
if (aProcessInfo.getEnabled())
|
||||
{
|
||||
aProcess[i].setModalita(CrontabCostants.STATO_PROCESSO_ABILITATO);
|
||||
}
|
||||
else
|
||||
{
|
||||
aProcess[i].setModalita(CrontabCostants.STATO_PROCESSO_DISABILITATO);
|
||||
|
||||
}
|
||||
aProcess[i].setStatoProcesso(String.valueOf(aProcessInfo.getTaskRefs().
|
||||
size()));
|
||||
}
|
||||
aLista.setListaProcessi(aProcess);
|
||||
return aLista;
|
||||
}
|
||||
|
||||
public static ListaTasks formatterListaTaskSchedulati(TaskManagerMBean
|
||||
taskManagerMonitor)
|
||||
{
|
||||
// metodo che formatta un ArrayList, di ritono dal metodo di task manager monitor,
|
||||
// in un ListaTasks per il client
|
||||
TaskState aTask = null;
|
||||
ListaTasks aLista = new ListaTasks();
|
||||
|
||||
ArrayList arrTaskSched = taskManagerMonitor.getTaskList(); //getScheduledTaskList();//
|
||||
|
||||
// ordino la lista
|
||||
Collections.sort(arrTaskSched, new Comparator()
|
||||
{
|
||||
public int compare(Object o1, Object o2)
|
||||
{
|
||||
TaskState t1 = (TaskState) o1;
|
||||
TaskState t2 = (TaskState) o2;
|
||||
int res = (t1.getSchedulation().before(t2.getSchedulation())) ? -1 :
|
||||
(t1.getSchedulation().after(t2.getSchedulation()) ? 1 : 0);
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return this.getClass().equals(o.getClass());
|
||||
}
|
||||
});
|
||||
// FINE ordino la lista
|
||||
|
||||
/// prendo solo i primi 20
|
||||
int dimensione = 20;
|
||||
if (arrTaskSched.size() < 20)
|
||||
{
|
||||
dimensione = arrTaskSched.size();
|
||||
///
|
||||
|
||||
}
|
||||
TaskBean[] aTaskBean = new TaskBean[dimensione];
|
||||
|
||||
for (int i = 0; i < dimensione; i++)
|
||||
{
|
||||
aTask = (TaskState) arrTaskSched.get(i);
|
||||
aTaskBean[i] = new TaskBean();
|
||||
|
||||
/// Id
|
||||
aTaskBean[i].setId(aTask.getId());
|
||||
/// IdTask
|
||||
aTaskBean[i].setIdTask(aTask.getTaskId());
|
||||
/// Nome
|
||||
aTaskBean[i].setNome(aTask.getName());
|
||||
/// Modalita
|
||||
aTaskBean[i].setModalita(getModalitaTask(aTask.getState()));
|
||||
/// Istante Attivazione
|
||||
aTaskBean[i].setOraPartenza(orario.format(aTask.getSchedulation().getTime()));
|
||||
/// Istante Disattivazione
|
||||
if (aTask.getTaskId().equals(Resources.getID_TASK_EMERGENZA()))
|
||||
{
|
||||
aTaskBean[i].setNome("Task Emergenza");
|
||||
aTaskBean[i].setOraStop("END");
|
||||
}
|
||||
else
|
||||
{
|
||||
EventTime evt = aTask.getStopTime();
|
||||
if(evt!=null) {
|
||||
aTaskBean[i].setOraStop(orario.format(evt.getTime()));
|
||||
}
|
||||
|
||||
/// Processi Associati
|
||||
}
|
||||
aTaskBean[i].setLabelProcessAssociati(getLabelProcessAssociate(aTask.
|
||||
getProcessList()));
|
||||
/// Stati Uscita
|
||||
aTaskBean[i].setStato(getLabelStatiUscita(getProcessStateDesc(aTask.getProcessStateList())));
|
||||
/// processi-stato
|
||||
/*aTaskBean[i].setLabelProcessAssociati(
|
||||
getLabelProcessAssociate(aTask.getProcessList(),aTask.getExitValues()));*/
|
||||
}
|
||||
aLista.setListaTaskBean(aTaskBean);
|
||||
return aLista;
|
||||
}
|
||||
|
||||
private static ArrayList getProcessStateDesc(ArrayList procesState) {
|
||||
ArrayList res = new ArrayList();
|
||||
for (Iterator i = procesState.iterator(); i.hasNext(); ) {
|
||||
Integer istate = (Integer) i.next();
|
||||
switch (istate.intValue()) {
|
||||
case RunningTask.PROCESS_STATE_UNKNOWN:
|
||||
res.add(CrontabCostants.PROCESS_STATE_UNKNOWN_DESC);
|
||||
break;
|
||||
case RunningTask.PROCESS_STATE_RUN_AS_POSSIBLE:
|
||||
res.add(CrontabCostants.PROCESS_STATE_RUN_AS_POSSIBLE_DESC);
|
||||
break;
|
||||
case RunningTask.PROCESS_STATE_RUNNING:
|
||||
res.add(CrontabCostants.PROCESS_STATE_RUNNING_DESC);
|
||||
break;
|
||||
case RunningTask.PROCESS_STATE_EXITVALUEOK:
|
||||
res.add(CrontabCostants.PROCESS_STATE_EXITVALUEOK_DESC);
|
||||
break;
|
||||
case RunningTask.PROCESS_STATE_EXITVALUEKO:
|
||||
res.add(CrontabCostants.PROCESS_STATE_EXITVALUEKO_DESC);
|
||||
break;
|
||||
case RunningTask.PROCESS_STATE_DISABLED:
|
||||
res.add(CrontabCostants.PROCESS_STATE_DISABLED_DESC);
|
||||
break;
|
||||
default:
|
||||
res.add("STATE ERROR");
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public static ListaTasks formatterListaTaskAttivi(TaskManagerMBean
|
||||
taskManagerMonitor)
|
||||
{
|
||||
// metodo che formatta un ArrayList, di ritono dal metodo di task manager monitor,
|
||||
// in un ListaTasks per il client
|
||||
TaskState aTask = null;
|
||||
ListaTasks aLista = new ListaTasks();
|
||||
|
||||
ArrayList arrTaskSched = taskManagerMonitor.getActiveTaskList();
|
||||
|
||||
// ordino la lista
|
||||
Collections.sort(arrTaskSched, new Comparator()
|
||||
{
|
||||
public int compare(Object o1, Object o2)
|
||||
{
|
||||
TaskState t1 = (TaskState) o1;
|
||||
TaskState t2 = (TaskState) o2;
|
||||
int res = (t1.getSchedulation().before(t2.getSchedulation())) ? -1 :
|
||||
(t1.getSchedulation().after(t2.getSchedulation()) ? 1 : 0);
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return this.getClass().equals(o.getClass());
|
||||
}
|
||||
});
|
||||
// FINE ordino la lista
|
||||
|
||||
TaskBean[] aTaskBean = new TaskBean[arrTaskSched.size()];
|
||||
|
||||
for (int i = 0; i < arrTaskSched.size(); i++)
|
||||
{
|
||||
aTask = (TaskState) arrTaskSched.get(i);
|
||||
aTaskBean[i] = new TaskBean();
|
||||
|
||||
/// Nome
|
||||
aTaskBean[i].setNome(aTask.getName());
|
||||
/// Ora Partenza
|
||||
aTaskBean[i].setOraPartenza(orario.format(aTask.getSchedulation().getTime()));
|
||||
|
||||
}
|
||||
aLista.setListaTaskBean(aTaskBean);
|
||||
return aLista;
|
||||
}
|
||||
|
||||
/**
|
||||
* metodo per il ritorno della modalit<69> mappata sulla parte cliente
|
||||
* @param stato int
|
||||
* @return String
|
||||
*/
|
||||
public static String getModalitaTask(int stato) {
|
||||
String modalita = null;
|
||||
switch (stato) {
|
||||
case RunningTask.STATE_IDLE:
|
||||
modalita = CrontabCostants.MODALITA_STANDBY;
|
||||
break;
|
||||
case RunningTask.STATE_SCHEDULED:
|
||||
modalita = CrontabCostants.MODALITA_SCHEDULED;
|
||||
break;
|
||||
case RunningTask.STATE_RUN_AS_POSSIBLE:
|
||||
modalita = CrontabCostants.MODALITA_IN_PARTENZA;
|
||||
break;
|
||||
case RunningTask.STATE_RUNNING:
|
||||
modalita = CrontabCostants.MODALITA_RUNNING;
|
||||
break;
|
||||
case RunningTask.STATE_DESTROYED:
|
||||
modalita = CrontabCostants.MODALITA_DESTROYED;
|
||||
break;
|
||||
case RunningTask.STATE_DISABLED:
|
||||
modalita = CrontabCostants.MODALITA_DISABLED;
|
||||
break;
|
||||
case RunningTask.STATE_EXECUTED:
|
||||
modalita = CrontabCostants.MODALITA_EXECUTED;
|
||||
break;
|
||||
case RunningTask.STATE_DESTROY_AS_POSSIBLE:
|
||||
modalita = CrontabCostants.MODALITA_IN_DISTRUZIONE;
|
||||
break;
|
||||
default:
|
||||
modalita = "ERROR.";
|
||||
}
|
||||
return modalita;
|
||||
}
|
||||
|
||||
public static String getLabelProcessAssociate(ArrayList aProcessList)
|
||||
{
|
||||
/// metodo per il ritorno dei processi associati
|
||||
/// formato label
|
||||
String label = "";
|
||||
TaskInfo.ProcessInfoRef aProcess = null;
|
||||
|
||||
for (int i = 0; i < aProcessList.size(); i++)
|
||||
{
|
||||
aProcess = (TaskInfo.ProcessInfoRef) aProcessList.get(i);
|
||||
label = label + aProcess.getProcess().getName() + "<br>";
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
public static String getLabelProcessAssociate(ArrayList aProcessList,
|
||||
ArrayList exitValue)
|
||||
{
|
||||
/// metodo per il ritorno dei processi associati con ExitValue
|
||||
/// formato label
|
||||
String label = "";
|
||||
TaskInfo.ProcessInfoRef aProcess = null;
|
||||
String exit = "";
|
||||
|
||||
for (int i = 0; i < aProcessList.size(); i++)
|
||||
{
|
||||
aProcess = (TaskInfo.ProcessInfoRef) aProcessList.get(i);
|
||||
exit = (String) exitValue.get(i);
|
||||
label = label + aProcess.getProcess().getName() + " - " + exit + "<br>";
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
public static String getLabelStatiUscita(ArrayList exitValue)
|
||||
{
|
||||
/// metodo per il ritorno dei processi associati con ExitValue
|
||||
/// formato label
|
||||
String label = "";
|
||||
String exit = "";
|
||||
|
||||
for (int i = 0; i < exitValue.size(); i++)
|
||||
{
|
||||
exit = (String) exitValue.get(i);
|
||||
label = label + exit + "<br>";
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
public static TaskBean formatterTask(TaskInfo aTaskInfo)
|
||||
{
|
||||
// metodo che ritorna un TaskBean da un TaskInfo da backEND
|
||||
TaskBean aTask = new TaskBean();
|
||||
aTask.setIdTask(aTaskInfo.getId());
|
||||
aTask.setNome(aTaskInfo.getName());
|
||||
aTask.setDescrizione(aTaskInfo.getDesc());
|
||||
aTask.setNote(aTaskInfo.getNote());
|
||||
|
||||
if (aTaskInfo.isEnabled())
|
||||
{
|
||||
aTask.setModalita(CrontabCostants.MODALITA_STANDBY);
|
||||
}
|
||||
else
|
||||
{
|
||||
aTask.setModalita(CrontabCostants.MODALITA_DISABLED);
|
||||
|
||||
// intervalli di attivazione
|
||||
}
|
||||
Vector intervalli = getIntervalliAttivazione(aTaskInfo.getRegoleAttivazione().
|
||||
iterator());
|
||||
String label = getLabelIntervalli(intervalli);
|
||||
aTask.setLabelIntervalli(label);
|
||||
// processi associati
|
||||
aTask.setVectorProcessi(getProcessiAssociati(aTaskInfo.getProcessList()));
|
||||
|
||||
return aTask;
|
||||
}
|
||||
|
||||
public static ProcessBean formatterProcess(TaskManagerMBean taskManagerMonitor,ProcessInfo aProcessInfo)
|
||||
{
|
||||
// metodo che ritorna un ProcessBean da un ProcessInfo da backEND
|
||||
ProcessBean aProcess = new ProcessBean();
|
||||
aProcess.setProcessId(aProcessInfo.getId());
|
||||
aProcess.setNome(aProcessInfo.getName());
|
||||
aProcess.setDescrizione(aProcessInfo.getDesc());
|
||||
aProcess.setComando(aProcessInfo.getCommand());
|
||||
aProcess.setParametri(aProcessInfo.getParams());
|
||||
|
||||
if (aProcessInfo.getEnabled())
|
||||
{
|
||||
aProcess.setModalita(CrontabCostants.STATO_PROCESSO_ABILITATO);
|
||||
}
|
||||
else
|
||||
{
|
||||
aProcess.setModalita(CrontabCostants.STATO_PROCESSO_DISABILITATO);
|
||||
|
||||
// task associati
|
||||
}
|
||||
aProcess.setVectorTask(getTaskAssociati(aProcessInfo.getTaskRefs()));
|
||||
// processi bloccanti
|
||||
aProcess.setVectorProcessi(getProcessiBloccanti(taskManagerMonitor,aProcessInfo.getBlockingProcessList()));
|
||||
|
||||
return aProcess;
|
||||
}
|
||||
|
||||
public static String getLabelIntervalli(Vector intervalli)
|
||||
{
|
||||
/// metodo per il ritorno degli intervalli
|
||||
/// formato label
|
||||
String label = "";
|
||||
IntervalloAttivazione aIntervallo;
|
||||
|
||||
for (int i = 0; i < intervalli.size(); i++)
|
||||
{
|
||||
aIntervallo = (IntervalloAttivazione) intervalli.elementAt(i);
|
||||
label = label + aIntervallo.costruisciLabel(aIntervallo) + "<br>";
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
public static Vector getIntervalliAttivazione(Iterator WindowsList)
|
||||
{
|
||||
Vector intervalli = new Vector();
|
||||
IntervalloAttivazione aIntervallo;
|
||||
DecimalFormat decFormat = new DecimalFormat("##");
|
||||
//SimpleDateFormat giornoMeseFormat = new SimpleDateFormat("dd");
|
||||
Hashtable tableRegoleAttivazione = new Hashtable();
|
||||
while (WindowsList.hasNext())
|
||||
{
|
||||
// aIntervallo = new IntervalloAttivazione();
|
||||
// TaskInfo.DayWindowTime daySched = (TaskInfo.DayWindowTime) WindowsList.next();
|
||||
RegolaAttivazione regolaAttiv = (RegolaAttivazione) WindowsList.next();
|
||||
ArrayList listDay = (ArrayList)tableRegoleAttivazione.get(regolaAttiv.getIdRule());
|
||||
if(listDay == null)
|
||||
{
|
||||
listDay = new ArrayList();
|
||||
tableRegoleAttivazione.put(regolaAttiv.getIdRule(), listDay);
|
||||
}
|
||||
listDay.add(regolaAttiv);
|
||||
|
||||
//aIntervallo.setGiorno(regolaAttiv.getStartDayOfWeek());
|
||||
|
||||
/*
|
||||
aIntervallo.setGiornoStop(regolaAttiv.getStopDayOfWeek());
|
||||
aIntervallo.setGiornoMese(decFormat.format(regolaAttiv.getStartDayOfMonth()));
|
||||
aIntervallo.setGiornoMeseStop(decFormat.format(regolaAttiv.getStopDayOfMonth()));
|
||||
aIntervallo.setOraFrom(orario.format(regolaAttiv.getStartTime().getTime()));
|
||||
aIntervallo.setOraTo(orario.format(regolaAttiv.getStopTime().getTime()));
|
||||
aIntervallo.setEveryPeriodo("" + regolaAttiv.getEvery());
|
||||
aIntervallo.setHourFrom(aIntervallo.getOraFrom().substring(0,2));
|
||||
aIntervallo.setMinutiFrom(aIntervallo.getOraFrom().substring(3,5));
|
||||
aIntervallo.setHourTo(aIntervallo.getOraTo().substring(0,2));
|
||||
aIntervallo.setMinutiTo(aIntervallo.getOraTo().substring(3,5));
|
||||
*/
|
||||
}
|
||||
for (Iterator i = tableRegoleAttivazione.keySet().iterator(); i.hasNext(); ) {
|
||||
ArrayList item = (ArrayList) tableRegoleAttivazione.get(i.next());
|
||||
if(item.size()<1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
aIntervallo = new IntervalloAttivazione();
|
||||
RegolaAttivazione ra = (RegolaAttivazione) item.get(0);
|
||||
aIntervallo.setIdIntervallo(ra.getIdRule());
|
||||
aIntervallo.setDeadline("" + ra.getMaxExecFromLastStart());
|
||||
aIntervallo.setGiornoMese(decFormat.format(ra.getStartDayOfMonth()));
|
||||
aIntervallo.setOraFrom(orario.format(ra.getStartTime().getTime()));
|
||||
|
||||
aIntervallo.setEveryPeriodo("" + ra.getEvery());
|
||||
aIntervallo.setHourFrom(aIntervallo.getOraFrom().substring(0, 2));
|
||||
aIntervallo.setMinutiFrom(aIntervallo.getOraFrom().substring(3, 5));
|
||||
|
||||
if (ra.getLastStartTime() != null)
|
||||
{
|
||||
aIntervallo.setOraTo(orario.format(ra.getLastStartTime().getTime()));
|
||||
aIntervallo.setHourTo(aIntervallo.getOraTo().substring(0, 2));
|
||||
aIntervallo.setMinutiTo(aIntervallo.getOraTo().substring(3, 5));
|
||||
}
|
||||
|
||||
if (aIntervallo.getGiornoMese().equals("0"))
|
||||
{
|
||||
/* if(item.size()>=1)
|
||||
{*/
|
||||
String[] giorniSett = new String[item.size()];
|
||||
for (int j = 0; j < item.size(); j++) {
|
||||
giorniSett[j] = ((RegolaAttivazione)item.get(j)).getStartDayOfWeek();
|
||||
}
|
||||
aIntervallo.setGiorniSettimana(giorniSett);
|
||||
}
|
||||
if (aIntervallo.getGiorniSettimana()!= null)
|
||||
aIntervallo.setGiorno(aIntervallo.costruisciLabelGiorno(aIntervallo.getGiorniSettimana()));
|
||||
else
|
||||
aIntervallo.setGiorno(aIntervallo.getGiornoMese());
|
||||
|
||||
intervalli.add(aIntervallo);
|
||||
}
|
||||
return intervalli;
|
||||
}
|
||||
|
||||
public static Vector getProcessiAssociati(ArrayList processList)
|
||||
{
|
||||
//processList = listaProcessiOrdinatiRef(processList);
|
||||
Vector processi = new Vector();
|
||||
ProcessBean aProcess;
|
||||
TaskInfo.ProcessInfoRef aProcessInfo = null;
|
||||
|
||||
for (int i = 0; i < processList.size(); i++)
|
||||
{
|
||||
aProcess = new ProcessBean();
|
||||
aProcessInfo = (TaskInfo.ProcessInfoRef) processList.get(i);
|
||||
aProcess.setProcessId(aProcessInfo.getProcess().getId());
|
||||
aProcess.setNome(aProcessInfo.getProcess().getName());
|
||||
/// stato abilitato o disabilitato
|
||||
if (aProcessInfo.isEnabled())
|
||||
{
|
||||
aProcess.setStatoProcesso(CrontabCostants.STATO_PROCESSO_ABILITATO);
|
||||
}
|
||||
else
|
||||
{
|
||||
aProcess.setStatoProcesso(CrontabCostants.STATO_PROCESSO_DISABILITATO);
|
||||
|
||||
//aProcess.setStatoUscita("MAnca in process info");
|
||||
|
||||
}
|
||||
processi.add(aProcess);
|
||||
}
|
||||
|
||||
return processi;
|
||||
|
||||
}
|
||||
|
||||
// C.P ritorna il vettore dei processi bloccanti
|
||||
/**
|
||||
*
|
||||
* @param processList ArrayList di ProcessBean
|
||||
* @return Vector
|
||||
*/
|
||||
public static Vector getProcessiBloccanti(TaskManagerMBean taskManagerMonitor,ArrayList processList) {
|
||||
Vector processi = new Vector();
|
||||
ProcessBean aProcess;
|
||||
ProcessInfo.BlockingProcessInfoRef aProcessInfo = null;
|
||||
ProcessInfo pInfo=null;
|
||||
|
||||
for (int i = 0; i < processList.size(); i++) {
|
||||
aProcess = new ProcessBean();
|
||||
aProcessInfo = (ProcessInfo.BlockingProcessInfoRef) processList.get(i);
|
||||
pInfo = taskManagerMonitor.getProcess(aProcessInfo.getProcID());
|
||||
aProcess.setProcessId(pInfo.getId());
|
||||
aProcess.setNome(pInfo.getName());
|
||||
/// stato abilitato o disabilitato
|
||||
if (pInfo.getEnabled())
|
||||
{
|
||||
aProcess.setStatoProcesso(CrontabCostants.STATO_PROCESSO_ABILITATO);
|
||||
}
|
||||
else
|
||||
{
|
||||
aProcess.setStatoProcesso(CrontabCostants.STATO_PROCESSO_DISABILITATO);
|
||||
|
||||
//aProcess.setStatoUscita("MAnca in process info");
|
||||
|
||||
}
|
||||
processi.add(aProcess);
|
||||
}
|
||||
|
||||
return processi;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Vector getTaskAssociati(TaskInfoList aTaskList)
|
||||
{
|
||||
|
||||
Vector ListaTask = new Vector();
|
||||
TaskBean aTask;
|
||||
TaskInfo aTaskInfo = null;
|
||||
|
||||
/* while(aTaskList.iterator().hasNext())
|
||||
{*/
|
||||
for (Iterator i = aTaskList.iterator(); i.hasNext(); )
|
||||
{
|
||||
aTaskInfo = (TaskInfo) i.next();
|
||||
aTask = new TaskBean();
|
||||
aTask.setIdTask(aTaskInfo.getId());
|
||||
aTask.setNome(aTaskInfo.getName());
|
||||
|
||||
ListaTask.add(aTask);
|
||||
}
|
||||
|
||||
return ListaTask;
|
||||
|
||||
}
|
||||
|
||||
public static Vector getProcessiDisponibili(ArrayList processList)
|
||||
{
|
||||
processList=listaProcessiOrdinati(processList);
|
||||
Vector processi = new Vector();
|
||||
ProcessBean aProcess;
|
||||
ProcessInfo aProcessInfo = null;
|
||||
|
||||
for (int i = 0; i < processList.size(); i++)
|
||||
{
|
||||
aProcess = new ProcessBean();
|
||||
aProcessInfo = (ProcessInfo) processList.get(i);
|
||||
aProcess.setProcessId(aProcessInfo.getId());
|
||||
aProcess.setNome(aProcessInfo.getName());
|
||||
/// stato abilitato o disabilitato
|
||||
if (aProcessInfo.getEnabled())
|
||||
{
|
||||
aProcess.setStatoProcesso(CrontabCostants.STATO_PROCESSO_ABILITATO);
|
||||
}
|
||||
else
|
||||
{
|
||||
aProcess.setStatoProcesso(CrontabCostants.STATO_PROCESSO_DISABILITATO);
|
||||
|
||||
}
|
||||
aProcess.setStatoUscita("MAnca in process info");
|
||||
|
||||
processi.add(aProcess);
|
||||
}
|
||||
|
||||
return processi;
|
||||
|
||||
}
|
||||
|
||||
public static ProcessInfo formatterProcessToProcessInfo(TaskManagerMBean taskManagerMonitor,ProcessBean aProcess)
|
||||
{
|
||||
boolean stato = false;
|
||||
if (aProcess.getStatoProcesso().equals(CrontabCostants.
|
||||
STATO_PROCESSO_ABILITATO))
|
||||
{
|
||||
stato = true;
|
||||
|
||||
// ProcessInfo aProcessInfo=new ProcessInfo(aProcess.getProcessId(),aProcess.getNome(),"","","",stato);
|
||||
}
|
||||
ProcessInfo aProcessInfo = taskManagerMonitor.getProcess(aProcess.getProcessId());
|
||||
//carlo remmato per non sisabilitare completamente un processo
|
||||
//quando disabilito un processo interno ad un task
|
||||
//aProcessInfo.setEneabled(stato);
|
||||
|
||||
return aProcessInfo;
|
||||
}
|
||||
|
||||
public static Iterator formatterIntervalliToRegoleAttivazioneIterator(IntervalloAttivazione ia)
|
||||
{
|
||||
return new IntervalloRegoleAttivazioneIterator(ia);
|
||||
}
|
||||
|
||||
public static RegolaAttivazione formatterIntervalliToRegolaAttivazione(
|
||||
IntervalloAttivazione ia)
|
||||
{
|
||||
|
||||
RegolaAttivazione res = null;
|
||||
if (ia.getHourTo() == null || ia.getHourTo().equals(""))
|
||||
res = new RegolaAttivazione(ia.getIdIntervallo(), null, Short.parseShort(ia.getGiornoMese()),
|
||||
new short[]{Short.parseShort(ia.getHourFrom()),Short.parseShort(ia.getMinutiFrom()), 0, 0},
|
||||
null,
|
||||
Integer.parseInt(ia.getEveryPeriodo()),
|
||||
Integer.parseInt(ia.getDeadline()));
|
||||
|
||||
else
|
||||
res = new RegolaAttivazione(ia.getIdIntervallo(), null, Short.parseShort(ia.getGiornoMese()),
|
||||
new short[]{Short.parseShort(ia.getHourFrom()),Short.parseShort(ia.getMinutiFrom()), 0, 0},
|
||||
new short[]{Short.parseShort(ia.getHourTo()), Short.parseShort(ia.getMinutiTo()), 0, 0},
|
||||
Integer.parseInt(ia.getEveryPeriodo()),
|
||||
Integer.parseInt(ia.getDeadline()));
|
||||
|
||||
return res;
|
||||
|
||||
/*
|
||||
/// orario partenza
|
||||
short[] from =
|
||||
{Short.parseShort(aIntervallo.getHourFrom()),
|
||||
Short.parseShort(aIntervallo.getMinutiFrom()), 0, 0};
|
||||
/// orario ultima partenza se non indicata va il valore vuoto o il valore di partenza
|
||||
// short[] to = {Short.parseShort(aIntervallo.getHourTo()), Short.parseShort(aIntervallo.getMinutiTo()), 0, 0};
|
||||
/// periodo
|
||||
int every = Integer.parseInt(aIntervallo.getEveryPeriodo());
|
||||
/// deadline
|
||||
//inserire regola di deadline aIntervallo.getDeadLine()
|
||||
|
||||
short startDayOfMonth = (aIntervallo.getGiornoMese().equals("")) ? 0 :
|
||||
Short.parseShort(aIntervallo.getGiornoMese());
|
||||
|
||||
// eliminare stopDay
|
||||
// short stopDayOfMonth = (aIntervallo.getGiornoMeseStop().equals(""))? 0: Short.parseShort(aIntervallo.getGiornoMeseStop());
|
||||
|
||||
// da riattivare con le nuove regole
|
||||
// RegolaAttivazione ra=new RegolaAttivazione(from, to, every, aIntervallo.getGiorno(),
|
||||
// startDayOfMonth, aIntervallo.getGiornoStop(), stopDayOfMonth);
|
||||
|
||||
return new RegolaAttivazione();*/
|
||||
}
|
||||
public static ArrayList listaProcessiOrdinati(ArrayList listaProcessi)
|
||||
{
|
||||
|
||||
// ordino la lista
|
||||
Collections.sort(listaProcessi, new Comparator()
|
||||
{
|
||||
public int compare(Object o1, Object o2)
|
||||
{
|
||||
ProcessInfo t1 = (ProcessInfo) o1;
|
||||
ProcessInfo t2 = (ProcessInfo) o2;
|
||||
int res = (t1.getName().compareTo(t2.getName()));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return this.getClass().equals(o.getClass());
|
||||
}
|
||||
});
|
||||
// FINE ordino la lista
|
||||
|
||||
return listaProcessi;
|
||||
}
|
||||
|
||||
public static ArrayList listaTaskOrdinati(ArrayList listaTask)
|
||||
{
|
||||
|
||||
// ordino la lista
|
||||
Collections.sort(listaTask, new Comparator()
|
||||
{
|
||||
public int compare(Object o1, Object o2)
|
||||
{
|
||||
TaskInfo t1 = (TaskInfo) o1;
|
||||
TaskInfo t2 = (TaskInfo) o2;
|
||||
int res = (t1.getName().compareTo(t2.getName()));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return this.getClass().equals(o.getClass());
|
||||
}
|
||||
});
|
||||
// FINE ordino la lista
|
||||
|
||||
return listaTask;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList listaProcessiOrdinatiRef(ArrayList listaProcessi)
|
||||
{
|
||||
|
||||
// ordino la lista
|
||||
Collections.sort(listaProcessi, new Comparator()
|
||||
{
|
||||
public int compare(Object o1, Object o2)
|
||||
{
|
||||
TaskInfo.ProcessInfoRef t1 = (TaskInfo.ProcessInfoRef) o1;
|
||||
TaskInfo.ProcessInfoRef t2 = (TaskInfo.ProcessInfoRef) o2;
|
||||
int res = (t1.getProcess().getName().compareTo(t2.getProcess().getName()));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return this.getClass().equals(o.getClass());
|
||||
}
|
||||
});
|
||||
// FINE ordino la lista
|
||||
|
||||
return listaProcessi;
|
||||
}
|
||||
|
||||
public static DayOfWeekType formatterDayToWeek(String day)
|
||||
{
|
||||
//day bisogna passargli Lun;Mar;Mer;Gio;Ven;Sab;Dom
|
||||
|
||||
DayOfWeekType dayWeek = null;
|
||||
|
||||
return dayWeek.fromValue(day);
|
||||
}
|
||||
|
||||
public static class IntervalloRegoleAttivazioneIterator implements Iterator
|
||||
{
|
||||
IntervalloAttivazione ia = null;
|
||||
String[] giorniDellaSettimana = null;
|
||||
int idx = 0;
|
||||
boolean bEnd = false;
|
||||
public IntervalloRegoleAttivazioneIterator(IntervalloAttivazione ia)
|
||||
{
|
||||
this.ia = ia;
|
||||
giorniDellaSettimana = ia.getGiorniSettimana();
|
||||
idx = 0;
|
||||
if(giorniDellaSettimana != null)
|
||||
{
|
||||
bEnd = idx >= giorniDellaSettimana.length;
|
||||
}
|
||||
}
|
||||
|
||||
public Object next()
|
||||
{
|
||||
RegolaAttivazione res = null;
|
||||
if((giorniDellaSettimana == null || giorniDellaSettimana.length == 0) && (ia.getGiornoMese() != null || ia.getGiornoMese().length()>0))
|
||||
{
|
||||
if (ia.getHourTo() == null || ia.getHourTo().equals(""))
|
||||
res = new RegolaAttivazione(ia.getIdIntervallo(), null, Short.parseShort(ia.getGiornoMese()),
|
||||
new short[]{Short.parseShort(ia.getHourFrom()),Short.parseShort(ia.getMinutiFrom()), 0, 0},
|
||||
null,
|
||||
Integer.parseInt(ia.getEveryPeriodo()),
|
||||
Integer.parseInt(ia.getDeadline()));
|
||||
|
||||
else
|
||||
res = new RegolaAttivazione(ia.getIdIntervallo(), null, Short.parseShort(ia.getGiornoMese()),
|
||||
new short[]{Short.parseShort(ia.getHourFrom()),Short.parseShort(ia.getMinutiFrom()), 0, 0},
|
||||
new short[]{Short.parseShort(ia.getHourTo()), Short.parseShort(ia.getMinutiTo()), 0, 0},
|
||||
Integer.parseInt(ia.getEveryPeriodo()),
|
||||
Integer.parseInt(ia.getDeadline()));
|
||||
bEnd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ia.getHourTo()==null || ia.getHourTo().equals(""))
|
||||
res = new RegolaAttivazione(ia.getIdIntervallo(), giorniDellaSettimana[idx], (short)0,
|
||||
new short[]{Short.parseShort(ia.getHourFrom()),Short.parseShort(ia.getMinutiFrom()), 0, 0},
|
||||
null,
|
||||
Integer.parseInt(ia.getEveryPeriodo()),
|
||||
Integer.parseInt(ia.getDeadline()));
|
||||
|
||||
else
|
||||
res = new RegolaAttivazione(ia.getIdIntervallo(), giorniDellaSettimana[idx], (short)0,
|
||||
new short[]{Short.parseShort(ia.getHourFrom()),Short.parseShort(ia.getMinutiFrom()), 0, 0},
|
||||
new short[]{Short.parseShort(ia.getHourTo()), Short.parseShort(ia.getMinutiTo()), 0, 0},
|
||||
Integer.parseInt(ia.getEveryPeriodo()),
|
||||
Integer.parseInt(ia.getDeadline()));
|
||||
idx++;
|
||||
bEnd = idx >= giorniDellaSettimana.length;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public boolean hasNext()
|
||||
{
|
||||
return !bEnd;
|
||||
}
|
||||
public void remove()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,631 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
/**
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
/// oggetti java
|
||||
import java.util.*;
|
||||
|
||||
import org.exolab.castor.types.*;
|
||||
import mnp.crontab.config.am.*;
|
||||
import mnp.crontab.config.gestioneXml.*;
|
||||
import mnp.crontab.config.lnternalSystemXml.*;
|
||||
import mnp.crontab.config.lnternalSystemXml.SistemiInterni;
|
||||
import mnp.crontab.objects.am.*;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
|
||||
//import mnp.crontab.config.gestioneXml.;
|
||||
|
||||
public class FormatterCommandApplication {
|
||||
static java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat(
|
||||
"dd-MMMMM-yyyy HH:mm");
|
||||
static java.text.SimpleDateFormat orario = new java.text.SimpleDateFormat(
|
||||
"HH:mm");
|
||||
public FormatterCommandApplication() {
|
||||
}
|
||||
|
||||
public static XMLObject formattaXMLObject_TO_XMLGestioneConfig(
|
||||
XmlControllerWrapper
|
||||
aXMLGestioneConfig) {
|
||||
XMLObject aXMLObject = new XMLObject();
|
||||
FileInfo aFile = null;
|
||||
FileInfoAck aFileAck = null;
|
||||
ArrayList aL = new ArrayList();
|
||||
|
||||
aXMLObject.setAbilitazione(aXMLGestioneConfig.isAbilitato());
|
||||
aXMLObject.setNroRichieste(String.valueOf(aXMLGestioneConfig.
|
||||
get_nroReqWrapper()));
|
||||
aXMLObject.setMaxTempoAttesa(String.valueOf(aXMLGestioneConfig.get_maxTime()));
|
||||
|
||||
// LISTA FILE INFO
|
||||
for (int i = 0; i < aXMLGestioneConfig.getListaFileInfo().size(); i++) {
|
||||
aFile = new FileInfo();
|
||||
InfoFile iF = (InfoFile) aXMLGestioneConfig.getListaFileInfo().
|
||||
get(i);
|
||||
aFile.setIdFile(String.valueOf(iF.getFileID()));
|
||||
aFile.setNome(iF.getName());
|
||||
aFile.setDescrizione(iF.getDesc());
|
||||
|
||||
ListOperatore aListOperator = (ListOperatore) iF.getListOperatore();
|
||||
|
||||
/// Controllo la Lista degli Operatori
|
||||
if (aListOperator.getListOperatoreItemCount() != 0) {
|
||||
aFile.setListaOperatori(formattaListaOperatori(aListOperator));
|
||||
aFile.setLabelOperatori(componiLabel("O", aFile.getListaOperatori()));
|
||||
}
|
||||
else {
|
||||
aFile.setLabelOperatori(" ");
|
||||
aFile.setListaOperatori(new ArrayList());
|
||||
}
|
||||
|
||||
/// Controllo la Lista delle Schedulazioni
|
||||
Schedulation aListSchedulation = (Schedulation) iF.getSchedulation();
|
||||
|
||||
if (aListSchedulation.getSchedulationItemCount() != 0) {
|
||||
aFile.setListaSchedulazione(formattaListaSchedulazione(
|
||||
aListSchedulation));
|
||||
aFile.setLabelSchedulazione(componiLabel("S",
|
||||
aFile.getListaSchedulazione()));
|
||||
}
|
||||
else {
|
||||
aFile.setLabelSchedulazione(" ");
|
||||
aFile.setListaSchedulazione(new ArrayList());
|
||||
}
|
||||
|
||||
/// Controllo la Lista dei Processi-Priorità
|
||||
Priority aListPriority = (Priority) iF.getPriority();
|
||||
|
||||
if (aListPriority.getPriorityItemCount() != 0) {
|
||||
aFile.setListaPriorita(formattaListaPriorita(
|
||||
aListPriority));
|
||||
aFile.setLabelProcessiPriorita(componiLabel("P",
|
||||
aFile.getListaPriorita()));
|
||||
}
|
||||
else {
|
||||
aFile.setLabelProcessiPriorita(" ");
|
||||
aFile.setListaPriorita(new ArrayList());
|
||||
}
|
||||
|
||||
/// Controllo la Lista dei Processi-Priorità di ingresso
|
||||
PriorityIn aListPriorityIn = (PriorityIn) iF.getPriorityIn();
|
||||
|
||||
if (aListPriorityIn.getPriorityInItemCount() != 0) {
|
||||
aFile.setListaPrioritaIn(formattaListaPrioritaIn(
|
||||
aListPriorityIn));
|
||||
aFile.setLabelProcessiPrioritaIn(componiLabel("P",
|
||||
aFile.getListaPrioritaIn()));
|
||||
}
|
||||
else {
|
||||
aFile.setLabelProcessiPrioritaIn(" ");
|
||||
aFile.setListaPrioritaIn(new ArrayList());
|
||||
}
|
||||
|
||||
|
||||
aL.add(aFile);
|
||||
}
|
||||
|
||||
aXMLObject.setListaFile(aL);
|
||||
// FINE LISTA FILE INFO
|
||||
aL = new ArrayList();
|
||||
// LISTA FILE ACK
|
||||
for (int i = 0; i < aXMLGestioneConfig.getListaFileAck().size(); i++) {
|
||||
aFileAck = new FileInfoAck();
|
||||
InfoFileAck iF_Ack = (InfoFileAck) aXMLGestioneConfig.getListaFileAck().
|
||||
get(i);
|
||||
aFileAck.setIdFile(String.valueOf(iF_Ack.getFileID()));
|
||||
aFileAck.setNome(iF_Ack.getName());
|
||||
aFileAck.setDescrizione(iF_Ack.getFileRef());
|
||||
|
||||
ListOperatore aListOperator = (ListOperatore) iF_Ack.getListOperatore();
|
||||
|
||||
/// Controllo la Lista degli Operatori
|
||||
if (aListOperator.getListOperatoreItemCount() != 0) {
|
||||
aFileAck.setListaOperatori(formattaListaOperatori(aListOperator));
|
||||
aFileAck.setLabelOperatori(componiLabel("O", aFileAck.getListaOperatori()));
|
||||
}
|
||||
else {
|
||||
aFileAck.setLabelOperatori(" ");
|
||||
aFileAck.setListaOperatori(new ArrayList());
|
||||
}
|
||||
|
||||
Schedulation aListSchedulation = (Schedulation) iF_Ack.getSchedulation();
|
||||
|
||||
if (aListSchedulation.getSchedulationItemCount() != 0) {
|
||||
aFileAck.setListaSchedulazione(formattaListaSchedulazione(
|
||||
aListSchedulation));
|
||||
aFileAck.setLabelSchedulazione(componiLabel("S",
|
||||
aFileAck.getListaSchedulazione()));
|
||||
}
|
||||
else {
|
||||
aFileAck.setLabelSchedulazione(" ");
|
||||
aFileAck.setListaSchedulazione(new ArrayList());
|
||||
}
|
||||
|
||||
/// Controllo la Lista dei Processi-Priorità
|
||||
Priority aListPriority = (Priority) iF_Ack.getPriority();
|
||||
|
||||
if (aListPriority.getPriorityItemCount() != 0) {
|
||||
aFileAck.setListaPriorita(formattaListaPriorita(
|
||||
aListPriority));
|
||||
aFileAck.setLabelProcessiPriorita(componiLabel("P",
|
||||
aFileAck.getListaPriorita()));
|
||||
}
|
||||
else {
|
||||
aFileAck.setLabelProcessiPriorita(" ");
|
||||
aFileAck.setListaPriorita(new ArrayList());
|
||||
}
|
||||
|
||||
aL.add(aFileAck);
|
||||
}
|
||||
|
||||
aXMLObject.setListaFileAck(aL);
|
||||
// FINE LISTA FILE ACK
|
||||
|
||||
return aXMLObject;
|
||||
}
|
||||
|
||||
public static ArrayList formattaSistemiInterni_TO_ArrayList(ArrayList
|
||||
aList) {
|
||||
|
||||
ArrayList aSistemi = new ArrayList();
|
||||
ItemBean aItem;
|
||||
InfoSistema aSistItem;
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
aItem = new ItemBean();
|
||||
aSistItem = (InfoSistema) aList.get(i);
|
||||
aItem.setLabels(aSistItem.getName());
|
||||
aItem.setValues(aSistItem.getSistemId());
|
||||
aItem.setValuesBoolean(aSistItem.getEnabled());
|
||||
aSistemi.add(aItem);
|
||||
}
|
||||
return aSistemi;
|
||||
}
|
||||
|
||||
public static String componiLabel(String _tipo, ArrayList aList) {
|
||||
String _label = "";
|
||||
IntervalloAttivazione ia;
|
||||
ItemBean ib;
|
||||
TipoProcesso tp;
|
||||
|
||||
if (_tipo.equals("S")) {
|
||||
// label schedulazione
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
ia = (IntervalloAttivazione) aList.get(i);
|
||||
_label = _label + ia.getOraFrom() + " - " +
|
||||
ia.getOraTo() + "<BR>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (_tipo.equals("O")) {
|
||||
// label Operatore
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
ib = (ItemBean) aList.get(i);
|
||||
if (ib.isValuesBoolean())
|
||||
_label = _label + ib.getLabels() + "<BR>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (_tipo.equals("P")) {
|
||||
// label Priorità-Processo
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
tp = (TipoProcesso) aList.get(i);
|
||||
_label = _label + "<B>"+tp.getNomeProcesso()+"</B> - "+tp.getDescPriorita() + "<BR>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return _label;
|
||||
|
||||
}
|
||||
|
||||
public static ArrayList formattaListaOperatori(ListOperatore aList) {
|
||||
ArrayList aL = new ArrayList();
|
||||
InfoOperatore io = new InfoOperatore();
|
||||
ItemBean ib;
|
||||
|
||||
// Creo la lista di Operatori
|
||||
for (int i = 0; i < aList.getListOperatoreItemCount(); i++) {
|
||||
io = (InfoOperatore) aList.getListOperatoreItem(i).getInfoOperatore();
|
||||
ib = new ItemBean();
|
||||
ib.setLabels(io.getName());
|
||||
ib.setValuesInt(Integer.parseInt(io.getOperatoreID()));
|
||||
ib.setValues(io.getDesc_olo());
|
||||
ib.setValuesBoolean(io.getEnabled());
|
||||
|
||||
aL.add(ib);
|
||||
}
|
||||
|
||||
return aL;
|
||||
}
|
||||
|
||||
public static ArrayList formattaListaSchedulazione(Schedulation aList) {
|
||||
ArrayList aL = new ArrayList();
|
||||
WindowsTime io = new WindowsTime();
|
||||
IntervalloAttivazione ib;
|
||||
|
||||
// Creo la lista di Operatori
|
||||
for (int i = 0; i < aList.getSchedulationItemCount(); i++) {
|
||||
io = (WindowsTime) aList.getSchedulationItem(i).getWindowsTime();
|
||||
ib = new IntervalloAttivazione();
|
||||
ib.setOraFrom(orario.format(io.getStartAt().toCalendar().getTime()));
|
||||
// ib.setMinutiFrom(io.getStartAt());
|
||||
ib.setOraTo(orario.format(io.getLastStart().toCalendar().getTime()));
|
||||
// ib.setMinutiTo(io.getLastStart());
|
||||
ib.setIdIntervallo(io.getIdRule());
|
||||
|
||||
aL.add(ib);
|
||||
}
|
||||
|
||||
return aL;
|
||||
}
|
||||
|
||||
public static ArrayList formattaListaPriorita(Priority aList) {
|
||||
ArrayList aL = new ArrayList();
|
||||
ProcessType pt = new ProcessType();
|
||||
TipoProcesso ib;
|
||||
|
||||
// Creo la lista di Operatori
|
||||
for (int i = 0; i < aList.getPriorityItemCount(); i++) {
|
||||
pt = (ProcessType) aList.getPriorityItem(i).getProcessType();
|
||||
ib = new TipoProcesso();
|
||||
// Nome Processo
|
||||
ib.setNomeProcesso(pt.getProcessName());
|
||||
// Codice Processo
|
||||
ib.setCodiceProcesso(pt.getProcessID());
|
||||
// Priorità Processo
|
||||
ib.setCodicePriorita(pt.getValuePriority());
|
||||
// Descrizione Priorità
|
||||
ib.setDescPriorita(getDescrizionePriorita(pt.getValuePriority()));
|
||||
|
||||
aL.add(ib);
|
||||
}
|
||||
|
||||
return aL;
|
||||
}
|
||||
|
||||
public static ArrayList formattaListaPrioritaIn(PriorityIn aList) {
|
||||
ArrayList aL = new ArrayList();
|
||||
ProcessType pt = new ProcessType();
|
||||
TipoProcesso ib;
|
||||
|
||||
// Creo la lista di Operatori
|
||||
for (int i = 0; i < aList.getPriorityInItemCount(); i++) {
|
||||
pt = (ProcessType) aList.getPriorityInItem(i).getProcessType();
|
||||
ib = new TipoProcesso();
|
||||
// Nome Processo
|
||||
ib.setNomeProcesso(pt.getProcessName());
|
||||
// Codice Processo
|
||||
ib.setCodiceProcesso(pt.getProcessID());
|
||||
// Priorità Processo
|
||||
ib.setCodicePriorita(pt.getValuePriority());
|
||||
// Descrizione Priorità
|
||||
ib.setDescPriorita(getDescrizionePriorita(pt.getValuePriority()));
|
||||
|
||||
aL.add(ib);
|
||||
}
|
||||
|
||||
return aL;
|
||||
}
|
||||
|
||||
public static SistemiInterni formattaInternalSystem(ArrayList aList) {
|
||||
SistemiInterni aL = new SistemiInterni();
|
||||
InfoSistema aInfo;
|
||||
SistemiInterniItem aSysInt;
|
||||
ItemBean aItemBean;
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
|
||||
aItemBean = (ItemBean) aList.get(i);
|
||||
aSysInt = new SistemiInterniItem();
|
||||
aInfo = new InfoSistema();
|
||||
aInfo.setName(aItemBean.getLabels());
|
||||
aInfo.setSistemId(aItemBean.getValues());
|
||||
aInfo.setEnabled(aItemBean.isValuesBoolean());
|
||||
aSysInt.setInfoSistema(aInfo);
|
||||
aL.addSistemiInterniItem(i, aSysInt);
|
||||
}
|
||||
return aL;
|
||||
}
|
||||
|
||||
public static XmlControllerWrapper formattaWrapperXmlToXMLObject(XMLObject
|
||||
aXMLObject) {
|
||||
XmlControllerWrapper aXmlWrapper = XmlControllerWrapper.getInstance();
|
||||
ListFile _listFile = new ListFile();
|
||||
ListInfoFile aInfoList;
|
||||
ListInfoFileAck aInfoListAck;
|
||||
ListInfoFileItem aInfoFileItem;
|
||||
ListInfoFileAckItem aInfoFileAckItem;
|
||||
|
||||
/// DATI GLOBALI
|
||||
_listFile.setEnabled(aXMLObject.isAbilitazione());
|
||||
_listFile.setNroRichieste(Integer.parseInt(aXMLObject.getNroRichieste()));
|
||||
_listFile.setMaxTimeWait(Integer.parseInt(aXMLObject.getMaxTempoAttesa()));
|
||||
|
||||
/// COSTRUISCO LA LISTA DI INFOFILE
|
||||
aInfoList = getListaInfoFile(aXMLObject.getListaFile());
|
||||
aXmlWrapper.setListaFileInfo(aXMLObject.getListaFile());
|
||||
aInfoListAck = getListaInfoFileAck(aXMLObject.getListaFileAck());
|
||||
aXmlWrapper.setListaFileAck(aXMLObject.getListaFileAck());
|
||||
|
||||
// aInfoList
|
||||
_listFile.setListInfoFile(aInfoList);
|
||||
|
||||
// aInfoListACK
|
||||
_listFile.setListInfoFileAck(aInfoListAck);
|
||||
|
||||
aXmlWrapper.set_ListFile(_listFile);
|
||||
return aXmlWrapper;
|
||||
}
|
||||
|
||||
public static ListInfoFile getListaInfoFile(ArrayList aList) {
|
||||
ListInfoFile _listInfo = new ListInfoFile();
|
||||
ListInfoFileItem _listInfoItem;
|
||||
InfoFile _File;
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) { // prelevo l'oggetto da quello di Interfaccia
|
||||
FileInfo aFileObject = (FileInfo) aList.get(i);
|
||||
|
||||
// setto i vari campi
|
||||
_File = new InfoFile();
|
||||
_File.setFileID(aFileObject.getIdFile());
|
||||
_File.setDesc(aFileObject.getDescrizione());
|
||||
_File.setName(aFileObject.getNome());
|
||||
|
||||
_File.setListOperatore(getListOperatoreXML(aFileObject.getListaOperatori()));
|
||||
|
||||
_File.setSchedulation(getSchedulazioneXML(aFileObject.getListaSchedulazione()));
|
||||
|
||||
_File.setPriority(getListPrioritaXML(aFileObject.getListaPriorita()));
|
||||
_File.setPriorityIn(getListPrioritaXMLIn(aFileObject.getListaPrioritaIn()));
|
||||
|
||||
// setto l'item e la lista di Info
|
||||
_listInfoItem = new ListInfoFileItem();
|
||||
_listInfoItem.setInfoFile(_File);
|
||||
_listInfo.addListInfoFileItem(i, _listInfoItem);
|
||||
}
|
||||
return _listInfo;
|
||||
}
|
||||
|
||||
public static ListInfoFileAck getListaInfoFileAck(ArrayList aList) {
|
||||
ListInfoFileAck _listInfo = new ListInfoFileAck();
|
||||
ListInfoFileAckItem _listInfoItem;
|
||||
InfoFileAck _File;
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) { // prelevo l'oggetto da quello di Interfaccia
|
||||
FileInfoAck aFileObject = (FileInfoAck) aList.get(i);
|
||||
|
||||
// setto i vari campi
|
||||
_File = new InfoFileAck();
|
||||
_File.setFileID(aFileObject.getIdFile());
|
||||
_File.setFileRef(aFileObject.getDescrizione());
|
||||
_File.setName(aFileObject.getNome());
|
||||
|
||||
_File.setListOperatore(getListOperatoreXML(aFileObject.getListaOperatori()));
|
||||
|
||||
_File.setSchedulation(getSchedulazioneXML(aFileObject.getListaSchedulazione()));
|
||||
|
||||
_File.setPriority(getListPrioritaXML(aFileObject.getListaPriorita()));
|
||||
|
||||
// setto l'item e la lista di Info
|
||||
_listInfoItem = new ListInfoFileAckItem();
|
||||
_listInfoItem.setInfoFileAck(_File);
|
||||
_listInfo.addListInfoFileAckItem(i, _listInfoItem);
|
||||
}
|
||||
return _listInfo;
|
||||
}
|
||||
|
||||
public static ListOperatore getListOperatoreXML(ArrayList aList) {
|
||||
ListOperatore _listOperator = new ListOperatore();
|
||||
ListOperatoreItem _listOperatorItem;
|
||||
InfoOperatore _Operatore;
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) { // prelevo l'oggetto da quello di Interfaccia
|
||||
ItemBean aItem = (ItemBean) aList.get(i);
|
||||
|
||||
// setto i vari campi
|
||||
_Operatore = new InfoOperatore();
|
||||
_Operatore.setName(aItem.getLabels());
|
||||
_Operatore.setOperatoreID(String.valueOf(aItem.getValuesInt()));
|
||||
_Operatore.setDesc_olo(aItem.getValues());
|
||||
_Operatore.setEnabled(aItem.isValuesBoolean());
|
||||
|
||||
// setto l'item e la lista di Operatori
|
||||
_listOperatorItem = new ListOperatoreItem();
|
||||
_listOperatorItem.setInfoOperatore(_Operatore);
|
||||
_listOperator.addListOperatoreItem(i, _listOperatorItem);
|
||||
}
|
||||
|
||||
return _listOperator;
|
||||
}
|
||||
|
||||
public static Schedulation getSchedulazioneXML(ArrayList aList) {
|
||||
Schedulation _schedulation = new Schedulation();
|
||||
SchedulationItem _listSchedulationItem;
|
||||
WindowsTime _Wt;
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) { // prelevo l'oggetto da quello di Interfaccia
|
||||
IntervalloAttivazione aItem = (IntervalloAttivazione) aList.get(i);
|
||||
|
||||
// setto i vari campi
|
||||
_Wt = new WindowsTime();
|
||||
_Wt.setIdRule(aItem.getIdIntervallo());
|
||||
// Conversione da stringa a Time
|
||||
short[] from = new short[] {
|
||||
Short.parseShort(aItem.getOraFrom().substring(0, 2)),
|
||||
Short.parseShort(aItem.getOraFrom().substring(3, 5)), 0, 0};
|
||||
_Wt.setStartAt(new Time(from));
|
||||
short[] to = new short[] {
|
||||
Short.parseShort(aItem.getOraTo().substring(0, 2)),
|
||||
Short.parseShort(aItem.getOraTo().substring(3, 5)), 0, 0};
|
||||
_Wt.setLastStart(new Time(to));
|
||||
|
||||
// setto l'item e la lista di Schedulazioni
|
||||
_listSchedulationItem = new SchedulationItem();
|
||||
_listSchedulationItem.setWindowsTime(_Wt);
|
||||
_schedulation.addSchedulationItem(i, _listSchedulationItem);
|
||||
}
|
||||
|
||||
return _schedulation;
|
||||
}
|
||||
|
||||
public static XMLControllerConfig formattaConfigToWrapper(
|
||||
XmlControllerWrapper
|
||||
_xmlWrapper) {
|
||||
|
||||
XMLControllerConfig _xmlController = new XMLControllerConfig();
|
||||
_xmlController.setAbilitazione(_xmlWrapper.isAbilitato());
|
||||
_xmlController.setMaxRequests(_xmlWrapper.get_nroReqWrapper());
|
||||
_xmlController.setMaxTimeOut(_xmlWrapper.get_maxTime());
|
||||
ArrayList aL = formattaListaFile(_xmlWrapper.get_ListFile().getListInfoFile());
|
||||
_xmlController.setListFile(aL);
|
||||
ArrayList aLAck = formattaListaFileAck(_xmlWrapper.get_ListFile().
|
||||
getListInfoFileAck());
|
||||
_xmlController.setListFileAck(aLAck);
|
||||
|
||||
return _xmlController;
|
||||
}
|
||||
|
||||
public static ArrayList formattaListaFile(ListInfoFile aList) {
|
||||
ArrayList aL = new ArrayList();
|
||||
FileInfo aFile;
|
||||
// LISTA FILE INFO
|
||||
for (int i = 0; i < aList.getListInfoFileItemCount(); i++) {
|
||||
aFile = new FileInfo();
|
||||
InfoFile iF = (InfoFile) aList.getListInfoFileItem(i).getInfoFile();
|
||||
|
||||
aFile.setIdFile(String.valueOf(iF.getFileID()));
|
||||
aFile.setNome(iF.getName());
|
||||
aFile.setDescrizione(iF.getDesc());
|
||||
|
||||
ListOperatore aListOperator = (ListOperatore) iF.getListOperatore();
|
||||
|
||||
/// Controllo la Lista degli Operatori
|
||||
|
||||
aFile.setListaOperatori(formattaListaOperatori(aListOperator));
|
||||
aFile.setLabelOperatori(componiLabel("O", aFile.getListaOperatori()));
|
||||
|
||||
/// Controllo la Schedulazione
|
||||
Schedulation aListSchedulation = (Schedulation) iF.getSchedulation();
|
||||
|
||||
aFile.setListaSchedulazione(formattaListaSchedulazione(aListSchedulation));
|
||||
aFile.setLabelSchedulazione(componiLabel("S",aFile.getListaSchedulazione()));
|
||||
|
||||
/// Controllo la Priorità
|
||||
Priority aListPriorita = (Priority) iF.getPriority();
|
||||
|
||||
aFile.setListaPriorita(formattaListaPriorita(aListPriorita));
|
||||
aFile.setLabelProcessiPriorita(componiLabel("P",aFile.getListaPriorita()));
|
||||
|
||||
/// Controllo la Priorità ingresso
|
||||
PriorityIn aListPrioritaIn = (PriorityIn) iF.getPriorityIn();
|
||||
|
||||
aFile.setListaPrioritaIn(formattaListaPrioritaIn(aListPrioritaIn));
|
||||
aFile.setLabelProcessiPrioritaIn(componiLabel("P",aFile.getListaPrioritaIn()));
|
||||
|
||||
aL.add(aFile);
|
||||
}
|
||||
|
||||
return aL;
|
||||
}
|
||||
|
||||
public static Priority getListPrioritaXML(ArrayList aList) {
|
||||
Priority _priority = new Priority();
|
||||
PriorityItem _listPriorityItem;
|
||||
ProcessType _pt;
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) { // prelevo l'oggetto da quello di Interfaccia
|
||||
TipoProcesso aItem = (TipoProcesso) aList.get(i);
|
||||
|
||||
// setto i vari campi
|
||||
_pt = new ProcessType();
|
||||
_pt.setProcessName(aItem.getNomeProcesso());
|
||||
_pt.setProcessID(aItem.getCodiceProcesso());
|
||||
_pt.setValuePriority(aItem.getCodicePriorita());
|
||||
|
||||
// setto l'item e la lista di Schedulazioni
|
||||
_listPriorityItem = new PriorityItem();
|
||||
_listPriorityItem.setProcessType(_pt);
|
||||
_priority.addPriorityItem(i, _listPriorityItem);
|
||||
}
|
||||
|
||||
return _priority;
|
||||
}
|
||||
|
||||
public static PriorityIn getListPrioritaXMLIn(ArrayList aList) {
|
||||
PriorityIn _priority = new PriorityIn();
|
||||
PriorityInItem _listPriorityItem;
|
||||
ProcessType _pt;
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) { // prelevo l'oggetto da quello di Interfaccia
|
||||
TipoProcesso aItem = (TipoProcesso) aList.get(i);
|
||||
|
||||
// setto i vari campi
|
||||
_pt = new ProcessType();
|
||||
_pt.setProcessName(aItem.getNomeProcesso());
|
||||
_pt.setProcessID(aItem.getCodiceProcesso());
|
||||
_pt.setValuePriority(aItem.getCodicePriorita());
|
||||
|
||||
// setto l'item e la lista di Schedulazioni
|
||||
_listPriorityItem = new PriorityInItem();
|
||||
_listPriorityItem.setProcessType(_pt);
|
||||
_priority.addPriorityInItem(i, _listPriorityItem);
|
||||
}
|
||||
|
||||
return _priority;
|
||||
}
|
||||
|
||||
public static String getDescrizionePriorita(int valuePrority) {
|
||||
|
||||
if (valuePrority == XMLControllerConfigIF.BASSA)
|
||||
return TipoProcesso.BASSA_PRIORITA;
|
||||
if (valuePrority == XMLControllerConfigIF.NORMALE)
|
||||
return TipoProcesso.NORMALE_PRIORITA;
|
||||
if (valuePrority == XMLControllerConfigIF.ALTA)
|
||||
return TipoProcesso.ALTA_PRIORITA;
|
||||
return "";
|
||||
}
|
||||
|
||||
public static ArrayList formattaListaFileAck(ListInfoFileAck aList) {
|
||||
ArrayList aL = new ArrayList();
|
||||
FileInfoAck aFile;
|
||||
// LISTA FILE INFO
|
||||
for (int i = 0; i < aList.getListInfoFileAckItemCount(); i++) {
|
||||
aFile = new FileInfoAck();
|
||||
InfoFileAck iF = (InfoFileAck) aList.getListInfoFileAckItem(i).getInfoFileAck();
|
||||
|
||||
aFile.setIdFile(String.valueOf(iF.getFileID()));
|
||||
aFile.setNome(iF.getName());
|
||||
aFile.setDescrizione(iF.getFileRef());
|
||||
|
||||
ListOperatore aListOperator = (ListOperatore) iF.getListOperatore();
|
||||
|
||||
/// Controllo la Lista degli Operatori
|
||||
|
||||
aFile.setListaOperatori(formattaListaOperatori(aListOperator));
|
||||
aFile.setLabelOperatori(componiLabel("O", aFile.getListaOperatori()));
|
||||
|
||||
/// Controllo la Schedulazione
|
||||
Schedulation aListSchedulation = (Schedulation) iF.getSchedulation();
|
||||
|
||||
aFile.setListaSchedulazione(formattaListaSchedulazione(
|
||||
aListSchedulation));
|
||||
aFile.setLabelSchedulazione(componiLabel("S",
|
||||
aFile.getListaSchedulazione()));
|
||||
|
||||
/// Controllo la Priorità
|
||||
Priority aListPriorita = (Priority) iF.getPriority();
|
||||
|
||||
aFile.setListaPriorita(formattaListaPriorita(aListPriorita));
|
||||
aFile.setLabelProcessiPriorita(componiLabel("P",aFile.getListaPriorita()));
|
||||
|
||||
aL.add(aFile);
|
||||
}
|
||||
|
||||
return aL;
|
||||
}
|
||||
|
||||
}
|
||||
697
dbcmnpsrc/FE/mnpdev/crontab/src/mnp/crontab/command/Index.java
Normal file
697
dbcmnpsrc/FE/mnpdev/crontab/src/mnp/crontab/command/Index.java
Normal file
@@ -0,0 +1,697 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
/**
|
||||
@author Zagaria Massimo
|
||||
* @version 1.0
|
||||
*/
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import javax.servlet.http.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import it.valueteam.crontab.engine.exception.*;
|
||||
import it.valueteam.crontab.engine.mbean.*;
|
||||
import it.valueteam.crontab.engine.mbean.client.*;
|
||||
import it.valueteam.crontab.utility.EventTime;
|
||||
import it.valueteam.logging.*;
|
||||
import mnp.crontab.objects.*;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
import mnp.crontab.utility.*;
|
||||
|
||||
|
||||
|
||||
public class Index
|
||||
extends AbstractCommand {
|
||||
String retCommand;
|
||||
Exception myException;
|
||||
TaskManagerMBean taskManagerMonitor;
|
||||
private static Logger log = Logger.getLogger(Index.class);
|
||||
|
||||
private static final String ABILITA_GATEWAY = "?stato=y";
|
||||
private static final String DISABILITA_GATEWAY = "?stato=n";
|
||||
|
||||
public Index() {
|
||||
}
|
||||
|
||||
public String execute(HttpServletRequest request, HttpServletResponse res) throws
|
||||
Exception {
|
||||
|
||||
//log security
|
||||
Map paramLog=null;
|
||||
String objectLog="";
|
||||
Azione a = null;
|
||||
int actionCode=0;
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
// controllo se la sessione è scaduta
|
||||
if (session.isNew()) {
|
||||
session.invalidate();
|
||||
retCommand = CommandsDef.SESSIONE_INATTIVA;
|
||||
return retCommand;
|
||||
}
|
||||
|
||||
CrontabSession aCrontabSession = (CrontabSession) session.getAttribute(
|
||||
CrontabCostants.OBJECT_CRONTAB_SESSION);
|
||||
String jspName = request.getParameter("JSP_FUNCTION");
|
||||
int jspNameValue = 0;
|
||||
if(jspName==null){
|
||||
jspNameValue=CrontabCostants.FNC_APPLICATION_MANAGER;
|
||||
}
|
||||
else {
|
||||
jspNameValue=Integer.parseInt(jspName);
|
||||
}
|
||||
//prendo il taskManagerMonitor del nodo Master
|
||||
taskManagerMonitor = new TaskManagerClient(CrontabCostants.OBJECT_TASK_MANAGER_MBEAN_CLIENT);
|
||||
|
||||
switch (jspNameValue) {
|
||||
|
||||
case CrontabCostants.CMD_ABILITAZIONE_SCHED:
|
||||
|
||||
{ // ABILITAZIONE SCHEDULATORE
|
||||
// da inserire il metodo per abilitare lo schedulatore
|
||||
|
||||
actionCode=ActionLogMapping.AbilitazioneSchedulatore;
|
||||
|
||||
// prelevo l'oggetto dalla sessione
|
||||
taskManagerMonitor.start(); // taskManager partito
|
||||
|
||||
/// controllo che loschedulatore sia attivo o meno
|
||||
if (taskManagerMonitor.isAlive()) {
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA,
|
||||
CrontabCostants.ABILITA_MOTORE);
|
||||
retCommand = CommandsDef.PAGE_ESITO;
|
||||
//getListaSchedulation(session);
|
||||
//getListaTaskTimer(session);
|
||||
aCrontabSession.setStato_Schedulatore(CrontabCostants.
|
||||
STATO_SCHEDULATORE_RUNNING);
|
||||
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
else {
|
||||
myException = new Exception("Errore interno");
|
||||
request.setAttribute("resultBean", myException);
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO , objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_DISABILITAZIONE_SCHED:
|
||||
|
||||
{ // DISABILITAZIONE SCHEDULATORE
|
||||
// da inserire il metodo per disabilitare lo schedulatore
|
||||
|
||||
actionCode=ActionLogMapping.DisabilitazioneSchedulatore;
|
||||
|
||||
taskManagerMonitor.stop(); // taskManager stoppato
|
||||
|
||||
/// controllo che lo schedulatore sia disattivo o meno
|
||||
if (!taskManagerMonitor.isAlive()) {
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA,
|
||||
CrontabCostants.DISABILITA_MOTORE);
|
||||
retCommand = CommandsDef.PAGE_ESITO;
|
||||
aCrontabSession.setStato_Schedulatore(CrontabCostants.
|
||||
STATO_SCHEDULATORE_STANDBY);
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
else {
|
||||
myException = new Exception("Errore interno");
|
||||
request.setAttribute("resultBean", myException);
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO , objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_RESTART_SCHED:
|
||||
|
||||
{ // RESTART SCHEDULATORE
|
||||
// da inserire il metodo per restartare lo schedulatore
|
||||
|
||||
actionCode=ActionLogMapping.RestartSchedulatore;
|
||||
|
||||
/// prima disabilita e poi abilita
|
||||
// prelevo l'oggetto dalla sessione
|
||||
|
||||
taskManagerMonitor.stop(); // taskManager stoppato
|
||||
taskManagerMonitor.start(); // taskManager partito
|
||||
|
||||
/// controllo che loschedulatore sia attivo o meno
|
||||
if (taskManagerMonitor.isAlive()) {
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA,
|
||||
CrontabCostants.RESTART_MOTORE);
|
||||
retCommand = CommandsDef.PAGE_ESITO;
|
||||
aCrontabSession.setStato_Schedulatore(CrontabCostants.
|
||||
STATO_SCHEDULATORE_STANDBY);
|
||||
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
else {
|
||||
myException = new Exception("Errore interno");
|
||||
request.setAttribute("resultBean", myException);
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO , objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_GESTIONE_TASK:
|
||||
|
||||
{ // GESTIONE TASKS
|
||||
// ACCEDE ALLA LISTA DI TASKS DISPONIBILI
|
||||
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTask(
|
||||
taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.LISTA_TASKS;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_LISTA_TASK_SCHEDULATI:
|
||||
|
||||
{ //
|
||||
// ACCEDE ALLA LISTA DI TASKS SCHEDULATI IN GIORNATA
|
||||
IntervalloAttivazione aIntervallo = new IntervalloAttivazione();
|
||||
aIntervallo.setOraFrom("0");
|
||||
aIntervallo.setOraTo("24");
|
||||
|
||||
EventTime et_from = new EventTime();
|
||||
et_from = et_from.getRelEvent(Integer.parseInt(aIntervallo.getOraFrom()),0,0,0);
|
||||
EventTime et_to = new EventTime();
|
||||
et_to = et_to.getRelEvent(Integer.parseInt(aIntervallo.getOraTo()),0,0,0);
|
||||
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTask(
|
||||
taskManagerMonitor,et_from,et_to));
|
||||
|
||||
/* TaskBean[] aTaskBean = new TaskBean[0];
|
||||
ListaTasks aLista = new ListaTasks();
|
||||
aLista.setListaTaskBean(aTaskBean);
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
aLista);*/
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN_INTERVALLO,
|
||||
aIntervallo);
|
||||
retCommand = CommandsDef.LISTA_TASK_SCHEDULATI;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_LISTA_TASK_SCHEDULATI:
|
||||
|
||||
{ //
|
||||
// ACCEDE ALLA LISTA DI TASKS schedulati in base all'arco temporale
|
||||
// inserito dall'utente
|
||||
actionCode=ActionLogMapping.RicercaTaskGiornalieri;
|
||||
|
||||
try {
|
||||
IntervalloAttivazione aIntervallo = new IntervalloAttivazione();
|
||||
aIntervallo.setOraFrom(request.getParameter("oraFrom"));
|
||||
aIntervallo.setOraTo(request.getParameter("oraTo"));
|
||||
|
||||
EventTime et_from = new EventTime();
|
||||
et_from = et_from.getRelEvent(Integer.parseInt(aIntervallo.getOraFrom()),0,0,0);
|
||||
EventTime et_to = new EventTime();
|
||||
et_to = et_to.getRelEvent(Integer.parseInt(aIntervallo.getOraTo()),0,0,0);
|
||||
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTask(
|
||||
taskManagerMonitor,et_from,et_to));
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN_INTERVALLO,
|
||||
aIntervallo);
|
||||
retCommand = CommandsDef.LISTA_TASK_SCHEDULATI;
|
||||
|
||||
//log security
|
||||
objectLog="Task Giornalieri";
|
||||
paramLog = new TreeMap();
|
||||
paramLog.put("Ora Inizio",aIntervallo.getOraFrom());
|
||||
paramLog.put("Ora Fine",aIntervallo.getOraTo());
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO , objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case CrontabCostants.FNC_GESTIONE_PROCESSI:
|
||||
|
||||
|
||||
{ // GESTIONE PROCESSI
|
||||
// ACCEDE ALLA LISTA DI PROCESSI DISPONIBILI
|
||||
|
||||
// ListaProcessi aLista = new ListaProcessi();
|
||||
// calcolo la Lista dei processi disponibili
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaProcessi(
|
||||
taskManagerMonitor));
|
||||
/*
|
||||
aLista=aLista.setDummyProcess();
|
||||
request.setAttribute("resultBean",aLista);
|
||||
*/
|
||||
retCommand = CommandsDef.LISTA_PROCESS;
|
||||
|
||||
// session.setAttribute("oggettoDummyProcess", aLista);
|
||||
// aCrontabSession.setStato_Schedulatore(CrontabCostants.STATO_SCHEDULATORE_RUNNING);
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_LOGOUT:
|
||||
|
||||
{ // ritorna alla pagina di Login
|
||||
// dovrebbe scadere la sessione
|
||||
try {
|
||||
//CARLOM 21/09/2006 la logout la effettua il SessionManager.
|
||||
// commentata la logout esplicita ed aggiunta la chiamata al sessionManager mediante invalidate()
|
||||
|
||||
//LoginBean aLogin = (LoginBean) session.getAttribute("LoginBean");
|
||||
//LoginManager loginManag = new LoginManager();
|
||||
//loginManag.logout(aLogin.getUserID(),LoginBeanDTO.APP_CODE_DBC);
|
||||
request.getSession().invalidate();
|
||||
retCommand = CommandsDef.LOGIN_DO;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
request.setAttribute("resultBean", ex.toString());
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_CONFIGURAZIONE_XML:
|
||||
|
||||
{ // accede alla pagina di configurazione
|
||||
//
|
||||
File fileConf = new File(taskManagerMonitor.getFileCfg());
|
||||
String pathFile = fileConf.getAbsolutePath();
|
||||
String cfgVer = taskManagerMonitor.getCfgVer();
|
||||
String cfgSubVer = taskManagerMonitor.getCfgSubVer();
|
||||
String cfgName = taskManagerMonitor.getCfgName();
|
||||
//System.out.println("pathFile: " + pathFile);
|
||||
//System.out.println("cfgVer: " + cfgVer);
|
||||
//System.out.println("cfgName: " + cfgName);
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN, pathFile);
|
||||
request.setAttribute(CrontabCostants.XML_CONF_VER, cfgVer);
|
||||
request.setAttribute(CrontabCostants.XML_CONF_SUBVER, cfgSubVer);
|
||||
request.setAttribute(CrontabCostants.XML_CONF_NAME, cfgName);
|
||||
|
||||
retCommand = CommandsDef.CONFIGURAZIONE_XML;
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_GESTIONE_GATEWAY:
|
||||
|
||||
{ // accede alla pagina di configurazione
|
||||
//
|
||||
StringBuffer sResponse=new StringBuffer();
|
||||
String[][] statoGW = ritornaStatoGW(res);
|
||||
// statoGW[i][0]= url gateway
|
||||
// statoGW[i][1]= response gateway/errore msg
|
||||
for (int i = 0; i < statoGW.length; i++) {
|
||||
sResponse.append(statoGW[i][0]).append(" : ");
|
||||
if ((!statoGW[i][1].equals("y")) &&
|
||||
(!statoGW[i][1].equals("n"))) {
|
||||
// errore di comunicazione
|
||||
sResponse.append(CrontabCostants.GATEWAY_ERRORE_DI_COMUNICAZIONE).append("-").append(statoGW[i][1]);
|
||||
}
|
||||
else {
|
||||
if (statoGW[i][1].equals("y") )
|
||||
sResponse.append(CrontabCostants.GATEWAY_ABILITATO);
|
||||
else
|
||||
sResponse.append(CrontabCostants.GATEWAY_DISABILITATO);
|
||||
}
|
||||
sResponse.append("<br>");//MANDO A CAPO
|
||||
}
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA,
|
||||
sResponse.toString());
|
||||
retCommand = CommandsDef.GESTIONE_GATEWAY;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_SAVE_XML:
|
||||
|
||||
|
||||
{ // SALVATAGGIO FILE XML
|
||||
actionCode = ActionLogMapping.SalvataggioConfigurazione;
|
||||
try {
|
||||
String file = taskManagerMonitor.save();
|
||||
retCommand = CommandsDef.PAGE_ESITO;
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA,
|
||||
CrontabCostants.FILE_XML_SALVATO);
|
||||
|
||||
//log security
|
||||
objectLog = "File=" + file;
|
||||
a = new Azione(actionCode, paramLog,
|
||||
ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK, objectLog,
|
||||
ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
}
|
||||
catch (Exception e) {
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO , objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_RELOAD_XML:
|
||||
|
||||
{ // LOAD FILE XML
|
||||
actionCode=ActionLogMapping.RipristinoConfigurazione;
|
||||
try {
|
||||
|
||||
taskManagerMonitor.load(request.getParameter("Ripristina"));
|
||||
retCommand = CommandsDef.PAGE_ESITO;
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA,
|
||||
CrontabCostants.FILE_XML_RIPRISTINATO);
|
||||
//log security
|
||||
objectLog="File="+request.getParameter("Ripristina");
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
catch (NotValidCrontabFileException ex1) {
|
||||
retCommand = CommandsDef.PAGE_ESITO;
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA, "File specificato non valido, Viene mantenuta la configurazione in memoria (file: "
|
||||
+ taskManagerMonitor.getFileCfg() + ")");
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO , objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CrontabCostants.CMD_ABILITA_GATEWAY:
|
||||
|
||||
{ // ABILITARE GATEWAY
|
||||
actionCode=ActionLogMapping.AbilitaGateway;
|
||||
try {
|
||||
abilitaGateway(res);
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA,
|
||||
CrontabCostants.GATEWAY_ABILITATO);
|
||||
retCommand = CommandsDef.PAGE_ESITO;
|
||||
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
catch (IOException io) {
|
||||
request.setAttribute("resultBean", (Exception) io.fillInStackTrace());
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO , objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_DISABILITA_GATEWAY:
|
||||
|
||||
{ // DISABILITARE GATEWAY
|
||||
actionCode=ActionLogMapping.DisabilitaGateway;
|
||||
try {
|
||||
disabilitaGateway(res);
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA,
|
||||
CrontabCostants.GATEWAY_DISABILITATO);
|
||||
retCommand = CommandsDef.PAGE_ESITO;
|
||||
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
catch (IOException io) {
|
||||
request.setAttribute("resultBean", (Exception) io.fillInStackTrace());
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO , objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_ATTIVITA_GIORNALIERE:
|
||||
|
||||
{ // Accede alla pagina di presentazione deitask giornalieri
|
||||
|
||||
// lista task schedulati
|
||||
// TaskTimerMonitorMBean aTimerMonitor =(TaskTimerMonitorClient)
|
||||
// session.getAttribute(CrontabCostants.OBJECT_TASK_TIMER_SESSION);
|
||||
|
||||
ListaTasks aLista = FormatterCommand.formatterListaTaskSchedulati(
|
||||
taskManagerMonitor);
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN, aLista);
|
||||
|
||||
// String [] lista = taskManagerMonitor. Task() .getListTaskSchedulation();
|
||||
if (aLista.getListaTaskBean().length == 0)
|
||||
aCrontabSession.setStato_Schedulatore(CrontabCostants.
|
||||
STATO_SCHEDULATORE_STANDBY);
|
||||
else
|
||||
aCrontabSession.setStato_Schedulatore(CrontabCostants.
|
||||
STATO_SCHEDULATORE_RUNNING);
|
||||
|
||||
// ListaTasks aLista = ListaTasks.setDummyTasks(lista);
|
||||
// request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN, aLista);
|
||||
retCommand = CommandsDef.ATTIVITA_GIORNALIERA;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_HOME_PRESENTAZIONE:
|
||||
|
||||
{ // Accede alla pagina di presentazione dei task
|
||||
|
||||
retCommand = CommandsDef.HOME_CRONTAB_DO;
|
||||
|
||||
ListaTasks aLista = FormatterCommand.formatterListaTaskAttivi(
|
||||
taskManagerMonitor);
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN, aLista);
|
||||
|
||||
if (taskManagerMonitor.isAlive())
|
||||
request.setAttribute("statoSchedulatore", "A");
|
||||
else
|
||||
request.setAttribute("statoSchedulatore", "D");
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_APPLICATION_MANAGER: {
|
||||
|
||||
session.setAttribute(ApplicationManagerCostants.OBJECT_MANAGER_SESSION,
|
||||
new ManagerSession());
|
||||
|
||||
retCommand = CommandsDef.PRESENTAZIONE_APPLICATION;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_LOGOUT_CRONTAB: {
|
||||
|
||||
retCommand = CommandsDef.PRESENTAZIONE_INTERFACCE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
myException = new Exception("Errore interno");
|
||||
request.setAttribute("resultBean", myException);
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
return retCommand;
|
||||
|
||||
}
|
||||
}
|
||||
if (taskManagerMonitor!=null)
|
||||
session.setAttribute(CrontabCostants.STATO_CONFIGURAZIONE, ((taskManagerMonitor.getSaved())?Boolean.TRUE: Boolean.FALSE));
|
||||
return retCommand;
|
||||
}
|
||||
|
||||
public void disabilitaGateway(HttpServletResponse response) throws Exception {
|
||||
gestioneGateway(response,DISABILITA_GATEWAY);
|
||||
}
|
||||
public void abilitaGateway(HttpServletResponse response) throws Exception {
|
||||
gestioneGateway(response,ABILITA_GATEWAY);
|
||||
}
|
||||
|
||||
private void gestioneGateway(HttpServletResponse response, String richiesta) throws
|
||||
Exception {
|
||||
URL wlsUrl = null;
|
||||
String[] urlGw = Resources.getUrlGateway();
|
||||
String urlManagementServlet = Resources.getUrlManagementServlet();
|
||||
String address = null;
|
||||
String errMsg = null;
|
||||
weblogic.net.http.HttpURLConnection sconnection = null;
|
||||
|
||||
for (int i = 0; i < urlGw.length; i++) {
|
||||
address = urlGw[i] + urlManagementServlet + richiesta;
|
||||
wlsUrl = new URL(address);
|
||||
try {
|
||||
|
||||
if (wlsUrl.getProtocol().equalsIgnoreCase("https")) {
|
||||
sconnection = new weblogic.net.http.HttpsURLConnection(wlsUrl);
|
||||
}
|
||||
else {
|
||||
sconnection = new weblogic.net.http.HttpURLConnection(wlsUrl);
|
||||
}
|
||||
|
||||
// Set request method
|
||||
sconnection.setRequestMethod("POST");
|
||||
sconnection.connect();
|
||||
String ok = sconnection.getResponseMessage();
|
||||
if (!ok.equalsIgnoreCase("OK"))throw new Exception(
|
||||
"Colloquio con GW non valido:" + address + " response is:" + ok);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
if (errMsg == null)
|
||||
errMsg += address + ":" + ex.toString();
|
||||
else
|
||||
errMsg += "--" + address + ":" + ex.toString();
|
||||
}
|
||||
finally {
|
||||
if (sconnection != null)
|
||||
try {
|
||||
sconnection.disconnect();
|
||||
}
|
||||
catch (Exception ex1) {
|
||||
}
|
||||
}
|
||||
if (errMsg != null)
|
||||
throw new Exception(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* statoFE[i][0]= url gateway
|
||||
* statoFE[i][1]= response gateway/errore msg
|
||||
* @param response HttpServletResponse
|
||||
* @throws Exception
|
||||
* @return String[][]
|
||||
*/
|
||||
private String[][] ritornaStatoGW(HttpServletResponse response) throws Exception {
|
||||
|
||||
String[] urlGw = Resources.getUrlGateway();
|
||||
String urlManagementServlet = Resources.getUrlManagementServlet();
|
||||
String address = null;
|
||||
String errMsg = null;
|
||||
URL wlsUrl = null;
|
||||
weblogic.net.http.HttpURLConnection sconnection = null;
|
||||
String[][] statoGW = null;
|
||||
|
||||
statoGW = new String[urlGw.length][2];
|
||||
|
||||
for (int i = 0; i < urlGw.length; i++) {
|
||||
statoGW[i][0] = urlGw[i];
|
||||
address = urlGw[i] + urlManagementServlet;
|
||||
wlsUrl = new URL(address);
|
||||
// effettuo la connessione
|
||||
try {
|
||||
sconnection = null;
|
||||
if (wlsUrl.getProtocol().equalsIgnoreCase("https")) {
|
||||
sconnection = new weblogic.net.http.HttpsURLConnection(wlsUrl);
|
||||
}
|
||||
else {
|
||||
sconnection = new weblogic.net.http.HttpURLConnection(wlsUrl);
|
||||
}
|
||||
// Set request method
|
||||
sconnection.setRequestMethod("GET");
|
||||
// Apertura canali e scrittura file
|
||||
sconnection.setDoOutput(true);
|
||||
sconnection.setDoInput(true);
|
||||
sconnection.connect();
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(
|
||||
sconnection.getInputStream()));
|
||||
char ch = (char) in.read();
|
||||
System.out.println("--------->carattere di ritorno " + ch);
|
||||
statoGW[i][1] = String.valueOf(ch);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
statoGW[i][1] = ex.toString();
|
||||
}
|
||||
finally {
|
||||
if (sconnection != null)
|
||||
try {
|
||||
sconnection.disconnect();
|
||||
}
|
||||
catch (Exception ex1) {
|
||||
}
|
||||
}
|
||||
} // end for
|
||||
return statoGW;
|
||||
}
|
||||
|
||||
// public String ritornaStatoGW(HttpServletResponse response) throws Exception
|
||||
// {
|
||||
// String statoFE="";
|
||||
// URL wlsUrl = null;
|
||||
// String address=Resources.getUrlManagementServlet();
|
||||
// wlsUrl = new URL(address);
|
||||
// try
|
||||
// {
|
||||
// weblogic.net.http.HttpURLConnection sconnection = null;
|
||||
// if (wlsUrl.getProtocol().equalsIgnoreCase("https")) {
|
||||
// sconnection = new weblogic.net.http.HttpsURLConnection(wlsUrl);
|
||||
// }
|
||||
// else {
|
||||
// sconnection = new weblogic.net.http.HttpURLConnection(wlsUrl);
|
||||
// }
|
||||
//
|
||||
// // Set request method
|
||||
// sconnection.setRequestMethod("GET");
|
||||
// // Apertura canali e scrittura file
|
||||
// sconnection.setDoOutput(true);
|
||||
// sconnection.setDoInput(true);
|
||||
//
|
||||
// try {
|
||||
// sconnection.connect();
|
||||
// BufferedReader in= new BufferedReader(new InputStreamReader(sconnection.getInputStream()));
|
||||
// char ch =(char)in.read();
|
||||
// System.out.println("--------->carattere di ritorno " + ch);
|
||||
// statoFE = String.valueOf(ch);
|
||||
// }
|
||||
//
|
||||
// catch (Exception ex) {
|
||||
// throw ex;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// throw ex;
|
||||
// }
|
||||
//
|
||||
// return statoFE;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP - Amministrazione</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
import it.valueteam.crontab.engine.mbean.TaskManagerMBean;
|
||||
import it.valueteam.crontab.engine.mbean.client.TaskManagerClient;
|
||||
import mnp.crontab.database.dao.LoginDAO;
|
||||
import mnp.crontab.database.dao.ProfiloDAO;
|
||||
import mnp.crontab.objects.ListaTasks;
|
||||
import mnp.crontab.objects.ui.LoginBean;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
public class InterfacceCommand extends AbstractCommand {
|
||||
|
||||
String retCommand;
|
||||
Exception myException;
|
||||
|
||||
public InterfacceCommand() {
|
||||
}
|
||||
|
||||
private static Logger log = Logger.getLogger(InterfacceCommand.class.getName());
|
||||
|
||||
public String execute(HttpServletRequest request, HttpServletResponse res) throws Exception {
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
// controllo se la sessione e' scaduta
|
||||
if (session.isNew()) {
|
||||
session.invalidate();
|
||||
retCommand = CommandsDef.SESSIONE_INATTIVA;
|
||||
return retCommand;
|
||||
}
|
||||
|
||||
LoginBean aLoginBean = (LoginBean) session.getAttribute(AmministrazioneCostants.OBJECT_LOGINBEAN_SESSION);
|
||||
|
||||
ProfiloDAO pr = null;
|
||||
// Individuo la funzionalita' da eseguire
|
||||
String jspName = request.getParameter("JSP_FUNCTION");
|
||||
|
||||
int jspNameValue = Integer.parseInt(jspName);
|
||||
|
||||
switch (jspNameValue) {
|
||||
case AmministrazioneCostants.FNC_LOGOUT:
|
||||
{ // DISCONNETTI DA APPLICAZIONE
|
||||
try {
|
||||
// CARLOM 21/09/2006 la logout la effettua il SessionManager. (vd. Index)
|
||||
//LoginBean aLogin = (LoginBean) session.getAttribute("LoginBean");
|
||||
//LoginManager loginManag = new LoginManager();
|
||||
//loginManag.logout(aLogin.getUserID(),LoginBeanDTO.APP_CODE_DBC);
|
||||
request.getSession().invalidate();
|
||||
retCommand = CommandsDef.LOGOUT_DO;
|
||||
} catch (Exception ex) {
|
||||
request.setAttribute("resultBean", ex.toString());
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case AmministrazioneCostants.FNC_CRONTAB:
|
||||
{ // ACCEDE ALL'INTERFACCIA GRAFICA DEL CRONTAB
|
||||
CrontabSession aCrontab = new CrontabSession();
|
||||
ListaTasks aLista = new ListaTasks();
|
||||
//controllo il tipo di utente
|
||||
aCrontab.setUser(getProfiloUtente(aLoginBean.getUserID()));
|
||||
session.setAttribute(CrontabCostants.OBJECT_CRONTAB_SESSION, aCrontab);
|
||||
/// riferimento al server jmx remoto
|
||||
|
||||
/// fine riferimento al server jmx remoto del nodo Master
|
||||
TaskManagerMBean taskManagerMonitor = new TaskManagerClient(CrontabCostants.OBJECT_TASK_MANAGER_MBEAN_CLIENT);
|
||||
|
||||
aLista = FormatterCommand.formatterListaTaskAttivi(taskManagerMonitor);
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN, aLista);
|
||||
|
||||
// STATO SCHEDULATORE
|
||||
request.setAttribute("statoSchedulatore", getStatoSchedulatore(taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.HOME_CRONTAB_DO;
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN, aLista);
|
||||
}
|
||||
break;
|
||||
|
||||
case AmministrazioneCostants.FNC_APPLICATION_MANAGER:
|
||||
{ // ACCEDE ALL'INTERFACCIA GRAFICA DELL'APPLICATION MANAGER
|
||||
// Oggetto di profilo
|
||||
CrontabSession aCrontab = new CrontabSession();
|
||||
session.setAttribute(ApplicationManagerCostants.OBJECT_MANAGER_SESSION, new ManagerSession());
|
||||
retCommand = CommandsDef.PRESENTAZIONE_APPLICATION;
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
retCommand = CommandsDef.PRESENTAZIONE_INTERFACCE;
|
||||
}
|
||||
}
|
||||
return retCommand;
|
||||
}
|
||||
|
||||
/*
|
||||
@Metodo per la creazione di un profilo utente
|
||||
@ al 18-02-04 metodo draft
|
||||
@ come versione 1.5.1
|
||||
*/
|
||||
public static String getProfiloUtente(String user) {
|
||||
LoginDAO lg = new LoginDAO();
|
||||
String profile;
|
||||
if (lg.isAdmin(user))
|
||||
profile = CrontabCostants.USER_AMMINISTRATORE;
|
||||
else
|
||||
profile = CrontabCostants.USER_VISUALIZZATORE;
|
||||
return profile;
|
||||
}
|
||||
|
||||
/*
|
||||
@Metodo per la creazione dello stato dello schedulatore
|
||||
@ al 18-02-04
|
||||
@ come versione 1.5.1
|
||||
*/
|
||||
public static String getStatoSchedulatore(TaskManagerMBean taskManagerMonitor) {
|
||||
String stato;
|
||||
if (taskManagerMonitor.isAlive())
|
||||
stato = "A";
|
||||
else
|
||||
stato = "D";
|
||||
|
||||
return stato;
|
||||
}
|
||||
}
|
||||
286
dbcmnpsrc/FE/mnpdev/crontab/src/mnp/crontab/command/Login.java
Normal file
286
dbcmnpsrc/FE/mnpdev/crontab/src/mnp/crontab/command/Login.java
Normal file
@@ -0,0 +1,286 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
import it.valueteam.logging.Azione;
|
||||
import it.valueteam.logging.SessionInfo;
|
||||
import mnp.crontab.manager.LoginManager;
|
||||
import mnp.crontab.objects.ui.LoginBean;
|
||||
import mnp.crontab.objects.ui.LoginRetCodeIF;
|
||||
import mnp.crontab.utility.Resources;
|
||||
import mnp.crontab.utility.ui.Res;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
public class Login extends AbstractCommand {
|
||||
|
||||
String retCommand;
|
||||
Exception myException;
|
||||
protected static String USER_TEMP="usernameTemp";
|
||||
protected static String PROFILE_TEMP="codiceProfiloTemp";
|
||||
private static Logger log = Logger.getLogger(Login.class.getName());
|
||||
|
||||
public Login() {}
|
||||
|
||||
public String execute(HttpServletRequest request, HttpServletResponse res) throws
|
||||
Exception {
|
||||
|
||||
LoginBean loginBean = null;
|
||||
|
||||
int retCode = -11;
|
||||
HttpSession session = null;
|
||||
String info_client = request.getParameter("info_client");
|
||||
Res.ApplContext = request.getContextPath();
|
||||
|
||||
Res.ReqURL = "https://" + request.getServerName() + ":" +
|
||||
request.getServerPort() +
|
||||
request.getContextPath();
|
||||
|
||||
//Controllo se l'oggetto LoginBean <20> in sessione, in questo caso
|
||||
// non faccio alcun controllo (pu<70> capitare in caso di refresh della home page)
|
||||
LoginBean tempLog=(LoginBean)request.getSession().getAttribute(AmministrazioneCostants.
|
||||
OBJECT_LOGINBEAN_SESSION);
|
||||
if(tempLog==null && Resources.isSviluppo()){
|
||||
tempLog=new LoginBean();
|
||||
tempLog.setUserID("admin");
|
||||
tempLog.setCodiceProfilo("AAM");
|
||||
session = request.getSession();
|
||||
session.setAttribute(AmministrazioneCostants.
|
||||
OBJECT_LOGINBEAN_SESSION, tempLog);
|
||||
}
|
||||
if(tempLog!=null && tempLog.getUserID()!=null && tempLog.getCodiceProfilo()!=null)
|
||||
{
|
||||
return CommandsDef.PRESENTAZIONE_INTERFACCE;
|
||||
|
||||
}
|
||||
else{
|
||||
/*// Quando la richiesta viene da PCS entro in questo blocco perch<63>
|
||||
il parametro info_client viene valorizzato nella pagina SecurityInfoClient.jsp*/
|
||||
if (info_client == null) {
|
||||
|
||||
String user_parameter_name_pcs = Resources.getUSER_PARAMETER_NAME_PCS();
|
||||
String profile_parameter_name_pcs = Resources.
|
||||
getPROFILE_PARAMETER_NAME_PCS();
|
||||
|
||||
/*Potrebbe capitare che quando viene visualizzata la pagina di
|
||||
reperimento informazioni client(SecurityInfoClient.jsp) l'utente chiuda
|
||||
il browser, in questo caso non sono entrato nel blocco ELSE e non ho il
|
||||
LoginBean in sessione ma solo i parametri temporanei, se per PCS sono
|
||||
ancora loggato non avr<76> pi<70> i parametri(username e codice profilo) nell'header
|
||||
e quindi tento di reperirli dalla sessione. La stessa cosa pu<70> capitare se per
|
||||
un problema qualsiasi nella pagina SecurityInfoClient.jsp non riesco a fare la
|
||||
submit automatica o manuale. In poche parole faccio questo controllo perch<63>
|
||||
potrebbe capitare che non sono entrato nel blocco ELSE e per PCS sono loggato*/
|
||||
|
||||
String usernameTemp = request.getHeader(user_parameter_name_pcs);
|
||||
//##### CERCO LE INFORMAZIONI USERNAME IN SESSIONE #################
|
||||
if (usernameTemp == null || usernameTemp.trim().length() == 0) {
|
||||
usernameTemp = (String) request.getSession().getAttribute(
|
||||
USER_TEMP);
|
||||
//#################################################
|
||||
|
||||
}
|
||||
String codiceProfiloTemp = request.getHeader(profile_parameter_name_pcs);
|
||||
//##### CERCO LE INFORMAZIONI CODICE PROFILO IN SESSIONE #################
|
||||
if (codiceProfiloTemp == null || codiceProfiloTemp.trim().length() == 0) {
|
||||
codiceProfiloTemp = (String) request.getSession().getAttribute(
|
||||
PROFILE_TEMP);
|
||||
//#################################################
|
||||
|
||||
}
|
||||
|
||||
//verifica che user e codiceProfilo siano valorizzati
|
||||
if (!checkCredentials(usernameTemp, codiceProfiloTemp)) {
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
myException = new Exception(
|
||||
"Non sono stati trovati i parametri di autenticazione provenienti da PCS");
|
||||
log.info(
|
||||
"Non sono stati trovati i parametri di autenticazione provenienti da PCS");
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN, myException);
|
||||
|
||||
this.setActionLog(new Azione(ActionLogMapping.Login, null,
|
||||
ActionLogMapping.
|
||||
LOG_RESULT_CODE_DETAIL_KO,
|
||||
"Utente = " + usernameTemp,
|
||||
ActionLogMapping.LOG_RESULT_CODE_KO));
|
||||
|
||||
return retCommand;
|
||||
}
|
||||
//############################################
|
||||
|
||||
request.getSession().setAttribute(USER_TEMP, usernameTemp);
|
||||
request.getSession().setAttribute(PROFILE_TEMP, codiceProfiloTemp);
|
||||
|
||||
retCommand = CommandsDef.LOGIN_DO;
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
/*//Qua gestico la richiesta dopo che ho preso gli ActiveX, al
|
||||
ritorno dalla pagina SecurityInfoClient.jsp*/
|
||||
String username = (String) request.getSession().getAttribute(
|
||||
USER_TEMP);
|
||||
String codiceProfilo = (String) request.getSession().getAttribute(
|
||||
PROFILE_TEMP);
|
||||
String ipClient = request.getParameter("ipclient");
|
||||
String hostNameClient = request.getParameter("hostnameclient");
|
||||
String utenzaClient = request.getParameter("utenzaclient");
|
||||
|
||||
//######## IP ADDRESS SORGENTE ##############
|
||||
String ipAddress = request.getRemoteAddr();
|
||||
//##########################################
|
||||
|
||||
log.debug("INFO CLIENT: " + ipClient + " " + hostNameClient + " " +
|
||||
utenzaClient);
|
||||
|
||||
loginBean = new LoginBean();
|
||||
|
||||
loginBean.setUserID(username);
|
||||
loginBean.setCodiceProfilo(codiceProfilo);
|
||||
|
||||
LoginManager loginManag = new LoginManager();
|
||||
loginManag.login(loginBean);
|
||||
loginBean.setIpAddress(ipAddress);
|
||||
loginBean.setIpClient(ipClient);
|
||||
loginBean.setHostNameClient(hostNameClient);
|
||||
loginBean.setUtenzaClient(utenzaClient);
|
||||
|
||||
if (isTightLogin() &&
|
||||
(loginBean.getIpClient() == null ||
|
||||
loginBean.getIpClient().length() == 0)) {
|
||||
retCode = LoginRetCodeIF.SECURITY_PROBLEM;
|
||||
log.debug("retCode " + retCode);
|
||||
}
|
||||
else {
|
||||
|
||||
retCode = loginBean.getRetCode();
|
||||
}
|
||||
|
||||
log.debug("retCode " + retCode);
|
||||
|
||||
switch (retCode) {
|
||||
|
||||
case LoginRetCodeIF.LOGIN_OK: {
|
||||
retCommand = CommandsDef.PRESENTAZIONE_INTERFACCE;
|
||||
}
|
||||
break;
|
||||
|
||||
case LoginRetCodeIF.SECURITY_PROBLEM: {
|
||||
myException = new Exception("Motivi di sicurezza impediscono l'accesso! Configurare correttamente il browser e chiuderlo per rendere effettive le modifiche. Per informazioni consultare la relativa documentazione");
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
log.info("Motivi di sicurezza impediscono l'accesso! Configurare correttamente il browser e chiuderlo per rendere effettive le modifiche. Per informazioni consultare la relativa documentazione");
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case LoginRetCodeIF.PROFILO_KO: {
|
||||
myException = new Exception("Il codiceProfilo riscontrato non coincide con nessuno di quelli mappati dall'applicazione");
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
log.info("Il codiceProfilo riscontrato non coincide con nessuno di quelli mappati dall'applicazione");
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
myException = new Exception("Errore interno");
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
log.info("Errore interno");
|
||||
}
|
||||
|
||||
}
|
||||
//log security
|
||||
//inizializzazione info per i log di sicurezza
|
||||
log.debug("HOSTNAME: " + loginBean.getHostNameClient());
|
||||
SessionInfo sessionInfo = new SessionInfo(
|
||||
Resources.getHostAddress(), //ipServer
|
||||
Resources.getHostName(), //hostNameServer
|
||||
loginBean.getUserID(), //utenzaApplicativa
|
||||
CrontabCostants.LOG_CLIENT_APP_NAME, //applicativoClient
|
||||
loginBean.getProfilo(), //profiloUtente
|
||||
loginBean.getIpClient(), //ipClient
|
||||
loginBean.getHostNameClient(), //hostNameClient
|
||||
loginBean.getUtenzaClient(), //utenzaClient
|
||||
loginBean.getIpAddress() //ipSorgente
|
||||
);
|
||||
loginBean.setSessionInfo(sessionInfo);
|
||||
|
||||
if (retCommand.equals(CommandsDef.ERROR_DO)) {
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN, myException);
|
||||
|
||||
/* if (retCommand.equals(CommandsDef.HOME_CRONTAB_DO))
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN, aLista);*/
|
||||
}
|
||||
else {
|
||||
|
||||
// INSERISCO L'OGGETTO LOGINBEAN IN SESSIONE
|
||||
session = request.getSession();
|
||||
session.setAttribute(AmministrazioneCostants.
|
||||
OBJECT_LOGINBEAN_SESSION, loginBean);
|
||||
//Rimuovo dalla sessione gli oggetti temporanei introdotti nel primo blocco IF
|
||||
if (session.getAttribute(USER_TEMP) != null) {
|
||||
session.removeAttribute(USER_TEMP);
|
||||
}
|
||||
if (session.getAttribute(PROFILE_TEMP) != null) {
|
||||
session.removeAttribute(PROFILE_TEMP);
|
||||
|
||||
//################################################
|
||||
}
|
||||
}
|
||||
|
||||
//request.getSession(false).setAttribute(AmministrazioneCostants.OBJECT_MANAGER_SESSION, new SessionManager(loginBean.getUserID()));
|
||||
boolean loginDone = !retCommand.equalsIgnoreCase(CommandsDef.ERROR_DO);
|
||||
this.setActionLog(new Azione(ActionLogMapping.Login, null,
|
||||
(loginDone) ?
|
||||
ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK :
|
||||
ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO,
|
||||
"Utente = " + loginBean.getUserID(),
|
||||
(loginDone) ?
|
||||
ActionLogMapping.LOG_RESULT_CODE_OK :
|
||||
ActionLogMapping.LOG_RESULT_CODE_KO));
|
||||
|
||||
log.debug("retCommand " + retCommand);
|
||||
|
||||
}
|
||||
|
||||
return retCommand;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica se la funzionalit<69> di tight login <20> attiva controllando il valore della chiave dbcgo.tight_login sul file
|
||||
* dbcgo.properties
|
||||
*
|
||||
* @return boolean
|
||||
* @author Mario Giurlanda - kit Dicembre 2006
|
||||
*/
|
||||
private boolean isTightLogin() {
|
||||
|
||||
if (Resources.getTIGHT_LOGIN().equalsIgnoreCase("YES")) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* checkCredentials
|
||||
*
|
||||
* @param user String
|
||||
* @param profile String
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean checkCredentials(String user, String profile) {
|
||||
|
||||
if (user == null || user.equalsIgnoreCase("") || profile == null ||
|
||||
profile.equalsIgnoreCase("")) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
public class ManagerSession {
|
||||
private String ID_Intervallo;
|
||||
private String ID_TipologiaFile;
|
||||
private String nome_file;
|
||||
private String tipo_file;
|
||||
private String path_file;
|
||||
public ManagerSession() {
|
||||
}
|
||||
public String getID_Intervallo() {
|
||||
return ID_Intervallo;
|
||||
}
|
||||
public void setID_Intervallo(String ID_Intervallo) {
|
||||
this.ID_Intervallo = ID_Intervallo;
|
||||
}
|
||||
public String getID_TipologiaFile() {
|
||||
return ID_TipologiaFile;
|
||||
}
|
||||
public void setID_TipologiaFile(String ID_TipologiaFile) {
|
||||
this.ID_TipologiaFile = ID_TipologiaFile;
|
||||
}
|
||||
public String getNome_file() {
|
||||
return nome_file;
|
||||
}
|
||||
public void setNome_file(String nome_file) {
|
||||
this.nome_file = nome_file;
|
||||
}
|
||||
public String getTipo_file() {
|
||||
return tipo_file;
|
||||
}
|
||||
public void setTipo_file(String tipo_file) {
|
||||
this.tipo_file = tipo_file;
|
||||
}
|
||||
public String getPath_file() {
|
||||
return path_file;
|
||||
}
|
||||
public void setPath_file(String path_file) {
|
||||
this.path_file = path_file;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,445 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
/**
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
// util java
|
||||
// back-end
|
||||
import java.util.*;
|
||||
import javax.servlet.http.*;
|
||||
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.engine.mbean.*;
|
||||
import it.valueteam.crontab.engine.mbean.client.*;
|
||||
import it.valueteam.logging.*;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
import mnp.crontab.utility.*;
|
||||
|
||||
|
||||
|
||||
|
||||
public class ProcessCommand extends AbstractCommand{
|
||||
String retCommand;
|
||||
Exception myException;
|
||||
TaskManagerMBean taskManagerMonitor;
|
||||
|
||||
public ProcessCommand() {
|
||||
}
|
||||
|
||||
public String execute(HttpServletRequest request, HttpServletResponse res) throws Exception {
|
||||
|
||||
|
||||
//log security
|
||||
Map paramLog=null;
|
||||
String objectLog="";
|
||||
Azione a = null;
|
||||
int actionCode=0;
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
CrontabSession aCrontabSession = (CrontabSession) session.getAttribute(CrontabCostants.OBJECT_CRONTAB_SESSION);
|
||||
String jspName = request.getParameter(CrontabCostants.CAMPO_HIDDEN_FUNCTION);
|
||||
|
||||
/// oggetti per ora Dummy appena ci saranno i metodi di LUCA questi scompariranno
|
||||
/* ListaProcessi ListaDummy = new ListaProcessi();//(ListaProcessi) session.getAttribute("oggettoDummyProcess");
|
||||
ProcessBean[] rProcess = null;
|
||||
rProcess = ListaDummy.getListaProcessi();*/
|
||||
try
|
||||
{
|
||||
int jspNameValue = Integer.parseInt(jspName);
|
||||
|
||||
/* if (ExecutionProfile.valideCommandProcess(aCrontabSession.getUser(),jspNameValue))
|
||||
{
|
||||
retCommand = CommandsDef.PAGE_ESITO;
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA, CrontabCostants.UTENTE_NON_ABILITATO);
|
||||
return retCommand;
|
||||
}
|
||||
*/
|
||||
// prendo l'oggetto sul nodo master
|
||||
taskManagerMonitor = new TaskManagerClient(CrontabCostants.OBJECT_TASK_MANAGER_MBEAN_CLIENT);
|
||||
|
||||
switch (jspNameValue) {
|
||||
|
||||
case CrontabCostants.FNC_NUOVO_PROCESSO :
|
||||
|
||||
{ // Function che fa accedere al form di inserimento di un processo
|
||||
|
||||
aCrontabSession.setLabelOperazione(CrontabCostants.LABEL_OPERAZIONE_NUOVO_PROCESSO);
|
||||
aCrontabSession.setCmdOperazione(CrontabCostants.CMD_NUOVO_PROCESSO);
|
||||
aCrontabSession.setProcessId("");
|
||||
request.setAttribute("resultBean",new ProcessBean());
|
||||
// in sessione i processi bloccanti il processo
|
||||
session.setAttribute(CrontabCostants.OBJECT_PROCESSI_BLOCCANTI, new Vector());
|
||||
|
||||
// in sessione i processi disponibili
|
||||
Vector ProcessiBloccantiDisponibili = FormatterCommand.getProcessiDisponibili(taskManagerMonitor.getAvailableProcess());
|
||||
session.setAttribute(CrontabCostants.OBJECT_PROCESSI_BLOCCANTI_DISPONIBILI,ProcessiBloccantiDisponibili);
|
||||
|
||||
|
||||
retCommand = CommandsDef.INSERT_PROCESSO;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_MODIFICA_PROCESSO :
|
||||
|
||||
{ // Function che fa accedere al form di Modifica di un processo
|
||||
|
||||
// int element = Integer.parseInt(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
|
||||
aCrontabSession.setLabelOperazione(CrontabCostants.LABEL_OPERAZIONE_MODIFICA_PROCESSO);
|
||||
aCrontabSession.setCmdOperazione(CrontabCostants.CMD_MODIFICA_PROCESSO);
|
||||
aCrontabSession.setProcessId(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
ProcessInfo aProcessInfo=taskManagerMonitor.getProcess(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
ProcessBean aProcessBean = FormatterCommand.formatterProcess(taskManagerMonitor,aProcessInfo);
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,aProcessBean);
|
||||
|
||||
// Prelevo e Formatto Process in vector di ProcessiBloccanti
|
||||
Vector ProcessiBloccanti = FormatterCommand.getProcessiBloccanti(taskManagerMonitor,aProcessInfo.getBlockingProcessList());
|
||||
session.setAttribute(CrontabCostants.OBJECT_PROCESSI_BLOCCANTI,ProcessiBloccanti);
|
||||
|
||||
Vector ProcessiBloccantiDisponibili = FormatterCommand.getProcessiDisponibili(
|
||||
taskManagerMonitor.getNotUsedBlockingProcesses(aProcessInfo.getId()));
|
||||
session.setAttribute(CrontabCostants.OBJECT_PROCESSI_BLOCCANTI_DISPONIBILI,ProcessiBloccantiDisponibili);
|
||||
|
||||
retCommand = CommandsDef.INSERT_PROCESSO;
|
||||
|
||||
}
|
||||
break;
|
||||
// C.P. aggiunto x gestione processi bloccanti
|
||||
case CrontabCostants.FNC_ASSOCIA_PROCESSO_BLOCCANTE :
|
||||
// Vector processi =(Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI);
|
||||
// request.setAttribute("ORDINE",String.valueOf(processi.size()+1));
|
||||
System.out.println("CrontabCostants.FNC_ASSOCIA_PROCESSO_BLOCCANTE");
|
||||
retCommand = CommandsDef.PROCESSI_BLOCCATI_DISPONIBILI;
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_MODIFICA_PROCESSO :
|
||||
{ // Comando d'Inserimento di modifica Processo
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Tale metodo ha le seguenti funzionalità
|
||||
// 1 - Modifica il processo selezionato
|
||||
// 2 - Ricreare la lista dei processi
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
actionCode = ActionLogMapping.ModificaProcesso;
|
||||
|
||||
// riprendo il processoInfo
|
||||
ProcessInfo aProcessInfo=taskManagerMonitor.getProcess(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
// apporto le modifiche
|
||||
aProcessInfo.setName(request.getParameter("Nome"));
|
||||
aProcessInfo.setDesc(request.getParameter("Descrizione"));
|
||||
aProcessInfo.setCommand(request.getParameter("Comando"));
|
||||
aProcessInfo.setParams(request.getParameter("Parametri"));
|
||||
|
||||
// gestione processi bloccanti
|
||||
Vector processi = (Vector) session.getAttribute(CrontabCostants.
|
||||
OBJECT_PROCESSI_BLOCCANTI);
|
||||
// rimuovo il processi dipendenti precedenti
|
||||
aProcessInfo.removeAllBlockingProcess();
|
||||
//metto quelli nuovi
|
||||
ProcessBean aProcess;
|
||||
for (int i = 0; i < processi.size(); i++) {
|
||||
aProcess = (ProcessBean) processi.elementAt(i);
|
||||
aProcessInfo.addBlockingDependentProcess(aProcess.getProcessId());
|
||||
System.out.println("add process id:"+aProcess.getProcessId());
|
||||
}
|
||||
|
||||
//
|
||||
taskManagerMonitor.update(aProcessInfo);
|
||||
// lista processi
|
||||
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaProcessi(taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.LISTA_PROCESS;
|
||||
//log security
|
||||
objectLog="Processo="+aProcessInfo.getName();
|
||||
paramLog=new TreeMap();
|
||||
paramLog.put("Comando",aProcessInfo.getCommand());
|
||||
paramLog.put("Parametri",aProcessInfo.getParams());
|
||||
paramLog.put("Descrizione",aProcessInfo.getDesc());
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_NUOVO_PROCESSO :
|
||||
{ // Comando d'Inserimento di un nuovo Processo
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Tale metodo ha le seguenti funzionalità
|
||||
// 1 - Inserire un nuovo processo
|
||||
// 2 - Ricreare la lista dei processi con in + il nuovo processo
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
actionCode=ActionLogMapping.NuovoProcesso;
|
||||
|
||||
ProcessInfo aProcessInfo=new ProcessInfo(Resources.getID_PROCESS(request.getParameter("Nome")),
|
||||
request.getParameter("Nome"),request.getParameter("Descrizione"),
|
||||
request.getParameter("Comando"),request.getParameter("Parametri"),
|
||||
false);
|
||||
// gestione processi bloccanti
|
||||
Vector processi = (Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_BLOCCANTI);
|
||||
|
||||
ProcessBean aProcess;
|
||||
for (int i = 0; i < processi.size(); i++) {
|
||||
aProcess = (ProcessBean) processi.elementAt(i);
|
||||
aProcessInfo.addBlockingDependentProcess(aProcess.getProcessId());
|
||||
System.out.println("add process id");
|
||||
}
|
||||
|
||||
//
|
||||
taskManagerMonitor.addNew(aProcessInfo);
|
||||
// lista processi
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaProcessi(taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.LISTA_PROCESS;
|
||||
|
||||
//log security
|
||||
objectLog="Processo="+aProcessInfo.getName();
|
||||
paramLog=new TreeMap();
|
||||
paramLog.put("Comando",aProcessInfo.getCommand());
|
||||
paramLog.put("Parametri",aProcessInfo.getParams());
|
||||
paramLog.put("Descrizione",aProcessInfo.getDesc());
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
break;
|
||||
/*
|
||||
case CrontabCostants.CMD_ARRESTA_PROCESSO :
|
||||
{ // Function per arrestare un processo in running
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Tale metodo ha le seguenti funzionalità
|
||||
// 1 - Arrestare il processo che in quel momento è in fase di running
|
||||
// 2 - Riportare la modalità del processo in fase standby
|
||||
// 3 - Ricreare la lista dei processi con le nuove informazioni
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
int element = Integer.parseInt(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
rProcess[element].setModalita(CrontabCostants.MODALITA_STANDBY);
|
||||
|
||||
request.setAttribute("resultBean", ListaDummy);
|
||||
aCrontabSession.setStato_Schedulatore(CrontabCostants.STATO_SCHEDULATORE_STANDBY);
|
||||
|
||||
retCommand = CommandsDef.LISTA_PROCESS;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_START_PROCESSO :
|
||||
|
||||
{ // Comando che RUNNING un task che è in fase di standby
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Tale metodo ha le seguenti funzionalità
|
||||
// 1 - Startare il task che in quel momento è in fase di standby
|
||||
// 2 - Riportare la modalità del task in fase running
|
||||
// 3 - Ricreare la lista dei task con le nuove informazioni
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
int element = Integer.parseInt(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
rProcess[element].setModalita(CrontabCostants.MODALITA_RUNNING);
|
||||
|
||||
request.setAttribute("resultBean", ListaDummy);
|
||||
aCrontabSession.setStato_Schedulatore(CrontabCostants.STATO_SCHEDULATORE_RUNNING);
|
||||
|
||||
retCommand = CommandsDef.LISTA_PROCESS;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case CrontabCostants.CMD_ABILITA_PROCESSO :
|
||||
|
||||
{ // Comando che Abilita un processo che è in fase di Disabilitato
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// 1 - Abilitare il processo che in quel momento è in fase di disabilitato
|
||||
// 2 - Ricreare la lista dei processo con le nuove informazioni
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
actionCode=ActionLogMapping.AbilitaProcesso;
|
||||
|
||||
// riprendo il processoInfo
|
||||
ProcessInfo aProcessInfo=
|
||||
taskManagerMonitor.getProcess(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
// apporto le modifiche
|
||||
aProcessInfo.setEneabled(true);
|
||||
taskManagerMonitor.update(aProcessInfo);
|
||||
|
||||
// lista processi
|
||||
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaProcessi(taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.LISTA_PROCESS;
|
||||
|
||||
//log security
|
||||
objectLog="Processo="+aProcessInfo.getName();
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_DISABILITA_PROCESSO :
|
||||
|
||||
{ // Comando che Disabilita un processo che è in fase di Standby
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// 1 - Disabilitare il processo che in quel momento è in fase di standby
|
||||
// 2 - Ricreare la lista dei processi con le nuove informazioni
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
actionCode=ActionLogMapping.DisabilitaProcesso;
|
||||
|
||||
// riprendo il processoInfo
|
||||
ProcessInfo aProcessInfo=
|
||||
taskManagerMonitor.getProcess(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
// apporto le modifiche
|
||||
aProcessInfo.setEneabled(false);
|
||||
taskManagerMonitor.update(aProcessInfo);
|
||||
|
||||
// lista processi
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaProcessi(taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.LISTA_PROCESS;
|
||||
|
||||
//log security
|
||||
objectLog="Processo="+aProcessInfo.getName();
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_ELIMINA_PROCESSO :
|
||||
|
||||
{ // Comando che Elimina un processo che è in fase di Standby
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// 1 - Eliminare il processo
|
||||
// 2 - Ricreare la lista dei processi con le nuove informazioni
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
//log security
|
||||
actionCode=ActionLogMapping.EliminaProcesso;
|
||||
ProcessInfo aProcessInfo=
|
||||
taskManagerMonitor.getProcess(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
objectLog="Processo="+aProcessInfo.getName();
|
||||
|
||||
// remove PROCESSInfo
|
||||
taskManagerMonitor.removeProcess(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
|
||||
|
||||
// riporto la lista aggiornata
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaProcessi(taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.LISTA_PROCESS;
|
||||
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_DETTAGLIO_PROCESSO :
|
||||
{ // Function per accedere al dettaglio di un processo
|
||||
|
||||
aCrontabSession.setLabelOperazione(CrontabCostants.LABEL_OPERAZIONE_DETTAGLIO_PROCESSO);
|
||||
|
||||
// prelevo le informazioni del Processo da " taskManagerMonitor "
|
||||
ProcessInfo aProcessInfo=
|
||||
taskManagerMonitor.getProcess(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
ProcessBean aProcessBean = FormatterCommand.formatterProcess(taskManagerMonitor,aProcessInfo);
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,aProcessBean);
|
||||
retCommand = CommandsDef.SCHEDA_PROCESSO;
|
||||
}
|
||||
break;
|
||||
case CrontabCostants.CMD_ASSOCIA_PROCESSO_BLOCCANTE:
|
||||
|
||||
{ // Cmd per la associazione di processi bloccante al processo.
|
||||
System.out.println("CMD_ASSOCIA_PROCESSO_BLOCCANTE");
|
||||
ProcessBean aProcessBean = new ProcessBean();
|
||||
|
||||
// processi ASSOCIATI E DISPONIBILI
|
||||
Vector processBloccanti = (Vector) session.getAttribute(CrontabCostants.
|
||||
OBJECT_PROCESSI_BLOCCANTI);
|
||||
Vector processi = (Vector) session.getAttribute(CrontabCostants.
|
||||
OBJECT_PROCESSI_BLOCCANTI_DISPONIBILI);
|
||||
|
||||
// PROCESSO DA ASSOCIARE
|
||||
String element = request.getParameter(CrontabCostants.
|
||||
CAMPO_ELEMENT_CHECKED);
|
||||
|
||||
aProcessBean = (ProcessBean) processi.elementAt(Integer.parseInt(element));
|
||||
//to do capiere se va messo
|
||||
aProcessBean.setStatoUscita("Stato d'uscita " + "1");
|
||||
|
||||
System.out.println("---"+aProcessBean.getNome());
|
||||
// associo il processo e lo tolgo dai processi disponibili
|
||||
processBloccanti.add(aProcessBean);
|
||||
|
||||
processi.remove(Integer.parseInt(element));
|
||||
|
||||
retCommand = CommandsDef.PROCESSI_BLOCCANTI;
|
||||
}
|
||||
break;
|
||||
case CrontabCostants.CMD_DISASSOCIA_PROCESSO_BLOCCANTE:
|
||||
|
||||
{ // Cmd per la disassociazione di processi bloccanti da processo.
|
||||
System.out.println("CMD_DISASSOCIA_PROCESSO_BLOCCANTE");
|
||||
|
||||
//String[] element = request.getParameterValues("elementiLista");
|
||||
Vector processBloccanti = (Vector) session.getAttribute(CrontabCostants.
|
||||
OBJECT_PROCESSI_BLOCCANTI);
|
||||
Vector processi = (Vector) session.getAttribute(CrontabCostants.
|
||||
OBJECT_PROCESSI_BLOCCANTI_DISPONIBILI);
|
||||
|
||||
String element = request.getParameter(CrontabCostants.
|
||||
CAMPO_ELEMENT_CHECKED);
|
||||
|
||||
ProcessBean aProcessBean = null;
|
||||
aProcessBean = (ProcessBean)processBloccanti.get(Integer.parseInt(element));
|
||||
System.out.println("levo "+aProcessBean.getNome());
|
||||
aProcessBean = (ProcessBean)processBloccanti.remove(Integer.parseInt(element));
|
||||
processi.add(aProcessBean);
|
||||
|
||||
retCommand = CommandsDef.PROCESSI_BLOCCANTI;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
session.setAttribute(CrontabCostants.STATO_CONFIGURAZIONE, ((taskManagerMonitor.getSaved())?Boolean.TRUE: Boolean.FALSE));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
myException = new Exception("Errore interno");
|
||||
request.setAttribute("resultBean", myException);
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
|
||||
//log security
|
||||
if (actionCode!=0){
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO, objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
}
|
||||
|
||||
return retCommand;
|
||||
}
|
||||
|
||||
return retCommand;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import javax.servlet.http.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import it.valueteam.logging.*;
|
||||
import mnp.crontab.config.am.*;
|
||||
import mnp.crontab.engine.mbean.*;
|
||||
import mnp.crontab.objects.am.*;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
import mnp.crontab.utility.*;
|
||||
import it.valueteam.crontab.jms.AppConfigurationMessageHandler;
|
||||
|
||||
|
||||
public class SistemiCommand
|
||||
extends AbstractCommand {
|
||||
String retCommand;
|
||||
Exception myException;
|
||||
ApplicationController appController=new ApplicationController();
|
||||
Configuration aConfiguration = new Configuration();
|
||||
SistemiInterni aSistemiInterni;
|
||||
|
||||
private static Logger log = Logger.getLogger(SistemiCommand.class.getName());
|
||||
|
||||
public SistemiCommand() {
|
||||
}
|
||||
|
||||
public String execute(HttpServletRequest request, HttpServletResponse res) throws
|
||||
Exception {
|
||||
|
||||
//log security
|
||||
Map paramLog=null;
|
||||
String objectLog="";
|
||||
Azione a = null;
|
||||
int actionCode=0;
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
|
||||
// controllo se la sessione è scaduta
|
||||
if (session.isNew()) {
|
||||
session.invalidate();
|
||||
retCommand = CommandsDef.SESSIONE_INATTIVA;
|
||||
return retCommand;
|
||||
}
|
||||
|
||||
String jspName = request.getParameter("JSP_FUNCTION");
|
||||
int jspNameValue = Integer.parseInt(jspName);
|
||||
/*
|
||||
if (ExecutionProfile.valideCommandSistemi(aCrontabSession.getUser(),
|
||||
jspNameValue)) {
|
||||
retCommand = CommandsDef.ESITO_APPLICATION;
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
CrontabCostants.UTENTE_NON_ABILITATO);
|
||||
return retCommand;
|
||||
}
|
||||
*/
|
||||
switch (jspNameValue) {
|
||||
|
||||
case ApplicationManagerCostants.FNC_CONFIGURAZIONE_SISTEMI_INTERNI: {
|
||||
|
||||
appController = new ApplicationController();
|
||||
aConfiguration = appController.getConfiguration(
|
||||
ApplicationManagerCostants.
|
||||
SISTEMI_BINDING_NAME);
|
||||
log.info("Apro e leggo il file xml per la gestione dei Sistemi Interni ");
|
||||
ArrayList aL = FormatterCommandApplication.
|
||||
formattaSistemiInterni_TO_ArrayList(aConfiguration.
|
||||
getConfSistemiInterni());
|
||||
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aL);
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_NOME_FILE,
|
||||
aConfiguration.getPath_Sistemi());
|
||||
session.setAttribute(ApplicationManagerCostants.OBJECT_SESSION_SISTEMI,
|
||||
aL);
|
||||
|
||||
retCommand = CommandsDef.SISTEMI_CONFIGURATION;
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.CMD_APPLY_SISTEMI_INTERNI:
|
||||
|
||||
{ // AGGIORNA tutti i DATI DEL SISTEMA CCRM sul file xml
|
||||
|
||||
actionCode=ActionLogMapping.AbilitazioneSistemaInterno;
|
||||
ArrayList aListSistemi = getDatiAbilitazione( (ArrayList) session.
|
||||
getAttribute(ApplicationManagerCostants.OBJECT_SESSION_SISTEMI),
|
||||
request);
|
||||
|
||||
CrontabSession aCrontabSession = (CrontabSession) session.getAttribute(
|
||||
CrontabCostants.OBJECT_CRONTAB_SESSION);
|
||||
// Aggiorna la configurazione
|
||||
|
||||
aConfiguration.setConfSistemiInterni(aListSistemi);
|
||||
InternalSystemControllerConfig _internal= (InternalSystemControllerConfig) appController.updateConfiguration(aConfiguration,
|
||||
ApplicationManagerCostants.
|
||||
SISTEMI_BINDING_NAME);
|
||||
log.info("Aggiorna la configurazione");
|
||||
|
||||
//log security
|
||||
ItemBean aItem;
|
||||
paramLog=new TreeMap();
|
||||
for (int i = 0; i < aListSistemi.size(); i++) {
|
||||
aItem = (ItemBean) aListSistemi.get(i);
|
||||
paramLog.put(aItem.getLabels(),Boolean.valueOf(aItem.isValuesBoolean()));
|
||||
}
|
||||
objectLog="Abilitazione Sistemi Interni";
|
||||
|
||||
// Passa la configurazione al Controller di MNP
|
||||
|
||||
try {
|
||||
inviaConfigurazioneSistemi(res,_internal);
|
||||
log.info(
|
||||
"Notifica la configurazione aggiornata dei Sistemi Interni a MNP");
|
||||
}
|
||||
catch (IOException io) {
|
||||
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO , objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
|
||||
throw io;
|
||||
}
|
||||
|
||||
// Salva la configurazione sul file SistemiInterni.xml
|
||||
InternalSystemWrapper IsysW = InternalSystemWrapper.getInstance();
|
||||
IsysW.setInternalSystem(FormatterCommandApplication.formattaInternalSystem(aListSistemi));
|
||||
IsysW.save();
|
||||
log.info("Salva la configurazione aggiornata sul file SistemiInterni.xml");
|
||||
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
ApplicationManagerCostants.
|
||||
MESSAGE_CONFIRM_UPDATE_SISTEMI);
|
||||
|
||||
|
||||
|
||||
retCommand = CommandsDef.ESITO_APPLICATION;
|
||||
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.FNC_LOGOUT:
|
||||
|
||||
{ // ritorna alla pagina di Login
|
||||
// dovrebbe scadere la sessione
|
||||
try {
|
||||
//CARLOM 21/09/2006 la logout la effettua il SessionManager. (vedi Index)
|
||||
//LoginBean aLogin = (LoginBean) session.getAttribute("LoginBean");
|
||||
//LoginManager loginManag = new LoginManager();
|
||||
//loginManag.logout(aLogin.getUserID(),LoginBeanDTO.APP_CODE_DBC);
|
||||
request.getSession().invalidate();
|
||||
retCommand = CommandsDef.LOGIN_DO;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
request.setAttribute("resultBean", ex.toString());
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.FNC_LOGOUT_APPLICATION : {
|
||||
|
||||
retCommand = CommandsDef.PRESENTAZIONE_INTERFACCE;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return retCommand;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList getDatiAbilitazione(ArrayList aList,
|
||||
javax.servlet.http.HttpServletRequest
|
||||
request) throws Exception {
|
||||
|
||||
ItemBean aItem;
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
aItem = (ItemBean) aList.get(i);
|
||||
|
||||
if (request.getParameter(aItem.getValues()).equals("Si"))
|
||||
aItem.setValuesBoolean(true);
|
||||
else
|
||||
aItem.setValuesBoolean(false);
|
||||
}
|
||||
return aList;
|
||||
}
|
||||
|
||||
public void inviaConfigurazioneSistemi(HttpServletResponse response,InternalSystemControllerConfig _internal) throws Exception {
|
||||
|
||||
|
||||
AppConfigurationMessageHandler.getInstance().insertTopic(_internal);
|
||||
// String urlStr = Resources.getURL_SERVLET_MNP();
|
||||
// String _response = null;
|
||||
// URL url = new URL(urlStr);
|
||||
// weblogic.net.http.HttpURLConnection connection = null;
|
||||
// if (url.getProtocol().equalsIgnoreCase("https")) {
|
||||
// connection = new weblogic.net.http.HttpsURLConnection(url);
|
||||
// }
|
||||
// else {
|
||||
// connection = new weblogic.net.http.HttpURLConnection(url);
|
||||
// }
|
||||
// connection.setRequestMethod("POST");
|
||||
// connection.setDoOutput(true);
|
||||
// connection.setDoInput(true);
|
||||
// ObjectOutputStream wout = new ObjectOutputStream(connection.getOutputStream());
|
||||
// wout.writeObject(_internal);
|
||||
// wout.flush();
|
||||
//
|
||||
// // Invio dati e chiusura canali
|
||||
// connection.connect();
|
||||
// _response = connection.getResponseMessage();
|
||||
// if (response == null || !_response.equalsIgnoreCase("OK")) {
|
||||
// throw new Exception("Colloquio con MNP non valido");
|
||||
// }
|
||||
// connection.disconnect();
|
||||
// wout.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,987 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import javax.servlet.http.*;
|
||||
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.engine.mbean.*;
|
||||
import it.valueteam.crontab.engine.mbean.client.*;
|
||||
import it.valueteam.crontab.utility.EventTime;
|
||||
import it.valueteam.logging.*;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
import mnp.crontab.utility.*;
|
||||
|
||||
|
||||
|
||||
public class TaskCommand extends AbstractCommand{
|
||||
String retCommand;
|
||||
Exception myException;
|
||||
TaskManagerMBean taskManagerMonitor;
|
||||
|
||||
public TaskCommand() {
|
||||
}
|
||||
|
||||
public String execute(HttpServletRequest request, HttpServletResponse res) throws Exception {
|
||||
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
CrontabSession aCrontabSession = (CrontabSession) session.getAttribute(CrontabCostants.OBJECT_CRONTAB_SESSION);
|
||||
String jspName = request.getParameter(CrontabCostants.CAMPO_HIDDEN_FUNCTION);
|
||||
Vector ListaSession =(Vector) session.getAttribute("oggettoDummy");
|
||||
|
||||
//sessione scaduta
|
||||
if (aCrontabSession==null)
|
||||
return CommandsDef.SESSIONE_INATTIVA;
|
||||
|
||||
|
||||
//log security
|
||||
Map paramLog=null;
|
||||
String objectLog="";
|
||||
Azione a = null;
|
||||
int actionCode=0;
|
||||
|
||||
try
|
||||
{
|
||||
int jspNameValue = Integer.parseInt(jspName);
|
||||
|
||||
/* if (ExecutionProfile.valideCommandTask(aCrontabSession.getUser(),jspNameValue))
|
||||
{
|
||||
retCommand = CommandsDef.PAGE_ESITO;
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA, CrontabCostants.UTENTE_NON_ABILITATO);
|
||||
return retCommand;
|
||||
}
|
||||
*/
|
||||
// prelevo l'oggetto Task Manager Sessione dalla sessione
|
||||
taskManagerMonitor = new TaskManagerClient(CrontabCostants.OBJECT_TASK_MANAGER_MBEAN_CLIENT);
|
||||
|
||||
switch (jspNameValue) {
|
||||
|
||||
case CrontabCostants.CMD_TASK_EMERGENZA :
|
||||
|
||||
{ // Comando che inserisce un task d'emergenza
|
||||
// Questo dovrebbe scatenare diverse situazioni tipo il ricalcolo
|
||||
// attività dello schedulatore
|
||||
|
||||
actionCode=ActionLogMapping.EsecuzioneNuovoTaskEmergenza;
|
||||
|
||||
EventTime et=new EventTime();
|
||||
// setto TaskInfo
|
||||
TaskInfo aTaskBean =new TaskInfo(Resources.getID_TASK_EMERGENZA(),null,
|
||||
null,null,et.getTime(),et.getTime(),false);
|
||||
|
||||
// Processi Associati
|
||||
Vector processi =(Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI);
|
||||
|
||||
if (processi.size() !=0)
|
||||
{
|
||||
ProcessBean aProcess;
|
||||
boolean stato = false;
|
||||
for (int i = 0; i < processi.size(); i++) {
|
||||
aProcess = (ProcessBean) processi.elementAt(i);
|
||||
if (aProcess.getStatoProcesso().equals(CrontabCostants.
|
||||
STATO_PROCESSO_ABILITATO))
|
||||
stato = true;
|
||||
else
|
||||
stato=false;
|
||||
|
||||
aTaskBean.addProcessInfo(FormatterCommand.
|
||||
formatterProcessToProcessInfo(taskManagerMonitor,aProcess),
|
||||
i, stato);
|
||||
|
||||
}
|
||||
|
||||
// add TaskInfo per Task EMERGENZA
|
||||
taskManagerMonitor.runEmergencyTask(aTaskBean);
|
||||
// riporto la lista aggiornata
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTaskSchedulati(
|
||||
taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.ATTIVITA_GIORNALIERA;
|
||||
|
||||
//log security
|
||||
objectLog="Task=" + aTaskBean.getId()+" - "+ aTaskBean.getName();
|
||||
paramLog=aTaskBean.getProcessMapToLog();
|
||||
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
request.setAttribute(CrontabCostants.MESSAGGIO_CONFERMA, CrontabCostants.TASK_EMERGENZA_NO_CORRECT);
|
||||
retCommand = CommandsDef.PAGE_ESITO;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_TASK_EMERGENZA :
|
||||
|
||||
{ // Function che fa accedere al form di inserimento di un task
|
||||
|
||||
aCrontabSession.setLabelOperazione(CrontabCostants.LABEL_OPERAZIONE_TASK_EMERGENZA);
|
||||
aCrontabSession.setCmdOperazione(CrontabCostants.CMD_TASK_EMERGENZA);
|
||||
|
||||
TaskBean aTaskBean = new TaskBean();
|
||||
//request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,aTaskBean);
|
||||
|
||||
// in sessione i processi associati al task
|
||||
session.setAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI, new Vector());
|
||||
|
||||
// in sessione i processi disponibili
|
||||
Vector ProcessiDisponibili = FormatterCommand.getProcessiDisponibili(taskManagerMonitor.getAvailableProcess());
|
||||
session.setAttribute(CrontabCostants.OBJECT_PROCESSI_DISPONIBILI,ProcessiDisponibili);
|
||||
|
||||
retCommand = CommandsDef.TASK_EMERGENZA;
|
||||
|
||||
}
|
||||
break;
|
||||
case CrontabCostants.FNC_LANCIA_TASK_EMERGENZA:
|
||||
|
||||
{ // Function che fa accedere al form di inserimento di un task
|
||||
// come task di emergenza
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTask(
|
||||
taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.LISTA_TASK_AS_EMERGENZA;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_LANCIA_TASK_EMERGENZA :
|
||||
|
||||
{ // Comando che inserisce come task d'emergenza un task già esistente
|
||||
// Questo dovrebbe scatenare diverse situazioni tipo il ricalcolo
|
||||
// attività dello schedulatore
|
||||
|
||||
actionCode=ActionLogMapping.EsecuzioneTaskEmergenza;
|
||||
|
||||
// setto TaskInfo
|
||||
TaskInfo aTaskinfo = taskManagerMonitor.getTask(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
|
||||
|
||||
// add TaskInfo per Task EMERGENZA
|
||||
taskManagerMonitor.runEmergencyTask(aTaskinfo);
|
||||
// riporto la lista aggiornata
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTaskSchedulati(
|
||||
taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.ATTIVITA_GIORNALIERA;
|
||||
|
||||
//log security
|
||||
objectLog="Task=" + aTaskinfo.getId()+" - "+ aTaskinfo.getName();
|
||||
paramLog=aTaskinfo.getProcessMapToLog();
|
||||
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_DETTAGLIO_TASK :
|
||||
{ // Function per accedere al dettaglio di un task
|
||||
|
||||
aCrontabSession.setLabelOperazione(CrontabCostants.LABEL_OPERAZIONE_DETTAGLIO_TASK);
|
||||
|
||||
// prelevo le informazioni del Task
|
||||
TaskInfo aTask=taskManagerMonitor.getTask(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
|
||||
TaskBean aTaskBean = FormatterCommand.formatterTask(aTask);
|
||||
aTaskBean.setModalita(request.getParameter("modalita"));
|
||||
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,aTaskBean);
|
||||
|
||||
retCommand = CommandsDef.SCHEDA_TASK;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_MODIFICA_TASK :
|
||||
|
||||
{ // Function per accedere al form di modifica di un task
|
||||
|
||||
aCrontabSession.setLabelOperazione(CrontabCostants.LABEL_OPERAZIONE_MODIFICA_TASK);
|
||||
aCrontabSession.setCmdOperazione(CrontabCostants.CMD_MODIFICA_TASK);
|
||||
aCrontabSession.setTaskId(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
|
||||
// prelevo le informazioni del Task
|
||||
TaskInfo aTask=taskManagerMonitor.getTask(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
TaskBean aTaskBean = FormatterCommand.formatterTask(aTask);
|
||||
|
||||
aCrontabSession.setDataCreazione(aTask.getCreateAt());
|
||||
|
||||
// aTaskBean.setModalita(request.getParameter("modalita"));
|
||||
// Prelevo e Formatto WindowTime in vector di Intervalli di Attivazione
|
||||
Vector Intervalli = FormatterCommand.getIntervalliAttivazione(aTask.getRegoleAttivazione().iterator());
|
||||
session.setAttribute(CrontabCostants.OBJECT_INTERVALLI_SESSION,Intervalli);
|
||||
|
||||
// Prelevo e Formatto Process in vector di ProcessiAssociati
|
||||
Vector ProcessiAssociati = FormatterCommand.getProcessiAssociati(aTask.getProcessList());
|
||||
session.setAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI,ProcessiAssociati);
|
||||
|
||||
Vector ProcessiDisponibili = FormatterCommand.getProcessiDisponibili(taskManagerMonitor.getNotUsedProcesses(aTask.getId()));
|
||||
session.setAttribute(CrontabCostants.OBJECT_PROCESSI_DISPONIBILI,ProcessiDisponibili);
|
||||
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,aTaskBean);
|
||||
|
||||
|
||||
retCommand = CommandsDef.INSERT_TASK;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_MODIFICA_TASK :
|
||||
|
||||
{ // Comando che modifica un task
|
||||
// Acquisisce i campi del form
|
||||
// Questo dovrebbe scatenare diverse situazioni tipo il ricalcolo
|
||||
// di attività dello schedulatore
|
||||
|
||||
actionCode=ActionLogMapping.ModificaTask;
|
||||
|
||||
// oggetto TaskInfo
|
||||
boolean stato=true;
|
||||
if (request.getParameter("modalita").equals(CrontabCostants.MODALITA_DISABLED))
|
||||
stato=false;
|
||||
|
||||
EventTime et=new EventTime();
|
||||
TaskInfo aPrevTask=taskManagerMonitor.getTask(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
aPrevTask.removeAllProcessInfoRef();
|
||||
TaskInfo aTaskBean =new TaskInfo(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED),request.getParameter("Nome"),
|
||||
request.getParameter("Descrizione"),request.getParameter("Note"),aCrontabSession.getDataCreazione(),et.getTime(),stato);
|
||||
|
||||
// Intervalli Attivazione
|
||||
Vector intervalli =(Vector) session.getAttribute(CrontabCostants.OBJECT_INTERVALLI_SESSION);
|
||||
IntervalloAttivazione aIntervallo;
|
||||
for (int i=0; i<intervalli.size();i++)
|
||||
{
|
||||
aIntervallo= (IntervalloAttivazione) intervalli.elementAt(i);
|
||||
for (Iterator iter = FormatterCommand.formatterIntervalliToRegoleAttivazioneIterator(aIntervallo); iter.hasNext(); ) {
|
||||
RegolaAttivazione item = (RegolaAttivazione)iter.next();
|
||||
aTaskBean.addRegolaAttivazione(item);
|
||||
}
|
||||
}
|
||||
|
||||
// Processi Associati
|
||||
Vector processi =(Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI);
|
||||
ProcessBean aProcess;
|
||||
stato=false;
|
||||
for (int i=0; i<processi.size();i++)
|
||||
{
|
||||
aProcess= (ProcessBean) processi.elementAt(i);
|
||||
if (aProcess.getStatoProcesso().equals(CrontabCostants.STATO_PROCESSO_ABILITATO))
|
||||
stato=true;
|
||||
else
|
||||
stato=false;
|
||||
|
||||
aTaskBean.addProcessInfo(FormatterCommand.formatterProcessToProcessInfo(taskManagerMonitor,aProcess),i,stato);
|
||||
|
||||
}
|
||||
|
||||
// aggiorno TaskInfo
|
||||
taskManagerMonitor.update(aTaskBean);
|
||||
// riporto la lista aggiornata
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTask(taskManagerMonitor));
|
||||
|
||||
|
||||
retCommand = CommandsDef.LISTA_TASKS;
|
||||
|
||||
//log security
|
||||
objectLog="Task=" + aTaskBean.getId()+" - "+ aTaskBean.getName();
|
||||
paramLog=aTaskBean.getProcessMapToLog();
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_ASSOCIA_PROCESSO :
|
||||
|
||||
{ // Fnc per la associazione di processiad un task.
|
||||
Vector processi =(Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI);
|
||||
request.setAttribute("ORDINE",String.valueOf(processi.size()+1));
|
||||
retCommand = CommandsDef.PROCESSI_DISPONIBILI;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_ABILITA_PROCESSO_ASSOCIATO :
|
||||
|
||||
{ // Cmd per la abilitazione di un processo associato ad un task.
|
||||
|
||||
// TaskBean aTaskBean =(TaskBean) session.getAttribute("oggettoTaskBean");
|
||||
Vector processTask = (Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI);
|
||||
ProcessBean aProcessBean = (ProcessBean) processTask.elementAt(Integer.parseInt(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED)));
|
||||
|
||||
aProcessBean.setStatoProcesso(CrontabCostants.STATO_PROCESSO_ABILITATO);
|
||||
|
||||
// aTaskBean.setVectorProcessi(processTask);
|
||||
|
||||
retCommand = CommandsDef.PROCESSI_ASSOCIATI;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case CrontabCostants.CMD_DISABILITA_PROCESSO_ASSOCIATO :
|
||||
|
||||
{ // Cmd per la disabilitazione di processi associati ad un task.
|
||||
|
||||
String[] element=request.getParameterValues("elementiLista");
|
||||
// TaskBean aTaskBean =(TaskBean) session.getAttribute("oggettoTaskBean");
|
||||
Vector processTask = (Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI);
|
||||
ProcessBean aProcessBean = new ProcessBean();
|
||||
|
||||
/// Modifico lo stato diun processo da abilitato in disabilitato
|
||||
|
||||
for (int i=0;i<element.length;i++)
|
||||
{
|
||||
aProcessBean =(ProcessBean) processTask.elementAt(Integer.parseInt(element[i]));
|
||||
aProcessBean.setStatoProcesso(CrontabCostants.STATO_PROCESSO_DISABILITATO);
|
||||
}
|
||||
// aTaskBean.setVectorProcessi(processTask);
|
||||
|
||||
retCommand = CommandsDef.PROCESSI_ASSOCIATI;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_DISASSOCIA_PROCESSO :
|
||||
|
||||
{ // Cmd per la disassociazione di processi ad un task.
|
||||
|
||||
String[] element=request.getParameterValues("elementiLista");
|
||||
// TaskBean aTaskBean =(TaskBean) session.getAttribute("oggettoTaskBean");
|
||||
|
||||
Vector processTask = (Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI);
|
||||
Vector processi =(Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_DISPONIBILI);
|
||||
|
||||
/*
|
||||
Vector processTask = (Vector) aTaskBean.getVectorProcessi();
|
||||
|
||||
Vector processi =(Vector) session.getAttribute("oggettoListaProcess");
|
||||
*/
|
||||
ProcessBean aProcessBean =new ProcessBean();
|
||||
|
||||
/// disassocio i record di processi del task
|
||||
/// Rimetto i processi disassociati al task
|
||||
/// alla lista diprocessi disponibili
|
||||
|
||||
for (int i=element.length;i>0;i--)
|
||||
{
|
||||
aProcessBean =(ProcessBean) processTask.elementAt(Integer.parseInt(element[i-1]));
|
||||
processTask.remove(Integer.parseInt(element[i-1]));
|
||||
processi.add(aProcessBean);
|
||||
}
|
||||
// aTaskBean.setVectorProcessi(processTask);
|
||||
|
||||
|
||||
|
||||
retCommand = CommandsDef.PROCESSI_ASSOCIATI;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_ASSOCIA_PROCESSO :
|
||||
|
||||
{ // Cmd per la associazione di processi ad un task.
|
||||
|
||||
ProcessBean aProcessBean =new ProcessBean();
|
||||
|
||||
//TaskBean aTaskBean =(TaskBean) session.getAttribute("oggettoTaskBean");
|
||||
|
||||
// processi ASSOCIATI E DISPONIBILI
|
||||
Vector processTask = (Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI);
|
||||
Vector processi =(Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_DISPONIBILI);
|
||||
|
||||
// PROCESSO DA ASSOCIARE
|
||||
String element=request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED);
|
||||
|
||||
// ORDINE
|
||||
int ordine=Integer.parseInt(request.getParameter("Ordine"));
|
||||
|
||||
|
||||
aProcessBean =(ProcessBean) processi.elementAt(Integer.parseInt(element));
|
||||
aProcessBean.setStatoUscita("Stato d'uscita "+"1");
|
||||
|
||||
// associo il processo e lo tolgo dai processi disponibili
|
||||
if (processTask.size() == 0)
|
||||
processTask.add(aProcessBean);
|
||||
else
|
||||
processTask.insertElementAt(aProcessBean,ordine-1);
|
||||
|
||||
processi.remove(Integer.parseInt(element));
|
||||
|
||||
retCommand = CommandsDef.PROCESSI_ASSOCIATI;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_ELIMINA_INTERVALLO :
|
||||
|
||||
{ // Cmd cheelimina un intervallo di attivazione.
|
||||
|
||||
//TaskBean aTaskBean =(TaskBean) session.getAttribute("oggettoTaskBean");
|
||||
Vector intervalli = (Vector) session.getAttribute(CrontabCostants.OBJECT_INTERVALLI_SESSION);
|
||||
intervalli.remove(Integer.parseInt(request.getParameter("elementoChecked")));
|
||||
|
||||
retCommand = CommandsDef.LISTA_INTERVALLI;
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_NUOVO_INTERVALLO :
|
||||
|
||||
{ // Inserisce un nuovo Intervallo di Attivazione
|
||||
// Acquisisce i campi del form
|
||||
|
||||
// TaskBean aTaskBean =(TaskBean) session.getAttribute("oggettoTaskBean");
|
||||
Vector intervalli =(Vector) session.getAttribute(CrontabCostants.OBJECT_INTERVALLI_SESSION);
|
||||
IntervalloAttivazione aIntervallo =new IntervalloAttivazione();
|
||||
aIntervallo.setIdIntervallo("IA" + Resources.getRandomString());
|
||||
// giorni della settimana oppure giorno del mese
|
||||
aIntervallo.setGiorniSettimana(request.getParameterValues("giorniSettimana"));
|
||||
aIntervallo.setGiornoMese(request.getParameter("giornoData"));
|
||||
|
||||
/// crea la label per il giorno
|
||||
if (aIntervallo.getGiorniSettimana() != null)
|
||||
aIntervallo.setGiorno(aIntervallo.costruisciLabelGiorno(aIntervallo.getGiorniSettimana()));
|
||||
else
|
||||
aIntervallo.setGiorno(aIntervallo.getGiornoMese());
|
||||
|
||||
//aIntervallo.setGiornoStop(request.getParameter("giornoStop"));
|
||||
|
||||
//aIntervallo.setGiornoMeseStop(request.getParameter("giornoDataStop"));
|
||||
|
||||
/// orario di partenza ed ultima partenza
|
||||
aIntervallo.setHourFrom(request.getParameter("oraFrom"));
|
||||
aIntervallo.setHourTo(request.getParameter("oraTo"));
|
||||
aIntervallo.setMinutiFrom(request.getParameter("minutiFrom"));
|
||||
aIntervallo.setMinutiTo(request.getParameter("minutiTo"));
|
||||
|
||||
aIntervallo.setOraFrom(aIntervallo.getHourFrom()+":"+aIntervallo.getMinutiFrom());
|
||||
|
||||
if (aIntervallo.getHourTo().equals("") || aIntervallo.getMinutiTo().equals(""))
|
||||
{
|
||||
aIntervallo.setOraTo("");
|
||||
aIntervallo.setHourTo(null);
|
||||
aIntervallo.setMinutiTo(null);
|
||||
}
|
||||
else
|
||||
aIntervallo.setOraTo(aIntervallo.getHourTo()+":"+aIntervallo.getMinutiTo());
|
||||
|
||||
aIntervallo.setEveryPeriodo(request.getParameter("every"));
|
||||
|
||||
aIntervallo.setDeadline(request.getParameter("deadline"));
|
||||
|
||||
// da controllare
|
||||
aIntervallo.setLabelIntervallo(aIntervallo.costruisciLabel(aIntervallo));
|
||||
|
||||
intervalli.addElement(aIntervallo);
|
||||
|
||||
retCommand = CommandsDef.LISTA_INTERVALLI;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_MODIFICA_INTERVALLO :
|
||||
|
||||
{ // Inserisce una modifica ad un Intervallo di Attivazione
|
||||
// Acquisisce i campi del form
|
||||
|
||||
|
||||
Vector intervalli =(Vector) session.getAttribute(CrontabCostants.OBJECT_INTERVALLI_SESSION);
|
||||
|
||||
IntervalloAttivazione aIntervallo =(IntervalloAttivazione)
|
||||
intervalli.elementAt(Integer.parseInt(request.getParameter("elementoChecked")));
|
||||
|
||||
/// giorni della settimana oppure giorno del mese
|
||||
aIntervallo.setGiorniSettimana(request.getParameterValues("giorniSettimana"));
|
||||
aIntervallo.setGiornoMese(request.getParameter("giornoData"));
|
||||
|
||||
/// crea la label per il giorno
|
||||
if (aIntervallo.getGiorniSettimana() != null)
|
||||
aIntervallo.setGiorno(aIntervallo.costruisciLabelGiorno(aIntervallo.getGiorniSettimana()));
|
||||
else
|
||||
aIntervallo.setGiorno(aIntervallo.getGiornoMese());
|
||||
|
||||
//aIntervallo.setGiornoStop(request.getParameter("giornoStop"));
|
||||
|
||||
//aIntervallo.setGiornoMeseStop(request.getParameter("giornoDataStop"));
|
||||
|
||||
/// orario di partenza ed ultima partenza
|
||||
aIntervallo.setHourFrom(request.getParameter("oraFrom"));
|
||||
aIntervallo.setHourTo(request.getParameter("oraTo"));
|
||||
aIntervallo.setMinutiFrom(request.getParameter("minutiFrom"));
|
||||
aIntervallo.setMinutiTo(request.getParameter("minutiTo"));
|
||||
|
||||
aIntervallo.setOraFrom(aIntervallo.getHourFrom()+":"+aIntervallo.getMinutiFrom());
|
||||
|
||||
if (aIntervallo.getHourTo().equals("") || aIntervallo.getMinutiTo().equals(""))
|
||||
{
|
||||
aIntervallo.setOraTo("");
|
||||
aIntervallo.setHourTo(null);
|
||||
aIntervallo.setMinutiTo(null);
|
||||
}
|
||||
else
|
||||
aIntervallo.setOraTo(aIntervallo.getHourTo()+":"+aIntervallo.getMinutiTo());
|
||||
|
||||
aIntervallo.setEveryPeriodo(request.getParameter("every"));
|
||||
|
||||
aIntervallo.setDeadline(request.getParameter("deadline"));
|
||||
|
||||
// da controllare
|
||||
aIntervallo.setLabelIntervallo(aIntervallo.costruisciLabel(aIntervallo));
|
||||
|
||||
retCommand = CommandsDef.LISTA_INTERVALLI;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_NUOVO_INTERVALLO :
|
||||
|
||||
{ // Function che fa accedere al form di inserimento di un intervallo di attivazione
|
||||
|
||||
request.setAttribute(CrontabCostants.TIPO_OPERAZIONE,String.valueOf(CrontabCostants.CMD_NUOVO_INTERVALLO));
|
||||
IntervalloAttivazione aIntervallo =new IntervalloAttivazione();
|
||||
if (aIntervallo.getGiorniSettimana()==null)
|
||||
{
|
||||
aIntervallo.setGiorniSettimana(new String[7]);
|
||||
}
|
||||
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,aIntervallo);
|
||||
retCommand = CommandsDef.INSERT_INTERVALLO;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.FNC_MODIFICA_INTERVALLO :
|
||||
|
||||
{ // Function che fa accedere al form di modifica di un intervallo di attivazione
|
||||
|
||||
request.setAttribute(CrontabCostants.TIPO_OPERAZIONE,String.valueOf(CrontabCostants.CMD_MODIFICA_INTERVALLO));
|
||||
request.setAttribute(CrontabCostants.CAMPO_ELEMENT_CHECKED,request.getParameter("elementoChecked"));
|
||||
|
||||
//TaskBean aTaskBean =(TaskBean) session.getAttribute("oggettoTaskBean");
|
||||
Vector intervalli = (Vector) session.getAttribute(CrontabCostants.OBJECT_INTERVALLI_SESSION);
|
||||
IntervalloAttivazione aIntervallo = (IntervalloAttivazione) intervalli.elementAt(Integer.parseInt(request.getParameter("elementoChecked")));
|
||||
|
||||
if (aIntervallo.getGiorniSettimana()==null)
|
||||
{
|
||||
aIntervallo.setGiorniSettimana(new String[7]);
|
||||
}
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,aIntervallo);
|
||||
|
||||
retCommand = CommandsDef.INSERT_INTERVALLO;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_NUOVO_TASK :
|
||||
|
||||
{ // Comando che inserisce un nuovo task
|
||||
// Acquisisce i campi del form
|
||||
// Questo dovrebbe scatenare diverse situazioni tipo il ricalcolo
|
||||
// attività dello schedulatore
|
||||
actionCode=ActionLogMapping.NuovoTask;
|
||||
EventTime et=new EventTime();
|
||||
// setto TaskInfo
|
||||
TaskInfo aTaskBean =new TaskInfo(Resources.getID_TASK(request.getParameter("Nome")), request.getParameter("Nome"),
|
||||
request.getParameter("Descrizione"),request.getParameter("Note"),et.getTime(),et.getTime(),false);
|
||||
|
||||
// Intervalli Attivazione
|
||||
Vector intervalli =(Vector) session.getAttribute(CrontabCostants.OBJECT_INTERVALLI_SESSION);
|
||||
IntervalloAttivazione aIntervallo;
|
||||
for (int i=0; i<intervalli.size();i++)
|
||||
{
|
||||
aIntervallo= (IntervalloAttivazione) intervalli.elementAt(i);
|
||||
|
||||
if (aIntervallo.getGiorniSettimana() == null)
|
||||
{ aIntervallo.setGiorno("");
|
||||
aTaskBean.addRegolaAttivazione(FormatterCommand.
|
||||
formatterIntervalliToRegolaAttivazione(aIntervallo));
|
||||
}
|
||||
else
|
||||
{ String[] giorni=aIntervallo.getGiorniSettimana();
|
||||
|
||||
for (Iterator iter = FormatterCommand.formatterIntervalliToRegoleAttivazioneIterator(aIntervallo); iter.hasNext(); ) {
|
||||
RegolaAttivazione item = (RegolaAttivazione)iter.next();
|
||||
aTaskBean.addRegolaAttivazione(item);
|
||||
}
|
||||
|
||||
/*
|
||||
for (int j = 0; j < aIntervallo.getGiorniSettimana().length; j++) {
|
||||
aIntervallo.setGiorno(giorni[j]);
|
||||
aTaskBean.addRegolaAttivazione(FormatterCommand.
|
||||
formatterIntervalliToRegolaAttivazione(aIntervallo));
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
// Processi Associati
|
||||
Vector processi =(Vector) session.getAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI);
|
||||
ProcessBean aProcess;
|
||||
boolean stato=false;
|
||||
for (int i=0; i<processi.size();i++)
|
||||
{
|
||||
aProcess= (ProcessBean) processi.elementAt(i);
|
||||
if (aProcess.getStatoProcesso().equals(CrontabCostants.STATO_PROCESSO_ABILITATO))
|
||||
stato=true;
|
||||
else
|
||||
stato=false;
|
||||
|
||||
aTaskBean.addProcessInfo(
|
||||
FormatterCommand.formatterProcessToProcessInfo(taskManagerMonitor,aProcess),i,stato);
|
||||
|
||||
}
|
||||
|
||||
// add TaskInfo
|
||||
taskManagerMonitor.add(aTaskBean);
|
||||
// riporto la lista aggiornata
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTask(taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.LISTA_TASKS;
|
||||
|
||||
//log security
|
||||
objectLog="Task=" + aTaskBean.getId()+" - "+ aTaskBean.getName();
|
||||
paramLog=aTaskBean.getProcessMapToLog();
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case CrontabCostants.FNC_NUOVO_TASK :
|
||||
|
||||
{ // Function che fa accedere al form di inserimento di un task
|
||||
|
||||
aCrontabSession.setLabelOperazione(CrontabCostants.LABEL_OPERAZIONE_NUOVO_TASK);
|
||||
aCrontabSession.setCmdOperazione(CrontabCostants.CMD_NUOVO_TASK);
|
||||
|
||||
TaskBean aTaskBean = new TaskBean();
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,aTaskBean);
|
||||
|
||||
// in sessione il vector di intervalli di attivazione
|
||||
// tale oggetto servirà dal lato Client per la gestione degli intervalli
|
||||
// tale oggetto sarà memorizzato al conferma dei dati del Task
|
||||
session.setAttribute(CrontabCostants.OBJECT_INTERVALLI_SESSION,new Vector());
|
||||
|
||||
// in sessione i processi associati al task
|
||||
session.setAttribute(CrontabCostants.OBJECT_PROCESSI_ASSOCIATI, new Vector());
|
||||
|
||||
// in sessione i processi disponibili
|
||||
Vector ProcessiDisponibili = FormatterCommand.getProcessiDisponibili(taskManagerMonitor.getAvailableProcess());
|
||||
session.setAttribute(CrontabCostants.OBJECT_PROCESSI_DISPONIBILI,ProcessiDisponibili);
|
||||
|
||||
retCommand = CommandsDef.INSERT_TASK;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_ELIMINA_TASK :
|
||||
|
||||
{ // Comando che Elimina un task
|
||||
// Controllare se si elimina un task in running poichè deve avvenire prima
|
||||
// l'arresta task.
|
||||
|
||||
//log security
|
||||
actionCode=ActionLogMapping.EliminaTask;
|
||||
TaskInfo aTask=taskManagerMonitor.getTask(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
objectLog="Task=" + aTask.getId()+" - "+ aTask.getName();
|
||||
paramLog=aTask.getProcessMapToLog();
|
||||
|
||||
// remove TaskInfo
|
||||
taskManagerMonitor.remove(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
|
||||
// riporto la lista aggiornata
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTask(taskManagerMonitor));
|
||||
|
||||
|
||||
retCommand = CommandsDef.LISTA_TASKS;
|
||||
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_DISABILITA_TASK :
|
||||
|
||||
{ // Comando che Disabilita un task che è in fase di Standby
|
||||
|
||||
actionCode=ActionLogMapping.DisabilitaTask;
|
||||
// prelevo task
|
||||
|
||||
TaskInfo aTask=taskManagerMonitor.getTask(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
aTask.setEnabled(false);
|
||||
//abilito task
|
||||
taskManagerMonitor.update(aTask);
|
||||
// riporto la lista aggiornata
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTask(taskManagerMonitor));
|
||||
retCommand = CommandsDef.LISTA_TASKS;
|
||||
|
||||
//log security
|
||||
objectLog="Task=" + aTask.getId()+" - "+ aTask.getName();
|
||||
paramLog=aTask.getProcessMapToLog();
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CrontabCostants.CMD_ABILITA_TASK :
|
||||
|
||||
{ // Comando che Abilita un task che è in fase di Disabilitato
|
||||
|
||||
actionCode=ActionLogMapping.AbilitaTask;
|
||||
// prelevo task
|
||||
|
||||
TaskInfo aTask=taskManagerMonitor.getTask(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
aTask.setEnabled(true);
|
||||
//abilito task
|
||||
taskManagerMonitor.update(aTask);
|
||||
// riporto la lista aggiornata
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTask(taskManagerMonitor));
|
||||
retCommand = CommandsDef.LISTA_TASKS;
|
||||
|
||||
//log security
|
||||
objectLog="Task=" + aTask.getId()+" - "+ aTask.getName();
|
||||
paramLog=aTask.getProcessMapToLog();
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
case CrontabCostants.CMD_START_TASK :
|
||||
|
||||
{ // Comando che RUNNING un task che è in fase di standby
|
||||
|
||||
//starto task
|
||||
taskManagerMonitor.startForced(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
// riporto la lista aggiornata
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTask(taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.LISTA_TASKS;
|
||||
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case CrontabCostants.CMD_ARRESTA_TASK :
|
||||
|
||||
{ // Comando che arresta un task che è in fase di running
|
||||
// riportando il task in fase di standby
|
||||
|
||||
actionCode=ActionLogMapping.ArrestoTask;
|
||||
//arresto task
|
||||
System.out.println("1-"+request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
System.out.println("2-"+request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED_PARAM));
|
||||
taskManagerMonitor.stopForced(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED));
|
||||
// taskManagerMonitor.stopForced(request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED),
|
||||
// request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED_PARAM));
|
||||
// riporto la lista aggiornata
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
FormatterCommand.formatterListaTaskSchedulati(taskManagerMonitor));
|
||||
|
||||
retCommand = CommandsDef.ATTIVITA_GIORNALIERA;
|
||||
|
||||
//log security
|
||||
objectLog="Task=" + request.getParameter(CrontabCostants.CAMPO_ELEMENT_CHECKED);
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK , objectLog ,ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
session.setAttribute(CrontabCostants.STATO_CONFIGURAZIONE, ((taskManagerMonitor.getSaved())?Boolean.TRUE: Boolean.FALSE));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
ex.printStackTrace(new PrintWriter(sw));
|
||||
myException = new Exception("Errore interno: "+ex.toString());
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN, myException);
|
||||
retCommand = CommandsDef.ERROR_DO;
|
||||
|
||||
//log security
|
||||
if (actionCode!=0){
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO, objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
}
|
||||
|
||||
return retCommand;
|
||||
}
|
||||
|
||||
return retCommand;
|
||||
}
|
||||
|
||||
public static boolean nuovoTask(java.util.Vector ListaSession,TaskBean aTaskBean,int idTask)
|
||||
{
|
||||
|
||||
// controllo che non ci siano già Intervalli di Attivazione e Processi già Inseriti
|
||||
if (idTask != ListaSession.size())
|
||||
{
|
||||
aTaskBean.setIdTask(String.valueOf(ListaSession.size()+1));
|
||||
aTaskBean.setOraPartenza("");
|
||||
aTaskBean.setLabelProcessAssociati("");
|
||||
ListaSession.addElement(aTaskBean);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Vector eliminaTask(Vector ListaTask,String idTask,CrontabSession aCrontabSession) throws Exception {
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Tale metodo ha le seguenti funzionalità
|
||||
// 1 - Controllare che il task da eliminare sia infase di running
|
||||
// 2 - Eliminare il task
|
||||
// 2 - Ricreare la lista dei task con le nuove informazioni
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
TaskBean aTaskBean = (TaskBean) ListaTask.elementAt(Integer.parseInt(idTask));
|
||||
// controllo la modalità del task selezionato
|
||||
if (aTaskBean.getModalita().equals(CrontabCostants.MODALITA_RUNNING))
|
||||
aCrontabSession.setStato_Schedulatore(CrontabCostants.STATO_SCHEDULATORE_STANDBY);
|
||||
|
||||
// Elimino il task
|
||||
ListaTask.remove(aTaskBean);
|
||||
|
||||
return ListaTask;
|
||||
}
|
||||
|
||||
public Vector disabilitaTask(Vector ListaTask,String idTask) throws Exception {
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Tale metodo ha le seguenti funzionalità
|
||||
// 1 - Disabilitare il task che in quel momento è in fase di standby
|
||||
// 2 - Ricreare la lista dei task con le nuove informazioni
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
//// 1 - metodo di Luca (in attesa)
|
||||
|
||||
//// 2 ---------------
|
||||
//// Estrapolo il task in fase di standby
|
||||
|
||||
TaskBean aTaskBean = (TaskBean) ListaTask.elementAt(Integer.parseInt(idTask));
|
||||
aTaskBean.setModalita(CrontabCostants.MODALITA_DISABLED);
|
||||
|
||||
// controllare se il valore è stato modificato nel vettore
|
||||
|
||||
|
||||
|
||||
return ListaTask;
|
||||
}
|
||||
|
||||
public Vector abilitaTask(Vector ListaTask,String idTask) throws Exception {
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Tale metodo ha le seguenti funzionalità
|
||||
// 1 - Abilitare il task che in quel momento è in fase di disabilitato
|
||||
// 2 - Ricreare la lista dei task con le nuove informazioni
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
//// 1 - metodo di Luca (in attesa)
|
||||
|
||||
//// 2 ---------------
|
||||
//// Estrapolo il task in fase di disabled
|
||||
|
||||
TaskBean aTaskBean = (TaskBean) ListaTask.elementAt(Integer.parseInt(idTask));
|
||||
aTaskBean.setModalita(CrontabCostants.MODALITA_STANDBY);
|
||||
|
||||
// controllare se il valore è stato modificato nel vettore
|
||||
|
||||
|
||||
|
||||
return ListaTask;
|
||||
}
|
||||
|
||||
public Vector startTask(Vector ListaTask,String idTask) throws Exception {
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Tale metodo ha le seguenti funzionalità
|
||||
// 1 - Startare il task che in quel momento è in fase di standby
|
||||
// 2 - Riportare la modalità del task in fase running
|
||||
// 3 - Ricreare la lista dei task con le nuove informazioni
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
//// 1 - metodo di Luca (in attesa)
|
||||
|
||||
//// 2 ---------------
|
||||
//// Estrapolo il task in fase di standby
|
||||
|
||||
TaskBean aTaskBean = (TaskBean) ListaTask.elementAt(Integer.parseInt(idTask));
|
||||
aTaskBean.setModalita(CrontabCostants.MODALITA_RUNNING);
|
||||
|
||||
// controllare se il valore è stato modificato nel vettore
|
||||
|
||||
|
||||
|
||||
return ListaTask;
|
||||
}
|
||||
|
||||
public Vector arrestaTask(Vector ListaTask,String idTask) throws Exception {
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Tale metodo ha le seguenti funzionalità
|
||||
// 1 - Arrestare il task che in quel momento è in fase di running
|
||||
// 2 - Riportare la modalità del task in fase standby
|
||||
// 3 - Ricreare la lista dei task con le nuove informazioni
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
//// 1 - metodo di Luca (in attesa)
|
||||
|
||||
//// 2 ---------------
|
||||
//// Estrapolo il task in fase di running
|
||||
|
||||
TaskBean aTaskBean = (TaskBean) ListaTask.elementAt(Integer.parseInt(idTask));
|
||||
aTaskBean.setModalita(CrontabCostants.MODALITA_STANDBY);
|
||||
|
||||
// controllare se il valore è stato modificato nel vettore
|
||||
|
||||
|
||||
|
||||
return ListaTask;
|
||||
}
|
||||
|
||||
public static Vector listaIntervalliAttivazione(Vector ListaTask,String idTask) throws Exception {
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Tale metodo ha le seguenti funzionalità
|
||||
// 1 - Estrapolare dalla Lista dei Task , il task indicato da Id del parametro d'ingresso
|
||||
// 2 - Estrapolare dal Task, il vector di Intervalli di Attivazione
|
||||
// 3 - Controllo che se il task non ha Intervalli di Attivazione deve fornire un vector vuoto
|
||||
// e non nulllo
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
try
|
||||
{
|
||||
//// 1 -
|
||||
|
||||
TaskBean aTaskBean = (TaskBean) ListaTask.elementAt(Integer.parseInt(idTask));
|
||||
}
|
||||
|
||||
catch (Exception ex){
|
||||
// se cattura questa eccezione significa che stiamo inserendo prima gli
|
||||
// Intervalli di Attivazione.
|
||||
return new Vector();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//// 2 ---------------
|
||||
|
||||
return ListaTask;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,736 @@
|
||||
package mnp.crontab.command;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import javax.servlet.http.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import it.valueteam.logging.*;
|
||||
import mnp.crontab.config.am.*;
|
||||
import mnp.crontab.engine.mbean.*;
|
||||
import mnp.crontab.objects.am.*;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
import mnp.crontab.utility.*;
|
||||
import it.valueteam.crontab.jms.AppConfigurationMessageHandler;
|
||||
|
||||
|
||||
|
||||
public class XMLCommand
|
||||
extends AbstractCommand {
|
||||
|
||||
String retCommand;
|
||||
Exception myException;
|
||||
ManagerSession aManagerSession;
|
||||
ApplicationController appController = new ApplicationController();
|
||||
Configuration aConfiguration = new Configuration();
|
||||
|
||||
private static Logger log = Logger.getLogger(XMLCommand.class.getName());
|
||||
|
||||
public XMLCommand() {
|
||||
}
|
||||
|
||||
public String execute(HttpServletRequest request, HttpServletResponse res) throws
|
||||
Exception,IOException {
|
||||
|
||||
//log security
|
||||
Map paramLog=null;
|
||||
String objectLog="";
|
||||
Azione a = null;
|
||||
int actionCode=0;
|
||||
|
||||
// istanza XMLBean
|
||||
HttpSession session = request.getSession();
|
||||
|
||||
XMLControllerConfig aXMLGestioneConfig = new XMLControllerConfig();
|
||||
|
||||
XMLObject aXMLObject = (XMLObject) session.getAttribute(
|
||||
ApplicationManagerCostants.OBJECT_SESSION_XML);
|
||||
aManagerSession = (ManagerSession) session.getAttribute(
|
||||
ApplicationManagerCostants.OBJECT_MANAGER_SESSION);
|
||||
|
||||
CrontabSession aCrontabSession = (CrontabSession) session.getAttribute(
|
||||
CrontabCostants.OBJECT_CRONTAB_SESSION);
|
||||
|
||||
// controllo se la sessione è scaduta
|
||||
if (session.isNew()) {
|
||||
session.invalidate();
|
||||
retCommand = CommandsDef.SESSIONE_INATTIVA;
|
||||
return retCommand;
|
||||
}
|
||||
|
||||
String jspName = request.getParameter("JSP_FUNCTION");
|
||||
|
||||
int jspNameValue = Integer.parseInt(jspName);
|
||||
|
||||
/* if (ExecutionProfile.valideCommandXML(aCrontabSession.getUser(),
|
||||
jspNameValue)) {
|
||||
retCommand = CommandsDef.ESITO_APPLICATION;
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
CrontabCostants.UTENTE_NON_ABILITATO);
|
||||
return retCommand;
|
||||
}
|
||||
*/
|
||||
|
||||
switch (jspNameValue) {
|
||||
|
||||
case ApplicationManagerCostants.FNC_CONFIGURAZIONE_XML: {
|
||||
// Ritorna APPLICATION CONTROLLER
|
||||
// ApplicationController appController = new ApplicationController();
|
||||
Configuration aConfiguration = appController.getConfiguration(
|
||||
ApplicationManagerCostants.
|
||||
XML_BINDING_NAME
|
||||
);
|
||||
aXMLObject = FormatterCommandApplication.
|
||||
formattaXMLObject_TO_XMLGestioneConfig(aConfiguration.
|
||||
getConfXMLSystem());
|
||||
|
||||
/// XML OBJECT in Sessione?????
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aXMLObject);
|
||||
session.setAttribute(ApplicationManagerCostants.OBJECT_SESSION_XML,
|
||||
aXMLObject);
|
||||
|
||||
aManagerSession.setTipo_file(ApplicationManagerCostants.
|
||||
TIPO_FILE_NO_ACK);
|
||||
aManagerSession.setPath_file(aConfiguration.getPath_Xml());
|
||||
retCommand = CommandsDef.XML_CONFIGURATION;
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.FNC_MODIFICA_FILE_XML:
|
||||
|
||||
{ // FORM DI MODIFICA DI FLUSSI
|
||||
|
||||
FileInfo aObjFile = getObjFile(aXMLObject, request);
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aObjFile);
|
||||
aManagerSession.setTipo_file(ApplicationManagerCostants.
|
||||
TIPO_FILE_NO_ACK);
|
||||
retCommand = CommandsDef.XML_CONF_FILE;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.FNC_MODIFICA_PRIORITA_XML:
|
||||
|
||||
{ // FORM DI MODIFICA DELLE PRIORITA' DEI PROCESSI
|
||||
|
||||
FileInfo aObjFile = getObjFile(aXMLObject, request);
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aObjFile);
|
||||
aManagerSession.setTipo_file(ApplicationManagerCostants.
|
||||
TIPO_FILE_NO_ACK);
|
||||
request.setAttribute("resultName", aManagerSession.getNome_file());
|
||||
retCommand = CommandsDef.XML_PRIORITY;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
// C.P kit luglio 2006
|
||||
case ApplicationManagerCostants.FNC_MODIFICA_PRIORITA_XML_IN:
|
||||
|
||||
{ // FORM DI MODIFICA DELLE PRIORITA' DEI PROCESSI
|
||||
|
||||
FileInfo aObjFile = getObjFile(aXMLObject, request);
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aObjFile);
|
||||
aManagerSession.setTipo_file(ApplicationManagerCostants.
|
||||
TIPO_FILE_NO_ACK);
|
||||
request.setAttribute("resultName", aManagerSession.getNome_file());
|
||||
retCommand = CommandsDef.XML_PRIORITY_IN;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case ApplicationManagerCostants.FNC_MODIFICA_PRIORITA_ACK_XML:
|
||||
|
||||
{ // FORM DI MODIFICA DELLE PRIORITA' DEI PROCESSI per FILE ACK
|
||||
|
||||
FileInfoAck aObjFile = getObjFileAck(aXMLObject, request);
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aObjFile);
|
||||
aManagerSession.setTipo_file(ApplicationManagerCostants.
|
||||
TIPO_FILE_ACK);
|
||||
request.setAttribute("resultName", aManagerSession.getNome_file());
|
||||
retCommand = CommandsDef.XML_PRIORITY_ACK;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.FNC_BACK_CONFIGURAZIONE_XML:
|
||||
|
||||
{ // FORM DI MODIFICA DI FLUSSI
|
||||
if (aManagerSession.getTipo_file().equals(ApplicationManagerCostants.
|
||||
TIPO_FILE_NO_ACK))
|
||||
retCommand = CommandsDef.XML_CONFIGURATION;
|
||||
else
|
||||
retCommand = CommandsDef.XML_CONFIGURATION_ACK;
|
||||
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aXMLObject);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.FNC_BACK_XML:
|
||||
|
||||
{ // TORNA INDIETRO ALLA GESTIONE XML
|
||||
|
||||
retCommand = CommandsDef.XML_CONFIGURATION;
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aXMLObject);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.CMD_AGGIORNA_FILE_XML:
|
||||
|
||||
{ // AGGIORNAMENTO DATI FLUSSO
|
||||
aXMLObject = aggiornaDatiFile(aXMLObject, request);
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aXMLObject);
|
||||
|
||||
retCommand = CommandsDef.XML_CONFIGURATION;
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.FNC_MODIFICA_SCHEDULAZIONE_XML:
|
||||
|
||||
{ // FORM DI MODIFICA DI FLUSSI
|
||||
if (aManagerSession.getTipo_file().equals(ApplicationManagerCostants.
|
||||
TIPO_FILE_NO_ACK))
|
||||
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
getIntervalloFromFile(aXMLObject, request));
|
||||
|
||||
else
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
getIntervalloFromFileAck(aXMLObject, request));
|
||||
|
||||
retCommand = CommandsDef.XML_CONF_SCHEDULAZIONE;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.CMD_MODIFICA_SCHEDULAZIONE_CCRM:
|
||||
|
||||
{ // AGGIORNAMENTO SCHEDULAZIONE
|
||||
FileInfoAck aObjFile;
|
||||
if (aManagerSession.getTipo_file().equals(ApplicationManagerCostants.
|
||||
TIPO_FILE_NO_ACK))
|
||||
|
||||
aObjFile = getAggiornaObjFile(aXMLObject, request);
|
||||
|
||||
else
|
||||
|
||||
aObjFile = getAggiornaObjFileAck(aXMLObject, request);
|
||||
|
||||
retCommand = CommandsDef.XML_CONF_FILE;
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aObjFile);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.FNC_MODIFICA_OPERATORE_XML:
|
||||
|
||||
{ // FORM DI MODIFICA DI FLUSSI
|
||||
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
getStatoOperatori(aXMLObject, request));
|
||||
request.setAttribute("resultName", aManagerSession.getNome_file());
|
||||
aManagerSession.setTipo_file(ApplicationManagerCostants.
|
||||
TIPO_FILE_NO_ACK);
|
||||
retCommand = CommandsDef.XML_STATO_OPERATORE;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.CMD_AGGIORNA_OPERATORE_XML:
|
||||
|
||||
{ // AGGIORNA tutti i DATI DEL SISTEMA CCRM sul file xml
|
||||
|
||||
if (aManagerSession.getTipo_file().equals(ApplicationManagerCostants.
|
||||
TIPO_FILE_NO_ACK)) {
|
||||
aXMLObject = getDatiAbilitazioneOperatore(aXMLObject, request);
|
||||
retCommand = CommandsDef.XML_CONFIGURATION;
|
||||
}
|
||||
else {
|
||||
aXMLObject = getDatiAbilitazioneOperatoreAck(aXMLObject, request);
|
||||
retCommand = CommandsDef.XML_CONFIGURATION_ACK;
|
||||
}
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aXMLObject);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.CMD_AGGIORNA_PRIORITA_XML:
|
||||
|
||||
{ // AGGIORNA tutti le priorità dei processi di un determinato File XML
|
||||
// TIPO_FILE_NO_ACK - significa tipologia file
|
||||
// TIPO_FILE_ACK - significa tipologia file ack
|
||||
if (aManagerSession.getTipo_file().equals(ApplicationManagerCostants.
|
||||
TIPO_FILE_NO_ACK)) {
|
||||
aXMLObject = getDatiPriorita(aXMLObject, request);
|
||||
retCommand = CommandsDef.XML_CONFIGURATION;
|
||||
}
|
||||
else {
|
||||
aXMLObject = getDatiPrioritaAck(aXMLObject, request);
|
||||
retCommand = CommandsDef.XML_CONFIGURATION_ACK;
|
||||
}
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aXMLObject);
|
||||
|
||||
}
|
||||
break;
|
||||
// C.P. kit luglio 2006
|
||||
case ApplicationManagerCostants.CMD_AGGIORNA_PRIORITA_XML_IN:
|
||||
|
||||
{ // AGGIORNA tutti le priorità dei processi di un determinato File XML per l'ingresso
|
||||
aXMLObject = getDatiPrioritaIn(aXMLObject, request);
|
||||
retCommand = CommandsDef.XML_CONFIGURATION;
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,aXMLObject);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case ApplicationManagerCostants.FNC_LISTA_FILE_ACK:
|
||||
|
||||
{ // Gestione della Configurazione dei File_ACK
|
||||
aManagerSession.setTipo_file(ApplicationManagerCostants.TIPO_FILE_ACK);
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aXMLObject);
|
||||
|
||||
retCommand = CommandsDef.XML_CONFIGURATION_ACK;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.FNC_OPERATORE_ACK:
|
||||
|
||||
{ // FORM DI MODIFICA DI FLUSSI
|
||||
|
||||
request.setAttribute(CrontabCostants.OBJECT_RESULT_BEAN,
|
||||
getStatoOperatoriAck(aXMLObject, request));
|
||||
request.setAttribute("resultName", aManagerSession.getNome_file());
|
||||
|
||||
retCommand = CommandsDef.XML_STATO_OPERATORE;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.FNC_SCHEDULAZIONE_ACK:
|
||||
|
||||
{ // FORM DI MODIFICA DI FLUSSI
|
||||
|
||||
FileInfoAck aObjFile = getObjFileAck(aXMLObject, request);
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
aObjFile);
|
||||
|
||||
retCommand = CommandsDef.XML_CONF_FILE;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ApplicationManagerCostants.CMD_APPLY_ALL_XML:
|
||||
|
||||
{ // AGGIORNA e apllica tutte le modifiche apportate ai
|
||||
// DATI di configurazione dei vari file xml.
|
||||
|
||||
actionCode=ActionLogMapping.SalvaDatiSistemaXML;
|
||||
|
||||
try {
|
||||
|
||||
// Aggiorna la configurazione
|
||||
XmlControllerWrapper _xmlWrapper = FormatterCommandApplication.
|
||||
formattaWrapperXmlToXMLObject(aXMLObject);
|
||||
aConfiguration.setConfXMLSystem(_xmlWrapper);
|
||||
XMLControllerConfig _xmlController = (XMLControllerConfig)
|
||||
appController.updateConfiguration(aConfiguration,
|
||||
ApplicationManagerCostants.
|
||||
XML_BINDING_NAME);
|
||||
log.info("Aggiorna la configurazione");
|
||||
|
||||
// Passa la configurazione al Controller di MNP
|
||||
|
||||
try {
|
||||
inviaConfigurazioneXML(res, _xmlController);
|
||||
log.info("Notifica la configurazione aggiornata dei File XML a MNP");
|
||||
}
|
||||
catch (IOException io) {
|
||||
throw io;
|
||||
}
|
||||
|
||||
// Salva la configurazione sul file GestioneXML.xml
|
||||
_xmlWrapper.save();
|
||||
log.info(
|
||||
"Salva la configurazione aggiornata sul file GestioneXML.xml");
|
||||
|
||||
request.setAttribute(ApplicationManagerCostants.OBJECT_RESULT_BEAN,
|
||||
ApplicationManagerCostants.
|
||||
MESSAGE_CONFIRM_UPDATE_XML);
|
||||
|
||||
retCommand = CommandsDef.ESITO_APPLICATION;
|
||||
|
||||
//log security
|
||||
objectLog = "Dati Sistema XML";
|
||||
paramLog = new TreeMap();
|
||||
paramLog.put("Abilitazione",
|
||||
Boolean.valueOf(aXMLObject.isAbilitazione()));
|
||||
paramLog.put("Numero Massimo di Richieste",
|
||||
aXMLObject.getNroRichieste());
|
||||
paramLog.put("Tempo Massimo di Attesa", aXMLObject.getMaxTempoAttesa());
|
||||
ArrayList al = aXMLObject.getListaFile();
|
||||
for (int i = 0; i < al.size(); i++) {
|
||||
FileInfo fi = (FileInfo) al.get(i);
|
||||
paramLog.put(fi.getNome(), fi.getStringToLog());
|
||||
}
|
||||
al = aXMLObject.getListaFileAck();
|
||||
for (int i = 0; i < al.size(); i++) {
|
||||
FileInfoAck fi = (FileInfoAck) al.get(i);
|
||||
paramLog.put(fi.getNome(), fi.getStringToLog());
|
||||
}
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_OK, objectLog, ActionLogMapping.LOG_RESULT_CODE_OK);
|
||||
this.setActionLog(a);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
//log security
|
||||
a = new Azione(actionCode, paramLog, ActionLogMapping.LOG_RESULT_CODE_DETAIL_KO , objectLog ,ActionLogMapping.LOG_RESULT_CODE_KO);
|
||||
this.setActionLog(a);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return retCommand;
|
||||
}
|
||||
|
||||
|
||||
public FileInfo getObjFile(XMLObject aXMLObject,
|
||||
javax.servlet.http.HttpServletRequest
|
||||
request) throws Exception {
|
||||
int _file = Integer.parseInt(request.getParameter(
|
||||
ApplicationManagerCostants.CAMPO_ELEMENT_CHECKED));
|
||||
FileInfo objFile = (FileInfo) aXMLObject.getListaFile().get(_file);
|
||||
|
||||
aManagerSession.setID_TipologiaFile(request.getParameter(
|
||||
ApplicationManagerCostants.CAMPO_ELEMENT_CHECKED));
|
||||
aManagerSession.setNome_file(objFile.getNome());
|
||||
return objFile;
|
||||
}
|
||||
|
||||
public FileInfoAck getObjFileAck(XMLObject aXMLObject,
|
||||
javax.servlet.http.HttpServletRequest
|
||||
request) throws Exception {
|
||||
int _file = Integer.parseInt(request.getParameter(
|
||||
ApplicationManagerCostants.CAMPO_ELEMENT_CHECKED));
|
||||
FileInfoAck objFile = (FileInfoAck) aXMLObject.getListaFileAck().get(_file);
|
||||
|
||||
aManagerSession.setID_TipologiaFile(request.getParameter(
|
||||
ApplicationManagerCostants.CAMPO_ELEMENT_CHECKED));
|
||||
aManagerSession.setNome_file(objFile.getNome());
|
||||
return objFile;
|
||||
}
|
||||
|
||||
public FileInfo getAggiornaObjFile(XMLObject aXMLObject,
|
||||
javax.servlet.http.HttpServletRequest
|
||||
request) throws Exception {
|
||||
int _file = Integer.parseInt(aManagerSession.getID_TipologiaFile());
|
||||
int _intervallo = Integer.parseInt(aManagerSession.getID_Intervallo());
|
||||
FileInfo objFile = (FileInfo) aXMLObject.getListaFile().get(_file);
|
||||
IntervalloAttivazione ia = (IntervalloAttivazione) objFile.
|
||||
getListaSchedulazione().get(_intervallo);
|
||||
|
||||
/// orario di partenza ed ultima partenza
|
||||
ia.setOraFrom(request.getParameter("oraFrom") + ":" +
|
||||
request.getParameter("minutiFrom"));
|
||||
ia.setOraTo(request.getParameter("oraTo") + ":" +
|
||||
request.getParameter("minutiTo"));
|
||||
//ia.setMinutiFrom(request.getParameter("minutiFrom"));
|
||||
//ia.setMinutiTo(request.getParameter("minutiTo"));
|
||||
|
||||
objFile.setLabelSchedulazione(FormatterCommandApplication.componiLabel("S",
|
||||
objFile.getListaSchedulazione()));
|
||||
|
||||
return objFile;
|
||||
}
|
||||
|
||||
public FileInfoAck getAggiornaObjFileAck(XMLObject aXMLObject,
|
||||
javax.servlet.http.HttpServletRequest
|
||||
request) throws Exception {
|
||||
int _file = Integer.parseInt(aManagerSession.getID_TipologiaFile());
|
||||
int _intervallo = Integer.parseInt(aManagerSession.getID_Intervallo());
|
||||
FileInfoAck objFile = (FileInfoAck) aXMLObject.getListaFileAck().get(_file);
|
||||
IntervalloAttivazione ia = (IntervalloAttivazione) objFile.
|
||||
getListaSchedulazione().get(_intervallo);
|
||||
|
||||
/// orario di partenza ed ultima partenza
|
||||
ia.setOraFrom(request.getParameter("oraFrom") + ":" +
|
||||
request.getParameter("minutiFrom"));
|
||||
ia.setOraTo(request.getParameter("oraTo") + ":" +
|
||||
request.getParameter("minutiTo"));
|
||||
//ia.setMinutiFrom(request.getParameter("minutiFrom"));
|
||||
//ia.setMinutiTo(request.getParameter("minutiTo"));
|
||||
|
||||
objFile.setLabelSchedulazione(FormatterCommandApplication.componiLabel("S",
|
||||
objFile.getListaSchedulazione()));
|
||||
|
||||
return objFile;
|
||||
}
|
||||
|
||||
public XMLObject aggiornaDatiFile(XMLObject aXMLObject,
|
||||
javax.servlet.http.HttpServletRequest
|
||||
request) throws Exception {
|
||||
//int _file = Integer.parseInt(aManagerSession.getID_TipologiaFile());
|
||||
//FileInfo objFile = (FileInfo) aXMLObject.getListaFile().get(_file);
|
||||
//objFile = getDatiFile(objFile, request);
|
||||
if (request.getParameter("abilitazione").equals("Si"))
|
||||
aXMLObject.setAbilitazione(true);
|
||||
else
|
||||
aXMLObject.setAbilitazione(false);
|
||||
|
||||
aXMLObject.setMaxTempoAttesa(request.getParameter("maxTempoAttesa"));
|
||||
aXMLObject.setNroRichieste(request.getParameter("nroMassimoRichieste"));
|
||||
|
||||
return aXMLObject;
|
||||
}
|
||||
|
||||
public FileInfo getDatiFile(FileInfo objFile,
|
||||
javax.servlet.http.HttpServletRequest
|
||||
request) throws Exception {
|
||||
|
||||
objFile.setNome(request.getParameter("nomeFile"));
|
||||
return objFile;
|
||||
}
|
||||
|
||||
public IntervalloAttivazione getIntervalloFromFile(XMLObject aXMLObject,
|
||||
javax.servlet.http.HttpServletRequest
|
||||
request) throws Exception {
|
||||
int _file = Integer.parseInt(aManagerSession.getID_TipologiaFile());
|
||||
|
||||
FileInfo objFile = (FileInfo) aXMLObject.getListaFile().get(_file);
|
||||
|
||||
aManagerSession.setID_Intervallo(request.getParameter(
|
||||
ApplicationManagerCostants.CAMPO_ELEMENT_CHECKED));
|
||||
int _intervallo = Integer.parseInt(aManagerSession.getID_Intervallo());
|
||||
|
||||
IntervalloAttivazione ia = (IntervalloAttivazione) objFile.
|
||||
getListaSchedulazione().get(_intervallo);
|
||||
|
||||
return ia;
|
||||
}
|
||||
|
||||
public IntervalloAttivazione getIntervalloFromFileAck(XMLObject aXMLObject,
|
||||
javax.servlet.http.HttpServletRequest
|
||||
request) throws Exception {
|
||||
int _file = Integer.parseInt(aManagerSession.getID_TipologiaFile());
|
||||
|
||||
FileInfoAck objFile = (FileInfoAck) aXMLObject.getListaFileAck().get(_file);
|
||||
|
||||
aManagerSession.setID_Intervallo(request.getParameter(
|
||||
ApplicationManagerCostants.CAMPO_ELEMENT_CHECKED));
|
||||
int _intervallo = Integer.parseInt(aManagerSession.getID_Intervallo());
|
||||
|
||||
IntervalloAttivazione ia = (IntervalloAttivazione) objFile.
|
||||
getListaSchedulazione().get(_intervallo);
|
||||
|
||||
return ia;
|
||||
}
|
||||
|
||||
public ArrayList getStatoOperatori(XMLObject aXMLObject,
|
||||
javax.servlet.http.HttpServletRequest
|
||||
request) throws Exception {
|
||||
ArrayList aL = new ArrayList();
|
||||
String r = request.getParameter(ApplicationManagerCostants.
|
||||
CAMPO_ELEMENT_CHECKED);
|
||||
int _file = Integer.parseInt(r);
|
||||
|
||||
aManagerSession.setID_TipologiaFile(r);
|
||||
|
||||
FileInfo objFile = (FileInfo) aXMLObject.getListaFile().get(_file);
|
||||
aL = objFile.getListaOperatori();
|
||||
aManagerSession.setNome_file(objFile.getNome());
|
||||
return aL;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList getStatoOperatoriAck(XMLObject aXMLObject,
|
||||
javax.servlet.http.HttpServletRequest
|
||||
request) throws Exception {
|
||||
ArrayList aL = new ArrayList();
|
||||
String r = request.getParameter(ApplicationManagerCostants.
|
||||
CAMPO_ELEMENT_CHECKED);
|
||||
int _file = Integer.parseInt(r);
|
||||
|
||||
aManagerSession.setID_TipologiaFile(r);
|
||||
|
||||
FileInfoAck objFile = (FileInfoAck) aXMLObject.getListaFileAck().get(_file);
|
||||
aL = objFile.getListaOperatori();
|
||||
aManagerSession.setNome_file(objFile.getNome());
|
||||
return aL;
|
||||
|
||||
}
|
||||
|
||||
public XMLObject getDatiAbilitazioneOperatore(XMLObject aXMLObject,
|
||||
javax.servlet.http.
|
||||
HttpServletRequest
|
||||
request) throws Exception {
|
||||
|
||||
ItemBean aItem;
|
||||
FileInfo FI = (FileInfo) aXMLObject.getListaFile().get(Integer.parseInt(
|
||||
aManagerSession.getID_TipologiaFile()));
|
||||
|
||||
ArrayList aList = FI.getListaOperatori();
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
aItem = (ItemBean) aList.get(i);
|
||||
|
||||
if (request.getParameter(String.valueOf(i)).equals(
|
||||
"Si"))
|
||||
aItem.setValuesBoolean(true);
|
||||
else
|
||||
aItem.setValuesBoolean(false);
|
||||
}
|
||||
FI.setLabelOperatori(FormatterCommandApplication.componiLabel("O", aList));
|
||||
return aXMLObject;
|
||||
|
||||
}
|
||||
|
||||
public XMLObject getDatiAbilitazioneOperatoreAck(XMLObject aXMLObject,
|
||||
javax.servlet.http.
|
||||
HttpServletRequest
|
||||
request) throws Exception {
|
||||
|
||||
ItemBean aItem;
|
||||
FileInfoAck FI = (FileInfoAck) aXMLObject.getListaFileAck().get(Integer.parseInt(
|
||||
aManagerSession.getID_TipologiaFile()));
|
||||
|
||||
ArrayList aList = FI.getListaOperatori();
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
aItem = (ItemBean) aList.get(i);
|
||||
|
||||
if (request.getParameter(String.valueOf(i)).equals(
|
||||
"Si"))
|
||||
aItem.setValuesBoolean(true);
|
||||
else
|
||||
aItem.setValuesBoolean(false);
|
||||
}
|
||||
FI.setLabelOperatori(FormatterCommandApplication.componiLabel("O", aList));
|
||||
return aXMLObject;
|
||||
|
||||
}
|
||||
/**
|
||||
* Dati PRIORITA' PROCESSO
|
||||
* @param aXMLObject
|
||||
* @param request
|
||||
* @return
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
private XMLObject getDatiPriorita(XMLObject aXMLObject,
|
||||
HttpServletRequest request) throws Exception {
|
||||
TipoProcesso aItem;
|
||||
FileInfo FI = (FileInfo) aXMLObject.getListaFile().get(Integer.parseInt(
|
||||
aManagerSession.getID_TipologiaFile()));
|
||||
|
||||
ArrayList aList = FI.getListaPriorita();
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
aItem = (TipoProcesso) aList.get(i);
|
||||
aItem.setCodicePriorita(Integer.parseInt(request.getParameter(aItem.getCodiceProcesso())));
|
||||
aItem.setDescPriorita(FormatterCommandApplication.getDescrizionePriorita(aItem.getCodicePriorita()));
|
||||
}
|
||||
FI.setLabelProcessiPriorita(FormatterCommandApplication.componiLabel("P", aList));
|
||||
|
||||
return aXMLObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Dati PRIORITA' PROCESSO
|
||||
* @param aXMLObject
|
||||
* @param request
|
||||
* @return
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
private XMLObject getDatiPrioritaIn(XMLObject aXMLObject,
|
||||
HttpServletRequest request) throws Exception {
|
||||
TipoProcesso aItem;
|
||||
FileInfo FI = (FileInfo) aXMLObject.getListaFile().get(Integer.parseInt(
|
||||
aManagerSession.getID_TipologiaFile()));
|
||||
|
||||
ArrayList aList = FI.getListaPrioritaIn();
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
aItem = (TipoProcesso) aList.get(i);
|
||||
aItem.setCodicePriorita(Integer.parseInt(request.getParameter(aItem.getCodiceProcesso())));
|
||||
aItem.setDescPriorita(FormatterCommandApplication.getDescrizionePriorita(aItem.getCodicePriorita()));
|
||||
}
|
||||
FI.setLabelProcessiPrioritaIn(FormatterCommandApplication.componiLabel("P", aList));
|
||||
|
||||
return aXMLObject;
|
||||
|
||||
}
|
||||
|
||||
private XMLObject getDatiPrioritaAck(XMLObject aXMLObject,
|
||||
HttpServletRequest request) throws Exception {
|
||||
TipoProcesso aItem;
|
||||
FileInfoAck FI = (FileInfoAck) aXMLObject.getListaFileAck().get(Integer.parseInt(
|
||||
aManagerSession.getID_TipologiaFile()));
|
||||
|
||||
ArrayList aList = FI.getListaPriorita();
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
aItem = (TipoProcesso) aList.get(i);
|
||||
aItem.setCodicePriorita(Integer.parseInt(request.getParameter(aItem.getCodiceProcesso())));
|
||||
aItem.setDescPriorita(FormatterCommandApplication.getDescrizionePriorita(aItem.getCodicePriorita()));
|
||||
}
|
||||
FI.setLabelProcessiPriorita(FormatterCommandApplication.componiLabel("P", aList));
|
||||
|
||||
return aXMLObject;
|
||||
|
||||
}
|
||||
public void inviaConfigurazioneXML(HttpServletResponse response,XMLControllerConfig _xmlController) throws Exception {
|
||||
|
||||
AppConfigurationMessageHandler.getInstance().insertTopic(_xmlController);
|
||||
// String urlStr = Resources.getURL_SERVLET_MNP();
|
||||
// String _response = null;
|
||||
// URL url = new URL(urlStr);
|
||||
// weblogic.net.http.HttpURLConnection connection = null;
|
||||
// if (url.getProtocol().equalsIgnoreCase("https")) {
|
||||
// connection = new weblogic.net.http.HttpsURLConnection(url);
|
||||
// }
|
||||
// else {
|
||||
// connection = new weblogic.net.http.HttpURLConnection(url);
|
||||
// }
|
||||
// connection.setRequestMethod("POST");
|
||||
// connection.setDoOutput(true);
|
||||
// connection.setDoInput(true);
|
||||
// ObjectOutputStream wout = new ObjectOutputStream(connection.getOutputStream());
|
||||
// wout.writeObject(_xmlController);
|
||||
// wout.flush();
|
||||
//
|
||||
// // Invio dati e chiusura canali
|
||||
// connection.connect();
|
||||
// _response = connection.getResponseMessage();
|
||||
// if (response == null || !_response.equalsIgnoreCase("OK")) {
|
||||
// throw new Exception("Colloquio con MNP non valido");
|
||||
// }
|
||||
// connection.disconnect();
|
||||
// wout.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package mnp.crontab.config.am;
|
||||
/// IMPORT APPLICATION MANAGER
|
||||
import it.valueteam.crontab.engine.exception.*;
|
||||
import mnp.crontab.command.*;
|
||||
import mnp.crontab.utility.*;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class AppManagerInitializer {
|
||||
public AppManagerInitializer() {
|
||||
}
|
||||
|
||||
// private static Logger log = Logger.getLogger(AppManagerInitializer.class.
|
||||
// getName());
|
||||
public static InternalSystemControllerConfig getInternalConfig() throws
|
||||
Exception {
|
||||
/////////// Carica il file SistemiInterni.xml
|
||||
InternalSystemControllerConfig _internalConfig = new
|
||||
InternalSystemControllerConfig();
|
||||
try {
|
||||
InternalSystemWrapper _internal = InternalSystemWrapper.getInstance(
|
||||
Resources.getPATH_CONF_SISTEMI());
|
||||
// (String) hashTable.get("sistemiInterniCfg")
|
||||
_internalConfig = new InternalSystemControllerConfig();
|
||||
_internalConfig.setListInternalSystem(FormatterCommandApplication.
|
||||
formattaSistemiInterni_TO_ArrayList(
|
||||
_internal.getListSystem()));
|
||||
// log.info(
|
||||
// "Oggetto per la Configurazione dei Sistemi Interni instanziato");
|
||||
}
|
||||
catch (NotValidCrontabFileException ex) {
|
||||
// log.error(ex);
|
||||
|
||||
// log.warn(
|
||||
// "Problemi con la configurazione viene caricato un file non correttamente");
|
||||
throw ex;
|
||||
|
||||
}
|
||||
return _internalConfig;
|
||||
|
||||
/////////// FINE Carica il file SistemiInterni.xml
|
||||
}
|
||||
|
||||
public static XMLControllerConfig getXmlConfig() throws Exception {
|
||||
/////////// Carica il file GestioneXML.xml
|
||||
XMLControllerConfig _xmlController = new XMLControllerConfig();
|
||||
try {
|
||||
XmlControllerWrapper _xmlWrapper = XmlControllerWrapper.getInstance(
|
||||
Resources.getPATH_CONF_XML_SISTEMA());
|
||||
// (String) hashTable.get("gestioneXmlCfg")
|
||||
_xmlController = FormatterCommandApplication.formattaConfigToWrapper(
|
||||
_xmlWrapper);
|
||||
// log.info("Oggetto per la Configurazione del Sistema XML instanziato");
|
||||
|
||||
}
|
||||
catch (NotValidCrontabFileException ex) {
|
||||
// log.error(ex);
|
||||
|
||||
// log.warn(
|
||||
// "Problemi con la configurazione viene caricato un file non correttamente");
|
||||
throw ex;
|
||||
}
|
||||
return _xmlController;
|
||||
/////////// FINE Carica il file GestioneXml.xml
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package mnp.crontab.config.am;
|
||||
import mnp.crontab.config.am.XmlControllerWrapper;
|
||||
public class Configuration implements java.io.Serializable{
|
||||
private String systemID;
|
||||
|
||||
private XmlControllerWrapper confXMLSystem;
|
||||
private java.util.ArrayList confSistemiInterni;
|
||||
private String path_Sistemi;
|
||||
private String path_Xml;
|
||||
public Configuration() {
|
||||
}
|
||||
public String getSystemID() {
|
||||
return systemID;
|
||||
}
|
||||
public void setSystemID(String systemID) {
|
||||
this.systemID = systemID;
|
||||
}
|
||||
public XmlControllerWrapper getConfXMLSystem() {
|
||||
return confXMLSystem;
|
||||
}
|
||||
public void setConfXMLSystem(XmlControllerWrapper confXMLSystem) {
|
||||
this.confXMLSystem = confXMLSystem;
|
||||
}
|
||||
public java.util.ArrayList getConfSistemiInterni() {
|
||||
return confSistemiInterni;
|
||||
}
|
||||
public void setConfSistemiInterni(java.util.ArrayList confSistemiInterni) {
|
||||
this.confSistemiInterni = confSistemiInterni;
|
||||
}
|
||||
public String getPath_Sistemi() {
|
||||
return path_Sistemi;
|
||||
}
|
||||
public void setPath_Sistemi(String path_Sistemi) {
|
||||
this.path_Sistemi = path_Sistemi;
|
||||
}
|
||||
public String getPath_Xml() {
|
||||
return path_Xml;
|
||||
}
|
||||
public void setPath_Xml(String path_Xml) {
|
||||
this.path_Xml = path_Xml;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package mnp.crontab.config.am;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class InfoFileWrapper implements Serializable {
|
||||
private String name;
|
||||
private java.util.ArrayList listSchedulation;
|
||||
private int IDtipo_file;
|
||||
private java.util.ArrayList listStateOperator;
|
||||
public InfoFileWrapper() {
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public java.util.ArrayList getListSchedulation() {
|
||||
return listSchedulation;
|
||||
}
|
||||
public void setListSchedulation(java.util.ArrayList listSchedulation) {
|
||||
this.listSchedulation = listSchedulation;
|
||||
}
|
||||
public int getIDtipo_file() {
|
||||
return IDtipo_file;
|
||||
}
|
||||
public void setIDtipo_file(int IDtipo_file) {
|
||||
this.IDtipo_file = IDtipo_file;
|
||||
}
|
||||
public java.util.ArrayList getListStateOperator() {
|
||||
return listStateOperator;
|
||||
}
|
||||
public void setListStateOperator(java.util.ArrayList listStateOperator) {
|
||||
this.listStateOperator = listStateOperator;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package mnp.crontab.config.am;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
import mnp.crontab.objects.ui.ItemBean;
|
||||
public class InternalSystemControllerConfig implements InternalSystemControllerConfigIF,java.io.Serializable{
|
||||
|
||||
/// I sistemi interni sono un ArrayList di ItemBean
|
||||
private java.util.ArrayList listInternalSystem;
|
||||
public InternalSystemControllerConfig() {
|
||||
}
|
||||
public java.util.ArrayList getListInternalSystem() {
|
||||
return listInternalSystem;
|
||||
}
|
||||
public void setListInternalSystem(java.util.ArrayList listInternalSystem) {
|
||||
this.listInternalSystem = listInternalSystem;
|
||||
}
|
||||
|
||||
public boolean getAbilitazione(int internal_system) {
|
||||
|
||||
for (int i = 0; i < this.listInternalSystem.size(); i++) {
|
||||
ItemBean aItem = (ItemBean)this.listInternalSystem.get(i);
|
||||
if (aItem.getValues().equals(String.valueOf(internal_system))) {
|
||||
if (aItem.isValuesBoolean())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package mnp.crontab.config.am;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface InternalSystemControllerConfigIF {
|
||||
|
||||
public boolean getAbilitazione(int internalSystem);
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
package mnp.crontab.config.am;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import org.exolab.castor.xml.*;
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.engine.exception.*;
|
||||
import mnp.crontab.config.lnternalSystemXml.*;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
//* Rappresenta un'astrazione del file di configurazione dei Sistemi Interni.
|
||||
//* Tutte le operazioni sul file di configurazione vengono effettuate mediante questa classe.
|
||||
|
||||
public class InternalSystemWrapper implements Serializable {
|
||||
private static InternalSystemWrapper _instance;
|
||||
private SistemiInterni internalSystem;
|
||||
private String fileCfg = null;
|
||||
private static Logger log = Logger.getLogger(InternalSystemWrapper.class.
|
||||
getName());
|
||||
|
||||
private String file = null;
|
||||
private java.util.ArrayList listSystem;
|
||||
|
||||
protected InternalSystemWrapper() {
|
||||
}
|
||||
|
||||
public static InternalSystemWrapper getInstance() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton factory. Crea un'istanza di configurazione se già non è stata creata.
|
||||
* Viene gestita una sola configurazione quindi una chiamata a questo metodo dopo
|
||||
* la prima manda in gc l'istanza di configurazione precedente e crea la nuova.
|
||||
* @param fileCfg File di configurazione da leggere
|
||||
* @return Istanza di configurazione associata al file specificato
|
||||
* @throws NotValidCrontabFileException file di configurazione non valido e non presente l'ultima
|
||||
* configurazione valida
|
||||
*/
|
||||
|
||||
public static InternalSystemWrapper getInstance(String fileCfg) throws
|
||||
NotValidCrontabFileException {
|
||||
if (_instance == null) {
|
||||
synchronized (mnp.crontab.config.am.InternalSystemWrapper.class) {
|
||||
if (_instance == null) {
|
||||
_instance = new mnp.crontab.config.am.InternalSystemWrapper();
|
||||
_instance.fileCfg = fileCfg;
|
||||
try {
|
||||
_instance.open(_instance.fileCfg);
|
||||
}
|
||||
catch (CrontabException ex) {
|
||||
throw new NotValidCrontabFileException("CrontabException: " +
|
||||
ex.toString());
|
||||
}
|
||||
catch (NotValidCrontabConfigException ex) {
|
||||
throw new NotValidCrontabFileException(
|
||||
"NotValidCrontabConfigException: " + ex.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Carica la configurazione specificata nel file passato per parametro.
|
||||
* @params file Filename del file di configurazione.
|
||||
* @throws CrontabException Se si verificano problemi nel parser del file
|
||||
* @throws NotValidCrontabConfigException Se il file specificato non è valido o è inesistente.
|
||||
*/
|
||||
|
||||
public void open(String file) throws CrontabException,
|
||||
NotValidCrontabConfigException {
|
||||
try {
|
||||
this.file = file;
|
||||
SistemiInterni internalSystem = SistemiInterni.unmarshal(new FileReader(
|
||||
file));
|
||||
RuleValidator ruleValidator = new RuleValidator();
|
||||
SistemiInterniItem _infoSistema;
|
||||
this.listSystem = new ArrayList();
|
||||
if (ruleValidator.isValid(internalSystem)) {
|
||||
for (int i = 0; i < internalSystem.getSistemiInterniItemCount(); i++) {
|
||||
_infoSistema = (SistemiInterniItem) internalSystem.
|
||||
getSistemiInterniItem(i);
|
||||
this.listSystem.add(_infoSistema.getInfoSistema());
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
throw new NotValidCrontabConfigException();
|
||||
}
|
||||
}
|
||||
catch (ValidationException ex) {
|
||||
throw new NotValidCrontabConfigException(ex);
|
||||
}
|
||||
catch (MarshalException ex) {
|
||||
throw new CrontabException(ex);
|
||||
}
|
||||
catch (FileNotFoundException ex) {
|
||||
throw new NotValidCrontabConfigException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.ArrayList getListSystem() {
|
||||
return this.listSystem;
|
||||
}
|
||||
|
||||
public void setListSystem(java.util.ArrayList listSystem) {
|
||||
this.listSystem = listSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Salva la configurazione in memoria sul file specificato per parametro.
|
||||
* @params file nome del file di configurazione da salvare.
|
||||
* @throws CrontabException Se si verificano problemi a scrivere il file o non è riuscita la conversione in XML
|
||||
* @throws NotValidCrontabConfigException Se la configurazione da salvare non è valida.
|
||||
*/
|
||||
|
||||
public void save() throws CrontabException, NotValidCrontabConfigException {
|
||||
RuleValidator ruleValidator = new RuleValidator();
|
||||
if (this.internalSystem.isValid() &&
|
||||
ruleValidator.isValid(this.internalSystem)) {
|
||||
try {
|
||||
String file = getFileCfg();
|
||||
// Faccio prima il backup del file su un .bak
|
||||
backup();
|
||||
// Salvo la nuova configurazione
|
||||
this.internalSystem.marshal(new FileWriter(file));
|
||||
this.internalSystem = null;
|
||||
}
|
||||
catch (ValidationException ex) {
|
||||
throw new NotValidCrontabConfigException(ex);
|
||||
}
|
||||
catch (MarshalException ex) {
|
||||
throw new CrontabException(ex);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new CrontabException(ex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new NotValidCrontabConfigException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna il path del file di configurazione
|
||||
* @return path del file di configurazione
|
||||
*/
|
||||
public synchronized String getFileCfg() {
|
||||
return this.fileCfg;
|
||||
}
|
||||
|
||||
private SistemiInterni makeInternalSystem() {
|
||||
|
||||
ArrayList aL = new ArrayList();
|
||||
InfoSistema aInfo = new InfoSistema();
|
||||
SistemiInterniItem aSysInt = new SistemiInterniItem();
|
||||
ItemBean aItemBean;
|
||||
|
||||
for (int i = 0; i < this.listSystem.size(); i++) {
|
||||
aItemBean = (ItemBean)this.listSystem.get(i);
|
||||
aInfo.setName(aItemBean.getLabels());
|
||||
aInfo.setSistemId(aItemBean.getValues());
|
||||
aInfo.setEnabled(aItemBean.isValuesBoolean());
|
||||
aSysInt.setInfoSistema(aInfo);
|
||||
this.internalSystem.addSistemiInterniItem(i, aSysInt);
|
||||
}
|
||||
|
||||
return this.internalSystem;
|
||||
}
|
||||
|
||||
public void setInternalSystem(SistemiInterni internalSystem) {
|
||||
this.internalSystem = internalSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Effettua il backup della configurazione corrente salvandola su un file:
|
||||
* <nomeFile>.bak
|
||||
*/
|
||||
public synchronized void backup() {
|
||||
try {
|
||||
FileReader inFile = new FileReader(this.fileCfg);
|
||||
|
||||
FileWriter outFile = new FileWriter(this.fileCfg +
|
||||
".bak");
|
||||
char[] buff = new char[655535];
|
||||
int len = 0;
|
||||
while ( (len = inFile.read(buff)) != -1) {
|
||||
outFile.write(buff, 0, len);
|
||||
}
|
||||
|
||||
// outFile.write(this.fileCfg + ".bak");
|
||||
|
||||
outFile.flush();
|
||||
outFile.close();
|
||||
inFile.close();
|
||||
log.info("backup del file " + this.fileCfg + " effettuato!");
|
||||
}
|
||||
|
||||
catch (IOException ex) {
|
||||
log.error(ex);
|
||||
}
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,449 @@
|
||||
package mnp.crontab.config.am;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.utility.*;
|
||||
import mnp.crontab.objects.am.*;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class XMLControllerConfig
|
||||
implements XMLControllerConfigIF,java.io.Serializable {
|
||||
private java.util.ArrayList listFile;
|
||||
private java.util.ArrayList listOperator;
|
||||
private int maxRequests;
|
||||
private boolean abilitazione;
|
||||
private long maxTimeOut;
|
||||
private java.util.ArrayList listFileAck;
|
||||
public XMLControllerConfig() {
|
||||
}
|
||||
|
||||
public java.util.ArrayList getListFile() {
|
||||
return listFile;
|
||||
}
|
||||
|
||||
public void setListFile(java.util.ArrayList listFile) {
|
||||
this.listFile = listFile;
|
||||
}
|
||||
|
||||
public java.util.ArrayList getListOperator() {
|
||||
return listOperator;
|
||||
}
|
||||
|
||||
public void setListOperator(java.util.ArrayList listOperator) {
|
||||
this.listOperator = listOperator;
|
||||
}
|
||||
|
||||
public int getMaxRequests() {
|
||||
return maxRequests;
|
||||
}
|
||||
|
||||
public void setMaxRequests(int maxRequests) {
|
||||
this.maxRequests = maxRequests;
|
||||
}
|
||||
|
||||
public boolean isAbilitazione() {
|
||||
return abilitazione;
|
||||
}
|
||||
|
||||
public void setAbilitazione(boolean abilitazione) {
|
||||
this.abilitazione = abilitazione;
|
||||
}
|
||||
|
||||
public long getMaxTimeOut() {
|
||||
return maxTimeOut*60000;
|
||||
}
|
||||
|
||||
public void setMaxTimeOut(long maxTimeOut) {
|
||||
this.maxTimeOut = maxTimeOut;
|
||||
}
|
||||
|
||||
public boolean isDateInInterval(int tipo_file, java.util.Date aDate) {
|
||||
|
||||
// Metodo che stabilisce se per un dato Tipo File "NO ACK"
|
||||
// la data passata come parametro
|
||||
// è all'interno dell'intervallo di Schedulazione
|
||||
// Tipo file è l'id del file
|
||||
// Data da controllare
|
||||
|
||||
for (int i = 0; i < this.listFile.size(); i++) {
|
||||
|
||||
FileInfo iF = (FileInfo)this.listFile.get(i);
|
||||
|
||||
if (tipo_file == Integer.parseInt(iF.getIdFile())) {
|
||||
// Controllo L'Operatore
|
||||
ArrayList aListSchedul = (ArrayList) iF.getListaSchedulazione();
|
||||
return checkIntervallo(aListSchedul, aDate);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDateInInterval(int tipo_file, java.util.Date aDate,
|
||||
int tipo_fileRef) {
|
||||
|
||||
// Metodo che stabilisce se per un dato Tipo File "ACK"
|
||||
// la data passata come parametro
|
||||
// è all'interno dell'intervallo di Schedulazione
|
||||
// Tipo file è l'id del file
|
||||
// Data da controllare
|
||||
// File riferimento
|
||||
|
||||
for (int i = 0; i < this.listFileAck.size(); i++) {
|
||||
|
||||
FileInfoAck iF = (FileInfoAck)this.listFileAck.get(i);
|
||||
|
||||
if (tipo_fileRef == Integer.parseInt(iF.getDescrizione())) {
|
||||
// Controllo L'Operatore
|
||||
ArrayList aListSchedul = (ArrayList) iF.getListaSchedulazione();
|
||||
return checkIntervallo(aListSchedul, aDate);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public boolean getAbilitazioneFiledaOperatore(int tipo_file,
|
||||
String operatore) {
|
||||
|
||||
// Metodo che stabilisce se per un dato Tipo File ( FILE NO_ACK)
|
||||
// l'operatore è abilitato o meno........... //
|
||||
// Tipo file è l'id del file
|
||||
// Operatore è il codice descrittore ( campo descrizione dell'oggetto)
|
||||
|
||||
|
||||
// Controllo LISTA FILE INFO
|
||||
for (int i = 0; i < this.listFile.size(); i++) {
|
||||
|
||||
FileInfo iF = (FileInfo)this.listFile.get(i);
|
||||
|
||||
if (tipo_file == Integer.parseInt(iF.getIdFile())) {
|
||||
// Controllo L'Operatore
|
||||
ArrayList aListOperator = (ArrayList) iF.getListaOperatori();
|
||||
if (checkOperatore(aListOperator, operatore))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public boolean getAbilitazioneFiledaOperatore(int tipo_file,String operatore,int tipo_fileRef)
|
||||
{
|
||||
|
||||
// Controllo LISTA FILE INFO ACK
|
||||
for (int i = 0; i < this.listFileAck.size(); i++) {
|
||||
|
||||
FileInfoAck iF_Ack = (FileInfoAck)this.listFileAck.get(i);
|
||||
|
||||
if (tipo_fileRef == Integer.parseInt(iF_Ack.getDescrizione())) {
|
||||
// Controllo L'Operatore
|
||||
ArrayList aListOperator = (ArrayList) iF_Ack.getListaOperatori();
|
||||
if (checkOperatore(aListOperator, operatore))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean getAbilitazione() {
|
||||
return this.isAbilitazione();
|
||||
}
|
||||
|
||||
public java.util.ArrayList getListFileAck() {
|
||||
return listFileAck;
|
||||
}
|
||||
|
||||
public void setListFileAck(java.util.ArrayList listFileAck) {
|
||||
this.listFileAck = listFileAck;
|
||||
}
|
||||
|
||||
private boolean checkOperatore(ArrayList aList, String operatore) {
|
||||
|
||||
ItemBean io = new ItemBean();
|
||||
|
||||
boolean check = false;
|
||||
//
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
io = (ItemBean) aList.get(i);
|
||||
|
||||
if (operatore.equals(io.getValues()))
|
||||
return io.isValuesBoolean();
|
||||
}
|
||||
|
||||
return check;
|
||||
}
|
||||
|
||||
private boolean checkIntervallo(ArrayList aList, java.util.Date aDate) {
|
||||
|
||||
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
IntervalloAttivazione aItem = (IntervalloAttivazione) aList.get(i);
|
||||
|
||||
// Conversione da stringa a Time
|
||||
|
||||
int fromH = Integer.parseInt(aItem.getOraFrom().substring(0, 2));
|
||||
int fromM = Integer.parseInt(aItem.getOraFrom().substring(3, 5));
|
||||
|
||||
int toH = Integer.parseInt(aItem.getOraTo().substring(0, 2));
|
||||
int toM = Integer.parseInt(aItem.getOraTo().substring(3, 5));
|
||||
|
||||
EventTime eT_from = new EventTime(fromH,fromM,0,0);
|
||||
EventTime eT_to = new EventTime(toH,toM,0,0);
|
||||
EventTime eT_date = new EventTime(aDate);
|
||||
|
||||
if ( (eT_from.before(eT_date)) && (eT_date.before(eT_to)))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estrae tutte le finestre temporali di invio dei file XML indipendentemente
|
||||
* dal tipo file
|
||||
* @return Elenco delle finestre temporali attive
|
||||
* AP - 5.04.2004
|
||||
*/
|
||||
private ArrayList getActivationInterval() {
|
||||
ArrayList elencoIntervalli = new ArrayList();
|
||||
//Vector interval = new Vector();
|
||||
|
||||
// Per tutti i file non ack
|
||||
for (int i = 0; i < this.listFile.size(); i++) {
|
||||
FileInfo iF = (FileInfo)this.listFile.get(i);
|
||||
//Ottengo l'elenco delle finestre temporali attive per il tipo file
|
||||
ArrayList aListSchedul = (ArrayList) iF.getListaSchedulazione();
|
||||
// Per ogni finestra temporale
|
||||
for (int j = 0; j < aListSchedul.size(); j++) {
|
||||
IntervalloAttivazione intAtt = (IntervalloAttivazione)aListSchedul.get(j);
|
||||
ActivationInterval actInt = getInterval(intAtt);
|
||||
// Se la finestra non è contenuta nel vettore l'aggiungo
|
||||
|
||||
if(!elencoIntervalli.contains(actInt))
|
||||
elencoIntervalli.add(actInt);
|
||||
}
|
||||
}
|
||||
|
||||
// Per tutti i file che sono ack
|
||||
for (int i = 0; i < this.listFileAck.size(); i++) {
|
||||
FileInfoAck iFack = (FileInfoAck)this.listFileAck.get(i);
|
||||
//Ottengo l'elenco delle finestre temporali attive per il tipo file
|
||||
ArrayList ackListSched = (ArrayList) iFack.getListaSchedulazione();
|
||||
// Per ogni finestra temporal
|
||||
for (int j = 0; j < ackListSched.size(); j++) {
|
||||
IntervalloAttivazione ackAttInt = (IntervalloAttivazione)ackListSched.get(j);
|
||||
ActivationInterval ackActInt = getInterval(ackAttInt);
|
||||
// Se la finestra non è contenuta nel vettore l'aggiungo
|
||||
if(!elencoIntervalli.contains(ackActInt))
|
||||
elencoIntervalli.add(ackActInt);
|
||||
}
|
||||
|
||||
}
|
||||
elencoIntervalli = sortActivationInterval(elencoIntervalli);
|
||||
return elencoIntervalli;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica se l'ora attuale cade all'interno di una finestra temporale
|
||||
* @return boolean - true: l'ora attuale è dentro una finestra temporale
|
||||
* - false: l'ora attuale non è dentro una finestra temporale
|
||||
* AP - 5.04.2004
|
||||
*/
|
||||
public boolean isDateInInterval() {
|
||||
java.util.Date now = new Date();
|
||||
EventTime eventNow = new EventTime(now);
|
||||
//Ricavo tutte le finestre temporali attive
|
||||
ActivationInterval _interval =null;
|
||||
ArrayList actInt = getActivationInterval();
|
||||
|
||||
for (int i = 0; i < actInt.size(); i++) {
|
||||
_interval = (ActivationInterval) actInt.get(i);
|
||||
if(_interval.isInWindowTime(eventNow))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trasforma un oggetto di tipo IntervalloAttivazione in un oggetto di tipo
|
||||
* ActivationInterval
|
||||
* @param intervallo Oggetto da trasformare
|
||||
* @param id Identificativo
|
||||
* @return
|
||||
*/
|
||||
private ActivationInterval getInterval(IntervalloAttivazione intervallo){
|
||||
|
||||
int fromH = Integer.parseInt(intervallo.getOraFrom().substring(0, 2));
|
||||
int fromM = Integer.parseInt(intervallo.getOraFrom().substring(3, 5));
|
||||
|
||||
int toH = Integer.parseInt(intervallo.getOraTo().substring(0, 2));
|
||||
int toM = Integer.parseInt(intervallo.getOraTo().substring(3, 5));
|
||||
|
||||
EventTime eT_from = new EventTime(fromH,fromM,0,0);
|
||||
EventTime eT_to = new EventTime(toH,toM,0,0);
|
||||
ActivationInterval actInt = new ActivationInterval(eT_from, eT_to, "0");
|
||||
|
||||
return actInt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordina Array di ActivactionInterval
|
||||
* @param elencoIntervalli
|
||||
* @return
|
||||
*/
|
||||
private ArrayList sortActivationInterval(ArrayList elencoIntervalli) {
|
||||
|
||||
Collections.sort(elencoIntervalli,new Comparator()
|
||||
{
|
||||
public int compare(Object o1, Object o2)
|
||||
{
|
||||
ActivationInterval t1 = (ActivationInterval) o1;
|
||||
ActivationInterval t2 = (ActivationInterval) o2;
|
||||
int res = (t1.getFrom().before(t2.getFrom())) ? -1 :
|
||||
(t1.getFrom().after(t2.getFrom()) ? 1 : 0);
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return this.getClass().equals(o.getClass());
|
||||
}
|
||||
});
|
||||
|
||||
return elencoIntervalli;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estrae il prossimo ActivationInterval dall'ora attuale
|
||||
* @return ActivationInterval
|
||||
* MZ - 07.04.04
|
||||
*/
|
||||
|
||||
public ActivationInterval getNextActivationInterval()
|
||||
{
|
||||
java.util.Date now = new Date();
|
||||
EventTime eventNow = new EventTime(now);
|
||||
|
||||
ArrayList actInt = getActivationInterval();
|
||||
ActivationInterval _interval = null;
|
||||
ActivationInterval _intervalFirst = (ActivationInterval) actInt.get(0);
|
||||
|
||||
for (int i = 0; i < actInt.size(); i++) {
|
||||
_interval = (ActivationInterval) actInt.get(i);
|
||||
|
||||
// controllo se è prima di un intervallo
|
||||
if (eventNow.before(_interval.getFrom()))
|
||||
return _interval;
|
||||
}
|
||||
|
||||
return _intervalFirst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estrae la priorità del tipo processo al tipo file
|
||||
* @param tipo_file
|
||||
* @param tipo_processo
|
||||
* @return
|
||||
*/
|
||||
public int getPrioritaXML(int tipo_file, String tipo_processo) {
|
||||
int _priority = 0;
|
||||
|
||||
// Controllo LISTA FILE INFO
|
||||
for (int i = 0; i < this.listFile.size(); i++) {
|
||||
|
||||
FileInfo iF = (FileInfo)this.listFile.get(i);
|
||||
|
||||
if (tipo_file == Integer.parseInt(iF.getIdFile())) {
|
||||
// Controllo Le Priorità
|
||||
ArrayList aListPriority = (ArrayList) iF.getListaPriorita();
|
||||
return _priority = getValuePriority(aListPriority, tipo_processo);
|
||||
}
|
||||
|
||||
}
|
||||
return _priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estrae la priorità di ingresso del tipo processo al tipo file
|
||||
* @param tipo_file
|
||||
* @param tipo_processo
|
||||
* @return
|
||||
*/
|
||||
public int getPrioritaXMLIn(int tipo_file, String tipo_processo) {
|
||||
int _priority = 0;
|
||||
|
||||
// Controllo LISTA FILE INFO
|
||||
for (int i = 0; i < this.listFile.size(); i++) {
|
||||
|
||||
FileInfo iF = (FileInfo)this.listFile.get(i);
|
||||
|
||||
if (tipo_file == Integer.parseInt(iF.getIdFile())) {
|
||||
// Controllo Le Priorità
|
||||
ArrayList aListPriorityIn = (ArrayList) iF.getListaPrioritaIn();
|
||||
return _priority = getValuePriority(aListPriorityIn, tipo_processo);
|
||||
}
|
||||
|
||||
}
|
||||
return _priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estrae la priorità dei file di ack dal tipo processo e tipo file
|
||||
* @param tipo_file int
|
||||
* @param tipo_processo String
|
||||
* @param tipo_file_riferito int
|
||||
* @return int
|
||||
*/
|
||||
public int getPrioritaXML(int tipo_file, String tipo_processo,
|
||||
int tipo_file_riferito) {
|
||||
int _priority = 0;
|
||||
// Controllo LISTA FILE INFO ACK
|
||||
for (int i = 0; i < this.listFileAck.size(); i++) {
|
||||
FileInfoAck iF_Ack = (FileInfoAck)this.listFileAck.get(i);
|
||||
|
||||
if (tipo_file_riferito == Integer.parseInt(iF_Ack.getDescrizione())) {
|
||||
|
||||
// Controllo Le Priorità XML
|
||||
ArrayList aListPriority = (ArrayList) iF_Ack.getListaPriorita();
|
||||
return _priority = getValuePriority(aListPriority, tipo_processo);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return _priority;
|
||||
}
|
||||
|
||||
private int getValuePriority(ArrayList aListPriority, String tipo_processo) {
|
||||
|
||||
TipoProcesso tp = new TipoProcesso();
|
||||
|
||||
int priority = 0;
|
||||
//
|
||||
for (int i = 0; i < aListPriority.size(); i++) {
|
||||
tp = (TipoProcesso) aListPriority.get(i);
|
||||
|
||||
if (tipo_processo.equals(tp.getCodiceProcesso()))
|
||||
return tp.getCodicePriorita();
|
||||
}
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package mnp.crontab.config.am;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
import it.valueteam.crontab.config.*;
|
||||
|
||||
|
||||
public interface XMLControllerConfigIF {
|
||||
|
||||
public static int BASSA = 1;
|
||||
public static int NORMALE = 4;
|
||||
public static int ALTA = 9;
|
||||
|
||||
public int getMaxRequests();
|
||||
|
||||
public boolean getAbilitazione();
|
||||
|
||||
public long getMaxTimeOut();
|
||||
|
||||
public boolean isDateInInterval();
|
||||
|
||||
public boolean isDateInInterval(int tipo_file,java.util.Date aDate);
|
||||
|
||||
public boolean isDateInInterval(int tipo_file,java.util.Date aDate,int tipo_fileRef);
|
||||
|
||||
public boolean getAbilitazioneFiledaOperatore(int tipo_file,String operatore);
|
||||
|
||||
public boolean getAbilitazioneFiledaOperatore(int tipo_file,String operatore,int tipo_fileRef);
|
||||
|
||||
public ActivationInterval getNextActivationInterval();
|
||||
|
||||
/// Servizi per PRIORITA' XML
|
||||
|
||||
public int getPrioritaXML(int tipo_file,String tipo_processo);
|
||||
|
||||
public int getPrioritaXMLIn(int tipo_file,String tipo_processo);
|
||||
|
||||
public int getPrioritaXML(int tipo_file,String tipo_processo,int tipo_file_riferito);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
package mnp.crontab.config.am;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import org.exolab.castor.xml.*;
|
||||
import it.valueteam.crontab.config.*;
|
||||
import it.valueteam.crontab.engine.exception.*;
|
||||
import mnp.crontab.config.gestioneXml.*;
|
||||
|
||||
|
||||
public class XmlControllerWrapper implements Serializable {
|
||||
|
||||
private static XmlControllerWrapper _instance;
|
||||
private String fileCfg = null;
|
||||
private static Logger log = Logger.getLogger(XmlControllerWrapper.class.
|
||||
getName());
|
||||
private int _nroReqWrapper;
|
||||
private int _maxTime;
|
||||
private boolean abilitato;
|
||||
private java.util.ArrayList listaFileInfo;
|
||||
private java.util.ArrayList listaFileAck;
|
||||
private mnp.crontab.config.gestioneXml.ListFile _ListFile;
|
||||
|
||||
protected XmlControllerWrapper() {
|
||||
}
|
||||
|
||||
public static XmlControllerWrapper getInstance() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton factory. Crea un'istanza di configurazione se già non è stata creata.
|
||||
* Viene gestita una sola configurazione quindi una chiamata a questo metodo dopo
|
||||
* la prima manda in gc l'istanza di configurazione precedente e crea la nuova.
|
||||
* @param fileCfg File di configurazione da leggere
|
||||
* @return Istanza di configurazione associata al file specificato
|
||||
* @throws NotValidCrontabFileException file di configurazione non valido e non presente l'ultima
|
||||
* configurazione valida
|
||||
*/
|
||||
|
||||
public static XmlControllerWrapper getInstance(String fileCfg) throws
|
||||
NotValidCrontabFileException {
|
||||
if (_instance == null) {
|
||||
synchronized (mnp.crontab.config.am.XmlControllerWrapper.class) {
|
||||
if (_instance == null) {
|
||||
_instance = new mnp.crontab.config.am.XmlControllerWrapper();
|
||||
_instance.fileCfg = fileCfg;
|
||||
try {
|
||||
_instance.open();
|
||||
}
|
||||
catch (CrontabException ex) {
|
||||
ex.printStackTrace();
|
||||
throw new NotValidCrontabFileException("CrontabException: " +
|
||||
ex.toString());
|
||||
}
|
||||
catch (NotValidCrontabConfigException ex) {
|
||||
ex.printStackTrace();
|
||||
throw new NotValidCrontabFileException(
|
||||
"NotValidCrontabConfigException: " + ex.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Carica la configurazione specificata nel file passato per parametro.
|
||||
* @params file Filename del file di configurazione.
|
||||
* @throws CrontabException Se si verificano problemi nel parser del file
|
||||
* @throws NotValidCrontabConfigException Se il file specificato non è valido o è inesistente.
|
||||
*/
|
||||
|
||||
public void open() throws CrontabException,
|
||||
NotValidCrontabConfigException {
|
||||
try {
|
||||
|
||||
ListFile _ListFile = ListFile.unmarshal(new FileReader(
|
||||
this.fileCfg));
|
||||
this._ListFile = _ListFile;
|
||||
|
||||
/// Incolla i dati globali del file di gestione di XML
|
||||
this._nroReqWrapper = _ListFile.getNroRichieste();
|
||||
this._maxTime = _ListFile.getMaxTimeWait();
|
||||
this.abilitato = _ListFile.getEnabled();
|
||||
|
||||
InfoFile _infoFile = new InfoFile();
|
||||
InfoFileAck _infoFileAck = new InfoFileAck();
|
||||
listaFileInfo = new ArrayList();
|
||||
listaFileAck = new ArrayList();
|
||||
|
||||
RuleValidator ruleValidator = new RuleValidator();
|
||||
if (ruleValidator.isValid(_ListFile)) {
|
||||
|
||||
// Creo la lista di InfoFile
|
||||
for (int i = 0;
|
||||
i < _ListFile.getListInfoFile().getListInfoFileItemCount(); i++) {
|
||||
_infoFile = (InfoFile) _ListFile.
|
||||
getListInfoFile().getListInfoFileItem(i).getInfoFile();
|
||||
this.listaFileInfo.add(_infoFile);
|
||||
}
|
||||
|
||||
// Creo la lista di InfoFileAck
|
||||
for (int i = 0;
|
||||
i < _ListFile.getListInfoFileAck().getListInfoFileAckItemCount();
|
||||
i++) {
|
||||
_infoFileAck = (InfoFileAck) _ListFile.
|
||||
getListInfoFileAck().getListInfoFileAckItem(i).getInfoFileAck();
|
||||
this.listaFileAck.add(_infoFileAck);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
throw new NotValidCrontabConfigException();
|
||||
}
|
||||
|
||||
}
|
||||
catch (ValidationException ex) {
|
||||
throw new NotValidCrontabConfigException(ex);
|
||||
}
|
||||
catch (MarshalException ex) {
|
||||
throw new CrontabException(ex);
|
||||
}
|
||||
catch (FileNotFoundException ex) {
|
||||
throw new NotValidCrontabConfigException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Salva la configurazione in memoria sul file specificato per parametro.
|
||||
* @params file nome del file di configurazione da salvare.
|
||||
* @throws CrontabException Se si verificano problemi a scrivere il file o non è riuscita la conversione in XML
|
||||
* @throws NotValidCrontabConfigException Se la configurazione da salvare non è valida.
|
||||
*/
|
||||
|
||||
public void save() throws CrontabException, NotValidCrontabConfigException {
|
||||
RuleValidator ruleValidator = new RuleValidator();
|
||||
if (this._ListFile.isValid() &&
|
||||
ruleValidator.isValid(this._ListFile)) {
|
||||
try {
|
||||
String file = getFileCfg();
|
||||
// Faccio prima il backup del file su un .bak
|
||||
backup();
|
||||
// Salvo la nuova configurazione
|
||||
this._ListFile.marshal(new FileWriter(file));
|
||||
this._ListFile = null;
|
||||
}
|
||||
catch (ValidationException ex) {
|
||||
throw new NotValidCrontabConfigException(ex);
|
||||
}
|
||||
catch (MarshalException ex) {
|
||||
throw new CrontabException(ex);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new CrontabException(ex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new NotValidCrontabConfigException();
|
||||
}
|
||||
}
|
||||
|
||||
public String getFileCfg() {
|
||||
return fileCfg;
|
||||
}
|
||||
|
||||
public int get_nroReqWrapper() {
|
||||
return this.get_ListFile().getNroRichieste();
|
||||
}
|
||||
|
||||
public void set_nroReqWrapper(int _nroReqWrapper) {
|
||||
this._nroReqWrapper = _nroReqWrapper;
|
||||
}
|
||||
|
||||
public int get_maxTime() {
|
||||
return this.get_ListFile().getMaxTimeWait();
|
||||
}
|
||||
|
||||
public void set_maxTime(int _maxTime) {
|
||||
this._maxTime = _maxTime;
|
||||
}
|
||||
|
||||
public boolean isAbilitato() {
|
||||
return this.get_ListFile().getEnabled();
|
||||
}
|
||||
|
||||
public void setAbilitato(boolean abilitato) {
|
||||
this.abilitato = abilitato;
|
||||
}
|
||||
|
||||
public java.util.ArrayList getListaFileInfo() {
|
||||
return listaFileInfo;
|
||||
}
|
||||
|
||||
public void setListaFileInfo(java.util.ArrayList listaFileInfo) {
|
||||
this.listaFileInfo = listaFileInfo;
|
||||
}
|
||||
|
||||
public java.util.ArrayList getListaFileAck() {
|
||||
return listaFileAck;
|
||||
}
|
||||
|
||||
public void setListaFileAck(java.util.ArrayList listaFileAck) {
|
||||
this.listaFileAck = listaFileAck;
|
||||
}
|
||||
|
||||
public mnp.crontab.config.gestioneXml.ListFile get_ListFile() {
|
||||
return _ListFile;
|
||||
}
|
||||
|
||||
public void set_ListFile(mnp.crontab.config.gestioneXml.ListFile _ListFile) {
|
||||
this._ListFile = _ListFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Effettua il backup della configurazione corrente salvandola su un file:
|
||||
* <nomeFile>.bak
|
||||
*/
|
||||
public synchronized void backup() {
|
||||
try {
|
||||
FileReader inFile = new FileReader(this.fileCfg);
|
||||
|
||||
FileWriter outFile = new FileWriter(this.fileCfg +
|
||||
".bak");
|
||||
char[] buff = new char[655535];
|
||||
int len = 0;
|
||||
while ( (len = inFile.read(buff)) != -1) {
|
||||
outFile.write(buff, 0, len);
|
||||
}
|
||||
|
||||
// outFile.write(this.fileCfg + ".bak");
|
||||
|
||||
outFile.flush();
|
||||
outFile.close();
|
||||
inFile.close();
|
||||
log.info("backup del file " + this.fileCfg + " effettuato!");
|
||||
}
|
||||
|
||||
catch (IOException ex) {
|
||||
log.error(ex);
|
||||
}
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package mnp.crontab.config.ui;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
import mnp.crontab.objects.ui.FunctionBean;
|
||||
import java.io.*;
|
||||
|
||||
public class ProfileConfig implements Serializable {
|
||||
|
||||
/// Le Funzionalità di Profilo sono un ArrayList di FunctionBean
|
||||
|
||||
// COSTANTI PER AMMINISTRAZIONE GUI MNP
|
||||
|
||||
///// DOMINII
|
||||
public static final String DOMINIO_APPLICATION_MANAGER ="MAN";
|
||||
public static final String DOMINIO_MNP ="MNP";
|
||||
public static final String DOMINIO_CRONTAB ="CRO";
|
||||
|
||||
///// JSP NAME
|
||||
public static final String SISTEMI_CONFIGURAZIONE ="SistemiConfigurazione";
|
||||
public static final String XML_CONFIGURAZIONE ="XMLConfigurazione";
|
||||
public static final String BANNER_CRONTAB ="Banner";
|
||||
public static final String ATTIVITA_GIORNALIERA ="AttivitaGiornaliera";
|
||||
public static final String LISTA_TASK ="ListaTask";
|
||||
public static final String LISTA_PROCESSI ="ListaProcessi";
|
||||
public static final String LISTA_CONFIGURAZIONE ="Configurazione";
|
||||
public static final String BANNER_MNP ="Banner MNP";
|
||||
|
||||
private java.util.ArrayList listFunction;
|
||||
public ProfileConfig() {
|
||||
}
|
||||
public java.util.ArrayList getListFunction() {
|
||||
return listFunction;
|
||||
}
|
||||
public void setListFunction(java.util.ArrayList listFunction) {
|
||||
this.listFunction = listFunction;
|
||||
}
|
||||
public boolean visualizzaFunction(String _comando)
|
||||
{
|
||||
|
||||
boolean ret=false;
|
||||
for (int i = 0; i < this.listFunction.size(); i++) {
|
||||
FunctionBean aItem = (FunctionBean)this.listFunction.get(i);
|
||||
if (aItem.getComando().equals(_comando))
|
||||
return true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
}
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package mnp.crontab.database.dao;
|
||||
|
||||
/**
|
||||
* <p>Title: Progetto Gateway OLO MNP</p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2002</p>
|
||||
* <p>Company: </p>
|
||||
* @author Marco Palmini
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
//import java
|
||||
import java.sql.*;
|
||||
import javax.sql.*;
|
||||
import javax.naming.*;
|
||||
//import mnp
|
||||
import mnp.crontab.utility.*;
|
||||
|
||||
|
||||
public abstract class BaseDAO {
|
||||
|
||||
|
||||
protected DataSource ds;
|
||||
protected InitialContext ctx;
|
||||
protected String DATASOURCE = Resources.getDATA_SOURCE();
|
||||
private Connection conn;
|
||||
|
||||
|
||||
/**
|
||||
* Inizializza il data source
|
||||
* @throws Exception
|
||||
*/
|
||||
protected void initDB() throws Exception{
|
||||
try
|
||||
{
|
||||
ctx = new InitialContext();
|
||||
// DATASOURCE
|
||||
ds = (DataSource)ctx.lookup(DATASOURCE);
|
||||
//System.out.println("DataSource Ottenuto: "+ds);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
ctx.close();
|
||||
}
|
||||
catch (Exception ex) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo per ottenere le connessioni dal DB
|
||||
* Se non è disponibile una connessione ritorna null
|
||||
*/
|
||||
public Connection getConnection() throws Exception{
|
||||
Connection conn = null;
|
||||
try
|
||||
{
|
||||
if (ds==null) initDB();
|
||||
conn = ds.getConnection();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if( conn != null ) conn.setAutoCommit(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
// se non riesce ad ottenere una connessione per tre volte torna null
|
||||
return conn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Metodo per la chiusura del ResultSet,dello Statement e della Connection
|
||||
* tale metodo non lancia eccezzioni
|
||||
* @param rs
|
||||
* @param stmt
|
||||
* @param c
|
||||
*/
|
||||
public void closeAll(ResultSet rs, Statement stmt, Connection c) {
|
||||
try
|
||||
{
|
||||
if(rs!=null) rs.close();
|
||||
}
|
||||
catch (Throwable ex) {}
|
||||
try
|
||||
{
|
||||
if(stmt!=null) stmt.close();
|
||||
}
|
||||
catch (Throwable ex) {}
|
||||
try
|
||||
{
|
||||
if(c!=null && ds!=null) c.close();
|
||||
}
|
||||
catch (Throwable ex) {}
|
||||
}
|
||||
|
||||
|
||||
protected String getFieldsStr(int[] fieldIndex, String tableAlias, String[] fieldsName){
|
||||
|
||||
String s = "";
|
||||
for(int i=0;i<fieldIndex.length-1;i++){
|
||||
s = s + " " + tableAlias + "." + fieldsName[fieldIndex[i]] + "," ;
|
||||
}
|
||||
s = s + " " + tableAlias + "." + fieldsName[fieldIndex[fieldIndex.length-1]] ;
|
||||
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package mnp.crontab.database.dao;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
|
||||
import mnp.crontab.ejb.*;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
import mnp.crontab.utility.*;
|
||||
|
||||
|
||||
/**
|
||||
*LoginDAO
|
||||
*Description: DAO utilizzato per l'accesso al DB per le operazioni di login della GUI
|
||||
</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class LoginDAO extends BaseDAO {
|
||||
|
||||
/*Extra Kit Dicembre 06 - M.G. Eliminate le seguenti query:
|
||||
sql_getLoginInfo
|
||||
sql_getPassword
|
||||
sql_setLogged
|
||||
sql_setLoggedDbcgo
|
||||
sql_setLoggedOut
|
||||
sql_setLoggedOutDbcgo
|
||||
sql_setLoggedUpd
|
||||
sql_modifyPwd
|
||||
sql_modifyPwdDBCGO
|
||||
sql_modifyErrorLogin
|
||||
*/
|
||||
String sql_LoadFunzionalitaByProfilo =
|
||||
"SELECT f.* FROM MNP_FUNZIONALITA_GUI f, MNP_PROFILI_FUNZIONALITA " +
|
||||
"WHERE f.ID_PROG = MNP_PROFILI_FUNZIONALITA.ID_PROG " +
|
||||
" AND MNP_PROFILI_FUNZIONALITA.CODICE_PROFILO = ?";
|
||||
|
||||
//Query per verificare la correttezza della login
|
||||
String sql_getLoginInfo = "SELECT PROFILO,"+
|
||||
"CODICE_DOMINIO " +
|
||||
"FROM MNP_PROFILI_UTENTE " +
|
||||
"WHERE CODICE_PROFILO=? ";
|
||||
|
||||
String utente_admin = "admin";
|
||||
|
||||
|
||||
public LoginDAO() {
|
||||
}
|
||||
|
||||
/*Extra Kit Dicembre 06 - M.G. Eliminati i seguenti metodi:
|
||||
String getPassword(String userid)
|
||||
void updatePwd(LoginBean aLogin, int appCode,String ipAddr)
|
||||
void setLogged(String userid, String logged, String ip_address, int appCode)
|
||||
void setLoggedUpd(String userid, String logged, String ip_address)
|
||||
void updateError_Login(int _num, String userId)
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Costruisce oggetto di Login in base alla userId e alla password
|
||||
* @param userid Utente
|
||||
*/
|
||||
public LoginBean getUSERLogin(LoginBean aLogin) throws Exception {
|
||||
Connection conn = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
//LoginBean aLogin = null;
|
||||
|
||||
try {
|
||||
conn = getConnection();
|
||||
pstmt = conn.prepareStatement(sql_getLoginInfo);
|
||||
pstmt.setString(1, aLogin.getCodiceProfilo());
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
if (rs.next()) {
|
||||
aLogin.setProfilo(rs.getString("profilo"));
|
||||
aLogin.setCodiceDominio(rs.getString("codice_dominio"));
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
if (aLogin != null) {
|
||||
closeAll(rs, pstmt, null);
|
||||
|
||||
String cprofilo = aLogin.getCodiceProfilo();
|
||||
//System.out.println("codice: " + cprofilo);
|
||||
|
||||
pstmt = conn.prepareStatement(sql_LoadFunzionalitaByProfilo);
|
||||
pstmt.setString(1, cprofilo);
|
||||
rs = pstmt.executeQuery();
|
||||
ArrayList array = new ArrayList();
|
||||
|
||||
while (rs.next()) {
|
||||
//System.out.println("1");
|
||||
FunctionBean fb = new FunctionBean();
|
||||
fb.setId_prog(rs.getString("ID_PROG"));
|
||||
fb.setFunzionalita(rs.getString("FUNZIONALITA"));
|
||||
fb.setComando(rs.getString("COMANDO_FUNZ"));
|
||||
fb.setJspName(rs.getString("JSP_NAME"));
|
||||
fb.setDominio(rs.getString("CODICE_DOMINIO"));
|
||||
|
||||
//System.out.println("funz: " + fb.getFunzionalita());
|
||||
|
||||
array.add(fb);
|
||||
}
|
||||
FunctionBean[] fbs = new FunctionBean[array.size()];
|
||||
for (int i = 0; i < fbs.length; i++) {
|
||||
fbs[i] = (FunctionBean) array.get(i);
|
||||
}
|
||||
aLogin.setFunctionBeans(fbs);
|
||||
//---------------------------------------
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw ex;
|
||||
} finally {
|
||||
closeAll(rs, pstmt, conn);
|
||||
}
|
||||
return aLogin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isAdmin(String userid) {
|
||||
if (userid.equals(utente_admin))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ritorna un array di bean Funzionalita
|
||||
* @param profilo CODICE_PROFILO su tabella MNP_UTENTI
|
||||
*/
|
||||
public FunctionBean[] getFunctionBeans(String profilo) throws Exception {
|
||||
|
||||
Connection conn = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
FunctionBean[] fb = new FunctionBean[0];
|
||||
|
||||
try {
|
||||
conn = getConnection();
|
||||
pstmt = conn.prepareStatement(sql_LoadFunzionalitaByProfilo);
|
||||
|
||||
pstmt.setString(1, profilo);
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
int count = 0;
|
||||
while (rs.next()) {
|
||||
count++;
|
||||
}
|
||||
fb = new FunctionBean[count];
|
||||
|
||||
rs.beforeFirst();
|
||||
for (int i = 0; rs.next(); i++) {
|
||||
fb[i].setId_prog(rs.getString("ID_PROG"));
|
||||
fb[i].setFunzionalita(rs.getString("FUNZIONALITA"));
|
||||
fb[i].setComando(rs.getString("COMANDO_FUNZ"));
|
||||
fb[i].setJspName(rs.getString("JSP_NAME"));
|
||||
fb[i].setDominio(rs.getString("CODICE_DOMINIO"));
|
||||
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw ex;
|
||||
} finally {
|
||||
closeAll(rs, pstmt, conn);
|
||||
}
|
||||
return fb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package mnp.crontab.database.dao;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
public class LovDAO extends BaseDAO {
|
||||
|
||||
public static final int LOV_ID = 0;
|
||||
public static final int LOV_NAME = 1;
|
||||
public static final int NAME = 2;
|
||||
public static final int DESCR = 3;
|
||||
|
||||
public static final int FIELDCOUNT=4;
|
||||
|
||||
public static String[] fieldsName =
|
||||
{
|
||||
"LOV_ID",
|
||||
"LOV_NAME",
|
||||
"NAME",
|
||||
"DESCR"
|
||||
};
|
||||
|
||||
public static String tableName = "MNP_LOV";
|
||||
|
||||
public LovDAO() {
|
||||
}
|
||||
|
||||
//restituisce la chiave della Hash come Integer
|
||||
public Hashtable selectByLovName(String lovName) throws Exception {
|
||||
|
||||
int[] fieldIndex = {LOV_ID,LOV_NAME,NAME,DESCR};
|
||||
String s = "SELECT " + this.getFieldsStr(fieldIndex, tableName, fieldsName) +
|
||||
" FROM " + tableName +
|
||||
" WHERE " + fieldsName[LOV_NAME] + " = '" + lovName + "'";
|
||||
Connection conn = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
Hashtable ht = new Hashtable();
|
||||
try {
|
||||
conn = getConnection();
|
||||
pstmt = conn.prepareStatement(s);
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()){
|
||||
ht.put(new Integer(rs.getInt(fieldsName[NAME])),rs.getString(fieldsName[DESCR]));
|
||||
}
|
||||
} finally {
|
||||
closeAll(rs, pstmt, conn);
|
||||
}
|
||||
|
||||
return ht;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,459 @@
|
||||
package mnp.crontab.database.dao;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Vector;
|
||||
|
||||
import mnp.crontab.database.*;
|
||||
import mnp.crontab.objects.ListaFunzionalita;
|
||||
import mnp.crontab.objects.ui.ProfiloBean;
|
||||
import mnp.crontab.objects.ui.FunctionBean;
|
||||
import mnp.crontab.utility.*;
|
||||
import java.sql.ResultSet;
|
||||
import mnp.crontab.config.ui.ProfileConfig;
|
||||
|
||||
public class ProfiloDAO extends BaseDAO{
|
||||
public ProfiloDAO() {
|
||||
}
|
||||
|
||||
protected String SELECT_CAMPI_FUNZIONE ="SELECT mnp_funzionalita_gui.id_prog,funzionalita,jsp_name,dominio ";
|
||||
protected String TABELLE_CAMPI_FUNZIONE ="FROM mnp_funzionalita_gui,mnp_profili_funzionalita,mnp_dominio_funzioni ";
|
||||
protected String ORDER_BY_DOMINIO ="ORDER BY dominio";
|
||||
protected String ORDER_BY_FUNZIONE ="ORDER BY funzionalita";
|
||||
|
||||
String sql_ListaProfili =
|
||||
"SELECT codice_profilo, profilo, mnp_dominio_funzioni.dominio "+
|
||||
"FROM mnp_profili_utente, mnp_dominio_funzioni "+
|
||||
"WHERE mnp_dominio_funzioni.codice_dominio = mnp_profili_utente.codice_dominio "+
|
||||
"ORDER BY profilo";
|
||||
String sql_getProfilo =
|
||||
"SELECT codice_profilo, profilo, mnp_dominio_funzioni.dominio "+
|
||||
"FROM mnp_profili_utente, mnp_dominio_funzioni "+
|
||||
"WHERE mnp_dominio_funzioni.codice_dominio = mnp_profili_utente.codice_dominio "+
|
||||
"and codice_profilo=?";
|
||||
|
||||
String sql_FunzByProfilo =
|
||||
"SELECT funzionalita "+
|
||||
"FROM mnp_funzionalita_gui,mnp_profili_funzionalita "+
|
||||
"WHERE mnp_funzionalita_gui.id_prog=mnp_profili_funzionalita.id_prog "+
|
||||
"AND codice_profilo = ?"+
|
||||
"ORDER BY funzionalita";
|
||||
|
||||
String sql_ListFunzDaAssociare =
|
||||
SELECT_CAMPI_FUNZIONE+
|
||||
"FROM mnp_funzionalita_gui,mnp_dominio_funzioni "+
|
||||
"WHERE mnp_funzionalita_gui.codice_dominio=mnp_dominio_funzioni.codice_dominio "+
|
||||
"MINUS "+
|
||||
SELECT_CAMPI_FUNZIONE+TABELLE_CAMPI_FUNZIONE+
|
||||
"WHERE mnp_funzionalita_gui.id_prog=mnp_profili_funzionalita.id_prog "+
|
||||
"AND codice_profilo = ? "+
|
||||
ORDER_BY_FUNZIONE;
|
||||
|
||||
String sql_AssociaProfiloFunzione =
|
||||
"INSERT INTO mnp_profili_funzionalita "+
|
||||
"(CODICE_PROFILO,ID_PROG) "+
|
||||
"VALUES (?,?)";
|
||||
|
||||
String sql_DisassociaFunzione =
|
||||
"DELETE FROM mnp_profili_funzionalita "+
|
||||
"WHERE CODICE_PROFILO=? "+
|
||||
"AND ID_PROG=? ";
|
||||
|
||||
String sql_ListFunzDaDisassociare=
|
||||
"SELECT mnp_profili_funzionalita.id_prog,funzionalita,jsp_name,dominio "+
|
||||
"FROM mnp_profili_funzionalita,mnp_funzionalita_gui,mnp_dominio_funzioni "+
|
||||
"WHERE mnp_funzionalita_gui.codice_dominio = mnp_dominio_funzioni.codice_dominio "+
|
||||
"AND mnp_profili_funzionalita.id_prog = mnp_funzionalita_gui.id_prog "+
|
||||
"AND mnp_profili_funzionalita.codice_profilo=? "+
|
||||
ORDER_BY_FUNZIONE;
|
||||
|
||||
String sql_funzBYProfileDominio=
|
||||
"SELECT mnp_profili_funzionalita.id_prog,funzionalita,jsp_name,comando_funz "+
|
||||
"FROM mnp_profili_funzionalita,mnp_funzionalita_gui,mnp_dominio_funzioni "+
|
||||
"WHERE mnp_funzionalita_gui.codice_dominio = mnp_dominio_funzioni.codice_dominio "+
|
||||
"AND mnp_profili_funzionalita.id_prog = mnp_funzionalita_gui.id_prog "+
|
||||
"AND mnp_profili_funzionalita.codice_profilo=? "+
|
||||
"AND mnp_dominio_funzioni.codice_dominio=? "+
|
||||
"AND mnp_funzionalita_gui.jsp_name = ?";
|
||||
/**
|
||||
* Costruisce oggetto : INSIEME DI PROFILI
|
||||
* codice_profilo
|
||||
* profilo
|
||||
* dominio
|
||||
* funzionalita associate
|
||||
*/
|
||||
|
||||
public ProfiloBean[] listaProfili() throws Exception, SQLException {
|
||||
|
||||
ProfiloBean[] ret = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
conn = getConnection();
|
||||
pstmt = conn.prepareStatement(sql_ListaProfili);
|
||||
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
ret = caricaListaProfili(rs);
|
||||
|
||||
// Parte di Caricamento delle Funzionalita Associate ai vari profili
|
||||
String labelFunz="";
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
|
||||
pstmt = conn.prepareStatement(sql_FunzByProfilo);
|
||||
|
||||
pstmt.setString(1,ret[i].getCodice_profilo());
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
ret[i].setLabelFunction(caricaLabelFunction(rs));
|
||||
}
|
||||
}
|
||||
|
||||
catch (SQLException sqlex) {
|
||||
throw sqlex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
finally {
|
||||
closeAll(rs, pstmt, conn);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Costruisce oggetto :PROFIL0
|
||||
* codice_profilo
|
||||
* profilo
|
||||
* dominio
|
||||
* funzionalita associate
|
||||
*/
|
||||
|
||||
public ProfiloBean getProfilo(String codiceProfilo) throws Exception, SQLException {
|
||||
|
||||
ProfiloBean ret = null;
|
||||
ProfiloBean[] listaProfili = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
conn = getConnection();
|
||||
pstmt = conn.prepareStatement(sql_getProfilo);
|
||||
pstmt.setString(1,codiceProfilo);
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
listaProfili = caricaListaProfili(rs);
|
||||
|
||||
// Parte di Caricamento delle Funzionalita Associate ai vari profili
|
||||
String labelFunz = "";
|
||||
for (int i = 0; i < listaProfili.length; i++) {
|
||||
|
||||
pstmt = conn.prepareStatement(sql_FunzByProfilo);
|
||||
|
||||
pstmt.setString(1, listaProfili[i].getCodice_profilo());
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
listaProfili[i].setLabelFunction(caricaLabelFunction(rs));
|
||||
}
|
||||
if (listaProfili.length==1)
|
||||
ret=listaProfili[0];
|
||||
}
|
||||
catch (SQLException sqlex) {
|
||||
throw sqlex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
closeAll(rs, pstmt, conn);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public ListaFunzionalita getListFunctionForProfile(String _codiceProfilo) throws Exception, SQLException {
|
||||
|
||||
ListaFunzionalita ret = new ListaFunzionalita();
|
||||
Connection conn = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
conn = getConnection();
|
||||
pstmt = conn.prepareStatement(sql_ListFunzDaAssociare);
|
||||
|
||||
pstmt.setString(1,_codiceProfilo);
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
FunctionBean[] retF =caricaListaFunzionalita(rs);
|
||||
ret.setListaFunzione(retF);
|
||||
}
|
||||
|
||||
catch (SQLException sqlex) {
|
||||
throw sqlex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
finally {
|
||||
closeAll(rs, pstmt, conn);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
Carica la label delle eventuali funzionalita associate
|
||||
*/
|
||||
private String caricaLabelFunction(ResultSet rs) throws Exception,
|
||||
SQLException {
|
||||
String label = "";
|
||||
|
||||
try {
|
||||
while (rs.next())
|
||||
label += rs.getString(1) + "<br>";
|
||||
}
|
||||
catch (SQLException sqle) {
|
||||
throw sqle;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
/*
|
||||
Carica la lista delle Funzionalita
|
||||
*/
|
||||
|
||||
private FunctionBean[] caricaListaFunzionalita(ResultSet rs) throws Exception,SQLException{
|
||||
|
||||
FunctionBean[] ret = null;
|
||||
FunctionBean o = null;
|
||||
ArrayList listRec = new ArrayList();
|
||||
|
||||
try {
|
||||
while(rs.next()) {
|
||||
|
||||
o = new FunctionBean();
|
||||
o.setId_prog(rs.getString("id_prog"));
|
||||
o.setFunzionalita(rs.getString("funzionalita"));
|
||||
o.setJspName(rs.getString("jsp_name"));
|
||||
o.setDominio(rs.getString("dominio"));
|
||||
|
||||
listRec.add(o);
|
||||
}
|
||||
ret = new FunctionBean[listRec.size()];
|
||||
ret = (FunctionBean[])listRec.toArray(ret);
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
throw sqle;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Carica la lista dei Profili
|
||||
*/
|
||||
public ProfiloBean[] caricaListaProfili(ResultSet rs) throws Exception,SQLException {
|
||||
|
||||
ProfiloBean[] ret = null;
|
||||
ProfiloBean o = null;
|
||||
ArrayList listRec = new ArrayList();
|
||||
|
||||
try {
|
||||
while(rs.next()) {
|
||||
|
||||
o = new ProfiloBean();
|
||||
o.setCodice_profilo(rs.getString("codice_profilo"));
|
||||
o.setDominio(rs.getString("dominio"));
|
||||
o.setProfilo(rs.getString("profilo"));
|
||||
|
||||
listRec.add(o);
|
||||
}
|
||||
ret = new ProfiloBean[listRec.size()];
|
||||
ret = (ProfiloBean[])listRec.toArray(ret);
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
throw sqle;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ASSOCIA PROFILO A FUNZIONALITA
|
||||
public void associaProfilo_Function(String profilo, String[] element) throws
|
||||
SQLException, Exception {
|
||||
Connection c = null;
|
||||
PreparedStatement pstmt = null;
|
||||
|
||||
try {
|
||||
c = getConnection();
|
||||
|
||||
for (int i = 0; i < element.length; i++) {
|
||||
pstmt = c.prepareStatement(sql_AssociaProfiloFunzione);
|
||||
/*,
|
||||
ResultSet.TYPE_SCROLL_INSENSITIVE,
|
||||
ResultSet.CONCUR_READ_ONLY);
|
||||
*/
|
||||
pstmt.setString(1, profilo);
|
||||
pstmt.setString(2, element[i]);
|
||||
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
c.commit();
|
||||
}
|
||||
catch (SQLException sqle) {
|
||||
throw sqle;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
closeAll(null, pstmt, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// DISASSOCIA FUNZIONALITA AL PROFILO
|
||||
public void disassociaProfilo_Function(String profilo, String[] element) throws
|
||||
SQLException, Exception {
|
||||
Connection c = null;
|
||||
PreparedStatement pstmt = null;
|
||||
|
||||
try {
|
||||
c = getConnection();
|
||||
|
||||
for (int i = 0; i < element.length; i++) {
|
||||
pstmt = c.prepareStatement(sql_DisassociaFunzione);
|
||||
|
||||
pstmt.setString(1, profilo);
|
||||
pstmt.setString(2, element[i]);
|
||||
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
c.commit();
|
||||
}
|
||||
catch (SQLException sqle) {
|
||||
throw sqle;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
closeAll(null, pstmt, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ListaFunzionalita getListDisassociaFunction(String _codiceProfilo) throws
|
||||
SQLException, Exception {
|
||||
ListaFunzionalita ret = new ListaFunzionalita();
|
||||
Connection conn = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
conn = getConnection();
|
||||
pstmt = conn.prepareStatement(sql_ListFunzDaDisassociare);
|
||||
|
||||
pstmt.setString(1,_codiceProfilo);
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
FunctionBean[] retF =caricaListaFunzionalita(rs);
|
||||
ret.setListaFunzione(retF);
|
||||
}
|
||||
|
||||
catch (SQLException sqlex) {
|
||||
throw sqlex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
finally {
|
||||
closeAll(rs, pstmt, conn);
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
public ProfileConfig listFunctionApplication(String _profilo, String _dominio, String _jspName) throws
|
||||
SQLException, Exception {
|
||||
|
||||
ProfileConfig ret = new ProfileConfig();
|
||||
Connection conn = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
conn = getConnection();
|
||||
pstmt = conn.prepareStatement(sql_funzBYProfileDominio);
|
||||
|
||||
pstmt.setString(1,_profilo);
|
||||
pstmt.setString(2,_dominio);
|
||||
pstmt.setString(3,_jspName);
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
ret.setListFunction(caricaFunzioni(rs));
|
||||
|
||||
}
|
||||
|
||||
catch (SQLException sqlex) {
|
||||
throw sqlex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
finally {
|
||||
closeAll(rs, pstmt, conn);
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
private ArrayList caricaFunzioni(ResultSet rs) throws Exception,SQLException {
|
||||
|
||||
ArrayList ret = new ArrayList();
|
||||
FunctionBean o = null;
|
||||
|
||||
|
||||
try {
|
||||
while(rs.next()) {
|
||||
|
||||
o = new FunctionBean();
|
||||
o.setId_prog(rs.getString("id_prog"));
|
||||
o.setFunzionalita(rs.getString("funzionalita"));
|
||||
o.setComando(rs.getString("comando_funz"));
|
||||
o.setJspName(rs.getString("jsp_name"));
|
||||
|
||||
ret.add(o);
|
||||
}
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
throw sqle;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package mnp.crontab.ejb;
|
||||
|
||||
import javax.ejb.EJBObject;
|
||||
import mnp.crontab.manager.*;
|
||||
import mnp.crontab.objects.ui.LoginBean;
|
||||
import mnp.crontab.objects.ui.LoginRetCodeIF;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
public interface Autentication extends EJBObject {
|
||||
|
||||
public LoginBeanDTO login(LoginBeanDTO dto) throws Exception, RemoteException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package mnp.crontab.ejb;
|
||||
|
||||
import javax.ejb.SessionBean;
|
||||
import javax.ejb.SessionContext;
|
||||
import javax.ejb.CreateException;
|
||||
import mnp.crontab.manager.*;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
|
||||
public class AutenticationBean
|
||||
implements SessionBean {
|
||||
SessionContext sessionContext;
|
||||
LoginManager loginManager;
|
||||
|
||||
public void ejbCreate() throws CreateException {
|
||||
loginManager = new LoginManager();
|
||||
}
|
||||
|
||||
public void ejbRemove() {
|
||||
}
|
||||
|
||||
public void ejbActivate() {
|
||||
}
|
||||
|
||||
public void ejbPassivate() {
|
||||
}
|
||||
|
||||
public void setSessionContext(SessionContext sessionContext) {
|
||||
this.sessionContext = sessionContext;
|
||||
}
|
||||
|
||||
public LoginBeanDTO login(LoginBeanDTO dto) throws Exception {
|
||||
|
||||
LoginBean bean = new LoginBean();
|
||||
//bean.setUserID(dto.getUserID());
|
||||
bean.setCodiceProfilo(dto.getCodiceProfilo());
|
||||
LoginBean rbean = loginManager.login(bean);
|
||||
|
||||
LoginBeanDTO rdto = new LoginBeanDTO();
|
||||
|
||||
|
||||
//rdto.setUserID(rbean.getUserID());
|
||||
rdto.setRetCode(rbean.getRetCode());
|
||||
rdto.setCodiceProfilo(dto.getCodiceProfilo());
|
||||
|
||||
if(rbean.getRetCode()!=LoginRetCodeIF.PROFILO_KO){
|
||||
rdto.setProfilo(rbean.getProfilo());
|
||||
rdto.setCodiceDominio(rbean.getCodiceDominio());
|
||||
}
|
||||
|
||||
|
||||
FunctionBean[] fbs = rbean.getFunctionBeans();
|
||||
FunctionBeanDTO[] fbsdto = null;
|
||||
|
||||
if (fbs != null) {
|
||||
fbsdto = new FunctionBeanDTO[fbs.length];
|
||||
|
||||
//System.out.println("fbs.length: " + fbs.length);
|
||||
for (int i = 0; i < fbs.length; i++) {
|
||||
//System.out.println("i:" +i);
|
||||
fbsdto[i] = new FunctionBeanDTO();
|
||||
fbsdto[i].setComando(fbs[i].getComando());
|
||||
fbsdto[i].setDominio(fbs[i].getDominio());
|
||||
fbsdto[i].setFunzionalita(fbs[i].getFunzionalita());
|
||||
fbsdto[i].setId_prog(fbs[i].getId_prog());
|
||||
fbsdto[i].setJspName(fbs[i].getJspName());
|
||||
}
|
||||
rdto.setFunctionBeanDTO(fbsdto);
|
||||
}
|
||||
|
||||
return rdto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package mnp.crontab.ejb;
|
||||
|
||||
import javax.ejb.EJBHome;
|
||||
import javax.ejb.CreateException;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
public interface AutenticationHome
|
||||
extends EJBHome {
|
||||
|
||||
public Autentication create() throws CreateException, RemoteException;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package mnp.crontab.ejb;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class FunctionBeanDTO
|
||||
implements Serializable {
|
||||
|
||||
private String id_prog;
|
||||
private String funzionalita;
|
||||
private String jspName;
|
||||
private String dominio;
|
||||
private String comando;
|
||||
|
||||
public final static long serialVersionUID = 42L;
|
||||
|
||||
public FunctionBeanDTO() {
|
||||
}
|
||||
public String getId_prog() {
|
||||
return id_prog;
|
||||
}
|
||||
public void setId_prog(String id_prog) {
|
||||
this.id_prog = id_prog;
|
||||
}
|
||||
public String getFunzionalita() {
|
||||
return funzionalita;
|
||||
}
|
||||
public void setFunzionalita(String funzionalita) {
|
||||
this.funzionalita = funzionalita;
|
||||
}
|
||||
public String getJspName() {
|
||||
return jspName;
|
||||
}
|
||||
public void setJspName(String jspName) {
|
||||
this.jspName = jspName;
|
||||
}
|
||||
public String getDominio() {
|
||||
return dominio;
|
||||
}
|
||||
public void setDominio(String dominio) {
|
||||
this.dominio = dominio;
|
||||
}
|
||||
public String getComando() {
|
||||
return comando;
|
||||
}
|
||||
public void setComando(String comando) {
|
||||
this.comando = comando;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Created on 16-set-2005
|
||||
*
|
||||
* MNP [project mnp_fe]
|
||||
* Copyright (c) 2005
|
||||
*
|
||||
* @author Giovanni Amici
|
||||
* @version 1.0
|
||||
*/
|
||||
package mnp.crontab.ejb;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Giovanni
|
||||
*
|
||||
*/
|
||||
public class LoginBeanDTO implements Serializable {
|
||||
|
||||
public final static long serialVersionUID = 42L;
|
||||
|
||||
private int retCode;
|
||||
private String retMessage;
|
||||
private String codiceProfilo;
|
||||
private String profilo;
|
||||
private FunctionBeanDTO functionBeanDTO[];
|
||||
private String codiceDominio;
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the profilo.
|
||||
*/
|
||||
public String getProfilo() {
|
||||
return profilo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param profilo The profilo to set.
|
||||
*/
|
||||
public void setProfilo(String profilo) {
|
||||
this.profilo = profilo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the retCode.
|
||||
*/
|
||||
public int getRetCode() {
|
||||
return retCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param retCode The retCode to set.
|
||||
*/
|
||||
public void setRetCode(int retCode) {
|
||||
this.retCode = retCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the codiceProfilo.
|
||||
*/
|
||||
public String getCodiceProfilo() {
|
||||
return codiceProfilo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param codiceProfilo The codiceProfilo to set.
|
||||
*/
|
||||
public void setCodiceProfilo(String codiceProfilo) {
|
||||
this.codiceProfilo = codiceProfilo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the functionBeanDTO.
|
||||
*/
|
||||
public FunctionBeanDTO[] getFunctionBeanDTO() {
|
||||
return functionBeanDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param functionBeanDTO The functionBeanDTO to set.
|
||||
*/
|
||||
public void setFunctionBeanDTO(FunctionBeanDTO[] functionBeanDTO) {
|
||||
this.functionBeanDTO = functionBeanDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getRetMessage() {
|
||||
return retMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
public void setRetMessage(String string) {
|
||||
retMessage = string;
|
||||
}
|
||||
|
||||
public String getCodiceDominio() {
|
||||
return codiceDominio;
|
||||
}
|
||||
|
||||
public void setCodiceDominio(String value) {
|
||||
this.codiceDominio = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package mnp.crontab.engine.mbean;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import it.valueteam.crontab.engine.exception.*;
|
||||
import mnp.crontab.command.*;
|
||||
import mnp.crontab.config.am.*;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Marco Palmini
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ApplicationController
|
||||
|
||||
{
|
||||
private static Category log = Category.getInstance(ApplicationController.class.
|
||||
getName());
|
||||
|
||||
public ApplicationController() {
|
||||
}
|
||||
|
||||
public Object updateConfiguration(Configuration aConfiguration,
|
||||
String systemMNP) throws
|
||||
Exception {
|
||||
|
||||
/// Update Configuration manda la configurazione all'applicazione MNP
|
||||
/// Chiamando la web application di mnp attraverso una servlet
|
||||
/// e passando un Oggetto di Configurazione
|
||||
if (systemMNP.equals(ApplicationManagerCostants.SISTEMI_BINDING_NAME)) {
|
||||
InternalSystemControllerConfig _internal = new
|
||||
InternalSystemControllerConfig();
|
||||
_internal.setListInternalSystem(aConfiguration.getConfSistemiInterni());
|
||||
|
||||
return _internal;
|
||||
}
|
||||
|
||||
if (systemMNP.equals(ApplicationManagerCostants.XML_BINDING_NAME)) {
|
||||
XMLControllerConfig _xmlController = new
|
||||
XMLControllerConfig();
|
||||
_xmlController = getXMLController(aConfiguration.getConfXMLSystem());
|
||||
|
||||
return _xmlController;
|
||||
}
|
||||
return new Object();
|
||||
}
|
||||
|
||||
public Configuration getConfiguration(String systemMNP) throws Exception {
|
||||
// Riprendo ApplicationController attraverso il suo Stub
|
||||
// Leggo il file xml.
|
||||
|
||||
Configuration aConfiguration = new Configuration();
|
||||
|
||||
if (systemMNP.equals(ApplicationManagerCostants.XML_BINDING_NAME)) {
|
||||
// Parte XML del file DI GESTIONE DEL XML
|
||||
|
||||
XmlControllerWrapper _xmlController = XmlControllerWrapper.getInstance();
|
||||
try {
|
||||
_xmlController.open();
|
||||
}
|
||||
catch (CrontabException ex) {
|
||||
ex.printStackTrace();
|
||||
throw new NotValidCrontabFileException("CrontabException: " +
|
||||
ex.toString());
|
||||
}
|
||||
catch (NotValidCrontabConfigException ex) {
|
||||
ex.printStackTrace();
|
||||
throw new NotValidCrontabFileException(
|
||||
"NotValidCrontabConfigException: " + ex.toString());
|
||||
}
|
||||
|
||||
aConfiguration.setConfXMLSystem(_xmlController);
|
||||
aConfiguration.setPath_Xml(_xmlController.getFileCfg());
|
||||
}
|
||||
|
||||
if (systemMNP.equals(ApplicationManagerCostants.SISTEMI_BINDING_NAME)) {
|
||||
// Parte XML del file DI GESTIONE DEI SISTEMI INTERNI
|
||||
|
||||
InternalSystemWrapper _internal = InternalSystemWrapper.getInstance();
|
||||
try {
|
||||
_internal.open(_internal.getFileCfg());
|
||||
}
|
||||
catch (CrontabException ex) {
|
||||
throw new NotValidCrontabFileException("CrontabException: " +
|
||||
ex.toString());
|
||||
}
|
||||
catch (NotValidCrontabConfigException ex) {
|
||||
throw new NotValidCrontabFileException(
|
||||
"NotValidCrontabConfigException: " + ex.toString());
|
||||
}
|
||||
|
||||
aConfiguration.setConfSistemiInterni(_internal.getListSystem());
|
||||
aConfiguration.setPath_Sistemi(_internal.getFileCfg());
|
||||
}
|
||||
|
||||
return aConfiguration;
|
||||
}
|
||||
|
||||
public static XMLControllerConfig getXMLController(XmlControllerWrapper
|
||||
_xmlWrapper) {
|
||||
XMLControllerConfig _xmlController = new XMLControllerConfig();
|
||||
_xmlController.setAbilitazione(_xmlWrapper.isAbilitato());
|
||||
_xmlController.setMaxRequests(_xmlWrapper.get_nroReqWrapper());
|
||||
_xmlController.setMaxTimeOut(_xmlWrapper.get_maxTime());
|
||||
_xmlController.setListFile(_xmlWrapper.getListaFileInfo());
|
||||
_xmlController.setListFileAck(_xmlWrapper.getListaFileAck());
|
||||
return _xmlController;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package mnp.crontab.exception;
|
||||
|
||||
/**
|
||||
* Title: Amministrazione magistratura
|
||||
* Description:
|
||||
* Copyright: Copyright (c) 2000
|
||||
* Company: OW
|
||||
* @author Paloni Gian Luca
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class BadPasswordException
|
||||
extends Exception {
|
||||
|
||||
public BadPasswordException( ) {
|
||||
super("Utente Disabilitato avendo esaurito il numero di tentativi a disposizione! <BR> Contattare l'Amministratore per la riabilitazione dell'utenza");
|
||||
}
|
||||
public BadPasswordException( int tentativi) {
|
||||
super("Utente non autorizzato! Prego rieseguire il Log-In. <BR> Numero di tentativi ancora a disposizione : " +tentativi);
|
||||
}
|
||||
public BadPasswordException( String _user) {
|
||||
super("Utente "+_user+ " non autorizzato! Prego rieseguire il Log-In.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package mnp.crontab.exception;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP Project</p>
|
||||
* <p>Description: Progetto per Mobile Number Portability</p>
|
||||
* <p>Copyright: Copyright (c) 2002</p>
|
||||
* <p>Company: OW</p>
|
||||
* @author Gian Luca Paloni
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class CommandNotFoundException extends Exception {
|
||||
|
||||
public CommandNotFoundException() {
|
||||
super("Non è stato possibile instanziare il comando richiesto! mhh!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package mnp.crontab.exception;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DisabledException extends Exception {
|
||||
public DisabledException() {
|
||||
super("Utente Disabilitato! <BR>Contattare l'Amministratore per la riabilitazione dell'utenza ");
|
||||
}
|
||||
|
||||
public DisabledException(boolean active) {
|
||||
super("Utente Disabilitato dall'Amministratore! <BR>Contattare l'Amministratore per la riabilitazione dell'utenza ");
|
||||
}
|
||||
|
||||
public DisabledException(String admin) {
|
||||
super("Utente "+admin+" Disabilitato per inattività! <BR>Riabilitare l'utenza tramite DBA Oracle");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package mnp.crontab.exception;
|
||||
|
||||
public class MasterNotActiveException extends Exception{
|
||||
public MasterNotActiveException() {
|
||||
}
|
||||
|
||||
public MasterNotActiveException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package mnp.crontab.exception;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP - Amministrazione</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class PasswordEqualsException extends Exception{
|
||||
public PasswordEqualsException() {
|
||||
super("Password identica a quella memorizzata. Prego inserire una nuova password ! ");
|
||||
}
|
||||
|
||||
public PasswordEqualsException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package mnp.crontab.exception;
|
||||
|
||||
public class PwdEqualsUserException extends Exception {
|
||||
public PwdEqualsUserException() {
|
||||
super("Password identica alla User-ID. Prego inserire una nuova password ! ");
|
||||
}
|
||||
|
||||
public PwdEqualsUserException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package mnp.crontab.exception;
|
||||
|
||||
/**
|
||||
* <p>Title: MNP</p>
|
||||
* <p>Description: MNP - Amministrazione</p>
|
||||
* <p>Copyright: Copyright (c) 2003</p>
|
||||
* <p>Company: Siemens</p>
|
||||
* @author Massimo Zagaria
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class UserIDException extends Exception {
|
||||
public UserIDException() {
|
||||
super("Utente già esistente! Prego Re-Inserire una nuova User.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package mnp.crontab.exception.controller;
|
||||
|
||||
/**
|
||||
* <p>Title: Progetto Gateway OLO MNP</p>
|
||||
* <p>Description: </p>
|
||||
* <p>Copyright: Copyright (c) 2002</p>
|
||||
* <p>Company: </p>
|
||||
* @author Marco Palmini
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class UnknownControllerException extends Exception {
|
||||
|
||||
public UnknownControllerException()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public UnknownControllerException(String s)
|
||||
{
|
||||
super(s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package mnp.crontab.exception;
|
||||
|
||||
/**
|
||||
* Title:
|
||||
* Description:
|
||||
* Copyright: Copyright (c) 2001
|
||||
* Company:
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class userLoggedException extends Exception {
|
||||
|
||||
public userLoggedException() {
|
||||
super("Utente già connesso!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package mnp.crontab.exception;
|
||||
|
||||
/**
|
||||
* Title:
|
||||
* Description:
|
||||
* Copyright: Copyright (c) 2001
|
||||
* Company:
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class userUnknownException extends Exception {
|
||||
|
||||
public userUnknownException() {
|
||||
super("Utente sconosciuto!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package mnp.crontab.manager;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
|
||||
public interface LoginIF {
|
||||
public LoginBean login(LoginBean loginInfo) throws Exception;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package mnp.crontab.manager;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.log4j.*;
|
||||
import mnp.crontab.database.dao.*;
|
||||
import mnp.crontab.ejb.*;
|
||||
import mnp.crontab.objects.ui.*;
|
||||
import mnp.crontab.utility.*;
|
||||
|
||||
public class LoginManager
|
||||
implements LoginIF {
|
||||
|
||||
private static Logger logger = Logger.getLogger(LoginManager.class.getName());
|
||||
|
||||
public LoginManager() {
|
||||
}
|
||||
|
||||
public static int MIN_PASSWORD_LENGTH = 10;
|
||||
public static int MAX_PASSWORD_LENGTH = 16;
|
||||
|
||||
|
||||
public LoginBean login(LoginBean loginInfo) throws
|
||||
Exception {
|
||||
try {
|
||||
|
||||
LoginDAO lg = new LoginDAO();
|
||||
|
||||
//ORA Setta nel bean le funzionalità da visualizzare nella homepage
|
||||
|
||||
|
||||
lg.getUSERLogin(loginInfo);
|
||||
|
||||
if(loginInfo.getProfilo()==null || loginInfo.getProfilo().trim().length()==0){
|
||||
//IL PROFILO NON E' STATO RICONOSCIUTO
|
||||
|
||||
loginInfo.setRetCode(LoginRetCodeIF.PROFILO_KO); //DA SETTARE CON L'OPPORTUNO CODICE
|
||||
|
||||
}/*else if(loginInfo.Amministratore()){
|
||||
|
||||
loginInfo.setRetCode(LoginRetCodeIF.LOGIN_AMMINISTRATORE_OK);
|
||||
}*/else {
|
||||
|
||||
loginInfo.setRetCode(LoginRetCodeIF.LOGIN_OK);
|
||||
}
|
||||
|
||||
return loginInfo;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user