cul_hydra 1.6.4 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dab1003e11e34d701dde1eb46e18f31e34c72f2aedaadb6c56c95de80ce21f9a
4
- data.tar.gz: '090c961afa5d3dd183c32ffeb3362fd712dca7321f42c4b9c8b3abe89f8d7ef0'
3
+ metadata.gz: 9cfae057e0eb17a94cd5c1d9428e9198d9b5e23917bb61f30ee53e961325d2b6
4
+ data.tar.gz: f7c3fd3150d8e7f68f83b94cbdb3b6b8c15e51965aacdd99904275acf7b811eb
5
5
  SHA512:
6
- metadata.gz: 56f4da8b82090c0d603655d69707ea82dbb09137614e973e8b08c29101339c816655b88d340f61f96fa1e79f96cc3c154b1426128ada17eeb3edb68f9868eb8f
7
- data.tar.gz: 3a8a85793196a278cab4c74a8ba3e38659de18866caed38ee9eb078b3edb8e9c0fe69a093ec35f2bdf5dc46dfccccee6cc48883923c759cbc4597fca69bdc68c
6
+ metadata.gz: b59e0f3115c18aa023fc89d32c3052087f0e4038ff9d3f21547536e7c742c22a83d23960abf1291eadef58b1618be99e466555061d46ab917f0b812ed2464e5d
7
+ data.tar.gz: f3898ca39cc7af64c33744f60d32fe6c72c6f1302775031264fbfbba34f17dc0d0830a9126b88812a5d97e12fd5bb00b0f38a26d5b528ea6c910901f912a5576
@@ -0,0 +1,10 @@
1
+ module Cul
2
+ module Hydra
3
+ module Datastreams
4
+ class AccessControlMetadata < ::ActiveFedora::Datastream
5
+ include ::ActiveFedora::Datastreams::NokogiriDatastreams
6
+ include Cul::Hydra::Solrizer::AccessControlMetadataFields
7
+ end
8
+ end
9
+ end
10
+ end
@@ -21,6 +21,7 @@ class GenericResource < ::ActiveFedora::Base
21
21
  LENGTH = RDF::URI(ActiveFedora::Predicates.find_graph_predicate(:image_length))
22
22
 
23
23
  has_datastream :name => "content", :type=>::ActiveFedora::Datastream, :versionable => true
24
+ has_datastream :name => "accessControlMetadata", :type=>Cul::Hydra::Datastreams::AccessControlMetadata, :versionable => false
24
25
  has_metadata :name=>"RELS-INT", :type=>ActiveFedora::RelsInt::Datastream
25
26
 
26
27
  rdf_types(RDF::CUL.Resource)
