Skip to content

Commit

Permalink
i18n keys
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-stastny committed Jan 28, 2015
1 parent ec361b5 commit 9acc1e3
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,74 @@
import org.json.JSONObject;

import cz.incad.kramerius.client.utils.RedirectHelp;
import cz.incad.kramerius.utils.StringUtils;
import cz.incad.kramerius.utils.conf.KConfiguration;

public class PrintFunctionalityServlet extends HttpServlet {

public static Logger LOGGER = Logger.getLogger(PrintFunctionalityServlet.class.getName());

public static Logger LOGGER = Logger
.getLogger(PrintFunctionalityServlet.class.getName());

private static boolean encodedTypes(String mtype) {
return mtype.contains("pdf") || mtype.contains("djvu") || mtype.contains("jp2");
return mtype.contains("pdf") || mtype.contains("djvu")
|| mtype.contains("jp2");
}

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
try {
String params = req.getParameter("pids");
if (params != null) {
String startPid = req.getParameter("startPid");
String parentPid = req.getParameter("parentPid");

if (StringUtils.isAnyString(params)) {
String[] splitted = params.split(",");
if (splitted.length > 0) {
boolean transcode = false;
for (String pid : splitted) {
try {
String api = KConfiguration.getInstance().getConfiguration().getString("api.point");
String api = KConfiguration.getInstance()
.getConfiguration().getString("api.point");
if (!api.endsWith("/")) {
api += "/";
}

String jsoned = getJSON(api+"item/"+pid+"/streams");
String jsoned = getJSON(api + "item/" + pid
+ "/streams");
JSONObject jObject = new JSONObject(jsoned);
JSONObject imgFull = jObject.getJSONObject("IMG_FULL");
JSONObject imgFull = jObject
.getJSONObject("IMG_FULL");
String mType = imgFull.getString("mimeType");
if (encodedTypes(mType)) {
transcode = true;
break;
}
} catch (JSONException e) {
LOGGER.log(Level.SEVERE,e.getMessage(),e);
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}

String redirecthost = RedirectHelp.redirectApplication(req);
String str = redirecthost+"search/inc/_iprint.jsp?pids="+params+"&transcode="+transcode+"&page=A4&layout=portrait";
String str = redirecthost + "search/inc/_iprint.jsp?pids="
+ params + "&transcode=" + transcode
+ "&page=A4&layout=portrait";
resp.sendRedirect(str);
}
} else if (StringUtils.isAnyString(startPid)) {
String redirecthost = RedirectHelp.redirectApplication(req);
String str = redirecthost + "search/inc/_iprint.jsp?startPid="
+ startPid;
resp.sendRedirect(str);

} else if (StringUtils.isAnyString(parentPid)) {
String redirecthost = RedirectHelp.redirectApplication(req);
String str = redirecthost + "search/inc/_iprint.jsp?parentPid="
+ parentPid;
resp.sendRedirect(str);
}
} catch (ConfigurationException e) {
LOGGER.log(Level.SEVERE,e.getMessage(),e);
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
}
2 changes: 2 additions & 0 deletions client/src/main/resources/k5client.properties
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ common.action = Action

common.all = All

common.url.handle=Persistent URL

fedora.model=Fedora models
fedora.model.page=Page
fedora.model.monograph=Monograph
Expand Down
2 changes: 2 additions & 0 deletions client/src/main/resources/k5client_cs.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ common.change=Zm\u011bna
common.close=Zav\u0159\u00edt
common.saveandclose=Zav\u0159\u00edt a ulo\u017eit

common.url.handle=Persistentní URL


common.collections=Virtu\u00e1ln\u00ed sb\u00edrky
common.cool=vybran\u00e9
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/webapp/WEB-INF/actions/persistent.vm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<div id="persistens_container" class="dialogs_content">
<div>
<label data-key="application.url">Persistent url </label>
<label data-key="common.url.handle">$i18n.common.url.handle</label>
</div>
<div>
<input type="text" id="persisturl" name="persistenturl" />
Expand Down
1 change: 1 addition & 0 deletions client/src/main/webapp/WEB-INF/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2611,6 +2611,7 @@ div.download {
}

#download_options select option {
background-color: white;
color: black;
}
#download_options div {
Expand Down
4 changes: 0 additions & 4 deletions client/src/main/webapp/js/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,9 @@ function _eventProcess(pid) {
K5.gui["selected"] = mixInto(new ItemSupport(K5), instance);
K5.gui["selected"].initItemSupport();
K5.gui["selected"].open();
//K5.gui["selected"].ctxMenu();

K5.gui["selected"]["ctx"] = {};

//_metadatainit();


K5.gui.selected["disabledDisplay"] = false;
});
var failfunc = _.bind(function() {
Expand Down
10 changes: 1 addition & 9 deletions client/src/main/webapp/js/outputs/outprint.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ PrintSupport.prototype= {


title: function(pid) {
var itm = K5.api.ctx.item[pid];
var children = itm.children;
var ll = children.length;
var v = _.reduce(children, function(memo, value, key){
memo = memo + value.pid;
if (key >= 0 && key < ll - 1) memo = memo +",";
return memo;
}, "");
window.open('print?pids='+v,'_blank');
window.open('print?parentPid='+pid,'_blank');
}
}
2 changes: 1 addition & 1 deletion common/src/main/java/base.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pdf.Blank=Blank page
pdf.Index=Index

pdf.firstpage.library=Digital library
pdf.firstpage.title=KRAMERIUS 4
pdf.firstpage.title=KRAMERIUS 5


fedora.model=Fedora models
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/base_cs.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pdf.Blank=Pr\u00E1zdn\u00E1 strana
pdf.Index=Rest\u00E1ik

pdf.firstpage.library=Digitální knihovna
pdf.firstpage.title=KRAMERIUS 4
pdf.firstpage.title=KRAMERIUS 5

fedora.model=Modely Fedora
fedora.model.page=Stránka
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public class PDFResource extends AbstractPDFResource {

public static Logger LOGGER = Logger.getLogger(PDFResource.class.getName());




@GET
@Path("selection")
Expand Down Expand Up @@ -95,6 +93,7 @@ public Response selection(@QueryParam("pids") String pidsParam,
&& (!configuration.getApplicationURL().equals(""))) {
i18nUrl = configuration.getApplicationURL() + "i18n";
}

AbstractPDFResource.FirstPage fp = pageType != null ? AbstractPDFResource.FirstPage
.valueOf(pageType) : AbstractPDFResource.FirstPage.TEXT;
String[] pids = pidsParam.split(",");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import cz.incad.kramerius.FedoraAccess;
import cz.incad.kramerius.ObjectPidsPath;
import cz.incad.kramerius.SolrAccess;
import cz.incad.kramerius.rest.api.k5.client.SolrMemoization;
import cz.incad.kramerius.rest.api.k5.client.item.utils.ItemResourceUtils;
import cz.incad.kramerius.security.IsActionAllowed;
import cz.incad.kramerius.security.SecuredActions;
import cz.incad.kramerius.security.User;
Expand Down Expand Up @@ -48,6 +50,9 @@ public class PicturePrepareViewObject extends AbstractPrepareViewObject impleme
@Inject
SolrAccess solrAccess;

@Inject
SolrMemoization solrMemoization;

private List<String> pids = new ArrayList<String>();


Expand All @@ -57,7 +62,18 @@ public void init() {
double ratio = KConfiguration.getInstance().getConfiguration().getDouble("search.print.pageratio",1.414);
HttpServletRequest request = this.servletRequestProvider.get();
String pidsString = request.getParameter("pids");
String[] pids = pidsString.split(",");
String startPid = request.getParameter("startPid");
String parentPid = request.getParameter("parentPid");

String[] pids = new String[0];
if (StringUtils.isAnyString(pidsString)) {
pids = pidsAsList(pidsString);
} else if (StringUtils.isAnyString(startPid)){
pids = pidsAsSiblings(startPid);
} else if (StringUtils.isAnyString(parentPid)){
pids = pidsAsChildren(parentPid);
}

String transcode = request.getParameter("transcode");
int bits = numberOfBits(pids.length);
for (int i = 0; i < pids.length; i++) {
Expand Down Expand Up @@ -86,6 +102,47 @@ public void init() {
}
}


private String[] pidsAsChildren(String parentPid)
throws IOException {
String[] pids = new String[0];
List<String> solrChildrenPids = ItemResourceUtils.solrChildrenPids(parentPid, new ArrayList<String>(), this.solrAccess, this.solrMemoization);
return solrChildrenPids.toArray(new String[solrChildrenPids.size()]);
}


private String[] pidsAsSiblings( String startPid)
throws IOException {
String[] pids = new String[0];
ObjectPidsPath[] paths = this.solrAccess.getPath(startPid);
ObjectPidsPath pths = selectOnePath(startPid, paths);
String[] pidsPths = pths.getPathFromRootToLeaf();
if (pidsPths.length > 1) {
String parent = pidsPths[pidsPths.length -2];
List<String> solrChildrenPids = ItemResourceUtils.solrChildrenPids(parent, new ArrayList<String>(), this.solrAccess, this.solrMemoization);
List<String> rest = new ArrayList<String>();
boolean append = true;
for (String pid : solrChildrenPids) {
if ((!append) && pid.equals(startPid)) {
append = true;
}
if (append) {
rest.add(pid);
}
}
pids = rest.toArray(new String[rest.size()]);
}
return pids;
}


private String[] pidsAsList(String pidsString) {
String[] pids;
pids = pidsString.split(",");
return pids;
}


private boolean canBeRead(String pid) throws IOException {
ObjectPidsPath[] paths = solrAccess.getPath(pid);
for (ObjectPidsPath pth : paths) {
Expand All @@ -96,5 +153,16 @@ private boolean canBeRead(String pid) throws IOException {
return false;
}

public static ObjectPidsPath selectOnePath(String requestedPid,
ObjectPidsPath[] paths) {
ObjectPidsPath path;
if (paths.length > 0) {
path = paths[0];
} else {
path = new ObjectPidsPath(requestedPid);
}
return path;
}

}

0 comments on commit 9acc1e3

Please sign in to comment.