active-fedora 15.0.1 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +21 -6
- data/.fcrepo_wrapper +10 -0
- data/.rubocop.yml +3 -0
- data/.solr_wrapper +1 -1
- data/Gemfile +3 -0
- data/Upgrading.md +46 -0
- data/active-fedora.gemspec +3 -1
- data/config/fcrepo_allow.txt +3 -0
- data/lib/active_fedora/attached_files.rb +2 -0
- data/lib/active_fedora/change_set.rb +3 -1
- data/lib/active_fedora/clean_connection.rb +1 -0
- data/lib/active_fedora/containers/direct_container.rb +0 -1
- data/lib/active_fedora/containers/indirect_container.rb +0 -2
- data/lib/active_fedora/file/external.rb +39 -0
- data/lib/active_fedora/file/streaming.rb +30 -27
- data/lib/active_fedora/file.rb +3 -0
- data/lib/active_fedora/file_configurator.rb +1 -1
- data/lib/active_fedora/indexing/descendant_fetcher.rb +7 -1
- data/lib/active_fedora/ldp_resource.rb +20 -5
- data/lib/active_fedora/ldp_resource_service.rb +13 -2
- data/lib/active_fedora/persistence.rb +3 -2
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/versionable.rb +6 -30
- data/lib/active_fedora/versions_graph.rb +9 -19
- data/lib/active_fedora/with_metadata/metadata_node.rb +6 -1
- data/lib/tasks/active_fedora_dev.rake +4 -4
- metadata +26 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f5d0386b3a13967268eb18a96ea04dd3df72727560894ce0b57384b30c5dd2ef
|
|
4
|
+
data.tar.gz: a279cfdf64d1c3a792cd5660b58f84468ab97162bf3fdc0d3998d61873220cd9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe5eaad145521121a5fa40ae7b17e76833b3dc42fbccb478be53862af54d5cbd9fa6f183dcf1af8662a0244ce005384c8843e4c05401f263b668bc0d0d6eee75
|
|
7
|
+
data.tar.gz: d67621a40ef2dd9225a94393645a08d878af77f7802d2a1a45fc508c8216dc9c14b74722a0e8418e2d647f47f569c61e76f918f99b24382467b55cc365f52d81
|
data/.circleci/config.yml
CHANGED
|
@@ -4,6 +4,9 @@ orbs:
|
|
|
4
4
|
jobs:
|
|
5
5
|
bundle_lint_test:
|
|
6
6
|
parameters:
|
|
7
|
+
ruby_type:
|
|
8
|
+
type: string
|
|
9
|
+
default: 'ruby'
|
|
7
10
|
ruby_version:
|
|
8
11
|
type: string
|
|
9
12
|
bundler_version:
|
|
@@ -14,23 +17,22 @@ jobs:
|
|
|
14
17
|
solr_config_path:
|
|
15
18
|
type: string
|
|
16
19
|
default: lib/generators/active_fedora/config/solr/templates/solr/conf
|
|
17
|
-
ruby_type:
|
|
18
|
-
type: string
|
|
19
|
-
default: 'ruby'
|
|
20
20
|
solr_port:
|
|
21
21
|
type: string
|
|
22
22
|
default: '8985'
|
|
23
23
|
fcrepo_version:
|
|
24
24
|
type: string
|
|
25
|
-
default: "
|
|
25
|
+
default: "5.1.0"
|
|
26
26
|
solr_version:
|
|
27
27
|
type: string
|
|
28
28
|
default: "9"
|
|
29
29
|
docker:
|
|
30
30
|
- image: cimg/<< parameters.ruby_type >>:<< parameters.ruby_version >>-browsers
|
|
31
|
-
- image:
|
|
31
|
+
- image: fcrepo/fcrepo:6.5-tomcat9
|
|
32
32
|
environment:
|
|
33
|
-
|
|
33
|
+
JAVA_OPTS: -Dfcrepo.autoversioning.enabled=false -Dfcrepo.external.content.allowed=/fcrepo_allow.txt
|
|
34
|
+
command: |
|
|
35
|
+
/bin/bash -c "echo 'http://fedoraAdmin:fedoraAdmin@localhost:8080/' > /fcrepo_allow.txt && catalina.sh run"
|
|
34
36
|
- image: zookeeper:3.9
|
|
35
37
|
environment:
|
|
36
38
|
ZOO_ADMINSERVER_ENABLED: false
|
|
@@ -38,6 +40,7 @@ jobs:
|
|
|
38
40
|
environment:
|
|
39
41
|
VERBOSE: yes
|
|
40
42
|
SECURITY_JSON: '{"authentication":{"blockUnknown": false, "class":"solr.BasicAuthPlugin", "credentials":{"solr":"IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="}, "realm":"My Solr users", "forwardCredentials": false}, "authorization":{ "class":"solr.RuleBasedAuthorizationPlugin", "permissions":[{"name":"security-edit", "role":"admin"}], "user-role":{"solr":"admin"}}}'
|
|
43
|
+
SOLR_MODULES: "analysis-extras,extraction"
|
|
41
44
|
command: sh -c "server/scripts/cloud-scripts/zkcli.sh -zkhost localhost:2181 -cmd put /security.json \"${SECURITY_JSON}\" && solr-fg -cloud -noprompt -p << parameters.solr_port >> -z localhost:2181"
|
|
42
45
|
environment:
|
|
43
46
|
BUNDLE_PATH: vendor/bundle
|
|
@@ -48,6 +51,8 @@ jobs:
|
|
|
48
51
|
FCREPO_TEST_PORT: 8080
|
|
49
52
|
SPEC_OPTS: --profile 10 --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress
|
|
50
53
|
RAILS_VERSION: << parameters.rails_version >>
|
|
54
|
+
FCREPO_PORT: 8080
|
|
55
|
+
FCREPO_REST_PATH: fcrepo/rest
|
|
51
56
|
steps:
|
|
52
57
|
- samvera/cached_checkout
|
|
53
58
|
- checkout
|
|
@@ -81,6 +86,11 @@ jobs:
|
|
|
81
86
|
workflows:
|
|
82
87
|
ci:
|
|
83
88
|
jobs:
|
|
89
|
+
# Ruby 3.4 releases
|
|
90
|
+
- bundle_lint_test:
|
|
91
|
+
name: ruby3-4_rails8-0
|
|
92
|
+
ruby_version: 3.4.4
|
|
93
|
+
rails_version: 8.0.2
|
|
84
94
|
# Ruby 3.3 releases
|
|
85
95
|
- bundle_lint_test:
|
|
86
96
|
name: ruby3-3_rails7-2
|
|
@@ -134,6 +144,11 @@ workflows:
|
|
|
134
144
|
only:
|
|
135
145
|
- main
|
|
136
146
|
jobs:
|
|
147
|
+
# Ruby 3.4 releases
|
|
148
|
+
- bundle_lint_test:
|
|
149
|
+
name: ruby3-4_rails8-0
|
|
150
|
+
ruby_version: 3.4.4
|
|
151
|
+
rails_version: 8.0.2
|
|
137
152
|
# Ruby 3.3 releases
|
|
138
153
|
- bundle_lint_test:
|
|
139
154
|
name: ruby3-3_rails7-2
|
data/.fcrepo_wrapper
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Place any default configuration for solr_wrapper here
|
|
2
|
+
port: 8986
|
|
3
|
+
version: 6.4.0
|
|
4
|
+
enable_jms: false
|
|
5
|
+
java_options: ['-Dfcrepo.log.http.api=DEBUG','-Dfcrepo.log.kernel=ERROR','-Xmx512m',
|
|
6
|
+
'-Dfcrepo.external.content.allowed=config/fcrepo_allow.txt', '-Dfcrepo.autoversioning.enabled=false']
|
|
7
|
+
#managed: true
|
|
8
|
+
#fcrepo_home_dir: tmp/fcrepo-development-data
|
|
9
|
+
url: https://github.com/fcrepo/fcrepo/releases/download/fcrepo-6.4.0/fcrepo-webapp-6.4.0-jetty-console.jar
|
|
10
|
+
ignore_md5sum: true
|
data/.rubocop.yml
CHANGED
data/.solr_wrapper
CHANGED
data/Gemfile
CHANGED
data/Upgrading.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Upgrading to ActiveFedora 16+
|
|
2
|
+
|
|
3
|
+
ActiveFedora 16+ is built for use with Fedora 6+.
|
|
4
|
+
|
|
5
|
+
## Changes from ActiveFedora 15
|
|
6
|
+
|
|
7
|
+
- Direct/Indirect container classes now specified in headers required by Fedora 5+
|
|
8
|
+
- External files supported via a Link header (see ActiveFedora::File::External)
|
|
9
|
+
- Versioning updated based upon Fedora's use of Memento
|
|
10
|
+
- Ability to restore previous versions removed
|
|
11
|
+
|
|
12
|
+
## Upgrade considerations
|
|
13
|
+
|
|
14
|
+
- You may want to turn off autoversioning in Fedora (`fcrepo.autoversioning.enabled=false`) if you edit objects frequently.
|
|
15
|
+
- Be sure to allocate sufficient memory (2-4 GB) to the import-export tools.
|
|
16
|
+
- The Fedora 4 export and Fedora 5/6 data directories have lots of files so file system operations can take a LONG time.
|
|
17
|
+
|
|
18
|
+
## Upgrading from Fedora 4 (without versions)
|
|
19
|
+
|
|
20
|
+
1. Install Java 21+
|
|
21
|
+
2. Download [fcrepo-import-export](https://github.com/fcrepo-exts/fcrepo-import-export/) 1.2.0 or higher.
|
|
22
|
+
3. Export from Fedora 4 (update --resource url to match the root of your fedora instance):
|
|
23
|
+
```
|
|
24
|
+
java -jar fcrepo-import-export-1.2.0.jar -b --dir fcrepo4.7.5_export --user fedoraAdmin:fedoraAdmin --mode export --resource http://fedora:8080/fedora/rest --binaries --membership --auditLog > importexport_`date +%Y%m%dT%H%M%S`.log 2>&1
|
|
25
|
+
```
|
|
26
|
+
4. Check that all objects were exported (uses ripgrep):
|
|
27
|
+
```
|
|
28
|
+
rg '^<(http://fedora:8080/fedora/[^#:]*)>$' -g '*.ttl' fcrepo4.7.5_export/ --no-heading -m 1 -INor '$1' | sort | uniq > subject_ids
|
|
29
|
+
rg '<(http://fedora:8080/fedora/[^#:]*)>.*[.;]$' -g '*.ttl' fcrepo4.7.5_export/ --no-heading -INor '$1' | sort | uniq > object_ids
|
|
30
|
+
comm -13 subject_ids object_ids > missing_ids
|
|
31
|
+
```
|
|
32
|
+
5. (If necessary) Restart export from missing_ids file (can also be done with remaining file if export does not finish successfully):
|
|
33
|
+
```
|
|
34
|
+
java -jar fcrepo-import-export-1.2.0.jar --dir fcrepo4.7.5_export --user fedoraAdmin:fedoraAdmin --mode export --repositoryRoot http://fedora:8080/fedora/rest --resourcesFile missing_ids --binaries --membership --auditLog > importexport_`date +%Y%m%dT%H%M%S`.log 2>&1
|
|
35
|
+
```
|
|
36
|
+
6. Download [fcrepo-upgrade-utils](https://github.com/fcrepo-exts/fcrepo-upgrade-utils/) 6.4.0 or higher. (6.4.0 has not been released yet so use the [Avalon patched version](https://github.com/avalonmediasystem/fcrepo-upgrade-utils/releases/download/6.3.0-AVALON/fcrepo-upgrade-utils-6.3.0-AVALON.jar) for now.)
|
|
37
|
+
7. Migrate Fedora 4 export to Fedora 5:
|
|
38
|
+
```
|
|
39
|
+
java -jar fcrepo-upgrade-utils-6.3.0-AVALON.jar --input-dir fcrepo4.7.5_export --output-dir fcrepo5_export --source-version 4.7.5 --target-version 5+ > upgrade_5_`date +%Y%m%dT%H%M%S`.log 2>&1
|
|
40
|
+
```
|
|
41
|
+
8. Migrate Fedora 5 data directory to Fedora 6 (be sure that --base-uri matches --resource from the Fedora 4 export):
|
|
42
|
+
```
|
|
43
|
+
java --add-opens java.base/java.util.concurrent=ALL-UNNAMED -jar fcrepo-upgrade-utils-6.3.0-AVALON.jar --input-dir fcrepo5_export --output-dir fcrepo6_export --source-version 5+ --target-version 6+ --base-uri http://fedora:8080/fedora/rest > upgrade_6_`date +%Y%m%dT%H%M%S`.log 2>&1
|
|
44
|
+
```
|
|
45
|
+
9. Copy Fedora 6 data directory to `fcrepo.home` and startup Fedora
|
|
46
|
+
This will kick off Fedora's indexing which can take hours depending on the size of your repository. During indexing Fedora will not respond to requests.
|
data/active-fedora.gemspec
CHANGED
|
@@ -20,8 +20,9 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
s.add_dependency "activesupport", '>= 6.1'
|
|
21
21
|
s.add_dependency "active-triples", '>= 0.11.0', '< 2.0.0'
|
|
22
22
|
s.add_dependency "deprecation"
|
|
23
|
-
s.add_dependency 'faraday', '>=
|
|
23
|
+
s.add_dependency 'faraday', '>= 2.0'
|
|
24
24
|
s.add_dependency 'faraday-encoding', '>= 0.0.5'
|
|
25
|
+
s.add_dependency 'faraday-follow_redirects'
|
|
25
26
|
s.add_dependency "ldp", '>= 0.7.0', '< 2'
|
|
26
27
|
s.add_dependency "mutex_m"
|
|
27
28
|
s.add_dependency 'rsolr', '>= 1.1.2', '< 3'
|
|
@@ -47,4 +48,5 @@ Gem::Specification.new do |s|
|
|
|
47
48
|
"README.md"
|
|
48
49
|
]
|
|
49
50
|
s.require_paths = ["lib"]
|
|
51
|
+
s.post_install_message = "ActiveFedora 16+ is built for Fedora 6+. See Upgrading.md for important changes from ActiveFedora 15 and hints for using the Fedora upgrade tools to migrate from Fedora 4."
|
|
50
52
|
end
|
|
@@ -32,7 +32,9 @@ module ActiveFedora
|
|
|
32
32
|
elsif key == 'type'.freeze
|
|
33
33
|
# working around https://github.com/ActiveTriples/ActiveTriples/issues/122
|
|
34
34
|
predicate = ::RDF.type
|
|
35
|
-
result[predicate] = graph.query({ subject: object.rdf_subject, predicate: predicate })
|
|
35
|
+
result[predicate] = graph.query({ subject: object.rdf_subject, predicate: predicate }).select do |statement|
|
|
36
|
+
!statement.object.to_s.start_with?("http://fedora.info/definitions/v4/repository#", "http://www.w3.org/ns/ldp#")
|
|
37
|
+
end
|
|
36
38
|
elsif object.local_attributes.include?(key)
|
|
37
39
|
raise "Unable to find a graph predicate corresponding to the attribute: \"#{key}\""
|
|
38
40
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module ActiveFedora::File::External
|
|
2
|
+
HANDLING_TYPES = ['redirect', 'proxy', 'copy'].freeze
|
|
3
|
+
|
|
4
|
+
def external_uri
|
|
5
|
+
@external_uri ||= fetch_external_uri
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def external_uri=(uri)
|
|
9
|
+
@external_uri = uri
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def external_handling=(handling)
|
|
13
|
+
@external_handling = handling
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def external_handling
|
|
17
|
+
@external_handling ||= fetch_external_handling
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def fetch_external_uri
|
|
23
|
+
return if new_record?
|
|
24
|
+
ldp_source.head.response.headers['Content-Location']
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def fetch_external_handling
|
|
28
|
+
return if new_record?
|
|
29
|
+
response = ldp_source.head.response
|
|
30
|
+
return unless response.headers.key?('Content-Location')
|
|
31
|
+
|
|
32
|
+
case response.status
|
|
33
|
+
when Net::HTTPRedirection
|
|
34
|
+
'redirect'
|
|
35
|
+
when Net::HTTPSuccess
|
|
36
|
+
'proxy'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
require 'faraday/follow_redirects'
|
|
2
|
+
|
|
1
3
|
module ActiveFedora::File::Streaming
|
|
2
4
|
# @param range [String] the Range HTTP header
|
|
3
5
|
# @return [Stream] an object that responds to each
|
|
4
6
|
def stream(range = nil)
|
|
5
7
|
uri = URI.parse(self.uri)
|
|
6
|
-
FileBody.new(uri, headers(range,
|
|
8
|
+
FileBody.new(uri, headers(range, nil))
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
# @param range [String] from #stream
|
|
10
|
-
# @param key [String] from #authorization_key
|
|
11
12
|
# @return [Hash]
|
|
12
|
-
def headers(range,
|
|
13
|
+
def headers(range, _key, result = {})
|
|
13
14
|
result["Range"] = range if range
|
|
14
|
-
result["Authorization"] = key if key
|
|
15
15
|
result
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -22,32 +22,35 @@ module ActiveFedora::File::Streaming
|
|
|
22
22
|
@headers = headers
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def each(no_of_requests_limit = 3
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
http.request request do |response|
|
|
30
|
-
case response
|
|
31
|
-
when Net::HTTPSuccess
|
|
32
|
-
response.read_body do |chunk|
|
|
33
|
-
yield chunk
|
|
34
|
-
end
|
|
35
|
-
when Net::HTTPRedirection
|
|
36
|
-
no_of_requests_limit -= 1
|
|
37
|
-
@uri = URI(response["location"])
|
|
38
|
-
each(no_of_requests_limit, &block)
|
|
39
|
-
else
|
|
40
|
-
raise "Couldn't get data from Fedora (#{uri}). Response: #{response.code}"
|
|
41
|
-
end
|
|
25
|
+
def each(no_of_requests_limit = 3)
|
|
26
|
+
redirecting_connection(no_of_requests_limit).get(uri.to_s, nil, headers) do |req|
|
|
27
|
+
req.options.on_data = proc do |chunk, overall_received_bytes, _env|
|
|
28
|
+
yield chunk unless overall_received_bytes.zero? # Don't yield when redirecting
|
|
42
29
|
end
|
|
43
30
|
end
|
|
31
|
+
rescue Faraday::FollowRedirects::RedirectLimitReached
|
|
32
|
+
raise ArgumentError, 'HTTP redirect too deep'
|
|
33
|
+
rescue Faraday::Error => ex
|
|
34
|
+
raise "Couldn't get data from Fedora (#{uri}). Response: #{ex.response_status}"
|
|
44
35
|
end
|
|
45
|
-
end
|
|
46
36
|
|
|
47
|
-
|
|
37
|
+
private
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
# Create a new faraday connection with follow_redirects enabled and configured using passed value
|
|
40
|
+
def redirecting_connection(redirection_limit)
|
|
41
|
+
options = {}
|
|
42
|
+
options[:ssl] = ActiveFedora.fedora.ssl_options if ActiveFedora.fedora.ssl_options
|
|
43
|
+
options[:request] = ActiveFedora.fedora.request_options if ActiveFedora.fedora.request_options
|
|
44
|
+
Faraday.new(ActiveFedora.fedora.host, options) do |conn|
|
|
45
|
+
conn.response :encoding # use Faraday::Encoding middleware
|
|
46
|
+
conn.adapter Faraday.default_adapter # net/http
|
|
47
|
+
if Gem::Version.new(Faraday::VERSION) < Gem::Version.new('2')
|
|
48
|
+
conn.request :basic_auth, ActiveFedora.fedora.user, ActiveFedora.fedora.password
|
|
49
|
+
else
|
|
50
|
+
conn.request :authorization, :basic, ActiveFedora.fedora.user, ActiveFedora.fedora.password
|
|
51
|
+
conn.response :follow_redirects, limit: redirection_limit - 1 # Need to reduce by one to retain same behavior as before
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
53
56
|
end
|
data/lib/active_fedora/file.rb
CHANGED
|
@@ -8,10 +8,12 @@ module ActiveFedora
|
|
|
8
8
|
|
|
9
9
|
autoload :Streaming
|
|
10
10
|
autoload :Attributes
|
|
11
|
+
autoload :External
|
|
11
12
|
|
|
12
13
|
include Common
|
|
13
14
|
include ActiveFedora::File::Attributes
|
|
14
15
|
include ActiveFedora::File::Streaming
|
|
16
|
+
include ActiveFedora::File::External
|
|
15
17
|
include ActiveFedora::FilePersistence
|
|
16
18
|
include ActiveFedora::Versionable
|
|
17
19
|
include ActiveModel::Dirty
|
|
@@ -175,6 +177,7 @@ module ActiveFedora
|
|
|
175
177
|
def ldp_headers
|
|
176
178
|
headers = { 'Content-Type'.freeze => mime_type, 'Content-Length'.freeze => content.size.to_s }
|
|
177
179
|
headers['Content-Disposition'.freeze] = "attachment; filename=\"#{URI::DEFAULT_PARSER.escape(@original_name)}\"" if @original_name
|
|
180
|
+
headers["Link"] = "<#{@external_uri}>; rel=\"http://fedora.info/definitions/fcrepo#ExternalContent\"; handling=\"#{@external_handling}\"; type=\"#{mime_type}\"" if @external_uri
|
|
178
181
|
headers
|
|
179
182
|
end
|
|
180
183
|
|
|
@@ -183,7 +183,7 @@ module ActiveFedora
|
|
|
183
183
|
end
|
|
184
184
|
|
|
185
185
|
if defined?(Rails.root)
|
|
186
|
-
config_path =
|
|
186
|
+
config_path = [Rails.root, "config/#{config_type}.yml"].join('/')
|
|
187
187
|
return config_path if ::File.file? config_path
|
|
188
188
|
end
|
|
189
189
|
|
|
@@ -55,7 +55,7 @@ module ActiveFedora
|
|
|
55
55
|
def descendant_and_self_uris_partitioned_by_model
|
|
56
56
|
# GET could be slow if it's a big resource, we're using HEAD to avoid this problem,
|
|
57
57
|
# but this causes more requests to Fedora.
|
|
58
|
-
return partitioned_uris unless
|
|
58
|
+
return partitioned_uris unless rdf_source?
|
|
59
59
|
|
|
60
60
|
add_self_to_partitioned_uris unless @exclude_self
|
|
61
61
|
|
|
@@ -76,6 +76,12 @@ module ActiveFedora
|
|
|
76
76
|
|
|
77
77
|
protected
|
|
78
78
|
|
|
79
|
+
# Fcrepo 6.4 returns a 406 for file objects when returning ntriples
|
|
80
|
+
# so use the standard connection just for the head request
|
|
81
|
+
def rdf_source?
|
|
82
|
+
Ldp::Resource.new(ActiveFedora.fedora.connection, uri).head.rdf_source?
|
|
83
|
+
end
|
|
84
|
+
|
|
79
85
|
def rdf_resource
|
|
80
86
|
@rdf_resource ||= Ldp::Resource::RdfSource.new(ActiveFedora.fedora.build_ntriples_connection, uri)
|
|
81
87
|
end
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
module ActiveFedora
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
module LdpResourceAddons
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
module ClassMethods
|
|
5
|
+
def graph_class
|
|
6
|
+
ActiveTriples::Resource
|
|
7
|
+
end
|
|
5
8
|
end
|
|
6
9
|
|
|
7
|
-
def
|
|
8
|
-
|
|
10
|
+
def build_empty_graph
|
|
11
|
+
graph_class.new(subject_uri)
|
|
9
12
|
end
|
|
10
13
|
|
|
11
14
|
def graph_class
|
|
@@ -27,4 +30,16 @@ module ActiveFedora
|
|
|
27
30
|
graph_class.new(subject_uri, data: resp.graph.data)
|
|
28
31
|
end
|
|
29
32
|
end
|
|
33
|
+
|
|
34
|
+
class LdpResource < Ldp::Resource::RdfSource
|
|
35
|
+
include LdpResourceAddons
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
class IndirectContainerResource < Ldp::Container::Indirect
|
|
39
|
+
include LdpResourceAddons
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class DirectContainerResource < Ldp::Container::Direct
|
|
43
|
+
include LdpResourceAddons
|
|
44
|
+
end
|
|
30
45
|
end
|
|
@@ -7,11 +7,22 @@ module ActiveFedora
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def build(klass, id)
|
|
10
|
+
resource_klass = resource_klass(klass)
|
|
10
11
|
if id
|
|
11
|
-
|
|
12
|
+
resource_klass.new(connection, to_uri(klass, id))
|
|
12
13
|
else
|
|
13
14
|
parent_uri = ActiveFedora.fedora.host + ActiveFedora.fedora.base_path
|
|
14
|
-
|
|
15
|
+
resource_klass.new(connection, nil, nil, parent_uri)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def resource_klass(klass)
|
|
20
|
+
if klass <= ActiveFedora::IndirectContainer
|
|
21
|
+
IndirectContainerResource
|
|
22
|
+
elsif klass <= ActiveFedora::DirectContainer
|
|
23
|
+
DirectContainerResource
|
|
24
|
+
else
|
|
25
|
+
LdpResource
|
|
15
26
|
end
|
|
16
27
|
end
|
|
17
28
|
|
|
@@ -228,10 +228,11 @@ module ActiveFedora
|
|
|
228
228
|
# and assign_id can mint an id for the object, then assign it to the resource.
|
|
229
229
|
# Otherwise the resource will have the id assigned by the LDP server
|
|
230
230
|
def assign_rdf_subject
|
|
231
|
+
ldp_resource_klass = ActiveFedora.fedora.ldp_resource_service.resource_klass(self.class)
|
|
231
232
|
@ldp_source = if !id && new_id = assign_id
|
|
232
|
-
|
|
233
|
+
ldp_resource_klass.new(ActiveFedora.fedora.connection, self.class.id_to_uri(new_id), @resource)
|
|
233
234
|
else
|
|
234
|
-
|
|
235
|
+
ldp_resource_klass.new(ActiveFedora.fedora.connection, @ldp_source.subject, @resource, base_path_for_resource)
|
|
235
236
|
end
|
|
236
237
|
end
|
|
237
238
|
|
|
@@ -6,21 +6,11 @@ module ActiveFedora
|
|
|
6
6
|
class_attribute :versionable
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def model_type
|
|
10
|
-
if respond_to?(:metadata)
|
|
11
|
-
metadata.ldp_source.graph.query({ predicate: ::RDF.type }).objects
|
|
12
|
-
else
|
|
13
|
-
resource.query({ subject: resource.rdf_subject, predicate: ::RDF.type }).objects
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
9
|
# Returns an array of ActiveFedora::VersionsGraph::ResourceVersion objects.
|
|
18
|
-
# Excludes auto-snapshot versions from Fedora.
|
|
19
10
|
def versions(reload = false)
|
|
20
11
|
response = versions_request
|
|
21
12
|
|
|
22
13
|
return ActiveFedora::VersionsGraph.new unless response
|
|
23
|
-
|
|
24
14
|
if reload
|
|
25
15
|
@versions = ActiveFedora::VersionsGraph.new << versions_request.reader
|
|
26
16
|
else
|
|
@@ -29,46 +19,32 @@ module ActiveFedora
|
|
|
29
19
|
end
|
|
30
20
|
|
|
31
21
|
def create_version
|
|
32
|
-
resp = ActiveFedora.fedora.connection.post(versions_uri, nil
|
|
22
|
+
resp = ActiveFedora.fedora.connection.post(versions_uri, nil)
|
|
33
23
|
@versions = nil
|
|
34
24
|
resp.success?
|
|
35
25
|
end
|
|
36
26
|
|
|
37
27
|
# Queries Fedora to figure out if there are versions for the resource.
|
|
38
28
|
def has_versions?
|
|
39
|
-
ActiveFedora.fedora.connection.
|
|
40
|
-
|
|
29
|
+
resp = ActiveFedora.fedora.connection.get(versions_uri)
|
|
30
|
+
graph = ::RDF::Graph.new << resp.reader
|
|
31
|
+
graph.query({ predicate: ::RDF::Vocab::LDP.contains }).present?
|
|
41
32
|
rescue Ldp::NotFound
|
|
42
33
|
false
|
|
43
34
|
end
|
|
44
35
|
|
|
45
|
-
def restore_version(label)
|
|
46
|
-
resp = ActiveFedora.fedora.connection.patch(versions.with_label(label).uri, nil)
|
|
47
|
-
@versions = nil
|
|
48
|
-
reload
|
|
49
|
-
refresh_attributes if respond_to?("refresh_attributes")
|
|
50
|
-
resp.success?
|
|
51
|
-
end
|
|
52
|
-
|
|
53
36
|
private
|
|
54
37
|
|
|
55
38
|
def versions_request
|
|
56
|
-
return false unless has_versions?
|
|
57
39
|
ActiveFedora.fedora.connection.get(versions_uri)
|
|
40
|
+
rescue Ldp::NotFound
|
|
41
|
+
false
|
|
58
42
|
end
|
|
59
43
|
|
|
60
44
|
def versions_uri
|
|
61
45
|
uri + '/fcr:versions'
|
|
62
46
|
end
|
|
63
47
|
|
|
64
|
-
def version_name
|
|
65
|
-
if versions.all.empty?
|
|
66
|
-
"version1"
|
|
67
|
-
else
|
|
68
|
-
"version" + (versions.all.count + 1).to_s
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
48
|
def status_message(response)
|
|
73
49
|
"Unexpected return value #{response.status} when retrieving datastream content at #{uri}\n\t#{response.body}"
|
|
74
50
|
end
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
module ActiveFedora
|
|
2
2
|
class VersionsGraph < ::RDF::Graph
|
|
3
|
-
def all(
|
|
3
|
+
def all(_opts = {})
|
|
4
4
|
versions = fedora_versions
|
|
5
|
-
versions.reject! { |version| version.label =~ /auto/ } unless opts[:include_auto_save]
|
|
6
5
|
versions.sort_by { |version| DateTime.parse(version.created) }
|
|
7
6
|
rescue ArgumentError, NoMethodError
|
|
8
7
|
raise ActiveFedora::VersionLacksCreateDate
|
|
@@ -12,40 +11,31 @@ module ActiveFedora
|
|
|
12
11
|
|
|
13
12
|
delegate :last, to: :all
|
|
14
13
|
|
|
15
|
-
def
|
|
14
|
+
def with_datetime(datetime)
|
|
16
15
|
all.each do |version|
|
|
17
|
-
return version if version.
|
|
16
|
+
return version if version.created == datetime
|
|
18
17
|
end
|
|
19
18
|
end
|
|
20
19
|
|
|
21
|
-
def
|
|
22
|
-
query({ predicate: ::RDF::Vocab::
|
|
20
|
+
def versions
|
|
21
|
+
query({ predicate: ::RDF::Vocab::LDP.contains })
|
|
23
22
|
end
|
|
24
23
|
|
|
25
24
|
private
|
|
26
25
|
|
|
27
26
|
class ResourceVersion
|
|
28
|
-
attr_accessor :uri, :
|
|
27
|
+
attr_accessor :uri, :created
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
def version_from_resource(statement)
|
|
32
31
|
version = ResourceVersion.new
|
|
33
|
-
version.uri = statement.object
|
|
34
|
-
version.
|
|
35
|
-
version.created = created_query(statement)
|
|
32
|
+
version.uri = statement.object
|
|
33
|
+
version.created = statement.object.to_s.split("fcr:versions/")[1]
|
|
36
34
|
version
|
|
37
35
|
end
|
|
38
36
|
|
|
39
|
-
def label_query(statement)
|
|
40
|
-
query({ subject: statement.object }).query({ predicate: ::RDF::Vocab::Fcrepo4.hasVersionLabel }).first.object.to_s
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def created_query(statement)
|
|
44
|
-
query({ subject: statement.object }).query({ predicate: ::RDF::Vocab::Fcrepo4.created }).first.object.to_s
|
|
45
|
-
end
|
|
46
|
-
|
|
47
37
|
def fedora_versions
|
|
48
|
-
|
|
38
|
+
versions.map { |statement| version_from_resource(statement) }
|
|
49
39
|
end
|
|
50
40
|
end
|
|
51
41
|
end
|
|
@@ -14,8 +14,13 @@ module ActiveFedora
|
|
|
14
14
|
def initialize(file)
|
|
15
15
|
@file = file
|
|
16
16
|
super(file.uri, ldp_source.graph)
|
|
17
|
+
|
|
17
18
|
return unless self.class.type && !type.include?(self.class.type)
|
|
18
|
-
|
|
19
|
+
types = type.reject do |statement|
|
|
20
|
+
::RDF::URI.new(statement.object).to_s.start_with?("http://fedora.info/definitions/v4/repository#", "http://www.w3.org/ns/ldp#")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
attribute_will_change!(:type) if types.present?
|
|
19
24
|
# Workaround for https://github.com/ActiveTriples/ActiveTriples/issues/123
|
|
20
25
|
get_values(:type) << self.class.type
|
|
21
26
|
end
|
|
@@ -19,7 +19,7 @@ namespace :active_fedora do
|
|
|
19
19
|
end
|
|
20
20
|
rescue LoadError
|
|
21
21
|
desc "Generate YARD Documentation"
|
|
22
|
-
task doc
|
|
22
|
+
task :doc do
|
|
23
23
|
abort "Please install the YARD gem to generate rdoc."
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -42,7 +42,7 @@ namespace :active_fedora do
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
desc "CI build"
|
|
45
|
-
task ci
|
|
45
|
+
task :ci do
|
|
46
46
|
Rake::Task['active_fedora:rubocop'].invoke unless ENV['NO_RUBOCOP']
|
|
47
47
|
ENV['environment'] = "test"
|
|
48
48
|
with_test_server do
|
|
@@ -51,7 +51,7 @@ namespace :active_fedora do
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
desc "Execute specs with coverage"
|
|
54
|
-
task coverage
|
|
54
|
+
task :coverage do
|
|
55
55
|
# Put spec opts in a file named .rspec in root
|
|
56
56
|
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
|
|
57
57
|
ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
|
|
@@ -59,7 +59,7 @@ namespace :active_fedora do
|
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
desc "Execute specs with coverage"
|
|
62
|
-
task spec
|
|
62
|
+
task :spec do
|
|
63
63
|
with_test_server do
|
|
64
64
|
Rake::Task["active_fedora:rspec"].invoke
|
|
65
65
|
end
|
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active-fedora
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 16.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Zumwalt
|
|
8
8
|
- McClain Looney
|
|
9
9
|
- Justin Coyne
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: activemodel
|
|
@@ -80,14 +79,14 @@ dependencies:
|
|
|
80
79
|
requirements:
|
|
81
80
|
- - ">="
|
|
82
81
|
- !ruby/object:Gem::Version
|
|
83
|
-
version: '
|
|
82
|
+
version: '2.0'
|
|
84
83
|
type: :runtime
|
|
85
84
|
prerelease: false
|
|
86
85
|
version_requirements: !ruby/object:Gem::Requirement
|
|
87
86
|
requirements:
|
|
88
87
|
- - ">="
|
|
89
88
|
- !ruby/object:Gem::Version
|
|
90
|
-
version: '
|
|
89
|
+
version: '2.0'
|
|
91
90
|
- !ruby/object:Gem::Dependency
|
|
92
91
|
name: faraday-encoding
|
|
93
92
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -102,6 +101,20 @@ dependencies:
|
|
|
102
101
|
- - ">="
|
|
103
102
|
- !ruby/object:Gem::Version
|
|
104
103
|
version: 0.0.5
|
|
104
|
+
- !ruby/object:Gem::Dependency
|
|
105
|
+
name: faraday-follow_redirects
|
|
106
|
+
requirement: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
type: :runtime
|
|
112
|
+
prerelease: false
|
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
105
118
|
- !ruby/object:Gem::Dependency
|
|
106
119
|
name: ldp
|
|
107
120
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -349,6 +362,7 @@ extra_rdoc_files:
|
|
|
349
362
|
- README.md
|
|
350
363
|
files:
|
|
351
364
|
- ".circleci/config.yml"
|
|
365
|
+
- ".fcrepo_wrapper"
|
|
352
366
|
- ".github_changelog_generator"
|
|
353
367
|
- ".gitignore"
|
|
354
368
|
- ".gitmodules"
|
|
@@ -367,7 +381,9 @@ files:
|
|
|
367
381
|
- README.md
|
|
368
382
|
- Rakefile
|
|
369
383
|
- SUPPORT.md
|
|
384
|
+
- Upgrading.md
|
|
370
385
|
- active-fedora.gemspec
|
|
386
|
+
- config/fcrepo_allow.txt
|
|
371
387
|
- config/fedora.yml
|
|
372
388
|
- config/service_mappings.yml
|
|
373
389
|
- config/solr.yml
|
|
@@ -456,6 +472,7 @@ files:
|
|
|
456
472
|
- lib/active_fedora/fedora_attributes.rb
|
|
457
473
|
- lib/active_fedora/file.rb
|
|
458
474
|
- lib/active_fedora/file/attributes.rb
|
|
475
|
+
- lib/active_fedora/file/external.rb
|
|
459
476
|
- lib/active_fedora/file/streaming.rb
|
|
460
477
|
- lib/active_fedora/file_configurator.rb
|
|
461
478
|
- lib/active_fedora/file_io.rb
|
|
@@ -590,7 +607,9 @@ licenses:
|
|
|
590
607
|
- Apache-2.0
|
|
591
608
|
metadata:
|
|
592
609
|
rubygems_mfa_required: 'true'
|
|
593
|
-
post_install_message:
|
|
610
|
+
post_install_message: ActiveFedora 16+ is built for Fedora 6+. See Upgrading.md for
|
|
611
|
+
important changes from ActiveFedora 15 and hints for using the Fedora upgrade tools
|
|
612
|
+
to migrate from Fedora 4.
|
|
594
613
|
rdoc_options: []
|
|
595
614
|
require_paths:
|
|
596
615
|
- lib
|
|
@@ -605,8 +624,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
605
624
|
- !ruby/object:Gem::Version
|
|
606
625
|
version: '0'
|
|
607
626
|
requirements: []
|
|
608
|
-
rubygems_version: 3.
|
|
609
|
-
signing_key:
|
|
627
|
+
rubygems_version: 3.6.9
|
|
610
628
|
specification_version: 4
|
|
611
629
|
summary: A convenience libary for manipulating documents in the Fedora Repository.
|
|
612
630
|
test_files: []
|