Skip to content

Commit 0f9f282

Browse files
authored
Merge pull request #289 from edoweb/EDOZWO-931
Edozwo 931
2 parents 00f37b7 + 4dc9a77 commit 0f9f282

File tree

12 files changed

+521
-31
lines changed

12 files changed

+521
-31
lines changed

app/actions/Create.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.List;
2626
import com.fasterxml.jackson.databind.JsonNode;
2727
import helper.HttpArchiveException;
28+
import helper.WebsiteVersionPublisher;
2829
import helper.oai.OaiDispatcher;
2930
import helper.WpullCrawl;
3031
import models.Gatherconf;
@@ -68,6 +69,7 @@ public Node updateResource(Node node, RegalObject object) {
6869
}
6970

7071
private Node updateResource(Node node) {
72+
play.Logger.debug("Updating Node with Pid " + node.getPid());
7173
Globals.fedora.updateNode(node);
7274
updateIndex(node.getPid());
7375
return node;
@@ -79,8 +81,11 @@ private Node updateResource(Node node) {
7981
* @return the updated node
8082
*/
8183
public Node patchResource(Node node, RegalObject object) {
84+
play.Logger.debug("Patching Node with Pid " + node.getPid());
8285
new Index().remove(node);
8386
setNodeMembers(node, object);
87+
node.setLastModifyMessage(
88+
WebsiteVersionPublisher.handleWebpagePublishing(node, object));
8489
return updateResource(node);
8590
}
8691

app/actions/Modify.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ class MetadataNotFoundException extends RuntimeException {
791791
}
792792

793793
@SuppressWarnings({ "serial" })
794-
private class UpdateNodeException extends RuntimeException {
794+
public class UpdateNodeException extends RuntimeException {
795795
UpdateNodeException(Throwable cause) {
796796
super(cause);
797797
}

app/archive/fedora/FedoraFacade.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ public void updateNode(Node node) {
390390
} else {
391391
utils.updateUnManagedStream(node);
392392
}
393-
393+
play.Logger.debug("Updated stream");
394394
}
395395
if (node.getMetadataFile() != null) {
396396
utils.updateMetadataStream(node);

app/controllers/Resource.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import authenticate.BasicAuth;
5959
import helper.HttpArchiveException;
6060
import helper.WebgatherUtils;
61+
import helper.WebsiteVersionPublisher;
6162
import helper.oai.OaiDispatcher;
6263
import models.DublinCoreData;
6364
import 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));

app/helper/JsonMapper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public JsonMapper(final Node n) {
154154
node.getPid() + " metadata2 stream is NULL!");
155155
} catch (Exception e) {
156156
play.Logger.warn("", e.getMessage());
157-
play.Logger.debug("", e);
157+
// play.Logger.debug("", e);
158158
}
159159

160160
}
@@ -296,7 +296,7 @@ private Map<String, Object> getDescriptiveMetadata1() {
296296
return rdf;
297297
} catch (Exception e) {
298298
play.Logger
299-
.trace(node.getPid() + " can not create JSON! " + e.getMessage());
299+
.warn(node.getPid() + " can not create JSON! " + e.getMessage());
300300
play.Logger.trace("", e);
301301
}
302302
return null;
@@ -312,7 +312,7 @@ private Map<String, Object> getDescriptiveMetadata2() {
312312
} catch (Exception e) {
313313
play.Logger.warn(node.getPid()
314314
+ " has no descriptive Metadata2! Try to return metadata instead.");
315-
play.Logger.debug("", e);
315+
// play.Logger.debug("", e);
316316
}
317317
return getDescriptiveMetadata1();
318318
}
@@ -533,6 +533,7 @@ private void postProcessContribution(Map<String, Object> rdf) {
533533
rdf.put("creator", creator);
534534
} catch (Exception e) {
535535
play.Logger.debug("Problem processing key contribution.agent", e);
536+
// play.Logger.debug("", e);
536537
}
537538
}
538539

app/helper/WebgatherUtils.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,18 @@
1616
*/
1717
package helper;
1818

19-
import static org.junit.Assert.assertEquals;
20-
21-
import java.io.IOException;
22-
import java.net.HttpURLConnection;
2319
import java.net.IDN;
24-
import java.net.MalformedURLException;
2520
import java.net.URI;
2621
import java.net.URISyntaxException;
2722
import java.net.URL;
2823
import java.text.DateFormat;
2924
import java.text.SimpleDateFormat;
30-
import java.util.Date;
31-
import java.util.List;
32-
import java.util.Map.Entry;
33-
34-
import com.google.common.base.CharMatcher;
35-
36-
import actions.Create;
37-
import actions.Modify;
38-
import actions.RegalAction;
3925
import helper.mail.Mail;
4026
import models.Gatherconf;
4127
import models.Globals;
4228
import models.Message;
4329
import models.Node;
4430
import play.Logger;
45-
import play.Play;
4631

4732
/**
4833
* Eine Klasse mit nützlichen Methoden im Umfeld des Webgatherings

0 commit comments

Comments
 (0)