All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nbnResolving.resolver.EpicurResolverResponse Maven / Gradle / Ivy

/* *********************************************************************
 * Class EpicurResolverResponse
 * 
 * Copyright (c) 2010-2012, German National Library/Deutsche Nationalbibliothek
 * Adickesallee 1, D-60322 Frankfurt am Main, Federal Republic of Germany 
 *
 * This program is free software.
 * For your convenience it is dual licensed.
 * You can redistribute it and/or modify it under the terms of
 * one of the following licenses:
 * 
 * 1.)
 * The GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 * You should have received a copy of the GNU General Public License
 * along with this program (gpl-3.0.txt); if not please read
 * http://www.gnu.org/licenses/gpl.html
 * 
 * 2.)
 * The European Union Public Licence as published by
 * The European Commission (executive body of the European Union);
 * either version 1.1 of the License, or (at your option) any later version.
 * You should have received a copy of the European Union Public Licence
 * along with this program (eupl_v1.1_en.pdf); if not please read
 * http://www.osor.eu/eupl
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the above licenses for more details.
 * 
 * Kadir Karaca Kocer -- German National Library
 * 
 **********************************************************************/

/* ********************************************************************
 * CHANGELOG:
 * 
 * 2012-04-03 Port to Maven by Timo Heck & Karaca Kocer
 * 2011-12-01 Refactored PIDEF generation -> own generator.
 * Renamed due to naming problems
 * Refactored to PIDEF Schema
 * Created on 2010-08-02 by Karaca Kocer
 ********************************************************************/

package org.nbnResolving.resolver;

import org.nbnResolving.pidef.DataType;
import org.nbnResolving.pidef.PidefDocument;

import eu.europeanaconnect.erds.ResourceDescription;

/**
 * Class representing a detailed response of the local resolver.
 * Because of detailed database queries a local resolver can return
 * much more information than a remote resolver that is called via HTTP.
 *   
 * @see eu.europeanaconnect.erds.ResolverResponse
 * @author Kadir Karaca Kocer, German National Library
 */

public class EpicurResolverResponse extends eu.europeanaconnect.erds.ResolverResponse {
	//ResourceDescription  resourceDescription = null;
	protected String        dataProviderId = "Data provider id not set!";
	protected PidefDocument doc;
	
	/**
	 * Default Constructor. Generates a new XML document and sets some default values.
	 * @see PidefDocumentGenerator
	 */
	public EpicurResolverResponse() {
		super();
		this.doc = PidefDocumentGenerator.generateNewPidefDocument();
	}
	
	/**
	 * @param requestString User request (URI) as Java String.
	 */
	public EpicurResolverResponse(String requestString) {
		this();
		this.getDoc().getPidef().getHeader().setRequest(requestString);
	}
	
	/**
	 * @return The URL with the highest priority (it is assumed that the URLs are sorted according
	 * to their importance. EpicurLocalResolver does this with a SQL "ORDEY BY" command.)
	 */
	@Override
	public String getUrl() {
		String ret = null;
		DataType data = this.doc.getPidef().getData();
		if (data != null) {
			if (data.getResolvingInformation() != null) {
				if ((data.getResolvingInformation().getUrlInfoArray() != null) && (data.getResolvingInformation().getUrlInfoArray().length > 0)){
					ret = data.getResolvingInformation().getUrlInfoArray(0).getUrl();
				}
			} else {
				if (data.getLinks() != null) {
					if (data.getLinks().getLinkArray() != null) {
						ret = data.getLinks().getLinkArray(0);
					}
				}
			}
		}
		return ret;
	}
	
	/**
	 * @param url the url to set (not active in this class.
	 */
	@Override
	public void setUrl(String url) {
		//this functionality does not make sense in this class 
	}
	
	/**
	 * @return ATTENTION: in this class this returns always NULL!
	 */
	@Override
	public ResourceDescription getResourceDescription() {
		return null;
	}
	
	/**
	 * @param resourceDescription the resourceDescription to set
	 */
	@Override
	public void setResourceDescription(ResourceDescription resourceDescription) {
		//this functionality does not make sense in this class 
	}
	
	/**
	 * @return the dataProviderId
	 */
	@Override
	public String getDataProviderId() {
		return this.dataProviderId;
	}
	
	/**
	 * @param providerId the dataProviderId to set
	 */
	@Override
	public void setDataProviderId(String providerId) {
		this.dataProviderId = providerId;
	}
	
	/**
	 * @return the returnCode
	 */
	public int getReturnCode() {
		return this.doc.getPidef().getHeader().getStatusCode();
	}
	
	/**
	 * @param returnCode the returnCode to set
	 */
	public void setReturnCode(short returnCode) {
		this.doc.getPidef().getHeader().setStatusCode(returnCode);
	}

	/**
	 * @return The document
	 */
	public PidefDocument getDoc() {
		return this.doc;
	}

	/**
	 * @param pidefDoc the PIDEF to set
	 */
	public void setDoc(PidefDocument pidefDoc) {
		this.doc = pidefDoc;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy