Skip to content

Commit

Permalink
Merge pull request #75 from ebremer/develop
Browse files Browse the repository at this point in the history
Zephyr Enhancements and library updates
  • Loading branch information
ebremer authored Jun 24, 2024
2 parents 9fb6f78 + eabe952 commit ce598e2
Show file tree
Hide file tree
Showing 102 changed files with 4,008 additions and 761 deletions.
108 changes: 108 additions & 0 deletions Halcyon/nbactions-native.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.longClasspath>true</exec.longClasspath>
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.executable>java</exec.executable>
<exec.vmArgs>--enable-preview -Xmx50G -Xms50G --add-opens=java.base/java.nio=ALL-UNNAMED</exec.vmArgs>
<exec.appArgs></exec.appArgs>
<exec.mainClass>com.ebremer.halcyon.server.Main</exec.mainClass>
</properties>
</action>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.longClasspath>true</exec.longClasspath>
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
<exec.vmArgs>--enable-preview -Xmx50G -Xms50G --add-opens=java.base/java.nio=ALL-UNNAMED -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</exec.vmArgs>
<exec.appArgs></exec.appArgs>
<exec.mainClass>com.ebremer.halcyon.server.Main</exec.mainClass>
</properties>
</action>
<action>
<actionName>profile</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.longClasspath>true</exec.longClasspath>
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.executable>java</exec.executable>
<exec.vmArgs>--enable-preview -Xmx50G -Xms50G --add-opens=java.base/java.nio=ALL-UNNAMED</exec.vmArgs>
<exec.appArgs></exec.appArgs>
<exec.mainClass>com.ebremer.halcyon.server.Main</exec.mainClass>
</properties>
</action>
<action>
<actionName>build-with-dependencies</actionName>
<reactor>also-make</reactor>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>install</goal>
</goals>
<properties>
<exec.longClasspath>true</exec.longClasspath>
</properties>
</action>
<action>
<actionName>run.single.main</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:3.0.0:exec</goal>
</goals>
<properties>
<exec.longClasspath>true</exec.longClasspath>
<exec.vmArgs></exec.vmArgs>
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.executable>java</exec.executable>
<exec.mainClass>${packageClassName}</exec.mainClass>
<exec.classpathScope>${classPathScope}</exec.classpathScope>
</properties>
</action>
<action>
<actionName>debug.single.main</actionName>
<packagings>
<packaging>*</packaging>
</packagings>
<goals>
<goal>process-test-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:3.0.0:exec</goal>
</goals>
<properties>
<exec.longClasspath>true</exec.longClasspath>
<exec.vmArgs>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</exec.vmArgs>
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.executable>java</exec.executable>
<exec.mainClass>${packageClassName}</exec.mainClass>
<exec.classpathScope>${classPathScope}</exec.classpathScope>
<jpda.listen>true</jpda.listen>
</properties>
</action>
</actions>
16 changes: 6 additions & 10 deletions Halcyon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@
<profile>
<id>native</id>
<build>
<plugins>
<plugins>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down Expand Up @@ -242,17 +243,12 @@
</goals>
</execution>
</executions>
</plugin>
</plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<image>
<builder>paketobuildpacks/builder:tiny</builder>
<env>
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
</env>
</image>
</configuration>
<executions>
<execution>
Expand All @@ -262,10 +258,11 @@
</goals>
</execution>
</executions>
</plugin>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.10.1</version>
<extensions>true</extensions>
<executions>
<execution>
Expand All @@ -281,7 +278,6 @@
<fallback>false</fallback>
<mainClass>com.ebremer.halcyon.server.Main</mainClass>
<buildArgs>
<buildArg>--no-fallback</buildArg>
</buildArgs>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<metadataRepository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,33 @@

import java.util.UUID;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.wicket.model.LoadableDetachableModel;

/**
*
* @author erich
*/
public class RDFDetachableModel extends LoadableDetachableModel<Model> {
private final String originaluuid;
private final String uuid;

public RDFDetachableModel(Model m) {
super();
this.uuid = UUID.randomUUID().toString();
this.originaluuid = UUID.randomUUID().toString();
Model org = ModelFactory.createDefaultModel();
org.add(m);
EphemeralModelStorage.getInstance().put(originaluuid, org);
EphemeralModelStorage.getInstance().put(uuid, m);
}

/*
public RDFDetachableModel(String uuid, Model m) {
super();
this.uuid = uuid;
EphemeralModelStorage.getInstance().put(uuid, m);
}
}*/

public void flush() {
EphemeralModelStorage.getInstance().remove(uuid);
Expand All @@ -32,6 +39,10 @@ public Model load() {
return EphemeralModelStorage.getInstance().get(uuid);
}

public Model loadOriginal() {
return EphemeralModelStorage.getInstance().get(originaluuid);
}

@Override
public void detach() {
super.detach();
Expand Down
19 changes: 12 additions & 7 deletions Halcyon/src/main/java/com/ebremer/ethereal/RDFRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Statement;
import org.apache.jena.shared.PropertyNotFoundException;
import org.apache.jena.vocabulary.DCTerms;
import org.apache.jena.vocabulary.SchemaDO;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.IModel;
Expand All @@ -24,14 +25,18 @@ public Object getDisplayValue(Object t) {
Model m = rdg.getObject();
Node r = (Node) t;
Statement s;
try {
s = m.getRequiredProperty(m.createResource(r.toString()), SchemaDO.name);
try {
s = m.getRequiredProperty(m.createResource(r.toString()), DCTerms.title);
} catch (PropertyNotFoundException ex) {
return switch (r.toString()) {
case "urn:halcyon:nocollections" -> "not specified";
case "urn:halcyon:allcollections" -> "All";
default -> r.toString();
};
try {
s = m.getRequiredProperty(m.createResource(r.toString()), SchemaDO.name);
} catch (PropertyNotFoundException ex2) {
return switch (r.toString()) {
case "urn:halcyon:nocollections" -> "not specified";
case "urn:halcyon:allcollections" -> "All";
default -> r.toString();
};
}
}
return s.getObject().asLiteral().getString();
}
Expand Down
2 changes: 1 addition & 1 deletion Halcyon/src/main/java/com/ebremer/ethereal/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public LinkedHashMap<String,Node> getMap() {
public Model get(String key) {
Node n = d.get(key);
if (n==null) {
return Model.of("UNBOUND");
return Model.of("");
}
if (n.isURI()) {
return Model.of(n.getURI());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ebremer.halcyon.data;

import com.ebremer.halcyon.data.WACSecurityEvaluator;
import com.ebremer.halcyon.datum.AccessDeniedException;
import com.ebremer.halcyon.datum.HalSec;
import com.ebremer.halcyon.datum.HalcyonPrincipal;
Expand Down Expand Up @@ -72,17 +71,16 @@ public Graph getDefaultGraph() {
public Graph getGraph(Node graphNode) {
boolean isReadAllowed = hasReadAccess(graphNode);
if (isReadAllowed) {
Graph gg = base.getGraph(graphNode);
gg = Factory.getInstance(securityEvaluator, graphNode.getURI(), gg);
return gg;
return Factory.getInstance(securityEvaluator, graphNode.getURI(), base.getGraph(graphNode));
} else {
return GraphZero.instance();
return (Graph) GraphZero.instance();
}
}

@Override
public Graph getUnionGraph() {
throw new UnsupportedOperationException("Not supported yet.");
Graph g = base.getUnionGraph();
return Factory.getInstance(securityEvaluator, "http://localhost/unionx", g);
}

@Override
Expand All @@ -93,7 +91,7 @@ public boolean containsGraph(Node graphNode) {
@Override
public void addGraph(Node node, Graph graph) {
HalcyonPrincipal hp = HalcyonSession.get().getHalcyonPrincipal();
if (HalSec.canCreateCollection(hp.getURNUUID())) {
if (HalSec.canCreateCollection(hp.getUserURI())) {
base.addGraph(node, graph);
} else {
throw new UnsupportedOperationException("Not supported yet.");
Expand Down
42 changes: 42 additions & 0 deletions Halcyon/src/main/java/com/ebremer/halcyon/data/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.ebremer.halcyon.data;

import static com.ebremer.halcyon.data.DataCore.Level.CLOSED;
import com.ebremer.ns.HAL;
import org.apache.jena.graph.Graph;
import org.apache.jena.permissions.graph.SecuredGraph;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.DatasetFactory;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.ReadWrite;
import org.apache.jena.query.ResultSetFormatter;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.tdb2.TDB2Factory;


/**
*
* @author erich
*/
public class Test {

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
Dataset x = TDB2Factory.connectDataset("/projects/Halcyon/Halcyon/tdb2");
Dataset ds = DatasetFactory.wrap(new SecuredDatasetGraph(x.asDatasetGraph(), new WACSecurityEvaluator(CLOSED)));
QueryExecution qe = QueryExecutionFactory.create(
"""
select *
where { graph <https://halcyon.is/ns/CollectionsAndResources> {
?s ?p ?o
}
}
""", ds);
ds.begin(ReadWrite.READ);
ResultSetFormatter.out(System.out,qe.execSelect());
ds.end();

}
}
Loading

0 comments on commit ce598e2

Please sign in to comment.