@@ -0,0 +1,20 @@
1
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
2
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ PolicyId="policy:89dcca6c-87b3-46d5-a1fd-1264ae7488c2"
4
+ RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-unless-permit">
5
+ <Description>Sample policy for unpublishable content</Description>
6
+ <Target>
7
+ <AnyOf>
8
+ <AllOf>
9
+ <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
10
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">GET</AttributeValue>
11
+ <AttributeDesignator MustBePresent="false" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action"
12
+ AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string"/>
13
+ </Match>
14
+ </AllOf>
15
+ </AnyOf>
16
+ </Target>
17
+ <Rule RuleId="1" Effect="Deny">
18
+ <Description>Closed</Description>
19
+ </Rule>
20
+ </Policy>
@@ -0,0 +1,43 @@
1
+
2
+ <?xml version="1.0"?>
3
+ <xacml:Policy xmlns:xacml="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" PolicyId="policy:c2bb973a-b21d-4a5f-b75d-c0374cc820d7" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-unless-permit">
4
+ <xacml:Target>
5
+ <xacml:AnyOf>
6
+ <xacml:AllOf>
7
+ <xacml:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
8
+ <xacml:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">GET</xacml:AttributeValue>
9
+ <xacml:AttributeDesignator MustBePresent="false" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string"/>
10
+ </xacml:Match>
11
+ </xacml:AllOf>
12
+ </xacml:AnyOf>
13
+ </xacml:Target>
14
+ <xacml:Rule RuleId="1" Effect="Permit">
15
+ <xacml:Description>On-site Access</xacml:Description>
16
+ <xacml:Condition FunctionId="urn:oasis:names:tc:xacml:1.0:function:anyURI-at-least-one-member-of">
17
+ <xacml:AttributeDesignator MustBePresent="false" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment" AttributeId="urn:library.columbia.edu:names:reading-room-location" DataType="http://www.w3.org/2001/XMLSchema#anyURI"/>
18
+ <xacml:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:anyURI-bag">
19
+ <xacml:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI" FriendlyName="Reading Room, Rare Book &amp; Manuscript Library, Columbia University">http://id.library.columbia.edu/term/45487bbd-97ef-44b4-9468-dda47594bc60</xacml:AttributeValue>
20
+ </xacml:Apply>
21
+ </xacml:Condition>
22
+ </xacml:Rule>
23
+ <xacml:Rule RuleId="2" Effect="Permit">
24
+ <xacml:Description>Specified Group/UNI Access</xacml:Description>
25
+ <xacml:Condition FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of">
26
+ <xacml:AttributeDesignator MustBePresent="false" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="http://www.ja-sig.org/products/cas/affiliation" DataType="http://www.w3.org/2001/XMLSchema#string"/>
27
+ <xacml:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
28
+ <xacml:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">LIB_role-ext-UnivSemArchives</xacml:AttributeValue>
29
+ </xacml:Apply>
30
+ </xacml:Condition>
31
+ </xacml:Rule>
32
+ <xacml:Rule RuleId="3" Effect="Permit">
33
+ <!-- Each restriction_on_access field group results in a Rule element defining a permit condition -->
34
+ <xacml:Description>Embargoed</xacml:Description>
35
+ <xacml:Condition FunctionId="urn:oasis:names:tc:xacml:1.0:function:date-greater-than-or-equal">
36
+ <xacml:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:date-one-and-only">
37
+ <xacml:AttributeDesignator MustBePresent="false" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment"
38
+ AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-date" DataType="http://www.w3.org/2001/XMLSchema#date"/>
39
+ </xacml:Apply>
40
+ <xacml:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#date">2099-01-01</xacml:AttributeValue>
41
+ </xacml:Condition>
42
+ </xacml:Rule>
43
+ </xacml:Policy>
@@ -0,0 +1,20 @@
1
+ <Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
2
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ PolicyId="policy:89dcca6c-87b3-46d5-a1fd-1264ae7488c2"
4
+ RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-unless-permit">
5
+ <Description>Sample policy for unpublishable content</Description>
6
+ <Target>
7
+ <AnyOf>
8
+ <AllOf>
9
+ <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
10
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">GET</AttributeValue>
11
+ <AttributeDesignator MustBePresent="false" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action"
12
+ AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string"/>
13
+ </Match>
14
+ </AllOf>
15
+ </AnyOf>
16
+ </Target>
17
+ <Rule RuleId="1" Effect="Permit">
18
+ <Description>Public Access</Description>
19
+ </Rule>
20
+ </Policy>
@@ -0,0 +1,9 @@
1
+ module Cul::Hydra::AccessLevels
2
+ ACCESS_LEVEL_PUBLIC = "Public Access".freeze
3
+ ACCESS_LEVEL_ONSITE = "On-site Access".freeze
4
+ ACCESS_LEVEL_REQUEST = "On-site Access By Request".freeze
5
+ ACCESS_LEVEL_EMBARGO = "Embargoed".freeze
6
+ ACCESS_LEVEL_CLOSED = "Closed".freeze
7
+ ACCESS_LEVEL_AFFILIATION = "Specified Group/UNI Access".freeze
8
+ ACCESS_LEVEL_CLASSROOM = "Columbia Classroom Access".freeze
9
+ end
@@ -0,0 +1,76 @@
1
+ module Cul::Hydra::Solrizer
2
+ module AccessControlMetadataFields
3
+ extend ActiveSupport::Concern
4
+ include Cul::Hydra::AccessLevels # useful constants
5
+
6
+ XACML_NS = {'xacml'=>'urn:oasis:names:tc:xacml:3.0:core:schema:wd-17'}
7
+
8
+ FUNCTION_EMBARGO = "urn:oasis:names:tc:xacml:1.0:function:date-greater-than-or-equal".freeze
9
+ FUNCTION_ONE_STRING_MATCH = "urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of".freeze
10
+ FUNCTION_ONE_URI_MATCH = "urn:oasis:names:tc:xacml:1.0:function:anyURI-at-least-one-member-of".freeze
11
+
12
+ TYPE_DATE = "http://www.w3.org/2001/XMLSchema#date".freeze
13
+ TYPE_STRING = "http://www.w3.org/2001/XMLSchema#string".freeze
14
+ TYPE_URI = "http://www.w3.org/2001/XMLSchema#anyURI".freeze
15
+
16
+ ATTRIBUTE_AFFILIATION = "http://www.ja-sig.org/products/cas/affiliation".freeze
17
+
18
+ def to_solr(solr_doc={})
19
+ solr_doc = (defined? super) ? super : solr_doc
20
+
21
+ return solr_doc if policy.nil? # Return because there is nothing to process
22
+ solr_doc['access_control_levels_ssim'] = access_levels
23
+ solr_doc['access_control_permissions_bsi'] = permissions_indicated?
24
+ solr_doc['access_control_embargo_dtsi'] = permit_after_date
25
+ solr_doc['access_control_affiliations_ssim'] = permit_affiliations
26
+ solr_doc['access_control_locations_ssim'] = permit_locations
27
+ solr_doc
28
+ end
29
+
30
+ def policy
31
+ ng_xml.xpath('/xacml:Policy', XACML_NS).first
32
+ end
33
+
34
+ def access_levels
35
+ policy&.xpath('./xacml:Rule/xacml:Description', XACML_NS).map(&:text)
36
+ end
37
+
38
+ def permissions_indicated?
39
+ permissions&.length > 0
40
+ end
41
+
42
+ def permissions
43
+ policy&.xpath('./xacml:Rule[@Effect=\'Permit\']/xacml:Condition', XACML_NS)
44
+ end
45
+
46
+ def permit_affiliations
47
+ permissions&.map do |condition|
48
+ if condition.xpath("../xacml:Description", XACML_NS).text.eql?(ACCESS_LEVEL_AFFILIATION)
49
+ if condition['FunctionId'].eql?(FUNCTION_ONE_STRING_MATCH)
50
+ condition.xpath(".//xacml:AttributeValue[@DataType='#{TYPE_STRING}']", XACML_NS).text
51
+ end
52
+ end
53
+ end.compact
54
+ end
55
+
56
+ def permit_locations
57
+ permissions&.map do |condition|
58
+ if condition.xpath("../xacml:Description", XACML_NS).text.eql?(ACCESS_LEVEL_ONSITE)
59
+ if condition['FunctionId'].eql?(FUNCTION_ONE_URI_MATCH)
60
+ condition.xpath(".//xacml:AttributeValue[@DataType='#{TYPE_URI}']", XACML_NS).text
61
+ end
62
+ end
63
+ end.compact
64
+ end
65
+
66
+ def permit_after_date
67
+ permissions&.map do |condition|
68
+ if condition.xpath("../xacml:Description", XACML_NS).text.eql?(ACCESS_LEVEL_EMBARGO)
69
+ if condition['FunctionId'].eql?(FUNCTION_EMBARGO)
70
+ condition.xpath("./xacml:AttributeValue[@DataType='#{TYPE_DATE}']", XACML_NS).text
71
+ end
72
+ end
73
+ end.compact.first
74
+ end
75
+ end
76
+ end
@@ -525,6 +525,7 @@ module Cul::Hydra::Solrizer
525
525
 
