From e3e8f13883685f4bc5e71f35c320fe92553ad2e1 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Thu, 17 Nov 2011 11:20:10 -0600 Subject: [PATCH] Bump to verision 3.1.3. Updated hydra-jetty. Make file-assets easier to override --- HISTORY.textile | 6 +- app/controllers/file_assets_controller.rb | 171 +-- .../conf/{ => development}/fedora.fcfg | 0 fedora_conf/conf/test/fedora.fcfg | 1021 +++++++++++++++++ jetty | 2 +- lib/hydra-head/version.rb | 2 +- lib/hydra.rb | 1 + lib/hydra/file_assets.rb | 148 +++ lib/railties/hydra_jetty.rake | 12 +- .../permissions_controller_spec.rb | 24 - .../generators/hydra-head_generator_spec.rb | 14 - 11 files changed, 1187 insertions(+), 214 deletions(-) rename fedora_conf/conf/{ => development}/fedora.fcfg (100%) create mode 100644 fedora_conf/conf/test/fedora.fcfg create mode 100644 lib/hydra/file_assets.rb delete mode 100644 test_support/spec/generators/hydra-head_generator_spec.rb diff --git a/HISTORY.textile b/HISTORY.textile index b9379dfdf..32973cc8e 100644 --- a/HISTORY.textile +++ b/HISTORY.textile @@ -1,5 +1,9 @@ +h3. 3.1.3 +* Make FileAssetController easily overridden +* Update hydra-jetty, to support test and development fedora + h3. 3.1.2 -* Make asset controller easily overridden +* Make AssetController easily overridden h3. 3.1.1 diff --git a/app/controllers/file_assets_controller.rb b/app/controllers/file_assets_controller.rb index 9144dd1bd..d7d95d826 100644 --- a/app/controllers/file_assets_controller.rb +++ b/app/controllers/file_assets_controller.rb @@ -1,172 +1,3 @@ class FileAssetsController < ApplicationController - - include Hydra::AccessControlsEnforcement - include Hydra::AssetsControllerHelper - include Hydra::FileAssetsHelper - include Hydra::RepositoryController - include MediaShelf::ActiveFedoraHelper - include Blacklight::SolrHelper - - before_filter :require_solr, :only=>[:index, :create, :show, :destroy] - - # need to include this after the :require_solr/fedora before filters because of the before filter that the workflow provides. - include Hydra::SubmissionWorkflow - - prepend_before_filter :sanitize_update_params - - helper :hydra_uploader - - def index -=begin -Removed from file_assets/index.html.haml --# javascript_includes << infusion_javascripts(:inline_edit, :extras=>[:inline_editor_integrations], :debug=>true, :render_html=>false) --# javascript_includes << ['../infusion/framework/core/js/ProgressiveEnhancement.js', '../infusion/InfusionAll.js', {:cache=>true, :plugin=>"fluid-infusion"}] - -- javascript_includes << "jquery.jeditable.mini" -- javascript_includes << 'custom' -- javascript_includes << "catalog/edit" -- javascript_includes << "jquery.hydraMetadata.js" -- javascript_includes << "/plugin_assets/fluid-infusion/infusion/components/undo/js/Undo.js" -- javascript_includes << "jquery.form.js" - - - - -=end - - if params[:layout] == "false" - # action = "index_embedded" - layout = false - end - - if params[:asset_id].nil? - # @solr_result = ActiveFedora::SolrService.instance.conn.query('has_model_field:info\:fedora/afmodel\:FileAsset', @search_params) - @solr_result = FileAsset.find_by_solr(:all) - else - container_uri = "info:fedora/#{params[:asset_id]}" - escaped_uri = container_uri.gsub(/(:)/, '\\:') - extra_controller_params = {:q=>"is_part_of_s:#{escaped_uri}"} - @response, @document_list = get_search_results( extra_controller_params ) - - # Including this line so permissions tests can be run against the container - @container_response, @document = get_solr_response_for_doc_id(params[:asset_id]) - - # Including these lines for backwards compatibility (until we can use Rails3 callbacks) - @container = ActiveFedora::Base.load_instance(params[:asset_id]) - @solr_result = @container.file_objects(:response_format=>:solr) - end - - # Load permissions_solr_doc based on params[:asset_id] - load_permissions_from_solr(params[:asset_id]) - - render :action=>params[:action], :layout=>layout - end - - def new -=begin -From file_assets/_new.html.haml -=render :partial=>"fluid_infusion/uploader" -=render :partial=>"fluid_infusion/uploader_js" -=end - render :partial=>"new", :layout=>false - end - - # Creates and Saves a File Asset to contain the the Uploaded file - # If container_id is provided: - # * the File Asset will use RELS-EXT to assert that it's a part of the specified container - # * the method will redirect to the container object's edit view after saving - def create - if params.has_key?(:number_of_files) and params[:number_of_files] != "0" - return redirect_to({:controller => "catalog", :action => "edit", :id => params[:id], :wf_step => :files, :number_of_files => params[:number_of_files]}) - elsif params.has_key?(:number_of_files) and params[:number_of_files] == "0" - return redirect_to( {:controller => "catalog", :action => "edit", :id => params[:id]}.merge(params_for_next_step_in_wokflow) ) - end - - if params.has_key?(:Filedata) - @file_assets = create_and_save_file_assets_from_params - notice = [] - @file_assets.each do |file_asset| - apply_depositor_metadata(file_asset) - - notice << "The file #{file_asset.label} has been saved in #{file_asset.pid}." - - if !params[:container_id].nil? - associate_file_asset_with_container(file_asset,'info:fedora/' + params[:container_id]) - end - - ## Apply any posted file metadata - unless params[:asset].nil? - logger.debug("applying submitted file metadata: #{@sanitized_params.inspect}") - apply_file_metadata - end - # If redirect_params has not been set, use {:action=>:index} - logger.debug "Created #{file_asset.pid}." - end - flash[:notice] = notice.join("
") unless notice.blank? - else - flash[:notice] = "You must specify a file to upload." - end - - unless params[:container_id].nil? - redirect_params = {:controller => "catalog", :action => "edit", :id => params[:container_id]}.merge(params_for_next_step_in_wokflow) - end - redirect_params ||= {:controller => "catalog", :action => "index"} - - redirect_to redirect_params - end - - # Common destroy method for all AssetsControllers - def destroy - # The correct implementation, with garbage collection: - # if params.has_key?(:container_id) - # container = ActiveFedora::Base.load_instance(params[:container_id]) - # container.file_objects_remove(params[:id]) - # FileAsset.garbage_collect(params[:id]) - # else - - # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers) - ActiveFedora::Base.load_instance(params[:id]).delete - - flash[:notice] = "Deleted #{params[:id]} from #{params[:container_id]}." - - if !params[:container_id].nil? - redirect_params = {:controller => "catalog", :action => "edit", :id => params[:container_id], :anchor => "file_assets"} - end - redirect_params ||= {:action => 'index', :q => nil , :f => nil} - - redirect_to redirect_params - - end - - - def show - @file_asset = FileAsset.find(params[:id]) - if (@file_asset.nil?) - logger.warn("No such file asset: " + params[:id]) - flash[:notice]= "No such file asset." - redirect_to(:action => 'index', :q => nil , :f => nil) - else - # get array of parent (container) objects for this FileAsset - @id_array = @file_asset.containers(:response_format => :id_array) - @downloadable = false - # A FileAsset is downloadable iff the user has read or higher access to a parent - @id_array.each do |pid| - @response, @permissions_solr_document = get_solr_response_for_doc_id(pid) - if reader? - @downloadable = true - break - end - end - - if @downloadable - if @file_asset.datastreams_in_memory.include?("DS1") - send_datastream @file_asset.datastreams_in_memory["DS1"] - end - else - flash[:notice]= "You do not have sufficient access privileges to download this document, which has been marked private." - redirect_to(:action => 'index', :q => nil , :f => nil) - end - end - end - + include Hydra::FileAssets end diff --git a/fedora_conf/conf/fedora.fcfg b/fedora_conf/conf/development/fedora.fcfg similarity index 100% rename from fedora_conf/conf/fedora.fcfg rename to fedora_conf/conf/development/fedora.fcfg diff --git a/fedora_conf/conf/test/fedora.fcfg b/fedora_conf/conf/test/fedora.fcfg new file mode 100644 index 000000000..40f1e7e12 --- /dev/null +++ b/fedora_conf/conf/test/fedora.fcfg @@ -0,0 +1,1021 @@ + + + + Defines a human readable name for the Fedora server; default is + Fedora Repository. + + + Defines one or more email addresses for server administrators; + list is space delimited. + + + Defines the port number on which the Fedora server runs; + default is 8080. + + + Defines the port number used to shutdown the Fedora sever; + default is 8005. + + + Defines the redirect port of the Fedora sever; default is 8443. + + + Defines the host name for the Fedora server, as seen from the + outside world. + + + Defines the context name for the Fedora server within the + application server. If set to eg "myfedora" the URL for Fedora will result + in http[s]://fedoraServerHost[:fedoraServerPort]/myfedora. + + + Controls the size of the datastream mediation hash by removing + entries outside the specified threshold. The value is specified in + seconds. Note this value must be greater than the limit specified for + the datastreamMediationLimit. + + + Determines the time interval in which external mechanisms must + respond to requests by the Fedora server. The value is specified in + milliseconds. The value specified should be set high enough to allow + for an average response time from any single external mechanisms. Note + this value must be less than the limit specified for the + datastreamExpirationLimit. + + + determines if a content-disposition header specifying "inline" and + a filename is added to the response for the REST API getDatastreamDissemination + when no query parameter of download=true is specified. Browser support for + recognising a filename in case of "inline" content disposition is patchy, + so you may wish to disable the content disposition header in this case and only + have it provided when download=true is specified, in which case the content disposition + of "attachment" will be used; which is generally supported. + + + determines the source of the filename generated when download=true + on a datastream dissemination. Value is space separated list of label: use the datastream label; + id: use the datastream ID; rels: use the value defined in RELS-INT. Each + source is checked in order, and the first containing a value is used. Omit + any of the sources if that source is never to be used. If no sources are to be used, + and just the default filename and extension below are to be used, specify " ". + + + Controls filename extension mapping when the datastream label is used + as the source of the filename. Values are always: always generate an extension + based on the MIMETYPE, using the default extension if none can be determined; + ifmissing: generate an extension if the filename obtained from the source does not + already contain one (again returning the default if there is no MIMETYPE-to-extension + mapping is found); never: never generate an extension, use the filename from the source + as-is + + + Controls filename extension mapping when the datastream ID is used + as the source of the filename. Values are as above. + + + Controls filename extension mapping when RELS-INT is used + as the source of the filename. Values are as above. + + + Controls filename extension mapping when no filename can be determined from + the sources listed in datastreamFilenameSource. Values are always: always generate an extension + based on the MIMETYPE (using the default if no appropriate mapping is specified); + never: never generate an extension. + + + Filename to use for datastream downloads when none can be determined from the + sources listed in datastreamFilenameSource. + + + Extension to use when none can be determined from mappings + + + Source of mappings from MIMETYPE to file extension + + + Number of seconds Fedora http client will wait for a connection before timing + out. + + + Number of seconds Fedora http client will wait for data coming across an + established http connection. + + + Maximum number of Fedora http client connections allowed to a given host. + + + Maximum number of total Fedora http client connections allowed at once. + + + Should the Fedora http client follow redirects? + + + Maximun number of redirects the Fedora http client will follow (only if + httpClientFollowRedirects is set to true.) + + + The value to be set for the User-Agent HTTP request header. + + + + + Builds and manages Fedora's authorization structure. + + + This parameter is for future use. + + + + + + + + + + Description: Interface to the backend service security + configuration. This module initializes backend service security + information in the server by parsing the beSecurity configuration file. + This file is located in the distribution in + $FEDORA_HOME/dist/server/config/beSecurity.xml. The configuration file + is read once at server startup. + + Controls whether beSecurity config file is validated + against the beSecurityDescription schema. The default is + "false". Valid values are "true" or + "false". + + + The character encoding used for the beSecurity + configuration file. The default is "utf-8". The value + specified must correspond to the character encoding used in the + beSecurity configuration file. + + + + The interface to the storage subsystem. This provides + context-appropriate DOReaders and DOWriters for reflecting on and + writing to the objects stored in the repository. It also provides + methods for reflecting on the contents of the repository as a whole.. + + This is the namespace id for pids of newly-created objects. + This should be unique for a repository. It can be from 1 to 17 + characters, and may only contain A-Z, a-z, 0-9, '.', or '-' (dash). + + + The named connection pool from which read/write database + connections are to be provided for the storage subsystem (see the + ConnectionPoolManager module). Default is the default provided by the + ConnectionPoolManager. + + + If the serialization format is text-based, this is the + character encoding that should be used. Default is UTF-8. + + + + The control group to use for the system-generated DC datastream + if no DC datastream is present on ingest. Must be "X" or "M". + + + The control group to use for system-generated RELS-EXT and + RELS-INT datastreams where these are not already present when + adding relationships via addRelationship. Must be "X" or "M". + + + The REST endpoint of the Fedora Generic Search service. + This parameter is only required if GSearchDOManager is + used. + + + The username for accessing the REST endpoint of the + Fedora Generic Search service. This parameter is only required if + GSearchDOManager is used, and the service requires + authentication. + + + The associated password for accessing the REST endpoint + of the Fedora Generic Search service. This parameter is only + required if GSearchDOManager is used, and the service requires + authentication. + + + + The management subsystem. This implements the methods necessary + to fulfill API-M requests without regard to: + - how the service is exposed + - how bytestreams and java types might be marshalled/demarshalled over the wire + - how the storage subsystem is implemented. + + + Controls whether a checksum is automatically computed for + every datastream as the datastream is added to the repository. This + will allow the integrity of datastream contents to be periodically + checked to insure the object is not corrupted. + + + Specifies which checksumming algorithm is to be used when + automatically computing checksums as specified by the above + parameter. Valid values are: MD5 SHA-1 SHA-256 SHA-384 SHA-512. + + + Optional, default is 60000 (1 minute). + This specifies the amount of time between checks to remove + temporary files uploaded via the API-M upload interface. During + each check, old files whose age exceeds uploadStorageMinutes + will be removed. + + + Optional, default is 5. + This specifies the minimum amount of time that each uploaded + file should be kept in temporary storage. + + + + Description: The access subsystem. This implements the methods + necessary to fulfill API-A requests without regard to: + - how the service is exposed + - how bytestreams and java types might be marshalled/demarshalled + over the wire. + + A boolean switch indicating whether Datastream Mediation is + activated or not. Datastream Mediation is required if using basic + authentication for API-A. When basic authentication is enabled for + API-A, backend services used by custom disseminations may or may not be + capable of authenticating with the Fedora server. Datastream mediation + coupled with the backend service configuration information in the + beSecurity.xml file enables the Fedora server to determine which backend + services are required to authenticate and which ones are allowed to + connect without authentication. Datastream mediation provides additional + repository security by not exposing the physical location of Referenced + Content datastreams to external mechanisms(services). Instead of + exposing the actual physical location of Referenced Content datastreams, + Datastream Mediation functions as a proxy requiring all external + services to communicate through the Fedora server to resolve the + location of Referenced Content datastreams. + + IMPORTANT: For Datastream Mediation to function, the Fedora server must + be internet accessible using the configured name for fedoraServerHost + and fedoraServerPort. For example, using the default fedoraServerHost + value of "localhost" will not work if you have remote backend services + since the hostname of "localhost" will not be resolvable as the Fedora + server by the remote backend services. This requirement can be difficult + to satisfy if the Fedora server is located behind a firewall and you do + not have ready access to the firewall's configuration to enable the + required access. If the Fedora server is behind a firewall and you have + no access to the firewall's configuration, you are limited to keeping + Datastream Mediation turned off. Note that this will also prevent you + from using basic authentication with API-A. The default value of + doMediateDatastreams is false. + + + + The dynamic behavior module for the access subsystem. This + implements the methods necessary to fulfill API-A requests without + regard to: + - dynamically associating a default behavior definition and mechanism with objects + - (Future) dynamically associating other behavior definitions and mechanisms + with objects + - running disseminations of dynamic behaviors + + The interface that defines the methods of the bootstrap + disseminator. These methods are "built-in" to the Fedora system, and + are dynamically associated with every behavior definition and + behavior mechanism object. + + + The class that implements the methods of the bootstrap + disseminator. These method implementations are "built-in" to the + Fedora system, and are dynamically associated with every behavior + definition and behavior mechanism object. This class can be thought + of as implementing an "internal service" whereas other disseminators + use external services (described by WSDL) to do their work. + + + The interface that defines the methods of the default + disseminator. These methods are "built-in" to the Fedora system, and + are dynamically associated with every object. + + + The class that implements the methods of the default + disseminator. These method implementations are "built-in" to the + Fedora system, and are dynamically associated with every object. + This class can be though of as implementing an "internal service" + whereas other disseminators use external services (described by + WSDL) to do their work. + + + + Supports the API-A simpleSearch and advancedSearch methods. + + (required, must be > 0) + The maximum number of records to + return as the result of a search. Even if a client requests more + results at a time, this is the cutoff value. + + + (required, must be > 0) + The maximum number of seconds that the server guarantees subsequent + search results may be obtained. This is only used in cases where the + number of results is greater than maxResults (as specified by the + server [above] or the client [in the search request]). + + + (optional) To make unspecified, comment out or delete the + whole param line as opposed to using an empty string, + default=ConnectionPoolManager's default) The connectionPool + providing the connection to the database to be used. Warning: When + setting these values, keep in mind that while a session is not timed + out (maxSecondsPerSession seconds haven't elapsed, and not all + results have been requested), a connection from the pool is tied up. + Therefore, the connectionPool should be at least of size n, large + enough to accomodate n simultaneous search sessions. The longer + maxSecondsPerSession is, the more chance you have of tying up all + available connections from the pool. Therefore, keep + maxSecondsPerSession fairly low, but still reasonable for an + automated program or user to serially get a long list of results, + and make sure you have a connectionPool large enough to accomodate + your users. + + + (optional, default is true) Whether the content of the DC + datastream should be examined and the contents indexed, for each object. + You may wish to save time and space by disabling DC field indexing, + particularly if you have an external search service (such as Fedora + Generic Search) that already fulfills this need. + Note: If you change this value on a Fedora repository that has been + running for some time, you will need to perform a SQL rebuild using the + Fedora Rebuilder tool if you want to change objects that have already + been ingested. + + + + Supports the ResourceIndex. + + (required) + Index level. Currently, only 0, and 1 are supported levels. + 0 = off and 1 = on. + WARNING: changing the level (except to 0) requires + running the Resource Index Rebuilder. + + + (required) + Name of the triplestore to use. WARNING: changing the + triplestore running the Resource Index Rebuilder. + + + (optional, default is false) + Whether to flush the triple buffer before + returning from object modification operations. + Specifying this as true will ensure that RI queries + immediately reflect the latest triples. + Specifying false will not provide this guarantee, + but can significantly reduce roundtrip time for + API-M operations (depending on the triplestore + implementation). + + + (optional) Aliases that can be used for queries. The param + name of an alias starts with the string "alias:" and is followed by + the name of the alias (shortcut) for the value, which is a URI + prefix. For example: name="alias:test" + value="http://example.org/terms#" will allow a query to use + test:apple instead of http://example.org/terms#apple + + + + Description: Exposes the repository for OAI harvesters. + + + + + + + + + Supports translation from DigitalObject to a stream of some + format, and vice-versa. The parameters below specify + serializer/deserializer classes to be used for a given format. Those + classes must implement the DOSerializer/DODeserializer interfaces. + + + + + + + + + + + + + + + The pid generator. + + + + Fedora's Java Messaging Service (JMS) Module + + + + + A datastore representing a JMS Destination for APIM events which update the repository + + + A datastore representing a JMS Destination for APIM events which do not update the repository + + + + This module facilitates obtaining ConnectionPools + + + + + Description: Supports validation of digital objects, including + XML Schema validation, Schematron validation (to Fedora Rules schema + written in Schematron language), and other programatic validation + including referential integrity checking of existence and + availability of distributed data and/or services. + + The local path for the Fedora-METS XML + schema used to do XML schema validation of digital objects. + + + The local path for the Fedora-METS 1.0 XML + schema used to do XML schema validation of digital objects. + + + The local path for the Fedora FOXML 1.1 XML schema + used to do XML schema validation of digital objects + + + The local path for the Fedora FOXML 1.0 XML schema + used to do XML schema validation of digital objects + + + The local path for the Atom XML schema used to do XML + schema validation of digital objects + + + The local path for the Atom XML schema used to do XML + schema validation of digital objects + + + The local path for the OASIS XACML XML policy schema + used to do XML schema validation of XACML policies. + + + The local path to the Schematron Rules used for + Fedora-specific validation on Fedora-METS XML files. + + + The local path to the Schematron Rules used for + Fedora-specific validation on Fedora-METS 1.0 XML files. + + + The local path to the Schematron Rules used for + Fedora-specific validation on FOXML 1.1 XML files. + + + The local path to the Schematron Rules used for + Fedora-specific validation on FOXML 1.0 XML files. + + + The local path to the Schematron Rules used for + Fedora-specific on Atom XML files. + + + The local path to the Schematron Rules used for + Fedora-specific on Atom Zip files. + + + + (required) + This is a directory that the validation module can use as a work space, as + when it must write a temporary file. + + + + This module facilitates obtaining external content via HTTP + + + MySQL database on localhost with db name of fedora3. Each + connection pool instance has several configuration parameter that + can be used to tune the options for the connection pool. It is + recommended that you not change the default values unless you are + trying to address a specific performance issue. For additional + information regarding connection pool options, refer to the Apache + Commons Pool API documentation at + http://jakarta.apache.org/commons/pool/apidocs/index.html. + + The database user name. + + + The database password. + + + The JDBC connection URL. + + + The JDBC driver class name. + + + + The maximum number of active instances in pool. + + + The maximum number of idle instances in pool. + + + The maximum amount of time in milliseconds the + borrowObject() method should wait before throwing an Exception when + whenExhaustedAction is set to WHEN_EXHAUSTED_BLOCK. A value less + than zero indicates block indefinitely. + + + The minimum of idle instances in pool. + + + The minimum amount of time in milliseconds an object can be + idle in pool before eligible for eviction (if applicable). A value + less than zero indicates no object will be evicted due to idle time + alone. + + + The number of objects to be examined on each run of idle + evictor thread (if applicable). A value less than zero indicates + that ceil(numIdle)/abs(numTestsPerEvictionRun) will be run. + + + The time in milliseconds to sleep between runs of the idle + object evictor thread. A value less than zero indicates no idle + evictor thread is run. + + + The query to run when validating connections. + Connections are validated according to the testOnBorrow, + testOnReturn, and testWhileIdle configuration values. + If this is specified, it must be a SQL SELECT statement + that returns at least one row. If this is NOT specified, + validation tests will not be run. + + + When true objects are validated before borrowed from the + pool. + + + When true, objects are validated before returned to the + pool. + + + When true, objects are validated by the idle object evictor + thread. + + + Action to take when a new object is requested and the the pool has + reached maximum number of active objects. Valid values are: + 0 (fail i.e., throw Exception) + 1 (block i.e., wait until pool resources are freed) + 2 (grow i.e., increase the size of the pool). + + + + McKoi database on localhost running on port 9157 Each + connection pool instance has several configuration parameter that + can be used to tune the options for the connection pool. It is + recommended that you not change the default values unless you are + trying to address a specific performance issue. For additional + information regarding connection pool options, refer to the Apache + Commons Pool API documentation at + http://jakarta.apache.org/commons/pool/apidocs/index.html. + + The database user name. + + + The database password. + + + The JDBC connection URL. + + + The JDBC driver class name. + + + + The maximum number of active instances in pool. + + + The maximum number of idle instances in pool. + + + The maximum amount of time in milliseconds the + borrowObject() method should wait before throwing an Exception when + whenExhaustedAction is set to WHEN_EXHAUSTED_BLOCK. A value less + than zero indicates block indefinitely. + + + The minimum of idle instances in pool. + + + The minimum amount of time in milliseconds an object can be + idle in pool before eligible for eviction (if applicable). A value + less than zero indicates no object will be evicted due to idle time + alone. + + + The number of objects to be examined on each run of idle + evictor thread (if applicable). A value less than zero indicates + that ceil(numIdle)/abs(numTestsPerEvictionRun) will be run. + + + The time in milliseconds to sleep between runs of the idle + object evictor thread. A value less than zero indicates no idle + evictor thread is run. + + + When true objects are validated before borrowed from the + pool. + + + When true, objects are validated before returned to the + pool. + + + When true, objects are validated by the idle object evictor + thread. + + + Action to take when a new object is requested and the the pool has + reached maximum number of active objects. Valid values are: + 0 (fail i.e., throw Exception) + 1 (block i.e., wait until pool resources are freed) + 2 (grow i.e., increase the size of the pool). + + + + Derby database on localhost running on port 1527 Each + connection pool instance has several configuration parameter that + can be used to tune the options for the connection pool. It is + recommended that you not change the default values unless you are + trying to address a specific performance issue. For additional + information regarding connection pool options, refer to the Apache + Commons Pool API documentation at + http://jakarta.apache.org/commons/pool/apidocs/index.html. + + The database user name. + + + The database password. + + + The JDBC connection URL. + + + The JDBC driver class name. + + + + The maximum number of active instances in pool. + + + The maximum number of idle instances in pool. + + + The maximum amount of time in milliseconds the + borrowObject() method should wait before throwing an Exception when + whenExhaustedAction is set to WHEN_EXHAUSTED_BLOCK. A value less + than zero indicates block indefinitely. + + + The minimum of idle instances in pool. + + + The minimum amount of time in milliseconds an object can be + idle in pool before eligible for eviction (if applicable). A value + less than zero indicates no object will be evicted due to idle time + alone. + + + The number of objects to be examined on each run of idle + evictor thread (if applicable). A value less than zero indicates + that ceil(numIdle)/abs(numTestsPerEvictionRun) will be run. + + + The time in milliseconds to sleep between runs of the idle + object evictor thread. A value less than zero indicates no idle + evictor thread is run. + + + When true objects are validated before borrowed from the + pool. + + + When true, objects are validated before returned to the + pool. + + + When true, objects are validated by the idle object evictor + thread. + + + Action to take when a new object is requested and the the pool has + reached maximum number of active objects. Valid values are: + 0 (fail i.e., throw Exception) + 1 (block i.e., wait until pool resources are freed) + 2 (grow i.e., increase the size of the pool). + + + + Oracle database on localhost with SID=fedora3 Each + connection pool instance has several configuration parameter that + can be used to tune the options for the connection pool. It is + recommended that you not change the default values unless you are + trying to address a specific performance issue. For additional + information regarding connection pool options, refer to the Apache + Commons Pool API documentation at + http://jakarta.apache.org/commons/pool/apidocs/index.html. + + The database user name. + + + The database password. + + + The JDBC connection URL. + + + The JDBC driver class name. + + + + The maximum number of active instances in pool. + + + The maximum number of idle instances in pool. + + + The maximum amount of time in milliseconds the + borrowObject() method should wait before throwing an Exception when + whenExhaustedAction is set to WHEN_EXHAUSTED_BLOCK. A value less + than zero indicates block indefinitely. + + + The minimum of idle instances in pool. + + + The minimum amount of time in milliseconds an object can be + idle in pool before eligible for eviction (if applicable). A value + less than zero indicates no object will be evicted due to idle time + alone. + + + The number of objects to be examined on each run of idle + evictor thread (if applicable). A value less than zero indicates + that ceil(numIdle)/abs(numTestsPerEvictionRun) will be run. + + + The time in milliseconds to sleep between runs of the idle + object evictor thread. A value less than zero indicates no idle + evictor thread is run. + + + The query to run when validating connections. + Connections are validated according to the testOnBorrow, + testOnReturn, and testWhileIdle configuration values. + If this is specified, it must be a SQL SELECT statement + that returns at least one row. If this is NOT specified, + validation tests will not be run. + + + When true objects are validated before borrowed from the + pool. + + + When true, objects are validated before returned to the + pool. + + + When true, objects are validated by the idle object evictor + thread. + + + Action to take when a new object is requested and the the pool has + reached maximum number of active objects. Valid values are: + 0 (fail i.e., throw Exception) + 1 (block i.e., wait until pool resources are freed) + 2 (grow i.e., increase the size of the pool). + + + + + PostgreSQL database on localhost with db name of fedora3. Each + connection pool instance has several configuration parameter that + can be used to tune the options for the connection pool. It is + recommended that you not change the default values unless you are + trying to address a specific performance issue. For additional + information regarding connection pool options, refer to the Apache + Commons Pool API documentation at + http://jakarta.apache.org/commons/pool/apidocs/index.html. + + The database user name. + + + The database password. + + + The JDBC connection URL. + + + The JDBC driver class name. + + + + The maximum number of active instances in pool. + + + The maximum number of idle instances in pool. + + + The maximum amount of time in milliseconds the + borrowObject() method should wait before throwing an Exception when + whenExhaustedAction is set to WHEN_EXHAUSTED_BLOCK. A value less + than zero indicates block indefinitely. + + + The minimum of idle instances in pool. + + + The minimum amount of time in milliseconds an object can be + idle in pool before eligible for eviction (if applicable). A value + less than zero indicates no object will be evicted due to idle time + alone. + + + The number of objects to be examined on each run of idle + evictor thread (if applicable). A value less than zero indicates + that ceil(numIdle)/abs(numTestsPerEvictionRun) will be run. + + + The time in milliseconds to sleep between runs of the idle + object evictor thread. A value less than zero indicates no idle + evictor thread is run. + + + The query to run when validating connections. + Connections are validated according to the testOnBorrow, + testOnReturn, and testWhileIdle configuration values. + If this is specified, it must be a SQL SELECT statement + that returns at least one row. If this is NOT specified, + validation tests will not be run. + + + When true objects are validated before borrowed from the + pool. + + + When true, objects are validated before returned to the + pool. + + + When true, objects are validated by the idle object evictor + thread. + + + Action to take when a new object is requested and the the pool has + reached maximum number of active objects. Valid values are: + 0 (fail i.e., throw Exception) + 1 (block i.e., wait until pool resources are freed) + 2 (grow i.e., increase the size of the pool). + + + + local Mulgara Triplestore used by the Resource Index + + The name of the Trippi Connector class used to communicate + with the triplestore. + + + Tells the connector to communicate with Mulgara in remote or + local mode. If true, the host parameter must be defined. If false, + the path parameter must be defined. + + + The local path to the main triplestore directory. + + + The server name for rmi binding. + + + The name of the model to use. + + + The initial size of the session pool used for queries. + Note: A value of 0 will cause the Resource Index to operate in + synchronized mode: concurrent read/write requests are put in a queue + and handled in FIFO order; this will severely impair performance and + is only intended for debugging. + + + Maximum number of additional sessions the pool may add. If + specified as -1, no limit will be placed on pool growth. + + + Whether the triplestore should be read-only. Most Fedora + repositories will set this to false. + + + Create the model if it doesn't already exist. + At startup, the model will be automatically created. In addition, an + XML schema datatyped model named "xsd" will also be automatically + created. + + + Whether to propagate adds/deletes to a full-text + [Full-Text] model automatically. While a very useful feature, + enabling full-text indexing adds significantly to object ingest + times. If true, the text model will be named modelName-fullText. + Note that if this is true and autoCreate is true, the text model + will also be created if it doesn't already exist. + + + Seconds of buffer inactivity that will trigger an + auto-flush. If this threshold is reached, flushing will occur in the + background, during which time the buffer is still available for + writing. + + + The size at which the buffer should be auto-flushed. If + this threshold is reached, flushing will occur in the background, + during which time the buffer is still available for + writing. + + + The number of updates to send to the triplestore at a time. + This should be the same size as, or smaller than + autoFlushBufferSize. + + + The maximum size the buffer can reach before being forcibly + flushed. If this threshold is reached, flushing will occur in the + foreground and the buffer will be locked for writing until it is + finished. This should be larger than autoFlushBufferSize. + + + + Example local MPTStore backed by Postgres. + To use this triplestore for the Resource Index: + 1) In fedora.fcfg, change the "datastore" parameter of the + ResourceIndex module to localPostgresMPTTriplestore. + 2) Login to your Postgres server as an administrative user and + run the following commands: + CREATE ROLE "fedoraAdmin" LOGIN PASSWORD 'fedoraAdmin' + NOINHERIT CREATEDB + VALID UNTIL 'infinity'; + CREATE DATABASE "riTriples" + WITH ENCODING='SQL_ASCII' + OWNER="fedoraAdmin"; + 3) Make sure you can login to your Postgres server as fedoraAdmin. + 4) Download the appropriate Postgres JDBC 3 driver from + http://jdbc.postgresql.org/download.html + and make sure it's accessible to your servlet container. + If you're running Tomcat, putting it in common/lib/ will work. + + + + + + + + + + + + + + + + + Messaging Destination for API-M events which update the repository + + A space-separated list of message types that will be + delivered to this Destination. Currently, "apimUpdate" and + "apimAccess" are the only supported message types. + + + + Optional, defaults to topic. + + + + Messaging Destination for API-M events which did not make changes to the repository + + A space-separated list of message types that will be + delivered to this Destination. Currently, "apimUpdate" and + "apimAccess" are the only supported message types. + + + + Optional, defaults to topic. + + + diff --git a/jetty b/jetty index 3eecb92c2..2f144a12c 160000 --- a/jetty +++ b/jetty @@ -1 +1 @@ -Subproject commit 3eecb92c24c9e2fce7997109bbcaa990534dbe44 +Subproject commit 2f144a12c53b1c6655772c148aaa4087aeb95ba0 diff --git a/lib/hydra-head/version.rb b/lib/hydra-head/version.rb index 6a564c673..0db95e596 100644 --- a/lib/hydra-head/version.rb +++ b/lib/hydra-head/version.rb @@ -1,4 +1,4 @@ module HydraHead - VERSION = "3.1.2" + VERSION = "3.1.3" end diff --git a/lib/hydra.rb b/lib/hydra.rb index a575920de..7079622f1 100644 --- a/lib/hydra.rb +++ b/lib/hydra.rb @@ -5,6 +5,7 @@ module Hydra extend ActiveSupport::Autoload autoload :Configurable, 'blacklight/configurable' autoload :Assets + autoload :FileAssets end diff --git a/lib/hydra/file_assets.rb b/lib/hydra/file_assets.rb new file mode 100644 index 000000000..e39639722 --- /dev/null +++ b/lib/hydra/file_assets.rb @@ -0,0 +1,148 @@ +module Hydra::FileAssets + extend ActiveSupport::Concern + + include Hydra::AccessControlsEnforcement + include Hydra::AssetsControllerHelper + include Hydra::FileAssetsHelper + include Hydra::RepositoryController + include MediaShelf::ActiveFedoraHelper + include Blacklight::SolrHelper + + included do + before_filter :require_solr, :only=>[:index, :create, :show, :destroy] + # need to include this after the :require_solr/fedora before filters because of the before filter that the workflow provides. + include Hydra::SubmissionWorkflow + prepend_before_filter :sanitize_update_params + helper :hydra_uploader + end + + def index + if params[:layout] == "false" + layout = false + end + + if params[:asset_id].nil? + @solr_result = FileAsset.find_by_solr(:all) + else + container_uri = "info:fedora/#{params[:asset_id]}" + escaped_uri = container_uri.gsub(/(:)/, '\\:') + extra_controller_params = {:q=>"is_part_of_s:#{escaped_uri}"} + @response, @document_list = get_search_results( extra_controller_params ) + + # Including this line so permissions tests can be run against the container + @container_response, @document = get_solr_response_for_doc_id(params[:asset_id]) + + # Including these lines for backwards compatibility (until we can use Rails3 callbacks) + @container = ActiveFedora::Base.load_instance(params[:asset_id]) + @solr_result = @container.file_objects(:response_format=>:solr) + end + + # Load permissions_solr_doc based on params[:asset_id] + load_permissions_from_solr(params[:asset_id]) + + render :action=>params[:action], :layout=>layout + end + + def new + render :partial=>"new", :layout=>false + end + + # Creates and Saves a File Asset to contain the the Uploaded file + # If container_id is provided: + # * the File Asset will use RELS-EXT to assert that it's a part of the specified container + # * the method will redirect to the container object's edit view after saving + def create + if params.has_key?(:number_of_files) and params[:number_of_files] != "0" + return redirect_to({:controller => "catalog", :action => "edit", :id => params[:id], :wf_step => :files, :number_of_files => params[:number_of_files]}) + elsif params.has_key?(:number_of_files) and params[:number_of_files] == "0" + return redirect_to( {:controller => "catalog", :action => "edit", :id => params[:id]}.merge(params_for_next_step_in_wokflow) ) + end + + if params.has_key?(:Filedata) + @file_assets = create_and_save_file_assets_from_params + notice = [] + @file_assets.each do |file_asset| + apply_depositor_metadata(file_asset) + + notice << "The file #{file_asset.label} has been saved in #{file_asset.pid}." + + if !params[:container_id].nil? + associate_file_asset_with_container(file_asset,'info:fedora/' + params[:container_id]) + end + + ## Apply any posted file metadata + unless params[:asset].nil? + logger.debug("applying submitted file metadata: #{@sanitized_params.inspect}") + apply_file_metadata + end + # If redirect_params has not been set, use {:action=>:index} + logger.debug "Created #{file_asset.pid}." + end + flash[:notice] = notice.join("
") unless notice.blank? + else + flash[:notice] = "You must specify a file to upload." + end + + unless params[:container_id].nil? + redirect_params = {:controller => "catalog", :action => "edit", :id => params[:container_id]}.merge(params_for_next_step_in_wokflow) + end + redirect_params ||= {:controller => "catalog", :action => "index"} + + redirect_to redirect_params + end + + # Common destroy method for all AssetsControllers + def destroy + # The correct implementation, with garbage collection: + # if params.has_key?(:container_id) + # container = ActiveFedora::Base.load_instance(params[:container_id]) + # container.file_objects_remove(params[:id]) + # FileAsset.garbage_collect(params[:id]) + # else + + # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers) + ActiveFedora::Base.load_instance(params[:id]).delete + + flash[:notice] = "Deleted #{params[:id]} from #{params[:container_id]}." + + if !params[:container_id].nil? + redirect_params = {:controller => "catalog", :action => "edit", :id => params[:container_id], :anchor => "file_assets"} + end + redirect_params ||= {:action => 'index', :q => nil , :f => nil} + + redirect_to redirect_params + + end + + + def show + @file_asset = FileAsset.find(params[:id]) + if (@file_asset.nil?) + logger.warn("No such file asset: " + params[:id]) + flash[:notice]= "No such file asset." + redirect_to(:action => 'index', :q => nil , :f => nil) + else + # get array of parent (container) objects for this FileAsset + @id_array = @file_asset.containers(:response_format => :id_array) + @downloadable = false + # A FileAsset is downloadable iff the user has read or higher access to a parent + @id_array.each do |pid| + @response, @permissions_solr_document = get_solr_response_for_doc_id(pid) + if reader? + @downloadable = true + break + end + end + + if @downloadable + if @file_asset.datastreams.include?("DS1") + send_datastream @file_asset.datastreams["DS1"] + end + else + flash[:notice]= "You do not have sufficient access privileges to download this document, which has been marked private." + redirect_to(:action => 'index', :q => nil , :f => nil) + end + end + end +end + diff --git a/lib/railties/hydra_jetty.rake b/lib/railties/hydra_jetty.rake index 865bdf9cf..e33867bea 100644 --- a/lib/railties/hydra_jetty.rake +++ b/lib/railties/hydra_jetty.rake @@ -32,14 +32,20 @@ namespace :hydra do app_root = File.join(File.dirname(__FILE__),"..") end - fcfg = File.join(app_root,"fedora_conf","conf","fedora.fcfg") - puts "PWD:: #{FileUtils.pwd}" + fcfg = File.join(app_root,"fedora_conf","conf","development","fedora.fcfg") if File.exists?(fcfg) - puts "copying over fedora.fcfg" + puts "copying over development/fedora.fcfg" cp("#{fcfg}", 'jetty/fedora/default/server/config/', :verbose => true) else puts "#{fcfg} file not found -- skipping fedora config" end + fcfg = File.join(app_root,"fedora_conf","conf","test","fedora.fcfg") + if File.exists?(fcfg) + puts "copying over test/fedora.fcfg" + cp("#{fcfg}", 'jetty/fedora/test/server/config/', :verbose => true) + else + puts "#{fcfg} file not found -- skipping fedora config" + end end desc "Copies the default SOLR config files and starts up the fedora instance." diff --git a/test_support/spec/controllers/permissions_controller_spec.rb b/test_support/spec/controllers/permissions_controller_spec.rb index 26d5b1a85..2fe151ed8 100644 --- a/test_support/spec/controllers/permissions_controller_spec.rb +++ b/test_support/spec/controllers/permissions_controller_spec.rb @@ -9,22 +9,6 @@ # rake cucumber describe PermissionsController do - describe "index" do - it "should retrieve the object's rightsMetadata datastream as a Hydra::RightsMetadata object and render the _index partial" do - end - end - describe "show" do - it"should render different partial based on the permission type" do - pending - renders "permissions/edit_individual" - renders "permissions/edit_group" - end - end - describe "edit" do - end - describe "new" do - it "should render the _new partial" - end describe "create" do it "should create a new permissions entry" do stub_solrizer = stub("solrizer", :solrize) @@ -33,7 +17,6 @@ Hydra::RightsMetadata.stubs(:from_xml) Hydra::RightsMetadata.stubs(:new).returns(mock_ds) mock_ds.expects(:permissions).with({"person" => "_person_id_"}, "read") - # mock_ds.expects(:update_permissions).with({"person"=>{"_person_id_"=>"read"}}) mock_ds.stubs(:content) mock_ds.stubs(:pid=) mock_ds.stubs(:dsid=) @@ -47,9 +30,7 @@ ActiveFedora::Base.expects(:load_instance).with("_pid_").returns(mock_object) post :create, :asset_id=>"_pid_", :permission => {"actor_id"=>"_person_id_","actor_type"=>"person","access_level"=>"read"} - # post :create, :asset_id=>"_pid_", :permission => {"person"=>"_person_id_","level"=>"read"} end - it "should rely on .update method" end describe "update" do it "should call Hydra::RightsMetadata properties setter" do @@ -79,10 +60,5 @@ post :update, :asset_id=>"_pid_", :permission => {"group"=>{"_group_id_"=>"discover"}} end - it "should add a rightsMetadata datastream if it doesn't exist" - it "should not cause the metadata to be indexed twice" do - # should load the object as ActiveFedora::Base, initialize the rightsMetadata datastream as Hydra::RightsMetadata, update the datastream, save the datastream, and tell Solrizer to re-index the object from pid - # re-indexing from pid rather than passing in the current object prevents double-indexing of the edited metadatata datastream - end end end diff --git a/test_support/spec/generators/hydra-head_generator_spec.rb b/test_support/spec/generators/hydra-head_generator_spec.rb deleted file mode 100644 index ce07bcede..000000000 --- a/test_support/spec/generators/hydra-head_generator_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -# -*- encoding : utf-8 -*- -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -require "generators/hydra/head_generator" -require "generators/blacklight/blacklight_generator" - -describe Hydra::HeadGenerator do - - it "should be tested, but it's not clear how..." - it "should inject Hydra behaviors into User model by adding include Hydra::User" do - pending "Not sure how to test this..." - end - -end -