Skip to content

Commit a1be275

Browse files
committed
Merge branch 'master' of github.com:ceskaexpedice/kramerius
2 parents bae15b2 + 3f312be commit a1be275

File tree

4 files changed

+131
-2
lines changed

4 files changed

+131
-2
lines changed

client/src/main/webapp/js/item.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,21 @@ ItemSupport.prototype = {
258258

259259
this.biblioModsXml(div, p, this.itemContext[i].model);
260260
contextDiv.append(div);
261+
261262
}
262263
contextDiv.insertBefore("#metadata");
264+
this.renderDonator();
263265
},
264266

265-
267+
renderDonator: function(){
268+
var pid = K5.api.ctx["item"]["selected"];
269+
var data = K5.api.ctx["item"][pid];
270+
if(data.hasOwnProperty("donator")){
271+
var donatorDiv = $("<div/>", {class: "donator"});
272+
donatorDiv.append('<img src="api/item/'+data.donator+'/streams/LOGO"/>');
273+
$(".mtd_footer dialogs_footer").prepend(donatorDiv);
274+
}
275+
},
266276

267277

268278
/**

rest/src/main/java/cz/incad/kramerius/rest/api/guice/ApiServletModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import cz.incad.kramerius.rest.api.k5.client.feeder.decorators.SolrISSNDecorate;
3939
import cz.incad.kramerius.rest.api.k5.client.feeder.decorators.SolrLanguageDecorate;
4040
import cz.incad.kramerius.rest.api.k5.client.impl.SolrMemoizationImpl;
41+
import cz.incad.kramerius.rest.api.k5.client.info.InfoResource;
4142
import cz.incad.kramerius.rest.api.k5.client.item.ItemResource;
4243
import cz.incad.kramerius.rest.api.k5.client.item.decorators.CollectionsDecorator;
4344
import cz.incad.kramerius.rest.api.k5.client.item.decorators.DonatorDecorate;
@@ -94,6 +95,7 @@ protected void configureServlets() {
9495
bind(ClientRightsResource.class);
9596
bind(PDFResource.class);
9697
bind(AsyncPDFResource.class);
98+
bind(InfoResource.class);
9799

98100
bind(RightsResource.class);
99101
bind(UsersResource.class);

rest/src/main/java/cz/incad/kramerius/rest/api/k5/client/feeder/decorators/FeederSolrAuthorDecorate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void decorate(JSONObject jsonObject, Map<String, Object> runtimeContext)
3838
doc = this.memo.askForIndexDocument(pid);
3939
}
4040
if (doc != null) {
41-
List<String> authors = SOLRUtils.array(doc, "dc.creator", String.class);
41+
List<String> authors = SOLRUtils.narray(doc, "dc.creator", String.class);
4242
if (authors != null && !authors.isEmpty()) {
4343
jsonObject.put("author", authors);
4444
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package cz.incad.kramerius.rest.api.k5.client.info;
2+
3+
import com.google.inject.Inject;
4+
import com.google.inject.Provider;
5+
import cz.incad.kramerius.rest.api.exceptions.GenericApplicationException;
6+
import cz.incad.kramerius.service.ResourceBundleService;
7+
import cz.incad.kramerius.service.TextsService;
8+
import cz.incad.kramerius.utils.conf.KConfiguration;
9+
import net.sf.json.JSONObject;
10+
11+
import javax.ws.rs.*;
12+
import javax.ws.rs.core.MediaType;
13+
import javax.ws.rs.core.Response;
14+
import java.awt.*;
15+
import java.io.IOException;
16+
import java.io.InputStream;
17+
import java.util.Locale;
18+
import java.util.Properties;
19+
import java.util.logging.Logger;
20+
21+
/**
22+
* Created by Martin Rumanek on 27.5.15.
23+
*/
24+
25+
@Path("/v5.0/info")
26+
public class InfoResource {
27+
28+
private static final String DEFAULT_INTRO_CONSTANT = "default_intro";
29+
30+
private static final String INTRO_CONSTANT = "intro";
31+
32+
private static final String RIGHT_MSG = "rightMsg";
33+
34+
public static Logger LOGGER = Logger.getLogger(InfoResource.class.getName());
35+
36+
@Inject
37+
private KConfiguration configuration;
38+
39+
@Inject
40+
private TextsService textService;
41+
42+
@Inject
43+
private Provider<Locale> provider;
44+
45+
@Inject
46+
private ResourceBundleService resourceBundleService;
47+
48+
InputStream revisions = this.getClass().getClassLoader().getResourceAsStream("build.properties");
49+
50+
@GET
51+
@Produces({MediaType.APPLICATION_JSON + ";charset=utf-8"})
52+
public Response getInfo() {
53+
54+
Properties buildProperties = new Properties();
55+
String version = "";
56+
String hash = "";
57+
try {
58+
buildProperties.load(revisions);
59+
version = buildProperties.getProperty("version");
60+
hash = buildProperties.getProperty("hash");
61+
} catch (IOException e) {
62+
e.printStackTrace();
63+
}
64+
65+
JSONObject jsonObject = new JSONObject();
66+
jsonObject.put("version", version);
67+
jsonObject.put("hash", hash);
68+
69+
String adminEmail = configuration.getProperty("administrator.email");
70+
if (adminEmail != null && !adminEmail.isEmpty()) {
71+
jsonObject.put("email", adminEmail);
72+
}
73+
74+
String intro = null;
75+
String rightsMsg = null;
76+
try {
77+
if (textService.isAvailable(INTRO_CONSTANT, provider.get())) {
78+
intro = textService.getText(INTRO_CONSTANT, provider.get());
79+
} else {
80+
intro = textService.getText(DEFAULT_INTRO_CONSTANT, provider.get());
81+
}
82+
if (intro != null && !intro.isEmpty()) {
83+
jsonObject.put("intro", intro);
84+
}
85+
86+
if (textService.isAvailable(RIGHT_MSG, provider.get())) {
87+
rightsMsg = textService.getText(RIGHT_MSG, provider.get());
88+
} else {
89+
rightsMsg = resourceBundleService.getResourceBundle("labels", provider.get()).getString(RIGHT_MSG);
90+
}
91+
92+
if (intro != null && !intro.isEmpty()) {
93+
jsonObject.put("intro", intro);
94+
}
95+
96+
if (rightsMsg != null && !rightsMsg.isEmpty()) {
97+
jsonObject.put("rightMsg", rightsMsg);
98+
}
99+
100+
} catch (IOException e) {
101+
throw new GenericApplicationException(e.getMessage());
102+
}
103+
104+
String maxPage = KConfiguration.getInstance().getProperty(
105+
"generatePdfMaxRange");
106+
boolean turnOff = KConfiguration.getInstance().getConfiguration().getBoolean("turnOffPdfCheck");
107+
108+
if (turnOff) {
109+
jsonObject.put("pdfMaxRange", "unlimited");
110+
} else {
111+
jsonObject.put("pdfMaxRange", maxPage);
112+
}
113+
114+
115+
return Response.ok().entity(jsonObject.toString()).build();
116+
}
117+
}

0 commit comments

Comments
 (0)