Skip to content

Commit

Permalink
Merge origin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
alberto authored and alberto committed Jun 13, 2017
2 parents 6401ce0 + 2b4634e commit 2e7139a
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.apache.commons.codec.binary.Base64;

import cz.incad.kramerius.client.cache.SimpleJSONResultsCache;
import cz.incad.kramerius.utils.IPAddressUtils;
import cz.incad.utils.IOUtils;

public class RESTHelper {
Expand Down Expand Up @@ -152,7 +153,7 @@ public static URLConnection openConnection(HttpServletRequest request, String ur
uc.setReadTimeout(Integer.parseInt(settings.get(READ_TIMEOUT)));
uc.setConnectTimeout(Integer.parseInt(settings.get(CONNECTION_TIMEOUT)));
}
uc.setRequestProperty("X_IP_FORWARD", request.getRemoteAddr());
uc.setRequestProperty(IPAddressUtils.X_IP_FORWARD, request.getRemoteAddr());
return uc;
}

Expand Down Expand Up @@ -187,7 +188,7 @@ public static URLConnection openConnection(HttpServletRequest request, String ur
String userPassword = user + ":" + pass;
String encoded = Base64.encodeBase64String(userPassword.getBytes());

uc.setRequestProperty("X_IP_FORWARD", request.getRemoteAddr());
uc.setRequestProperty(IPAddressUtils.X_IP_FORWARD, request.getRemoteAddr());
uc.setRequestProperty("Authorization", "Basic " + encoded);
return uc;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import cz.incad.kramerius.document.model.ImagePage;
import cz.incad.kramerius.document.model.OutlineItem;
import cz.incad.kramerius.document.model.PreparedDocument;
import cz.incad.kramerius.document.model.TextPage;
import cz.incad.kramerius.pdf.OutOfRangeException;
import cz.incad.kramerius.pdf.impl.ConfigurationUtils;
import cz.incad.kramerius.pdf.utils.TitlesUtils;
Expand Down Expand Up @@ -202,61 +203,27 @@ protected void buildRenderingDocumentAsTree(
final String pid) throws IOException, ProcessSubtreeException {

fedoraAccess.processSubtree(pid, new TreeNodeProcessor() {
private int previousLevel = -1;
private OutlineItem currOutline = null;

@Override
public void process(String pid, int level)
throws ProcessSubtreeException {
try {
AbstractPage page = createPage(renderedDocument, pid);
renderedDocument.addPage(page);
if (previousLevel == -1) {
// first
AbstractPage page = null;

if (fedoraAccess.isImageFULLAvailable(pid)) {
page = createPage(renderedDocument, pid);
renderedDocument.addPage(page);
this.currOutline = createOutlineItem(
renderedDocument.getOutlineItemRoot(),
page.getOutlineDestination(),
page.getOutlineTitle(), level);
StringBuffer buffer = new StringBuffer();
this.currOutline.debugInformations(buffer, 0);
} else if (previousLevel == level) {
this.currOutline = this.currOutline.getParent();
this.currOutline = createOutlineItem(this.currOutline,
page.getOutlineDestination(),
page.getOutlineTitle(), level);

StringBuffer buffer = new StringBuffer();
this.currOutline.debugInformations(buffer, 0);

} else if (previousLevel < level) {
// dolu
this.currOutline = createOutlineItem(this.currOutline,
page.getOutlineDestination(),
page.getOutlineTitle(), level);

StringBuffer buffer = new StringBuffer();
this.currOutline.debugInformations(buffer, 0);

} else if (previousLevel > level) {
// nahoru // za poslednim smerem nahoru
// this.currOutline = this.currOutline.getParent();
int diff = previousLevel - level;
for (int i = 0; i < diff; i++) {
this.currOutline = this.currOutline.getParent();
}

page.getOutlineTitle(), 1);
StringBuffer buffer = new StringBuffer();
this.currOutline.debugInformations(buffer, 0);

this.currOutline = this.currOutline.getParent();
this.currOutline = createOutlineItem(this.currOutline,
page.getOutlineDestination(),
page.getOutlineTitle(), level);

} else {
// no page
}

previousLevel = level;
} catch (DOMException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
throw new RuntimeException(e);
Expand Down Expand Up @@ -295,8 +262,10 @@ public boolean skipBranch(String pid, int level) {

}



protected AbstractPage createTextPage(final PreparedDocument renderedDocument,
String pid) throws LexerException, IOException {
throw new IllegalStateException();
}

protected AbstractPage createPage(final PreparedDocument renderedDocument,
String pid) throws LexerException, IOException {
Expand Down Expand Up @@ -365,7 +334,8 @@ protected AbstractPage createPage(final PreparedDocument renderedDocument,
}

} else {
page = new ImagePage(modelName,

page = new TextPage(modelName,
this.fedoraAccess.findFirstViewablePid(pid));
page.setOutlineDestination(pid);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.io.*;
import java.util.Locale;
import java.util.Properties;
import java.util.Random;
import java.util.ResourceBundle;

public class ParametrizedImportInputTemplate implements ProcessInputTemplate {
Expand Down Expand Up @@ -65,6 +66,9 @@ public boolean accept(File file) {
}
});

Random randomGenerator = new Random();
int idPostfix = randomGenerator.nextInt(2000);

StringTemplateGroup parametrizedimport = new StringTemplateGroup(new InputStreamReader(iStream,"UTF-8"), DefaultTemplateLexer.class);
StringTemplate template = parametrizedimport.getInstanceOf("form");

Expand All @@ -80,7 +84,8 @@ public boolean accept(File file) {
Boolean updateExisting = configuration.getConfiguration().getBoolean("ingest.updateExisting");
template.setAttribute("updateExisting",updateExisting);


template.setAttribute("postfixdiv",""+idPostfix);

writer.write(template.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ tree(root) ::=<<



form(importDirectory,importRootDirectory, startIndexer, updateExisting, bundle) ::=<<
form(postfixdiv, importDirectory,importRootDirectory, startIndexer, updateExisting, bundle) ::=<<

<div style="width:100%">
<script language="JavaScript" type="text/javascript">
<!--



// send parameters to server
window.onProcessFormSend = function() {
var startIndexer = \$('#startIndexer').attr('checked');
Expand All @@ -47,12 +50,14 @@ form(importDirectory,importRootDirectory, startIndexer, updateExisting, bundle)
processStarter("parametrizedimport").start(url);
}


// show directory dialog
function ShowDirectoryTree() {
this.dialog = null;
}

ShowDirectoryTree.prototype.openTree=function() {

if (this.dialog) {
this.dialog.dialog('open');
} else {
Expand All @@ -77,20 +82,25 @@ form(importDirectory,importRootDirectory, startIndexer, updateExisting, bundle)
}]
});



\$(function () {
\$("#_selectImportFolderTree_$postfixdiv$").jstree({
"plugins" : [ "themes", "html_data", "ui" ]
})
.bind("select_node.jstree", function (event, data) {
var p = data.rslt.obj.attr("id");
\$("#_selectedImportFolder").text(p);
});
});


}

\$(function () {
\$("#_selectImportFolderTree").jstree({
"plugins" : [ "themes", "html_data", "ui" ]
})
.bind("select_node.jstree", function (event, data) {
var p = data.rslt.obj.attr("id");
\$("#_selectedImportFolder").text(p);
});
});

}


var directoryTree = new ShowDirectoryTree();

-->
Expand Down Expand Up @@ -124,7 +134,7 @@ form(importDirectory,importRootDirectory, startIndexer, updateExisting, bundle)

<div id="_selectImportFolderDialog" style="display:none">
<h3> $bundle.("import.selection.dialog")$</h3>
<div id="_selectImportFolderTree">
<div id="_selectImportFolderTree_$postfixdiv$">
$tree(root=importRootDirectory)$
</div>

Expand Down
10 changes: 10 additions & 0 deletions search/web/inc/adminMenu.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -718,11 +718,19 @@ ParameterizedProcess.prototype.openWaitDialog = function() {
}
}
ParameterizedProcess.prototype.destroyDialog = function() {
if (typeof __destroyParametrizedDialog !== "undefined") {
__destroyParametrizedDialog();
}
}
/**
* opens parameters dialog
*/
ParameterizedProcess.prototype.open = function(definition, paramsMapping) {
this.openWaitDialog();
paramsMapping = paramsMapping ? paramsMapping : {};
Expand Down Expand Up @@ -758,13 +766,15 @@ ParameterizedProcess.prototype.open = function(definition, paramsMapping) {
{
text: dictionary['common.start'],
click: bind(function() {
this.destroyDialog();
window.onProcessFormSend();
this.dialog.dialog("close");
}, this)
},
{
text: dictionary["common.close"],
click:bind(function() {
this.destroyDialog();
this.dialog.dialog("close");
},this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
import cz.incad.kramerius.lp.utils.ASCIITranslate;
import cz.incad.kramerius.pdf.Break;
import cz.incad.kramerius.pdf.impl.OutputStreams;
import cz.incad.kramerius.utils.conf.KConfiguration;

public class GenerateController implements Break, OutputStreams {

public static final long ONE_FILE_LIMIT = 100l << 20;

private File curFile;
private DecoratedOutputStream currentDos;
private int pocitadlo = 1;

private File folder;
private String name;
private long velikost = ONE_FILE_LIMIT;
private long velikost = KConfiguration.getInstance().getConfiguration().getLong("static.export.filelimit", 104857600);

public GenerateController(File folder, String name) {
super();
this.folder = folder;
this.name = ASCIITranslate.asciiString(name.trim());

this.corruptName();
}

Expand Down Expand Up @@ -57,5 +58,4 @@ public boolean broken(String uuid) {
if (this.currentDos.getActualSize() >= this.velikost) return true;
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public static void main(String[] args) throws Exception {
if (args.length > 6) {
LOGGER.fine("Country "+args[5]);
LOGGER.fine("Lang "+args[6]);
System.setProperty(ArgumentLocalesProvider.ISO3COUNTRY_KEY, args[5]);
if (args[5] != null) {
System.setProperty(ArgumentLocalesProvider.ISO3COUNTRY_KEY, args[5]);
}
System.setProperty(ArgumentLocalesProvider.ISO3LANG_KEY, args[6]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ public ArgumentLocalesProvider() {

@Override
public Locale get() {
Locale[] availableLocales = Locale.getAvailableLocales();
for (Locale locale : availableLocales) {
if ((locale.getISO3Country().equals(this.iso3country)) && (locale.getISO3Language().equals(this.iso3lang))) return locale;
if (this.iso3country != null && this.iso3lang != null) {
return new Locale(this.iso3lang, this.iso3country);
} else if (this.iso3lang != null) {
return new Locale(this.iso3lang);
} else {
LOGGER.info("returning default locale ");
return Locale.getDefault();
}
LOGGER.info("returning default locale ");
return Locale.getDefault();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ form(rootNode, lang, country ) ::=<<
<!--
window.onProcessFormSend = function() {
var vals = 'outputFolder='+\$('#outputFolder').val()
//var vals = 'outputFolder='+\$('#outputFolder').val().replace()
var escapedFolder = \$('#outputFolder').val().replaceAll("\\\\\\\\","/").replaceAll(":","\\\\:");
if (escapedFolder.startsWith("/")) {
escapedFolder = "/"+escapedFolder;
}
var vals = 'outputFolder='+escapedFolder
+';lang='+\$('#lang').val()
+';country='+\$('#country').val()
Expand Down
3 changes: 3 additions & 0 deletions static-export/src/main/java/res/configuration.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## Vystupni adresar statickeho exportu
static.export.folder=${sys:user.home}/.kramerius4/static_export

## limit for one file
static.export.filelimit=104857600

## Pouze pro interni potreby
_ext_configuration_file_name=static_export.properties

0 comments on commit 2e7139a

Please sign in to comment.