5858import authenticate .BasicAuth ;
5959import helper .HttpArchiveException ;
6060import helper .WebgatherUtils ;
61+ import helper .WebsiteVersionPublisher ;
6162import helper .oai .OaiDispatcher ;
6263import models .DublinCoreData ;
6364import models .Gatherconf ;
@@ -315,11 +316,20 @@ public static Promise<Result> listDc(@PathParam("pid") String pid) {
315316 @ ApiImplicitParam (value = "New Object" , required = true , dataType = "RegalObject" , paramType = "body" ) })
316317 public static Promise <Result > patchResource (@ PathParam ("pid" ) String pid ) {
317318 return new ModifyAction ().call (pid , userId -> {
318- Node node = readNodeOrNull (pid );
319- RegalObject object = getRegalObject (request ().body ().asJson ());
320- Node newNode = create .patchResource (node , object );
321- String result = newNode .getPid () + " created/updated!" ;
322- return JsonMessage (new Message (result ));
319+ try {
320+ play .Logger .debug ("Patching Pid: " + pid );
321+ String result = "" ;
322+ Node node = readNodeOrNull (pid );
323+ RegalObject object = getRegalObject (request ().body ().asJson ());
324+ Node newNode = create .patchResource (node , object );
325+ result = newNode .getLastModifyMessage ();
326+ result = result .concat (" " + newNode .getPid () + " created/updated!" );
327+ return JsonMessage (new Message (result ));
328+ } catch (Exception e ) {
329+ play .Logger .error ("" , e );
330+ return JsonMessage (new Message (e , 500 ));
331+ // return JsonMessage(new Message( json(e.toString()) ));
332+ }
323333 });
324334 }
325335
@@ -345,6 +355,8 @@ public static Promise<Result> patchResources(@PathParam("pid") String pid) {
345355 @ ApiImplicitParam (value = "New Object" , required = true , dataType = "RegalObject" , paramType = "body" ) })
346356 public static Promise <Result > updateResource (@ PathParam ("pid" ) String pid ) {
347357 return new ModifyAction ().call (pid , userId -> {
358+ play .Logger .debug ("Updating Pid: " + pid );
359+ String result = "" ;
348360 Node node = readNodeOrNull (pid );
349361 RegalObject object = getRegalObject (request ().body ().asJson ());
350362 Node newNode = null ;
@@ -355,9 +367,11 @@ public static Promise<Result> updateResource(@PathParam("pid") String pid) {
355367 } else {
356368 newNode = create .updateResource (node , object );
357369 }
358- String result = newNode .getPid () + " created/updated!" ;
370+ result = result . concat ( newNode .getPid () + " created/updated!" ) ;
359371 return JsonMessage (new Message (result ));
372+
360373 });
374+
361375 }
362376
363377 @ ApiOperation (produces = "application/json" , nickname = "createNewResource" , value = "createNewResource" , notes = "Creates a Resource on a new position" , response = Message .class , httpMethod = "PUT" )
@@ -367,6 +381,9 @@ public static Promise<Result> createResource(
367381 @ PathParam ("namespace" ) String namespace ) {
368382 return new CreateAction ().call ((userId ) -> {
369383 RegalObject object = getRegalObject (request ().body ().asJson ());
384+ if (object .getContentType ().equals ("webpage" )) {
385+ object .setAccessScheme ("restricted" );
386+ }
370387 Node newNode = create .createResource (namespace , object );
371388 String result = newNode .getPid () + " created/updated!" ;
372389 response ().setHeader ("Location" , read .getHttpUriOfResource (newNode ));
0 commit comments