21
21
import static org .fcrepo .client .ExternalContentHandling .PROXY ;
22
22
import static org .fcrepo .client .FedoraTypes .LDP_NON_RDF_SOURCE ;
23
23
import static org .fcrepo .client .LinkHeaderConstants .DESCRIBEDBY_REL ;
24
+ import static org .slf4j .LoggerFactory .getLogger ;
24
25
25
26
import java .io .ByteArrayInputStream ;
26
27
import java .io .IOException ;
41
42
import org .fcrepo .client .FcrepoClient ;
42
43
import org .fcrepo .client .FcrepoOperationFailedException ;
43
44
import org .fcrepo .client .FcrepoResponse ;
45
+ import org .slf4j .Logger ;
44
46
45
47
import edu .unc .lib .dl .fedora .ChecksumMismatchException ;
46
48
import edu .unc .lib .dl .fedora .FedoraException ;
61
63
*
62
64
*/
63
65
public class RepositoryObjectFactory {
66
+ private static final Logger log = getLogger (RepositoryObjectFactory .class );
64
67
65
68
private LdpContainerFactory ldpFactory ;
66
69
@@ -88,17 +91,24 @@ public DepositRecord createDepositRecord(Model model) throws FedoraException {
88
91
public DepositRecord createDepositRecord (PID pid , Model model ) throws FedoraException {
89
92
URI path = pid .getRepositoryUri ();
90
93
94
+ log .debug ("Creating deposit record {}" , pid .getId ());
91
95
// Add the deposit record type to the object being created
92
96
model = populateModelTypes (path , model , Arrays .asList (Cdr .DepositRecord ));
93
97
94
- try (FcrepoResponse response = getClient ().put (path )
95
- .body (RDFModelUtil .streamModel (model ), TURTLE_MIMETYPE )
96
- .perform ()) {
97
- URI createdUri = response .getLocation ();
98
+ log .debug ("Streaming model and requesting creation of {}" , pid .getId ());
99
+ try {
100
+ URI createdUri ;
101
+ try (FcrepoResponse response = getClient ().put (path )
102
+ .body (RDFModelUtil .streamModel (model ), TURTLE_MIMETYPE )
103
+ .perform ()) {
104
+ createdUri = response .getLocation ();
105
+ }
98
106
// Add the manifests container
107
+ log .debug ("Created with location {}, adding manifest container" , createdUri );
99
108
ldpFactory .createDirectContainer (createdUri , Cdr .hasManifest ,
100
109
RepositoryPathConstants .DEPOSIT_MANIFEST_CONTAINER );
101
110
111
+ log .debug ("Adding metadata container to {}" , createdUri );
102
112
// Add container for metadata objects
103
113
addMetadataContainer (createdUri );
104
114
@@ -108,6 +118,7 @@ public DepositRecord createDepositRecord(PID pid, Model model) throws FedoraExce
108
118
throw ClientFaultResolver .resolve (e );
109
119
}
110
120
121
+ log .debug ("Retrieving created deposit record object {}" , pid .getId ());
111
122
DepositRecord depositRecord = new DepositRecord (pid , repoObjDriver , this );
112
123
return depositRecord ;
113
124
}
@@ -284,10 +295,13 @@ public FileObject createFileObject(PID pid, Model model) throws FedoraException
284
295
// Add types to the object being created
285
296
model = populateModelTypes (path , model , Arrays .asList (Cdr .FileObject , PcdmModels .Object ));
286
297
287
- try (FcrepoResponse response = getClient ().put (path )
288
- .body (RDFModelUtil .streamModel (model ), TURTLE_MIMETYPE )
289
- .perform ()) {
290
- URI createdUri = response .getLocation ();
298
+ try {
299
+ URI createdUri ;
300
+ try (FcrepoResponse response = getClient ().put (path )
301
+ .body (RDFModelUtil .streamModel (model ), TURTLE_MIMETYPE )
302
+ .perform ()) {
303
+ createdUri = response .getLocation ();
304
+ }
291
305
292
306
// Add container for metadata objects
293
307
addMetadataContainer (createdUri );
@@ -673,11 +687,13 @@ private void persistTripleToFedora(URI subject, String sparqlUpdate) {
673
687
}
674
688
675
689
private URI createContentContainerObject (URI path , Model model ) throws FedoraException {
676
- try (FcrepoResponse response = getClient ().put (path )
677
- .body (RDFModelUtil .streamModel (model ), TURTLE_MIMETYPE )
678
- .perform ()) {
679
-
680
- URI createdUri = response .getLocation ();
690
+ try {
691
+ URI createdUri ;
692
+ try (FcrepoResponse response = getClient ().put (path )
693
+ .body (RDFModelUtil .streamModel (model ), TURTLE_MIMETYPE )
694
+ .perform ()) {
695
+ createdUri = response .getLocation ();
696
+ }
681
697
682
698
// Add container for metadata objects
683
699
addMetadataContainer (createdUri );
0 commit comments