import java.util.HashMap;\r
import java.util.List;\r
\r
+import org.apache.log4j.Logger;\r
+\r
import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2ResponseData;\r
\r
public class Pazpar2ResponseData implements Serializable {\r
- \r
+\r
+ Logger logger = Logger.getLogger(Pazpar2ResponseData.class);\r
private static final long serialVersionUID = -3909755656714679959L;\r
String type = null;\r
HashMap<String,String> attributes = new HashMap<String,String>();\r
HashMap<String,List<Pazpar2ResponseData>> elements = new HashMap<String,List<Pazpar2ResponseData>>();\r
String textContent = "";\r
+ CommandError error = null;\r
+ String xml = null;\r
\r
public void setType (String type) {\r
this.type = type;\r
}\r
}\r
\r
+ /**\r
+ * Returns the text content of the first element found with the given\r
+ * name\r
+ * @param name of the element \r
+ * @return text value, empty string if none found\r
+ */\r
public String getOneElementValue (String name) {\r
if (getOneElement(name)!=null && getOneElement(name).getValue().length()>0) {\r
return getOneElement(name).getValue();\r
return Integer.parseInt(val);\r
}\r
}\r
-\r
- \r
+ \r
+ public boolean hasApplicationError () {\r
+ return (getOneElement("applicationerror") != null); \r
+ }\r
+ \r
+ public CommandError getApplicationError() {\r
+ return (CommandError) getOneElement("applicationerror");\r
+ }\r
+ \r
+ public boolean hasPazpar2Error() {\r
+ return hasApplicationError() && getApplicationError().hasPazpar2Error();\r
+ }\r
+ \r
+ public void setXml(String xml) {\r
+ this.xml = xml; \r
+ }\r
+ \r
+ public String getXml() {\r
+ if (type != null && type.equals("record")) {\r
+ logger.debug("Getting XML for "+type + ": "+xml);\r
+ } \r
+ return xml == null ? "" : xml;\r
+ }\r
+ \r
}\r