/Users/detro/workspace-nb/JAEBI/src/java/org/jaebi/server/service/XRequestCommandUpdate.java

Vai alla documentazione di questo file.
00001 /*
00002  * XRequestCommandUpdate.java
00003  *
00004  * Created on June 9, 2005, 12:21 PM
00005  * Created by Detro - 566/2145
00006  */
00007 
00008 package org.jaebi.server.service;
00009 
00010 import org.jaebi.server.service.exception.BackEndHandlerGenericException;
00011 import org.jaebi.server.service.exception.BackEndHandlerSQLCreationException;
00012 import org.jaebi.server.service.exception.CommandExecException;
00013 import org.jaebi.server.service.exception.XRequestCommandInitException;
00014 import org.jaebi.server.service.xml.exception.JAXBXResponseFactoryBuildingException;
00015 import org.jaebi.server.service.xml.xrequest.Xrequest;
00016 
00023 public class XRequestCommandUpdate extends XRequestCommand {
00024     
00026     public XRequestCommandUpdate(Xrequest xrequestObj, BackEndHandlerImpl backEndHandler) 
00027         throws XRequestCommandInitException {
00028         
00029         super(xrequestObj, backEndHandler);
00030         
00031         /* Controlla se la Factory ha costruito 
00032          * l'XRequestCommand con l'Xrequest corretto */
00033         if ( !xrequestObj.getType().equalsIgnoreCase("update") ) {
00034             throw new XRequestCommandInitException(
00035                     exceptionPrefix + "Xrequest Type does not match");
00036         }
00037     }
00038     
00044     public Object execute() 
00045         throws CommandExecException {
00046         
00047         int affectedRows;
00048         
00049         try {
00050             if ( getWhereColumnsName().size() == 0 ) {
00051                 affectedRows = backEndHandler.update(
00052                     getAffectedTable(),
00053                     getColumnsValue()
00054                 );
00055             } else {
00056                 affectedRows = backEndHandler.update(
00057                     getAffectedTable(),
00058                     getColumnsValue(),
00059                     getWhereColumnsValue()
00060                 );
00061             }
00062             
00063             return xresponseFactory.buildXresponse(true, 
00064                     "UPDATE #" + affectedRows + " ROWS" );
00065             
00066         } catch ( JAXBXResponseFactoryBuildingException e ) {
00067             // Errore durante la creazione dell'XResponse
00068             try {
00069                 return xresponseFactory.buildXresponse(false, 
00070                         "Internal Error - " + e.getMessage() );
00071             } catch ( JAXBXResponseFactoryBuildingException otherE ) {
00072                 throw new CommandExecException( exceptionPrefix + otherE );
00073             }
00074         } catch ( BackEndHandlerGenericException e) {
00075             // Errore nel BackEnd
00076             try {
00077                 return xresponseFactory.buildXresponse(false, 
00078                         "BackEnd Error - " + e.getMessage() );
00079             } catch ( JAXBXResponseFactoryBuildingException otherE ) {
00080                 throw new CommandExecException( exceptionPrefix + otherE );
00081             }
00082         } catch ( BackEndHandlerSQLCreationException sqle) {
00083             // Errore nel BackEndHandler durante la creazione dell'SQL
00084             try {
00085                 return xresponseFactory.buildXresponse(false, 
00086                         "Error in Submitted Data - " + sqle.getMessage() );
00087             } catch ( JAXBXResponseFactoryBuildingException otherE ) {
00088                 throw new CommandExecException( exceptionPrefix + otherE );
00089             }
00090         }
00091     }
00092     
00093 }

Generato il Mon Jun 27 22:50:38 2005 per JAEBI - JAva Enterprice BackEnd Interfacement da  doxygen 1.4.3