001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/csw/manager/Transaction.java $ 002 /*---------------- FILE HEADER ------------------------------------------ 003 004 This file is part of deegree. 005 Copyright (C) 2001-2006 by: 006 EXSE, Department of Geography, University of Bonn 007 http://www.giub.uni-bonn.de/deegree/ 008 lat/lon GmbH 009 http://www.lat-lon.de 010 011 This library is free software; you can redistribute it and/or 012 modify it under the terms of the GNU Lesser General Public 013 License as published by the Free Software Foundation; either 014 version 2.1 of the License, or (at your option) any later version. 015 016 This library is distributed in the hope that it will be useful, 017 but WITHOUT ANY WARRANTY; without even the implied warranty of 018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 019 Lesser General Public License for more details. 020 021 You should have received a copy of the GNU Lesser General Public 022 License along with this library; if not, write to the Free Software 023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 024 025 Contact: 026 027 Andreas Poth 028 lat/lon GmbH 029 Aennchenstr. 19 030 53115 Bonn 031 Germany 032 E-Mail: poth@lat-lon.de 033 034 Prof. Dr. Klaus Greve 035 Department of Geography 036 University of Bonn 037 Meckenheimer Allee 166 038 53115 Bonn 039 Germany 040 E-Mail: greve@giub.uni-bonn.de 041 042 ---------------------------------------------------------------------------*/ 043 044 package org.deegree.ogcwebservices.csw.manager; 045 046 import java.util.List; 047 import java.util.Map; 048 049 import org.deegree.framework.log.ILogger; 050 import org.deegree.framework.log.LoggerFactory; 051 import org.deegree.framework.xml.XMLException; 052 import org.deegree.framework.xml.XMLParsingException; 053 import org.deegree.i18n.Messages; 054 import org.deegree.ogcbase.ExceptionCode; 055 import org.deegree.ogcwebservices.AbstractOGCWebServiceRequest; 056 import org.deegree.ogcwebservices.OGCWebServiceException; 057 import org.w3c.dom.Element; 058 059 /** 060 * A Transaction defines an atomic unit of work and is a container for one or more insert, update 061 * and/or delete actions. 062 * 063 * 064 * @version $Revision: 7086 $ 065 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a> 066 * @author last edited by: $Author: rbezema $ 067 * 068 * @version $Revision: 7086 $, $Date: 2007-05-10 18:30:56 +0200 (Do, 10 Mai 2007) $ 069 * 070 */ 071 public class Transaction extends AbstractOGCWebServiceRequest { 072 073 private static final long serialVersionUID = -4393029325052150570L; 074 075 protected static final ILogger LOG = LoggerFactory.getLogger( Transaction.class ); 076 077 private List<Operation> operations = null; 078 079 private boolean verboseResponse = false; 080 081 /** 082 * creates a Transaction object from its XML representation defined in OGC CS-W 2.0.0 083 * specification 084 * @param id uniquely identifies the given request 085 * 086 * @param transRoot the root of the xml-encoded transaction request 087 * @return a Transaction with the values taken form the XML-Document. 088 * @throws OGCWebServiceException if the Transaction could not be created 089 */ 090 public static final Transaction create( String id, Element transRoot ) 091 throws OGCWebServiceException { 092 try { 093 TransactionDocument doc = new TransactionDocument( transRoot ); 094 return doc.parse( id ); 095 } catch ( XMLException e ) { 096 e.printStackTrace(); 097 String msg = Messages.getMessage( "CSW_ERROR_WHILE_PARSING_TRANSACTION", e.getMessage() ); 098 LOG.logError( msg, e ); 099 throw new OGCWebServiceException( msg, ExceptionCode.INVALID_FORMAT ); 100 } catch ( XMLParsingException e ) { 101 String msg = Messages.getMessage( "CSW_ERROR_WHILE_PARSING_TRANSACTION", e.getMessage() ); 102 e.printStackTrace(); 103 LOG.logError( msg, e ); 104 throw new OGCWebServiceException( msg, ExceptionCode.INVALID_FORMAT ); 105 } 106 } 107 108 /** 109 * 110 * @param version 111 * @param id 112 * @param vendorSpecificParameter 113 * @param operations 114 * @param verboseResponse 115 */ 116 public Transaction( String version, String id, Map<String, String> vendorSpecificParameter, 117 List<Operation> operations, boolean verboseResponse ) { 118 super( version, id, vendorSpecificParameter ); 119 this.operations = operations; 120 this.verboseResponse = verboseResponse; 121 } 122 123 /** 124 * @return the name of the service; always CSW 125 */ 126 public String getServiceName() { 127 return "CSW"; 128 } 129 130 /** 131 * The verboseResponseattribute is a boolean that may be used by a client to indicate to a 132 * server the amount of detail to generate in the rsponse. A value of FALSE means that a CSW 133 * should generate a terse or brief transaction response. A value of TRUE, or the absence of the 134 * attribute, means that the normal detailed transaction response should be generated. 135 * 136 * @return true if the response should be verbose 137 */ 138 public boolean verboseResponse() { 139 return verboseResponse; 140 } 141 142 /** 143 * returns all operations being part of a transaction 144 * 145 * @return all operations being part of a transaction 146 */ 147 public List<Operation> getOperations() { 148 return operations; 149 } 150 }