String form_ = request.getParameter("form");
String value = request.getParameter("value");
if(form!= null && value!= null){
//http://127.0.0.1:8080/mvx/EventServer.do?form=new&value=10/27/08&Submit=localhostl
//recuperar informacion del server
XMLServers xmlserver = new XMLServers();
Server server = xmlserver.loadServerByName(serName, servlet.getServletContext());
//tratar evento en el XML
XMLEvents xmlevents = new XMLEvents();
//Event events[] = xmlevents.loadEventsServerByName(serName,server.getFilePath());
if(form_.equals("new")){
int hourint = new Integer(request.getParameter("hour")).intValue();
if(request.getParameter("ampm").equals("PM")){
hourint=hourint+12;
if(hourint==24)
hourint=0;
}
String hour = ""+hourint+":"+request.getParameter("minute");
String id=serName+value+hour;
String description="";
String user="";
String results="";
//calculate folder name
Locale locale = new Locale("es","ES");
Date date1 = new Date(value);
Format formatter = new SimpleDateFormat("MMMM_yyyy");
String folName = formatter.format(date1);
formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateToKeep = formatter.format(date1);
String type = request.getParameter("type");
Event event = new Event(id,dateToKeep,hour,description,user,results,type);
xmlevents.addEvent(event,server.getFilePath(),serName,folName);
//programar el eventos en XMLHandler
if(XMLHandler.addEvent(server,event)){
System.out.println("programed event:"+event+ " at Server:"+server);
}
}
if(form_.equals("revise")){
String hour = request.getParameter("hour")+":"+request.getParameter("minute");
String id=serName+value+hour;//?
String description="";
String user="";
String results="";
String type = request.getParameter("type");
Event event = new Event(id,value,hour,description,user,results,type);
xmlevents.updEvent(id,event,server.getFilePath(),serName);
}
if(form_.equals("delete")){
String id="";//serName+value+hour;//??
xmlevents.delEvent(id,server.getFilePath(),serName);
}
}
//System.out.println("***********************date:"+date +" "+ "Submit"+serName);
if(date == null || date.trim().equals("")){
Calendar c = Calendar.getInstance();
date = ""+(c.get(Calendar.MONTH)+1);
date= date +"/"+ c.get(Calendar.DAY_OF_MONTH);
date = date +"/"+ c.get(Calendar.YEAR);
}
//recuperar los datos del server serName
XMLServers xmlserver = new XMLServers();
Server server = xmlserver.loadServerByName(serName, servlet.getServletContext());
//System.out.println("DatosServer:"+server);
//Presentar calendario