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

java.fedora.server.search.FieldSearchSQLModule Maven / Gradle / Ivy

Go to download

The Fedora Client is a Java Library that allows API access to a Fedora Repository. The client is typically one part of a full Fedora installation.

The newest version!
/*
 * -----------------------------------------------------------------------------
 *
 * 

License and Copyright: The contents of this file are subject to the * Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of * the License at * http://www.fedora-commons.org/licenses.

* *

Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License.

* *

The entire file consists of original code.

*

Copyright © 2008 Fedora Commons, Inc.
*

Copyright © 2002-2007 The Rector and Visitors of the University of * Virginia and Cornell University
* All rights reserved.

* * ----------------------------------------------------------------------------- */ package fedora.server.search; import java.util.Map; import org.apache.log4j.Logger; import fedora.server.Module; import fedora.server.Server; import fedora.server.errors.ConnectionPoolNotFoundException; import fedora.server.errors.ModuleInitializationException; import fedora.server.errors.ServerException; import fedora.server.storage.ConnectionPoolManager; import fedora.server.storage.ConnectionPool; import fedora.server.storage.DOManager; import fedora.server.storage.DOReader; /** * Module that wraps FieldSearchSQLImpl. * * @author [email protected] * @version $Id: FieldSearchSQLModule.java 5261 2006-12-01 05:57:11Z cwilper $ */ public class FieldSearchSQLModule extends Module implements FieldSearch { /** Logger for this class. */ private static final Logger LOG = Logger.getLogger( FieldSearchSQLModule.class.getName()); private FieldSearchSQLImpl m_wrappedFieldSearch; public FieldSearchSQLModule(Map params, Server server, String role) throws ModuleInitializationException { super(params, server, role); } public void postInitModule() throws ModuleInitializationException { // // get and validate maxResults // if (getParameter("maxResults")==null) { throw new ModuleInitializationException( "maxResults parameter must be specified.", getRole()); } int maxResults=0; try { maxResults=Integer.parseInt(getParameter("maxResults")); if (maxResults<1) { throw new NumberFormatException(""); } } catch (NumberFormatException nfe) { throw new ModuleInitializationException( "maxResults must be a positive integer.", getRole()); } // // get and validate maxSecondsPerSession // if (getParameter("maxSecondsPerSession")==null) { throw new ModuleInitializationException( "maxSecondsPerSession parameter must be specified.", getRole()); } int maxSecondsPerSession=0; try { maxSecondsPerSession=Integer.parseInt(getParameter("maxSecondsPerSession")); if (maxSecondsPerSession<1) { throw new NumberFormatException(""); } } catch (NumberFormatException nfe) { throw new ModuleInitializationException( "maxSecondsPerSession must be a positive integer.", getRole()); } // // get indexDCFields parameter (default to true if unspecified) // boolean indexDCFields = true; String indexDCFieldsValue = getParameter("indexDCFields"); if (indexDCFieldsValue != null) { String val = indexDCFieldsValue.trim().toLowerCase(); if (val.equals("false") || val.equals("no")) { indexDCFields = false; } else if (!val.equals("true") && !val.equals("yes")) { throw new ModuleInitializationException("indexDCFields param " + "was not a boolean", getRole()); } } // // get connectionPool from ConnectionPoolManager // ConnectionPoolManager cpm=(ConnectionPoolManager) getServer(). getModule("fedora.server.storage.ConnectionPoolManager"); if (cpm==null) { throw new ModuleInitializationException( "ConnectionPoolManager module was required, but apparently has " + "not been loaded.", getRole()); } String cPoolName=getParameter("connectionPool"); ConnectionPool cPool=null; try { if (cPoolName==null) { LOG.debug("connectionPool unspecified; using default from " + "ConnectionPoolManager."); cPool=cpm.getPool(); } else { LOG.debug("connectionPool specified: " + cPoolName); cPool=cpm.getPool(cPoolName); } } catch (ConnectionPoolNotFoundException cpnfe) { throw new ModuleInitializationException("Could not find requested " + "connectionPool.", getRole()); } // // get the doManager // DOManager doManager=(DOManager) getServer(). getModule("fedora.server.storage.DOManager"); if (doManager==null) { throw new ModuleInitializationException( "DOManager module was required, but apparently has " + "not been loaded.", getRole()); } // // things look ok...get the wrapped instance // m_wrappedFieldSearch=new FieldSearchSQLImpl(cPool, doManager, maxResults, maxSecondsPerSession, indexDCFields); } public String[] getRequiredModuleRoles() { return new String[] {"fedora.server.storage.ConnectionPoolManager", "fedora.server.storage.DOManager"}; } public void update(DOReader reader) throws ServerException { m_wrappedFieldSearch.update(reader); } public boolean delete(String pid) throws ServerException { return m_wrappedFieldSearch.delete(pid); } public FieldSearchResult findObjects(String[] resultFields, int maxResults, FieldSearchQuery query) throws ServerException { return m_wrappedFieldSearch.findObjects(resultFields, maxResults, query); } public FieldSearchResult resumeFindObjects(String sessionToken) throws ServerException { return m_wrappedFieldSearch.resumeFindObjects(sessionToken); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy