Skip to content

Commit

Permalink
Update 2.2.4 Release
Browse files Browse the repository at this point in the history
* Properly update Project ID for vocab copies from Globals
* Add CSRF protection to exports
  • Loading branch information
AtesComp committed Nov 27, 2024
1 parent ed41c90 commit 3c0e7c1
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 45 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ See the [Install page Prerequisites on the wiki](https://github.com/AtesComp/rdf

<!-- RDF Transform Version Control -->
### Latest Release
[RDF Transform v2.2.3](https://github.com/AtesComp/rdf-transform/releases/download/v2.2.3/rdf-transform-2.2.3.zip)
[RDF Transform v2.2.4](https://github.com/AtesComp/rdf-transform/releases/download/v2.2.4/rdf-transform-2.2.4.zip)

### Previous Releases
[RDF Transform v2.2.3](https://github.com/AtesComp/rdf-transform/releases/download/v2.2.3/rdf-transform-2.2.3.zip)<br />
[RDF Transform v2.2.2](https://github.com/AtesComp/rdf-transform/releases/download/v2.2.2/rdf-transform-2.2.2.zip)<br />
[RDF Transform v2.2.1](https://github.com/AtesComp/rdf-transform/releases/download/v2.2.1/rdf-transform-2.2.1.zip)<br />
[RDF Transform v2.2.0](https://github.com/AtesComp/rdf-transform/releases/download/v2.2.0/rdf-transform-2.2.0.zip)<br />
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<groupId>org.openrefine</groupId>
<artifactId>rdf-transform</artifactId>
<version>2.2.3</version><!-- RDF Transform Version Control -->
<version>2.2.4</version><!-- RDF Transform Version Control -->
<!--packaging>jar</packaging--><!--We don't need no stink'n JAR file-->

<properties>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/openrefine/rdf/RDFTransform.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static public final class Reconstructor {
// RDF Transform Version Control
static public final String VERSION_MAJOR = "2";
static public final String VERSION_MINOR = "2";
static public final String VERSION_MICRO = "3";
static public final String VERSION_MICRO = "4";
static public final String VERSION =
RDFTransform.VERSION_MAJOR + "." +
RDFTransform.VERSION_MINOR + "." +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public void init(RefineServlet servlet) {

//
// DUMMY OVERRIDES ================
// The InitializationCommand is s dummy Command class that does not actually process
// The InitializationCommand is a dummy Command class that does not actually process
// POST or GET requests. Instead, it absorbs all the "controller.js" server-side
// JavaScript functionality in a more performant code processor...Java
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
this.getRDFTransform(request).setNamespaces(listVocabs);

// ...and the namespaces' vocabulary searcher...
String projectID = request.getParameter(Util.gstrProject);
String strProjectID = request.getParameter(Util.gstrProject);
RDFTransform.getGlobalContext().
getVocabularySearcher().
synchronize( projectID, listVocabs.getPrefixSet() );
synchronize( strProjectID, listVocabs.getPrefixSet() );
}
catch (Exception ex) {
NamespacesSaveCommand.respondJSON(response, CodeResponse.error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public void export(Project theProject, Properties options, Engine theEngine, Out
this.export(theProject, options, theEngine);
}

public void export(Project theProject, Properties options, Engine theEngine, Writer theWriter)
@Override
public void export(Project theProject, Properties options, Engine theEngine, final Writer theWriter)
throws IOException
{
if ( Util.isDebugMode() ) RDFPrettyExporter.logger.info("DEBUG: Exporting " + this.strName + " via Writer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,15 @@ public RDFStreamExporter(RDFFormat format, String strName) {
super(format, strName);
}

public void export(Project theProject, Properties options, Engine theEngine,
OutputStream outputStream)
public void export(Project theProject, Properties options, Engine theEngine, OutputStream outputStream)
throws IOException {
if ( Util.isDebugMode() ) RDFStreamExporter.logger.info("DEBUG: Exporting " + this.strName + " via OutputStream");
this.outputStream = outputStream;
this.export(theProject, options, theEngine);
}

public void export(Project theProject, Properties options, Engine theEngine,
Writer theWriter)
@Override
public void export(Project theProject, Properties options, Engine theEngine, final Writer theWriter)
throws IOException
{
if ( Util.isDebugMode() ) RDFStreamExporter.logger.info("DEBUG: Exporting " + this.strName + " via Writer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,21 @@ private void indexRDFTNode(RDFTNode node, String strNodeType, String strProjectI

if ( Util.isDebugMode() ) VocabularySearcher.logger.info("Indexing: ");

// NOTES:
// TextField is indexed and analyzed
// StringField is indexed but not analyzed
// StoredField is not indexed

doc.add( new StoredField( Util.gstrIRI, node.getIRI() ) );
doc.add( new TextField( Util.gstrLabel, strLabel, Field.Store.YES) );
doc.add( new TextField( Util.gstrDescription, strDesc, Field.Store.YES) );
doc.add( new StringField( Util.gstrPrefix, strPrefix, Field.Store.YES) );
doc.add( new TextField( Util.gstrLabel, strLabel, Field.Store.YES) );
doc.add( new TextField( Util.gstrDescription, strDesc, Field.Store.YES) );
doc.add( new StringField( Util.gstrPrefix, strPrefix, Field.Store.YES) );
doc.add( new StoredField( Util.gstrNamespace, strNamespace ) );
doc.add( new TextField( Util.gstrLocalPart, strLocalPart, Field.Store.YES) );
doc.add( new TextField( Util.gstrLocalPart, strLocalPart, Field.Store.YES) );
// From Node Type (Class or Property)...
doc.add( new StringField( Util.gstrType, strNodeType, Field.Store.YES ) );
doc.add( new StringField( Util.gstrType, strNodeType, Field.Store.YES ) );
// From Project ID...
doc.add( new StringField( Util.gstrProject, strProjectID, Field.Store.NO ) );
doc.add( new StringField( Util.gstrProject, strProjectID, Field.Store.NO ) );

this.writer.addDocument(doc);
}
Expand Down Expand Up @@ -526,8 +531,8 @@ private void addGlobalDocumentsToProject(TopDocs docs, String strProjectID)
// These docs are "copied" for use in the specified project.
// See the calling function: addPredefinedVocabulariesToProject()

// Set new Project ID for "copied" documents...
IndexableField fieldProjectID = new StoredField(Util.gstrProject, strProjectID);
// Set new Project ID for "copied" documents ( just like in indexRDFTNode() )...
IndexableField fieldProjectID = new StringField(Util.gstrProject, strProjectID, Field.Store.NO);

// Iterate through the Global documents...
for (ScoreDoc sdoc : docs.scoreDocs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,17 @@ class RDFExporterMenuBar
return;
}

Refine.wrapCSRF( (token) => {
let form = RDFExporterMenuBar.#prepareExportRDFForm(format, ext, token);

document.body.appendChild(form);
window.open("Export " + format, "gridworks-export");
form.submit();
document.body.removeChild(form);
});
}

static #prepareExportRDFForm(format, ext, token) {
var strProjectName =
theProject.metadata.name
.replace(/^\p{White_Space}+/u, '') // Leading Whitespace to none
Expand All @@ -296,32 +307,23 @@ class RDFExporterMenuBar
var form = document.createElement("form");

$(form)
.css("display", "none")
.attr("method", "post")
.attr("action", "command/core/export-rows/" + strProjectName + "." + ext)
.attr("target", "gridworks-export")
.hide();

$('<input />')
.attr("name", "engine")
.val( JSON.stringify( ui.browsingEngine.getJSON() ) )
.appendTo(form);

$('<input />')
.attr("name", "project")
.val(theProject.id)
.appendTo(form);

$('<input />')
.attr("name", "format")
.val(format)
.appendTo(form);

document.body.appendChild(form);

window.open("Export " + format, "gridworks-export");
form.submit();
.attr("action", "command/core/export-rows/" + strProjectName + "." + ext + "?" + $.param( {csrf_token: token} ))
.attr("target", "gridworks-export");

var appendField = (name, value) => {
$('<input />')
.attr("name", name)
.val(value)
.appendTo(form);
};

appendField("engine", JSON.stringify( ui.browsingEngine.getJSON() ));
appendField("project", theProject.id);
appendField("format", format);

document.body.removeChild(form);
return form;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/module/scripts/rdf-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class RDFTransform {
// RDF Transform Version Control
static strVERSION_MAJOR = "2";
static strVERSION_MINOR = "2";
static strVERSION_MICRO = "3";
static strVERSION_MICRO = "4";
static strVERSION =
RDFTransform.strVERSION_MAJOR + "." +
RDFTransform.strVERSION_MINOR + "." +
Expand Down
5 changes: 5 additions & 0 deletions website/content/home-text.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ <h2>Getting started...</h2>
<div id="news">
<!-- RDF Transform Version Control -->
<h2>News</h2>
<dl>
<dt>2.2.4 Released</dt>
<dd>This version corrects the Lucene ontology copy process from Global space to a Project.
</dd>
</dl>
<dl>
<dt>2.2.3 Released</dt>
<dd>This version updates dependencies and fixes the ontology loading process. It also mitigates facet
Expand Down
2 changes: 1 addition & 1 deletion website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
},
'download-latest' : { // RDF Transform Version Control
'title' : 'Download Latest',
'redirect' : 'https://github.com/AtesComp/rdf-transform/releases/download/v2.2.3/rdf-transform-2.2.3.zip'
'redirect' : 'https://github.com/AtesComp/rdf-transform/releases/download/v2.2.4/rdf-transform-2.2.4.zip'
},
'issues' : {
'title' : 'Issue Tracker',
Expand Down

0 comments on commit 3c0e7c1

Please sign in to comment.