526
526
  repo_marc_code = repository_code
527
527
  unless repo_marc_code.nil?
528
+ solr_doc["lib_repo_code_ssim"] = [repo_marc_code]
528
529
  solr_doc["lib_repo_short_ssim"] = [translate_repo_marc_code(repo_marc_code, 'short')]
529
530
  solr_doc["lib_repo_long_sim"] = [translate_repo_marc_code(repo_marc_code, 'long')]
530
531
  solr_doc["lib_repo_full_ssim"] = [translate_repo_marc_code(repo_marc_code, 'full')]
@@ -5,6 +5,7 @@ module Cul
5
5
  autoload :TerminologyBasedSolrizer, "cul_hydra/solrizer/terminology_based_solrizer"
6
6
  autoload :ValueMapper, "cul_hydra/solrizer/value_mapper"
7
7
  autoload :ModsFieldable, "cul_hydra/solrizer/mods_fieldable"
8
+ autoload :AccessControlMetadataFields, "cul_hydra/solrizer/access_control_metadata_fields"
8
9
  end
9
10
  end
10
11
  end
@@ -1,6 +1,6 @@
1
1
  module Cul
2
2
  module Hydra
3
- VERSION = '1.6.4'
3
+ VERSION = '1.7.0'
4
4
  def self.version
