weblib: metadata url change
[nikiroo-utils.git] / src / be / nikiroo / fanfix / library / WebLibraryUrls.java
1 package be.nikiroo.fanfix.library;
2
3 public class WebLibraryUrls {
4 static public final String INDEX_URL = "/";
5
6 static public final String VERSION_URL = "/version";
7
8 static public final String LOGOUT_URL = "/logout";
9
10 static private final String VIEWER_URL_BASE = "/view/story/";
11 static private final String VIEWER_URL = VIEWER_URL_BASE
12 + "{luid}/{chap}/{para}";
13
14 static private final String STORY_URL_BASE = "/story/";
15 static private final String STORY_URL = STORY_URL_BASE
16 + "{luid}/{chap}/{para}";
17 static private final String STORY_URL_COVER = STORY_URL_BASE
18 + "{luid}/cover";
19 static private final String STORY_URL_JSON = STORY_URL_BASE + "{luid}/json";
20
21 static private final String LIST_URL_BASE = "/list/";
22
23 static public final String LIST_URL_METADATA = LIST_URL_BASE + "metadata";
24
25 static public String getViewUrl(String luid, Integer chap, Integer para) {
26 return VIEWER_URL //
27 .replace("{luid}", luid) //
28 .replace("/{chap}", chap == null ? "" : "/" + chap) //
29 .replace("/{para}",
30 (chap == null || para == null) ? "" : "/" + para);
31 }
32
33 static public String getStoryUrl(String luid, int chap, Integer para) {
34 return STORY_URL //
35 .replace("{luid}", luid) //
36 .replace("{chap}", Integer.toString(chap)) //
37 .replace("{para}", para == null ? "" : Integer.toString(para));
38 }
39
40 static public String getStoryUrlCover(String luid) {
41 return STORY_URL_COVER //
42 .replace("{luid}", luid);
43 }
44
45 static public String getStoryUrlJson(String luid) {
46 return STORY_URL_JSON //
47 .replace("{luid}", luid);
48 }
49
50 static public boolean isSupportedUrl(String url) {
51 return INDEX_URL.equals(url) || VERSION_URL.equals(url)
52 || LOGOUT_URL.equals(url) || isViewUrl(url) || isStoryUrl(url)
53 || isListUrl(url);
54 }
55
56 static public boolean isViewUrl(String url) {
57 return url != null && url.startsWith(VIEWER_URL_BASE);
58 }
59
60 static public boolean isStoryUrl(String url) {
61 return url != null && url.startsWith(STORY_URL_BASE);
62 }
63
64 static public boolean isListUrl(String url) {
65 return url != null && url.startsWith(LIST_URL_BASE);
66 }
67 }