// Handle the deposit
if (!deposit.isNoOp()) {
counter++;
}
DepositResponse dr = new DepositResponse(Deposit.CREATED);
SWORDEntry se = new SWORDEntry();
Title t = new Title();
t.setContent("DummyServer Deposit: #" + counter);
se.setTitle(t);
se.addCategory("Category");
if (deposit.getSlug() != null) {
se.setId(deposit.getSlug() + " - ID: " + counter);
} else {
se.setId("ID: " + counter);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
TimeZone utc = TimeZone.getTimeZone("UTC");
sdf.setTimeZone (utc);
String milliFormat = sdf.format(new Date());
se.setUpdated(milliFormat);
Summary s = new Summary();
s.setContent(filenames.toString());
se.setSummary(s);
Author a = new Author();
if (username != null) {
a.setName(username);
} else {
a.setName("unknown");
}
se.addAuthors(a);
Link em = new Link();
em.setRel("edit-media");
em.setHref("http://www.myrepository.ac.uk/sdl/workflow/my deposit");
se.addLink(em);
Link e = new Link();
e.setRel("edit");
e.setHref("http://www.myrepository.ac.uk/sdl/workflow/my deposit.atom");
se.addLink(e);
if (deposit.getOnBehalfOf() != null) {
Contributor c = new Contributor();
c.setName(deposit.getOnBehalfOf());
c.setEmail(deposit.getOnBehalfOf() + "@myrepository.ac.uk");
se.addContributor(c);
}
Generator generator = new Generator();
generator.setContent("Stuart's Dummy SWORD Server");
generator.setUri("http://dummy-sword-server.example.com/");
generator.setVersion("1.3");
se.setGenerator(generator);
Content content = new Content();
try {
content.setType("application/zip");
} catch (InvalidMediaTypeException ex) {
ex.printStackTrace();
}
content.setSource("http://www.myrepository.ac.uk/sdl/uploads/upload-" + counter + ".zip");
se.setContent(content);
se.setTreatment("Short back and sides");
if (deposit.isVerbose()) {
se.setVerboseDescription("I've done a lot of hard work to get this far!");
}
se.setNoOp(deposit.isNoOp());
dr.setEntry(se);
dr.setLocation("http://www.myrepository.ac.uk/atom/" + counter);
return dr;
}