forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 4
/
ItemService.java
985 lines (903 loc) · 42.3 KB
/
ItemService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
/**
* 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.content.service;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.ResourcePolicy;
import org.dspace.content.Bitstream;
import org.dspace.content.Bundle;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.EntityType;
import org.dspace.content.Item;
import org.dspace.content.MetadataField;
import org.dspace.content.MetadataValue;
import org.dspace.content.Thumbnail;
import org.dspace.content.WorkspaceItem;
import org.dspace.core.Context;
import org.dspace.discovery.SearchServiceException;
import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group;
/**
* Service interface class for the Item object.
* The implementation of this class is responsible for all business logic calls for the Item object and is autowired
* by spring
*
* @author kevinvandevelde at atmire.com
*/
public interface ItemService
extends DSpaceObjectService<Item>, DSpaceObjectLegacySupportService<Item> {
public Thumbnail getThumbnail(Context context, Item item, boolean requireOriginal) throws SQLException;
/**
* Create a new item, with a new internal ID. Authorization is done
* inside of this method.
*
* @param context DSpace context object
* @param workspaceItem in progress workspace item
* @return the newly created item
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public Item create(Context context, WorkspaceItem workspaceItem) throws SQLException, AuthorizeException;
/**
* Create a new item, with a provided ID. Authorisation is done
* inside of this method.
*
* @param context DSpace context object
* @param workspaceItem in progress workspace item
* @param uuid the pre-determined UUID to assign to the new item
* @return the newly created item
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public Item create(Context context, WorkspaceItem workspaceItem, UUID uuid) throws SQLException, AuthorizeException;
/**
* Create an empty template item for this collection. If one already exists,
* no action is taken. Caution: Make sure you call <code>update</code> on
* the collection after doing this, or the item will have been created but
* the collection record will not refer to it.
*
* @param context DSpace context object
* @param collection Collection (parent)
* @return empty template item for this collection
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public Item createTemplateItem(Context context, Collection collection) throws SQLException, AuthorizeException;
/**
* Populate the given item with all template item specified metadata.
*
* @param context DSpace context object
* @param collection Collection (parent)
* @param item item to populate with template item specified metadata
* @throws SQLException if database error
*/
public void populateWithTemplateItemMetadata (Context context, Collection collection, Item item)
throws SQLException;
/**
* Get all the items in the archive. Only items with the "in archive" flag
* set are included. The order of the list is indeterminate.
*
* @param context DSpace context object
* @return an iterator over the items in the archive.
* @throws SQLException if database error
*/
public Iterator<Item> findAll(Context context) throws SQLException;
/**
* Get all the items in the archive. Only items with the "in archive" flag
* set are included. The order of the list is indeterminate.
*
* @param context DSpace context object
* @param limit limit
* @param offset offset
* @return an iterator over the items in the archive.
* @throws SQLException if database error
*/
public Iterator<Item> findAll(Context context, Integer limit, Integer offset) throws SQLException;
/**
* Get all "final" items in the archive, both archived ("in archive" flag) or
* withdrawn items are included. The order of the list is indeterminate.
*
* @param context DSpace context object
* @return an iterator over the items in the archive.
* @throws SQLException if database error
*/
@Deprecated
public Iterator<Item> findAllUnfiltered(Context context) throws SQLException;
/**
* Find all items that are:
* - NOT in the workspace
* - NOT in the workflow
* - NOT a template item for e.g. a collection
*
* This implies that the result also contains older versions of items and withdrawn items.
* @param context the DSpace context.
* @return iterator over all regular items.
* @throws SQLException if database error.
*/
public Iterator<Item> findAllRegularItems(Context context) throws SQLException;
/**
* Find all the items in the archive by a given submitter. The order is
* indeterminate. Only items with the "in archive" flag set are included.
*
* @param context DSpace context object
* @param eperson the submitter
* @return an iterator over the items submitted by eperson
* @throws SQLException if database error
*/
public Iterator<Item> findBySubmitter(Context context, EPerson eperson)
throws SQLException;
/**
* Find all the items by a given submitter. The order is
* indeterminate. All items are included.
*
* @param context DSpace context object
* @param eperson the submitter
* @param retrieveAllItems flag to determine if all items should be returned or only archived items.
* If true, all items (regardless of status) are returned.
* If false, only archived items will be returned.
* @return an iterator over the items submitted by eperson
* @throws SQLException if database error
*/
public Iterator<Item> findBySubmitter(Context context, EPerson eperson, boolean retrieveAllItems)
throws SQLException;
/**
* Retrieve the list of items submitted by eperson, ordered by recently submitted, optionally limitable
*
* @param context DSpace context object
* @param eperson the submitter
* @param limit a positive integer to limit, -1 or null for unlimited
* @return an iterator over the items submitted by eperson
* @throws SQLException if database error
*/
public Iterator<Item> findBySubmitterDateSorted(Context context, EPerson eperson, Integer limit)
throws SQLException;
/**
* Get all the archived items in this collection. The order is indeterminate.
*
* @param context DSpace context object
* @param collection Collection (parent)
* @return an iterator over the items in the collection.
* @throws SQLException if database error
*/
public Iterator<Item> findByCollection(Context context, Collection collection) throws SQLException;
/**
* Get all the archived items in this collection. The order is indeterminate.
*
* @param context DSpace context object
* @param collection Collection (parent)
* @param limit limited number of items
* @param offset offset value
* @return an iterator over the items in the collection.
* @throws SQLException if database error
*/
public Iterator<Item> findByCollection(Context context, Collection collection, Integer limit, Integer offset)
throws SQLException;
/**
* Get all the archived items mapped to this collection (excludes owning collection). The order is indeterminate.
*
* @param context DSpace context object
* @param collection Collection (parent)
* @param limit limited number of items
* @param offset offset value
* @return an iterator over the items in the collection.
* @throws SQLException if database error
*/
public Iterator<Item> findByCollectionMapping(Context context, Collection collection, Integer limit, Integer offset)
throws SQLException;
/**
* Count all the archived items mapped to this collection (excludes owning collection). The order is indeterminate.
*
* @param context DSpace context object
* @param collection Collection (parent)
* @return an iterator over the items in the collection.
* @throws SQLException if database error
*/
public int countByCollectionMapping(Context context, Collection collection) throws SQLException;
/**
* Get all the items (including private and withdrawn) in this collection. The order is indeterminate.
*
* @param context DSpace context object
* @param collection Collection (parent)
* @return an iterator over the items in the collection.
* @param limit limited number of items
* @param offset offset value
* @throws SQLException if database error
*/
public Iterator<Item> findAllByCollection(Context context, Collection collection, Integer limit, Integer offset)
throws SQLException;
/**
* Get all Items installed or withdrawn, discoverable, and modified since a Date.
*
* @param context DSpace context object
* @param since earliest interesting last-modified date, or null for no date test.
* @return an iterator over the items in the collection.
* @throws SQLException if database error
*/
public Iterator<Item> findInArchiveOrWithdrawnDiscoverableModifiedSince(Context context, Date since)
throws SQLException;
/**
* Get all Items installed or withdrawn, NON-discoverable, and modified since a Date.
* @param context context
* @param since earliest interesting last-modified date, or null for no date test.
* @return an iterator over the items in the collection.
* @throws SQLException if database error
*/
public Iterator<Item> findInArchiveOrWithdrawnNonDiscoverableModifiedSince(Context context, Date since)
throws SQLException;
/**
* Get all the items (including private and withdrawn) in this collection. The order is indeterminate.
*
* @param context DSpace context object
* @param collection Collection (parent)
* @return an iterator over the items in the collection.
* @throws SQLException if database error
*/
public Iterator<Item> findAllByCollection(Context context, Collection collection) throws SQLException;
/**
* See whether this Item is contained by a given Collection.
*
* @param item item to check
* @param collection Collection (parent
* @return true if {@code collection} contains this Item.
* @throws SQLException if database error
*/
public boolean isIn(Item item, Collection collection) throws SQLException;
/**
* Get the communities this item is in. Returns an unordered array of the
* communities that house the collections this item is in, including parent
* communities of the owning collections.
*
* @param context DSpace context object
* @param item item to check
* @return the communities this item is in.
* @throws SQLException if database error
*/
public List<Community> getCommunities(Context context, Item item) throws SQLException;
/**
* Get the bundles matching a bundle name (name corresponds roughly to type)
*
* @param item item to check
* @param name name of bundle (ORIGINAL/TEXT/THUMBNAIL)
* @return the bundles in an unordered array
* @throws SQLException if database error
*/
public List<Bundle> getBundles(Item item, String name) throws SQLException;
/**
* Add an existing bundle to this item. This has immediate effect.
*
* @param context DSpace context object
* @param item item to add the bundle to
* @param bundle the bundle to add
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public void addBundle(Context context, Item item, Bundle bundle) throws SQLException, AuthorizeException;
/**
* Remove a bundle. This may result in the bundle being deleted, if the
* bundle is orphaned.
*
* @param context DSpace context object
* @param item Item
* @param bundle the bundle to remove
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
* @throws IOException if IO error
*/
public void removeBundle(Context context, Item item, Bundle bundle) throws SQLException, AuthorizeException,
IOException;
/**
* Remove all bundles linked to this item. This may result in the bundle being deleted, if the
* bundle is orphaned.
*
* @param context DSpace context object
* @param item the item from which to remove all bundles
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
* @throws IOException if IO error
*/
public void removeAllBundles(Context context, Item item) throws AuthorizeException, SQLException, IOException;
/**
* Create a single bitstream in a new bundle. Provided as a convenience
* method for the most common use.
*
* @param context DSpace context object
* @param item item to create bitstream on
* @param is the stream to create the new bitstream from
* @param name is the name of the bundle (ORIGINAL, TEXT, THUMBNAIL)
* @return Bitstream that is created
* @throws AuthorizeException if authorization error
* @throws IOException if IO error
* @throws SQLException if database error
*/
public Bitstream createSingleBitstream(Context context, InputStream is, Item item, String name)
throws AuthorizeException, IOException, SQLException;
/**
* Convenience method, calls createSingleBitstream() with name "ORIGINAL"
*
* @param context DSpace context object
* @param item item to create bitstream on
* @param is InputStream
* @return created bitstream
* @throws AuthorizeException if authorization error
* @throws IOException if IO error
* @throws SQLException if database error
*/
public Bitstream createSingleBitstream(Context context, InputStream is, Item item)
throws AuthorizeException, IOException, SQLException;
/**
* Get all non-internal bitstreams in the item. This is mainly used for
* auditing for provenance messages and adding format.* DC values. The order
* is indeterminate.
*
* @param context DSpace context object
* @param item item to check
* @return non-internal bitstreams.
* @throws SQLException if database error
*/
public List<Bitstream> getNonInternalBitstreams(Context context, Item item) throws SQLException;
/**
* Remove just the DSpace license from an item This is useful to update the
* current DSpace license, in case the user must accept the DSpace license
* again (either the item was rejected, or resumed after saving)
* <p>
* This method is used by the org.dspace.submit.step.LicenseStep class
*
* @param context DSpace context object
* @param item item to remove DSpace license from
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
* @throws IOException if IO error
*/
public void removeDSpaceLicense(Context context, Item item) throws SQLException, AuthorizeException,
IOException;
/**
* Remove all licenses from an item - it was rejected
*
* @param context DSpace context object
* @param item item to remove all licenses from
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
* @throws IOException if IO error
*/
public void removeLicenses(Context context, Item item) throws SQLException, AuthorizeException, IOException;
/**
* Withdraw the item from the archive. It is kept in place, and the content
* and metadata are not deleted, but it is not publicly accessible.
*
* @param context DSpace context object
* @param item item to withdraw
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public void withdraw(Context context, Item item) throws SQLException, AuthorizeException;
/**
* Reinstate a withdrawn item
*
* @param context DSpace context object
* @param item withdrawn item to reinstate
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public void reinstate(Context context, Item item) throws SQLException, AuthorizeException;
/**
* Return true if this Collection 'owns' this item
*
* @param item item to check
* @param collection Collection
* @return true if this Collection owns this item
*/
public boolean isOwningCollection(Item item, Collection collection);
/**
* remove all of the policies for item and replace them with a new list of
* policies
*
* @param context DSpace context object
* @param item item to replace policies on
* @param newpolicies -
* this will be all of the new policies for the item and its
* contents
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public void replaceAllItemPolicies(Context context, Item item, List<ResourcePolicy> newpolicies)
throws SQLException,
AuthorizeException;
/**
* remove all of the policies for item's bitstreams and bundles and replace
* them with a new list of policies
*
* @param context DSpace context object
* @param item item to replace policies on
* @param newpolicies -
* this will be all of the new policies for the bundle and
* bitstream contents
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public void replaceAllBitstreamPolicies(Context context, Item item, List<ResourcePolicy> newpolicies)
throws SQLException, AuthorizeException;
/**
* remove all of the policies for item's bitstreams and bundles that belong
* to a given Group
*
* @param context DSpace context object
* @param item item to remove group policies from
* @param group Group referenced by policies that needs to be removed
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public void removeGroupPolicies(Context context, Item item, Group group) throws SQLException, AuthorizeException;
/**
* Remove all policies on an item and its contents, and replace them with
* the DEFAULT_ITEM_READ and DEFAULT_BITSTREAM_READ policies belonging to
* the collection.
*
* @param context DSpace context object
* @param item item to reset policies on
* @param collection Collection
* @throws SQLException if database error
* if an SQL error or if no default policies found. It's a bit
* draconian, but default policies must be enforced.
* @throws AuthorizeException if authorization error
*/
public void inheritCollectionDefaultPolicies(Context context, Item item, Collection collection)
throws java.sql.SQLException, AuthorizeException;
/**
* Remove all submission and workflow policies on an item and its contents, and add
* default collection policies which are not yet already in place.
* If overrideItemReadPolicies is true, then all read policies on the item are replaced (but only if the
* collection has a default read policy).
*
* @param context DSpace context object
* @param item item to reset policies on
* @param collection Collection
* @param overrideItemReadPolicies if true, all read policies on the item are replaced (but only if the
* collection has a default read policy)
* @throws SQLException if database error
* if an SQL error or if no default policies found. It's a bit
* draconian, but default policies must be enforced.
* @throws AuthorizeException if authorization error
*/
public void inheritCollectionDefaultPolicies(Context context, Item item, Collection collection,
boolean overrideItemReadPolicies)
throws java.sql.SQLException, AuthorizeException;
/**
* Adjust the Bundle and Bitstream policies to reflect what have been defined
* during the submission/workflow. The temporary SUBMISSION and WORKFLOW
* policies are removed and the policies defined at the item and collection
* level are copied and inherited as appropriate. Custom selected Item policies
* are copied to the bundle/bitstream only if no explicit custom policies were
* already applied to the bundle/bitstream. Collection's policies are inherited
* if there are no other policies defined or if the append mode is defined by
* the configuration via the core.authorization.installitem.inheritance-read.append-mode property
*
* @param context DSpace context object
* @param item Item to adjust policies on
* @param collection Collection
* @throws SQLException If database error
* @throws AuthorizeException If authorization error
*/
public void adjustBundleBitstreamPolicies(Context context, Item item, Collection collection)
throws SQLException, AuthorizeException;
/**
* Adjust the Bundle and Bitstream policies to reflect what have been defined
* during the submission/workflow. The temporary SUBMISSION and WORKFLOW
* policies are removed and the policies defined at the item and collection
* level are copied and inherited as appropriate. Custom selected Item policies
* are copied to the bundle/bitstream only if no explicit custom policies were
* already applied to the bundle/bitstream. Collection's policies are inherited
* if there are no other policies defined or if the append mode is defined by
* the configuration via the core.authorization.installitem.inheritance-read.append-mode property
*
* @param context DSpace context object
* @param item Item to adjust policies on
* @param collection Collection
* @param replaceReadRPWithCollectionRP if true, all read policies on the item are replaced (but only if the
* collection has a default read policy)
* @throws SQLException If database error
* @throws AuthorizeException If authorization error
*/
public void adjustBundleBitstreamPolicies(Context context, Item item, Collection collection,
boolean replaceReadRPWithCollectionRP)
throws SQLException, AuthorizeException;
/**
* Adjust the Bitstream policies to reflect what have been defined
* during the submission/workflow. The temporary SUBMISSION and WORKFLOW
* policies are removed and the policies defined at the item and collection
* level are copied and inherited as appropriate. Custom selected Item policies
* are copied to the bitstream only if no explicit custom policies were
* already applied to the bitstream. Collection's policies are inherited
* if there are no other policies defined or if the append mode is defined by
* the configuration via the core.authorization.installitem.inheritance-read.append-mode property
*
* @param context DSpace context object
* @param item Item to adjust policies on
* @param collection Collection
* @param bitstream Bitstream to adjust policies on
* @throws SQLException If database error
* @throws AuthorizeException If authorization error
*/
public void adjustBitstreamPolicies(Context context, Item item, Collection collection, Bitstream bitstream)
throws SQLException, AuthorizeException;
/**
* Adjust the Bitstream policies to reflect what have been defined
* during the submission/workflow. The temporary SUBMISSION and WORKFLOW
* policies are removed and the policies defined at the item and collection
* level are copied and inherited as appropriate. Custom selected Item policies
* are copied to the bitstream only if no explicit custom policies were
* already applied to the bitstream. Collection's policies are inherited
* if there are no other policies defined or if the append mode is defined by
* the configuration via the core.authorization.installitem.inheritance-read.append-mode property
*
* @param context DSpace context object
* @param item Item to adjust policies on
* @param collection Collection
* @param bitstream Bitstream to adjust policies on
* @param replaceReadRPWithCollectionRP If true, all read policies on the bitstream are replaced (but only if the
* collection has a default read policy)
* @throws SQLException If database error
* @throws AuthorizeException If authorization error
*/
public void adjustBitstreamPolicies(Context context, Item item, Collection collection, Bitstream bitstream,
boolean replaceReadRPWithCollectionRP)
throws SQLException, AuthorizeException;
/**
* Adjust the Item's policies to reflect what have been defined during the
* submission/workflow. The temporary SUBMISSION and WORKFLOW policies are
* removed and the default policies defined at the collection level are
* inherited as appropriate. Collection's policies are inherited if there are no
* other policies defined or if the append mode is defined by the configuration
* via the core.authorization.installitem.inheritance-read.append-mode property
*
* @param context DSpace context object
* @param item Item to adjust policies on
* @param collection Collection
* @throws SQLException If database error
* @throws AuthorizeException If authorization error
*/
public void adjustItemPolicies(Context context, Item item, Collection collection)
throws SQLException, AuthorizeException;
/**
* Adjust the Item's policies to reflect what have been defined during the
* submission/workflow. The temporary SUBMISSION and WORKFLOW policies are
* removed and the default policies defined at the collection level are
* inherited as appropriate. Collection's policies are inherited if there are no
* other policies defined or if the append mode is defined by the configuration
* via the core.authorization.installitem.inheritance-read.append-mode property
*
* @param context DSpace context object
* @param item Item to adjust policies on
* @param collection Collection
* @param replaceReadRPWithCollectionRP If true, all read policies on the item are replaced (but only if the
* collection has a default read policy)
* @throws SQLException If database error
* @throws AuthorizeException If authorization error
*/
public void adjustItemPolicies(Context context, Item item, Collection collection,
boolean replaceReadRPWithCollectionRP)
throws SQLException, AuthorizeException;
/**
* Moves the item from one collection to another one
*
* @param context DSpace context object
* @param item item to move
* @param from Collection to move from
* @param to Collection to move to
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
* @throws IOException if IO error
*/
public void move(Context context, Item item, Collection from, Collection to)
throws SQLException, AuthorizeException, IOException;
/**
* Moves the item from one collection to another one
*
* @param context DSpace context object
* @param item item to move
* @param from Collection to move from
* @param to Collection to move to
* @param inheritDefaultPolicies whether to inherit policies from new collection
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
* @throws IOException if IO error
*/
public void move(Context context, Item item, Collection from, Collection to, boolean inheritDefaultPolicies)
throws SQLException, AuthorizeException, IOException;
/**
* Check the bundle ORIGINAL to see if there are any uploaded files
*
* @param item item to check
* @return true if there is a bundle named ORIGINAL with one or more
* bitstreams inside
* @throws SQLException if database error
*/
public boolean hasUploadedFiles(Item item) throws SQLException;
/**
* Get the collections this item is not in.
*
* @param context DSpace context object
* @param item item to check
* @return the collections this item is not in, if any.
* @throws SQLException if database error
*/
public List<Collection> getCollectionsNotLinked(Context context, Item item) throws SQLException;
/**
* return TRUE if context's user can edit item, false otherwise
*
* @param context DSpace context object
* @param item item to check
* @return boolean true = current user can edit item
* @throws SQLException if database error
*/
public boolean canEdit(Context context, Item item) throws java.sql.SQLException;
/**
* return TRUE if context's user can create new version of the item, false
* otherwise.
*
* @param context DSpace context object
* @param item item to check
* @return boolean true = current user can create new version of the item
* @throws SQLException if database error
*/
public boolean canCreateNewVersion(Context context, Item item) throws SQLException;
/**
* Returns an iterator of in archive items possessing the passed metadata field, or only
* those matching the passed value, if value is not Item.ANY
*
* @param context DSpace context object
* @param schema metadata field schema
* @param element metadata field element
* @param qualifier metadata field qualifier
* @param value field value or Item.ANY to match any value
* @return an iterator over the items matching that authority value
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public Iterator<Item> findArchivedByMetadataField(Context context, String schema,
String element, String qualifier,
String value) throws SQLException, AuthorizeException;
/**
* Returns an iterator of in archive items possessing the passed metadata field, or only
* those matching the passed value, if value is not Item.ANY
*
* @param context DSpace context object
* @param metadataField metadata
* @param value field value or Item.ANY to match any value
* @return an iterator over the items matching that authority value
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public Iterator<Item> findArchivedByMetadataField(Context context, String metadataField, String value)
throws SQLException, AuthorizeException;
/**
* Returns an iterator of Items possessing the passed metadata field, or only
* those matching the passed value, if value is not Item.ANY
*
* @param context DSpace context object
* @param schema metadata field schema
* @param element metadata field element
* @param qualifier metadata field qualifier
* @param value field value or Item.ANY to match any value
* @return an iterator over the items matching that authority value
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
* @throws IOException if IO error
*/
public Iterator<Item> findByMetadataField(Context context,
String schema, String element, String qualifier, String value)
throws SQLException, AuthorizeException, IOException;
public Iterator<Item> findByMetadataQuery(Context context, List<List<MetadataField>> listFieldList,
List<String> query_op, List<String> query_val, List<UUID> collectionUuids,
String regexClause, int offset, int limit)
throws SQLException, AuthorizeException, IOException;
/**
* Find all the items in the archive with a given authority key value
* in the indicated metadata field.
*
* @param context DSpace context object
* @param schema metadata field schema
* @param element metadata field element
* @param qualifier metadata field qualifier
* @param value the value of authority key to look for
* @return an iterator over the items matching that authority value
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
* @throws IOException if IO error
*/
public Iterator<Item> findByAuthorityValue(Context context,
String schema, String element, String qualifier, String value)
throws SQLException, AuthorizeException;
public Iterator<Item> findByMetadataFieldAuthority(Context context, String mdString, String authority)
throws SQLException, AuthorizeException;
/**
* Service method for knowing if this Item should be visible in the item list.
* Items only show up in the "item list" if the user has READ permission
* and if the Item isn't flagged as unlisted.
*
* @param context DSpace context object
* @param item item
* @return true or false
*/
public boolean isItemListedForUser(Context context, Item item);
/**
* counts items in the given collection
*
* @param context DSpace context object
* @param collection Collection
* @return total items
* @throws SQLException if database error
*/
public int countItems(Context context, Collection collection) throws SQLException;
/**
* counts all items in the given collection including withdrawn items
*
* @param context DSpace context object
* @param collection Collection
* @return total items
* @throws SQLException if database error
*/
public int countAllItems(Context context, Collection collection) throws SQLException;
/**
* Find all Items modified since a Date.
*
* @param context DSpace context object
* @param last Earliest interesting last-modified date.
* @return iterator over items
* @throws SQLException if database error
*/
public Iterator<Item> findByLastModifiedSince(Context context, Date last)
throws SQLException;
/**
* counts items in the given community
*
* @param context DSpace context object
* @param community Community
* @return total items
* @throws SQLException if database error
*/
public int countItems(Context context, Community community) throws SQLException;
/**
* counts all items in the given community including withdrawn
*
* @param context DSpace context object
* @param community Community
* @return total items
* @throws SQLException if database error
*/
public int countAllItems(Context context, Community community) throws SQLException;
/**
* counts all items
*
* @param context DSpace context object
* @return total items
* @throws SQLException if database error
*/
int countTotal(Context context) throws SQLException;
/**
* counts all items not in archive
*
* @param context DSpace context object
* @return total items NOT in archive
* @throws SQLException if database error
*/
int countNotArchivedItems(Context context) throws SQLException;
/**
* counts all items in archive
*
* @param context DSpace context object
* @return total items in archive
* @throws SQLException if database error
*/
int countArchivedItems(Context context) throws SQLException;
/**
* counts all withdrawn items
*
* @param context DSpace context object
* @return total items withdrawn
* @throws SQLException if database error
*/
int countWithdrawnItems(Context context) throws SQLException;
/**
* finds all items for which the current user has editing rights
* @param context DSpace context object
* @param offset page offset
* @param limit page size limit
* @return list of items for which the current user has editing rights
* @throws SQLException
* @throws SearchServiceException
*/
public List<Item> findItemsWithEdit(Context context, int offset, int limit)
throws SQLException, SearchServiceException;
/**
* counts all items for which the current user has editing rights
* @param context DSpace context object
* @return list of items for which the current user has editing rights
* @throws SQLException
* @throws SearchServiceException
*/
public int countItemsWithEdit(Context context) throws SQLException, SearchServiceException;
/**
* Check if the supplied item is an inprogress submission
*
* @param context DSpace context object
* @param item item to check
* @return <code>true</code> if the item is linked to a workspaceitem or workflowitem
* @throws SQLException if database error
*/
boolean isInProgressSubmission(Context context, Item item) throws SQLException;
/**
* Get metadata for the DSpace Object in a chosen schema.
* See <code>MetadataSchema</code> for more information about schemas.
* Passing in a <code>null</code> value for <code>qualifier</code>
* or <code>lang</code> only matches metadata fields where that
* qualifier or languages is actually <code>null</code>.
* Passing in <code>DSpaceObject.ANY</code>
* retrieves all metadata fields with any value for the qualifier or
* language, including <code>null</code>
* <P>
* Examples:
* <P>
* Return values of the unqualified "title" field, in any language.
* Qualified title fields (e.g. "title.uniform") are NOT returned:
* <P>
* <code>dspaceobject.getMetadataByMetadataString("dc", "title", null, DSpaceObject.ANY );</code>
* <P>
* Return all US English values of the "title" element, with any qualifier
* (including unqualified):
* <P>
* <code>dspaceobject.getMetadataByMetadataString("dc, "title", DSpaceObject.ANY, "en_US" );</code>
* <P>
* The ordering of values of a particular element/qualifier/language
* combination is significant. When retrieving with wildcards, values of a
* particular element/qualifier/language combinations will be adjacent, but
* the overall ordering of the combinations is indeterminate.
*
* If enableVirtualMetadata is set to false, the virtual metadata will not be included
*
* @param item Item
* @param schema the schema for the metadata field. <em>Must</em> match
* the <code>name</code> of an existing metadata schema.
* @param element the element name. <code>DSpaceObject.ANY</code> matches any
* element. <code>null</code> doesn't really make sense as all
* metadata must have an element.
* @param qualifier the qualifier. <code>null</code> means unqualified, and
* <code>DSpaceObject.ANY</code> means any qualifier (including
* unqualified.)
* @param lang the ISO639 language code, optionally followed by an underscore
* and the ISO3166 country code. <code>null</code> means only
* values with no language are returned, and
* <code>DSpaceObject.ANY</code> means values with any country code or
* no country code are returned.
* @param enableVirtualMetadata
* Enables virtual metadata calculation and inclusion from the
* relationships.
* @return metadata fields that match the parameters
*/
public List<MetadataValue> getMetadata(Item item, String schema, String element, String qualifier,
String lang, boolean enableVirtualMetadata);
/**
* Retrieve the label of the entity type of the given item.
* @param item the item.
* @return the label of the entity type, taken from the item metadata, or null if not found.
*/
public String getEntityTypeLabel(Item item);
/**
* Retrieve the entity type of the given item.
* @param context the DSpace context.
* @param item the item.
* @return the entity type of the given item, or null if not found.
*/
public EntityType getEntityType(Context context, Item item) throws SQLException;
}