5
5
  VERSION
6
6
  end
data/lib/cul_hydra.rb CHANGED
@@ -8,6 +8,7 @@ module Cul
8
8
  autoload :Fedora, 'cul_hydra/fedora'
9
9
  autoload :Om, 'cul_hydra/om'
10
10
  autoload :Solrizer, 'cul_hydra/solrizer'
11
+ autoload :AccessLevels, 'cul_hydra/access_levels'
11
12
  end
12
13
  end
13
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cul_hydra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.4
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Armintor
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-29 00:00:00.000000000 Z
12
+ date: 2019-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bootstrap-sass
@@ -385,6 +385,7 @@ files:
385
385
  - app/models/concerns/sc/canvas.rb
386
386
  - app/models/concerns/sc/sequence.rb
387
387
  - app/models/content_aggregator.rb
388
+ - app/models/cul/hydra/datastreams/access_control_metadata.rb
388
389
  - app/models/cul/hydra/datastreams/dc_metadata.rb
389
390
  - app/models/cul/hydra/datastreams/mods_document.rb
390
391
  - app/models/cul/hydra/datastreams/struct_metadata.rb
@@ -399,14 +400,11 @@ files:
399
400
  - app/models/static_audio_aggregator.rb
400
401
  - app/models/static_image_aggregator.rb
401
402
  - bin/rails
402
- - config/fedora.yml
403
403
  - config/jetty.yml
404
404
  - config/locales/ldpd_hydra.en.yml
405
405
  - config/predicate_mappings.yml
406
- - config/solr.yml
407
406
  - config/solr_mappings.yml
408
407
  - config/solr_value_maps.yml
409
- - config/subs.yml
410
408
  - fixtures/cmodels/ldpd_ADLMetadata.xml
411
409
  - fixtures/cmodels/ldpd_AESMetadata.xml
412
410
  - fixtures/cmodels/ldpd_BagAggregator.xml
@@ -452,6 +450,9 @@ files:
452
450
  - fixtures/cmodels/pcdm_Collection.xml
453
451
  - fixtures/spec/BLOB/dlc.md
454
452
  - fixtures/spec/BLOB/test001.jpg
453
+ - fixtures/spec/CUL_ACCESS/access-closed.xml
454
+ - fixtures/spec/CUL_ACCESS/access-conditions.xml
455
+ - fixtures/spec/CUL_ACCESS/access-open.xml
455
456
  - fixtures/spec/CUL_DC/dc.xml
456
457
  - fixtures/spec/CUL_MODS/mods-001.xml
457
458
  - fixtures/spec/CUL_MODS/mods-all.xml
