X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FWebLibraryServer.java;h=55e8ed3d146658f5529471eb645d3caa26c1fe77;hp=dfbceeeb7a19ce09cdbd398fa45a36789a758811;hb=089e354e5efc0de39caa4df2f3987d573b71dcbc;hpb=e4b1b70c5388573bda8ae28f9391ee3831e53feb diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServer.java b/src/be/nikiroo/fanfix/library/WebLibraryServer.java index dfbceee..55e8ed3 100644 --- a/src/be/nikiroo/fanfix/library/WebLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/WebLibraryServer.java @@ -288,6 +288,43 @@ public class WebLibraryServer extends WebLibraryServerHtml { return newInputStreamResponse(mimeType, in); } + // /story/luid/source + // /story/luid/title + // /story/luid/author + @Override + protected Response setStoryPart(String uri, String value, + WLoginResult login) throws IOException { + String[] uriParts = uri.split("/"); + int off = 2; // "" and "story" + + if (uriParts.length < off + 2) { + return NanoHTTPD.newFixedLengthResponse(Status.BAD_REQUEST, + NanoHTTPD.MIME_PLAINTEXT, "Invalid story part request"); + } + + String luid = uriParts[off + 0]; + String type = uriParts[off + 1]; + + if (!Arrays.asList("source", "title", "author").contains(type)) { + return NanoHTTPD.newFixedLengthResponse(Status.BAD_REQUEST, + NanoHTTPD.MIME_PLAINTEXT, + "Invalid SET story part: " + type); + } + + if (meta(luid, login) != null) { + BasicLibrary lib = Instance.getInstance().getLibrary(); + if ("source".equals(type)) { + lib.changeSource(luid, value, null); + } else if ("title".equals(type)) { + lib.changeTitle(luid, value, null); + } else if ("author".equals(type)) { + lib.changeAuthor(luid, value, null); + } + } + + return newInputStreamResponse(NanoHTTPD.MIME_PLAINTEXT, null); + } + @Override protected Response getCover(String uri, WLoginResult login) throws IOException {