mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +00:00
Compare commits
931 Commits
rest-tutor
...
dspace-7.0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
44e7b3aca6 | ||
![]() |
2b9d726214 | ||
![]() |
7238f42cf4 | ||
![]() |
d89186a192 | ||
![]() |
d48aae5baa | ||
![]() |
8afb630fcc | ||
![]() |
43444c84b7 | ||
![]() |
8f472d9197 | ||
![]() |
ba267ce72b | ||
![]() |
be4c2f9ad5 | ||
![]() |
8097589db5 | ||
![]() |
858bf72fa9 | ||
![]() |
b76aacc626 | ||
![]() |
5c035fe6a6 | ||
![]() |
be9d80c410 | ||
![]() |
3f42590fb2 | ||
![]() |
5895f08337 | ||
![]() |
b5e29a36b8 | ||
![]() |
bee7313f8a | ||
![]() |
b98943ff64 | ||
![]() |
71cd11b558 | ||
![]() |
aac6b12de9 | ||
![]() |
a3334bd10e | ||
![]() |
4ccf73ebb6 | ||
![]() |
cd8226cc97 | ||
![]() |
6e21bcdad1 | ||
![]() |
4c6e939e57 | ||
![]() |
7dfd34036c | ||
![]() |
fc05d2dab0 | ||
![]() |
62ca358f33 | ||
![]() |
9a40fd817c | ||
![]() |
ccbf681f96 | ||
![]() |
20705e1da1 | ||
![]() |
6707dfb2e6 | ||
![]() |
0bb9880d2c | ||
![]() |
70e34edfef | ||
![]() |
51aa22cdb9 | ||
![]() |
8f56970c33 | ||
![]() |
09c9d851a5 | ||
![]() |
b331b26f80 | ||
![]() |
b2d28fcf83 | ||
![]() |
7b9f08e7ad | ||
![]() |
658708832a | ||
![]() |
dcf9240f42 | ||
![]() |
d1cd9c4a9b | ||
![]() |
ec8109a67e | ||
![]() |
5a69301212 | ||
![]() |
72afed29b8 | ||
![]() |
07ce7da613 | ||
![]() |
0898e33319 | ||
![]() |
bba8feff5b | ||
![]() |
d97ea343e4 | ||
![]() |
afc6682bfb | ||
![]() |
1bf1131237 | ||
![]() |
c83ae49e7f | ||
![]() |
b30e1cc6f9 | ||
![]() |
fe0a67ca43 | ||
![]() |
f8b0eac67a | ||
![]() |
22b297b207 | ||
![]() |
cfd4e0b435 | ||
![]() |
5338a88892 | ||
![]() |
b0bff18b53 | ||
![]() |
4fe26b914e | ||
![]() |
ca02d36933 | ||
![]() |
489ed8350b | ||
![]() |
62c0f0714d | ||
![]() |
a23a8821e6 | ||
![]() |
2ed91c616c | ||
![]() |
750bdecbc0 | ||
![]() |
84eabcbf91 | ||
![]() |
b0c6b912b3 | ||
![]() |
92cb9730fb | ||
![]() |
4f3885738a | ||
![]() |
4fc6ebc28c | ||
![]() |
211e8f72a1 | ||
![]() |
f8cedefa29 | ||
![]() |
20a0e42098 | ||
![]() |
d23ebd66c0 | ||
![]() |
504cb3c5cf | ||
![]() |
6fd5a76837 | ||
![]() |
e17e8eea08 | ||
![]() |
1e6497f1d6 | ||
![]() |
77928c2560 | ||
![]() |
0324787e35 | ||
![]() |
2dd14a06ba | ||
![]() |
5e3164bd06 | ||
![]() |
8de7a50f5b | ||
![]() |
a8190fe27a | ||
![]() |
30899b0e55 | ||
![]() |
eba97f4080 | ||
![]() |
689ac4e3bd | ||
![]() |
b71b6e9f1b | ||
![]() |
1252075ac9 | ||
![]() |
cc11f49556 | ||
![]() |
272f21a8dd | ||
![]() |
006b938c4a | ||
![]() |
d25463fedb | ||
![]() |
15f6ced31a | ||
![]() |
b98d8f4d21 | ||
![]() |
4b85bf4c56 | ||
![]() |
13ce03c8c7 | ||
![]() |
85480b9ec7 | ||
![]() |
8c28d5136e | ||
![]() |
b828e56bb8 | ||
![]() |
7f2e696949 | ||
![]() |
0cc2226b25 | ||
![]() |
f56996634b | ||
![]() |
aa2a5f8b6e | ||
![]() |
a857932393 | ||
![]() |
62928cedb6 | ||
![]() |
808f04852b | ||
![]() |
a39495bef5 | ||
![]() |
51cd8fa46a | ||
![]() |
1cfc53db5c | ||
![]() |
5d997e6cde | ||
![]() |
1df2d35c1f | ||
![]() |
b4e7d62725 | ||
![]() |
828861a871 | ||
![]() |
00a4863178 | ||
![]() |
02d8e5f750 | ||
![]() |
9678dbf573 | ||
![]() |
eee2929e51 | ||
![]() |
b481fbae17 | ||
![]() |
19606943b1 | ||
![]() |
13f9c8e1e5 | ||
![]() |
7e4e22d472 | ||
![]() |
b891f3190d | ||
![]() |
c87cd80ac3 | ||
![]() |
65fb4674a0 | ||
![]() |
970b66edb2 | ||
![]() |
3e22142aa7 | ||
![]() |
e883c95de8 | ||
![]() |
e48fef5f62 | ||
![]() |
39e04c2223 | ||
![]() |
efbffe4ea5 | ||
![]() |
337daef738 | ||
![]() |
2171b7ff83 | ||
![]() |
21fe803b53 | ||
![]() |
96d544d075 | ||
![]() |
000c47e7a3 | ||
![]() |
229b9f1039 | ||
![]() |
cae9a6baa8 | ||
![]() |
499fdcd61c | ||
![]() |
6a5838461a | ||
![]() |
0a54d4cf1e | ||
![]() |
1c0e29bc64 | ||
![]() |
a596a5cabf | ||
![]() |
23bbf45048 | ||
![]() |
d751d5dc59 | ||
![]() |
65d3495e18 | ||
![]() |
15c4a33d77 | ||
![]() |
ef10d47156 | ||
![]() |
434c0fa748 | ||
![]() |
4475eca5b2 | ||
![]() |
6056bf94e0 | ||
![]() |
e3fc9a52a7 | ||
![]() |
aa0a2a3b05 | ||
![]() |
10fc1afaa3 | ||
![]() |
bfc91292d2 | ||
![]() |
15faacc70c | ||
![]() |
df1e464939 | ||
![]() |
7c122e55aa | ||
![]() |
0961c5040d | ||
![]() |
aef31c8d37 | ||
![]() |
d7ec9e537a | ||
![]() |
033790e1b2 | ||
![]() |
7f94383719 | ||
![]() |
e929c39fb2 | ||
![]() |
d5b4963e26 | ||
![]() |
b3423770dd | ||
![]() |
999e912909 | ||
![]() |
9d378143a1 | ||
![]() |
185766d8d2 | ||
![]() |
1ad0c88c3c | ||
![]() |
4b6611353f | ||
![]() |
644970eba4 | ||
![]() |
ff298b393f | ||
![]() |
c56e41aec2 | ||
![]() |
1e3e37d11e | ||
![]() |
b0f8f828b7 | ||
![]() |
b7b3a74f85 | ||
![]() |
5b98f05e70 | ||
![]() |
7ad47ad705 | ||
![]() |
4858aa75d2 | ||
![]() |
dbddc2f06a | ||
![]() |
ea2ce38677 | ||
![]() |
cc21394276 | ||
![]() |
8c0a94e689 | ||
![]() |
3c8186e7c0 | ||
![]() |
3c9626a5ef | ||
![]() |
9f44be85a3 | ||
![]() |
800f254677 | ||
![]() |
65a94cdda7 | ||
![]() |
70091e59b8 | ||
![]() |
ac83a4edef | ||
![]() |
0609a6f0b7 | ||
![]() |
60ea589296 | ||
![]() |
35ca48e17a | ||
![]() |
653bfceac8 | ||
![]() |
35e98f0d4b | ||
![]() |
1989cd9ff4 | ||
![]() |
3302835650 | ||
![]() |
91caed0cf6 | ||
![]() |
a0ebd616f2 | ||
![]() |
7f194dfa95 | ||
![]() |
53580fa228 | ||
![]() |
7773b46aca | ||
![]() |
89c1cc7729 | ||
![]() |
f829b7df5a | ||
![]() |
4ac06271c8 | ||
![]() |
22cc5469a2 | ||
![]() |
5f47771e4e | ||
![]() |
e421a7c7c7 | ||
![]() |
d3d3b57133 | ||
![]() |
c7c204091f | ||
![]() |
37c3ab9e17 | ||
![]() |
b6f73682a3 | ||
![]() |
59bf702500 | ||
![]() |
501ea5b6a6 | ||
![]() |
4b59ef27fc | ||
![]() |
0194f557c0 | ||
![]() |
caf95d5acb | ||
![]() |
0b12168218 | ||
![]() |
44a3111e41 | ||
![]() |
6dd560bd92 | ||
![]() |
dd8a7c1fea | ||
![]() |
e6860e3724 | ||
![]() |
01b9707347 | ||
![]() |
8c971d9acd | ||
![]() |
6ecc3b2351 | ||
![]() |
cd2e6a7878 | ||
![]() |
589b719895 | ||
![]() |
c1800427bd | ||
![]() |
cb3276b02e | ||
![]() |
69fcb0ebce | ||
![]() |
732bc7d92f | ||
![]() |
e9296ac8a8 | ||
![]() |
cd5911a68f | ||
![]() |
ad50b73fd9 | ||
![]() |
70b5d6bf4f | ||
![]() |
0fa69a7f09 | ||
![]() |
3bcb2edd1c | ||
![]() |
094db7217a | ||
![]() |
687f04e269 | ||
![]() |
0f83c7fe8b | ||
![]() |
17ffe721da | ||
![]() |
bb350ca420 | ||
![]() |
919ce45338 | ||
![]() |
da9d5c7452 | ||
![]() |
bce42a47f6 | ||
![]() |
5db8a6a889 | ||
![]() |
38a88d8afb | ||
![]() |
975ebb0b5b | ||
![]() |
e928b94d07 | ||
![]() |
63c43eab15 | ||
![]() |
070c21a113 | ||
![]() |
e210e3ca35 | ||
![]() |
0c7f3c0e90 | ||
![]() |
8323ccd051 | ||
![]() |
205db5c6f8 | ||
![]() |
174a77cde0 | ||
![]() |
85c09cbb55 | ||
![]() |
f09287c56b | ||
![]() |
8a76b77e66 | ||
![]() |
db707750fe | ||
![]() |
d450b59899 | ||
![]() |
7115173d61 | ||
![]() |
7cde38d229 | ||
![]() |
ed41d852b1 | ||
![]() |
8c222b9826 | ||
![]() |
6254cedd21 | ||
![]() |
0fc979a2ad | ||
![]() |
93d982dfc8 | ||
![]() |
e517ba49a5 | ||
![]() |
d7c5e224e1 | ||
![]() |
d0db6e533a | ||
![]() |
34127e4e0f | ||
![]() |
0a7a8aab8e | ||
![]() |
42942978a8 | ||
![]() |
be453a0e55 | ||
![]() |
77328c388d | ||
![]() |
13c0b9b227 | ||
![]() |
211545a9d0 | ||
![]() |
2b1b10100a | ||
![]() |
416732921c | ||
![]() |
aa4125c9e9 | ||
![]() |
15eb85eb08 | ||
![]() |
d90e60a92b | ||
![]() |
d489636641 | ||
![]() |
78f7066c94 | ||
![]() |
f2b3f7027c | ||
![]() |
8fb1ac5bd6 | ||
![]() |
fb2e0d556e | ||
![]() |
05cb949655 | ||
![]() |
47d7021350 | ||
![]() |
02ff91259f | ||
![]() |
864f6f1237 | ||
![]() |
db8f6f1bb8 | ||
![]() |
2e446bf9a3 | ||
![]() |
ac283df61d | ||
![]() |
241fdbb538 | ||
![]() |
cb17cb1b7f | ||
![]() |
8c26a9a78e | ||
![]() |
ba0edff464 | ||
![]() |
f2cfab2d8d | ||
![]() |
fa9cc7c958 | ||
![]() |
c375fe1762 | ||
![]() |
0792ba77ed | ||
![]() |
3e8e1aa60f | ||
![]() |
cc38ec872a | ||
![]() |
9d0483c146 | ||
![]() |
8d5de13987 | ||
![]() |
ee3b60c45e | ||
![]() |
3504397031 | ||
![]() |
5e78f408f3 | ||
![]() |
ece64480a0 | ||
![]() |
01b80025b7 | ||
![]() |
32a3c74164 | ||
![]() |
3aa6b89487 | ||
![]() |
7b9bd509a2 | ||
![]() |
3e5c9426aa | ||
![]() |
2db2b70e82 | ||
![]() |
8c35296cdf | ||
![]() |
ed4f63c0b4 | ||
![]() |
1957f36988 | ||
![]() |
855b3f9556 | ||
![]() |
e99252c16f | ||
![]() |
0a91360061 | ||
![]() |
c72d731f93 | ||
![]() |
a663f05ad5 | ||
![]() |
e01e133765 | ||
![]() |
887a0999bd | ||
![]() |
2dc03adc58 | ||
![]() |
96f08e4414 | ||
![]() |
765e14b007 | ||
![]() |
f8497ff392 | ||
![]() |
7abc5b01e2 | ||
![]() |
da1346ef53 | ||
![]() |
7dc59a03a2 | ||
![]() |
a62a66ec41 | ||
![]() |
b908df263c | ||
![]() |
7d961db6ce | ||
![]() |
54a626892a | ||
![]() |
e768866292 | ||
![]() |
d7610ccf6e | ||
![]() |
1311c40cb7 | ||
![]() |
257b14bc54 | ||
![]() |
dac5ca467c | ||
![]() |
816c7d0772 | ||
![]() |
391c5b4dc6 | ||
![]() |
51de4cd87c | ||
![]() |
1ed01310b0 | ||
![]() |
8557f44673 | ||
![]() |
025c77ee70 | ||
![]() |
1ac514d4fb | ||
![]() |
ccaca1aaaa | ||
![]() |
a52b850080 | ||
![]() |
4847620a4c | ||
![]() |
7e14562139 | ||
![]() |
461b5ee21a | ||
![]() |
86f3f9e9c3 | ||
![]() |
f387ab18c0 | ||
![]() |
f2c2b768f7 | ||
![]() |
bfc1b39ea2 | ||
![]() |
929312d7e8 | ||
![]() |
6d40a57df7 | ||
![]() |
e7f39c23b2 | ||
![]() |
48d90660ab | ||
![]() |
0f6148db77 | ||
![]() |
ae96aeafd4 | ||
![]() |
269fdd2852 | ||
![]() |
a757a6661e | ||
![]() |
6ee687a4ae | ||
![]() |
07d6846234 | ||
![]() |
9b6e97fd24 | ||
![]() |
865b4256b9 | ||
![]() |
7f225f1ad5 | ||
![]() |
6d40600dbb | ||
![]() |
04d11924a5 | ||
![]() |
74fc3e97bb | ||
![]() |
51550079c4 | ||
![]() |
3d011c5411 | ||
![]() |
b96cf91ef8 | ||
![]() |
612c8e315c | ||
![]() |
6e02e145f0 | ||
![]() |
33eedeaba8 | ||
![]() |
cd5d1b038d | ||
![]() |
67602275bd | ||
![]() |
821d106439 | ||
![]() |
bf0139d5e9 | ||
![]() |
8a2ae7e891 | ||
![]() |
b3b1c8786e | ||
![]() |
f84e951106 | ||
![]() |
69f7c7588d | ||
![]() |
c8e11e6700 | ||
![]() |
7b2b923390 | ||
![]() |
f255521c8e | ||
![]() |
1a7b22a784 | ||
![]() |
0692701f7a | ||
![]() |
c9bbbfde1f | ||
![]() |
37fc3ee409 | ||
![]() |
f3f784c6ec | ||
![]() |
fb1a8b8c33 | ||
![]() |
035832cfdd | ||
![]() |
e283f43467 | ||
![]() |
32c9585ede | ||
![]() |
0d678aca58 | ||
![]() |
fe437ad88d | ||
![]() |
dc6bd487e0 | ||
![]() |
b050db1cae | ||
![]() |
efd579f054 | ||
![]() |
1b0f00df18 | ||
![]() |
dfd3ba4e38 | ||
![]() |
78e3e00e7f | ||
![]() |
7fe7da4813 | ||
![]() |
74aa295787 | ||
![]() |
e0175bd198 | ||
![]() |
f0ff442959 | ||
![]() |
b05eec3b92 | ||
![]() |
c305879b51 | ||
![]() |
c2803a7f69 | ||
![]() |
ff1f46aedb | ||
![]() |
942f2e7b92 | ||
![]() |
39bf016eb8 | ||
![]() |
1776f892e0 | ||
![]() |
10c610bf73 | ||
![]() |
6fca857429 | ||
![]() |
feaa5d1adb | ||
![]() |
21fe950593 | ||
![]() |
4e51fd0c86 | ||
![]() |
33268e8980 | ||
![]() |
c3f2fa7f47 | ||
![]() |
04475e42eb | ||
![]() |
240636e978 | ||
![]() |
2f0fb32c8c | ||
![]() |
e932075d03 | ||
![]() |
3123c1dd61 | ||
![]() |
43bfdbb3ff | ||
![]() |
c4ab55f6f5 | ||
![]() |
20904f897d | ||
![]() |
d95c378edc | ||
![]() |
67046598c1 | ||
![]() |
8ccb41a205 | ||
![]() |
7ccd99c97c | ||
![]() |
314e96a6ac | ||
![]() |
1b2cc563d7 | ||
![]() |
4171729f84 | ||
![]() |
8024242fd1 | ||
![]() |
0feb1748a0 | ||
![]() |
6e16a3ed62 | ||
![]() |
e02174bad8 | ||
![]() |
5ecc473311 | ||
![]() |
7d07a1e6f9 | ||
![]() |
09faec3f17 | ||
![]() |
ceed829800 | ||
![]() |
8df33db457 | ||
![]() |
844ef85583 | ||
![]() |
1d3a58958e | ||
![]() |
1e5bcd47ce | ||
![]() |
c795c8b4b4 | ||
![]() |
85db4fe2bb | ||
![]() |
6084f892b2 | ||
![]() |
ff8a5fac97 | ||
![]() |
dbcb1f291c | ||
![]() |
d9c80d8afc | ||
![]() |
9f64b9aa95 | ||
![]() |
de33ece1c9 | ||
![]() |
ab224b2508 | ||
![]() |
1478ab36fa | ||
![]() |
d6d0e67017 | ||
![]() |
f23fef032f | ||
![]() |
94ed795d00 | ||
![]() |
301f804d44 | ||
![]() |
90a9df75ef | ||
![]() |
6bbcc08e59 | ||
![]() |
733ef18184 | ||
![]() |
d77dd7fa4f | ||
![]() |
495ccdee21 | ||
![]() |
4c1fdfc49c | ||
![]() |
dcf21c04cf | ||
![]() |
699fb42683 | ||
![]() |
769398d6fb | ||
![]() |
8f81f28607 | ||
![]() |
9bc1f1ce69 | ||
![]() |
13fea6312e | ||
![]() |
41ff37de1b | ||
![]() |
58c01c500c | ||
![]() |
1d9a4edcc0 | ||
![]() |
b44cf37d9d | ||
![]() |
c6dfae90de | ||
![]() |
925b83bc02 | ||
![]() |
fc8e3744b6 | ||
![]() |
0b4dc28dfa | ||
![]() |
e7b6aded69 | ||
![]() |
30f8b61ad0 | ||
![]() |
6600839fa4 | ||
![]() |
8ebb6a1a41 | ||
![]() |
7613a204ed | ||
![]() |
912a1f0be6 | ||
![]() |
38250f94ad | ||
![]() |
34a2b92754 | ||
![]() |
b905f69d63 | ||
![]() |
aeee597101 | ||
![]() |
5114f21da8 | ||
![]() |
52f1cf1fdc | ||
![]() |
b8d6fa2fba | ||
![]() |
cfeabe349c | ||
![]() |
0ba6d75a30 | ||
![]() |
ad7bd23038 | ||
![]() |
3a972ba5b9 | ||
![]() |
a755f296bf | ||
![]() |
255de21271 | ||
![]() |
76470f4eec | ||
![]() |
f3245e7c88 | ||
![]() |
5eeb40e530 | ||
![]() |
8e8bb65f75 | ||
![]() |
01c1c0cddf | ||
![]() |
7b2233a9b7 | ||
![]() |
86cd0c7025 | ||
![]() |
353d4c9d60 | ||
![]() |
7d5e12a793 | ||
![]() |
37ffda5d21 | ||
![]() |
5de574d65a | ||
![]() |
b226666113 | ||
![]() |
b3a4a196d8 | ||
![]() |
45afa91d0e | ||
![]() |
c30e548533 | ||
![]() |
94aeb7c18a | ||
![]() |
e53af97a31 | ||
![]() |
9e1c16990f | ||
![]() |
18868370de | ||
![]() |
468725346f | ||
![]() |
3929a5d7ac | ||
![]() |
e671680ae4 | ||
![]() |
eff018aace | ||
![]() |
38e1d0a8d4 | ||
![]() |
5b66fdf5db | ||
![]() |
2925a3a3bf | ||
![]() |
b668860a2b | ||
![]() |
9133d289ed | ||
![]() |
959b5122b7 | ||
![]() |
f3505ed22b | ||
![]() |
3f904dc4ec | ||
![]() |
5cbe4fefb5 | ||
![]() |
bb10bfe01a | ||
![]() |
9be54714d3 | ||
![]() |
f5d325b36b | ||
![]() |
f48d005e2c | ||
![]() |
538b0046e5 | ||
![]() |
8eb074b11f | ||
![]() |
a3db6f727c | ||
![]() |
7996283d3c | ||
![]() |
56dd50d283 | ||
![]() |
7bd47362b6 | ||
![]() |
bb2dde22b1 | ||
![]() |
a49486310a | ||
![]() |
a5a00816cc | ||
![]() |
00088c9739 | ||
![]() |
3b10caef0d | ||
![]() |
bda4fa0ba7 | ||
![]() |
35b5c6c321 | ||
![]() |
7f589a5ad6 | ||
![]() |
1eed2698ae | ||
![]() |
b72fff4a25 | ||
![]() |
1e3231967f | ||
![]() |
7f4b4e9f8a | ||
![]() |
fb4e7ae9cb | ||
![]() |
195213d528 | ||
![]() |
34edf302b7 | ||
![]() |
4d882bec60 | ||
![]() |
200cede397 | ||
![]() |
b4eac9e5ff | ||
![]() |
3ec449f3df | ||
![]() |
79d027776e | ||
![]() |
673d4b9d36 | ||
![]() |
c810efccb3 | ||
![]() |
cb913fd24f | ||
![]() |
d364f351e6 | ||
![]() |
b37d0e2167 | ||
![]() |
68dca061b0 | ||
![]() |
af305d154a | ||
![]() |
445e42ccc2 | ||
![]() |
bfd0bd7362 | ||
![]() |
d8ced6aa7d | ||
![]() |
d90f4e63f5 | ||
![]() |
b81593c41c | ||
![]() |
75358b2bdd | ||
![]() |
0ee618385b | ||
![]() |
53e548e4a9 | ||
![]() |
91f779aa8c | ||
![]() |
218fdcbaf0 | ||
![]() |
defa4671d8 | ||
![]() |
8ec4780625 | ||
![]() |
a6276da8b0 | ||
![]() |
ed94b9ce9e | ||
![]() |
fa00fec49f | ||
![]() |
fed22f30bf | ||
![]() |
30c522f896 | ||
![]() |
b9b383bb05 | ||
![]() |
3255206212 | ||
![]() |
6c989433e1 | ||
![]() |
74149ba247 | ||
![]() |
9d5b59b46f | ||
![]() |
9fee00445e | ||
![]() |
1f15bb874e | ||
![]() |
9e99c911c6 | ||
![]() |
b5c3af6aa5 | ||
![]() |
3c10296d0c | ||
![]() |
b622781f5d | ||
![]() |
f984cd17c1 | ||
![]() |
b283d5d9e4 | ||
![]() |
0a9f5efcdc | ||
![]() |
c08fb4af1d | ||
![]() |
110f6c2a8d | ||
![]() |
003831f4f6 | ||
![]() |
eb0ea9a6bf | ||
![]() |
0c6c9afbd4 | ||
![]() |
9c242087a7 | ||
![]() |
d5e22ec1af | ||
![]() |
af94859404 | ||
![]() |
031642ddc1 | ||
![]() |
b0216cb918 | ||
![]() |
f223f1c067 | ||
![]() |
bd9bd233b7 | ||
![]() |
cb1a35a524 | ||
![]() |
992c775058 | ||
![]() |
e92852faca | ||
![]() |
819a42b69e | ||
![]() |
826babb48e | ||
![]() |
d55189a4f2 | ||
![]() |
499f496d62 | ||
![]() |
6dc6102325 | ||
![]() |
8b0db601b0 | ||
![]() |
f9861ec5ca | ||
![]() |
f890f1705c | ||
![]() |
b702582fb2 | ||
![]() |
fa3af00e4d | ||
![]() |
0d59219ead | ||
![]() |
d421942321 | ||
![]() |
c7cde57c3a | ||
![]() |
0c6690aa82 | ||
![]() |
5b43bebf17 | ||
![]() |
837814b596 | ||
![]() |
3c0c4565df | ||
![]() |
e2608f79bf | ||
![]() |
d6d7a620c2 | ||
![]() |
e64101a5e9 | ||
![]() |
ac788aacee | ||
![]() |
4652bb8cab | ||
![]() |
ed8f245e7d | ||
![]() |
d794c20385 | ||
![]() |
77f4b9db6e | ||
![]() |
2f1f45f8a8 | ||
![]() |
4c5b82c95a | ||
![]() |
50490370d9 | ||
![]() |
e58870eb8f | ||
![]() |
b6a35ebaf7 | ||
![]() |
7e4194b3a4 | ||
![]() |
a9bf1d869d | ||
![]() |
0f0066b0c0 | ||
![]() |
dc51e4c059 | ||
![]() |
a2e7069d1c | ||
![]() |
486b1fb41d | ||
![]() |
e4874ae356 | ||
![]() |
2458b5d621 | ||
![]() |
89ebd2c154 | ||
![]() |
3fd7cc903d | ||
![]() |
d3ee089d2e | ||
![]() |
447bea2921 | ||
![]() |
754915b8aa | ||
![]() |
4a0b636b3d | ||
![]() |
2d2afd886c | ||
![]() |
951d039830 | ||
![]() |
1bb1fd44a4 | ||
![]() |
a8863fd6a0 | ||
![]() |
9e85421ab4 | ||
![]() |
c466d10c6a | ||
![]() |
79b950c8e4 | ||
![]() |
f432568b31 | ||
![]() |
cc7bcf6007 | ||
![]() |
40ca9f6150 | ||
![]() |
267677a023 | ||
![]() |
ef8b0c642d | ||
![]() |
a3437d4217 | ||
![]() |
1f091bd6bd | ||
![]() |
aacb7b0ee3 | ||
![]() |
ca697e8064 | ||
![]() |
f9bfd5ed6d | ||
![]() |
7e1ca49bcf | ||
![]() |
06b4e5d12a | ||
![]() |
d51493a1a3 | ||
![]() |
65c7bbb6f6 | ||
![]() |
0b991a4d13 | ||
![]() |
e0d10d7eec | ||
![]() |
bd464e03f5 | ||
![]() |
47dc9482c6 | ||
![]() |
df5816dff9 | ||
![]() |
ea42765849 | ||
![]() |
b192552888 | ||
![]() |
aa4f3bb60b | ||
![]() |
26a55312b3 | ||
![]() |
a73b980955 | ||
![]() |
b0e076ddb1 | ||
![]() |
b3abd7743c | ||
![]() |
4f53075317 | ||
![]() |
7aed10c1b1 | ||
![]() |
0340cd73ad | ||
![]() |
43d01f283f | ||
![]() |
705e0fabbd | ||
![]() |
d4dbd3894a | ||
![]() |
0c58803a44 | ||
![]() |
2c47e9b149 | ||
![]() |
af27fde95b | ||
![]() |
e980811d4e | ||
![]() |
349eebb834 | ||
![]() |
287dce21fc | ||
![]() |
c56c1d38ef | ||
![]() |
173b7f4fce | ||
![]() |
25e3a69b8f | ||
![]() |
c0066d2a2f | ||
![]() |
66b89a786d | ||
![]() |
d43aba5131 | ||
![]() |
928ae19d1d | ||
![]() |
02fb1f4077 | ||
![]() |
154177db49 | ||
![]() |
d0889f858c | ||
![]() |
ae53acfcb7 | ||
![]() |
07a76d394b | ||
![]() |
b95a55d3d0 | ||
![]() |
a12c22a767 | ||
![]() |
a33f5de0df | ||
![]() |
db0a898c42 | ||
![]() |
0491247c6d | ||
![]() |
1745640bbc | ||
![]() |
877b84fda6 | ||
![]() |
6f5b9cddc6 | ||
![]() |
7385ce5b04 | ||
![]() |
e69ebcfe82 | ||
![]() |
e16857ce9e | ||
![]() |
ccb81d5091 | ||
![]() |
7c691d8086 | ||
![]() |
23f4ebc6c2 | ||
![]() |
cad1b5a10e | ||
![]() |
798264c001 | ||
![]() |
5d257f4423 | ||
![]() |
93bac51ead | ||
![]() |
44a0f9b2de | ||
![]() |
0dede9eacb | ||
![]() |
302c877d21 | ||
![]() |
295d6d6ba1 | ||
![]() |
238ede5f9d | ||
![]() |
c0f31e889f | ||
![]() |
cd94bbd0ee | ||
![]() |
14338cc183 | ||
![]() |
c02a5aa778 | ||
![]() |
de29b6af46 | ||
![]() |
3f7e2363c7 | ||
![]() |
322460827c | ||
![]() |
e25a732e6b | ||
![]() |
cbaad2e714 | ||
![]() |
7bb8a8e9c4 | ||
![]() |
81b41a2b78 | ||
![]() |
07c7fee64f | ||
![]() |
0361ed77a5 | ||
![]() |
e65f94da0c | ||
![]() |
cb3b4d20cd | ||
![]() |
063219add8 | ||
![]() |
6dbe089861 | ||
![]() |
587a807bec | ||
![]() |
a979392150 | ||
![]() |
db6c9faf83 | ||
![]() |
84c123a547 | ||
![]() |
a25a046ffa | ||
![]() |
544536ccef | ||
![]() |
ac1ea060ef | ||
![]() |
d5b0b8b43a | ||
![]() |
dac12e1233 | ||
![]() |
500b2648a1 | ||
![]() |
99aa4e0cfb | ||
![]() |
97a1180f6b | ||
![]() |
4a604488a7 | ||
![]() |
cc6bf1a343 | ||
![]() |
19172012b4 | ||
![]() |
b159aa901a | ||
![]() |
a85228bd24 | ||
![]() |
90d0bbccee | ||
![]() |
2760c95099 | ||
![]() |
643f0fcde7 | ||
![]() |
950c97bf6e | ||
![]() |
c038d76ced | ||
![]() |
ea9efd7fa3 | ||
![]() |
cbd5980368 | ||
![]() |
3c4d5042fb | ||
![]() |
74f47de1e2 | ||
![]() |
1b68a02dd7 | ||
![]() |
79709ef76a | ||
![]() |
21b628a792 | ||
![]() |
c4cf5b3c8d | ||
![]() |
49947808a2 | ||
![]() |
8bf8a9fa69 | ||
![]() |
527dd1f64a | ||
![]() |
794dbfd550 | ||
![]() |
64493d24ca | ||
![]() |
c65755653b | ||
![]() |
f159c70d1c | ||
![]() |
1ab41bb4d1 | ||
![]() |
b9a7204420 | ||
![]() |
5437f7f8b9 | ||
![]() |
d396cf3490 | ||
![]() |
0b33907f5e | ||
![]() |
0ced11c0af | ||
![]() |
33edc9530e | ||
![]() |
06ca8809e1 | ||
![]() |
15d100050c | ||
![]() |
ebb738e3e2 | ||
![]() |
9747d051a5 | ||
![]() |
7af1958d7e | ||
![]() |
fe648a678e | ||
![]() |
dfd0250ac1 | ||
![]() |
32399ac00b | ||
![]() |
9bcaa07bce | ||
![]() |
c1590ce15e | ||
![]() |
220c8a5a48 | ||
![]() |
58855cd632 | ||
![]() |
77d67537f7 | ||
![]() |
3eaaa5bb96 | ||
![]() |
cb7c2519a3 | ||
![]() |
ef67916563 | ||
![]() |
3eb16056c6 | ||
![]() |
c076c99686 | ||
![]() |
5ba8bdd42b | ||
![]() |
8f61b926bc | ||
![]() |
b00bae2c23 | ||
![]() |
5b717bfa35 | ||
![]() |
308dbe95e2 | ||
![]() |
27545eb088 | ||
![]() |
628c1250c2 | ||
![]() |
f3bdbe43cf | ||
![]() |
d903daadce | ||
![]() |
be02e510e2 | ||
![]() |
38f094caa8 | ||
![]() |
bfac8d1d4b | ||
![]() |
26d6ca9bac | ||
![]() |
92845557ff | ||
![]() |
9214ffa732 | ||
![]() |
38a6e7ad9b | ||
![]() |
9f2ca2633f | ||
![]() |
ac342b4819 | ||
![]() |
a2569fe905 | ||
![]() |
e248893e2f | ||
![]() |
353eed6f60 | ||
![]() |
f807cc38a3 | ||
![]() |
516d6af6f4 | ||
![]() |
e55846b212 | ||
![]() |
8fb56be144 | ||
![]() |
2ede483e2b | ||
![]() |
5a9edd1b70 | ||
![]() |
de33709364 | ||
![]() |
8ffbec58ca | ||
![]() |
eefb535214 | ||
![]() |
eb2b4184ef | ||
![]() |
c8a08e4bb9 | ||
![]() |
6b78459b68 | ||
![]() |
7328d49962 | ||
![]() |
bf9d63c363 | ||
![]() |
23c2f1a7ca | ||
![]() |
6eb2829b4a | ||
![]() |
005535fcbf | ||
![]() |
b38aa1723c | ||
![]() |
71347a3faf | ||
![]() |
7b6ce941df | ||
![]() |
25a83f3b3f | ||
![]() |
82de7bb125 | ||
![]() |
91218ed36c | ||
![]() |
9ab8904bf2 | ||
![]() |
ddbe928cd3 | ||
![]() |
ad1a3310f0 | ||
![]() |
fe2030d024 | ||
![]() |
3dc2024265 | ||
![]() |
4acde3df79 | ||
![]() |
db0a3cd756 | ||
![]() |
4d0382766c | ||
![]() |
b805baddf5 | ||
![]() |
e98af34e21 | ||
![]() |
a487fb7d58 | ||
![]() |
06ed982031 | ||
![]() |
a921a86422 | ||
![]() |
5a1202222f | ||
![]() |
55f5571e1d | ||
![]() |
93549cab24 | ||
![]() |
ecce5fe9b2 | ||
![]() |
3a51c7a962 | ||
![]() |
7d03da0fea | ||
![]() |
43eda56269 | ||
![]() |
f00d31e370 | ||
![]() |
b15a0027b7 | ||
![]() |
52401d0719 | ||
![]() |
40fc109c7c | ||
![]() |
d5d2fe0e68 | ||
![]() |
18046604a7 | ||
![]() |
bc2d9e0706 | ||
![]() |
7f68244c4e | ||
![]() |
6b74ef5544 | ||
![]() |
a87baf6edb | ||
![]() |
7e6d1a58ec | ||
![]() |
6af5349e74 | ||
![]() |
af758212f7 | ||
![]() |
a6c1113165 | ||
![]() |
27ee3a13f0 | ||
![]() |
7157c43bc1 | ||
![]() |
416fc80010 | ||
![]() |
d1f8c56be5 | ||
![]() |
388858de14 | ||
![]() |
e6d5254eff | ||
![]() |
5c7e5ee4e2 | ||
![]() |
e29b72d228 | ||
![]() |
5970b3ccfa | ||
![]() |
5f52704ce5 | ||
![]() |
7acaa69c95 | ||
![]() |
3b62f4de86 | ||
![]() |
6b57003e34 | ||
![]() |
032a76ddb8 | ||
![]() |
e62d63f343 | ||
![]() |
f2e2d01560 | ||
![]() |
b0e7994520 | ||
![]() |
bc581e64e0 | ||
![]() |
519f0a812c | ||
![]() |
e36ded0244 | ||
![]() |
24575d8ba1 | ||
![]() |
6d1b695ca5 | ||
![]() |
287cc56476 |
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.git/
|
||||||
|
.idea/
|
||||||
|
.settings/
|
||||||
|
*/target/
|
||||||
|
dspace/modules/*/target/
|
||||||
|
Dockerfile.*
|
17
.travis.yml
17
.travis.yml
@@ -26,19 +26,20 @@ before_install:
|
|||||||
# Skip install stage, as we'll do it below
|
# Skip install stage, as we'll do it below
|
||||||
install: "echo 'Skipping install stage, dependencies will be downloaded during build and test stages.'"
|
install: "echo 'Skipping install stage, dependencies will be downloaded during build and test stages.'"
|
||||||
|
|
||||||
# Two stage Build and Test
|
# Build DSpace and run both Unit and Integration Tests
|
||||||
# 1. Install & Unit Test APIs
|
|
||||||
# 2. Assemble DSpace
|
|
||||||
script:
|
script:
|
||||||
# 1. [Install & Unit Test] Check source code licenses and run source code Unit Tests
|
# Summary of flags used (below):
|
||||||
# license:check => Validate all source code license headers
|
# license:check => Validate all source code license headers
|
||||||
# -Dmaven.test.skip=false => Enable DSpace Unit Tests
|
# -Dmaven.test.skip=false => Enable DSpace Unit Tests
|
||||||
# -DskipITs=false => Enable DSpace Integration Tests
|
# -DskipITs=false => Enable DSpace Integration Tests
|
||||||
# -P !assembly => Skip normal assembly (as it can be memory intensive)
|
# -P !assembly => Skip assembly of "dspace-installer" directory (as it can be memory intensive)
|
||||||
# -B => Maven batch/non-interactive mode (recommended for CI)
|
# -B => Maven batch/non-interactive mode (recommended for CI)
|
||||||
# -V => Display Maven version info before build
|
# -V => Display Maven version info before build
|
||||||
# -Dsurefire.rerunFailingTestsCount=2 => try again for flakey tests, and keep track of/report on number of retries
|
# -Dsurefire.rerunFailingTestsCount=2 => try again for flakey tests, and keep track of/report on number of retries
|
||||||
- "mvn clean install license:check -Dmaven.test.skip=false -DskipITs=false -P !assembly -B -V -Dsurefire.rerunFailingTestsCount=2"
|
- "mvn clean install license:check -Dmaven.test.skip=false -DskipITs=false -P !assembly -B -V -Dsurefire.rerunFailingTestsCount=2"
|
||||||
# 2. [Assemble DSpace] Ensure overlay & assembly process works (from [src]/dspace/)
|
|
||||||
# -P !assembly => SKIP the actual building of [src]/dspace/dspace-installer (as it can be memory intensive)
|
# After a successful build and test (see 'script'), send code coverage reports to coveralls.io
|
||||||
- "cd dspace && mvn package -P !assembly -B -V -Dsurefire.rerunFailingTestsCount=2"
|
# These code coverage reports are generated by jacoco-maven-plugin (during test process above).
|
||||||
|
after_success:
|
||||||
|
# Run "verify", enabling the "coveralls" profile. This sends our reports to coveralls.io (see coveralls-maven-plugin)
|
||||||
|
- "cd dspace && mvn verify -P coveralls"
|
||||||
|
24
Dockerfile.dependencies
Normal file
24
Dockerfile.dependencies
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# This image will be published as dspace/dspace-dependencies
|
||||||
|
# The purpose of this image is to make the build for dspace/dspace run faster
|
||||||
|
|
||||||
|
# Step 1 - Run Maven Build
|
||||||
|
FROM maven:3-jdk-8 as build
|
||||||
|
ARG TARGET_DIR=dspace-installer
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN useradd dspace \
|
||||||
|
&& mkdir /home/dspace \
|
||||||
|
&& chown -Rv dspace: /home/dspace
|
||||||
|
USER dspace
|
||||||
|
|
||||||
|
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
||||||
|
ADD --chown=dspace . /app/
|
||||||
|
COPY dspace/src/main/docker/local.cfg /app/local.cfg
|
||||||
|
|
||||||
|
# Trigger the installation of all maven dependencies
|
||||||
|
# Clean up the built artifacts in the same step to keep the docker image small
|
||||||
|
RUN mvn package && mvn clean
|
||||||
|
|
||||||
|
# Clear the contents of the /app directory so no artifacts are left when dspace:dspace is built
|
||||||
|
USER root
|
||||||
|
RUN rm -rf /app/*
|
63
Dockerfile.jdk8
Normal file
63
Dockerfile.jdk8
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# This image will be published as dspace/dspace
|
||||||
|
# See https://dspace-labs.github.io/DSpace-Docker-Images/ for usage details
|
||||||
|
#
|
||||||
|
# This version is JDK8 compatible
|
||||||
|
# - tomcat:8-jre8
|
||||||
|
# - ANT 1.10.5
|
||||||
|
# - maven:3-jdk-8
|
||||||
|
# - note:
|
||||||
|
# - default tag for branch: dspace/dspace: dspace/dspace:dspace-7_x-jdk8
|
||||||
|
|
||||||
|
# Step 1 - Run Maven Build
|
||||||
|
FROM dspace/dspace-dependencies:dspace-7_x as build
|
||||||
|
ARG TARGET_DIR=dspace-installer
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# The dspace-install directory will be written to /install
|
||||||
|
RUN mkdir /install \
|
||||||
|
&& chown -Rv dspace: /install \
|
||||||
|
&& chown -Rv dspace: /app
|
||||||
|
|
||||||
|
USER dspace
|
||||||
|
|
||||||
|
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
||||||
|
ADD --chown=dspace . /app/
|
||||||
|
COPY dspace/src/main/docker/local.cfg /app/local.cfg
|
||||||
|
|
||||||
|
# Build DSpace. Copy the dspace-install directory to /install. Clean up the build to keep the docker image small
|
||||||
|
RUN mvn package && \
|
||||||
|
mv /app/dspace/target/${TARGET_DIR}/* /install && \
|
||||||
|
mvn clean
|
||||||
|
|
||||||
|
# Step 2 - Run Ant Deploy
|
||||||
|
FROM tomcat:8-jre8 as ant_build
|
||||||
|
ARG TARGET_DIR=dspace-installer
|
||||||
|
COPY --from=build /install /dspace-src
|
||||||
|
WORKDIR /dspace-src
|
||||||
|
|
||||||
|
# Create the initial install deployment using ANT
|
||||||
|
ENV ANT_VERSION 1.10.5
|
||||||
|
ENV ANT_HOME /tmp/ant-$ANT_VERSION
|
||||||
|
ENV PATH $ANT_HOME/bin:$PATH
|
||||||
|
|
||||||
|
RUN mkdir $ANT_HOME && \
|
||||||
|
wget -qO- "https://www.apache.org/dist/ant/binaries/apache-ant-$ANT_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C $ANT_HOME
|
||||||
|
|
||||||
|
RUN ant init_installation update_configs update_code update_webapps update_solr_indexes
|
||||||
|
|
||||||
|
# Step 3 - Run tomcat
|
||||||
|
# Create a new tomcat image that does not retain the the build directory contents
|
||||||
|
FROM tomcat:8-jre8
|
||||||
|
ENV DSPACE_INSTALL=/dspace
|
||||||
|
COPY --from=ant_build /dspace $DSPACE_INSTALL
|
||||||
|
EXPOSE 8080 8009
|
||||||
|
|
||||||
|
ENV JAVA_OPTS=-Xmx2000m
|
||||||
|
|
||||||
|
RUN ln -s $DSPACE_INSTALL/webapps/solr /usr/local/tomcat/webapps/solr && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/spring-rest && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/oai /usr/local/tomcat/webapps/oai && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/rdf /usr/local/tomcat/webapps/rdf && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/sword /usr/local/tomcat/webapps/sword && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/swordv2 /usr/local/tomcat/webapps/swordv2
|
69
Dockerfile.jdk8-test
Normal file
69
Dockerfile.jdk8-test
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# This image will be published as dspace/dspace
|
||||||
|
# See https://dspace-labs.github.io/DSpace-Docker-Images/ for usage details
|
||||||
|
#
|
||||||
|
# This version is JDK8 compatible
|
||||||
|
# - tomcat:8-jre8
|
||||||
|
# - ANT 1.10.5
|
||||||
|
# - maven:3-jdk-8
|
||||||
|
# - note:
|
||||||
|
# - default tag for branch: dspace/dspace: dspace/dspace:dspace-7_x-jdk8-test
|
||||||
|
|
||||||
|
# Step 1 - Run Maven Build
|
||||||
|
FROM dspace/dspace-dependencies:dspace-7_x as build
|
||||||
|
ARG TARGET_DIR=dspace-installer
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# The dspace-install directory will be written to /install
|
||||||
|
RUN mkdir /install \
|
||||||
|
&& chown -Rv dspace: /install \
|
||||||
|
&& chown -Rv dspace: /app
|
||||||
|
|
||||||
|
USER dspace
|
||||||
|
|
||||||
|
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
||||||
|
ADD --chown=dspace . /app/
|
||||||
|
COPY dspace/src/main/docker/local.cfg /app/local.cfg
|
||||||
|
|
||||||
|
# Build DSpace. Copy the dspace-install directory to /install. Clean up the build to keep the docker image small
|
||||||
|
RUN mvn package && \
|
||||||
|
mv /app/dspace/target/${TARGET_DIR}/* /install && \
|
||||||
|
mvn clean
|
||||||
|
|
||||||
|
# Step 2 - Run Ant Deploy
|
||||||
|
FROM tomcat:8-jre8 as ant_build
|
||||||
|
ARG TARGET_DIR=dspace-installer
|
||||||
|
COPY --from=build /install /dspace-src
|
||||||
|
WORKDIR /dspace-src
|
||||||
|
|
||||||
|
# Create the initial install deployment using ANT
|
||||||
|
ENV ANT_VERSION 1.10.5
|
||||||
|
ENV ANT_HOME /tmp/ant-$ANT_VERSION
|
||||||
|
ENV PATH $ANT_HOME/bin:$PATH
|
||||||
|
|
||||||
|
RUN mkdir $ANT_HOME && \
|
||||||
|
wget -qO- "https://www.apache.org/dist/ant/binaries/apache-ant-$ANT_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C $ANT_HOME
|
||||||
|
|
||||||
|
RUN ant init_installation update_configs update_code update_webapps update_solr_indexes
|
||||||
|
|
||||||
|
# Step 3 - Run tomcat
|
||||||
|
# Create a new tomcat image that does not retain the the build directory contents
|
||||||
|
FROM tomcat:8-jre8
|
||||||
|
ENV DSPACE_INSTALL=/dspace
|
||||||
|
COPY --from=ant_build /dspace $DSPACE_INSTALL
|
||||||
|
EXPOSE 8080 8009
|
||||||
|
|
||||||
|
ENV JAVA_OPTS=-Xmx2000m
|
||||||
|
|
||||||
|
RUN ln -s $DSPACE_INSTALL/webapps/solr /usr/local/tomcat/webapps/solr && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/spring-rest && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/oai /usr/local/tomcat/webapps/oai && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/rdf /usr/local/tomcat/webapps/rdf && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/sword /usr/local/tomcat/webapps/sword && \
|
||||||
|
ln -s $DSPACE_INSTALL/webapps/swordv2 /usr/local/tomcat/webapps/swordv2
|
||||||
|
|
||||||
|
COPY dspace/src/main/docker/test/solr_web.xml $DSPACE_INSTALL/webapps/solr/WEB-INF/web.xml
|
||||||
|
COPY dspace/src/main/docker/test/rest_web.xml $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml
|
||||||
|
|
||||||
|
RUN sed -i -e "s|\${dspace.dir}|$DSPACE_INSTALL|" $DSPACE_INSTALL/webapps/solr/WEB-INF/web.xml && \
|
||||||
|
sed -i -e "s|\${dspace.dir}|$DSPACE_INSTALL|" $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml
|
@@ -366,7 +366,6 @@ https://wiki.duraspace.org/display/DSPACE/Code+Contribution+Guidelines
|
|||||||
* FindBugs-Annotations (com.google.code.findbugs:annotations:3.0.1u2 - http://findbugs.sourceforge.net/)
|
* FindBugs-Annotations (com.google.code.findbugs:annotations:3.0.1u2 - http://findbugs.sourceforge.net/)
|
||||||
* MaxMind GeoIP Legacy API (com.maxmind.geoip:geoip-api:1.3.0 - https://github.com/maxmind/geoip-api-java)
|
* MaxMind GeoIP Legacy API (com.maxmind.geoip:geoip-api:1.3.0 - https://github.com/maxmind/geoip-api-java)
|
||||||
* JHighlight (com.uwyn:jhighlight:1.0 - https://jhighlight.dev.java.net/)
|
* JHighlight (com.uwyn:jhighlight:1.0 - https://jhighlight.dev.java.net/)
|
||||||
* DSpace TM-Extractors Dependency (org.dspace.dependencies:dspace-tm-extractors:1.0.1 - http://projects.dspace.org/dspace-pom/dspace-tm-extractors)
|
|
||||||
* A Hibernate O/RM Module (org.hibernate:hibernate-core:4.2.21.Final - http://hibernate.org)
|
* A Hibernate O/RM Module (org.hibernate:hibernate-core:4.2.21.Final - http://hibernate.org)
|
||||||
* A Hibernate O/RM Module (org.hibernate:hibernate-ehcache:4.2.21.Final - http://hibernate.org)
|
* A Hibernate O/RM Module (org.hibernate:hibernate-ehcache:4.2.21.Final - http://hibernate.org)
|
||||||
* Hibernate Commons Annotations (org.hibernate.common:hibernate-commons-annotations:4.0.2.Final - http://hibernate.org)
|
* Hibernate Commons Annotations (org.hibernate.common:hibernate-commons-annotations:4.0.2.Final - http://hibernate.org)
|
||||||
|
54
README.md
54
README.md
@@ -40,6 +40,9 @@ Please be aware that, as a Java web application, DSpace requires a database (Pos
|
|||||||
and a servlet container (usually Tomcat) in order to function.
|
and a servlet container (usually Tomcat) in order to function.
|
||||||
More information about these and all other prerequisites can be found in the Installation instructions above.
|
More information about these and all other prerequisites can be found in the Installation instructions above.
|
||||||
|
|
||||||
|
## Dockerfile Usage
|
||||||
|
See the [DSpace Docker Tutorial](https://dspace-labs.github.io/DSpace-Docker-Images/).
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
DSpace is a community built and supported project. We do not have a centralized development or support team,
|
DSpace is a community built and supported project. We do not have a centralized development or support team,
|
||||||
@@ -76,6 +79,57 @@ install, upgrade, customize or host DSpace, then we recommend getting in touch w
|
|||||||
|
|
||||||
The DSpace Issue Tracker can be found at: https://jira.duraspace.org/projects/DS/summary
|
The DSpace Issue Tracker can be found at: https://jira.duraspace.org/projects/DS/summary
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
### Running Tests
|
||||||
|
|
||||||
|
By default, in DSpace, Unit Tests and Integration Tests are disabled. However, they are
|
||||||
|
run automatically by [Travis CI](https://travis-ci.org/DSpace/DSpace/) for all Pull Requests and code commits.
|
||||||
|
|
||||||
|
* How to run both Unit Tests (via `maven-surefire-plugin`) and Integration Tests (via `maven-failsafe-plugin`):
|
||||||
|
```
|
||||||
|
# NOTE: while "mvn test" runs Unit Tests,
|
||||||
|
# Integration Tests only run for "verify" or "install" phases
|
||||||
|
mvn clean install -Dmaven.test.skip=false -DskipITs=false
|
||||||
|
```
|
||||||
|
* How to run just Unit Tests:
|
||||||
|
```
|
||||||
|
mvn clean test -Dmaven.test.skip=false
|
||||||
|
```
|
||||||
|
* How to run a *single* Unit Test
|
||||||
|
```
|
||||||
|
# Run all tests in a specific test class
|
||||||
|
# NOTE: testClassName is just the class name, do not include package
|
||||||
|
mvn clean test -Dmaven.test.skip=false -Dtest=[testClassName]
|
||||||
|
|
||||||
|
# Run one test method in a specific test class
|
||||||
|
mvn clean test -Dmaven.test.skip=false -Dtest=[testClassName]#[testMethodName]
|
||||||
|
```
|
||||||
|
* How to run Integration Tests (requires running Unit tests too)
|
||||||
|
```
|
||||||
|
mvn clean verify -Dmaven.test.skip=false -DskipITs=false
|
||||||
|
```
|
||||||
|
* How to run a *single* Integration Test (requires running Unit tests too)
|
||||||
|
```
|
||||||
|
# Run all integration tests in a specific test class
|
||||||
|
# NOTE: Integration Tests only run for "verify" or "install" phases
|
||||||
|
# NOTE: testClassName is just the class name, do not include package
|
||||||
|
mvn clean verify -Dmaven.test.skip=false -DskipITs=false -Dit.test=[testClassName]
|
||||||
|
|
||||||
|
# Run one test method in a specific test class
|
||||||
|
mvn clean verify -Dmaven.test.skip=false -DskipITs=false -Dit.test=[testClassName]#[testMethodName]
|
||||||
|
```
|
||||||
|
* How to run only tests of a specific DSpace module
|
||||||
|
```
|
||||||
|
# Before you can run only one module's tests, other modules may need installing into your ~/.m2
|
||||||
|
cd [dspace-src]
|
||||||
|
mvn clean install
|
||||||
|
|
||||||
|
# Then, move into a module subdirectory, and run the test command
|
||||||
|
cd [dspace-src]/dspace-spring-rest
|
||||||
|
# Choose your test command from the lists above
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
DSpace source code is freely available under a standard [BSD 3-Clause license](https://opensource.org/licenses/BSD-3-Clause).
|
DSpace source code is freely available under a standard [BSD 3-Clause license](https://opensource.org/licenses/BSD-3-Clause).
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.dspace</groupId>
|
<groupId>org.dspace</groupId>
|
||||||
<artifactId>dspace-api</artifactId>
|
<artifactId>dspace-api</artifactId>
|
||||||
@@ -13,7 +12,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dspace</groupId>
|
<groupId>org.dspace</groupId>
|
||||||
<artifactId>dspace-parent</artifactId>
|
<artifactId>dspace-parent</artifactId>
|
||||||
<version>7.0-SNAPSHOT</version>
|
<version>7.0-preview-1</version>
|
||||||
<relativePath>..</relativePath>
|
<relativePath>..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
@@ -51,6 +50,10 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<debug>true</debug>
|
<debug>true</debug>
|
||||||
<showDeprecation>true</showDeprecation>
|
<showDeprecation>true</showDeprecation>
|
||||||
|
<compilerArguments>
|
||||||
|
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
|
||||||
|
</compilerArguments>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -81,6 +84,7 @@
|
|||||||
<exclude>**/src/test/resources/**</exclude>
|
<exclude>**/src/test/resources/**</exclude>
|
||||||
<exclude>**/src/test/data/**</exclude>
|
<exclude>**/src/test/data/**</exclude>
|
||||||
<exclude>**/.gitignore</exclude>
|
<exclude>**/.gitignore</exclude>
|
||||||
|
<exclude>**/src/main/resources/rebel.xml</exclude>
|
||||||
<exclude>src/test/data/dspaceFolder/config/spiders/**</exclude>
|
<exclude>src/test/data/dspaceFolder/config/spiders/**</exclude>
|
||||||
<exclude>src/main/java/org/apache/solr/handler/extraction/ExtractingParams.java</exclude>
|
<exclude>src/main/java/org/apache/solr/handler/extraction/ExtractingParams.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
@@ -307,6 +311,10 @@
|
|||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-ehcache</artifactId>
|
<artifactId>hibernate-ehcache</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-validator-cdi</artifactId>
|
<artifactId>hibernate-validator-cdi</artifactId>
|
||||||
@@ -334,10 +342,6 @@
|
|||||||
<groupId>org.dspace</groupId>
|
<groupId>org.dspace</groupId>
|
||||||
<artifactId>mets</artifactId>
|
<artifactId>mets</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.dspace.dependencies</groupId>
|
|
||||||
<artifactId>dspace-tm-extractors</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.jena</groupId>
|
<groupId>org.apache.jena</groupId>
|
||||||
<artifactId>apache-jena-libs</artifactId>
|
<artifactId>apache-jena-libs</artifactId>
|
||||||
@@ -351,6 +355,14 @@
|
|||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -361,10 +373,6 @@
|
|||||||
<groupId>commons-codec</groupId>
|
<groupId>commons-codec</groupId>
|
||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>commons-codec</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>commons-collections</groupId>
|
|
||||||
<artifactId>commons-collections</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-collections4</artifactId>
|
<artifactId>commons-collections4</artifactId>
|
||||||
@@ -383,8 +391,8 @@
|
|||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-lang</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
@@ -400,7 +408,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -418,8 +426,16 @@
|
|||||||
<artifactId>jdom</artifactId>
|
<artifactId>jdom</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>oro</groupId>
|
<groupId>oro</groupId>
|
||||||
@@ -532,6 +548,10 @@
|
|||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -549,6 +569,10 @@
|
|||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -562,7 +586,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.solr</groupId>
|
<groupId>org.apache.solr</groupId>
|
||||||
<artifactId>solr-solrj</artifactId>
|
<artifactId>solr-solrj</artifactId>
|
||||||
<version>${solr.version}</version>
|
<version>${solr.client.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
@@ -576,8 +600,8 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-configuration</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-configuration</artifactId>
|
<artifactId>commons-configuration2</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.maxmind.geoip2</groupId>
|
<groupId>com.maxmind.geoip2</groupId>
|
||||||
@@ -597,7 +621,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.lucene</groupId>
|
<groupId>org.apache.lucene</groupId>
|
||||||
<artifactId>lucene-core</artifactId>
|
<artifactId>lucene-core</artifactId>
|
||||||
<version>4.10.4</version>
|
<version>${solr.client.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -616,7 +640,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>19.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
@@ -719,20 +742,19 @@
|
|||||||
<groupId>joda-time</groupId>
|
<groupId>joda-time</groupId>
|
||||||
<artifactId>joda-time</artifactId>
|
<artifactId>joda-time</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- S3 also wanted jackson... -->
|
|
||||||
|
<!-- For ORCID v2 integration -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>org.dspace</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>orcid-jaxb-api</artifactId>
|
||||||
|
<version>2.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>org.json</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>json</artifactId>
|
||||||
|
<version>20180130</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ import org.apache.commons.cli.CommandLineParser;
|
|||||||
import org.apache.commons.cli.HelpFormatter;
|
import org.apache.commons.cli.HelpFormatter;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
@@ -180,14 +180,10 @@ public class CommunityFiliator {
|
|||||||
// second test - circularity: parent's parents can't include proposed
|
// second test - circularity: parent's parents can't include proposed
|
||||||
// child
|
// child
|
||||||
List<Community> parentDads = parent.getParentCommunities();
|
List<Community> parentDads = parent.getParentCommunities();
|
||||||
|
if (parentDads.contains(child)) {
|
||||||
for (int i = 0; i < parentDads.size(); i++) {
|
System.out.println("Error, circular parentage - child is parent of parent");
|
||||||
if (parentDads.get(i).getID().equals(child.getID())) {
|
|
||||||
System.out
|
|
||||||
.println("Error, circular parentage - child is parent of parent");
|
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// everthing's OK
|
// everthing's OK
|
||||||
communityService.addSubcommunity(c, parent, child);
|
communityService.addSubcommunity(c, parent, child);
|
||||||
@@ -210,26 +206,15 @@ public class CommunityFiliator {
|
|||||||
throws SQLException, AuthorizeException, IOException {
|
throws SQLException, AuthorizeException, IOException {
|
||||||
// verify that child is indeed a child of parent
|
// verify that child is indeed a child of parent
|
||||||
List<Community> parentKids = parent.getSubcommunities();
|
List<Community> parentKids = parent.getSubcommunities();
|
||||||
boolean isChild = false;
|
if (!parentKids.contains(child)) {
|
||||||
|
System.out.println("Error, child community not a child of parent community");
|
||||||
for (int i = 0; i < parentKids.size(); i++) {
|
|
||||||
if (parentKids.get(i).getID().equals(child.getID())) {
|
|
||||||
isChild = true;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isChild) {
|
|
||||||
System.out
|
|
||||||
.println("Error, child community not a child of parent community");
|
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// OK remove the mappings - but leave the community, which will become
|
// OK remove the mappings - but leave the community, which will become
|
||||||
// top-level
|
// top-level
|
||||||
child.getParentCommunities().remove(parent);
|
child.removeParentCommunity(parent);
|
||||||
parent.getSubcommunities().remove(child);
|
parent.removeSubCommunity(child);
|
||||||
communityService.update(c, child);
|
communityService.update(c, child);
|
||||||
communityService.update(c, parent);
|
communityService.update(c, parent);
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ import org.apache.commons.cli.CommandLine;
|
|||||||
import org.apache.commons.cli.CommandLineParser;
|
import org.apache.commons.cli.CommandLineParser;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.I18nUtil;
|
import org.dspace.core.I18nUtil;
|
||||||
|
@@ -21,6 +21,7 @@ import org.apache.xpath.XPathAPI;
|
|||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.NonUniqueMetadataException;
|
import org.dspace.content.NonUniqueMetadataException;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.MetadataFieldService;
|
import org.dspace.content.service.MetadataFieldService;
|
||||||
@@ -248,7 +249,7 @@ public class MetadataImporter {
|
|||||||
|
|
||||||
// If the schema is not provided default to DC
|
// If the schema is not provided default to DC
|
||||||
if (schema == null) {
|
if (schema == null) {
|
||||||
schema = MetadataSchema.DC_SCHEMA;
|
schema = MetadataSchemaEnum.DC.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
|||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.xpath.XPathAPI;
|
import org.apache.xpath.XPathAPI;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.BitstreamFormat;
|
import org.dspace.content.BitstreamFormat;
|
||||||
@@ -47,7 +47,7 @@ public class RegistryLoader {
|
|||||||
/**
|
/**
|
||||||
* log4j category
|
* log4j category
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(RegistryLoader.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(RegistryLoader.class);
|
||||||
|
|
||||||
protected static BitstreamFormatService bitstreamFormatService = ContentServiceFactory.getInstance()
|
protected static BitstreamFormatService bitstreamFormatService = ContentServiceFactory.getInstance()
|
||||||
.getBitstreamFormatService();
|
.getBitstreamFormatService();
|
||||||
|
@@ -21,8 +21,10 @@ import javax.xml.transform.TransformerException;
|
|||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.commons.cli.CommandLineParser;
|
import org.apache.commons.cli.CommandLineParser;
|
||||||
|
import org.apache.commons.cli.DefaultParser;
|
||||||
|
import org.apache.commons.cli.HelpFormatter;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.xpath.XPathAPI;
|
import org.apache.xpath.XPathAPI;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
@@ -45,6 +47,7 @@ import org.xml.sax.SAXException;
|
|||||||
* an XML file.
|
* an XML file.
|
||||||
*
|
*
|
||||||
* The XML file structure needs to be:
|
* The XML file structure needs to be:
|
||||||
|
* <p>
|
||||||
* {@code
|
* {@code
|
||||||
* <import_structure>
|
* <import_structure>
|
||||||
* <community>
|
* <community>
|
||||||
@@ -56,29 +59,31 @@ import org.xml.sax.SAXException;
|
|||||||
* </community>
|
* </community>
|
||||||
* </import_structure>
|
* </import_structure>
|
||||||
* }
|
* }
|
||||||
* it can be arbitrarily deep, and supports all the metadata elements
|
* <p>
|
||||||
|
* It can be arbitrarily deep, and supports all the metadata elements
|
||||||
* that make up the community and collection metadata. See the system
|
* that make up the community and collection metadata. See the system
|
||||||
* documentation for more details
|
* documentation for more details.
|
||||||
*
|
*
|
||||||
* @author Richard Jones
|
* @author Richard Jones
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class StructBuilder {
|
public class StructBuilder {
|
||||||
/**
|
/**
|
||||||
* the output xml document which will contain updated information about the
|
* The output XML document which will contain updated information about the
|
||||||
* imported structure
|
* imported structure.
|
||||||
*/
|
*/
|
||||||
private static org.jdom.Document xmlOutput = new org.jdom.Document(new Element("imported_structure"));
|
private static final org.jdom.Document xmlOutput
|
||||||
|
= new org.jdom.Document(new Element("imported_structure"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a hashtable to hold metadata for the collection being worked on
|
* A hash table to hold metadata for the collection being worked on.
|
||||||
*/
|
*/
|
||||||
private static Map<String, String> collectionMap = new HashMap<String, String>();
|
private static final Map<String, String> collectionMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a hashtable to hold metadata for the community being worked on
|
* A hash table to hold metadata for the community being worked on.
|
||||||
*/
|
*/
|
||||||
private static Map<String, String> communityMap = new HashMap<String, String>();
|
private static final Map<String, String> communityMap = new HashMap<>();
|
||||||
|
|
||||||
protected static CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
protected static CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
||||||
protected static CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
protected static CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
||||||
@@ -101,19 +106,34 @@ public class StructBuilder {
|
|||||||
* with the handle for each imported item added as an attribute.
|
* with the handle for each imported item added as an attribute.
|
||||||
*
|
*
|
||||||
* @param argv the command line arguments given
|
* @param argv the command line arguments given
|
||||||
* @throws Exception if an error occurs
|
* @throws ParserConfigurationException passed through.
|
||||||
|
* @throws SQLException passed through.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv)
|
public static void main(String[] argv)
|
||||||
throws Exception {
|
throws ParserConfigurationException, SQLException {
|
||||||
CommandLineParser parser = new PosixParser();
|
CommandLineParser parser = new DefaultParser();
|
||||||
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
options.addOption("f", "file", true, "file");
|
options.addOption("h", "help", false, "help");
|
||||||
|
options.addOption("?", "help");
|
||||||
|
options.addOption("f", "file", true, "input structure document");
|
||||||
options.addOption("e", "eperson", true, "eperson");
|
options.addOption("e", "eperson", true, "eperson");
|
||||||
options.addOption("o", "output", true, "output");
|
options.addOption("o", "output", true, "output structure document");
|
||||||
|
|
||||||
CommandLine line = parser.parse(options, argv);
|
CommandLine line = null;
|
||||||
|
try {
|
||||||
|
line = parser.parse(options, argv);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
System.err.println(ex.getMessage());
|
||||||
|
usage(options);
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.hasOption('h') || line.hasOption('?')) {
|
||||||
|
usage(options);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
String file = null;
|
String file = null;
|
||||||
String eperson = null;
|
String eperson = null;
|
||||||
@@ -132,22 +152,41 @@ public class StructBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (output == null || eperson == null || file == null) {
|
if (output == null || eperson == null || file == null) {
|
||||||
usage();
|
usage(options);
|
||||||
System.exit(0);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a context
|
// create a context
|
||||||
Context context = new Context();
|
Context context = new Context();
|
||||||
|
|
||||||
// set the context
|
// set the context
|
||||||
|
try {
|
||||||
context.setCurrentUser(ePersonService.findByEmail(context, eperson));
|
context.setCurrentUser(ePersonService.findByEmail(context, eperson));
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.err.format("That user could not be found: %s%n", ex.getMessage());
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// load the XML
|
// load the XML
|
||||||
Document document = loadXML(file);
|
Document document = null;
|
||||||
|
try {
|
||||||
|
document = loadXML(file);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
System.err.format("The input document could not be read: %s%n", ex.getMessage());
|
||||||
|
System.exit(1);
|
||||||
|
} catch (SAXException ex) {
|
||||||
|
System.err.format("The input document could not be parsed: %s%n", ex.getMessage());
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// run the preliminary validation, to be sure that the the XML document
|
// run the preliminary validation, to be sure that the the XML document
|
||||||
// is properly structured
|
// is properly structured
|
||||||
|
try {
|
||||||
validate(document);
|
validate(document);
|
||||||
|
} catch (TransformerException ex) {
|
||||||
|
System.err.format("The input document is invalid: %s%n", ex.getMessage());
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// load the mappings into the member variable hashmaps
|
// load the mappings into the member variable hashmaps
|
||||||
communityMap.put("name", "name");
|
communityMap.put("name", "name");
|
||||||
@@ -164,60 +203,69 @@ public class StructBuilder {
|
|||||||
collectionMap.put("license", "license");
|
collectionMap.put("license", "license");
|
||||||
collectionMap.put("provenance", "provenance_description");
|
collectionMap.put("provenance", "provenance_description");
|
||||||
|
|
||||||
|
Element[] elements = new Element[]{};
|
||||||
|
try {
|
||||||
// get the top level community list
|
// get the top level community list
|
||||||
NodeList first = XPathAPI.selectNodeList(document, "/import_structure/community");
|
NodeList first = XPathAPI.selectNodeList(document, "/import_structure/community");
|
||||||
|
|
||||||
// run the import starting with the top level communities
|
// run the import starting with the top level communities
|
||||||
Element[] elements = handleCommunities(context, first, null);
|
elements = handleCommunities(context, first, null);
|
||||||
|
} catch (TransformerException ex) {
|
||||||
|
System.err.format("Input content not understood: %s%n", ex.getMessage());
|
||||||
|
System.exit(1);
|
||||||
|
} catch (AuthorizeException ex) {
|
||||||
|
System.err.format("Not authorized: %s%n", ex.getMessage());
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// generate the output
|
// generate the output
|
||||||
Element root = xmlOutput.getRootElement();
|
Element root = xmlOutput.getRootElement();
|
||||||
for (int i = 0; i < elements.length; i++) {
|
for (Element element : elements) {
|
||||||
root.addContent(elements[i]);
|
root.addContent(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally write the string into the output file
|
// finally write the string into the output file
|
||||||
try {
|
try (BufferedWriter out = new BufferedWriter(new FileWriter(output));) {
|
||||||
BufferedWriter out = new BufferedWriter(new FileWriter(output));
|
|
||||||
out.write(new XMLOutputter().outputString(xmlOutput));
|
out.write(new XMLOutputter().outputString(xmlOutput));
|
||||||
out.close();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Unable to write to output file " + output);
|
System.out.println("Unable to write to output file " + output);
|
||||||
System.exit(0);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.complete();
|
context.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output the usage information
|
* Output the usage information.
|
||||||
*/
|
*/
|
||||||
private static void usage() {
|
private static void usage(Options options) {
|
||||||
System.out.println("Usage: java StructBuilder -f <source XML file> -o <output file> -e <eperson email>");
|
HelpFormatter helper = new HelpFormatter();
|
||||||
System.out.println(
|
helper.printHelp("java StructBuilder -f <source XML file> -o <output file> -e <eperson email>",
|
||||||
"Communities will be created from the top level, and a map of communities to handles will be returned in " +
|
"Load community/collection structure from a file.",
|
||||||
"the output file");
|
options,
|
||||||
return;
|
"Communities will be created from the top level,"
|
||||||
|
+ " and a map of communities to handles will be returned"
|
||||||
|
+ " in the output file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the XML document. This method does not return, but if validation
|
* Validate the XML document. This method returns if the document is valid.
|
||||||
* fails it generates an error and ceases execution
|
* If validation fails it generates an error and ceases execution.
|
||||||
*
|
*
|
||||||
* @param document the XML document object
|
* @param document the XML document object
|
||||||
* @throws TransformerException if transformer error
|
* @throws TransformerException if transformer error
|
||||||
*/
|
*/
|
||||||
private static void validate(org.w3c.dom.Document document)
|
private static void validate(org.w3c.dom.Document document)
|
||||||
throws TransformerException {
|
throws TransformerException {
|
||||||
StringBuffer err = new StringBuffer();
|
StringBuilder err = new StringBuilder();
|
||||||
boolean trip = false;
|
boolean trip = false;
|
||||||
|
|
||||||
err.append("The following errors were encountered parsing the source XML\n");
|
err.append("The following errors were encountered parsing the source XML.\n");
|
||||||
err.append("No changes have been made to the DSpace instance\n\n");
|
err.append("No changes have been made to the DSpace instance.\n\n");
|
||||||
|
|
||||||
NodeList first = XPathAPI.selectNodeList(document, "/import_structure/community");
|
NodeList first = XPathAPI.selectNodeList(document, "/import_structure/community");
|
||||||
if (first.getLength() == 0) {
|
if (first.getLength() == 0) {
|
||||||
err.append("-There are no top level communities in the source document");
|
err.append("-There are no top level communities in the source document.");
|
||||||
System.out.println(err.toString());
|
System.out.println(err.toString());
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
@@ -236,7 +284,7 @@ public class StructBuilder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the communities section of the XML document. This returns a string
|
* Validate the communities section of the XML document. This returns a string
|
||||||
* containing any errors encountered, or null if there were no errors
|
* containing any errors encountered, or null if there were no errors.
|
||||||
*
|
*
|
||||||
* @param communities the NodeList of communities to validate
|
* @param communities the NodeList of communities to validate
|
||||||
* @param level the level in the XML document that we are at, for the purposes
|
* @param level the level in the XML document that we are at, for the purposes
|
||||||
@@ -246,7 +294,7 @@ public class StructBuilder {
|
|||||||
*/
|
*/
|
||||||
private static String validateCommunities(NodeList communities, int level)
|
private static String validateCommunities(NodeList communities, int level)
|
||||||
throws TransformerException {
|
throws TransformerException {
|
||||||
StringBuffer err = new StringBuffer();
|
StringBuilder err = new StringBuilder();
|
||||||
boolean trip = false;
|
boolean trip = false;
|
||||||
String errs = null;
|
String errs = null;
|
||||||
|
|
||||||
@@ -255,8 +303,9 @@ public class StructBuilder {
|
|||||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||||
if (name.getLength() != 1) {
|
if (name.getLength() != 1) {
|
||||||
String pos = Integer.toString(i + 1);
|
String pos = Integer.toString(i + 1);
|
||||||
err.append("-The level " + level + " community in position " + pos);
|
err.append("-The level ").append(level)
|
||||||
err.append(" does not contain exactly one name field\n");
|
.append(" community in position ").append(pos)
|
||||||
|
.append(" does not contain exactly one name field.\n");
|
||||||
trip = true;
|
trip = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,7 +335,7 @@ public class StructBuilder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* validate the collection section of the XML document. This generates a
|
* validate the collection section of the XML document. This generates a
|
||||||
* string containing any errors encountered, or returns null if no errors
|
* string containing any errors encountered, or returns null if no errors.
|
||||||
*
|
*
|
||||||
* @param collections a NodeList of collections to validate
|
* @param collections a NodeList of collections to validate
|
||||||
* @param level the level in the XML document for the purposes of error reporting
|
* @param level the level in the XML document for the purposes of error reporting
|
||||||
@@ -294,7 +343,7 @@ public class StructBuilder {
|
|||||||
*/
|
*/
|
||||||
private static String validateCollections(NodeList collections, int level)
|
private static String validateCollections(NodeList collections, int level)
|
||||||
throws TransformerException {
|
throws TransformerException {
|
||||||
StringBuffer err = new StringBuffer();
|
StringBuilder err = new StringBuilder();
|
||||||
boolean trip = false;
|
boolean trip = false;
|
||||||
String errs = null;
|
String errs = null;
|
||||||
|
|
||||||
@@ -303,8 +352,9 @@ public class StructBuilder {
|
|||||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||||
if (name.getLength() != 1) {
|
if (name.getLength() != 1) {
|
||||||
String pos = Integer.toString(i + 1);
|
String pos = Integer.toString(i + 1);
|
||||||
err.append("-The level " + level + " collection in position " + pos);
|
err.append("-The level ").append(level)
|
||||||
err.append(" does not contain exactly one name field\n");
|
.append(" collection in position ").append(pos)
|
||||||
|
.append(" does not contain exactly one name field.\n");
|
||||||
trip = true;
|
trip = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -363,7 +413,7 @@ public class StructBuilder {
|
|||||||
* created communities (e.g. the handles they have been assigned)
|
* created communities (e.g. the handles they have been assigned)
|
||||||
*/
|
*/
|
||||||
private static Element[] handleCommunities(Context context, NodeList communities, Community parent)
|
private static Element[] handleCommunities(Context context, NodeList communities, Community parent)
|
||||||
throws TransformerException, SQLException, Exception {
|
throws TransformerException, SQLException, AuthorizeException {
|
||||||
Element[] elements = new Element[communities.getLength()];
|
Element[] elements = new Element[communities.getLength()];
|
||||||
|
|
||||||
for (int i = 0; i < communities.getLength(); i++) {
|
for (int i = 0; i < communities.getLength(); i++) {
|
||||||
@@ -390,12 +440,10 @@ public class StructBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: at the moment, if the community already exists by name
|
// FIXME: at the moment, if the community already exists by name
|
||||||
// then this will throw a PSQLException on a duplicate key
|
// then this will throw an SQLException on a duplicate key
|
||||||
// violation
|
// violation.
|
||||||
// Ideally we'd skip this row and continue to create sub
|
// Ideally we'd skip this row and continue to create sub communities
|
||||||
// communities
|
// and so forth where they don't exist, but it's proving difficult
|
||||||
// and so forth where they don't exist, but it's proving
|
|
||||||
// difficult
|
|
||||||
// to isolate the community that already exists without hitting
|
// to isolate the community that already exists without hitting
|
||||||
// the database directly.
|
// the database directly.
|
||||||
communityService.update(context, community);
|
communityService.update(context, community);
|
||||||
@@ -470,7 +518,7 @@ public class StructBuilder {
|
|||||||
* created collections (e.g. the handle)
|
* created collections (e.g. the handle)
|
||||||
*/
|
*/
|
||||||
private static Element[] handleCollections(Context context, NodeList collections, Community parent)
|
private static Element[] handleCollections(Context context, NodeList collections, Community parent)
|
||||||
throws TransformerException, SQLException, AuthorizeException, IOException, Exception {
|
throws TransformerException, SQLException, AuthorizeException {
|
||||||
Element[] elements = new Element[collections.getLength()];
|
Element[] elements = new Element[collections.getLength()];
|
||||||
|
|
||||||
for (int i = 0; i < collections.getLength(); i++) {
|
for (int i = 0; i < collections.getLength(); i++) {
|
||||||
|
@@ -27,6 +27,7 @@ import java.util.UUID;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.authority.AuthorityValue;
|
import org.dspace.authority.AuthorityValue;
|
||||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||||
import org.dspace.authority.service.AuthorityValueService;
|
import org.dspace.authority.service.AuthorityValueService;
|
||||||
@@ -34,6 +35,7 @@ import org.dspace.content.Collection;
|
|||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.authority.Choices;
|
import org.dspace.content.authority.Choices;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
@@ -198,10 +200,12 @@ public class DSpaceCSV implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check that the scheme exists
|
// Check that the scheme exists
|
||||||
|
if (!StringUtils.equals(metadataSchema, MetadataSchemaEnum.RELATION.getName())) {
|
||||||
MetadataSchema foundSchema = metadataSchemaService.find(c, metadataSchema);
|
MetadataSchema foundSchema = metadataSchemaService.find(c, metadataSchema);
|
||||||
if (foundSchema == null) {
|
if (foundSchema == null) {
|
||||||
throw new MetadataImportInvalidHeadingException(clean[0],
|
throw new MetadataImportInvalidHeadingException(clean[0],
|
||||||
MetadataImportInvalidHeadingException.SCHEMA,
|
MetadataImportInvalidHeadingException
|
||||||
|
.SCHEMA,
|
||||||
columnCounter);
|
columnCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,9 +214,11 @@ public class DSpaceCSV implements Serializable {
|
|||||||
.findByElement(c, foundSchema, metadataElement, metadataQualifier);
|
.findByElement(c, foundSchema, metadataElement, metadataQualifier);
|
||||||
if (foundField == null) {
|
if (foundField == null) {
|
||||||
throw new MetadataImportInvalidHeadingException(clean[0],
|
throw new MetadataImportInvalidHeadingException(clean[0],
|
||||||
MetadataImportInvalidHeadingException.ELEMENT,
|
MetadataImportInvalidHeadingException
|
||||||
|
.ELEMENT,
|
||||||
columnCounter);
|
columnCounter);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Store the heading
|
// Store the heading
|
||||||
headings.add(authorityPrefix + element);
|
headings.add(authorityPrefix + element);
|
||||||
|
@@ -15,6 +15,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -25,22 +26,31 @@ import org.apache.commons.cli.HelpFormatter;
|
|||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.authority.AuthorityValue;
|
import org.dspace.authority.AuthorityValue;
|
||||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||||
import org.dspace.authority.service.AuthorityValueService;
|
import org.dspace.authority.service.AuthorityValueService;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
|
import org.dspace.content.Entity;
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
|
import org.dspace.content.Relationship;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.authority.Choices;
|
import org.dspace.content.authority.Choices;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
|
import org.dspace.content.service.EntityService;
|
||||||
|
import org.dspace.content.service.EntityTypeService;
|
||||||
import org.dspace.content.service.InstallItemService;
|
import org.dspace.content.service.InstallItemService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.content.service.RelationshipService;
|
||||||
|
import org.dspace.content.service.RelationshipTypeService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
@@ -50,6 +60,7 @@ import org.dspace.eperson.EPerson;
|
|||||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||||
import org.dspace.handle.factory.HandleServiceFactory;
|
import org.dspace.handle.factory.HandleServiceFactory;
|
||||||
import org.dspace.handle.service.HandleService;
|
import org.dspace.handle.service.HandleService;
|
||||||
|
import org.dspace.util.UUIDUtils;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
import org.dspace.workflow.WorkflowItem;
|
||||||
import org.dspace.workflow.WorkflowService;
|
import org.dspace.workflow.WorkflowService;
|
||||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||||
@@ -92,7 +103,7 @@ public class MetadataImport {
|
|||||||
/**
|
/**
|
||||||
* Logger
|
* Logger
|
||||||
*/
|
*/
|
||||||
protected static final Logger log = Logger.getLogger(MetadataImport.class);
|
protected static final Logger log = org.apache.logging.log4j.LogManager.getLogger(MetadataImport.class);
|
||||||
|
|
||||||
protected final AuthorityValueService authorityValueService;
|
protected final AuthorityValueService authorityValueService;
|
||||||
|
|
||||||
@@ -101,6 +112,10 @@ public class MetadataImport {
|
|||||||
protected final CollectionService collectionService;
|
protected final CollectionService collectionService;
|
||||||
protected final HandleService handleService;
|
protected final HandleService handleService;
|
||||||
protected final WorkspaceItemService workspaceItemService;
|
protected final WorkspaceItemService workspaceItemService;
|
||||||
|
protected final RelationshipTypeService relationshipTypeService;
|
||||||
|
protected final RelationshipService relationshipService;
|
||||||
|
protected final EntityTypeService entityTypeService;
|
||||||
|
protected final EntityService entityService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of the metadata importer. Requires a context and an array of CSV lines
|
* Create an instance of the metadata importer. Requires a context and an array of CSV lines
|
||||||
@@ -120,6 +135,10 @@ public class MetadataImport {
|
|||||||
handleService = HandleServiceFactory.getInstance().getHandleService();
|
handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||||
authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
|
authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
|
||||||
workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
|
workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
|
||||||
|
relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
||||||
|
relationshipTypeService = ContentServiceFactory.getInstance().getRelationshipTypeService();
|
||||||
|
entityTypeService = ContentServiceFactory.getInstance().getEntityTypeService();
|
||||||
|
entityService = ContentServiceFactory.getInstance().getEntityService();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -336,7 +355,17 @@ public class MetadataImport {
|
|||||||
item = wsItem.getItem();
|
item = wsItem.getItem();
|
||||||
|
|
||||||
// Add the metadata to the item
|
// Add the metadata to the item
|
||||||
|
List<BulkEditMetadataValue> relationships = new LinkedList<>();
|
||||||
for (BulkEditMetadataValue dcv : whatHasChanged.getAdds()) {
|
for (BulkEditMetadataValue dcv : whatHasChanged.getAdds()) {
|
||||||
|
if (StringUtils.equals(dcv.getSchema(), MetadataSchemaEnum.RELATION.getName())) {
|
||||||
|
|
||||||
|
if (!StringUtils.equals(dcv.getElement(), "type")) {
|
||||||
|
relationships.add(dcv);
|
||||||
|
} else {
|
||||||
|
handleRelationshipMetadataValueFromBulkEditMetadataValue(item, dcv);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
itemService.addMetadata(c, item, dcv.getSchema(),
|
itemService.addMetadata(c, item, dcv.getSchema(),
|
||||||
dcv.getElement(),
|
dcv.getElement(),
|
||||||
dcv.getQualifier(),
|
dcv.getQualifier(),
|
||||||
@@ -345,7 +374,11 @@ public class MetadataImport {
|
|||||||
dcv.getAuthority(),
|
dcv.getAuthority(),
|
||||||
dcv.getConfidence());
|
dcv.getConfidence());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BulkEditMetadataValue relationship : relationships) {
|
||||||
|
handleRelationshipMetadataValueFromBulkEditMetadataValue(item, relationship);
|
||||||
|
}
|
||||||
// Should the workflow be used?
|
// Should the workflow be used?
|
||||||
if (useWorkflow) {
|
if (useWorkflow) {
|
||||||
WorkflowService workflowService = WorkflowServiceFactory.getInstance().getWorkflowService();
|
WorkflowService workflowService = WorkflowServiceFactory.getInstance().getWorkflowService();
|
||||||
@@ -396,6 +429,27 @@ public class MetadataImport {
|
|||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This metod handles the BulkEditMetadataValue objects that correspond to Relationship metadatavalues
|
||||||
|
* @param item The item to which this metadatavalue will belong
|
||||||
|
* @param dcv The BulkEditMetadataValue to be processed
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
*/
|
||||||
|
private void handleRelationshipMetadataValueFromBulkEditMetadataValue(Item item, BulkEditMetadataValue dcv)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
LinkedList<String> values = new LinkedList<>();
|
||||||
|
values.add(dcv.getValue());
|
||||||
|
LinkedList<String> authorities = new LinkedList<>();
|
||||||
|
authorities.add(dcv.getAuthority());
|
||||||
|
LinkedList<Integer> confidences = new LinkedList<>();
|
||||||
|
confidences.add(dcv.getConfidence());
|
||||||
|
handleRelationMetadata(c, item, dcv.getSchema(), dcv.getElement(),
|
||||||
|
dcv.getQualifier(),
|
||||||
|
dcv.getLanguage(), values, authorities, confidences);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare an item metadata with a line from CSV, and optionally update the item
|
* Compare an item metadata with a line from CSV, and optionally update the item
|
||||||
*
|
*
|
||||||
@@ -583,9 +637,251 @@ public class MetadataImport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set those values
|
|
||||||
|
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName())) {
|
||||||
|
List<RelationshipType> relationshipTypeList = relationshipTypeService
|
||||||
|
.findByLeftOrRightLabel(c, element);
|
||||||
|
for (RelationshipType relationshipType : relationshipTypeList) {
|
||||||
|
for (Relationship relationship : relationshipService
|
||||||
|
.findByItemAndRelationshipType(c, item, relationshipType)) {
|
||||||
|
relationshipService.delete(c, relationship);
|
||||||
|
relationshipService.update(c, relationship);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handleRelationMetadata(c, item, schema, element, qualifier, language, values, authorities, confidences);
|
||||||
|
} else {
|
||||||
itemService.clearMetadata(c, item, schema, element, qualifier, language);
|
itemService.clearMetadata(c, item, schema, element, qualifier, language);
|
||||||
itemService.addMetadata(c, item, schema, element, qualifier, language, values, authorities, confidences);
|
itemService.addMetadata(c, item, schema, element, qualifier,
|
||||||
|
language, values, authorities, confidences);
|
||||||
|
itemService.update(c, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method decides whether the metadatavalue is of type relation.type or if it corresponds to
|
||||||
|
* a relationship and handles it accordingly to their respective methods
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param item The item to which this metadatavalue belongs to
|
||||||
|
* @param schema The schema for the metadatavalue
|
||||||
|
* @param element The element for the metadatavalue
|
||||||
|
* @param qualifier The qualifier for the metadatavalue
|
||||||
|
* @param language The language for the metadatavalue
|
||||||
|
* @param values The values for the metadatavalue
|
||||||
|
* @param authorities The authorities for the metadatavalue
|
||||||
|
* @param confidences The confidences for the metadatavalue
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
*/
|
||||||
|
private void handleRelationMetadata(Context c, Item item, String schema, String element, String qualifier,
|
||||||
|
String language, List<String> values, List<String> authorities,
|
||||||
|
List<Integer> confidences) throws SQLException, AuthorizeException {
|
||||||
|
|
||||||
|
if (StringUtils.equals(element, "type") && StringUtils.isBlank(qualifier)) {
|
||||||
|
handleRelationTypeMetadata(c, item, schema, element, qualifier, language, values, authorities, confidences);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for (String value : values) {
|
||||||
|
handleRelationOtherMetadata(c, item, element, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method takes the item, element and values to determine what relationships should be built
|
||||||
|
* for these parameters and calls on the method to construct them
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param item The item that the relationships will be made for
|
||||||
|
* @param element The string determining which relationshiptype is to be used
|
||||||
|
* @param value The value for the relationship
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
*/
|
||||||
|
private void handleRelationOtherMetadata(Context c, Item item, String element, String value)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
Entity entity = entityService.findByItemId(c, item.getID());
|
||||||
|
boolean left = false;
|
||||||
|
List<RelationshipType> acceptableRelationshipTypes = new LinkedList<>();
|
||||||
|
String url = handleService.resolveToURL(c, value);
|
||||||
|
UUID uuid = UUIDUtils.fromString(value);
|
||||||
|
if (uuid == null && StringUtils.isNotBlank(url)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity relationEntity = entityService.findByItemId(c, uuid);
|
||||||
|
|
||||||
|
|
||||||
|
List<RelationshipType> leftRelationshipTypesForEntity = entityService.getLeftRelationshipTypes(c, entity);
|
||||||
|
List<RelationshipType> rightRelationshipTypesForEntity = entityService.getRightRelationshipTypes(c, entity);
|
||||||
|
|
||||||
|
for (RelationshipType relationshipType : entityService.getAllRelationshipTypes(c, entity)) {
|
||||||
|
if (StringUtils.equalsIgnoreCase(relationshipType.getLeftLabel(), element)) {
|
||||||
|
left = handleLeftLabelEqualityRelationshipTypeElement(c, entity, relationEntity, left,
|
||||||
|
acceptableRelationshipTypes,
|
||||||
|
leftRelationshipTypesForEntity,
|
||||||
|
relationshipType);
|
||||||
|
} else if (StringUtils.equalsIgnoreCase(relationshipType.getRightLabel(), element)) {
|
||||||
|
left = handleRightLabelEqualityRelationshipTypeElement(c, entity, relationEntity, left,
|
||||||
|
acceptableRelationshipTypes,
|
||||||
|
rightRelationshipTypesForEntity,
|
||||||
|
relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (acceptableRelationshipTypes.size() > 1) {
|
||||||
|
log.error("Ambiguous relationship_types were found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (acceptableRelationshipTypes.size() == 0) {
|
||||||
|
log.error("no relationship_types were found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//There is exactly one
|
||||||
|
buildRelationObject(c, item, value, left, acceptableRelationshipTypes.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method creates the relationship for the item and stores it in the database
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param item The item for which this relationship will be constructed
|
||||||
|
* @param value The value for the relationship
|
||||||
|
* @param left A boolean indicating whether the item is the leftItem or the rightItem
|
||||||
|
* @param acceptedRelationshipType The acceptable relationship type
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
*/
|
||||||
|
private void buildRelationObject(Context c, Item item, String value, boolean left,
|
||||||
|
RelationshipType acceptedRelationshipType)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
Item leftItem = null;
|
||||||
|
Item rightItem = null;
|
||||||
|
if (left) {
|
||||||
|
leftItem = item;
|
||||||
|
rightItem = itemService.findByIdOrLegacyId(c, value);
|
||||||
|
} else {
|
||||||
|
rightItem = item;
|
||||||
|
leftItem = itemService.findByIdOrLegacyId(c, value);
|
||||||
|
}
|
||||||
|
RelationshipType relationshipType = acceptedRelationshipType;
|
||||||
|
int leftPlace = relationshipService.findLeftPlaceByLeftItem(c, leftItem) + 1;
|
||||||
|
int rightPlace = relationshipService.findRightPlaceByRightItem(c, rightItem) + 1;
|
||||||
|
Relationship persistedRelationship = relationshipService.create(c, leftItem, rightItem,
|
||||||
|
relationshipType, leftPlace, rightPlace);
|
||||||
|
relationshipService.update(c, persistedRelationship);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will add RelationshipType objects to the acceptableRelationshipTypes list
|
||||||
|
* if applicable and valid RelationshipType objects are found. It will also return a boolean indicating
|
||||||
|
* whether we're dealing with a left Relationship or not
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param entity The Entity for which the RelationshipType has to be checked
|
||||||
|
* @param relationEntity The other Entity of the Relationship
|
||||||
|
* @param left Boolean indicating whether the Relationship is left or not
|
||||||
|
* @param acceptableRelationshipTypes The list of RelationshipType objects that will be added to
|
||||||
|
* @param rightRelationshipTypesForEntity The list of RelationshipType objects that are possible
|
||||||
|
* for the right entity
|
||||||
|
* @param relationshipType The RelationshipType object that we want to check whether it's
|
||||||
|
* valid to be added or not
|
||||||
|
* @return A boolean indicating whether the relationship is left or right, will
|
||||||
|
* be false in this case
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
private boolean handleRightLabelEqualityRelationshipTypeElement(Context c, Entity entity, Entity relationEntity,
|
||||||
|
boolean left,
|
||||||
|
List<RelationshipType> acceptableRelationshipTypes,
|
||||||
|
List<RelationshipType>
|
||||||
|
rightRelationshipTypesForEntity,
|
||||||
|
RelationshipType relationshipType)
|
||||||
|
throws SQLException {
|
||||||
|
if (StringUtils.equalsIgnoreCase(entityService.getType(c, entity).getLabel(),
|
||||||
|
relationshipType.getRightType().getLabel()) &&
|
||||||
|
StringUtils.equalsIgnoreCase(entityService.getType(c, relationEntity).getLabel(),
|
||||||
|
relationshipType.getLeftType().getLabel())) {
|
||||||
|
|
||||||
|
for (RelationshipType rightRelationshipType : rightRelationshipTypesForEntity) {
|
||||||
|
if (StringUtils.equalsIgnoreCase(rightRelationshipType.getLeftType().getLabel(),
|
||||||
|
relationshipType.getLeftType().getLabel()) ||
|
||||||
|
StringUtils.equalsIgnoreCase(rightRelationshipType.getRightType().getLabel(),
|
||||||
|
relationshipType.getLeftType().getLabel())) {
|
||||||
|
left = false;
|
||||||
|
acceptableRelationshipTypes.add(relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will add RelationshipType objects to the acceptableRelationshipTypes list
|
||||||
|
* if applicable and valid RelationshipType objects are found. It will also return a boolean indicating
|
||||||
|
* whether we're dealing with a left Relationship or not
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param entity The Entity for which the RelationshipType has to be checked
|
||||||
|
* @param relationEntity The other Entity of the Relationship
|
||||||
|
* @param left Boolean indicating whether the Relationship is left or not
|
||||||
|
* @param acceptableRelationshipTypes The list of RelationshipType objects that will be added to
|
||||||
|
* @param leftRelationshipTypesForEntity The list of RelationshipType objects that are possible
|
||||||
|
* for the left entity
|
||||||
|
* @param relationshipType The RelationshipType object that we want to check whether it's
|
||||||
|
* valid to be added or not
|
||||||
|
* @return A boolean indicating whether the relationship is left or right, will
|
||||||
|
* be true in this case
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
*/
|
||||||
|
private boolean handleLeftLabelEqualityRelationshipTypeElement(Context c, Entity entity, Entity relationEntity,
|
||||||
|
boolean left,
|
||||||
|
List<RelationshipType> acceptableRelationshipTypes,
|
||||||
|
List<RelationshipType>
|
||||||
|
leftRelationshipTypesForEntity,
|
||||||
|
RelationshipType relationshipType)
|
||||||
|
throws SQLException {
|
||||||
|
if (StringUtils.equalsIgnoreCase(entityService.getType(c, entity).getLabel(),
|
||||||
|
relationshipType.getLeftType().getLabel()) &&
|
||||||
|
StringUtils.equalsIgnoreCase(entityService.getType(c, relationEntity).getLabel(),
|
||||||
|
relationshipType.getRightType().getLabel())) {
|
||||||
|
for (RelationshipType leftRelationshipType : leftRelationshipTypesForEntity) {
|
||||||
|
if (StringUtils.equalsIgnoreCase(leftRelationshipType.getRightType().getLabel(),
|
||||||
|
relationshipType.getRightType().getLabel()) ||
|
||||||
|
StringUtils.equalsIgnoreCase(leftRelationshipType.getLeftType().getLabel(),
|
||||||
|
relationshipType.getRightType().getLabel())) {
|
||||||
|
left = true;
|
||||||
|
acceptableRelationshipTypes.add(relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will add the relationship.type metadata to the item if an EntityType can be found for the value in
|
||||||
|
* the values list.
|
||||||
|
* @param c The relevant DSpace context
|
||||||
|
* @param item The item to which this metadatavalue will be added
|
||||||
|
* @param schema The schema for the metadatavalue to be added
|
||||||
|
* @param element The element for the metadatavalue to be added
|
||||||
|
* @param qualifier The qualifier for the metadatavalue to be added
|
||||||
|
* @param language The language for the metadatavalue to be added
|
||||||
|
* @param values The value on which we'll search for EntityType object and it's the value
|
||||||
|
* for the metadatavalue that will be created
|
||||||
|
* @param authorities The authority for the metadatavalue. This will be filled with the ID
|
||||||
|
* of the found EntityType for the value if it exists
|
||||||
|
* @param confidences The confidence for the metadatavalue
|
||||||
|
* @throws SQLException If something goes wrong
|
||||||
|
* @throws AuthorizeException If something goes wrong
|
||||||
|
*/
|
||||||
|
private void handleRelationTypeMetadata(Context c, Item item, String schema, String element, String qualifier,
|
||||||
|
String language, List<String> values, List<String> authorities,
|
||||||
|
List<Integer> confidences)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
EntityType entityType = entityTypeService.findByEntityType(c, values.get(0));
|
||||||
|
if (entityType != null) {
|
||||||
|
authorities.add(String.valueOf(entityType.getID()));
|
||||||
|
itemService.clearMetadata(c, item, schema, element, qualifier, language);
|
||||||
|
itemService.addMetadata(c, item, schema, element, qualifier, language,
|
||||||
|
values, authorities, confidences);
|
||||||
itemService.update(c, item);
|
itemService.update(c, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,8 @@ import org.apache.commons.cli.OptionBuilder;
|
|||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.checker.BitstreamDispatcher;
|
import org.dspace.checker.BitstreamDispatcher;
|
||||||
import org.dspace.checker.CheckerCommand;
|
import org.dspace.checker.CheckerCommand;
|
||||||
import org.dspace.checker.HandleDispatcher;
|
import org.dspace.checker.HandleDispatcher;
|
||||||
@@ -48,7 +49,7 @@ import org.dspace.core.Utils;
|
|||||||
* @author Nathan Sarr
|
* @author Nathan Sarr
|
||||||
*/
|
*/
|
||||||
public final class ChecksumChecker {
|
public final class ChecksumChecker {
|
||||||
private static final Logger LOG = Logger.getLogger(ChecksumChecker.class);
|
private static final Logger LOG = LogManager.getLogger(ChecksumChecker.class);
|
||||||
|
|
||||||
private static final BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
|
private static final BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
|
||||||
|
|
||||||
|
@@ -32,8 +32,8 @@ import java.util.zip.ZipEntry;
|
|||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.itemexport.service.ItemExportService;
|
import org.dspace.app.itemexport.service.ItemExportService;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
@@ -42,7 +42,7 @@ import org.dspace.content.Community;
|
|||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
@@ -98,7 +98,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
|||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
*/
|
*/
|
||||||
private Logger log = Logger.getLogger(ItemExportServiceImpl.class);
|
private Logger log = org.apache.logging.log4j.LogManager.getLogger(ItemExportServiceImpl.class);
|
||||||
|
|
||||||
protected ItemExportServiceImpl() {
|
protected ItemExportServiceImpl() {
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
|||||||
protected void writeMetadata(Context c, String schema, Item i,
|
protected void writeMetadata(Context c, String schema, Item i,
|
||||||
File destDir, boolean migrate) throws Exception {
|
File destDir, boolean migrate) throws Exception {
|
||||||
String filename;
|
String filename;
|
||||||
if (schema.equals(MetadataSchema.DC_SCHEMA)) {
|
if (schema.equals(MetadataSchemaEnum.DC.getName())) {
|
||||||
filename = "dublin_core.xml";
|
filename = "dublin_core.xml";
|
||||||
} else {
|
} else {
|
||||||
filename = "metadata_" + schema + ".xml";
|
filename = "metadata_" + schema + ".xml";
|
||||||
@@ -271,9 +271,8 @@ public class ItemExportServiceImpl implements ItemExportService {
|
|||||||
("date".equals(metadataField.getElement()) && "accessioned".equals(qualifier)) ||
|
("date".equals(metadataField.getElement()) && "accessioned".equals(qualifier)) ||
|
||||||
("date".equals(metadataField.getElement()) && "available".equals(qualifier)) ||
|
("date".equals(metadataField.getElement()) && "available".equals(qualifier)) ||
|
||||||
("identifier".equals(metadataField.getElement()) && "uri".equals(qualifier) &&
|
("identifier".equals(metadataField.getElement()) && "uri".equals(qualifier) &&
|
||||||
(dcv.getValue() != null && dcv.getValue().startsWith("http://hdl.handle.net/" +
|
(dcv.getValue() != null && dcv.getValue().startsWith(
|
||||||
handleService
|
handleService.getCanonicalPrefix() + handleService.getPrefix() + "/"))) ||
|
||||||
.getPrefix() + "/"))) ||
|
|
||||||
("description".equals(metadataField.getElement()) && "provenance".equals(qualifier)) ||
|
("description".equals(metadataField.getElement()) && "provenance".equals(qualifier)) ||
|
||||||
("format".equals(metadataField.getElement()) && "extent".equals(qualifier)) ||
|
("format".equals(metadataField.getElement()) && "extent".equals(qualifier)) ||
|
||||||
("format".equals(metadataField.getElement()) && "mimetype".equals(qualifier))))) {
|
("format".equals(metadataField.getElement()) && "mimetype".equals(qualifier))))) {
|
||||||
@@ -547,7 +546,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
|||||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||||
for (Bitstream bitstream : bitstreams) {
|
for (Bitstream bitstream : bitstreams) {
|
||||||
// add up the size
|
// add up the size
|
||||||
size += bitstream.getSize();
|
size += bitstream.getSizeBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
items.add(item.getID());
|
items.add(item.getID());
|
||||||
@@ -574,7 +573,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
|||||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||||
for (Bitstream bitstream : bitstreams) {
|
for (Bitstream bitstream : bitstreams) {
|
||||||
// add up the size
|
// add up the size
|
||||||
size += bitstream.getSize();
|
size += bitstream.getSizeBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
items.add(item.getID());
|
items.add(item.getID());
|
||||||
@@ -593,7 +592,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
|||||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||||
for (Bitstream bitstream : bitstreams) {
|
for (Bitstream bitstream : bitstreams) {
|
||||||
// add up the size
|
// add up the size
|
||||||
size += bitstream.getSize();
|
size += bitstream.getSizeBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArrayList<UUID> items = new ArrayList<>();
|
ArrayList<UUID> items = new ArrayList<>();
|
||||||
|
@@ -52,13 +52,13 @@ import gr.ekt.bte.core.TransformationSpec;
|
|||||||
import gr.ekt.bte.dataloader.FileDataLoader;
|
import gr.ekt.bte.dataloader.FileDataLoader;
|
||||||
import gr.ekt.bteio.generators.DSpaceOutputGenerator;
|
import gr.ekt.bteio.generators.DSpaceOutputGenerator;
|
||||||
import gr.ekt.bteio.loaders.OAIPMHDataLoader;
|
import gr.ekt.bteio.loaders.OAIPMHDataLoader;
|
||||||
import org.apache.commons.collections.ComparatorUtils;
|
import org.apache.commons.collections4.ComparatorUtils;
|
||||||
import org.apache.commons.io.FileDeleteStrategy;
|
import org.apache.commons.io.FileDeleteStrategy;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.xpath.XPathAPI;
|
import org.apache.xpath.XPathAPI;
|
||||||
import org.dspace.app.itemimport.service.ItemImportService;
|
import org.dspace.app.itemimport.service.ItemImportService;
|
||||||
import org.dspace.app.util.LocalSchemaFilenameFilter;
|
import org.dspace.app.util.LocalSchemaFilenameFilter;
|
||||||
@@ -74,6 +74,7 @@ import org.dspace.content.DSpaceObject;
|
|||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.service.BitstreamFormatService;
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
@@ -124,7 +125,7 @@ import org.xml.sax.SAXException;
|
|||||||
* allow the registration of files (bitstreams) into DSpace.
|
* allow the registration of files (bitstreams) into DSpace.
|
||||||
*/
|
*/
|
||||||
public class ItemImportServiceImpl implements ItemImportService, InitializingBean {
|
public class ItemImportServiceImpl implements ItemImportService, InitializingBean {
|
||||||
private final Logger log = Logger.getLogger(ItemImportServiceImpl.class);
|
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(ItemImportServiceImpl.class);
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected AuthorizeService authorizeService;
|
protected AuthorizeService authorizeService;
|
||||||
@@ -677,7 +678,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
|||||||
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem(
|
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem(
|
||||||
"schema");
|
"schema");
|
||||||
if (schemaAttr == null) {
|
if (schemaAttr == null) {
|
||||||
schema = MetadataSchema.DC_SCHEMA;
|
schema = MetadataSchemaEnum.DC.getName();
|
||||||
} else {
|
} else {
|
||||||
schema = schemaAttr.getNodeValue();
|
schema = schemaAttr.getNodeValue();
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ import javax.xml.transform.TransformerConfigurationException;
|
|||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
import javax.xml.transform.TransformerFactory;
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.util.LocalSchemaFilenameFilter;
|
import org.dspace.app.util.LocalSchemaFilenameFilter;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
@@ -47,7 +47,7 @@ import org.w3c.dom.Document;
|
|||||||
* Encapsulates the Item in the context of the DSpace Archive Format
|
* Encapsulates the Item in the context of the DSpace Archive Format
|
||||||
*/
|
*/
|
||||||
public class ItemArchive {
|
public class ItemArchive {
|
||||||
private static final Logger log = Logger.getLogger(ItemArchive.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(ItemArchive.class);
|
||||||
|
|
||||||
public static final String DUBLIN_CORE_XML = "dublin_core.xml";
|
public static final String DUBLIN_CORE_XML = "dublin_core.xml";
|
||||||
|
|
||||||
|
@@ -31,11 +31,12 @@ import org.apache.commons.cli.PosixParser;
|
|||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.ConfigurationManager;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||||
import org.dspace.eperson.service.EPersonService;
|
import org.dspace.eperson.service.EPersonService;
|
||||||
|
import org.dspace.handle.factory.HandleServiceFactory;
|
||||||
|
import org.dspace.handle.service.HandleService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides some batch editing capabilities for items in DSpace:
|
* Provides some batch editing capabilities for items in DSpace:
|
||||||
@@ -78,6 +79,7 @@ public class ItemUpdate {
|
|||||||
|
|
||||||
protected static final EPersonService epersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
protected static final EPersonService epersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||||
protected static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
protected static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||||
|
protected static final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filterAliases.put("ORIGINAL", "org.dspace.app.itemupdate.OriginalBitstreamFilter");
|
filterAliases.put("ORIGINAL", "org.dspace.app.itemupdate.OriginalBitstreamFilter");
|
||||||
@@ -330,10 +332,7 @@ public class ItemUpdate {
|
|||||||
iu.setEPerson(context, iu.eperson);
|
iu.setEPerson(context, iu.eperson);
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
HANDLE_PREFIX = ConfigurationManager.getProperty("handle.canonical.prefix");
|
HANDLE_PREFIX = handleService.getCanonicalPrefix();
|
||||||
if (HANDLE_PREFIX == null || HANDLE_PREFIX.length() == 0) {
|
|
||||||
HANDLE_PREFIX = "http://hdl.handle.net/";
|
|
||||||
}
|
|
||||||
|
|
||||||
iu.processArchive(context, sourcedir, itemField, metadataIndexName, alterProvenance, isTest);
|
iu.processArchive(context, sourcedir, itemField, metadataIndexName, alterProvenance, isTest);
|
||||||
|
|
||||||
|
@@ -28,12 +28,13 @@ import javax.xml.transform.TransformerException;
|
|||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.xpath.XPathAPI;
|
import org.apache.xpath.XPathAPI;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
@@ -189,7 +190,7 @@ public class MetadataUtilities {
|
|||||||
NodeList metadata = XPathAPI.selectNodeList(document, "/dublin_core");
|
NodeList metadata = XPathAPI.selectNodeList(document, "/dublin_core");
|
||||||
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem("schema");
|
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem("schema");
|
||||||
if (schemaAttr == null) {
|
if (schemaAttr == null) {
|
||||||
schema = MetadataSchema.DC_SCHEMA;
|
schema = MetadataSchemaEnum.DC.getName();
|
||||||
} else {
|
} else {
|
||||||
schema = schemaAttr.getNodeValue();
|
schema = schemaAttr.getNodeValue();
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@ import java.io.InputStream;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.poi.POITextExtractor;
|
import org.apache.poi.POITextExtractor;
|
||||||
import org.apache.poi.extractor.ExtractorFactory;
|
import org.apache.poi.extractor.ExtractorFactory;
|
||||||
import org.apache.poi.hssf.extractor.ExcelExtractor;
|
import org.apache.poi.hssf.extractor.ExcelExtractor;
|
||||||
@@ -36,7 +36,7 @@ import org.dspace.content.Item;
|
|||||||
*/
|
*/
|
||||||
public class ExcelFilter extends MediaFilter {
|
public class ExcelFilter extends MediaFilter {
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(ExcelFilter.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(ExcelFilter.class);
|
||||||
|
|
||||||
public String getFilteredName(String oldFilename) {
|
public String getFilteredName(String oldFilename) {
|
||||||
return oldFilename + ".txt";
|
return oldFilename + ".txt";
|
||||||
|
@@ -143,7 +143,7 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter {
|
|||||||
// PDFs using the CMYK color system can be handled specially if
|
// PDFs using the CMYK color system can be handled specially if
|
||||||
// profiles are defined
|
// profiles are defined
|
||||||
if (cmyk_profile != null && srgb_profile != null) {
|
if (cmyk_profile != null && srgb_profile != null) {
|
||||||
Info imageInfo = new Info(f.getAbsolutePath(), true);
|
Info imageInfo = new Info(f.getAbsolutePath() + s, true);
|
||||||
String imageClass = imageInfo.getImageClass();
|
String imageClass = imageInfo.getImageClass();
|
||||||
if (imageClass.contains("CMYK")) {
|
if (imageClass.contains("CMYK")) {
|
||||||
op.profile(cmyk_profile);
|
op.profile(cmyk_profile);
|
||||||
|
@@ -22,7 +22,7 @@ import org.apache.commons.cli.Option;
|
|||||||
import org.apache.commons.cli.OptionBuilder;
|
import org.apache.commons.cli.OptionBuilder;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.dspace.app.mediafilter.factory.MediaFilterServiceFactory;
|
import org.dspace.app.mediafilter.factory.MediaFilterServiceFactory;
|
||||||
import org.dspace.app.mediafilter.service.MediaFilterService;
|
import org.dspace.app.mediafilter.service.MediaFilterService;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
|
@@ -220,7 +220,7 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String handle = myItem.getHandle();
|
String handle = myItem.getHandle();
|
||||||
List<Bundle> bundles = myBitstream.getBundles();
|
List<Bundle> bundles = myBitstream.getBundles();
|
||||||
long size = myBitstream.getSize();
|
long size = myBitstream.getSizeBytes();
|
||||||
String checksum = myBitstream.getChecksum() + " (" + myBitstream.getChecksumAlgorithm() + ")";
|
String checksum = myBitstream.getChecksum() + " (" + myBitstream.getChecksumAlgorithm() + ")";
|
||||||
int assetstore = myBitstream.getStoreNumber();
|
int assetstore = myBitstream.getStoreNumber();
|
||||||
|
|
||||||
@@ -310,12 +310,11 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
|||||||
// get bitstream filename, calculate destination filename
|
// get bitstream filename, calculate destination filename
|
||||||
String newName = formatFilter.getFilteredName(source.getName());
|
String newName = formatFilter.getFilteredName(source.getName());
|
||||||
|
|
||||||
Bitstream existingBitstream = null; // is there an existing rendition?
|
// check if destination bitstream exists
|
||||||
Bundle targetBundle = null; // bundle we're modifying
|
Bundle existingBundle = null;
|
||||||
|
Bitstream existingBitstream = null;
|
||||||
List<Bundle> bundles = itemService.getBundles(item, formatFilter.getBundleName());
|
List<Bundle> bundles = itemService.getBundles(item, formatFilter.getBundleName());
|
||||||
|
|
||||||
// check if destination bitstream exists
|
|
||||||
if (bundles.size() > 0) {
|
if (bundles.size() > 0) {
|
||||||
// only finds the last match (FIXME?)
|
// only finds the last match (FIXME?)
|
||||||
for (Bundle bundle : bundles) {
|
for (Bundle bundle : bundles) {
|
||||||
@@ -323,7 +322,7 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
|||||||
|
|
||||||
for (Bitstream bitstream : bitstreams) {
|
for (Bitstream bitstream : bitstreams) {
|
||||||
if (bitstream.getName().trim().equals(newName.trim())) {
|
if (bitstream.getName().trim().equals(newName.trim())) {
|
||||||
targetBundle = bundle;
|
existingBundle = bundle;
|
||||||
existingBitstream = bitstream;
|
existingBitstream = bitstream;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,40 +344,41 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
|||||||
+ " (item: " + item.getHandle() + ")");
|
+ " (item: " + item.getHandle() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream destStream;
|
|
||||||
try {
|
|
||||||
System.out.println("File: " + newName);
|
System.out.println("File: " + newName);
|
||||||
destStream = formatFilter.getDestinationStream(item, bitstreamService.retrieve(context, source), isVerbose);
|
|
||||||
|
// start filtering of the bitstream, using try with resource to close all InputStreams properly
|
||||||
|
try (
|
||||||
|
// get the source stream
|
||||||
|
InputStream srcStream = bitstreamService.retrieve(context, source);
|
||||||
|
// filter the source stream to produce the destination stream
|
||||||
|
// this is the hard work, check for OutOfMemoryErrors at the end of the try clause.
|
||||||
|
InputStream destStream = formatFilter.getDestinationStream(item, srcStream, isVerbose);
|
||||||
|
) {
|
||||||
if (destStream == null) {
|
if (destStream == null) {
|
||||||
if (!isQuiet) {
|
if (!isQuiet) {
|
||||||
System.out.println("SKIPPED: bitstream " + source.getID()
|
System.out.println("SKIPPED: bitstream " + source.getID()
|
||||||
+ " (item: " + item.getHandle() + ") because filtering was unsuccessful");
|
+ " (item: " + item.getHandle() + ") because filtering was unsuccessful");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
System.out.println("!!! OutOfMemoryError !!!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create new bundle if needed
|
Bundle targetBundle; // bundle we're modifying
|
||||||
if (bundles.size() < 1) {
|
if (bundles.size() < 1) {
|
||||||
|
// create new bundle if needed
|
||||||
targetBundle = bundleService.create(context, item, formatFilter.getBundleName());
|
targetBundle = bundleService.create(context, item, formatFilter.getBundleName());
|
||||||
} else {
|
} else {
|
||||||
// take the first match
|
// take the first match as we already looked out for the correct bundle name
|
||||||
targetBundle = bundles.get(0);
|
targetBundle = bundles.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create bitstream to store the filter result
|
||||||
Bitstream b = bitstreamService.create(context, targetBundle, destStream);
|
Bitstream b = bitstreamService.create(context, targetBundle, destStream);
|
||||||
|
// set the name, source and description of the bitstream
|
||||||
// Now set the format and name of the bitstream
|
|
||||||
b.setName(context, newName);
|
b.setName(context, newName);
|
||||||
b.setSource(context, "Written by FormatFilter " + formatFilter.getClass().getName() +
|
b.setSource(context, "Written by FormatFilter " + formatFilter.getClass().getName() +
|
||||||
" on " + DCDate.getCurrent() + " (GMT).");
|
" on " + DCDate.getCurrent() + " (GMT).");
|
||||||
b.setDescription(context, formatFilter.getDescription());
|
b.setDescription(context, formatFilter.getDescription());
|
||||||
|
// Set the format of the bitstream
|
||||||
// Find the proper format
|
|
||||||
BitstreamFormat bf = bitstreamFormatService.findByShortDescription(context,
|
BitstreamFormat bf = bitstreamFormatService.findByShortDescription(context,
|
||||||
formatFilter.getFormatString());
|
formatFilter.getFormatString());
|
||||||
bitstreamService.setFormat(context, b, bf);
|
bitstreamService.setFormat(context, b, bf);
|
||||||
@@ -398,10 +398,17 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
|||||||
authorizeService.inheritPolicies(context, source, b);
|
authorizeService.inheritPolicies(context, source, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//do post-processing of the generated bitstream
|
||||||
|
formatFilter.postProcessBitstream(context, item, b);
|
||||||
|
|
||||||
|
} catch (OutOfMemoryError oome) {
|
||||||
|
System.out.println("!!! OutOfMemoryError !!!");
|
||||||
|
}
|
||||||
|
|
||||||
// fixme - set date?
|
// fixme - set date?
|
||||||
// we are overwriting, so remove old bitstream
|
// we are overwriting, so remove old bitstream
|
||||||
if (existingBitstream != null) {
|
if (existingBitstream != null) {
|
||||||
bundleService.removeBitstream(context, targetBundle, existingBitstream);
|
bundleService.removeBitstream(context, existingBundle, existingBitstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isQuiet) {
|
if (!isQuiet) {
|
||||||
@@ -409,9 +416,6 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
|||||||
+ " (item: " + item.getHandle() + ") and created '" + newName + "'");
|
+ " (item: " + item.getHandle() + ") and created '" + newName + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
//do post-processing of the generated bitstream
|
|
||||||
formatFilter.postProcessBitstream(context, item, b);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
import org.apache.pdfbox.text.PDFTextStripper;
|
import org.apache.pdfbox.text.PDFTextStripper;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
@@ -30,7 +30,7 @@ import org.dspace.core.ConfigurationManager;
|
|||||||
*/
|
*/
|
||||||
public class PDFFilter extends MediaFilter {
|
public class PDFFilter extends MediaFilter {
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(PDFFilter.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(PDFFilter.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFilteredName(String oldFilename) {
|
public String getFilteredName(String oldFilename) {
|
||||||
|
@@ -10,7 +10,7 @@ package org.dspace.app.mediafilter;
|
|||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.poi.POITextExtractor;
|
import org.apache.poi.POITextExtractor;
|
||||||
import org.apache.poi.extractor.ExtractorFactory;
|
import org.apache.poi.extractor.ExtractorFactory;
|
||||||
import org.apache.poi.hslf.extractor.PowerPointExtractor;
|
import org.apache.poi.hslf.extractor.PowerPointExtractor;
|
||||||
@@ -23,7 +23,7 @@ import org.dspace.content.Item;
|
|||||||
*/
|
*/
|
||||||
public class PowerPointFilter extends MediaFilter {
|
public class PowerPointFilter extends MediaFilter {
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(PowerPointFilter.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(PowerPointFilter.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFilteredName(String oldFilename) {
|
public String getFilteredName(String oldFilename) {
|
||||||
|
@@ -1,93 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.app.mediafilter;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dspace.content.Item;
|
|
||||||
import org.textmining.extraction.TextExtractor;
|
|
||||||
import org.textmining.extraction.word.WordTextExtractorFactory;
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* to do: helpful error messages - can't find mediafilter.cfg - can't
|
|
||||||
* instantiate filter - bitstream format doesn't exist.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class WordFilter extends MediaFilter {
|
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(WordFilter.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFilteredName(String oldFilename) {
|
|
||||||
return oldFilename + ".txt";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return String bundle name
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getBundleName() {
|
|
||||||
return "TEXT";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return String bitstreamformat
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getFormatString() {
|
|
||||||
return "Text";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return String description
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return "Extracted text";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param currentItem item
|
|
||||||
* @param source source input stream
|
|
||||||
* @param verbose verbose mode
|
|
||||||
* @return InputStream the resulting input stream
|
|
||||||
* @throws Exception if error
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose)
|
|
||||||
throws Exception {
|
|
||||||
// get input stream from bitstream
|
|
||||||
// pass to filter, get string back
|
|
||||||
try {
|
|
||||||
WordTextExtractorFactory factory = new WordTextExtractorFactory();
|
|
||||||
TextExtractor e = factory.textExtractor(source);
|
|
||||||
String extractedText = e.getText();
|
|
||||||
|
|
||||||
// if verbose flag is set, print out extracted text
|
|
||||||
// to STDOUT
|
|
||||||
if (verbose) {
|
|
||||||
System.out.println(extractedText);
|
|
||||||
}
|
|
||||||
|
|
||||||
// generate an input stream with the extracted text
|
|
||||||
byte[] textBytes = extractedText.getBytes();
|
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(textBytes);
|
|
||||||
|
|
||||||
return bais; // will this work? or will the byte array be out of scope?
|
|
||||||
} catch (IOException ioe) {
|
|
||||||
System.out.println("Invalid Word Format");
|
|
||||||
log.error("Error detected - Word File format not recognized: "
|
|
||||||
+ ioe.getMessage(), ioe);
|
|
||||||
throw ioe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -9,8 +9,8 @@ package org.dspace.app.requestitem;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -31,7 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
*/
|
*/
|
||||||
public class RequestItemHelpdeskStrategy extends RequestItemSubmitterStrategy {
|
public class RequestItemHelpdeskStrategy extends RequestItemSubmitterStrategy {
|
||||||
|
|
||||||
private Logger log = Logger.getLogger(RequestItemHelpdeskStrategy.class);
|
private Logger log = org.apache.logging.log4j.LogManager.getLogger(RequestItemHelpdeskStrategy.class);
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected EPersonService ePersonService;
|
protected EPersonService ePersonService;
|
||||||
|
@@ -10,7 +10,7 @@ package org.dspace.app.requestitem;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
|
@@ -10,7 +10,7 @@ package org.dspace.app.requestitem;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.requestitem.dao.RequestItemDAO;
|
import org.dspace.app.requestitem.dao.RequestItemDAO;
|
||||||
import org.dspace.app.requestitem.service.RequestItemService;
|
import org.dspace.app.requestitem.service.RequestItemService;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
@@ -28,7 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
*/
|
*/
|
||||||
public class RequestItemServiceImpl implements RequestItemService {
|
public class RequestItemServiceImpl implements RequestItemService {
|
||||||
|
|
||||||
private final Logger log = Logger.getLogger(RequestItemServiceImpl.class);
|
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(RequestItemServiceImpl.class);
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected RequestItemDAO requestItemDAO;
|
protected RequestItemDAO requestItemDAO;
|
||||||
|
@@ -8,13 +8,15 @@
|
|||||||
package org.dspace.app.requestitem.dao.impl;
|
package org.dspace.app.requestitem.dao.impl;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
import org.dspace.app.requestitem.RequestItem;
|
import org.dspace.app.requestitem.RequestItem;
|
||||||
|
import org.dspace.app.requestitem.RequestItem_;
|
||||||
import org.dspace.app.requestitem.dao.RequestItemDAO;
|
import org.dspace.app.requestitem.dao.RequestItemDAO;
|
||||||
import org.dspace.core.AbstractHibernateDAO;
|
import org.dspace.core.AbstractHibernateDAO;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.hibernate.Criteria;
|
|
||||||
import org.hibernate.criterion.Restrictions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hibernate implementation of the Database Access Object interface class for the RequestItem object.
|
* Hibernate implementation of the Database Access Object interface class for the RequestItem object.
|
||||||
@@ -30,9 +32,12 @@ public class RequestItemDAOImpl extends AbstractHibernateDAO<RequestItem> implem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RequestItem findByToken(Context context, String token) throws SQLException {
|
public RequestItem findByToken(Context context, String token) throws SQLException {
|
||||||
Criteria criteria = createCriteria(context, RequestItem.class);
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
criteria.add(Restrictions.eq("token", token));
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RequestItem.class);
|
||||||
return uniqueResult(criteria);
|
Root<RequestItem> requestItemRoot = criteriaQuery.from(RequestItem.class);
|
||||||
|
criteriaQuery.select(requestItemRoot);
|
||||||
|
criteriaQuery.where(criteriaBuilder.equal(requestItemRoot.get(RequestItem_.token), token));
|
||||||
|
return uniqueResult(context, criteriaQuery, false, RequestItem.class, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -15,8 +15,8 @@ import javax.xml.parsers.DocumentBuilder;
|
|||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.sfx.service.SFXFileReaderService;
|
import org.dspace.app.sfx.service.SFXFileReaderService;
|
||||||
import org.dspace.content.DCPersonName;
|
import org.dspace.content.DCPersonName;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
@@ -58,7 +58,7 @@ public class SFXFileReaderServiceImpl implements SFXFileReaderService {
|
|||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
*/
|
*/
|
||||||
private final Logger log = Logger.getLogger(SFXFileReaderServiceImpl.class);
|
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(SFXFileReaderServiceImpl.class);
|
||||||
|
|
||||||
protected SFXFileReaderServiceImpl() {
|
protected SFXFileReaderServiceImpl() {
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.app.util.XMLUtils;
|
import org.dspace.app.util.XMLUtils;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.sherpa;
|
package org.dspace.app.sherpa;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
@@ -16,7 +16,7 @@ import org.apache.http.client.methods.HttpGet;
|
|||||||
import org.apache.http.client.utils.URIBuilder;
|
import org.apache.http.client.utils.URIBuilder;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
|
|
||||||
public class SHERPAService {
|
public class SHERPAService {
|
||||||
@@ -29,7 +29,7 @@ public class SHERPAService {
|
|||||||
/**
|
/**
|
||||||
* log4j category
|
* log4j category
|
||||||
*/
|
*/
|
||||||
private static final Logger log = Logger.getLogger(SHERPAService.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(SHERPAService.class);
|
||||||
|
|
||||||
public SHERPAService() {
|
public SHERPAService() {
|
||||||
HttpClientBuilder builder = HttpClientBuilder.create();
|
HttpClientBuilder builder = HttpClientBuilder.create();
|
||||||
|
@@ -11,8 +11,8 @@ import java.util.LinkedHashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.sherpa.SHERPAResponse;
|
import org.dspace.app.sherpa.SHERPAResponse;
|
||||||
import org.dspace.app.sherpa.SHERPAService;
|
import org.dspace.app.sherpa.SHERPAService;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
@@ -27,7 +27,7 @@ public class SHERPASubmitService {
|
|||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(SHERPASubmitService.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(SHERPASubmitService.class);
|
||||||
|
|
||||||
public void setConfiguration(SHERPASubmitConfigurationService configuration) {
|
public void setConfiguration(SHERPASubmitConfigurationService configuration) {
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
|
@@ -27,9 +27,9 @@ import org.apache.commons.cli.HelpFormatter;
|
|||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
@@ -52,7 +52,7 @@ public class GenerateSitemaps {
|
|||||||
/**
|
/**
|
||||||
* Logger
|
* Logger
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(GenerateSitemaps.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(GenerateSitemaps.class);
|
||||||
|
|
||||||
private static final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
private static final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
||||||
private static final CollectionService collectionService =
|
private static final CollectionService collectionService =
|
||||||
|
@@ -28,7 +28,7 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
@@ -763,9 +763,10 @@ public class ReportGenerator {
|
|||||||
// build the referece
|
// build the referece
|
||||||
// FIXME: here we have blurred the line between content and presentation
|
// FIXME: here we have blurred the line between content and presentation
|
||||||
// and it should probably be un-blurred
|
// and it should probably be un-blurred
|
||||||
List<MetadataValue> title = itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
List<MetadataValue> title = itemService.getMetadata(item, MetadataSchemaEnum.DC.getName(),
|
||||||
|
"title", null, Item.ANY);
|
||||||
List<MetadataValue> author = itemService
|
List<MetadataValue> author = itemService
|
||||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "contributor", "author", Item.ANY);
|
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "contributor", "author", Item.ANY);
|
||||||
|
|
||||||
StringBuffer authors = new StringBuffer();
|
StringBuffer authors = new StringBuffer();
|
||||||
if (author.size() > 0) {
|
if (author.size() > 0) {
|
||||||
|
@@ -21,7 +21,7 @@ import java.util.Set;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.commons.lang.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -13,8 +13,8 @@ import java.util.Map;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.core.Utils;
|
import org.dspace.core.Utils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -63,6 +63,12 @@ public class DCInput {
|
|||||||
*/
|
*/
|
||||||
private String label = null;
|
private String label = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a style instruction to apply to the input. The exact way to use the style value is UI depending that receive the
|
||||||
|
* value from the REST API as is
|
||||||
|
*/
|
||||||
|
private String style = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the input type
|
* the input type
|
||||||
*/
|
*/
|
||||||
@@ -154,7 +160,7 @@ public class DCInput {
|
|||||||
// Default the schema to dublin core
|
// Default the schema to dublin core
|
||||||
dcSchema = fieldMap.get("dc-schema");
|
dcSchema = fieldMap.get("dc-schema");
|
||||||
if (dcSchema == null) {
|
if (dcSchema == null) {
|
||||||
dcSchema = MetadataSchema.DC_SCHEMA;
|
dcSchema = MetadataSchemaEnum.DC.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if the input have a language tag
|
//check if the input have a language tag
|
||||||
@@ -199,7 +205,7 @@ public class DCInput {
|
|||||||
typeBind.add(type.trim());
|
typeBind.add(type.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
style = fieldMap.get("style");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -262,7 +268,7 @@ public class DCInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the DC element for this form row.
|
* Get the DC element for this form field.
|
||||||
*
|
*
|
||||||
* @return the DC element
|
* @return the DC element
|
||||||
*/
|
*/
|
||||||
@@ -271,7 +277,7 @@ public class DCInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the DC namespace prefix for this form row.
|
* Get the DC namespace prefix for this form field.
|
||||||
*
|
*
|
||||||
* @return the DC namespace prefix
|
* @return the DC namespace prefix
|
||||||
*/
|
*/
|
||||||
@@ -290,7 +296,7 @@ public class DCInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is there a required string for this form row?
|
* Is there a required string for this form field?
|
||||||
*
|
*
|
||||||
* @return true if a required string is set
|
* @return true if a required string is set
|
||||||
*/
|
*/
|
||||||
@@ -299,7 +305,7 @@ public class DCInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the DC qualifier for this form row.
|
* Get the DC qualifier for this form field.
|
||||||
*
|
*
|
||||||
* @return the DC qualifier
|
* @return the DC qualifier
|
||||||
*/
|
*/
|
||||||
@@ -308,7 +314,7 @@ public class DCInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the language for this form row.
|
* Get the language for this form field.
|
||||||
*
|
*
|
||||||
* @return the language state
|
* @return the language state
|
||||||
*/
|
*/
|
||||||
@@ -317,7 +323,7 @@ public class DCInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the hint for this form row, formatted for an HTML table
|
* Get the hint for this form field
|
||||||
*
|
*
|
||||||
* @return the hints
|
* @return the hints
|
||||||
*/
|
*/
|
||||||
@@ -326,7 +332,7 @@ public class DCInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the label for this form row.
|
* Get the label for this form field.
|
||||||
*
|
*
|
||||||
* @return the label
|
* @return the label
|
||||||
*/
|
*/
|
||||||
@@ -334,6 +340,15 @@ public class DCInput {
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the style for this form field
|
||||||
|
*
|
||||||
|
* @return the style
|
||||||
|
*/
|
||||||
|
public String getStyle() {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the pairs type
|
* Get the name of the pairs type
|
||||||
*
|
*
|
||||||
|
@@ -25,25 +25,26 @@ public class DCInputSet {
|
|||||||
/**
|
/**
|
||||||
* the inputs ordered by row position
|
* the inputs ordered by row position
|
||||||
*/
|
*/
|
||||||
private DCInput[] inputs = null;
|
private DCInput[][] inputs = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
*
|
*
|
||||||
* @param formName form name
|
* @param formName form name
|
||||||
* @param headings
|
|
||||||
* @param mandatoryFlags
|
* @param mandatoryFlags
|
||||||
* @param fields fields
|
* @param rows the rows
|
||||||
* @param listMap map
|
* @param listMap map
|
||||||
*/
|
*/
|
||||||
public DCInputSet(String formName,
|
public DCInputSet(String formName, List<List<Map<String, String>>> rows, Map<String, List<String>> listMap) {
|
||||||
List<Map<String, String>> fields, Map<String, List<String>> listMap) {
|
|
||||||
this.formName = formName;
|
this.formName = formName;
|
||||||
this.inputs = new DCInput[fields.size()];
|
this.inputs = new DCInput[rows.size()][];
|
||||||
for (int i = 0; i < inputs.length; i++) {
|
for (int i = 0; i < inputs.length; i++) {
|
||||||
Map<String, String> field = fields.get(i);
|
List<Map<String, String>> fields = rows.get(i);
|
||||||
inputs[i] = new DCInput(field, listMap);
|
inputs[i] = new DCInput[fields.size()];
|
||||||
|
for (int j = 0; j < inputs[i].length; j++) {
|
||||||
|
Map<String, String> field = rows.get(i).get(j);
|
||||||
|
inputs[i][j] = new DCInput(field, listMap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ public class DCInputSet {
|
|||||||
* @return an array containing the fields
|
* @return an array containing the fields
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public DCInput[] getFields() {
|
public DCInput[][] getFields() {
|
||||||
return inputs;
|
return inputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,12 +105,14 @@ public class DCInputSet {
|
|||||||
*/
|
*/
|
||||||
public boolean isFieldPresent(String fieldName) {
|
public boolean isFieldPresent(String fieldName) {
|
||||||
for (int i = 0; i < inputs.length; i++) {
|
for (int i = 0; i < inputs.length; i++) {
|
||||||
DCInput field = inputs[i];
|
for (int j = 0; j < inputs[i].length; j++) {
|
||||||
|
DCInput field = inputs[i][j];
|
||||||
String fullName = field.getFieldName();
|
String fullName = field.getFieldName();
|
||||||
if (fullName.equals(fieldName)) {
|
if (fullName.equals(fieldName)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +130,8 @@ public class DCInputSet {
|
|||||||
documentType = "";
|
documentType = "";
|
||||||
}
|
}
|
||||||
for (int i = 0; i < inputs.length; i++) {
|
for (int i = 0; i < inputs.length; i++) {
|
||||||
DCInput field = inputs[i];
|
for (int j = 0; j < inputs[i].length; j++) {
|
||||||
|
DCInput field = inputs[i][j];
|
||||||
String fullName = field.getFieldName();
|
String fullName = field.getFieldName();
|
||||||
if (fullName.equals(fieldName)) {
|
if (fullName.equals(fieldName)) {
|
||||||
if (field.isAllowedFor(documentType)) {
|
if (field.isAllowedFor(documentType)) {
|
||||||
@@ -135,6 +139,7 @@ public class DCInputSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ import javax.xml.parsers.FactoryConfigurationError;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchemaEnum;
|
||||||
import org.dspace.core.Utils;
|
import org.dspace.core.Utils;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@@ -74,7 +74,7 @@ public class DCInputsReader {
|
|||||||
* Reference to the forms definitions map, computed from the forms
|
* Reference to the forms definitions map, computed from the forms
|
||||||
* definition file
|
* definition file
|
||||||
*/
|
*/
|
||||||
private Map<String, List<Map<String, String>>> formDefns = null;
|
private Map<String, List<List<Map<String, String>>>> formDefns = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to the value-pairs map, computed from the forms definition file
|
* Reference to the value-pairs map, computed from the forms definition file
|
||||||
@@ -115,7 +115,7 @@ public class DCInputsReader {
|
|||||||
|
|
||||||
private void buildInputs(String fileName)
|
private void buildInputs(String fileName)
|
||||||
throws DCInputsReaderException {
|
throws DCInputsReaderException {
|
||||||
formDefns = new HashMap<String, List<Map<String, String>>>();
|
formDefns = new HashMap<String, List<List<Map<String, String>>>>();
|
||||||
valuePairs = new HashMap<String, List<String>>();
|
valuePairs = new HashMap<String, List<String>>();
|
||||||
|
|
||||||
String uri = "file:" + new File(fileName).getAbsolutePath();
|
String uri = "file:" + new File(fileName).getAbsolutePath();
|
||||||
@@ -212,7 +212,7 @@ public class DCInputsReader {
|
|||||||
return lastInputSet;
|
return lastInputSet;
|
||||||
}
|
}
|
||||||
// cache miss - construct new DCInputSet
|
// cache miss - construct new DCInputSet
|
||||||
List<Map<String, String>> pages = formDefns.get(formName);
|
List<List<Map<String, String>>> pages = formDefns.get(formName);
|
||||||
if (pages == null) {
|
if (pages == null) {
|
||||||
throw new DCInputsReaderException("Missing the " + formName + " form");
|
throw new DCInputsReaderException("Missing the " + formName + " form");
|
||||||
}
|
}
|
||||||
@@ -292,8 +292,8 @@ public class DCInputsReader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the form-definitions section of the XML file. Each element is
|
* Process the form-definitions section of the XML file. Each element is
|
||||||
* formed thusly: <form name="formname">...pages...</form> Each pages
|
* formed thusly: <form name="formname">...row...</form> Each rows
|
||||||
* subsection is formed: <page number="#"> ...fields... </page> Each field
|
* subsection is formed: <row> ...fields... </row> Each field
|
||||||
* is formed from: dc-element, dc-qualifier, label, hint, input-type name,
|
* is formed from: dc-element, dc-qualifier, label, hint, input-type name,
|
||||||
* required text, and repeatable flag.
|
* required text, and repeatable flag.
|
||||||
*/
|
*/
|
||||||
@@ -311,10 +311,40 @@ public class DCInputsReader {
|
|||||||
if (formName == null) {
|
if (formName == null) {
|
||||||
throw new SAXException("form element has no name attribute");
|
throw new SAXException("form element has no name attribute");
|
||||||
}
|
}
|
||||||
List<Map<String, String>> fields = new ArrayList<Map<String, String>>(); // the form contains fields
|
List<List<Map<String, String>>> rows = new ArrayList<List<Map<String, String>>>(); // the form
|
||||||
formDefns.put(formName, fields);
|
// contains rows of fields
|
||||||
|
formDefns.put(formName, rows);
|
||||||
NodeList pl = nd.getChildNodes();
|
NodeList pl = nd.getChildNodes();
|
||||||
int lenpg = pl.getLength();
|
int lenpg = pl.getLength();
|
||||||
|
for (int j = 0; j < lenpg; j++) {
|
||||||
|
Node npg = pl.item(j);
|
||||||
|
if (npg.getNodeName().equals("row")) {
|
||||||
|
List<Map<String, String>> fields = new ArrayList<Map<String, String>>(); // the fields in the
|
||||||
|
// row
|
||||||
|
// process each row definition
|
||||||
|
processRow(formName, j, npg, fields);
|
||||||
|
rows.add(fields);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// sanity check number of fields
|
||||||
|
if (rows.size() < 1) {
|
||||||
|
throw new DCInputsReaderException("Form " + formName + " has no rows");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (numForms == 0) {
|
||||||
|
throw new DCInputsReaderException("No form definition found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process parts of a row
|
||||||
|
*/
|
||||||
|
private void processRow(String formName, int rowIdx, Node n, List<Map<String, String>> fields)
|
||||||
|
throws SAXException, DCInputsReaderException {
|
||||||
|
|
||||||
|
NodeList pl = n.getChildNodes();
|
||||||
|
int lenpg = pl.getLength();
|
||||||
for (int j = 0; j < lenpg; j++) {
|
for (int j = 0; j < lenpg; j++) {
|
||||||
Node npg = pl.item(j);
|
Node npg = pl.item(j);
|
||||||
|
|
||||||
@@ -323,6 +353,20 @@ public class DCInputsReader {
|
|||||||
Map<String, String> field = new HashMap<String, String>();
|
Map<String, String> field = new HashMap<String, String>();
|
||||||
processField(formName, npg, field);
|
processField(formName, npg, field);
|
||||||
fields.add(field);
|
fields.add(field);
|
||||||
|
String key = field.get(PAIR_TYPE_NAME);
|
||||||
|
if (StringUtils
|
||||||
|
.isNotBlank(key)) {
|
||||||
|
String schema = field.get("dc-schema");
|
||||||
|
String element = field.get("dc-element");
|
||||||
|
String qualifier = field
|
||||||
|
.get("dc-qualifier");
|
||||||
|
String metadataField = schema + "."
|
||||||
|
+ element;
|
||||||
|
if (StringUtils.isNotBlank(qualifier)) {
|
||||||
|
metadataField += "." + qualifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// we omit the duplicate validation, allowing multiple
|
// we omit the duplicate validation, allowing multiple
|
||||||
// fields definition for
|
// fields definition for
|
||||||
// the same metadata and different visibility/type-bind
|
// the same metadata and different visibility/type-bind
|
||||||
@@ -330,15 +374,11 @@ public class DCInputsReader {
|
|||||||
}
|
}
|
||||||
// sanity check number of fields
|
// sanity check number of fields
|
||||||
if (fields.size() < 1) {
|
if (fields.size() < 1) {
|
||||||
throw new DCInputsReaderException("Form " + formName + " has no fields");
|
throw new DCInputsReaderException("Form " + formName + "row " + rowIdx + " has no fields");
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (numForms == 0) {
|
|
||||||
throw new DCInputsReaderException("No form definition found");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process parts of a field
|
* Process parts of a field
|
||||||
* At the end, make sure that input-types 'qualdrop_value' and
|
* At the end, make sure that input-types 'qualdrop_value' and
|
||||||
@@ -424,7 +464,7 @@ public class DCInputsReader {
|
|||||||
String elem = field.get("dc-element");
|
String elem = field.get("dc-element");
|
||||||
String qual = field.get("dc-qualifier");
|
String qual = field.get("dc-qualifier");
|
||||||
if ((schema == null) || (schema.equals(""))) {
|
if ((schema == null) || (schema.equals(""))) {
|
||||||
schema = MetadataSchema.DC_SCHEMA;
|
schema = MetadataSchemaEnum.DC.getName();
|
||||||
}
|
}
|
||||||
String schemaTest;
|
String schemaTest;
|
||||||
|
|
||||||
@@ -434,7 +474,7 @@ public class DCInputsReader {
|
|||||||
Map<String, String> fld = pg.get(j);
|
Map<String, String> fld = pg.get(j);
|
||||||
if ((fld.get("dc-schema") == null) ||
|
if ((fld.get("dc-schema") == null) ||
|
||||||
((fld.get("dc-schema")).equals(""))) {
|
((fld.get("dc-schema")).equals(""))) {
|
||||||
schemaTest = MetadataSchema.DC_SCHEMA;
|
schemaTest = MetadataSchemaEnum.DC.getName();
|
||||||
} else {
|
} else {
|
||||||
schemaTest = fld.get("dc-schema");
|
schemaTest = fld.get("dc-schema");
|
||||||
}
|
}
|
||||||
@@ -537,7 +577,9 @@ public class DCInputsReader {
|
|||||||
Iterator<String> ki = formDefns.keySet().iterator();
|
Iterator<String> ki = formDefns.keySet().iterator();
|
||||||
while (ki.hasNext()) {
|
while (ki.hasNext()) {
|
||||||
String idName = ki.next();
|
String idName = ki.next();
|
||||||
List<Map<String, String>> fields = formDefns.get(idName);
|
List<List<Map<String, String>>> rows = formDefns.get(idName);
|
||||||
|
for (int j = 0; j < rows.size(); j++) {
|
||||||
|
List<Map<String, String>> fields = rows.get(j);
|
||||||
for (int i = 0; i < fields.size(); i++) {
|
for (int i = 0; i < fields.size(); i++) {
|
||||||
Map<String, String> fld = fields.get(i);
|
Map<String, String> fld = fields.get(i);
|
||||||
// verify reference in certain input types
|
// verify reference in certain input types
|
||||||
@@ -555,8 +597,9 @@ public class DCInputsReader {
|
|||||||
|
|
||||||
// we omit the "required" and "visibility" validation, provided this must be checked in the
|
// we omit the "required" and "visibility" validation, provided this must be checked in the
|
||||||
// processing class
|
// processing class
|
||||||
// only when it makes sense (if the field isn't visible means that it is not applicable, therefore it
|
// only when it makes sense (if the field isn't visible means that it is not applicable,
|
||||||
// can't be required)
|
// therefore it can't be required)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -639,4 +682,5 @@ public class DCInputsReader {
|
|||||||
}
|
}
|
||||||
throw new DCInputsReaderException("No field configuration found!");
|
throw new DCInputsReaderException("No field configuration found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -16,14 +16,14 @@ import java.util.Enumeration;
|
|||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
import javax.servlet.ServletContextListener;
|
import javax.servlet.ServletContextListener;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to initialize / cleanup resources used by DSpace when the web application
|
* Class to initialize / cleanup resources used by DSpace when the web application
|
||||||
* is started or stopped.
|
* is started or stopped.
|
||||||
*/
|
*/
|
||||||
public class DSpaceContextListener implements ServletContextListener {
|
public class DSpaceContextListener implements ServletContextListener {
|
||||||
private static Logger log = Logger.getLogger(DSpaceContextListener.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(DSpaceContextListener.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize any resources required by the application.
|
* Initialize any resources required by the application.
|
||||||
|
@@ -1,299 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.app.util;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.time.DateUtils;
|
|
||||||
import org.apache.log4j.FileAppender;
|
|
||||||
import org.apache.log4j.helpers.LogLog;
|
|
||||||
import org.apache.log4j.spi.LoggingEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Special log appender for log4j. Adds the current date (ie. year-mon) to
|
|
||||||
* the end of the file name, so that rolling on to the next log is simply
|
|
||||||
* a case of starting a new one - no renaming of old logs.
|
|
||||||
*
|
|
||||||
* This is advisable if you are using Windows, and have multiple applications
|
|
||||||
* (ie. dspace, dspace-oai, dspace-sword) that all want to write to the same log file,
|
|
||||||
* as each would otherwise try to rename the old files during rollover.
|
|
||||||
*
|
|
||||||
* An example log4j.properties (one log per month, retains three months of logs)
|
|
||||||
*
|
|
||||||
* log4j.rootCategory=INFO, A1
|
|
||||||
* log4j.appender.A1=org.dspace.app.util.DailyFileAppender
|
|
||||||
* log4j.appender.A1.File=@@log.dir@@/dspace.log
|
|
||||||
* log4j.appender.A1.DatePattern=yyyy-MM
|
|
||||||
* log4j.appender.A1.MaxLogs=3
|
|
||||||
* log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
|
||||||
* log4j.appender.A1.layout.ConversionPattern=%d %-5p %c @ %m%n
|
|
||||||
*/
|
|
||||||
public class DailyFileAppender extends FileAppender {
|
|
||||||
/**
|
|
||||||
* The fixed date pattern to be used if one is not specified.
|
|
||||||
*/
|
|
||||||
private static final String DATE_PATTERN = "yyyy-MM-dd";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The folder under which daily folders are created. This can be a absolute path
|
|
||||||
* or relative path also.
|
|
||||||
* e.g. JavaLogs/CPRILog or F:/LogFiles/CPRILog
|
|
||||||
*/
|
|
||||||
private String mstrFileName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used internally and contains the name of the date derived from current system date.
|
|
||||||
*/
|
|
||||||
private Date mstrDate = new Date(System.currentTimeMillis());
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds the user specified DatePattern,
|
|
||||||
*/
|
|
||||||
private String mstrDatePattern = DATE_PATTERN;
|
|
||||||
|
|
||||||
private boolean mMonthOnly = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The date formatter object used for parsing the user specified DatePattern.
|
|
||||||
*/
|
|
||||||
private SimpleDateFormat mobjSDF;
|
|
||||||
|
|
||||||
private boolean mWithHostName = false;
|
|
||||||
|
|
||||||
private int mMaxLogs = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor. This is required as the appender class is dynamically
|
|
||||||
* loaded.
|
|
||||||
*/
|
|
||||||
public DailyFileAppender() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.apache.log4j.FileAppender#activateOptions()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void activateOptions() {
|
|
||||||
setFileName();
|
|
||||||
cleanupOldFiles();
|
|
||||||
super.activateOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Getters
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
public String getDatePattern() {
|
|
||||||
return this.mstrDatePattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFile() {
|
|
||||||
return this.mstrFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getWithHost() {
|
|
||||||
return mWithHostName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxLogs() {
|
|
||||||
return mMaxLogs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Setters
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
public void setDatePattern(String pstrPattern) {
|
|
||||||
this.mstrDatePattern = checkPattern(pstrPattern);
|
|
||||||
if (mstrDatePattern.contains("dd") || mstrDatePattern.contains("DD")) {
|
|
||||||
mMonthOnly = false;
|
|
||||||
} else {
|
|
||||||
mMonthOnly = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setFile(String file) {
|
|
||||||
// Trim spaces from both ends. The users probably does not want
|
|
||||||
// trailing spaces in file names.
|
|
||||||
String val = file.trim();
|
|
||||||
mstrFileName = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWithHost(boolean wh) {
|
|
||||||
mWithHostName = wh;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxLogs(int ml) {
|
|
||||||
mMaxLogs = ml;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Methods
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.apache.log4j.WriterAppender#subAppend(org.apache.log4j.spi.LoggingEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void subAppend(LoggingEvent pobjEvent) {
|
|
||||||
Date dtNow = new Date(System.currentTimeMillis());
|
|
||||||
|
|
||||||
boolean rollover = false;
|
|
||||||
|
|
||||||
if (mMonthOnly) {
|
|
||||||
Calendar now = Calendar.getInstance();
|
|
||||||
Calendar cur = Calendar.getInstance();
|
|
||||||
now.setTime(dtNow);
|
|
||||||
cur.setTime(mstrDate);
|
|
||||||
rollover = !(now.get(Calendar.YEAR) == cur.get(Calendar.YEAR) && now.get(Calendar.MONTH) == cur
|
|
||||||
.get(Calendar.MONTH));
|
|
||||||
} else {
|
|
||||||
rollover = !(DateUtils.isSameDay(dtNow, mstrDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rollover) {
|
|
||||||
try {
|
|
||||||
rollOver(dtNow);
|
|
||||||
} catch (IOException IOEx) {
|
|
||||||
LogLog.error("rollOver() failed!", IOEx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
super.subAppend(pobjEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Helpers
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The helper function to validate the DatePattern.
|
|
||||||
*
|
|
||||||
* @param pstrPattern The DatePattern to be validated.
|
|
||||||
* @return The validated date pattern or defautlt DATE_PATTERN
|
|
||||||
*/
|
|
||||||
private String checkPattern(String pstrPattern) {
|
|
||||||
String strRet = null;
|
|
||||||
SimpleDateFormat objFmt = new SimpleDateFormat(DATE_PATTERN);
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.mobjSDF = new SimpleDateFormat(pstrPattern);
|
|
||||||
strRet = pstrPattern;
|
|
||||||
} catch (NullPointerException NPExIgnore) {
|
|
||||||
LogLog.error("Invalid DatePattern " + pstrPattern, NPExIgnore);
|
|
||||||
this.mobjSDF = objFmt;
|
|
||||||
strRet = DATE_PATTERN;
|
|
||||||
} catch (IllegalArgumentException IlArgExIgnore) {
|
|
||||||
LogLog.error("Invalid DatePattern " + pstrPattern, IlArgExIgnore);
|
|
||||||
this.mobjSDF = objFmt;
|
|
||||||
strRet = DATE_PATTERN;
|
|
||||||
} finally {
|
|
||||||
objFmt = null;
|
|
||||||
}
|
|
||||||
return strRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function is responsible for performing the actual file rollover.
|
|
||||||
*
|
|
||||||
* @param pstrName The name of the new folder based on current system date.
|
|
||||||
* @throws IOException if IO error
|
|
||||||
*/
|
|
||||||
private static boolean deletingFiles = false;
|
|
||||||
|
|
||||||
private void cleanupOldFiles() {
|
|
||||||
// If we need to delete log files
|
|
||||||
if (mMaxLogs > 0 && !deletingFiles) {
|
|
||||||
deletingFiles = true;
|
|
||||||
|
|
||||||
// Determine the final file extension with the hostname
|
|
||||||
String hostFileExt = null;
|
|
||||||
try {
|
|
||||||
hostFileExt = "." + java.net.InetAddress.getLocalHost().getHostName();
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
LogLog.error("Unable to retrieve host name");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Array to hold the logs we are going to keep
|
|
||||||
File[] logsToKeep = new File[mMaxLogs];
|
|
||||||
|
|
||||||
// Get a 'master' file handle, and the parent directory from it
|
|
||||||
File logMaster = new File(mstrFileName);
|
|
||||||
File logDir = logMaster.getParentFile();
|
|
||||||
if (logDir.isDirectory()) {
|
|
||||||
// Iterate all the files in that directory
|
|
||||||
File[] logArr = logDir.listFiles();
|
|
||||||
for (File curLog : logArr) {
|
|
||||||
LogLog.debug("Comparing '" + curLog.getAbsolutePath() + "' to '" + mstrFileName + "'");
|
|
||||||
String name = curLog.getAbsolutePath();
|
|
||||||
|
|
||||||
// First, see if we are not using hostname, or the log file ends with this host
|
|
||||||
if (!mWithHostName || (hostFileExt != null && name.endsWith(hostFileExt))) {
|
|
||||||
// Check that the file is indeed one we want (contains the master file name)
|
|
||||||
if (name.contains(mstrFileName)) {
|
|
||||||
// Iterate through the array of logs we are keeping
|
|
||||||
for (int i = 0; curLog != null && i < logsToKeep.length; i++) {
|
|
||||||
// Have we exhausted the 'to keep' array?
|
|
||||||
if (logsToKeep[i] == null) {
|
|
||||||
// Empty space, retain this log file
|
|
||||||
logsToKeep[i] = curLog;
|
|
||||||
curLog = null;
|
|
||||||
} else if (logsToKeep[i].getName().compareTo(curLog.getName()) < 0) {
|
|
||||||
// If the 'kept' file is older than the current one
|
|
||||||
// Replace tested entry with current file
|
|
||||||
File temp = logsToKeep[i];
|
|
||||||
logsToKeep[i] = curLog;
|
|
||||||
curLog = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we have a 'current' entry at this point, it's a log we don't want
|
|
||||||
if (curLog != null) {
|
|
||||||
LogLog.debug("Deleting log " + curLog.getName());
|
|
||||||
if (!curLog.delete()) {
|
|
||||||
LogLog.error("Unable to delete log file");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Don't worry about exceptions
|
|
||||||
} finally {
|
|
||||||
deletingFiles = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rollOver(Date dtNow) throws IOException {
|
|
||||||
mstrDate = dtNow;
|
|
||||||
setFileName();
|
|
||||||
this.setFile(fileName, true, bufferedIO, bufferSize);
|
|
||||||
|
|
||||||
cleanupOldFiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFileName() {
|
|
||||||
fileName = mstrFileName + "." + mobjSDF.format(mstrDate);
|
|
||||||
|
|
||||||
if (mWithHostName) {
|
|
||||||
try {
|
|
||||||
fileName += "." + java.net.InetAddress.getLocalHost().getHostName();
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
LogLog.error("Unable to retrieve host name");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -12,7 +12,7 @@ import java.util.Comparator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.BitstreamFormat;
|
import org.dspace.content.BitstreamFormat;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
@@ -24,7 +24,7 @@ import org.dspace.core.Context;
|
|||||||
*/
|
*/
|
||||||
public class GoogleBitstreamComparator implements Comparator<Bitstream> {
|
public class GoogleBitstreamComparator implements Comparator<Bitstream> {
|
||||||
|
|
||||||
private final static Logger log = Logger.getLogger(GoogleBitstreamComparator.class);
|
private final static Logger log = org.apache.logging.log4j.LogManager.getLogger(GoogleBitstreamComparator.class);
|
||||||
|
|
||||||
HashMap<String, Integer> priorityMap = new HashMap<>();
|
HashMap<String, Integer> priorityMap = new HashMap<>();
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ public class GoogleBitstreamComparator implements Comparator<Bitstream> {
|
|||||||
if (priority1 > priority2) {
|
if (priority1 > priority2) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (priority1 == priority2) {
|
} else if (priority1 == priority2) {
|
||||||
if (b1.getSize() <= b2.getSize()) {
|
if (b1.getSizeBytes() <= b2.getSizeBytes()) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -26,7 +26,7 @@ import java.util.Properties;
|
|||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
@@ -51,7 +51,7 @@ import org.jdom.Element;
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class GoogleMetadata {
|
public class GoogleMetadata {
|
||||||
|
|
||||||
private final static Logger log = Logger.getLogger(GoogleMetadata.class);
|
private final static Logger log = org.apache.logging.log4j.LogManager.getLogger(GoogleMetadata.class);
|
||||||
|
|
||||||
protected static final String GOOGLE_PREFIX = "google.";
|
protected static final String GOOGLE_PREFIX = "google.";
|
||||||
|
|
||||||
|
@@ -121,20 +121,24 @@ public class IndexVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open this index directory in Lucene
|
// Open this index directory in Lucene
|
||||||
Directory indexDir = FSDirectory.open(dir);
|
Directory indexDir = FSDirectory.open(dir.toPath());
|
||||||
|
|
||||||
// Get info on the Lucene segment file(s) in index directory
|
// Get info on the Lucene segment file(s) in index directory
|
||||||
SegmentInfos sis = new SegmentInfos();
|
SegmentInfos sis;
|
||||||
try {
|
try {
|
||||||
sis.read(indexDir);
|
sis = SegmentInfos.readLatestCommit(indexDir);
|
||||||
} catch (IOException ie) {
|
} catch (IOException ie) {
|
||||||
// Wrap default IOException, providing more info about which directory cannot be read
|
// Wrap default IOException, providing more info about which directory cannot be read
|
||||||
throw new IOException("Could not read Lucene segments files in " + dir.getAbsolutePath(), ie);
|
throw new IOException("Could not read Lucene segments files in " + dir.getAbsolutePath(), ie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null == sis) {
|
||||||
|
throw new IOException("Could not read Lucene segments files in " + dir.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
// If we have a valid Solr index dir, but it has no existing segments
|
// If we have a valid Solr index dir, but it has no existing segments
|
||||||
// then just return an empty string. It's a valid but empty index.
|
// then just return an empty string. It's a valid but empty index.
|
||||||
if (sis != null && sis.size() == 0) {
|
if (sis.size() == 0) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,227 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.apache.commons.cli.CommandLine;
|
||||||
|
import org.apache.commons.cli.CommandLineParser;
|
||||||
|
import org.apache.commons.cli.HelpFormatter;
|
||||||
|
import org.apache.commons.cli.Options;
|
||||||
|
import org.apache.commons.cli.ParseException;
|
||||||
|
import org.apache.commons.cli.PosixParser;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.content.EntityType;
|
||||||
|
import org.dspace.content.RelationshipType;
|
||||||
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
|
import org.dspace.content.service.EntityTypeService;
|
||||||
|
import org.dspace.content.service.RelationshipService;
|
||||||
|
import org.dspace.content.service.RelationshipTypeService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This script is used to initialize the database with a set of relationshiptypes that are written
|
||||||
|
* in an xml file that is given to this script.
|
||||||
|
* This XML file needs to have a proper XML structure and needs to define the variables of the RelationshipType object
|
||||||
|
*/
|
||||||
|
public class InitializeEntities {
|
||||||
|
|
||||||
|
private final static Logger log = LogManager.getLogger();
|
||||||
|
|
||||||
|
private RelationshipTypeService relationshipTypeService;
|
||||||
|
private RelationshipService relationshipService;
|
||||||
|
private EntityTypeService entityTypeService;
|
||||||
|
|
||||||
|
private InitializeEntities() {
|
||||||
|
relationshipTypeService = ContentServiceFactory.getInstance().getRelationshipTypeService();
|
||||||
|
relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
||||||
|
entityTypeService = ContentServiceFactory.getInstance().getEntityTypeService();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main method for this script
|
||||||
|
*
|
||||||
|
* @param argv The commandline arguments given with this command
|
||||||
|
* @throws SQLException If something goes wrong with the database
|
||||||
|
* @throws AuthorizeException If something goes wrong with permissions
|
||||||
|
* @throws ParseException If something goes wrong with the parsing
|
||||||
|
*/
|
||||||
|
public static void main(String[] argv) throws SQLException, AuthorizeException, ParseException {
|
||||||
|
InitializeEntities initializeEntities = new InitializeEntities();
|
||||||
|
CommandLineParser parser = new PosixParser();
|
||||||
|
Options options = createCommandLineOptions();
|
||||||
|
CommandLine line = parser.parse(options,argv);
|
||||||
|
String fileLocation = getFileLocationFromCommandLine(line);
|
||||||
|
checkHelpEntered(options, line);
|
||||||
|
initializeEntities.run(fileLocation);
|
||||||
|
}
|
||||||
|
private static void checkHelpEntered(Options options, CommandLine line) {
|
||||||
|
if (line.hasOption("h")) {
|
||||||
|
HelpFormatter formatter = new HelpFormatter();
|
||||||
|
formatter.printHelp("Intialize Entities", options);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static String getFileLocationFromCommandLine(CommandLine line) {
|
||||||
|
String query = line.getOptionValue("f");
|
||||||
|
if (StringUtils.isEmpty(query)) {
|
||||||
|
System.out.println("No file location was entered");
|
||||||
|
log.info("No file location was entered");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static Options createCommandLineOptions() {
|
||||||
|
Options options = new Options();
|
||||||
|
options.addOption("f", "file", true, "the location for the file containing the xml data");
|
||||||
|
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run(String fileLocation) throws SQLException, AuthorizeException {
|
||||||
|
Context context = new Context();
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
this.parseXMLToRelations(context, fileLocation);
|
||||||
|
context.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseXMLToRelations(Context context, String fileLocation) throws AuthorizeException {
|
||||||
|
try {
|
||||||
|
File fXmlFile = new File(fileLocation);
|
||||||
|
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder dBuilder = null;
|
||||||
|
dBuilder = dbFactory.newDocumentBuilder();
|
||||||
|
Document doc = dBuilder.parse(fXmlFile);
|
||||||
|
|
||||||
|
doc.getDocumentElement().normalize();
|
||||||
|
|
||||||
|
NodeList nList = doc.getElementsByTagName("type");
|
||||||
|
List<RelationshipType> relationshipTypes = new LinkedList<>();
|
||||||
|
for (int i = 0; i < nList.getLength(); i++) {
|
||||||
|
Node nNode = nList.item(i);
|
||||||
|
|
||||||
|
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
|
|
||||||
|
Element eElement = (Element) nNode;
|
||||||
|
|
||||||
|
String leftType = eElement.getElementsByTagName("leftType").item(0).getTextContent();
|
||||||
|
String rightType = eElement.getElementsByTagName("rightType").item(0).getTextContent();
|
||||||
|
String leftLabel = eElement.getElementsByTagName("leftLabel").item(0).getTextContent();
|
||||||
|
String rightLabel = eElement.getElementsByTagName("rightLabel").item(0).getTextContent();
|
||||||
|
|
||||||
|
|
||||||
|
NodeList leftCardinalityList = eElement.getElementsByTagName("leftCardinality");
|
||||||
|
NodeList rightCardinalityList = eElement.getElementsByTagName("rightCardinality");
|
||||||
|
|
||||||
|
String leftCardinalityMin = "";
|
||||||
|
String leftCardinalityMax = "";
|
||||||
|
|
||||||
|
String rightCardinalityMin = "";
|
||||||
|
String rightCardinalityMax = "";
|
||||||
|
|
||||||
|
for (int j = 0; j < leftCardinalityList.getLength(); j++) {
|
||||||
|
Node node = leftCardinalityList.item(j);
|
||||||
|
leftCardinalityMin = getString(leftCardinalityMin,(Element) node, "min");
|
||||||
|
leftCardinalityMax = getString(leftCardinalityMax,(Element) node, "max");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < rightCardinalityList.getLength(); j++) {
|
||||||
|
Node node = rightCardinalityList.item(j);
|
||||||
|
rightCardinalityMin = getString(rightCardinalityMin,(Element) node, "min");
|
||||||
|
rightCardinalityMax = getString(rightCardinalityMax,(Element) node, "max");
|
||||||
|
|
||||||
|
}
|
||||||
|
populateRelationshipType(context, leftType, rightType, leftLabel, rightLabel,
|
||||||
|
leftCardinalityMin, leftCardinalityMax,
|
||||||
|
rightCardinalityMin, rightCardinalityMax);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ParserConfigurationException | SAXException | IOException | SQLException e) {
|
||||||
|
log.error("An error occurred while parsing the XML file to relations", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getString(String leftCardinalityMin,Element node, String minOrMax) {
|
||||||
|
if (node.getElementsByTagName(minOrMax).getLength() > 0) {
|
||||||
|
leftCardinalityMin = node.getElementsByTagName(minOrMax).item(0).getTextContent();
|
||||||
|
}
|
||||||
|
return leftCardinalityMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateRelationshipType(Context context, String leftType, String rightType, String leftLabel,
|
||||||
|
String rightLabel, String leftCardinalityMin, String leftCardinalityMax,
|
||||||
|
String rightCardinalityMin, String rightCardinalityMax)
|
||||||
|
throws SQLException, AuthorizeException {
|
||||||
|
|
||||||
|
EntityType leftEntityType = entityTypeService.findByEntityType(context,leftType);
|
||||||
|
if (leftEntityType == null) {
|
||||||
|
leftEntityType = entityTypeService.create(context, leftType);
|
||||||
|
}
|
||||||
|
EntityType rightEntityType = entityTypeService.findByEntityType(context, rightType);
|
||||||
|
if (rightEntityType == null) {
|
||||||
|
rightEntityType = entityTypeService.create(context, rightType);
|
||||||
|
}
|
||||||
|
Integer leftCardinalityMinInteger;
|
||||||
|
Integer leftCardinalityMaxInteger;
|
||||||
|
Integer rightCardinalityMinInteger;
|
||||||
|
Integer rightCardinalityMaxInteger;
|
||||||
|
if (StringUtils.isNotBlank(leftCardinalityMin)) {
|
||||||
|
leftCardinalityMinInteger = Integer.parseInt(leftCardinalityMin);
|
||||||
|
} else {
|
||||||
|
leftCardinalityMinInteger = null;
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(leftCardinalityMax)) {
|
||||||
|
leftCardinalityMaxInteger = Integer.parseInt(leftCardinalityMax);
|
||||||
|
} else {
|
||||||
|
leftCardinalityMaxInteger = null;
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(rightCardinalityMin)) {
|
||||||
|
rightCardinalityMinInteger = Integer.parseInt(rightCardinalityMin);
|
||||||
|
} else {
|
||||||
|
rightCardinalityMinInteger = null;
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(rightCardinalityMax)) {
|
||||||
|
rightCardinalityMaxInteger = Integer.parseInt(rightCardinalityMax);
|
||||||
|
} else {
|
||||||
|
rightCardinalityMaxInteger = null;
|
||||||
|
}
|
||||||
|
RelationshipType relationshipType = relationshipTypeService
|
||||||
|
.findbyTypesAndLabels(context, leftEntityType, rightEntityType, leftLabel, rightLabel);
|
||||||
|
if (relationshipType == null) {
|
||||||
|
relationshipTypeService.create(context, leftEntityType, rightEntityType, leftLabel, rightLabel,
|
||||||
|
leftCardinalityMinInteger, leftCardinalityMaxInteger,
|
||||||
|
rightCardinalityMinInteger, rightCardinalityMaxInteger);
|
||||||
|
} else {
|
||||||
|
relationshipType.setLeftMinCardinality(leftCardinalityMinInteger);
|
||||||
|
relationshipType.setLeftMaxCardinality(leftCardinalityMaxInteger);
|
||||||
|
relationshipType.setRightMinCardinality(rightCardinalityMinInteger);
|
||||||
|
relationshipType.setRightMaxCardinality(rightCardinalityMaxInteger);
|
||||||
|
relationshipTypeService.update(context, relationshipType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -14,7 +14,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.util.service.MetadataExposureService;
|
import org.dspace.app.util.service.MetadataExposureService;
|
||||||
import org.dspace.authorize.service.AuthorizeService;
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -58,7 +58,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
* @version $Revision: 3734 $
|
* @version $Revision: 3734 $
|
||||||
*/
|
*/
|
||||||
public class MetadataExposureServiceImpl implements MetadataExposureService {
|
public class MetadataExposureServiceImpl implements MetadataExposureService {
|
||||||
protected Logger log = Logger.getLogger(MetadataExposureServiceImpl.class);
|
protected Logger log = org.apache.logging.log4j.LogManager.getLogger(MetadataExposureServiceImpl.class);
|
||||||
|
|
||||||
protected Map<String, Set<String>> hiddenElementSets = null;
|
protected Map<String, Set<String>> hiddenElementSets = null;
|
||||||
protected Map<String, Map<String, Set<String>>> hiddenElementMaps = null;
|
protected Map<String, Map<String, Set<String>>> hiddenElementMaps = null;
|
||||||
|
@@ -20,11 +20,13 @@ import com.sun.syndication.feed.module.opensearch.OpenSearchModule;
|
|||||||
import com.sun.syndication.feed.module.opensearch.entity.OSQuery;
|
import com.sun.syndication.feed.module.opensearch.entity.OSQuery;
|
||||||
import com.sun.syndication.feed.module.opensearch.impl.OpenSearchModuleImpl;
|
import com.sun.syndication.feed.module.opensearch.impl.OpenSearchModuleImpl;
|
||||||
import com.sun.syndication.io.FeedException;
|
import com.sun.syndication.io.FeedException;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.util.service.OpenSearchService;
|
import org.dspace.app.util.service.OpenSearchService;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.handle.service.HandleService;
|
import org.dspace.handle.service.HandleService;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
@@ -33,7 +35,6 @@ import org.jdom.JDOMException;
|
|||||||
import org.jdom.Namespace;
|
import org.jdom.Namespace;
|
||||||
import org.jdom.output.DOMOutputter;
|
import org.jdom.output.DOMOutputter;
|
||||||
import org.jdom.output.XMLOutputter;
|
import org.jdom.output.XMLOutputter;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
@@ -53,20 +54,14 @@ import org.w3c.dom.Document;
|
|||||||
*
|
*
|
||||||
* @author Richard Rodgers
|
* @author Richard Rodgers
|
||||||
*/
|
*/
|
||||||
public class OpenSearchServiceImpl implements OpenSearchService, InitializingBean {
|
public class OpenSearchServiceImpl implements OpenSearchService {
|
||||||
private static final Logger log = Logger.getLogger(OpenSearchServiceImpl.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(OpenSearchServiceImpl.class);
|
||||||
|
|
||||||
// are open search queries enabled?
|
|
||||||
protected boolean enabled = false;
|
|
||||||
// supported results formats
|
|
||||||
protected List<String> formats = null;
|
|
||||||
// Namespaces used
|
// Namespaces used
|
||||||
protected final String osNs = "http://a9.com/-/spec/opensearch/1.1/";
|
protected final String osNs = "http://a9.com/-/spec/opensearch/1.1/";
|
||||||
|
|
||||||
// base search UI URL
|
@Autowired(required = true)
|
||||||
protected String uiUrl = null;
|
protected ConfigurationService configurationService;
|
||||||
// base search service URL
|
|
||||||
protected String svcUrl = null;
|
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected HandleService handleService;
|
protected HandleService handleService;
|
||||||
@@ -75,25 +70,35 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public List<String> getFormats() {
|
||||||
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
|
List<String> formats = new ArrayList<>();
|
||||||
enabled = config.getBooleanProperty("websvc.opensearch.enable");
|
// read formats only if enabled
|
||||||
svcUrl = config.getProperty("dspace.url") + "/" +
|
if (isEnabled()) {
|
||||||
config.getProperty("websvc.opensearch.svccontext");
|
String[] fmts = configurationService.getArrayProperty("websvc.opensearch.formats");
|
||||||
uiUrl = config.getProperty("dspace.url") + "/" +
|
|
||||||
config.getProperty("websvc.opensearch.uicontext");
|
|
||||||
|
|
||||||
// read rest of config info if enabled
|
|
||||||
formats = new ArrayList<String>();
|
|
||||||
if (enabled) {
|
|
||||||
String[] fmts = config.getArrayProperty("websvc.opensearch.formats");
|
|
||||||
formats = Arrays.asList(fmts);
|
formats = Arrays.asList(fmts);
|
||||||
}
|
}
|
||||||
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getFormats() {
|
public boolean isEnabled() {
|
||||||
return formats;
|
return configurationService.getBooleanProperty("websvc.opensearch.enable");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get base search service URL (websvc.opensearch.svccontext)
|
||||||
|
*/
|
||||||
|
protected String getBaseSearchServiceURL() {
|
||||||
|
return configurationService.getProperty("dspace.url") + "/" +
|
||||||
|
configurationService.getProperty("websvc.opensearch.svccontext");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get base search UI URL (websvc.opensearch.uicontext)
|
||||||
|
*/
|
||||||
|
protected String getBaseSearchUIURL() {
|
||||||
|
return configurationService.getProperty("dspace.url") + "/" +
|
||||||
|
configurationService.getProperty("websvc.opensearch.uicontext");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -115,7 +120,7 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
@Override
|
@Override
|
||||||
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
||||||
int pageSize,
|
int pageSize,
|
||||||
DSpaceObject scope, List<DSpaceObject> results,
|
IndexableObject scope, List<IndexableObject> results,
|
||||||
Map<String, String> labels) throws IOException {
|
Map<String, String> labels) throws IOException {
|
||||||
try {
|
try {
|
||||||
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
||||||
@@ -129,7 +134,7 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
@Override
|
@Override
|
||||||
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
||||||
int pageSize,
|
int pageSize,
|
||||||
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels)
|
IndexableObject scope, List<IndexableObject> results, Map<String, String> labels)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try {
|
try {
|
||||||
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
||||||
@@ -141,8 +146,8 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected SyndicationFeed getResults(Context context, String format, String query, int totalResults, int start,
|
protected SyndicationFeed getResults(Context context, String format, String query, int totalResults, int start,
|
||||||
int pageSize,
|
int pageSize, IndexableObject scope,
|
||||||
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels) {
|
List<IndexableObject> results, Map<String, String> labels) {
|
||||||
// Encode results in requested format
|
// Encode results in requested format
|
||||||
if ("rss".equals(format)) {
|
if ("rss".equals(format)) {
|
||||||
format = "rss_2.0";
|
format = "rss_2.0";
|
||||||
@@ -221,13 +226,13 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
root.addContent(fav);
|
root.addContent(fav);
|
||||||
}
|
}
|
||||||
// service URLs
|
// service URLs
|
||||||
for (String format : formats) {
|
for (String format : getFormats()) {
|
||||||
Element url = new Element("Url", ns).setAttribute("type", getContentType(format));
|
Element url = new Element("Url", ns).setAttribute("type", getContentType(format));
|
||||||
StringBuilder template = new StringBuilder();
|
StringBuilder template = new StringBuilder();
|
||||||
if ("html".equals(format)) {
|
if ("html".equals(format)) {
|
||||||
template.append(uiUrl);
|
template.append(getBaseSearchUIURL());
|
||||||
} else {
|
} else {
|
||||||
template.append(svcUrl);
|
template.append(getBaseSearchServiceURL());
|
||||||
}
|
}
|
||||||
template.append("?query={searchTerms}");
|
template.append("?query={searchTerms}");
|
||||||
if (!"html".equals(format)) {
|
if (!"html".equals(format)) {
|
||||||
|
@@ -11,7 +11,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
@@ -28,7 +28,7 @@ import org.springframework.util.StopWatch;
|
|||||||
* Invocation: dsrun org.dspace.app.util.OptimizeSelectCollection
|
* Invocation: dsrun org.dspace.app.util.OptimizeSelectCollection
|
||||||
*/
|
*/
|
||||||
public class OptimizeSelectCollection {
|
public class OptimizeSelectCollection {
|
||||||
private static final Logger log = Logger.getLogger(OptimizeSelectCollection.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(OptimizeSelectCollection.class);
|
||||||
private static Context context;
|
private static Context context;
|
||||||
|
|
||||||
private static ArrayList<EPerson> brokenPeople;
|
private static ArrayList<EPerson> brokenPeople;
|
||||||
|
@@ -12,7 +12,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing a single Item Submission config definition, organized into
|
* Class representing a single Item Submission config definition, organized into
|
||||||
@@ -44,7 +44,7 @@ public class SubmissionConfig implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(SubmissionConfig.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(SubmissionConfig.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new Submission Configuration object, based on the XML
|
* Constructs a new Submission Configuration object, based on the XML
|
||||||
|
@@ -19,7 +19,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
|||||||
import javax.xml.parsers.FactoryConfigurationError;
|
import javax.xml.parsers.FactoryConfigurationError;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -71,7 +71,7 @@ public class SubmissionConfigReader {
|
|||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(SubmissionConfigReader.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(SubmissionConfigReader.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The fully qualified pathname of the directory containing the Item Submission Configuration file
|
* The fully qualified pathname of the directory containing the Item Submission Configuration file
|
||||||
|
@@ -34,9 +34,9 @@ import com.sun.syndication.feed.synd.SyndPerson;
|
|||||||
import com.sun.syndication.feed.synd.SyndPersonImpl;
|
import com.sun.syndication.feed.synd.SyndPersonImpl;
|
||||||
import com.sun.syndication.io.FeedException;
|
import com.sun.syndication.io.FeedException;
|
||||||
import com.sun.syndication.io.SyndFeedOutput;
|
import com.sun.syndication.io.SyndFeedOutput;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
@@ -52,6 +52,7 @@ import org.dspace.content.service.ItemService;
|
|||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.handle.factory.HandleServiceFactory;
|
import org.dspace.handle.factory.HandleServiceFactory;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
@@ -69,7 +70,7 @@ import org.w3c.dom.Document;
|
|||||||
* @author Larry Stone
|
* @author Larry Stone
|
||||||
*/
|
*/
|
||||||
public class SyndicationFeed {
|
public class SyndicationFeed {
|
||||||
protected final Logger log = Logger.getLogger(SyndicationFeed.class);
|
protected final Logger log = org.apache.logging.log4j.LogManager.getLogger(SyndicationFeed.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,12 +180,12 @@ public class SyndicationFeed {
|
|||||||
*
|
*
|
||||||
* @param request request
|
* @param request request
|
||||||
* @param context context
|
* @param context context
|
||||||
* @param dso DSpaceObject
|
* @param dso the scope
|
||||||
* @param items array of objects
|
* @param items array of objects
|
||||||
* @param labels label map
|
* @param labels label map
|
||||||
*/
|
*/
|
||||||
public void populate(HttpServletRequest request, Context context, DSpaceObject dso,
|
public void populate(HttpServletRequest request, Context context, IndexableObject dso,
|
||||||
List<? extends DSpaceObject> items, Map<String, String> labels) {
|
List<IndexableObject> items, Map<String, String> labels) {
|
||||||
String logoURL = null;
|
String logoURL = null;
|
||||||
String objectURL = null;
|
String objectURL = null;
|
||||||
String defaultTitle = null;
|
String defaultTitle = null;
|
||||||
@@ -208,6 +209,7 @@ public class SyndicationFeed {
|
|||||||
if (cols != null && cols.length() > 1 && cols.contains(col.getHandle())) {
|
if (cols != null && cols.length() > 1 && cols.contains(col.getHandle())) {
|
||||||
podcastFeed = true;
|
podcastFeed = true;
|
||||||
}
|
}
|
||||||
|
objectURL = resolveURL(request, col);
|
||||||
} else if (dso.getType() == Constants.COMMUNITY) {
|
} else if (dso.getType() == Constants.COMMUNITY) {
|
||||||
Community comm = (Community) dso;
|
Community comm = (Community) dso;
|
||||||
defaultTitle = comm.getName();
|
defaultTitle = comm.getName();
|
||||||
@@ -217,8 +219,9 @@ public class SyndicationFeed {
|
|||||||
if (comms != null && comms.length() > 1 && comms.contains(comm.getHandle())) {
|
if (comms != null && comms.length() > 1 && comms.contains(comm.getHandle())) {
|
||||||
podcastFeed = true;
|
podcastFeed = true;
|
||||||
}
|
}
|
||||||
|
objectURL = resolveURL(request, comm);
|
||||||
}
|
}
|
||||||
objectURL = resolveURL(request, dso);
|
|
||||||
if (logo != null) {
|
if (logo != null) {
|
||||||
logoURL = urlOfBitstream(request, logo);
|
logoURL = urlOfBitstream(request, logo);
|
||||||
}
|
}
|
||||||
@@ -247,11 +250,11 @@ public class SyndicationFeed {
|
|||||||
// add entries for items
|
// add entries for items
|
||||||
if (items != null) {
|
if (items != null) {
|
||||||
List<SyndEntry> entries = new ArrayList<SyndEntry>();
|
List<SyndEntry> entries = new ArrayList<SyndEntry>();
|
||||||
for (DSpaceObject itemDSO : items) {
|
for (IndexableObject idxObj : items) {
|
||||||
if (itemDSO.getType() != Constants.ITEM) {
|
if (idxObj.getType() != Constants.ITEM) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Item item = (Item) itemDSO;
|
Item item = (Item) idxObj;
|
||||||
boolean hasDate = false;
|
boolean hasDate = false;
|
||||||
SyndEntry entry = new SyndEntryImpl();
|
SyndEntry entry = new SyndEntryImpl();
|
||||||
entries.add(entry);
|
entries.add(entry);
|
||||||
@@ -366,7 +369,7 @@ public class SyndicationFeed {
|
|||||||
if (ArrayUtils.contains(podcastableMIMETypes, mime)) {
|
if (ArrayUtils.contains(podcastableMIMETypes, mime)) {
|
||||||
SyndEnclosure enc = new SyndEnclosureImpl();
|
SyndEnclosure enc = new SyndEnclosureImpl();
|
||||||
enc.setType(bit.getFormat(context).getMIMEType());
|
enc.setType(bit.getFormat(context).getMIMEType());
|
||||||
enc.setLength(bit.getSize());
|
enc.setLength(bit.getSizeBytes());
|
||||||
enc.setUrl(urlOfBitstream(request, bit));
|
enc.setUrl(urlOfBitstream(request, bit));
|
||||||
enclosures.add(enc);
|
enclosures.add(enc);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -22,9 +22,9 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.commons.collections.ListUtils;
|
import org.apache.commons.collections4.ListUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
@@ -44,7 +44,7 @@ public class Util {
|
|||||||
// cache for source version result
|
// cache for source version result
|
||||||
private static String sourceVersion = null;
|
private static String sourceVersion = null;
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(Util.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(Util.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. Must be protected as org.dspace.xmlworkflow.WorkflowUtils extends it
|
* Default constructor. Must be protected as org.dspace.xmlworkflow.WorkflowUtils extends it
|
||||||
@@ -418,31 +418,33 @@ public class Util {
|
|||||||
|
|
||||||
List<DCInputSet> inputSets = inputsReader.getInputsByCollectionHandle(col_handle);
|
List<DCInputSet> inputSets = inputsReader.getInputsByCollectionHandle(col_handle);
|
||||||
|
|
||||||
for (DCInputSet inputSet : inputSets) {
|
|
||||||
// Replace the values of Metadatum[] with the correct ones in case
|
// Replace the values of Metadatum[] with the correct ones in case
|
||||||
// of
|
// of
|
||||||
// controlled vocabularies
|
// controlled vocabularies
|
||||||
String currentField = Utils.standardize(schema, element, qualifier, ".");
|
String currentField = Utils.standardize(schema, element, qualifier, ".");
|
||||||
|
|
||||||
|
for (DCInputSet inputSet : inputSets) {
|
||||||
|
|
||||||
if (inputSet != null) {
|
if (inputSet != null) {
|
||||||
|
|
||||||
int fieldsNums = inputSet.getNumberFields();
|
int fieldsNums = inputSet.getNumberFields();
|
||||||
|
|
||||||
for (int p = 0; p < fieldsNums; p++) {
|
for (int p = 0; p < fieldsNums; p++) {
|
||||||
|
|
||||||
DCInput[] inputs = inputSet.getFields();
|
DCInput[][] inputs = inputSet.getFields();
|
||||||
|
|
||||||
if (inputs != null) {
|
if (inputs != null) {
|
||||||
|
|
||||||
for (int i = 0; i < inputs.length; i++) {
|
for (int i = 0; i < inputs.length; i++) {
|
||||||
String inputField = Utils.standardize(inputs[i].getSchema(), inputs[i].getElement(),
|
for (int j = 0; j < inputs[i].length; j++) {
|
||||||
inputs[i].getQualifier(), ".");
|
String inputField = Utils
|
||||||
|
.standardize(inputs[i][j].getSchema(), inputs[i][j].getElement(),
|
||||||
|
inputs[i][j].getQualifier(), ".");
|
||||||
if (currentField.equals(inputField)) {
|
if (currentField.equals(inputField)) {
|
||||||
|
myInputs = inputs[i][j];
|
||||||
myInputs = inputs[i];
|
|
||||||
myInputsFound = true;
|
myInputsFound = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -471,6 +473,26 @@ public class Util {
|
|||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Split a list in an array of i sub-lists uniformly sized
|
||||||
|
*
|
||||||
|
* @param idsList the list to split
|
||||||
|
* @param i the number of sublists to return
|
||||||
|
*
|
||||||
|
* @return an array of sub-lists of fixed size
|
||||||
|
*/
|
||||||
|
public static <T> List<T>[] splitList(List<T> idsList, int i) {
|
||||||
|
int setmin = idsList.size() / i;
|
||||||
|
List<T>[] result = new List[i];
|
||||||
|
int offset = 0;
|
||||||
|
for (int idx = 0; idx < i - 1; idx++) {
|
||||||
|
result[idx] = idsList.subList(offset, offset + setmin);
|
||||||
|
offset += setmin;
|
||||||
|
}
|
||||||
|
result[i - 1] = idsList.subList(offset, idsList.size());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<String> differenceInSubmissionFields(Collection fromCollection, Collection toCollection)
|
public static List<String> differenceInSubmissionFields(Collection fromCollection, Collection toCollection)
|
||||||
throws DCInputsReaderException {
|
throws DCInputsReaderException {
|
||||||
DCInputsReader reader = new DCInputsReader();
|
DCInputsReader reader = new DCInputsReader();
|
||||||
@@ -480,15 +502,19 @@ public class Util {
|
|||||||
Set<String> fromFieldName = new HashSet<>();
|
Set<String> fromFieldName = new HashSet<>();
|
||||||
Set<String> toFieldName = new HashSet<>();
|
Set<String> toFieldName = new HashSet<>();
|
||||||
for (DCInputSet ff : from) {
|
for (DCInputSet ff : from) {
|
||||||
for (DCInput fdc : ff.getFields()) {
|
for (DCInput[] fdcrow : ff.getFields()) {
|
||||||
|
for (DCInput fdc : fdcrow) {
|
||||||
fromFieldName.add(fdc.getFieldName());
|
fromFieldName.add(fdc.getFieldName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (DCInputSet tt : to) {
|
for (DCInputSet tt : to) {
|
||||||
for (DCInput tdc : tt.getFields()) {
|
for (DCInput[] tdcrow : tt.getFields()) {
|
||||||
|
for (DCInput tdc : tdcrow) {
|
||||||
toFieldName.add(tdc.getFieldName());
|
toFieldName.add(tdc.getFieldName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ListUtils.removeAll(fromFieldName, toFieldName);
|
return ListUtils.removeAll(fromFieldName, toFieldName);
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ import org.apache.http.HttpStatus;
|
|||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.methods.HttpHead;
|
import org.apache.http.client.methods.HttpHead;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.util.dao.WebAppDAO;
|
import org.dspace.app.util.dao.WebAppDAO;
|
||||||
import org.dspace.app.util.service.WebAppService;
|
import org.dspace.app.util.service.WebAppService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -33,7 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
*/
|
*/
|
||||||
public class WebAppServiceImpl implements WebAppService {
|
public class WebAppServiceImpl implements WebAppService {
|
||||||
|
|
||||||
private final Logger log = Logger.getLogger(WebAppServiceImpl.class);
|
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(WebAppServiceImpl.class);
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected WebAppDAO webAppDAO;
|
protected WebAppDAO webAppDAO;
|
||||||
|
@@ -11,7 +11,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,6 +42,13 @@ public interface OpenSearchService {
|
|||||||
*/
|
*/
|
||||||
public List<String> getFormats();
|
public List<String> getFormats();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the module is active
|
||||||
|
*
|
||||||
|
* @return boolean indicator if the OpenSearch module is enabled or not
|
||||||
|
*/
|
||||||
|
public boolean isEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a mime-type associated with passed format
|
* Returns a mime-type associated with passed format
|
||||||
*
|
*
|
||||||
@@ -76,7 +84,7 @@ public interface OpenSearchService {
|
|||||||
* @param totalResults - the hit count
|
* @param totalResults - the hit count
|
||||||
* @param start - start result index
|
* @param start - start result index
|
||||||
* @param pageSize - page size
|
* @param pageSize - page size
|
||||||
* @param scope - search scope, null or community/collection handle
|
* @param scope - search scope, null or the community/collection
|
||||||
* @param results the retreived DSpace objects satisfying search
|
* @param results the retreived DSpace objects satisfying search
|
||||||
* @param labels labels to apply - format specific
|
* @param labels labels to apply - format specific
|
||||||
* @return formatted search results
|
* @return formatted search results
|
||||||
@@ -84,7 +92,7 @@ public interface OpenSearchService {
|
|||||||
*/
|
*/
|
||||||
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
||||||
int pageSize,
|
int pageSize,
|
||||||
DSpaceObject scope, List<DSpaceObject> results,
|
IndexableObject scope, List<IndexableObject> results,
|
||||||
Map<String, String> labels) throws IOException;
|
Map<String, String> labels) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +104,7 @@ public interface OpenSearchService {
|
|||||||
* @param totalResults - the hit count
|
* @param totalResults - the hit count
|
||||||
* @param start - start result index
|
* @param start - start result index
|
||||||
* @param pageSize - page size
|
* @param pageSize - page size
|
||||||
* @param scope - search scope, null or community/collection handle
|
* @param scope - search scope, null or the community/collection
|
||||||
* @param results the retreived DSpace objects satisfying search
|
* @param results the retreived DSpace objects satisfying search
|
||||||
* @param labels labels to apply - format specific
|
* @param labels labels to apply - format specific
|
||||||
* @return formatted search results
|
* @return formatted search results
|
||||||
@@ -104,7 +112,7 @@ public interface OpenSearchService {
|
|||||||
*/
|
*/
|
||||||
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
||||||
int pageSize,
|
int pageSize,
|
||||||
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels)
|
IndexableObject scope, List<IndexableObject> results, Map<String, String> labels)
|
||||||
throws IOException;
|
throws IOException;
|
||||||
|
|
||||||
public DSpaceObject resolveScope(Context context, String scope) throws SQLException;
|
public DSpaceObject resolveScope(Context context, String scope) throws SQLException;
|
||||||
|
@@ -210,4 +210,10 @@ public interface AuthenticationMethod {
|
|||||||
public String loginPageURL(Context context,
|
public String loginPageURL(Context context,
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response);
|
HttpServletResponse response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a short name that uniquely identifies this authentication method
|
||||||
|
* @return The authentication method name
|
||||||
|
*/
|
||||||
|
public String getName();
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,7 @@ package org.dspace.authenticate;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -16,15 +17,15 @@ import java.util.UUID;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.collections.ListUtils;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dspace.core.ConfigurationManager;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.LogManager;
|
import org.dspace.core.LogManager;
|
||||||
|
import org.dspace.core.factory.CoreServiceFactory;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||||
import org.dspace.eperson.service.GroupService;
|
import org.dspace.eperson.service.GroupService;
|
||||||
|
import org.dspace.service.ClientInfoService;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,7 +50,7 @@ public class IPAuthentication implements AuthenticationMethod {
|
|||||||
/**
|
/**
|
||||||
* Our logger
|
* Our logger
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(IPAuthentication.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(IPAuthentication.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to look for x-forwarded headers for logging IP addresses
|
* Whether to look for x-forwarded headers for logging IP addresses
|
||||||
@@ -67,6 +68,7 @@ public class IPAuthentication implements AuthenticationMethod {
|
|||||||
protected List<IPMatcher> ipNegativeMatchers;
|
protected List<IPMatcher> ipNegativeMatchers;
|
||||||
|
|
||||||
protected GroupService groupService;
|
protected GroupService groupService;
|
||||||
|
protected ClientInfoService clientInfoService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,6 +93,7 @@ public class IPAuthentication implements AuthenticationMethod {
|
|||||||
ipMatcherGroupIDs = new HashMap<>();
|
ipMatcherGroupIDs = new HashMap<>();
|
||||||
ipMatcherGroupNames = new HashMap<>();
|
ipMatcherGroupNames = new HashMap<>();
|
||||||
groupService = EPersonServiceFactory.getInstance().getGroupService();
|
groupService = EPersonServiceFactory.getInstance().getGroupService();
|
||||||
|
clientInfoService = CoreServiceFactory.getInstance().getClientInfoService();
|
||||||
|
|
||||||
List<String> propNames = DSpaceServicesFactory.getInstance().getConfigurationService()
|
List<String> propNames = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
.getPropertyKeys("authentication-ip");
|
.getPropertyKeys("authentication-ip");
|
||||||
@@ -164,23 +167,12 @@ public class IPAuthentication implements AuthenticationMethod {
|
|||||||
public List<Group> getSpecialGroups(Context context, HttpServletRequest request)
|
public List<Group> getSpecialGroups(Context context, HttpServletRequest request)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
if (request == null) {
|
if (request == null) {
|
||||||
return ListUtils.EMPTY_LIST;
|
return Collections.EMPTY_LIST;
|
||||||
}
|
}
|
||||||
List<Group> groups = new ArrayList<Group>();
|
List<Group> groups = new ArrayList<Group>();
|
||||||
|
|
||||||
// Get the user's IP address
|
// Get the user's IP address
|
||||||
String addr = request.getRemoteAddr();
|
String addr = clientInfoService.getClientIp(request);
|
||||||
if (useProxies == null) {
|
|
||||||
useProxies = ConfigurationManager.getBooleanProperty("useProxies", false);
|
|
||||||
}
|
|
||||||
if (useProxies && request.getHeader("X-Forwarded-For") != null) {
|
|
||||||
/* This header is a comma delimited list */
|
|
||||||
for (String xfip : request.getHeader("X-Forwarded-For").split(",")) {
|
|
||||||
if (!request.getHeader("X-Forwarded-For").contains(addr)) {
|
|
||||||
addr = xfip.trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (IPMatcher ipm : ipMatchers) {
|
for (IPMatcher ipm : ipMatchers) {
|
||||||
try {
|
try {
|
||||||
@@ -276,4 +268,9 @@ public class IPAuthentication implements AuthenticationMethod {
|
|||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "ip";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ package org.dspace.authenticate;
|
|||||||
import java.net.Inet6Address;
|
import java.net.Inet6Address;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -38,7 +38,7 @@ import org.apache.log4j.Logger;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
public class IPMatcher {
|
public class IPMatcher {
|
||||||
private static Logger log = Logger.getLogger(IPMatcher.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(IPMatcher.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Network to match
|
* Network to match
|
||||||
|
@@ -10,6 +10,7 @@ package org.dspace.authenticate;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.naming.NamingEnumeration;
|
import javax.naming.NamingEnumeration;
|
||||||
@@ -27,9 +28,8 @@ import javax.naming.ldap.StartTlsResponse;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.collections.ListUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
|
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
|
||||||
import org.dspace.authenticate.service.AuthenticationService;
|
import org.dspace.authenticate.service.AuthenticationService;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
@@ -61,7 +61,7 @@ public class LDAPAuthentication
|
|||||||
/**
|
/**
|
||||||
* log4j category
|
* log4j category
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(LDAPAuthentication.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(LDAPAuthentication.class);
|
||||||
|
|
||||||
protected AuthenticationService authenticationService = AuthenticateServiceFactory.getInstance()
|
protected AuthenticationService authenticationService = AuthenticateServiceFactory.getInstance()
|
||||||
.getAuthenticationService();
|
.getAuthenticationService();
|
||||||
@@ -136,7 +136,7 @@ public class LDAPAuthentication
|
|||||||
log.warn(LogManager.getHeader(context,
|
log.warn(LogManager.getHeader(context,
|
||||||
"ldap_specialgroup",
|
"ldap_specialgroup",
|
||||||
"Group defined in login.specialgroup does not exist"));
|
"Group defined in login.specialgroup does not exist"));
|
||||||
return ListUtils.EMPTY_LIST;
|
return Collections.EMPTY_LIST;
|
||||||
} else {
|
} else {
|
||||||
return Arrays.asList(ldapGroup);
|
return Arrays.asList(ldapGroup);
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ public class LDAPAuthentication
|
|||||||
} catch (Exception npe) {
|
} catch (Exception npe) {
|
||||||
// The user is not an LDAP user, so we don't need to worry about them
|
// The user is not an LDAP user, so we don't need to worry about them
|
||||||
}
|
}
|
||||||
return ListUtils.EMPTY_LIST;
|
return Collections.EMPTY_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -639,6 +639,11 @@ public class LDAPAuthentication
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "ldap";
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add authenticated users to the group defined in dspace.cfg by
|
* Add authenticated users to the group defined in dspace.cfg by
|
||||||
* the authentication-ldap.login.groupmap.* key.
|
* the authentication-ldap.login.groupmap.* key.
|
||||||
|
@@ -9,13 +9,13 @@ package org.dspace.authenticate;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.collections.ListUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.LogManager;
|
import org.dspace.core.LogManager;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -49,7 +49,7 @@ public class PasswordAuthentication
|
|||||||
/**
|
/**
|
||||||
* log4j category
|
* log4j category
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(PasswordAuthentication.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(PasswordAuthentication.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,7 +151,7 @@ public class PasswordAuthentication
|
|||||||
"password_specialgroup",
|
"password_specialgroup",
|
||||||
"Group defined in modules/authentication-password.cfg login" +
|
"Group defined in modules/authentication-password.cfg login" +
|
||||||
".specialgroup does not exist"));
|
".specialgroup does not exist"));
|
||||||
return ListUtils.EMPTY_LIST;
|
return Collections.EMPTY_LIST;
|
||||||
} else {
|
} else {
|
||||||
return Arrays.asList(specialGroup);
|
return Arrays.asList(specialGroup);
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ public class PasswordAuthentication
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(LogManager.getHeader(context, "getSpecialGroups", ""), e);
|
log.error(LogManager.getHeader(context, "getSpecialGroups", ""), e);
|
||||||
}
|
}
|
||||||
return ListUtils.EMPTY_LIST;
|
return Collections.EMPTY_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,4 +242,9 @@ public class PasswordAuthentication
|
|||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "password";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ import java.net.URLEncoder;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -22,9 +23,8 @@ import java.util.UUID;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.collections.ListUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
|
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
@@ -70,7 +70,7 @@ public class ShibAuthentication implements AuthenticationMethod {
|
|||||||
/**
|
/**
|
||||||
* log4j category
|
* log4j category
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(ShibAuthentication.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(ShibAuthentication.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional metadata mappings
|
* Additional metadata mappings
|
||||||
@@ -288,7 +288,7 @@ public class ShibAuthentication implements AuthenticationMethod {
|
|||||||
if (request == null ||
|
if (request == null ||
|
||||||
context.getCurrentUser() == null ||
|
context.getCurrentUser() == null ||
|
||||||
request.getSession().getAttribute("shib.authenticated") == null) {
|
request.getSession().getAttribute("shib.authenticated") == null) {
|
||||||
return ListUtils.EMPTY_LIST;
|
return Collections.EMPTY_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have already calculated the special groups then return them.
|
// If we have already calculated the special groups then return them.
|
||||||
@@ -404,7 +404,7 @@ public class ShibAuthentication implements AuthenticationMethod {
|
|||||||
return new ArrayList<>(groups);
|
return new ArrayList<>(groups);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.error("Unable to validate any sepcial groups this user may belong too because of an exception.", t);
|
log.error("Unable to validate any sepcial groups this user may belong too because of an exception.", t);
|
||||||
return ListUtils.EMPTY_LIST;
|
return Collections.EMPTY_LIST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,6 +538,11 @@ public class ShibAuthentication implements AuthenticationMethod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "shibboleth";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify an existing EPerson based upon the shibboleth attributes provided on
|
* Identify an existing EPerson based upon the shibboleth attributes provided on
|
||||||
* the request object. There are three cases where this can occurr, each as
|
* the request object. There are three cases where this can occurr, each as
|
||||||
|
@@ -21,6 +21,7 @@ import java.security.cert.CertificateFactory;
|
|||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
@@ -28,9 +29,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.commons.collections.ListUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
|
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
|
||||||
import org.dspace.authenticate.service.AuthenticationService;
|
import org.dspace.authenticate.service.AuthenticationService;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
@@ -105,7 +105,7 @@ public class X509Authentication implements AuthenticationMethod {
|
|||||||
/**
|
/**
|
||||||
* log4j category
|
* log4j category
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(X509Authentication.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(X509Authentication.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* public key of CA to check client certs against.
|
* public key of CA to check client certs against.
|
||||||
@@ -442,7 +442,7 @@ public class X509Authentication implements AuthenticationMethod {
|
|||||||
public List<Group> getSpecialGroups(Context context, HttpServletRequest request)
|
public List<Group> getSpecialGroups(Context context, HttpServletRequest request)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
if (request == null) {
|
if (request == null) {
|
||||||
return ListUtils.EMPTY_LIST;
|
return Collections.EMPTY_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean authenticated = false;
|
Boolean authenticated = false;
|
||||||
@@ -472,7 +472,7 @@ public class X509Authentication implements AuthenticationMethod {
|
|||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListUtils.EMPTY_LIST;
|
return Collections.EMPTY_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -589,4 +589,9 @@ public class X509Authentication implements AuthenticationMethod {
|
|||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
return loginPageURL;
|
return loginPageURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "x509";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.authority;
|
package org.dspace.authority;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -22,7 +23,8 @@ import org.apache.solr.client.solrj.response.QueryResponse;
|
|||||||
*/
|
*/
|
||||||
public interface AuthoritySearchService {
|
public interface AuthoritySearchService {
|
||||||
|
|
||||||
public QueryResponse search(SolrQuery query) throws SolrServerException, MalformedURLException;
|
public QueryResponse search(SolrQuery query)
|
||||||
|
throws SolrServerException, MalformedURLException, IOException;
|
||||||
|
|
||||||
public List<String> getAllIndexedMetadataFields() throws Exception;
|
public List<String> getAllIndexedMetadataFields() throws Exception;
|
||||||
|
|
||||||
|
@@ -46,17 +46,11 @@ public class AuthorityServiceImpl implements AuthorityService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (AuthorityIndexerInterface indexerInterface : indexers) {
|
for (AuthorityIndexerInterface indexerInterface : indexers) {
|
||||||
|
List<AuthorityValue> authorityValues = indexerInterface.getAuthorityValues(context , item);
|
||||||
indexerInterface.init(context, item);
|
for (AuthorityValue authorityValue : authorityValues) {
|
||||||
while (indexerInterface.hasMore()) {
|
indexingService.indexContent(authorityValue);
|
||||||
AuthorityValue authorityValue = indexerInterface.nextValue();
|
|
||||||
if (authorityValue != null) {
|
|
||||||
indexingService.indexContent(authorityValue, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Close up
|
|
||||||
indexerInterface.close();
|
|
||||||
}
|
|
||||||
//Commit to our server
|
//Commit to our server
|
||||||
indexingService.commit();
|
indexingService.commit();
|
||||||
}
|
}
|
||||||
|
@@ -12,10 +12,10 @@ import java.net.MalformedURLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.solr.client.solrj.SolrQuery;
|
import org.apache.solr.client.solrj.SolrQuery;
|
||||||
import org.apache.solr.client.solrj.SolrServerException;
|
import org.apache.solr.client.solrj.SolrServerException;
|
||||||
import org.apache.solr.client.solrj.impl.HttpSolrServer;
|
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||||
import org.apache.solr.client.solrj.response.FacetField;
|
import org.apache.solr.client.solrj.response.FacetField;
|
||||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
@@ -30,7 +30,7 @@ import org.dspace.core.ConfigurationManager;
|
|||||||
*/
|
*/
|
||||||
public class AuthoritySolrServiceImpl implements AuthorityIndexingService, AuthoritySearchService {
|
public class AuthoritySolrServiceImpl implements AuthorityIndexingService, AuthoritySearchService {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(AuthoritySolrServiceImpl.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(AuthoritySolrServiceImpl.class);
|
||||||
|
|
||||||
protected AuthoritySolrServiceImpl() {
|
protected AuthoritySolrServiceImpl() {
|
||||||
|
|
||||||
@@ -39,16 +39,17 @@ public class AuthoritySolrServiceImpl implements AuthorityIndexingService, Autho
|
|||||||
/**
|
/**
|
||||||
* Non-Static CommonsHttpSolrServer for processing indexing events.
|
* Non-Static CommonsHttpSolrServer for processing indexing events.
|
||||||
*/
|
*/
|
||||||
protected HttpSolrServer solr = null;
|
protected HttpSolrClient solr = null;
|
||||||
|
|
||||||
protected HttpSolrServer getSolr() throws MalformedURLException, SolrServerException {
|
protected HttpSolrClient getSolr()
|
||||||
|
throws MalformedURLException, SolrServerException, IOException {
|
||||||
if (solr == null) {
|
if (solr == null) {
|
||||||
|
|
||||||
String solrService = ConfigurationManager.getProperty("solr.authority.server");
|
String solrService = ConfigurationManager.getProperty("solr.authority.server");
|
||||||
|
|
||||||
log.debug("Solr authority URL: " + solrService);
|
log.debug("Solr authority URL: " + solrService);
|
||||||
|
|
||||||
solr = new HttpSolrServer(solrService);
|
solr = new HttpSolrClient.Builder(solrService).build();
|
||||||
solr.setBaseURL(solrService);
|
solr.setBaseURL(solrService);
|
||||||
|
|
||||||
SolrQuery solrQuery = new SolrQuery().setQuery("*:*");
|
SolrQuery solrQuery = new SolrQuery().setQuery("*:*");
|
||||||
@@ -60,7 +61,7 @@ public class AuthoritySolrServiceImpl implements AuthorityIndexingService, Autho
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void indexContent(AuthorityValue value, boolean force) {
|
public void indexContent(AuthorityValue value) {
|
||||||
SolrInputDocument doc = value.getSolrInputDocument();
|
SolrInputDocument doc = value.getSolrInputDocument();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -129,7 +130,8 @@ public class AuthoritySolrServiceImpl implements AuthorityIndexingService, Autho
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryResponse search(SolrQuery query) throws SolrServerException, MalformedURLException {
|
public QueryResponse search(SolrQuery query)
|
||||||
|
throws SolrServerException, MalformedURLException, IOException {
|
||||||
return getSolr().query(query);
|
return getSolr().query(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains a list of active authority types.
|
* This class contains a list of active authority types.
|
||||||
@@ -32,7 +32,7 @@ public class AuthorityTypes {
|
|||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(AuthorityTypes.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(AuthorityTypes.class);
|
||||||
|
|
||||||
protected List<AuthorityValue> types = new ArrayList<AuthorityValue>();
|
protected List<AuthorityValue> types = new ArrayList<AuthorityValue>();
|
||||||
|
|
||||||
|
@@ -14,8 +14,8 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.solr.common.SolrDocument;
|
import org.apache.solr.common.SolrDocument;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
@@ -234,7 +234,7 @@ public class AuthorityValue {
|
|||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(AuthorityValue.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(AuthorityValue.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@@ -13,8 +13,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.solr.client.solrj.SolrQuery;
|
import org.apache.solr.client.solrj.SolrQuery;
|
||||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||||
import org.apache.solr.common.SolrDocument;
|
import org.apache.solr.common.SolrDocument;
|
||||||
@@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
*/
|
*/
|
||||||
public class AuthorityValueServiceImpl implements AuthorityValueService {
|
public class AuthorityValueServiceImpl implements AuthorityValueService {
|
||||||
|
|
||||||
private final Logger log = Logger.getLogger(AuthorityValueServiceImpl.class);
|
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(AuthorityValueServiceImpl.class);
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected AuthorityTypes authorityTypes;
|
protected AuthorityTypes authorityTypes;
|
||||||
|
@@ -12,8 +12,8 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.solr.common.SolrDocument;
|
import org.apache.solr.common.SolrDocument;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
|
||||||
|
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.authority;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jonas Van Goolen (jonas at atmire dot com)
|
||||||
|
*/
|
||||||
|
public interface SolrAuthorityInterface {
|
||||||
|
|
||||||
|
List<AuthorityValue> queryAuthorities(String text, int max);
|
||||||
|
|
||||||
|
AuthorityValue queryAuthorityID(String id);
|
||||||
|
}
|
@@ -19,7 +19,7 @@ import org.apache.commons.cli.HelpFormatter;
|
|||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||||
import org.dspace.authority.service.AuthorityValueService;
|
import org.dspace.authority.service.AuthorityValueService;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
@@ -40,7 +40,7 @@ public class UpdateAuthorities {
|
|||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(UpdateAuthorities.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(UpdateAuthorities.class);
|
||||||
|
|
||||||
protected PrintWriter print = null;
|
protected PrintWriter print = null;
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||||
import org.dspace.authority.service.AuthorityService;
|
import org.dspace.authority.service.AuthorityService;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
@@ -33,7 +33,7 @@ import org.dspace.event.Event;
|
|||||||
*/
|
*/
|
||||||
public class AuthorityConsumer implements Consumer {
|
public class AuthorityConsumer implements Consumer {
|
||||||
|
|
||||||
private final Logger log = Logger.getLogger(AuthorityConsumer.class);
|
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(AuthorityConsumer.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of all item IDs installed which need their authority updated
|
* A set of all item IDs installed which need their authority updated
|
||||||
|
@@ -8,13 +8,17 @@
|
|||||||
package org.dspace.authority.indexer;
|
package org.dspace.authority.indexer;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.authority.AuthorityValue;
|
import org.dspace.authority.AuthorityValue;
|
||||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||||
import org.dspace.authority.service.AuthorityService;
|
import org.dspace.authority.service.AuthorityService;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,7 +29,7 @@ import org.dspace.core.Context;
|
|||||||
*/
|
*/
|
||||||
public class AuthorityIndexClient {
|
public class AuthorityIndexClient {
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(AuthorityIndexClient.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(AuthorityIndexClient.class);
|
||||||
|
|
||||||
protected static final AuthorityService authorityService =
|
protected static final AuthorityService authorityService =
|
||||||
AuthorityServiceFactory.getInstance().getAuthorityService();
|
AuthorityServiceFactory.getInstance().getAuthorityService();
|
||||||
@@ -33,6 +37,8 @@ public class AuthorityIndexClient {
|
|||||||
AuthorityServiceFactory.getInstance().getAuthorityIndexingService();
|
AuthorityServiceFactory.getInstance().getAuthorityIndexingService();
|
||||||
protected static final List<AuthorityIndexerInterface> indexers =
|
protected static final List<AuthorityIndexerInterface> indexers =
|
||||||
AuthorityServiceFactory.getInstance().getAuthorityIndexers();
|
AuthorityServiceFactory.getInstance().getAuthorityIndexers();
|
||||||
|
protected static final ItemService itemService =
|
||||||
|
ContentServiceFactory.getInstance().getItemService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
@@ -64,15 +70,17 @@ public class AuthorityIndexClient {
|
|||||||
for (AuthorityIndexerInterface indexerInterface : indexers) {
|
for (AuthorityIndexerInterface indexerInterface : indexers) {
|
||||||
log.info("Initialize " + indexerInterface.getClass().getName());
|
log.info("Initialize " + indexerInterface.getClass().getName());
|
||||||
System.out.println("Initialize " + indexerInterface.getClass().getName());
|
System.out.println("Initialize " + indexerInterface.getClass().getName());
|
||||||
indexerInterface.init(context, true);
|
Iterator<Item> allItems = itemService.findAll(context);
|
||||||
while (indexerInterface.hasMore()) {
|
Map<String, AuthorityValue> authorityCache = new HashMap<>();
|
||||||
AuthorityValue authorityValue = indexerInterface.nextValue();
|
while (allItems.hasNext()) {
|
||||||
if (authorityValue != null) {
|
Item item = allItems.next();
|
||||||
|
List<AuthorityValue> authorityValues = indexerInterface.getAuthorityValues(
|
||||||
|
context, item, authorityCache);
|
||||||
|
for (AuthorityValue authorityValue : authorityValues) {
|
||||||
toIndexValues.put(authorityValue.getId(), authorityValue);
|
toIndexValues.put(authorityValue.getId(), authorityValue);
|
||||||
}
|
}
|
||||||
|
context.uncacheEntity(item);
|
||||||
}
|
}
|
||||||
//Close up
|
|
||||||
indexerInterface.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,7 +90,7 @@ public class AuthorityIndexClient {
|
|||||||
log.info("Writing new data");
|
log.info("Writing new data");
|
||||||
System.out.println("Writing new data");
|
System.out.println("Writing new data");
|
||||||
for (String id : toIndexValues.keySet()) {
|
for (String id : toIndexValues.keySet()) {
|
||||||
indexingService.indexContent(toIndexValues.get(id), true);
|
indexingService.indexContent(toIndexValues.get(id));
|
||||||
indexingService.commit();
|
indexingService.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,6 +9,8 @@
|
|||||||
package org.dspace.authority.indexer;
|
package org.dspace.authority.indexer;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.dspace.authority.AuthorityValue;
|
import org.dspace.authority.AuthorityValue;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
@@ -23,17 +25,10 @@ import org.dspace.core.Context;
|
|||||||
*/
|
*/
|
||||||
public interface AuthorityIndexerInterface {
|
public interface AuthorityIndexerInterface {
|
||||||
|
|
||||||
public void init(Context context, Item item);
|
public List<AuthorityValue> getAuthorityValues(Context context, Item item)
|
||||||
|
throws SQLException, AuthorizeException;
|
||||||
public void init(Context context, boolean useCache);
|
public List<AuthorityValue> getAuthorityValues(Context context, Item item, Map<String, AuthorityValue> cache)
|
||||||
|
throws SQLException, AuthorizeException;
|
||||||
public void init(Context context);
|
|
||||||
|
|
||||||
public AuthorityValue nextValue();
|
|
||||||
|
|
||||||
public boolean hasMore() throws SQLException, AuthorizeException;
|
|
||||||
|
|
||||||
public void close();
|
|
||||||
|
|
||||||
public boolean isConfiguredProperly();
|
public boolean isConfiguredProperly();
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@ import org.dspace.authority.AuthorityValue;
|
|||||||
public interface AuthorityIndexingService {
|
public interface AuthorityIndexingService {
|
||||||
|
|
||||||
|
|
||||||
public void indexContent(AuthorityValue value, boolean force);
|
public void indexContent(AuthorityValue value);
|
||||||
|
|
||||||
public void cleanIndex() throws Exception;
|
public void cleanIndex() throws Exception;
|
||||||
|
|
||||||
|
@@ -9,14 +9,12 @@ package org.dspace.authority.indexer;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.authority.AuthorityValue;
|
import org.dspace.authority.AuthorityValue;
|
||||||
import org.dspace.authority.service.AuthorityValueService;
|
import org.dspace.authority.service.AuthorityValueService;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
@@ -31,12 +29,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
/**
|
/**
|
||||||
* DSpaceAuthorityIndexer is used in IndexClient, which is called by the AuthorityConsumer and the indexing-script.
|
* DSpaceAuthorityIndexer is used in IndexClient, which is called by the AuthorityConsumer and the indexing-script.
|
||||||
* <p>
|
* <p>
|
||||||
* An instance of DSpaceAuthorityIndexer is bound to a list of items.
|
* The DSpaceAuthorityIndexer will return a list of all authority values for a
|
||||||
* This can be one item or all items too depending on the init() method.
|
* given item. It will return an authority value for all metadata fields defined
|
||||||
|
* in dspace.conf with 'authority.author.indexer.field'.
|
||||||
* <p>
|
* <p>
|
||||||
* DSpaceAuthorityIndexer lets you iterate over each metadata value
|
* You have to call getAuthorityValues for every Item you want to index. But you
|
||||||
* for each metadata field defined in dspace.cfg with 'authority.author.indexer.field'
|
* can supply an optional cache, to save the mapping from the metadata value to
|
||||||
* for each item in the list.
|
* the new authority values for metadata fields without an authority key.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
* @author Antoine Snyers (antoine at atmire.com)
|
||||||
@@ -46,25 +45,16 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
*/
|
*/
|
||||||
public class DSpaceAuthorityIndexer implements AuthorityIndexerInterface, InitializingBean {
|
public class DSpaceAuthorityIndexer implements AuthorityIndexerInterface, InitializingBean {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(DSpaceAuthorityIndexer.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(DSpaceAuthorityIndexer.class);
|
||||||
|
|
||||||
protected Iterator<Item> itemIterator;
|
|
||||||
protected Item currentItem;
|
|
||||||
/**
|
/**
|
||||||
* The list of metadata fields which are to be indexed *
|
* The list of metadata fields which are to be indexed *
|
||||||
*/
|
*/
|
||||||
protected List<String> metadataFields;
|
protected List<String> metadataFields;
|
||||||
protected int currentFieldIndex;
|
|
||||||
protected int currentMetadataIndex;
|
|
||||||
protected AuthorityValue nextValue;
|
|
||||||
protected Context context;
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected AuthorityValueService authorityValueService;
|
protected AuthorityValueService authorityValueService;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected ItemService itemService;
|
protected ItemService itemService;
|
||||||
protected boolean useCache;
|
|
||||||
protected Map<String, AuthorityValue> cache;
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected ConfigurationService configurationService;
|
protected ConfigurationService configurationService;
|
||||||
@@ -80,146 +70,83 @@ public class DSpaceAuthorityIndexer implements AuthorityIndexerInterface, Initia
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Context context, Item item) {
|
public List<AuthorityValue> getAuthorityValues(Context context, Item item)
|
||||||
ArrayList<Item> itemList = new ArrayList<>();
|
throws SQLException, AuthorizeException {
|
||||||
itemList.add(item);
|
return getAuthorityValues(context, item, null);
|
||||||
this.itemIterator = itemList.iterator();
|
|
||||||
currentItem = this.itemIterator.next();
|
|
||||||
initialize(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public List<AuthorityValue> getAuthorityValues(Context context, Item item, Map<String, AuthorityValue> cache)
|
||||||
public void init(Context context) {
|
throws SQLException, AuthorizeException {
|
||||||
init(context, false);
|
List<AuthorityValue> values = new ArrayList<>();
|
||||||
|
for (String metadataField : metadataFields) {
|
||||||
|
List<MetadataValue> metadataValues = itemService.getMetadataByMetadataString(item, metadataField);
|
||||||
|
for (MetadataValue metadataValue : metadataValues) {
|
||||||
|
String content = metadataValue.getValue();
|
||||||
|
String authorityKey = metadataValue.getAuthority();
|
||||||
|
// We only want to update our item IF our UUID is not present
|
||||||
|
// or if we need to generate one.
|
||||||
|
boolean requiresItemUpdate = StringUtils.isBlank(authorityKey) ||
|
||||||
|
StringUtils.startsWith(authorityKey, AuthorityValueService.GENERATE);
|
||||||
|
AuthorityValue value = null;
|
||||||
|
if (StringUtils.isBlank(authorityKey) && cache != null) {
|
||||||
|
// This is a value currently without an authority. So query
|
||||||
|
// the cache, if an authority is found for the exact value.
|
||||||
|
value = cache.get(content);
|
||||||
}
|
}
|
||||||
|
if (value == null) {
|
||||||
@Override
|
value = getAuthorityValue(context, metadataField, content,authorityKey);
|
||||||
public void init(Context context, boolean useCache) {
|
}
|
||||||
|
if (value != null) {
|
||||||
|
if (requiresItemUpdate) {
|
||||||
|
value.updateItem(context, item, metadataValue);
|
||||||
try {
|
try {
|
||||||
this.itemIterator = itemService.findAll(context);
|
itemService.update(context, item);
|
||||||
currentItem = this.itemIterator.next();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.error("Error while retrieving all items in the metadata indexer");
|
|
||||||
}
|
|
||||||
initialize(context);
|
|
||||||
this.useCache = useCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void initialize(Context context) {
|
|
||||||
this.context = context;
|
|
||||||
|
|
||||||
currentFieldIndex = 0;
|
|
||||||
currentMetadataIndex = 0;
|
|
||||||
useCache = false;
|
|
||||||
cache = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AuthorityValue nextValue() {
|
|
||||||
return nextValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasMore() throws SQLException, AuthorizeException {
|
|
||||||
if (currentItem == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. iterate over the metadata values
|
|
||||||
|
|
||||||
String metadataField = metadataFields.get(currentFieldIndex);
|
|
||||||
List<MetadataValue> values = itemService.getMetadataByMetadataString(currentItem, metadataField);
|
|
||||||
if (currentMetadataIndex < values.size()) {
|
|
||||||
prepareNextValue(metadataField, values.get(currentMetadataIndex));
|
|
||||||
|
|
||||||
currentMetadataIndex++;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// 2. iterate over the metadata fields
|
|
||||||
|
|
||||||
if ((currentFieldIndex + 1) < metadataFields.size()) {
|
|
||||||
currentFieldIndex++;
|
|
||||||
//Reset our current metadata index since we are moving to another field
|
|
||||||
currentMetadataIndex = 0;
|
|
||||||
return hasMore();
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// 3. iterate over the items
|
|
||||||
if (itemIterator.hasNext()) {
|
|
||||||
currentItem = itemIterator.next();
|
|
||||||
//Reset our current field index
|
|
||||||
currentFieldIndex = 0;
|
|
||||||
//Reset our current metadata index
|
|
||||||
currentMetadataIndex = 0;
|
|
||||||
} else {
|
|
||||||
currentItem = null;
|
|
||||||
}
|
|
||||||
return hasMore();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method looks at the authority of a metadata.
|
|
||||||
* If the authority can be found in solr, that value is reused.
|
|
||||||
* Otherwise a new authority value will be generated that will be indexed in solr.
|
|
||||||
* If the authority starts with AuthorityValueGenerator.GENERATE, a specific type of AuthorityValue will be
|
|
||||||
* generated.
|
|
||||||
* Depending on the type this may involve querying an external REST service
|
|
||||||
*
|
|
||||||
* @param metadataField Is one of the fields defined in dspace.cfg to be indexed.
|
|
||||||
* @param value Is one of the values of the given metadataField in one of the items being indexed.
|
|
||||||
* @throws SQLException if database error
|
|
||||||
* @throws AuthorizeException if authorization error
|
|
||||||
*/
|
|
||||||
protected void prepareNextValue(String metadataField, MetadataValue value) throws SQLException, AuthorizeException {
|
|
||||||
|
|
||||||
nextValue = null;
|
|
||||||
|
|
||||||
String content = value.getValue();
|
|
||||||
String authorityKey = value.getAuthority();
|
|
||||||
//We only want to update our item IF our UUID is not present or if we need to generate one.
|
|
||||||
boolean requiresItemUpdate = StringUtils.isBlank(authorityKey) || StringUtils
|
|
||||||
.startsWith(authorityKey, AuthorityValueService.GENERATE);
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(authorityKey) && !authorityKey.startsWith(AuthorityValueService.GENERATE)) {
|
|
||||||
// !uid.startsWith(AuthorityValueGenerator.GENERATE) is not strictly necessary here but it prevents
|
|
||||||
// exceptions in solr
|
|
||||||
nextValue = authorityValueService.findByUID(context, authorityKey);
|
|
||||||
}
|
|
||||||
if (nextValue == null && StringUtils.isBlank(authorityKey) && useCache) {
|
|
||||||
// A metadata without authority is being indexed
|
|
||||||
// If there is an exact match in the cache, reuse it rather than adding a new one.
|
|
||||||
AuthorityValue cachedAuthorityValue = cache.get(content);
|
|
||||||
if (cachedAuthorityValue != null) {
|
|
||||||
nextValue = cachedAuthorityValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nextValue == null) {
|
|
||||||
nextValue = authorityValueService
|
|
||||||
.generate(context, authorityKey, content, metadataField.replaceAll("\\.", "_"));
|
|
||||||
}
|
|
||||||
if (nextValue != null && requiresItemUpdate) {
|
|
||||||
nextValue.updateItem(context, currentItem, value);
|
|
||||||
try {
|
|
||||||
itemService.update(context, currentItem);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error creating a metadatavalue's authority", e);
|
log.error("Error creating a metadatavalue's authority", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (useCache) {
|
if (cache != null) {
|
||||||
cache.put(content, nextValue);
|
cache.put(content, value);
|
||||||
|
}
|
||||||
|
values.add(value);
|
||||||
|
} else {
|
||||||
|
log.error("Error getting an authority value for " +
|
||||||
|
"the metadata value \"" + content + "\" " +
|
||||||
|
"in the field \"" + metadataField + "\" " +
|
||||||
|
"of the item " + item.getHandle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
return values;
|
||||||
public void close() {
|
}
|
||||||
itemIterator = null;
|
/**
|
||||||
cache.clear();
|
* This method looks at the authority of a metadata value.
|
||||||
|
* If the authority can be found in solr, that value is reused.
|
||||||
|
* Otherwise a new authority value will be generated that will be indexed in solr.
|
||||||
|
*
|
||||||
|
* If the authority starts with AuthorityValueGenerator.GENERATE, a specific type of AuthorityValue will be
|
||||||
|
* generated.
|
||||||
|
* Depending on the type this may involve querying an external REST service
|
||||||
|
*
|
||||||
|
* @param context Current DSpace context
|
||||||
|
* @param metadataField Is one of the fields defined in dspace.cfg to be indexed.
|
||||||
|
* @param metadataContent Content of the current metadata value.
|
||||||
|
* @param metadataAuthorityKey Existing authority of the metadata value.
|
||||||
|
*/
|
||||||
|
private AuthorityValue getAuthorityValue(Context context, String metadataField,
|
||||||
|
String metadataContent, String metadataAuthorityKey) {
|
||||||
|
if (StringUtils.isNotBlank(metadataAuthorityKey) &&
|
||||||
|
!metadataAuthorityKey.startsWith(AuthorityValueService.GENERATE)) {
|
||||||
|
// !uid.startsWith(AuthorityValueGenerator.GENERATE) is not strictly
|
||||||
|
// necessary here but it prevents exceptions in solr
|
||||||
|
AuthorityValue value = authorityValueService.findByUID(context, metadataAuthorityKey);
|
||||||
|
if (value != null) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return authorityValueService.generate(context, metadataAuthorityKey,
|
||||||
|
metadataContent, metadataField.replaceAll("\\.", "_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -1,87 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid;
|
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dspace.authority.AuthorityValue;
|
|
||||||
import org.dspace.authority.orcid.model.Bio;
|
|
||||||
import org.dspace.authority.orcid.model.Work;
|
|
||||||
import org.dspace.authority.orcid.xml.XMLtoBio;
|
|
||||||
import org.dspace.authority.orcid.xml.XMLtoWork;
|
|
||||||
import org.dspace.authority.rest.RestSource;
|
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class Orcid extends RestSource {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* log4j logger
|
|
||||||
*/
|
|
||||||
private static Logger log = Logger.getLogger(Orcid.class);
|
|
||||||
|
|
||||||
private static Orcid orcid;
|
|
||||||
|
|
||||||
public static Orcid getOrcid() {
|
|
||||||
if (orcid == null) {
|
|
||||||
orcid = DSpaceServicesFactory.getInstance().getServiceManager()
|
|
||||||
.getServiceByName("OrcidSource", Orcid.class);
|
|
||||||
}
|
|
||||||
return orcid;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Orcid(String url) {
|
|
||||||
super(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bio getBio(String id) {
|
|
||||||
Document bioDocument = restConnector.get(id + "/orcid-bio");
|
|
||||||
XMLtoBio converter = new XMLtoBio();
|
|
||||||
Bio bio = converter.convert(bioDocument).get(0);
|
|
||||||
bio.setOrcid(id);
|
|
||||||
return bio;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Work> getWorks(String id) {
|
|
||||||
Document document = restConnector.get(id + "/orcid-works");
|
|
||||||
XMLtoWork converter = new XMLtoWork();
|
|
||||||
return converter.convert(document);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Bio> queryBio(String name, int start, int rows) {
|
|
||||||
Document bioDocument = restConnector
|
|
||||||
.get("search/orcid-bio?q=" + URLEncoder.encode("\"" + name + "\"") + "&start=" + start + "&rows=" + rows);
|
|
||||||
XMLtoBio converter = new XMLtoBio();
|
|
||||||
return converter.convert(bioDocument);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AuthorityValue> queryAuthorities(String text, int max) {
|
|
||||||
List<Bio> bios = queryBio(text, 0, max);
|
|
||||||
List<AuthorityValue> authorities = new ArrayList<AuthorityValue>();
|
|
||||||
for (Bio bio : bios) {
|
|
||||||
authorities.add(OrcidAuthorityValue.create(bio));
|
|
||||||
}
|
|
||||||
return authorities;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AuthorityValue queryAuthorityID(String id) {
|
|
||||||
Bio bio = getBio(id);
|
|
||||||
return OrcidAuthorityValue.create(bio);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,328 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.apache.solr.common.SolrDocument;
|
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
|
||||||
import org.dspace.authority.AuthorityValue;
|
|
||||||
import org.dspace.authority.AuthorityValueServiceImpl;
|
|
||||||
import org.dspace.authority.PersonAuthorityValue;
|
|
||||||
import org.dspace.authority.orcid.model.Bio;
|
|
||||||
import org.dspace.authority.orcid.model.BioExternalIdentifier;
|
|
||||||
import org.dspace.authority.orcid.model.BioName;
|
|
||||||
import org.dspace.authority.orcid.model.BioResearcherUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class OrcidAuthorityValue extends PersonAuthorityValue {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* log4j logger
|
|
||||||
*/
|
|
||||||
private static Logger log = Logger.getLogger(OrcidAuthorityValue.class);
|
|
||||||
|
|
||||||
private String orcid_id;
|
|
||||||
private Map<String, List<String>> otherMetadata = new HashMap<String, List<String>>();
|
|
||||||
private boolean update; // used in setValues(Bio bio)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an instance of OrcidAuthorityValue with only uninitialized fields.
|
|
||||||
* This is meant to be filled in with values from an existing record.
|
|
||||||
* To create a brand new OrcidAuthorityValue, use create()
|
|
||||||
*/
|
|
||||||
public OrcidAuthorityValue() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrcidAuthorityValue(SolrDocument document) {
|
|
||||||
super(document);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOrcid_id() {
|
|
||||||
return orcid_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrcid_id(String orcid_id) {
|
|
||||||
this.orcid_id = orcid_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, List<String>> getOtherMetadata() {
|
|
||||||
return otherMetadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addOtherMetadata(String label, String data) {
|
|
||||||
List<String> strings = otherMetadata.get(label);
|
|
||||||
if (strings == null) {
|
|
||||||
strings = new ArrayList<String>();
|
|
||||||
}
|
|
||||||
strings.add(data);
|
|
||||||
otherMetadata.put(label, strings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SolrInputDocument getSolrInputDocument() {
|
|
||||||
SolrInputDocument doc = super.getSolrInputDocument();
|
|
||||||
if (StringUtils.isNotBlank(getOrcid_id())) {
|
|
||||||
doc.addField("orcid_id", getOrcid_id());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String t : otherMetadata.keySet()) {
|
|
||||||
List<String> data = otherMetadata.get(t);
|
|
||||||
for (String data_entry : data) {
|
|
||||||
doc.addField("label_" + t, data_entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValues(SolrDocument document) {
|
|
||||||
super.setValues(document);
|
|
||||||
this.orcid_id = String.valueOf(document.getFieldValue("orcid_id"));
|
|
||||||
|
|
||||||
otherMetadata = new HashMap<String, List<String>>();
|
|
||||||
for (String fieldName : document.getFieldNames()) {
|
|
||||||
String labelPrefix = "label_";
|
|
||||||
if (fieldName.startsWith(labelPrefix)) {
|
|
||||||
String label = fieldName.substring(labelPrefix.length());
|
|
||||||
List<String> list = new ArrayList<String>();
|
|
||||||
Collection<Object> fieldValues = document.getFieldValues(fieldName);
|
|
||||||
for (Object o : fieldValues) {
|
|
||||||
list.add(String.valueOf(o));
|
|
||||||
}
|
|
||||||
otherMetadata.put(label, list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OrcidAuthorityValue create() {
|
|
||||||
OrcidAuthorityValue orcidAuthorityValue = new OrcidAuthorityValue();
|
|
||||||
orcidAuthorityValue.setId(UUID.randomUUID().toString());
|
|
||||||
orcidAuthorityValue.updateLastModifiedDate();
|
|
||||||
orcidAuthorityValue.setCreationDate(new Date());
|
|
||||||
return orcidAuthorityValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an authority based on a given orcid bio
|
|
||||||
*
|
|
||||||
* @param bio Bio
|
|
||||||
* @return OrcidAuthorityValue
|
|
||||||
*/
|
|
||||||
public static OrcidAuthorityValue create(Bio bio) {
|
|
||||||
OrcidAuthorityValue authority = OrcidAuthorityValue.create();
|
|
||||||
|
|
||||||
authority.setValues(bio);
|
|
||||||
|
|
||||||
return authority;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setValues(Bio bio) {
|
|
||||||
BioName name = bio.getName();
|
|
||||||
|
|
||||||
if (updateValue(bio.getOrcid(), getOrcid_id())) {
|
|
||||||
setOrcid_id(bio.getOrcid());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updateValue(name.getFamilyName(), getLastName())) {
|
|
||||||
setLastName(name.getFamilyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updateValue(name.getGivenNames(), getFirstName())) {
|
|
||||||
setFirstName(name.getGivenNames());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(name.getCreditName())) {
|
|
||||||
if (!getNameVariants().contains(name.getCreditName())) {
|
|
||||||
addNameVariant(name.getCreditName());
|
|
||||||
update = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (String otherName : name.getOtherNames()) {
|
|
||||||
if (!getNameVariants().contains(otherName)) {
|
|
||||||
addNameVariant(otherName);
|
|
||||||
update = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updateOtherMetadata("country", bio.getCountry())) {
|
|
||||||
addOtherMetadata("country", bio.getCountry());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String keyword : bio.getKeywords()) {
|
|
||||||
if (updateOtherMetadata("keyword", keyword)) {
|
|
||||||
addOtherMetadata("keyword", keyword);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BioExternalIdentifier externalIdentifier : bio.getBioExternalIdentifiers()) {
|
|
||||||
if (updateOtherMetadata("external_identifier", externalIdentifier.toString())) {
|
|
||||||
addOtherMetadata("external_identifier", externalIdentifier.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BioResearcherUrl researcherUrl : bio.getResearcherUrls()) {
|
|
||||||
if (updateOtherMetadata("researcher_url", researcherUrl.toString())) {
|
|
||||||
addOtherMetadata("researcher_url", researcherUrl.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updateOtherMetadata("biography", bio.getBiography())) {
|
|
||||||
addOtherMetadata("biography", bio.getBiography());
|
|
||||||
}
|
|
||||||
|
|
||||||
setValue(getName());
|
|
||||||
|
|
||||||
if (update) {
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
boolean result = update;
|
|
||||||
update = false;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean updateOtherMetadata(String label, String data) {
|
|
||||||
List<String> strings = getOtherMetadata().get(label);
|
|
||||||
boolean update;
|
|
||||||
if (strings == null) {
|
|
||||||
update = StringUtils.isNotBlank(data);
|
|
||||||
} else {
|
|
||||||
update = !strings.contains(data);
|
|
||||||
}
|
|
||||||
if (update) {
|
|
||||||
this.update = true;
|
|
||||||
}
|
|
||||||
return update;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean updateValue(String incoming, String resident) {
|
|
||||||
boolean update = StringUtils.isNotBlank(incoming) && !incoming.equals(resident);
|
|
||||||
if (update) {
|
|
||||||
this.update = true;
|
|
||||||
}
|
|
||||||
return update;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, String> choiceSelectMap() {
|
|
||||||
|
|
||||||
Map<String, String> map = super.choiceSelectMap();
|
|
||||||
|
|
||||||
map.put("orcid", getOrcid_id());
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAuthorityType() {
|
|
||||||
return "orcid";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String generateString() {
|
|
||||||
String generateString = AuthorityValueServiceImpl.GENERATE + getAuthorityType() + AuthorityValueServiceImpl
|
|
||||||
.SPLIT;
|
|
||||||
if (StringUtils.isNotBlank(getOrcid_id())) {
|
|
||||||
generateString += getOrcid_id();
|
|
||||||
}
|
|
||||||
return generateString;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AuthorityValue newInstance(String info) {
|
|
||||||
AuthorityValue authorityValue = null;
|
|
||||||
if (StringUtils.isNotBlank(info)) {
|
|
||||||
Orcid orcid = Orcid.getOrcid();
|
|
||||||
authorityValue = orcid.queryAuthorityID(info);
|
|
||||||
} else {
|
|
||||||
authorityValue = OrcidAuthorityValue.create();
|
|
||||||
}
|
|
||||||
return authorityValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
OrcidAuthorityValue that = (OrcidAuthorityValue) o;
|
|
||||||
|
|
||||||
if (orcid_id != null ? !orcid_id.equals(that.orcid_id) : that.orcid_id != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return orcid_id != null ? orcid_id.hashCode() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasTheSameInformationAs(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!super.hasTheSameInformationAs(o)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
OrcidAuthorityValue that = (OrcidAuthorityValue) o;
|
|
||||||
|
|
||||||
if (orcid_id != null ? !orcid_id.equals(that.orcid_id) : that.orcid_id != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String key : otherMetadata.keySet()) {
|
|
||||||
if (otherMetadata.get(key) != null) {
|
|
||||||
List<String> metadata = otherMetadata.get(key);
|
|
||||||
List<String> otherMetadata = that.otherMetadata.get(key);
|
|
||||||
if (otherMetadata == null) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
HashSet<String> metadataSet = new HashSet<String>(metadata);
|
|
||||||
HashSet<String> otherMetadataSet = new HashSet<String>(otherMetadata);
|
|
||||||
if (!metadataSet.equals(otherMetadataSet)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (that.otherMetadata.get(key) != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
191
dspace-api/src/main/java/org/dspace/authority/orcid/Orcidv2.java
Normal file
191
dspace-api/src/main/java/org/dspace/authority/orcid/Orcidv2.java
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.authority.orcid;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.client.HttpClient;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.dspace.authority.AuthorityValue;
|
||||||
|
import org.dspace.authority.SolrAuthorityInterface;
|
||||||
|
import org.dspace.authority.orcid.xml.XMLtoBio;
|
||||||
|
import org.dspace.authority.rest.RESTConnector;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.orcid.jaxb.model.record_v2.Person;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jonas Van Goolen (jonas at atmire dot com)
|
||||||
|
* This class contains all methods for retrieving "Person" objects calling the ORCID (version 2) endpoints.
|
||||||
|
* Additionally, this can also create AuthorityValues based on these returned Person objects
|
||||||
|
*/
|
||||||
|
public class Orcidv2 implements SolrAuthorityInterface {
|
||||||
|
|
||||||
|
private static Logger log = LogManager.getLogger(Orcidv2.class);
|
||||||
|
|
||||||
|
public RESTConnector restConnector;
|
||||||
|
private String OAUTHUrl;
|
||||||
|
private String clientId;
|
||||||
|
|
||||||
|
private String clientSecret;
|
||||||
|
|
||||||
|
private String accessToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the accessToken that is required for all subsequent calls to ORCID.
|
||||||
|
*
|
||||||
|
* @throws java.io.IOException passed through from HTTPclient.
|
||||||
|
*/
|
||||||
|
public void init() throws IOException {
|
||||||
|
if (StringUtils.isNotBlank(accessToken) && StringUtils.isNotBlank(clientSecret)) {
|
||||||
|
String authenticationParameters = "?client_id=" + clientId +
|
||||||
|
"&client_secret=" + clientSecret +
|
||||||
|
"&scope=/read-public&grant_type=client_credentials";
|
||||||
|
HttpPost httpPost = new HttpPost(OAUTHUrl + authenticationParameters);
|
||||||
|
httpPost.addHeader("Accept", "application/json");
|
||||||
|
httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
|
||||||
|
HttpClient httpClient = HttpClientBuilder.create().build();
|
||||||
|
HttpResponse getResponse = httpClient.execute(httpPost);
|
||||||
|
|
||||||
|
InputStream is = getResponse.getEntity().getContent();
|
||||||
|
BufferedReader streamReader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||||
|
|
||||||
|
JSONObject responseObject = null;
|
||||||
|
String inputStr;
|
||||||
|
while ((inputStr = streamReader.readLine()) != null && responseObject == null) {
|
||||||
|
if (inputStr.startsWith("{") && inputStr.endsWith("}") && inputStr.contains("access_token")) {
|
||||||
|
try {
|
||||||
|
responseObject = new JSONObject(inputStr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
//Not as valid as I'd hoped, move along
|
||||||
|
responseObject = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseObject != null && responseObject.has("access_token")) {
|
||||||
|
accessToken = (String) responseObject.get("access_token");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes an instance of the Orcidv2 class based on the provided parameters.
|
||||||
|
* This constructor is called through the spring bean initialization
|
||||||
|
*/
|
||||||
|
private Orcidv2(String url, String OAUTHUrl, String clientId, String clientSecret) {
|
||||||
|
this.restConnector = new RESTConnector(url);
|
||||||
|
this.OAUTHUrl = OAUTHUrl;
|
||||||
|
this.clientId = clientId;
|
||||||
|
this.clientSecret = clientSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes an instance of the Orcidv2 class based on the provided parameters.
|
||||||
|
* This constructor is called through the spring bean initialization
|
||||||
|
*/
|
||||||
|
private Orcidv2(String url) {
|
||||||
|
this.restConnector = new RESTConnector(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes an instance of the AuthorityValue with the given information.
|
||||||
|
* @param text search string
|
||||||
|
* @return List<AuthorityValue>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AuthorityValue> queryAuthorities(String text, int max) {
|
||||||
|
List<Person> bios = queryBio(text, max);
|
||||||
|
List<AuthorityValue> result = new ArrayList<>();
|
||||||
|
for (Person person : bios) {
|
||||||
|
AuthorityValue orcidAuthorityValue = Orcidv2AuthorityValue.create(person);
|
||||||
|
if (orcidAuthorityValue != null) {
|
||||||
|
result.add(orcidAuthorityValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an AuthorityValue from a Person retrieved using the given orcid identifier.
|
||||||
|
* @param id orcid identifier
|
||||||
|
* @return AuthorityValue
|
||||||
|
*/
|
||||||
|
public AuthorityValue queryAuthorityID(String id) {
|
||||||
|
Person person = getBio(id);
|
||||||
|
AuthorityValue valueFromPerson = Orcidv2AuthorityValue.create(person);
|
||||||
|
return valueFromPerson;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a Person object based on a given orcid identifier
|
||||||
|
* @param id orcid identifier
|
||||||
|
* @return Person
|
||||||
|
*/
|
||||||
|
public Person getBio(String id) {
|
||||||
|
log.debug("getBio called with ID=" + id);
|
||||||
|
if (!isValid(id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
InputStream bioDocument = restConnector.get(id + ((id.endsWith("/person")) ? "" : "/person"), accessToken);
|
||||||
|
XMLtoBio converter = new XMLtoBio();
|
||||||
|
Person person = converter.convertSinglePerson(bioDocument);
|
||||||
|
return person;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a list of Person objects.
|
||||||
|
* @param text search string
|
||||||
|
* @param start offset to use
|
||||||
|
* @param rows how many rows to return
|
||||||
|
* @return List<Person>
|
||||||
|
*/
|
||||||
|
public List<Person> queryBio(String text, int start, int rows) {
|
||||||
|
if (rows > 100) {
|
||||||
|
throw new IllegalArgumentException("The maximum number of results to retrieve cannot exceed 100.");
|
||||||
|
}
|
||||||
|
|
||||||
|
String searchPath = "search?q=" + URLEncoder.encode(text) + "&start=" + start + "&rows=" + rows;
|
||||||
|
log.debug("queryBio searchPath=" + searchPath + " accessToken=" + accessToken);
|
||||||
|
InputStream bioDocument = restConnector.get(searchPath, accessToken);
|
||||||
|
XMLtoBio converter = new XMLtoBio();
|
||||||
|
List<Person> bios = converter.convert(bioDocument);
|
||||||
|
return bios;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a list of Person objects.
|
||||||
|
* @param text search string
|
||||||
|
* @param max how many rows to return
|
||||||
|
* @return List<Person>
|
||||||
|
*/
|
||||||
|
public List<Person> queryBio(String text, int max) {
|
||||||
|
return queryBio(text, 0, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if the provided text has the correct ORCID syntax.
|
||||||
|
* Since only searching on ORCID id is allowed, this way, we filter out any queries that would return a
|
||||||
|
* blank result anyway
|
||||||
|
*/
|
||||||
|
private boolean isValid(String text) {
|
||||||
|
return StringUtils.isNotBlank(text) && text.matches(Orcidv2AuthorityValue.ORCID_ID_SYNTAX);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,342 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.authority.orcid;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.solr.common.SolrDocument;
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.authority.AuthorityValue;
|
||||||
|
import org.dspace.authority.AuthorityValueServiceImpl;
|
||||||
|
import org.dspace.authority.PersonAuthorityValue;
|
||||||
|
import org.dspace.utils.DSpace;
|
||||||
|
import org.orcid.jaxb.model.common_v2.ExternalId;
|
||||||
|
import org.orcid.jaxb.model.record_v2.ExternalIdentifiers;
|
||||||
|
import org.orcid.jaxb.model.record_v2.KeywordType;
|
||||||
|
import org.orcid.jaxb.model.record_v2.NameType;
|
||||||
|
import org.orcid.jaxb.model.record_v2.Person;
|
||||||
|
import org.orcid.jaxb.model.record_v2.ResearcherUrlType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jonas Van Goolen (jonas at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class Orcidv2AuthorityValue extends PersonAuthorityValue {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The ORCID identifier
|
||||||
|
*/
|
||||||
|
private String orcid_id;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Map containing key-value pairs filled in by "setValues(Person person)".
|
||||||
|
* This represents all dynamic information of the object.
|
||||||
|
*/
|
||||||
|
private Map<String, List<String>> otherMetadata = new HashMap<String, List<String>>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The syntax that the ORCID id needs to conform to
|
||||||
|
*/
|
||||||
|
public static final String ORCID_ID_SYNTAX = "\\d{4}-\\d{4}-\\d{4}-(\\d{3}X|\\d{4})";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of Orcidv2AuthorityValue with only uninitialized fields.
|
||||||
|
* This is meant to be filled in with values from an existing record.
|
||||||
|
* To create a brand new Orcidv2AuthorityValue, use create()
|
||||||
|
*/
|
||||||
|
public Orcidv2AuthorityValue() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Orcidv2AuthorityValue(SolrDocument document) {
|
||||||
|
super(document);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getOrcid_id() {
|
||||||
|
return orcid_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrcid_id(String orcid_id) {
|
||||||
|
this.orcid_id = orcid_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an empty authority.
|
||||||
|
* @return OrcidAuthorityValue
|
||||||
|
*/
|
||||||
|
public static Orcidv2AuthorityValue create() {
|
||||||
|
Orcidv2AuthorityValue orcidAuthorityValue = new Orcidv2AuthorityValue();
|
||||||
|
orcidAuthorityValue.setId(UUID.randomUUID().toString());
|
||||||
|
orcidAuthorityValue.updateLastModifiedDate();
|
||||||
|
orcidAuthorityValue.setCreationDate(new Date());
|
||||||
|
return orcidAuthorityValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an authority based on a given orcid bio
|
||||||
|
* @return OrcidAuthorityValue
|
||||||
|
*/
|
||||||
|
public static Orcidv2AuthorityValue create(Person person) {
|
||||||
|
if (person == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Orcidv2AuthorityValue authority = Orcidv2AuthorityValue.create();
|
||||||
|
|
||||||
|
authority.setValues(person);
|
||||||
|
|
||||||
|
return authority;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize this instance based on a Person object
|
||||||
|
* @param person Person
|
||||||
|
*/
|
||||||
|
protected void setValues(Person person) {
|
||||||
|
NameType name = person.getName();
|
||||||
|
|
||||||
|
if (!StringUtils.equals(name.getPath(), this.getOrcid_id())) {
|
||||||
|
this.setOrcid_id(name.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.equals(name.getFamilyName().getValue(), this.getLastName())) {
|
||||||
|
this.setLastName(name.getFamilyName().getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.equals(name.getGivenNames().getValue(), this.getFirstName())) {
|
||||||
|
this.setFirstName(name.getGivenNames().getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.getCreditName() != null && StringUtils.isNotBlank(name.getCreditName().getValue())) {
|
||||||
|
if (!this.getNameVariants().contains(name.getCreditName().getValue())) {
|
||||||
|
this.addNameVariant(name.getCreditName().getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (person.getKeywords() != null) {
|
||||||
|
for (KeywordType keyword : person.getKeywords().getKeyword()) {
|
||||||
|
if (this.isNewMetadata("keyword", keyword.getContent())) {
|
||||||
|
this.addOtherMetadata("keyword", keyword.getContent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ExternalIdentifiers externalIdentifiers = person.getExternalIdentifiers();
|
||||||
|
if (externalIdentifiers != null) {
|
||||||
|
for (ExternalId externalIdentifier : externalIdentifiers.getExternalIdentifier()) {
|
||||||
|
if (this.isNewMetadata("external_identifier", externalIdentifier.getExternalIdValue())) {
|
||||||
|
this.addOtherMetadata("external_identifier", externalIdentifier.getExternalIdValue());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (person.getResearcherUrls() != null) {
|
||||||
|
for (ResearcherUrlType researcherUrl : person.getResearcherUrls().getResearcherUrl()) {
|
||||||
|
if (this.isNewMetadata("researcher_url", researcherUrl.getUrl().getValue())) {
|
||||||
|
this.addOtherMetadata("researcher_url", researcherUrl.getUrl().getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (person.getBiography() != null) {
|
||||||
|
if (this.isNewMetadata("biography", person.getBiography().getContent())) {
|
||||||
|
this.addOtherMetadata("biography", person.getBiography().getContent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setValue(this.getName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes an instance of the AuthorityValue with the given information.
|
||||||
|
* @param info string info
|
||||||
|
* @return AuthorityValue
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AuthorityValue newInstance(String info) {
|
||||||
|
AuthorityValue authorityValue = null;
|
||||||
|
if (StringUtils.isNotBlank(info)) {
|
||||||
|
Orcidv2 orcid = new DSpace().getServiceManager().getServiceByName("AuthoritySource", Orcidv2.class);
|
||||||
|
authorityValue = orcid.queryAuthorityID(info);
|
||||||
|
} else {
|
||||||
|
authorityValue = this.create();
|
||||||
|
}
|
||||||
|
return authorityValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(String value) {
|
||||||
|
super.setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if the provided label / data pair is already present in the "otherMetadata" or not
|
||||||
|
* */
|
||||||
|
public boolean isNewMetadata(String label, String data) {
|
||||||
|
List<String> strings = getOtherMetadata().get(label);
|
||||||
|
boolean update;
|
||||||
|
if (strings == null) {
|
||||||
|
update = StringUtils.isNotBlank(data);
|
||||||
|
} else {
|
||||||
|
update = !strings.contains(data);
|
||||||
|
}
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add additional metadata to the otherMetadata map*/
|
||||||
|
public void addOtherMetadata(String label, String data) {
|
||||||
|
List<String> strings = otherMetadata.get(label);
|
||||||
|
if (strings == null) {
|
||||||
|
strings = new ArrayList<>();
|
||||||
|
}
|
||||||
|
strings.add(data);
|
||||||
|
otherMetadata.put(label, strings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<String>> getOtherMetadata() {
|
||||||
|
return otherMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a solr record from this instance
|
||||||
|
* @return SolrInputDocument
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SolrInputDocument getSolrInputDocument() {
|
||||||
|
SolrInputDocument doc = super.getSolrInputDocument();
|
||||||
|
if (StringUtils.isNotBlank(getOrcid_id())) {
|
||||||
|
doc.addField("orcid_id", getOrcid_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String t : otherMetadata.keySet()) {
|
||||||
|
List<String> data = otherMetadata.get(t);
|
||||||
|
for (String data_entry : data) {
|
||||||
|
doc.addField("label_" + t, data_entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information that can be used the choice ui
|
||||||
|
* @return map
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, String> choiceSelectMap() {
|
||||||
|
|
||||||
|
Map<String, String> map = super.choiceSelectMap();
|
||||||
|
|
||||||
|
String orcid_id = getOrcid_id();
|
||||||
|
if (StringUtils.isNotBlank(orcid_id)) {
|
||||||
|
map.put("orcid", orcid_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAuthorityType() {
|
||||||
|
return "orcid";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a string that will allow this AuthorityType to be recognized and provides information to create a new
|
||||||
|
* instance to be created using public Orcidv2AuthorityValue newInstance(String info).
|
||||||
|
* @return see {@link org.dspace.authority.service.AuthorityValueService#GENERATE AuthorityValueService.GENERATE}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String generateString() {
|
||||||
|
String generateString = AuthorityValueServiceImpl.GENERATE + getAuthorityType() +
|
||||||
|
AuthorityValueServiceImpl.SPLIT;
|
||||||
|
if (StringUtils.isNotBlank(getOrcid_id())) {
|
||||||
|
generateString += getOrcid_id();
|
||||||
|
}
|
||||||
|
return generateString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Orcidv2AuthorityValue that = (Orcidv2AuthorityValue) o;
|
||||||
|
|
||||||
|
if (orcid_id != null ? !orcid_id.equals(that.orcid_id) : that.orcid_id != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return orcid_id != null ? orcid_id.hashCode() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The regular equals() only checks if both AuthorityValues describe the same authority.
|
||||||
|
* This method checks if the AuthorityValues have different information
|
||||||
|
* E.g. it is used to decide when lastModified should be updated.
|
||||||
|
* @param o object
|
||||||
|
* @return true or false
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean hasTheSameInformationAs(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!super.hasTheSameInformationAs(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Orcidv2AuthorityValue that = (Orcidv2AuthorityValue) o;
|
||||||
|
|
||||||
|
if (orcid_id != null ? !orcid_id.equals(that.orcid_id) : that.orcid_id != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String key : otherMetadata.keySet()) {
|
||||||
|
if (otherMetadata.get(key) != null) {
|
||||||
|
List<String> metadata = otherMetadata.get(key);
|
||||||
|
List<String> otherMetadata = that.otherMetadata.get(key);
|
||||||
|
if (otherMetadata == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
HashSet<String> metadataSet = new HashSet<String>(metadata);
|
||||||
|
HashSet<String> otherMetadataSet = new HashSet<String>(otherMetadata);
|
||||||
|
if (!metadataSet.equals(otherMetadataSet)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (that.otherMetadata.get(key) != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,112 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class Bio {
|
|
||||||
|
|
||||||
protected String orcid;
|
|
||||||
|
|
||||||
protected BioName name;
|
|
||||||
|
|
||||||
protected String country;
|
|
||||||
|
|
||||||
protected Set<String> keywords;
|
|
||||||
|
|
||||||
protected Set<BioExternalIdentifier> bioExternalIdentifiers;
|
|
||||||
|
|
||||||
protected Set<BioResearcherUrl> researcherUrls;
|
|
||||||
|
|
||||||
protected String biography;
|
|
||||||
|
|
||||||
public Bio() {
|
|
||||||
this.name = new BioName();
|
|
||||||
keywords = new LinkedHashSet<String>();
|
|
||||||
bioExternalIdentifiers = new LinkedHashSet<BioExternalIdentifier>();
|
|
||||||
researcherUrls = new LinkedHashSet<BioResearcherUrl>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOrcid() {
|
|
||||||
return orcid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrcid(String orcid) {
|
|
||||||
this.orcid = orcid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BioName getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(BioName name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCountry() {
|
|
||||||
return country;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCountry(String country) {
|
|
||||||
this.country = country;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getKeywords() {
|
|
||||||
return keywords;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addKeyword(String keyword) {
|
|
||||||
this.keywords.add(keyword);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<BioExternalIdentifier> getBioExternalIdentifiers() {
|
|
||||||
return bioExternalIdentifiers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addExternalIdentifier(BioExternalIdentifier externalReference) {
|
|
||||||
bioExternalIdentifiers.add(externalReference);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<BioResearcherUrl> getResearcherUrls() {
|
|
||||||
return researcherUrls;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addResearcherUrl(BioResearcherUrl researcherUrl) {
|
|
||||||
researcherUrls.add(researcherUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBiography() {
|
|
||||||
return biography;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBiography(String biography) {
|
|
||||||
this.biography = biography;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Bio{" +
|
|
||||||
"orcid='" + orcid + '\'' +
|
|
||||||
", name=" + name +
|
|
||||||
", country='" + country + '\'' +
|
|
||||||
", keywords=" + keywords +
|
|
||||||
", bioExternalIdentifiers=" + bioExternalIdentifiers +
|
|
||||||
", researcherUrls=" + researcherUrls +
|
|
||||||
", biography='" + biography + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@@ -1,108 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class BioExternalIdentifier {
|
|
||||||
|
|
||||||
|
|
||||||
protected String id_orcid;
|
|
||||||
protected String id_common_name;
|
|
||||||
protected String id_reference;
|
|
||||||
protected String id_url;
|
|
||||||
|
|
||||||
public BioExternalIdentifier(String id_orcid, String id_common_name, String id_reference, String id_url) {
|
|
||||||
this.id_orcid = id_orcid;
|
|
||||||
this.id_common_name = id_common_name;
|
|
||||||
this.id_reference = id_reference;
|
|
||||||
this.id_url = id_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId_orcid() {
|
|
||||||
return id_orcid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId_orcid(String id_orcid) {
|
|
||||||
this.id_orcid = id_orcid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId_common_name() {
|
|
||||||
return id_common_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId_common_name(String id_common_name) {
|
|
||||||
this.id_common_name = id_common_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId_reference() {
|
|
||||||
return id_reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId_reference(String id_reference) {
|
|
||||||
this.id_reference = id_reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId_url() {
|
|
||||||
return id_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId_url(String id_url) {
|
|
||||||
this.id_url = id_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "BioExternalIdentifier{" +
|
|
||||||
"id_orcid='" + id_orcid + '\'' +
|
|
||||||
", id_common_name='" + id_common_name + '\'' +
|
|
||||||
", id_reference='" + id_reference + '\'' +
|
|
||||||
", id_url='" + id_url + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
BioExternalIdentifier that = (BioExternalIdentifier) o;
|
|
||||||
|
|
||||||
if (id_common_name != null ? !id_common_name.equals(that.id_common_name) : that.id_common_name != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (id_orcid != null ? !id_orcid.equals(that.id_orcid) : that.id_orcid != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (id_reference != null ? !id_reference.equals(that.id_reference) : that.id_reference != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (id_url != null ? !id_url.equals(that.id_url) : that.id_url != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = id_orcid != null ? id_orcid.hashCode() : 0;
|
|
||||||
result = 31 * result + (id_common_name != null ? id_common_name.hashCode() : 0);
|
|
||||||
result = 31 * result + (id_reference != null ? id_reference.hashCode() : 0);
|
|
||||||
result = 31 * result + (id_url != null ? id_url.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,114 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class BioName {
|
|
||||||
|
|
||||||
protected String givenNames;
|
|
||||||
protected String familyName;
|
|
||||||
protected String creditName;
|
|
||||||
protected List<String> otherNames;
|
|
||||||
|
|
||||||
BioName() {
|
|
||||||
otherNames = new ArrayList<String>();
|
|
||||||
}
|
|
||||||
|
|
||||||
BioName(String givenNames, String familyName, String creditName, List<String> otherNames) {
|
|
||||||
this.givenNames = givenNames;
|
|
||||||
this.familyName = familyName;
|
|
||||||
this.creditName = creditName;
|
|
||||||
this.otherNames = otherNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGivenNames() {
|
|
||||||
return givenNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGivenNames(String givenNames) {
|
|
||||||
this.givenNames = givenNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFamilyName() {
|
|
||||||
return familyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFamilyName(String familyName) {
|
|
||||||
this.familyName = familyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCreditName() {
|
|
||||||
return creditName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreditName(String creditName) {
|
|
||||||
this.creditName = creditName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getOtherNames() {
|
|
||||||
return otherNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOtherNames(List<String> otherNames) {
|
|
||||||
this.otherNames = otherNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "BioName{" +
|
|
||||||
"givenNames='" + givenNames + '\'' +
|
|
||||||
", familyName='" + familyName + '\'' +
|
|
||||||
", creditName='" + creditName + '\'' +
|
|
||||||
", otherNames=" + otherNames +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
BioName bioName = (BioName) o;
|
|
||||||
|
|
||||||
if (creditName != null ? !creditName.equals(bioName.creditName) : bioName.creditName != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (familyName != null ? !familyName.equals(bioName.familyName) : bioName.familyName != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (givenNames != null ? !givenNames.equals(bioName.givenNames) : bioName.givenNames != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (otherNames != null ? !otherNames.equals(bioName.otherNames) : bioName.otherNames != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = givenNames != null ? givenNames.hashCode() : 0;
|
|
||||||
result = 31 * result + (familyName != null ? familyName.hashCode() : 0);
|
|
||||||
result = 31 * result + (creditName != null ? creditName.hashCode() : 0);
|
|
||||||
result = 31 * result + (otherNames != null ? otherNames.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,77 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class BioResearcherUrl {
|
|
||||||
|
|
||||||
protected String name;
|
|
||||||
protected String url;
|
|
||||||
|
|
||||||
public BioResearcherUrl(String name, String url) {
|
|
||||||
this.name = name;
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "BioResearcherUrl{" +
|
|
||||||
"name='" + name + '\'' +
|
|
||||||
", url='" + url + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
BioResearcherUrl that = (BioResearcherUrl) o;
|
|
||||||
|
|
||||||
if (name != null ? !name.equals(that.name) : that.name != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (url != null ? !url.equals(that.url) : that.url != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = name != null ? name.hashCode() : 0;
|
|
||||||
result = 31 * result + (url != null ? url.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,49 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class Citation {
|
|
||||||
|
|
||||||
private CitationType type;
|
|
||||||
private String citation;
|
|
||||||
|
|
||||||
public Citation(CitationType type, String citation) {
|
|
||||||
this.type = type;
|
|
||||||
this.citation = citation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CitationType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(CitationType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCitation() {
|
|
||||||
return citation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCitation(String citation) {
|
|
||||||
this.citation = citation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Citation{" +
|
|
||||||
"type=" + type +
|
|
||||||
", citation='" + citation + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public enum CitationType {
|
|
||||||
|
|
||||||
FORMATTED_UNSPECIFIED,
|
|
||||||
BIBTEX,
|
|
||||||
FORMATTED_APA,
|
|
||||||
FORMATTED_HARVARD,
|
|
||||||
FORMATTED_IEEE,
|
|
||||||
FORMATTED_MLA,
|
|
||||||
FORMATTED_VANCOUVER,
|
|
||||||
FORMATTED_CHICAGO
|
|
||||||
|
|
||||||
}
|
|
@@ -1,111 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class Contributor {
|
|
||||||
|
|
||||||
private String orcid;
|
|
||||||
private String creditName;
|
|
||||||
private String email;
|
|
||||||
private Set<ContributorAttribute> contributorAttributes;
|
|
||||||
|
|
||||||
public Contributor(String orcid, String creditName, String email, Set<ContributorAttribute> contributorAttributes) {
|
|
||||||
this.orcid = orcid;
|
|
||||||
this.creditName = creditName;
|
|
||||||
this.email = email;
|
|
||||||
this.contributorAttributes = contributorAttributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOrcid() {
|
|
||||||
return orcid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrcid(String orcid) {
|
|
||||||
this.orcid = orcid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCreditName() {
|
|
||||||
return creditName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreditName(String creditName) {
|
|
||||||
this.creditName = creditName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEmail() {
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmail(String email) {
|
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<ContributorAttribute> getContributorAttributes() {
|
|
||||||
return contributorAttributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContributorAttributes(Set<ContributorAttribute> contributorAttributes) {
|
|
||||||
this.contributorAttributes = contributorAttributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Contributor{" +
|
|
||||||
"orcid='" + orcid + '\'' +
|
|
||||||
", creditName='" + creditName + '\'' +
|
|
||||||
", email='" + email + '\'' +
|
|
||||||
", contributorAttributes=" + contributorAttributes +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Contributor that = (Contributor) o;
|
|
||||||
|
|
||||||
if (contributorAttributes != null ? !contributorAttributes
|
|
||||||
.equals(that.contributorAttributes) : that.contributorAttributes != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (creditName != null ? !creditName.equals(that.creditName) : that.creditName != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (email != null ? !email.equals(that.email) : that.email != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (orcid != null ? !orcid.equals(that.orcid) : that.orcid != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = orcid != null ? orcid.hashCode() : 0;
|
|
||||||
result = 31 * result + (creditName != null ? creditName.hashCode() : 0);
|
|
||||||
result = 31 * result + (email != null ? email.hashCode() : 0);
|
|
||||||
result = 31 * result + (contributorAttributes != null ? contributorAttributes.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,78 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class ContributorAttribute {
|
|
||||||
|
|
||||||
private ContributorAttributeRole role;
|
|
||||||
private ContributorAttributeSequence sequence;
|
|
||||||
|
|
||||||
public ContributorAttribute(ContributorAttributeRole role, ContributorAttributeSequence sequence) {
|
|
||||||
this.role = role;
|
|
||||||
this.sequence = sequence;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContributorAttributeRole getRole() {
|
|
||||||
return role;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRole(ContributorAttributeRole role) {
|
|
||||||
this.role = role;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContributorAttributeSequence getSequence() {
|
|
||||||
return sequence;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSequence(ContributorAttributeSequence sequence) {
|
|
||||||
this.sequence = sequence;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "ContributorAttribute{" +
|
|
||||||
"role=" + role +
|
|
||||||
", sequence=" + sequence +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ContributorAttribute that = (ContributorAttribute) o;
|
|
||||||
|
|
||||||
if (role != that.role) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (sequence != that.sequence) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = role != null ? role.hashCode() : 0;
|
|
||||||
result = 31 * result + (sequence != null ? sequence.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,32 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* http://support.orcid.org/knowledgebase/articles/118843-anatomy-of-a-contributor
|
|
||||||
*
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public enum ContributorAttributeRole {
|
|
||||||
|
|
||||||
AUTHOR,
|
|
||||||
ASSIGNEE,
|
|
||||||
EDITOR,
|
|
||||||
CHAIR_OR_TRANSLATOR,
|
|
||||||
CO_INVESTIGATOR,
|
|
||||||
CO_INVENTOR,
|
|
||||||
GRADUATE_STUDENT,
|
|
||||||
OTHER_INVENTOR,
|
|
||||||
PRINCIPAL_INVESTIGATOR,
|
|
||||||
POSTDOCTORAL_RESEARCHER,
|
|
||||||
SUPPORT_STAFF
|
|
||||||
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* http://support.orcid.org/knowledgebase/articles/118843-anatomy-of-a-contributor
|
|
||||||
*
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public enum ContributorAttributeSequence {
|
|
||||||
|
|
||||||
FIRST,
|
|
||||||
ADDITIONAL
|
|
||||||
|
|
||||||
}
|
|
@@ -1,116 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class Work {
|
|
||||||
|
|
||||||
private WorkTitle workTitle;
|
|
||||||
private String description;
|
|
||||||
private Citation citation;
|
|
||||||
private WorkType workType;
|
|
||||||
private String publicationDate;
|
|
||||||
private WorkExternalIdentifier workExternalIdentifier;
|
|
||||||
private String url;
|
|
||||||
private Set<Contributor> contributors;
|
|
||||||
private String workSource;
|
|
||||||
|
|
||||||
public WorkTitle getWorkTitle() {
|
|
||||||
return workTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorkTitle(WorkTitle workTitle) {
|
|
||||||
this.workTitle = workTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Citation getCitation() {
|
|
||||||
return citation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCitation(Citation citation) {
|
|
||||||
this.citation = citation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkType getWorkType() {
|
|
||||||
return workType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorkType(WorkType workType) {
|
|
||||||
this.workType = workType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPublicationDate() {
|
|
||||||
return publicationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublicationDate(String publicationDate) {
|
|
||||||
this.publicationDate = publicationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkExternalIdentifier getWorkExternalIdentifier() {
|
|
||||||
return workExternalIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorkExternalIdentifier(WorkExternalIdentifier workExternalIdentifier) {
|
|
||||||
this.workExternalIdentifier = workExternalIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Contributor> getContributors() {
|
|
||||||
return contributors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContributors(Set<Contributor> contributors) {
|
|
||||||
this.contributors = contributors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWorkSource() {
|
|
||||||
return workSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorkSource(String workSource) {
|
|
||||||
this.workSource = workSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Work{" +
|
|
||||||
"workTitle=" + workTitle +
|
|
||||||
", description='" + description + '\'' +
|
|
||||||
", citation=" + citation +
|
|
||||||
", workType=" + workType +
|
|
||||||
", publicationDate='" + publicationDate + '\'' +
|
|
||||||
", workExternalIdentifier=" + workExternalIdentifier +
|
|
||||||
", url='" + url + '\'' +
|
|
||||||
", contributors=" + contributors +
|
|
||||||
", workSource='" + workSource + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,73 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* http://support.orcid.org/knowledgebase/articles/118807
|
|
||||||
*
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class WorkExternalIdentifier {
|
|
||||||
|
|
||||||
private WorkExternalIdentifierType workExternalIdentifierType;
|
|
||||||
private String workExternalIdenfitierID;
|
|
||||||
|
|
||||||
public WorkExternalIdentifier(WorkExternalIdentifierType workExternalIdentifierType,
|
|
||||||
String workExternalIdenfitierID) {
|
|
||||||
this.workExternalIdentifierType = workExternalIdentifierType;
|
|
||||||
this.workExternalIdenfitierID = workExternalIdenfitierID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkExternalIdentifierType getWorkExternalIdentifierType() {
|
|
||||||
return workExternalIdentifierType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorkExternalIdentifierType(WorkExternalIdentifierType workExternalIdentifierType) {
|
|
||||||
this.workExternalIdentifierType = workExternalIdentifierType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "WorkExternalIdentifier{" +
|
|
||||||
"workExternalIdentifierType=" + workExternalIdentifierType +
|
|
||||||
", workExternalIdenfitierID='" + workExternalIdenfitierID + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkExternalIdentifier that = (WorkExternalIdentifier) o;
|
|
||||||
|
|
||||||
if (workExternalIdenfitierID != null ? !workExternalIdenfitierID
|
|
||||||
.equals(that.workExternalIdenfitierID) : that.workExternalIdenfitierID != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (workExternalIdentifierType != that.workExternalIdentifierType) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = workExternalIdentifierType != null ? workExternalIdentifierType.hashCode() : 0;
|
|
||||||
result = 31 * result + (workExternalIdenfitierID != null ? workExternalIdenfitierID.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,42 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* http://support.orcid.org/knowledgebase/articles/118807
|
|
||||||
*
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public enum WorkExternalIdentifierType {
|
|
||||||
|
|
||||||
// OTHER_ID,
|
|
||||||
ARXIV,
|
|
||||||
ASIN,
|
|
||||||
ASIN_TLD,
|
|
||||||
BIBCODE,
|
|
||||||
DOI,
|
|
||||||
EID,
|
|
||||||
ISBN,
|
|
||||||
ISSN,
|
|
||||||
JFM,
|
|
||||||
JSTOR,
|
|
||||||
LCCN,
|
|
||||||
MR,
|
|
||||||
OCLC,
|
|
||||||
OL,
|
|
||||||
OSTI,
|
|
||||||
PMC,
|
|
||||||
PMID,
|
|
||||||
RFC,
|
|
||||||
SSRN,
|
|
||||||
ZBL
|
|
||||||
|
|
||||||
}
|
|
@@ -1,64 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* http://support.orcid.org/knowledgebase/articles/118807
|
|
||||||
*
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class WorkTitle {
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
private String subtitle;
|
|
||||||
private Map<String, String> translatedTitles;
|
|
||||||
|
|
||||||
public WorkTitle(String title, String subtitle, Map<String, String> translatedTitles) {
|
|
||||||
this.title = title;
|
|
||||||
this.subtitle = subtitle;
|
|
||||||
this.translatedTitles = translatedTitles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSubtitle() {
|
|
||||||
return subtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubtitle(String subtitle) {
|
|
||||||
this.subtitle = subtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTranslatedTitles(String languageCode) {
|
|
||||||
return translatedTitles.get(languageCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTranslatedTitle(String languageCode, String translatedTitle) {
|
|
||||||
translatedTitles.put(languageCode, translatedTitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "WorkTitle{" +
|
|
||||||
"title='" + title + '\'' +
|
|
||||||
", subtitle='" + subtitle + '\'' +
|
|
||||||
", translatedTitles=" + translatedTitles +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* http://support.orcid.org/knowledgebase/articles/118795
|
|
||||||
*
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public enum WorkType {
|
|
||||||
|
|
||||||
BOOK,
|
|
||||||
BOOK_CHAPTER,
|
|
||||||
BOOK_REVIEW,
|
|
||||||
DICTIONARY_ENTRY,
|
|
||||||
DISSERTATION,
|
|
||||||
ENCYCLOPEDIA_ARTICLE,
|
|
||||||
EDITED_BOOK,
|
|
||||||
JOURNAL_ARTICLE,
|
|
||||||
JOURNAL_ISSUE,
|
|
||||||
MAGAZINE_ARTICLE,
|
|
||||||
MANUAL,
|
|
||||||
ONLINE_RESOURCE,
|
|
||||||
NEWSLETTER_ARTICLE,
|
|
||||||
NEWSPAPER_ARTICLE,
|
|
||||||
REPORT,
|
|
||||||
RESEARCH_TOOL,
|
|
||||||
SUPERVISED_STUDENT_PUBLICATION,
|
|
||||||
TEST,
|
|
||||||
TRANSLATION,
|
|
||||||
WEBSITE,
|
|
||||||
CONFERENCE_ABSTRACT,
|
|
||||||
CONFERENCE_PAPER,
|
|
||||||
CONFERENCE_POSTER,
|
|
||||||
DISCLOSURE,
|
|
||||||
LICENSE,
|
|
||||||
PATENT,
|
|
||||||
REGISTERED_COPYRIGHT,
|
|
||||||
ARTISTIC_PERFORMANCE,
|
|
||||||
DATA_SET,
|
|
||||||
INVENTION,
|
|
||||||
LECTURE_SPEECH,
|
|
||||||
RESEARCH_TECHNIQUE,
|
|
||||||
SPIN_OFF_COMPANY,
|
|
||||||
STANDARDS_AND_POLICY,
|
|
||||||
TECHNICAL_STANDARD,
|
|
||||||
OTHER
|
|
||||||
|
|
||||||
}
|
|
@@ -7,8 +7,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.authority.orcid.xml;
|
package org.dspace.authority.orcid.xml;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import java.io.InputStream;
|
||||||
import org.w3c.dom.Document;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param <T> type
|
* @param <T> type
|
||||||
@@ -22,13 +29,17 @@ public abstract class Converter<T> {
|
|||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
*/
|
*/
|
||||||
private static Logger log = Logger.getLogger(Converter.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(Converter.class);
|
||||||
|
|
||||||
|
public abstract T convert(InputStream document);
|
||||||
|
|
||||||
protected void processError(Document xml) {
|
protected Object unmarshall(InputStream input, Class<?> type) throws SAXException, URISyntaxException {
|
||||||
String errorMessage = XMLErrors.getErrorMessage(xml);
|
try {
|
||||||
log.error("The orcid-message reports an error: " + errorMessage);
|
JAXBContext context = JAXBContext.newInstance(type);
|
||||||
|
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||||
|
return unmarshaller.unmarshal(input);
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
throw new RuntimeException("Unable to unmarshall orcid message" + e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract T convert(Document document);
|
|
||||||
}
|
}
|
||||||
|
@@ -1,77 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.authority.orcid.xml;
|
|
||||||
|
|
||||||
import javax.xml.xpath.XPathExpressionException;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.dspace.authority.util.XMLUtils;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Antoine Snyers (antoine at atmire.com)
|
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
|
||||||
* @author Ben Bosman (ben at atmire dot com)
|
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
|
||||||
*/
|
|
||||||
public class XMLErrors {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* log4j logger
|
|
||||||
*/
|
|
||||||
private static Logger log = Logger.getLogger(XMLErrors.class);
|
|
||||||
|
|
||||||
private static final String ERROR_DESC = "/orcid-message/error-desc";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor
|
|
||||||
*/
|
|
||||||
private XMLErrors() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Evaluates whether a given xml document contains errors or not.
|
|
||||||
*
|
|
||||||
* @param xml The given xml document
|
|
||||||
* @return true if the given xml document is null
|
|
||||||
* or if it contains errors
|
|
||||||
*/
|
|
||||||
public static boolean check(Document xml) {
|
|
||||||
|
|
||||||
if (xml == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String textContent = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
textContent = XMLUtils.getTextContent(xml, ERROR_DESC);
|
|
||||||
} catch (XPathExpressionException e) {
|
|
||||||
log.error("Error while checking for errors in orcid message", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return textContent == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getErrorMessage(Document xml) {
|
|
||||||
|
|
||||||
if (xml == null) {
|
|
||||||
return "Did not receive an XML document.";
|
|
||||||
}
|
|
||||||
|
|
||||||
String textContent = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
textContent = XMLUtils.getTextContent(xml, ERROR_DESC);
|
|
||||||
} catch (XPathExpressionException e) {
|
|
||||||
log.error("Error while checking for errors in orcid message", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return textContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user