@@ -508,6 +509,7 @@ files:
508
509
  - fixtures/spec/STRUCTMAP/structmap-unordered-seq.xml
509
510
  - lib/cul_hydra.rb
510
511
  - lib/cul_hydra/access_controls_enforcement.rb
512
+ - lib/cul_hydra/access_levels.rb
511
513
  - lib/cul_hydra/controllers.rb
512
514
  - lib/cul_hydra/controllers/aggregates.rb
513
515
  - lib/cul_hydra/controllers/aggregator_controller_helper.rb
@@ -538,6 +540,7 @@ files:
538
540
  - lib/cul_hydra/om/standard_mods.rb
539
541
  - lib/cul_hydra/risearch_members.rb
540
542
  - lib/cul_hydra/solrizer.rb
543
+ - lib/cul_hydra/solrizer/access_control_metadata_fields.rb
541
544
  - lib/cul_hydra/solrizer/extractor.rb
542
545
  - lib/cul_hydra/solrizer/mods_fieldable.rb
543
546
  - lib/cul_hydra/solrizer/terminology_based_solrizer.rb
data/config/fedora.yml DELETED
@@ -1,26 +0,0 @@
1
- development:
2
- user: fedoraAdmin
3
- password: f+BULUS*^
4
- url: http://repository.cul.columbia.edu:8080/fedora
5
- datastreams_root: /ifs/cul/repo/archive/repo-datastreams
6
- time_zone: "America/New_York"
7
- test: &TEST
8
- user: fedoraAdmin
9
- password: fedoraAdmin
10
- url: <%= "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8983}/fedora-test" %>
11
- datastreams_root: /ifs/cul/repo/archive/repo-datastreams
12
- time_zone: "America/New_York"
13
- production:
14
- user: fedoraAdmin
15
- password: f+BULUS*^
16
- url: http://repository.cul.columbia.edu:8080/fedora
17
- datastreams_root: /ifs/cul/repo/archive/repo-datastreams
18
- time_zone: "America/New_York"
19
- dcv_test:
20
- user: fedoraAdmin
21
- password: f+BULUS*^
22
- url: http://repository.cul.columbia.edu:8080/fedora
23
- datastreams_root: /ifs/cul/repo/archive/repo-datastreams
24
- time_zone: "America/New_York"
25
- cucumber:
26
- <<: *TEST
data/config/solr.yml DELETED
@@ -1,17 +0,0 @@
1
- # This is a sample config file that does not have multiple solr instances. You will also need to be sure to
2
- # edit the fedora.yml file to match the solr URL for active-fedora.
3
- # url: http://katana.cul.columbia.edu:8080/solr-4.7/dcv_private_dev
4
- test: &TEST
5
- url: <%= "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8983}/solr/test" %>
6
- dcv_dev: &DEV
7
- url: http://spatha.cul.columbia.edu:8080/solr-4.7/dcv_private_test
8
- dcv_core: 'dcv_private_dev'
9
- dcv_test: &IFP
10
- url: http://spatha.cul.columbia.edu:8080/solr-4.7/dcv_private_test
11
- dcv_core: 'dcv_private_test'
12
- cucumber:
13
- <<: *TEST
14
- production: &PROD
15
- url: http://spatha.cul.columbia.edu:8080/solr-4.7/dcv_prod
16
- development:
17
- <<: *PROD
data/config/subs.yml DELETED
@@ -1,10 +0,0 @@
1
- old:
2
- fedora_server: http://sayers.cul.columbia.edu:8080
3
- php_server: http://bach.cul.columbia.edu/dev
4
- djatoka_server: http://iris.cul.columbia.edu:8080
5
- development:
6
- fedora_server: http://repository.cul.columbia.edu:8080
7
- php_server: http://fedora-svc.cul.columbia.edu/dev
8
- test:
9
- fedora_server: http://repository.cul.columbia.edu:8080
10
- php_server: http://fedora-svc.cul.columbia.edu/dev