You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/02/22 16:21:36 UTC
[35/37] MARMOTTA-105: refactoring of packages in remaining platform
modules
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/model/SecurityConstraint.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/model/SecurityConstraint.java b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/model/SecurityConstraint.java
new file mode 100644
index 0000000..eef5593
--- /dev/null
+++ b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/model/SecurityConstraint.java
@@ -0,0 +1,304 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.platform.security.model;
+
+import org.apache.marmotta.platform.security.util.SubnetInfo;
+import org.apache.marmotta.commons.collections.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class SecurityConstraint implements Comparable<SecurityConstraint> {
+
+ public enum Type { PERMISSION, RESTRICTION };
+
+
+ private static Logger log = LoggerFactory.getLogger(SecurityConstraint.class);
+
+
+ private Type type;
+
+
+ private String name;
+
+ /**
+ * The URL pattern as a regular expression starting from the application root
+ */
+ private String urlPattern;
+
+ /**
+ * The host patterns as a list of strings in CIDR notation (e.g. 127.0.0.1/24, 192.168.100.2/32)
+ */
+ private Set<SubnetInfo> hostPatterns;
+
+
+ private boolean enabled = true;
+
+
+ /**
+ * The names of the roles for which access is granted
+ */
+ private Set<String> roles;
+
+ /**
+ * The methods to which this security constraint applies
+ */
+ private Set<HTTPMethods> methods;
+
+ /**
+ * The priority of this security constraint
+ */
+ private int priority = 1;
+
+
+ public SecurityConstraint(Type type, String name, String urlPattern, boolean enabled) {
+ this.type = type;
+ this.name = name;
+ this.enabled = enabled;
+ this.urlPattern = urlPattern;
+
+ roles = new HashSet<String>();
+ methods = new HashSet<HTTPMethods>();
+ hostPatterns = new HashSet<SubnetInfo>();
+ }
+
+ public SecurityConstraint(Type type, String name, String urlPattern, boolean enabled, int priority) {
+ this(type, name, urlPattern, enabled);
+ this.priority = priority;
+ }
+
+ /**
+ * Check whether the security constraint matches with the servlet request. Applies method, URL and
+ * remote address matching
+ *
+ * @param request
+ * @return
+ */
+ public boolean matches(HttpServletRequest request) {
+ return enabled && matchesMethod(request) && matchesAddress(request) && matchesUrl(request) && matchesRoles(request);
+ }
+
+
+ private boolean matchesMethod(HttpServletRequest request) {
+ // match any method
+ if(methods.size() == 0) {
+ return true;
+ }
+
+ HTTPMethods method = HTTPMethods.parse(request.getMethod());
+
+ if(method != null) {
+ return methods.contains(method);
+ } else {
+ // no method given
+ log.warn("request did not contain a supported HTTP method");
+ return false;
+ }
+ }
+
+ private boolean matchesUrl(HttpServletRequest request) {
+ try {
+ URL url = new URL(request.getRequestURL().toString());
+ String prefix = request.getContextPath();
+ String path = null;
+ if(url.getPath().startsWith(prefix)) {
+ path = url.getPath().substring(prefix.length());
+
+ return path.matches(urlPattern);
+
+ } else {
+ return false;
+ }
+
+
+
+ } catch(MalformedURLException ex) {
+ log.error("the request URL {} was invalid",request.getRequestURL().toString());
+ return false;
+ }
+
+
+ }
+
+ /**
+ * Check whether the remote address of the request matches one of the host patterns (CIDR)
+ * @param request
+ * @return true if there are no host patterns configured or one of the host patterns matches the remote address
+ */
+ private boolean matchesAddress(HttpServletRequest request) {
+ if(hostPatterns.size() == 0) {
+ return true;
+ }
+
+
+ for(SubnetInfo hostPattern : hostPatterns) {
+ if(hostPattern.getHostAddress().equals(request.getRemoteAddr()) || hostPattern.isInRange(request.getRemoteAddr())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check whether the request user is in one of the specified roles.
+ * @param request
+ * @return true if no roles are set or the user is in one of the configured roles
+ */
+ private boolean matchesRoles(HttpServletRequest request) {
+ if(roles.size() == 0) {
+ return true;
+ } else {
+ Set<String> userRoles = (Set<String>)request.getAttribute("user.roles");
+ if(userRoles != null) {
+ for(String role : roles) {
+ if(userRoles.contains(role)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Compares this object with the specified object for order. Returns a
+ * negative integer, zero, or a positive integer as this object is less
+ * than, equal to, or greater than the specified object.
+ *
+ * @param o the object to be compared.
+ * @return a negative integer, zero, or a positive integer as this object
+ * is less than, equal to, or greater than the specified object.
+ * @throws ClassCastException if the specified object's type prevents it
+ * from being compared to this object.
+ */
+ @Override
+ public int compareTo(SecurityConstraint o) {
+ if(this.priority > o.priority) {
+ return -1;
+ } else if(o.priority > this.priority) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUrlPattern() {
+ return urlPattern;
+ }
+
+ public void setUrlPattern(String urlPattern) {
+ this.urlPattern = urlPattern;
+ }
+
+ public Set<SubnetInfo> getHostPatterns() {
+ return hostPatterns;
+ }
+
+ public void setHostPatterns(Set<SubnetInfo> hostPattern) {
+ this.hostPatterns = hostPattern;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Set<String> getRoles() {
+ return roles;
+ }
+
+ public void setRoles(Set<String> roles) {
+ this.roles = roles;
+ }
+
+ public Set<HTTPMethods> getMethods() {
+ return methods;
+ }
+
+ public void setMethods(Set<HTTPMethods> methods) {
+ this.methods = methods;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
+
+ @Override
+ public String toString() {
+ String s = "security constraint "+name+":";
+ if(type == Type.PERMISSION) {
+ s += " allow ";
+ } else {
+ s += " deny ";
+ }
+ if(methods.size() > 0) {
+ s += "{" + CollectionUtils.fold(methods, ",") + "} of ";
+ }
+ s += urlPattern;
+ if(hostPatterns.size() > 0) {
+ s += " from " + CollectionUtils.fold(hostPatterns, new CollectionUtils.StringSerializer<SubnetInfo>() {
+ @Override
+ public String serialize(SubnetInfo subnetInfo) {
+ return subnetInfo.getCidrSignature();
+ }
+ }, ",");
+ }
+ s += ": ";
+ if(enabled) {
+ s += " enabled";
+ if(roles.size() > 0) {
+ s += " to " + CollectionUtils.fold(roles, ", ");
+ }
+ } else {
+ s += " unrestricted";
+ }
+ return s;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/services/SecurityServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/services/SecurityServiceImpl.java b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/services/SecurityServiceImpl.java
new file mode 100644
index 0000000..e59738a
--- /dev/null
+++ b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/services/SecurityServiceImpl.java
@@ -0,0 +1,328 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.platform.security.services;
+
+import org.apache.marmotta.platform.security.api.SecurityService;
+import org.apache.marmotta.platform.security.model.SecurityConstraint;
+import org.apache.marmotta.platform.security.util.SubnetInfo;
+import com.google.common.collect.Lists;
+import org.apache.marmotta.platform.core.api.config.ConfigurationService;
+import org.apache.marmotta.platform.core.events.ConfigurationChangedEvent;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.slf4j.Logger;
+import sun.net.util.IPAddressUtil;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import static org.apache.marmotta.platform.security.model.HTTPMethods.parse;
+
+/**
+ * Security Service default implementartion
+ *
+ * @author Sebastian Schaffert
+ */
+@ApplicationScoped
+public class SecurityServiceImpl implements SecurityService {
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private ConfigurationService configurationService;
+
+ private boolean profileLoading = false;
+
+ private List<SecurityConstraint> constraints;
+
+ @PostConstruct
+ public void initialise() {
+ log.info("Initialising Security Service; Access control is {}.",configurationService.getBooleanConfiguration("security.enabled",true)?"enabled":"disabled");
+ initSecurityConstraints();
+ }
+
+ /**
+ * Parse the security configuration contained in the configuration file into a list of SecurityConstraints, ordered
+ * by priority. This list will be evaluated for each request to the system.
+ */
+ private void initSecurityConstraints() {
+ constraints = new ArrayList<SecurityConstraint>();
+
+ if(configurationService.getBooleanConfiguration("security.enabled",true)) {
+
+ for(String type : Lists.newArrayList("permission","restriction")) {
+ // determine the names of constraints that are configured
+ Set<String> configNames = new HashSet<String>();
+ for(String key : configurationService.listConfigurationKeys("security."+type)) {
+ String[] components = key.split("\\.");
+ if(components.length > 2) {
+ configNames.add(components[2]);
+ }
+ }
+
+ for(String configName : configNames) {
+ String keyPrefix = "security."+type+"."+configName;
+
+ String pattern = configurationService.getStringConfiguration(keyPrefix+".pattern");
+ boolean enabled = configurationService.getBooleanConfiguration(keyPrefix + ".enabled", true);
+ int priority = configurationService.getIntConfiguration(keyPrefix+".priority",1);
+ List<String> methods = configurationService.getListConfiguration(keyPrefix + ".methods");
+ List<String> hosts = configurationService.getListConfiguration(keyPrefix + ".host");
+ List<String> roles = configurationService.getListConfiguration(keyPrefix + ".roles");
+
+ SecurityConstraint constraint =
+ new SecurityConstraint(SecurityConstraint.Type.valueOf(type.toUpperCase()),
+ configName,
+ pattern,
+ enabled,
+ priority);
+ constraint.getRoles().addAll(roles);
+
+ for(String method : methods) {
+ constraint.getMethods().add(parse(method));
+ }
+
+ constraint.setHostPatterns(parseHostAddresses(hosts));
+ constraints.add(constraint);
+
+ }
+ }
+
+ Collections.sort(constraints);
+
+ if(log.isInfoEnabled()) {
+ log.info("The following security constraints have been configured:");
+ for(SecurityConstraint constraint : constraints) {
+ log.info("-- {}",constraint.toString());
+ }
+
+ }
+ }
+ }
+
+ /**
+ * Parse host patterns into subnet information. A host pattern has one of the following forms:
+ * <ul>
+ * <li>LOCAL, meaning all local interfaces</li>
+ * <li>x.x.x.x/yy, meaning an IPv4 CIDR address with netmask (number of bits significant for the network, max 32), e.g. 192.168.100.0/24 </li>
+ * <li>xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/yy, meaning an IPv6 CIDR address with netmask (prefix length, max 128)</li>
+ * </ul>
+ * @param hostPatternStrings
+ * @return
+ */
+ private Set<SubnetInfo> parseHostAddresses(List<String> hostPatternStrings) {
+ HashSet<SubnetInfo> hostPatterns = new HashSet<SubnetInfo>();
+ for(String host : hostPatternStrings) {
+ try {
+ // reserved name: LOCAL maps to all local addresses
+ if("LOCAL".equalsIgnoreCase(host)) {
+ try {
+ Enumeration<NetworkInterface> ifs = NetworkInterface.getNetworkInterfaces();
+ while(ifs.hasMoreElements()) {
+ NetworkInterface iface = ifs.nextElement();
+ Enumeration<InetAddress> addrs = iface.getInetAddresses();
+ while(addrs.hasMoreElements()) {
+ InetAddress addr = addrs.nextElement();
+
+ try {
+ hostPatterns.add(SubnetInfo.getSubnetInfo(addr));
+ } catch (UnknownHostException e) {
+ log.warn("could not parse interface address: {}",e.getMessage());
+ }
+
+ }
+ }
+ } catch(SocketException ex) {
+ log.warn("could not determine local IP addresses, will use 127.0.0.1/24");
+
+ try {
+ hostPatterns.add(SubnetInfo.getSubnetInfo("127.0.0.1/24")); // IPv4
+ hostPatterns.add(SubnetInfo.getSubnetInfo("::1/128")); // IPv6
+ } catch (UnknownHostException e) {
+ log.error("could not parse localhost address: {}",e.getMessage());
+ }
+ }
+ } else if(host.matches("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\./[0-9]+$")) {
+ // CIDR notation
+ try {
+ hostPatterns.add(SubnetInfo.getSubnetInfo(host));
+ } catch (UnknownHostException e) {
+ log.warn("could not parse host specification '{}': {}",host,e.getMessage());
+ }
+
+ } else if(host.matches("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$")) {
+ // IP address
+ try {
+ hostPatterns.add(SubnetInfo.getSubnetInfo(host+"/32"));
+ } catch (UnknownHostException e) {
+ log.warn("could not parse host specification '{}': {}",host,e.getMessage());
+ }
+
+ } else if (IPAddressUtil.isIPv6LiteralAddress(host)) {
+ // IPv6 address
+ try {
+ hostPatterns.add(SubnetInfo.getSubnetInfo(host));
+ } catch (UnknownHostException e) {
+ log.warn("could not parse host specification '{}': {}",host,e.getMessage());
+ }
+
+
+ } else {
+ log.warn("invalid host name specification: {}; please use either CIDR u.v.w.x/zz notation or the keyword LOCAL", host);
+ }
+ } catch(IllegalArgumentException ex) {
+ log.warn("illegal host specification for security constraint {}; not in CIDR notation!",host);
+ }
+ }
+ return hostPatterns;
+ }
+
+ /**
+ * React to a change in the security configuration, e.g. when the profile is changed.
+ * @param event
+ */
+ public void configurationChangedEvent(@Observes ConfigurationChangedEvent event) {
+ if (profileLoading) return;
+
+ boolean load = false, init = false;
+ for (String key : event.getKeys()) {
+ if ("security.profile".equals(key)) {
+ load = true;
+ } else if (key.startsWith("security")) {
+ init = true;
+ }
+ }
+
+ if (load) {
+ loadSecurityProfile(configurationService.getStringConfiguration("security.profile"));
+ }
+ if (init) {
+ log.info("Access Control Filter reloading. Access control is {}.",configurationService.getBooleanConfiguration("security.enabled",true)?"enabled":"disabled");
+ initSecurityConstraints();
+ }
+ }
+
+
+ /**
+ * Check whether access is granted for the given request. Returns true if the security system grants access.
+ * Returns false if access is denied; in this case, the caller may decide to sent an authorization request to
+ * the client.
+ *
+ * @param request
+ * @return true in case the active security constraints grant access, false otherwise
+ */
+ @Override
+ public boolean grantAccess(HttpServletRequest request) {
+ if(configurationService.getBooleanConfiguration("security.enabled",true)) {
+ if(!configurationService.getBooleanConfiguration("security.configured")) {
+ loadSecurityProfile(configurationService.getStringConfiguration("security.profile"));
+ }
+
+
+ for(SecurityConstraint constraint : constraints) {
+ if(constraint.matches(request)) {
+ if(constraint.getType() == SecurityConstraint.Type.PERMISSION) {
+ log.debug("access to {} granted; {}", request.getRequestURL(), constraint);
+ return true;
+ } else {
+ log.debug("access to {} denied; {}", request.getRequestURL(), constraint);
+ return false;
+ }
+ }
+ }
+
+ log.debug("access to {} denied; no rule matched",request.getRequestURL());
+ return false;
+ } else
+ return true;
+ }
+
+
+ /**
+ * Load a pre-configured security profile from the classpath. When calling this method, the service will
+ * look for files called security-profile.<name>.properties and replace all existing security constraints by
+ * the new security constraints.
+ *
+ * @param profile
+ */
+ @Override
+ public void loadSecurityProfile(String profile) {
+ profileLoading = true;
+
+ URL securityConfigUrl = this.getClass().getClassLoader().getResource("security-profile."+profile+".properties");
+
+ if(securityConfigUrl != null) {
+ Configuration securityConfig = null;
+ try {
+ securityConfig = new PropertiesConfiguration(securityConfigUrl);
+
+ // remove all configuration keys that define permissions or restrictions
+ for(String type : Lists.newArrayList("permission","restriction")) {
+ // determine the names of constraints that are configured
+ for(String key : configurationService.listConfigurationKeys("security."+type)) {
+ configurationService.removeConfiguration(key);
+ }
+ }
+
+ for(Iterator<String> keys = securityConfig.getKeys() ; keys.hasNext(); ) {
+ String key = keys.next();
+
+ configurationService.setConfigurationWithoutEvent(key, securityConfig.getProperty(key));
+ }
+
+ configurationService.setConfigurationWithoutEvent("security.configured", true);
+ } catch (ConfigurationException e) {
+ log.error("error parsing security-profile.{}.properties file at {}: {}",new Object[] {profile,securityConfigUrl,e.getMessage()});
+ }
+
+ }
+
+ profileLoading = false;
+
+ initSecurityConstraints();
+ }
+
+ @Override
+ public List<SecurityConstraint> listSecurityConstraints() {
+ return constraints;
+ }
+
+ /**
+ * Does nothing, just ensures the security service is properly initialised.
+ * TODO: this is a workaround and should be fixed differently.
+ */
+ @Override
+ public void ping() {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/IPv4SubnetInfo.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/IPv4SubnetInfo.java b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/IPv4SubnetInfo.java
new file mode 100644
index 0000000..ff92776
--- /dev/null
+++ b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/IPv4SubnetInfo.java
@@ -0,0 +1,83 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.platform.security.util;
+
+import org.apache.commons.net.util.SubnetUtils;
+
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * Implementation of subnet information for IPv4, based on Apache Commons Net.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class IPv4SubnetInfo extends SubnetInfo {
+
+ private SubnetUtils.SubnetInfo apacheInfo;
+
+ public IPv4SubnetInfo(Inet4Address address, int netmask) {
+ apacheInfo = new SubnetUtils(address.getHostAddress()+"/"+netmask).getInfo();
+ }
+
+ /**
+ * Return the string representation of the IP address used to initialise this subnet.
+ *
+ * @return
+ */
+ @Override
+ public String getHostAddress() {
+ return apacheInfo.getAddress();
+ }
+
+ /**
+ * Return the string representation of the IP address represented by the subnet with the netmask applied.
+ *
+ * @return
+ */
+ @Override
+ public String getNetworkAddress() {
+ return apacheInfo.getNetworkAddress();
+ }
+
+ /**
+ * Return the CIDR representation of this subnet, depending on whether it is an IPv4 or an IPv6 subnet.
+ *
+ * @return
+ */
+ @Override
+ public String getCidrSignature() {
+ return apacheInfo.getCidrSignature();
+ }
+
+ /**
+ * Return true if the IP address string representation passed as argument is in the range
+ * of the subnet represented by this SubnetInfo.
+ *
+ * @param address
+ * @return
+ */
+ @Override
+ public boolean isInRange(String address) {
+ try {
+ if(InetAddress.getByName(address) instanceof Inet4Address) {
+ return apacheInfo.isInRange(address);
+ }
+ } catch (UnknownHostException e) {}
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/IPv6SubnetInfo.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/IPv6SubnetInfo.java b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/IPv6SubnetInfo.java
new file mode 100644
index 0000000..7a6e9e5
--- /dev/null
+++ b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/IPv6SubnetInfo.java
@@ -0,0 +1,118 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.platform.security.util;
+
+import java.math.BigInteger;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * Implements IPv6 Subnets using BigInteger to perform subnet matching.
+ *
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class IPv6SubnetInfo extends SubnetInfo {
+
+ // full 128 bit representation
+ private static BigInteger allbits = new BigInteger("ffffffffffffffffffffffffffffffff",16);
+
+ private BigInteger networkNetmask;
+
+ private Inet6Address hostAddress;
+
+ private Inet6Address networkAddress;
+
+ private BigInteger networkBitmap;
+
+ private int prefixLength;
+
+ public IPv6SubnetInfo(Inet6Address address, int prefixLength) throws UnknownHostException {
+ this.hostAddress = address;
+ this.networkNetmask = allbits.shiftRight(128-prefixLength).shiftLeft(128-prefixLength);
+ this.prefixLength = prefixLength;
+
+ BigInteger inetaddr = new BigInteger(address.getAddress());
+
+ byte[] network_bytes = new byte[16];
+ byte[] intbytes = inetaddr.and(networkNetmask).toByteArray();
+ for(int i=0; i<16 && intbytes.length - i >0; i++) {
+ network_bytes[16-i-1] = intbytes[intbytes.length-i-1];
+ }
+
+ this.networkAddress = (Inet6Address) InetAddress.getByAddress(network_bytes);
+ this.networkBitmap = new BigInteger(network_bytes);
+
+ }
+
+ /**
+ * Return the string representation of the IP hostAddress represented by this subnet.
+ *
+ * @return
+ */
+ @Override
+ public String getHostAddress() {
+ return hostAddress.getHostAddress();
+ }
+
+ /**
+ * Return the string representation of the IP hostAddress represented by the subnet with the networkNetmask applied.
+ *
+ * @return
+ */
+ @Override
+ public String getNetworkAddress() {
+ return networkAddress.getHostAddress();
+ }
+
+ /**
+ * Return the CIDR representation of this subnet, depending on whether it is an IPv4 or an IPv6 subnet.
+ *
+ * @return
+ */
+ @Override
+ public String getCidrSignature() {
+ return networkAddress.getHostAddress()+"/"+prefixLength;
+ }
+
+ /**
+ * Return true if the IP hostAddress string representation passed as argument is in the range
+ * of the subnet represented by this SubnetInfo.
+ *
+ * @param address
+ * @return
+ */
+ @Override
+ public boolean isInRange(String address) {
+
+ try {
+ InetAddress otherAddress = InetAddress.getByName(address);
+
+ if(otherAddress instanceof Inet6Address) {
+ BigInteger otherAddressInt = new BigInteger(otherAddress.getAddress());
+
+ // the other hostAddress is inside the network if we can first "and" it with the networkNetmask and
+ // then an xor with the network hostAddress yields 0
+ BigInteger maskMatch = otherAddressInt.and(networkNetmask).xor(networkBitmap);
+ return maskMatch.equals(BigInteger.ZERO);
+ }
+
+ } catch (UnknownHostException e) { }
+
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/SubnetInfo.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/SubnetInfo.java b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/SubnetInfo.java
new file mode 100644
index 0000000..34211b2
--- /dev/null
+++ b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/util/SubnetInfo.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.platform.security.util;
+
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * Subnet information about an IPv4 or IPv6 subnet. Specific implementations for IPv4 and IPv6 provided by
+ * the LMF.
+ *
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public abstract class SubnetInfo {
+
+ /**
+ * Return the string representation of the IP address used to initialise this subnet.
+ *
+ * @return
+ */
+ public abstract String getHostAddress();
+
+
+ /**
+ * Return the string representation of the IP address represented by the subnet with the netmask applied.
+ * @return
+ */
+ public abstract String getNetworkAddress();
+
+
+ /**
+ * Return true if the IP address string representation passed as argument is in the range
+ * of the subnet represented by this SubnetInfo.
+ *
+ * @param address
+ * @return
+ */
+ public abstract boolean isInRange(String address);
+
+
+ /**
+ * Return the CIDR representation of this subnet, depending on whether it is an IPv4 or an IPv6 subnet.
+ *
+ * @return
+ */
+ public abstract String getCidrSignature();
+
+
+ public static SubnetInfo getSubnetInfo(InetAddress address, int netmask) throws UnknownHostException {
+ if(address instanceof Inet6Address) {
+ return new IPv6SubnetInfo((Inet6Address) address,netmask);
+ } else {
+ return new IPv4SubnetInfo((Inet4Address) address,netmask);
+ }
+ }
+
+ public static SubnetInfo getSubnetInfo(InetAddress address) throws UnknownHostException {
+ if(address instanceof Inet6Address) {
+ return getSubnetInfo(address,128);
+ } else {
+ return getSubnetInfo(address,32);
+ }
+ }
+
+
+ public static SubnetInfo getSubnetInfo(String cidrAddress) throws UnknownHostException {
+ String[] components = cidrAddress.split("/");
+
+ InetAddress address = InetAddress.getByName(components[0]);
+ int netmask = components.length > 1 ? Integer.parseInt(components[1]) : (address instanceof Inet4Address?32:128);
+ return getSubnetInfo(address,netmask);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/webservices/SecurityWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/webservices/SecurityWebService.java b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/webservices/SecurityWebService.java
new file mode 100644
index 0000000..86483b4
--- /dev/null
+++ b/platform/marmotta-security/src/main/java/org/apache/marmotta/platform/security/webservices/SecurityWebService.java
@@ -0,0 +1,111 @@
+/**
+ * Copyright (C) 2013 Salzburg Research.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.platform.security.webservices;
+
+import org.apache.marmotta.platform.security.api.SecurityService;
+import org.apache.marmotta.platform.security.model.HTTPMethods;
+import org.apache.marmotta.platform.security.model.SecurityConstraint;
+import org.apache.marmotta.platform.security.util.SubnetInfo;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.slf4j.Logger;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A webservice providing access to the security constraints currently active in the system
+ *
+ * @author Sebastian Schaffert
+ */
+@ApplicationScoped
+@Path("/security")
+public class SecurityWebService {
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private SecurityService securityService;
+
+ @Path("/constraints")
+ @GET
+ @Produces("application/json")
+ public Response listConstraints() {
+ List<Map<String,Object>> result = Lists.transform(securityService.listSecurityConstraints(), new Function<SecurityConstraint, Map<String, Object>>() {
+ @Override
+ public Map<String, Object> apply(SecurityConstraint input) {
+ return formatConstraint(input);
+ }
+ });
+
+ return Response.ok().entity(result).build();
+
+ }
+
+ @Path("/constraints/{name}")
+ @GET
+ @Produces("application/json")
+ public Response getConstraint(@PathParam("name") String name) {
+ SecurityConstraint constraint = null;
+ for(SecurityConstraint constraint1 : securityService.listSecurityConstraints()) {
+ if(constraint1.getName().equals(name)) {
+ constraint = constraint1;
+ break;
+ }
+ }
+
+ if (constraint != null)
+ return Response.ok(formatConstraint(constraint)).build();
+ else
+ return Response.status(Response.Status.NOT_FOUND).entity("constraint with name "+name+" does not exist").build();
+ }
+
+ private Map<String,Object> formatConstraint(SecurityConstraint constraint) {
+ Map<String,Object> result = new HashMap<String, Object>();
+ result.put("name",constraint.getName());
+ result.put("pattern", constraint.getUrlPattern());
+ result.put("type", constraint.getType().toString());
+
+ List<String> methods = new ArrayList<String>();
+ for(HTTPMethods method : constraint.getMethods()) {
+ methods.add(method.toString());
+ }
+ result.put("methods",methods);
+
+ List<String> hosts = new ArrayList<String>();
+ for(SubnetInfo info : constraint.getHostPatterns()) {
+ hosts.add(info.getCidrSignature());
+ }
+ result.put("hosts",hosts);
+
+ result.put("roles",new ArrayList<String>(constraint.getRoles()));
+ result.put("enabled", constraint.isEnabled() ? "true" : "false");
+ result.put("priority", constraint.getPriority());
+
+ return result;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-security/src/main/resources/kiwi-module.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-security/src/main/resources/kiwi-module.properties b/platform/marmotta-security/src/main/resources/kiwi-module.properties
index 03e7ff9..dc40548 100644
--- a/platform/marmotta-security/src/main/resources/kiwi-module.properties
+++ b/platform/marmotta-security/src/main/resources/kiwi-module.properties
@@ -22,7 +22,7 @@ subtitle = Access Control Management
icon_small = /public/img/security_small.png
-webservices=at.newmedialab.lmf.security.webservices.SecurityWebService
+webservices=org.apache.marmotta.platform.security.webservices.SecurityWebService
adminpages=/admin/about.html,/admin/configuration.html,/admin/profiles.html,/admin/rules.html
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-sparql/jooq-config.xml
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/jooq-config.xml b/platform/marmotta-sparql/jooq-config.xml
index 606b36a..17b6be7 100644
--- a/platform/marmotta-sparql/jooq-config.xml
+++ b/platform/marmotta-sparql/jooq-config.xml
@@ -78,7 +78,7 @@
<target>
<!-- The destination package of your generated classes (within the
destination directory) -->
- <packageName>at.newmedialab.lmf.sparql.model</packageName>
+ <packageName>org.apache.marmotta.platform.sparql.model</packageName>
<!-- The destination directory of your generated classes -->
<directory>/Users/sschaffe/Documents/projects/LMF/lmf-sparql/src/main/java</directory>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/api/sparql/SparqlService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/api/sparql/SparqlService.java b/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/api/sparql/SparqlService.java
deleted file mode 100644
index b52c74f..0000000
--- a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/api/sparql/SparqlService.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.newmedialab.lmf.sparql.api.sparql;
-
-import at.newmedialab.lmf.sparql.services.sparqlio.rdf.SPARQLGraphResultWriter;
-import org.apache.marmotta.platform.core.exception.InvalidArgumentException;
-import org.apache.marmotta.platform.core.exception.LMFException;
-import org.openrdf.model.Value;
-import org.openrdf.query.MalformedQueryException;
-import org.openrdf.query.QueryEvaluationException;
-import org.openrdf.query.QueryLanguage;
-import org.openrdf.query.UpdateExecutionException;
-import org.openrdf.query.resultio.BooleanQueryResultWriter;
-import org.openrdf.query.resultio.TupleQueryResultWriter;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Add file description here!
- * <p/>
- * User: sschaffe
- */
-public interface SparqlService {
-
-
- /**
- * Evaluate a SPARQL query on the LMF TripleStore. Writes the query results to the output stream passed as argument os
- * in the output format specified as argument outputFormat.
- *
- * see http://www.w3.org/TR/sparql11-query/
- *
- *
- * @param queryLanguage the query language to use
- * @param query the SPARQL query to evaluate in SPARQL 1.1 syntax
- * @param tupleWriter the writer to use to write tuple query results
- * @param booleanWriter the writer to use to write boolean query results
- * @param graphWriter
- * @throws InvalidArgumentException if the output format or query language are undefined
- * @throws org.apache.marmotta.platform.core.exception.LMFException if the query evaluation fails
- */
- public void query(QueryLanguage queryLanguage, String query, TupleQueryResultWriter tupleWriter, BooleanQueryResultWriter booleanWriter, SPARQLGraphResultWriter graphWriter) throws InvalidArgumentException, LMFException, MalformedQueryException, QueryEvaluationException;
-
-
-
- /**
- * Evaluate a SPARQL query on the LMF TripleStore. Returns the results as a list of result maps, each element
- * a KiWiNode.
- *
- * see http://www.w3.org/TR/sparql11-query/
- *
- * @param queryLanguage the query language to use
- * @param query the SPARQL query to evaluate in SPARQL 1.1 syntax
- */
- public List<Map<String,Value>> query(QueryLanguage queryLanguage, String query) throws LMFException;
-
-
- /**
- * Execute a SPARQL update on the LMF TripleStore. Throws a KiWiException in case the update execution fails.
- *
- * see http://www.w3.org/TR/sparql11-update/
- *
- * @param queryLanguage
- * @param query a string representing the update query in SPARQL Update 1.1 syntax
- * @throws Exception
- */
- public void update(QueryLanguage queryLanguage, String query) throws InvalidArgumentException, LMFException, MalformedQueryException, UpdateExecutionException;
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/Public.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/Public.java b/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/Public.java
deleted file mode 100644
index c69470e..0000000
--- a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/Public.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * This class is generated by jOOQ
- */
-package at.newmedialab.lmf.sparql.model;
-
-import at.newmedialab.lmf.sparql.model.tables.TNodes;
-import at.newmedialab.lmf.sparql.model.tables.TTriples;
-
-/**
- * This class is generated by jOOQ.
- */
-@javax.annotation.Generated(value = {"http://www.jooq.org", "2.2.0"},
- comments = "This class is generated by jOOQ")
-public class Public extends org.jooq.impl.SchemaImpl {
-
- private static final long serialVersionUID = -664253339;
-
- /**
- * The singleton instance of public
- */
- //public static final Public PUBLIC = new Public();
- public static final Public PUBLIC = null;
-
- /**
- * No further instances allowed
- */
- private Public() {
- super("public");
- }
-
- @Override
- public final java.util.List<org.jooq.Table<?>> getTables() {
- return java.util.Arrays.<org.jooq.Table<?>>asList(
- TNodes.KIWINODE,
- TTriples.TRIPLES);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/Tables.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/Tables.java b/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/Tables.java
deleted file mode 100644
index a925046..0000000
--- a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/Tables.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * This class is generated by jOOQ
- */
-package at.newmedialab.lmf.sparql.model;
-
-import at.newmedialab.lmf.sparql.model.tables.TNodes;
-import at.newmedialab.lmf.sparql.model.tables.TTriples;
-
-/**
- * This class is generated by jOOQ.
- *
- * Convenience access to all tables in public
- */
-@javax.annotation.Generated(value = {"http://www.jooq.org", "2.2.0"},
- comments = "This class is generated by jOOQ")
-public final class Tables {
-
- /**
- * The table public.kiwinode
- */
- public static TNodes KIWINODE = TNodes.KIWINODE;
-
- /**
- * The table public.triples
- */
- public static TTriples TRIPLES = TTriples.TRIPLES;
-
- /**
- * No instances
- */
- private Tables() {}
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/TNodes.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/TNodes.java b/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/TNodes.java
deleted file mode 100644
index 207a3ca..0000000
--- a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/TNodes.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * This class is generated by jOOQ
- */
-package at.newmedialab.lmf.sparql.model.tables;
-
-import at.newmedialab.lmf.sparql.model.tables.records.RNodes;
-import org.jooq.impl.SQLDataType;
-
-import java.sql.Timestamp;
-
-/**
- * This class is generated by jOOQ.
- */
-@javax.annotation.Generated(value = {"http://www.jooq.org", "2.2.0"},
- comments = "This class is generated by jOOQ")
-public class TNodes extends org.jooq.impl.TableImpl<RNodes> {
-
- private static final long serialVersionUID = 377156424;
-
- /**
- * The singleton instance of public.kiwinode
- */
- public static final TNodes KIWINODE = new TNodes();
-
- /**
- * The class holding records for this type
- */
- private static final java.lang.Class<RNodes> __RECORD_TYPE = RNodes.class;
-
- /**
- * The class holding records for this type
- */
- @Override
- public java.lang.Class<RNodes> getRecordType() {
- return __RECORD_TYPE;
- }
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.lang.String> NODETYPE = createField("nodetype", org.jooq.impl.SQLDataType.VARCHAR, this);
-
- /**
- * An uncommented item
- *
- * PRIMARY KEY
- */
- public final org.jooq.TableField<RNodes, java.lang.Long> ID = createField("id", org.jooq.impl.SQLDataType.BIGINT, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.sql.Timestamp> CREATED = createField("created", org.jooq.impl.SQLDataType.TIMESTAMP, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.lang.Boolean> DELETED = createField("deleted", org.jooq.impl.SQLDataType.BOOLEAN, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.lang.Long> VERSION = createField("version", org.jooq.impl.SQLDataType.BIGINT, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.lang.String> URI = createField("uri", org.jooq.impl.SQLDataType.VARCHAR, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.lang.String> ANONID = createField("anonid", org.jooq.impl.SQLDataType.VARCHAR, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.lang.String> CONTENTMD5 = createField("contentmd5", org.jooq.impl.SQLDataType.VARCHAR, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.lang.String> LANGUAGE = createField("language", org.jooq.impl.SQLDataType.VARCHAR, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.lang.String> TYPE = createField("type", org.jooq.impl.SQLDataType.VARCHAR, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.lang.String> CONTENT = createField("content", org.jooq.impl.SQLDataType.CLOB, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.lang.Long> INTCONTENT = createField("intcontent", org.jooq.impl.SQLDataType.BIGINT, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RNodes, java.lang.Double> DOUBLECONTENT = createField("doublecontent", org.jooq.impl.SQLDataType.DOUBLE, this);
-
-
- public final org.jooq.TableField<RNodes, Timestamp> DATECONTENT = createField("datecontent", SQLDataType.TIMESTAMP, this);
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT kiwinode__fkbbc8d71252fbdfe5
- * FOREIGN KEY (context_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public final org.jooq.TableField<RNodes, java.lang.Long> CONTEXT_ID = createField("context_id", org.jooq.impl.SQLDataType.BIGINT, this);
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT kiwinode__fkbbc8d71236cf857c
- * FOREIGN KEY (creator_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public final org.jooq.TableField<RNodes, java.lang.Long> CREATOR_ID = createField("creator_id", org.jooq.impl.SQLDataType.BIGINT, this);
-
- public TNodes() {
- super("kiwinode", at.newmedialab.lmf.sparql.model.Public.PUBLIC);
- }
-
- public TNodes(java.lang.String alias) {
- super(alias, at.newmedialab.lmf.sparql.model.Public.PUBLIC, TNodes.KIWINODE);
- }
-
- @Override
- public TNodes as(java.lang.String alias) {
- return new TNodes(alias);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/TTriples.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/TTriples.java b/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/TTriples.java
deleted file mode 100644
index 42c7007..0000000
--- a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/TTriples.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * This class is generated by jOOQ
- */
-package at.newmedialab.lmf.sparql.model.tables;
-
-import at.newmedialab.lmf.sparql.model.tables.records.RTriples;
-
-/**
- * This class is generated by jOOQ.
- */
-@javax.annotation.Generated(value = {"http://www.jooq.org", "2.2.0"},
- comments = "This class is generated by jOOQ")
-public class TTriples extends org.jooq.impl.TableImpl<RTriples> {
-
- private static final long serialVersionUID = 1665365091;
-
- /**
- * The singleton instance of public.triples
- */
- public static final TTriples TRIPLES = new TTriples();
-
- /**
- * The class holding records for this type
- */
- private static final java.lang.Class<RTriples> __RECORD_TYPE = RTriples.class;
-
- /**
- * The class holding records for this type
- */
- @Override
- public java.lang.Class<RTriples> getRecordType() {
- return __RECORD_TYPE;
- }
-
- /**
- * An uncommented item
- *
- * PRIMARY KEY
- */
- public final org.jooq.TableField<RTriples, java.lang.Long> ID = createField("id", org.jooq.impl.SQLDataType.BIGINT, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RTriples, java.sql.Timestamp> CREATED = createField("created", org.jooq.impl.SQLDataType.TIMESTAMP, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RTriples, java.lang.Boolean> DELETED = createField("deleted", org.jooq.impl.SQLDataType.BOOLEAN, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RTriples, java.sql.Timestamp> DELETEDAT = createField("deletedat", org.jooq.impl.SQLDataType.TIMESTAMP, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RTriples, java.lang.Boolean> INFERRED = createField("inferred", org.jooq.impl.SQLDataType.BOOLEAN, this);
-
- /**
- * An uncommented item
- */
- public final org.jooq.TableField<RTriples, java.lang.Long> VERSION = createField("version", org.jooq.impl.SQLDataType.BIGINT, this);
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb552fbdfe5
- * FOREIGN KEY (context_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public final org.jooq.TableField<RTriples, java.lang.Long> CONTEXT_ID = createField("context_id", org.jooq.impl.SQLDataType.BIGINT, this);
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb536cf857c
- * FOREIGN KEY (creator_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public final org.jooq.TableField<RTriples, java.lang.Long> CREATOR_ID = createField("creator_id", org.jooq.impl.SQLDataType.BIGINT, this);
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb5d2e5bf7d
- * FOREIGN KEY (object_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public final org.jooq.TableField<RTriples, java.lang.Long> OBJECT_ID = createField("object_id", org.jooq.impl.SQLDataType.BIGINT, this);
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb593957dff
- * FOREIGN KEY (property_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public final org.jooq.TableField<RTriples, java.lang.Long> PROPERTY_ID = createField("predicate_id", org.jooq.impl.SQLDataType.BIGINT, this);
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb5c267907c
- * FOREIGN KEY (subject_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public final org.jooq.TableField<RTriples, java.lang.Long> SUBJECT_ID = createField("subject_id", org.jooq.impl.SQLDataType.BIGINT, this);
-
- public TTriples() {
- super("triples", at.newmedialab.lmf.sparql.model.Public.PUBLIC);
- }
-
- public TTriples(java.lang.String alias) {
- super(alias, at.newmedialab.lmf.sparql.model.Public.PUBLIC, TTriples.TRIPLES);
- }
-
- @Override
- public TTriples as(java.lang.String alias) {
- return new TTriples(alias);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/records/RNodes.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/records/RNodes.java b/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/records/RNodes.java
deleted file mode 100644
index 6588054..0000000
--- a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/records/RNodes.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * This class is generated by jOOQ
- */
-package at.newmedialab.lmf.sparql.model.tables.records;
-
-import at.newmedialab.lmf.sparql.model.tables.TNodes;
-
-/**
- * This class is generated by jOOQ.
- */
-@javax.annotation.Generated(value = {"http://www.jooq.org", "2.2.0"},
- comments = "This class is generated by jOOQ")
-public class RNodes extends org.jooq.impl.TableRecordImpl<RNodes> {
-
- private static final long serialVersionUID = 1708898505;
-
- /**
- * An uncommented item
- */
- public void setNodetype(java.lang.String value) {
- setValue(TNodes.KIWINODE.NODETYPE, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.String getNodetype() {
- return getValue(TNodes.KIWINODE.NODETYPE);
- }
-
- /**
- * An uncommented item
- *
- * PRIMARY KEY
- */
- public void setId(java.lang.Long value) {
- setValue(TNodes.KIWINODE.ID, value);
- }
-
- /**
- * An uncommented item
- *
- * PRIMARY KEY
- */
- public java.lang.Long getId() {
- return getValue(TNodes.KIWINODE.ID);
- }
-
- /**
- * An uncommented item
- */
- public void setCreated(java.sql.Timestamp value) {
- setValue(TNodes.KIWINODE.CREATED, value);
- }
-
- /**
- * An uncommented item
- */
- public java.sql.Timestamp getCreated() {
- return getValue(TNodes.KIWINODE.CREATED);
- }
-
- /**
- * An uncommented item
- */
- public void setDeleted(java.lang.Boolean value) {
- setValue(TNodes.KIWINODE.DELETED, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.Boolean getDeleted() {
- return getValue(TNodes.KIWINODE.DELETED);
- }
-
- /**
- * An uncommented item
- */
- public void setVersion(java.lang.Long value) {
- setValue(TNodes.KIWINODE.VERSION, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.Long getVersion() {
- return getValue(TNodes.KIWINODE.VERSION);
- }
-
- /**
- * An uncommented item
- */
- public void setUri(java.lang.String value) {
- setValue(TNodes.KIWINODE.URI, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.String getUri() {
- return getValue(TNodes.KIWINODE.URI);
- }
-
- /**
- * An uncommented item
- */
- public void setAnonid(java.lang.String value) {
- setValue(TNodes.KIWINODE.ANONID, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.String getAnonid() {
- return getValue(TNodes.KIWINODE.ANONID);
- }
-
- /**
- * An uncommented item
- */
- public void setContentmd5(java.lang.String value) {
- setValue(TNodes.KIWINODE.CONTENTMD5, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.String getContentmd5() {
- return getValue(TNodes.KIWINODE.CONTENTMD5);
- }
-
- /**
- * An uncommented item
- */
- public void setLanguage(java.lang.String value) {
- setValue(TNodes.KIWINODE.LANGUAGE, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.String getLanguage() {
- return getValue(TNodes.KIWINODE.LANGUAGE);
- }
-
- /**
- * An uncommented item
- */
- public void setType(java.lang.String value) {
- setValue(TNodes.KIWINODE.TYPE, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.String getType() {
- return getValue(TNodes.KIWINODE.TYPE);
- }
-
- /**
- * An uncommented item
- */
- public void setContent(java.lang.String value) {
- setValue(TNodes.KIWINODE.CONTENT, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.String getContent() {
- return getValue(TNodes.KIWINODE.CONTENT);
- }
-
- /**
- * An uncommented item
- */
- public void setIntcontent(java.lang.Long value) {
- setValue(TNodes.KIWINODE.INTCONTENT, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.Long getIntcontent() {
- return getValue(TNodes.KIWINODE.INTCONTENT);
- }
-
- /**
- * An uncommented item
- */
- public void setDoublecontent(java.lang.Double value) {
- setValue(TNodes.KIWINODE.DOUBLECONTENT, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.Double getDoublecontent() {
- return getValue(TNodes.KIWINODE.DOUBLECONTENT);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT kiwinode__fkbbc8d71252fbdfe5
- * FOREIGN KEY (context_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public void setContextId(java.lang.Long value) {
- setValue(TNodes.KIWINODE.CONTEXT_ID, value);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT kiwinode__fkbbc8d71252fbdfe5
- * FOREIGN KEY (context_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public java.lang.Long getContextId() {
- return getValue(TNodes.KIWINODE.CONTEXT_ID);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT kiwinode__fkbbc8d71236cf857c
- * FOREIGN KEY (creator_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public void setCreatorId(java.lang.Long value) {
- setValue(TNodes.KIWINODE.CREATOR_ID, value);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT kiwinode__fkbbc8d71236cf857c
- * FOREIGN KEY (creator_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public java.lang.Long getCreatorId() {
- return getValue(TNodes.KIWINODE.CREATOR_ID);
- }
-
- /**
- * Create a detached KiwinodeRecord
- */
- public RNodes() {
- super(TNodes.KIWINODE);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/records/RTriples.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/records/RTriples.java b/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/records/RTriples.java
deleted file mode 100644
index ec5053f..0000000
--- a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/model/tables/records/RTriples.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * This class is generated by jOOQ
- */
-package at.newmedialab.lmf.sparql.model.tables.records;
-
-import at.newmedialab.lmf.sparql.model.tables.TTriples;
-
-/**
- * This class is generated by jOOQ.
- */
-@javax.annotation.Generated(value = {"http://www.jooq.org", "2.2.0"},
- comments = "This class is generated by jOOQ")
-public class RTriples extends org.jooq.impl.TableRecordImpl<RTriples> {
-
- private static final long serialVersionUID = 971957447;
-
- /**
- * An uncommented item
- *
- * PRIMARY KEY
- */
- public void setId(java.lang.Long value) {
- setValue(TTriples.TRIPLES.ID, value);
- }
-
- /**
- * An uncommented item
- *
- * PRIMARY KEY
- */
- public java.lang.Long getId() {
- return getValue(TTriples.TRIPLES.ID);
- }
-
- /**
- * An uncommented item
- */
- public void setCreated(java.sql.Timestamp value) {
- setValue(TTriples.TRIPLES.CREATED, value);
- }
-
- /**
- * An uncommented item
- */
- public java.sql.Timestamp getCreated() {
- return getValue(TTriples.TRIPLES.CREATED);
- }
-
- /**
- * An uncommented item
- */
- public void setDeleted(java.lang.Boolean value) {
- setValue(TTriples.TRIPLES.DELETED, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.Boolean getDeleted() {
- return getValue(TTriples.TRIPLES.DELETED);
- }
-
- /**
- * An uncommented item
- */
- public void setDeletedat(java.sql.Timestamp value) {
- setValue(TTriples.TRIPLES.DELETEDAT, value);
- }
-
- /**
- * An uncommented item
- */
- public java.sql.Timestamp getDeletedat() {
- return getValue(TTriples.TRIPLES.DELETEDAT);
- }
-
- /**
- * An uncommented item
- */
- public void setInferred(java.lang.Boolean value) {
- setValue(TTriples.TRIPLES.INFERRED, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.Boolean getInferred() {
- return getValue(TTriples.TRIPLES.INFERRED);
- }
-
- /**
- * An uncommented item
- */
- public void setVersion(java.lang.Long value) {
- setValue(TTriples.TRIPLES.VERSION, value);
- }
-
- /**
- * An uncommented item
- */
- public java.lang.Long getVersion() {
- return getValue(TTriples.TRIPLES.VERSION);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb552fbdfe5
- * FOREIGN KEY (context_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public void setContextId(java.lang.Long value) {
- setValue(TTriples.TRIPLES.CONTEXT_ID, value);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb552fbdfe5
- * FOREIGN KEY (context_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public java.lang.Long getContextId() {
- return getValue(TTriples.TRIPLES.CONTEXT_ID);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb536cf857c
- * FOREIGN KEY (creator_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public void setCreatorId(java.lang.Long value) {
- setValue(TTriples.TRIPLES.CREATOR_ID, value);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb536cf857c
- * FOREIGN KEY (creator_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public java.lang.Long getCreatorId() {
- return getValue(TTriples.TRIPLES.CREATOR_ID);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb5d2e5bf7d
- * FOREIGN KEY (object_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public void setObjectId(java.lang.Long value) {
- setValue(TTriples.TRIPLES.OBJECT_ID, value);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb5d2e5bf7d
- * FOREIGN KEY (object_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public java.lang.Long getObjectId() {
- return getValue(TTriples.TRIPLES.OBJECT_ID);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb593957dff
- * FOREIGN KEY (property_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public void setPropertyId(java.lang.Long value) {
- setValue(TTriples.TRIPLES.PROPERTY_ID, value);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb593957dff
- * FOREIGN KEY (property_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public java.lang.Long getPropertyId() {
- return getValue(TTriples.TRIPLES.PROPERTY_ID);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb5c267907c
- * FOREIGN KEY (subject_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public void setSubjectId(java.lang.Long value) {
- setValue(TTriples.TRIPLES.SUBJECT_ID, value);
- }
-
- /**
- * An uncommented item
- * <p>
- * <code><pre>
- * CONSTRAINT triples__fkeba30bb5c267907c
- * FOREIGN KEY (subject_id)
- * REFERENCES public.kiwinode (id)
- * </pre></code>
- */
- public java.lang.Long getSubjectId() {
- return getValue(TTriples.TRIPLES.SUBJECT_ID);
- }
-
- /**
- * Create a detached TriplesRecord
- */
- public RTriples() {
- super(TTriples.TRIPLES);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/services/sparql/SparqlServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/services/sparql/SparqlServiceImpl.java b/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/services/sparql/SparqlServiceImpl.java
deleted file mode 100644
index 6498079..0000000
--- a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/services/sparql/SparqlServiceImpl.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.newmedialab.lmf.sparql.services.sparql;
-
-import at.newmedialab.lmf.sparql.api.sparql.SparqlService;
-import at.newmedialab.lmf.sparql.services.sparqlio.rdf.SPARQLGraphResultWriter;
-import org.apache.marmotta.platform.core.api.config.ConfigurationService;
-import org.apache.marmotta.platform.core.api.triplestore.SesameService;
-import org.apache.marmotta.platform.core.exception.InvalidArgumentException;
-import org.apache.marmotta.platform.core.exception.LMFException;
-import org.apache.marmotta.kiwi.model.rdf.KiWiNode;
-import org.openrdf.model.Value;
-import org.openrdf.query.*;
-import org.openrdf.query.resultio.BooleanQueryResultWriter;
-import org.openrdf.query.resultio.TupleQueryResultWriter;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.slf4j.Logger;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-
-/**
- * Add file description here!
- * <p/>
- * User: sschaffe
- */
-@Named("kiwi.core.query.sparqlService")
-@ApplicationScoped
-public class SparqlServiceImpl implements SparqlService {
-
-
- /**
- * Get the seam logger for issuing logging statements.
- */
- @Inject
- private Logger log;
-
- @Inject
- private ConfigurationService configurationService;
-
- @Inject
- private SesameService sesameService;
-
-
- @Override
- public void query(QueryLanguage queryLanguage, String query, TupleQueryResultWriter tupleWriter, BooleanQueryResultWriter booleanWriter, SPARQLGraphResultWriter graphWriter) throws LMFException, MalformedQueryException, QueryEvaluationException {
- long start = System.currentTimeMillis();
-
- log.debug("executing SPARQL query:\n{}", query);
-
- try {
- RepositoryConnection connection = sesameService.getConnection();
- try {
- connection.begin();
- Query sparqlQuery = connection.prepareQuery(queryLanguage, query);
-
- if (sparqlQuery instanceof TupleQuery) {
- TupleQuery tupleQuery = (TupleQuery) sparqlQuery;
- tupleQuery.evaluate(tupleWriter);
- } else if (sparqlQuery instanceof BooleanQuery) {
- BooleanQuery booleanQuery = (BooleanQuery) sparqlQuery;
- booleanWriter.write(booleanQuery.evaluate());
- } else if (sparqlQuery instanceof GraphQuery) {
- GraphQuery graphQuery = (GraphQuery) sparqlQuery;
- graphWriter.write(graphQuery.evaluate());
- } else {
- connection.rollback();
- throw new InvalidArgumentException("SPARQL query type " + sparqlQuery.getClass() + " not supported!");
- }
-
- connection.commit();
- } finally {
- connection.close();
- }
- } catch(RepositoryException ex) {
- log.error("error while getting repository connection");
- throw new LMFException("error while getting repository connection",ex);
- } catch (TupleQueryResultHandlerException e) {
- throw new LMFException("error while writing query result in format ",e);
- } catch (IOException e) {
- throw new LMFException("error while writing query result in format ",e);
- }
-
- log.debug("SPARQL execution took {}ms",System.currentTimeMillis()-start);
- }
-
-
-
- private static Pattern subTypePattern = Pattern.compile("[a-z]+/([a-z0-9-._]+\\+)?([a-z0-9-._]+)(;.*)?");
- private String parseSubType(String mimeType) {
- Matcher matcher = subTypePattern.matcher(mimeType);
- if(matcher.matches()) return matcher.group(2);
- else
- return mimeType;
- }
-
-
-
- /**
- * Evaluate a SPARQL query on the LMF TripleStore. Returns the results as a list of result maps, each element
- * a KiWiNode.
- * <p/>
- * see http://www.w3.org/TR/sparql11-query/
- *
- * @param queryLanguage the query language to use
- * @param query the SPARQL query to evaluate in SPARQL 1.1 syntax
- */
- @Override
- public List<Map<String, Value>> query(QueryLanguage queryLanguage, String query) throws LMFException {
- long start = System.currentTimeMillis();
-
- log.debug("executing {} query:\n{}", queryLanguage.getName(), query);
-
- List<Map<String,Value>> result = new LinkedList<Map<String, Value>>();
-
- try {
- RepositoryConnection connection = sesameService.getConnection();
- try {
- connection.begin();
- TupleQuery tupleQuery = connection.prepareTupleQuery(queryLanguage, query);
- TupleQueryResult r = tupleQuery.evaluate();
- try {
- while (r.hasNext()) {
- BindingSet s = r.next();
- Map<String, Value> map = new HashMap<String, Value>();
- for (Binding binding : s) {
- if (binding.getValue() instanceof KiWiNode) {
- map.put(binding.getName(), binding.getValue());
- } else {
- log.error("binding value {} is not a KiWiNode!", binding.getValue());
- }
- }
- result.add(map);
- }
- } finally {
- r.close();
- }
- //
- connection.commit();
- } finally {
- connection.close();
- }
- } catch(RepositoryException ex) {
- log.error("error while getting repository connection");
- throw new LMFException("error while getting repository connection",ex);
- } catch (QueryEvaluationException e) {
- throw new LMFException("error while evaluating SPARQL query "+query,e);
- } catch (MalformedQueryException e) {
- throw new InvalidArgumentException("malformed SPARQL query ("+query+") for language "+queryLanguage,e);
- }
-
- log.debug("SPARQL execution took {}ms",System.currentTimeMillis()-start);
- return result;
- }
-
- /**
- * Execute a SPARQL update on the LMF TripleStore. Throws a KiWiException in case the update execution fails.
- * <p/>
- * see http://www.w3.org/TR/sparql11-update/
- *
- * @param queryLanguage
- * @param query a string representing the update query in SPARQL Update 1.1 syntax
- * @throws Exception
- */
- @Override
- public void update(QueryLanguage queryLanguage, String query) throws LMFException {
- long start = System.currentTimeMillis();
-
- log.debug("executing SPARQL update:\n{}", query);
-
- try {
- RepositoryConnection connection = sesameService.getConnection();
- try {
- connection.begin();
- Update update = connection.prepareUpdate(queryLanguage,query,configurationService.getBaseUri());
- update.execute();
- connection.commit();
- } catch (UpdateExecutionException e) {
- connection.rollback();
- throw new LMFException("error while executing update",e);
- } catch (MalformedQueryException e) {
- connection.rollback();
- throw new LMFException("malformed query, update failed",e);
- } finally {
- connection.close();
- }
- } catch(RepositoryException ex) {
- log.error("error while getting repository connection", ex);
- throw new LMFException("error while getting repository connection",ex);
- }
- log.debug("SPARQL update execution took {}ms",System.currentTimeMillis()-start);
-
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/69cbd57a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/services/sparqlio/rdf/SPARQLGraphResultWriter.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/services/sparqlio/rdf/SPARQLGraphResultWriter.java b/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/services/sparqlio/rdf/SPARQLGraphResultWriter.java
deleted file mode 100644
index 45d881b..0000000
--- a/platform/marmotta-sparql/src/main/java/at/newmedialab/lmf/sparql/services/sparqlio/rdf/SPARQLGraphResultWriter.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Copyright (C) 2013 Salzburg Research.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.newmedialab.lmf.sparql.services.sparqlio.rdf;
-
-import org.openrdf.query.GraphQueryResult;
-import org.openrdf.query.QueryEvaluationException;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.rio.RDFFormat;
-import org.openrdf.rio.RDFHandlerException;
-import org.openrdf.rio.RDFWriter;
-import org.openrdf.rio.Rio;
-import org.openrdf.sail.memory.MemoryStore;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Map;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class SPARQLGraphResultWriter {
-
-
- private OutputStream outputStream;
-
-
- private RDFFormat format;
-
-
- public SPARQLGraphResultWriter(OutputStream outputStream) {
- this.outputStream = outputStream;
- format = RDFFormat.RDFXML;
- }
-
- public SPARQLGraphResultWriter(OutputStream outputStream, String mimeType) {
- this.outputStream = outputStream;
- this.format = RDFFormat.forMIMEType(mimeType, RDFFormat.RDFXML);
- }
-
-
- public void write(GraphQueryResult result) throws IOException {
- Repository repository = new SailRepository(new MemoryStore());
- try {
- repository.initialize();
-
- RepositoryConnection con = repository.getConnection();
- for(Map.Entry<String,String> namespace : result.getNamespaces().entrySet()) {
- con.setNamespace(namespace.getKey(),namespace.getValue());
- }
-
- while(result.hasNext()) {
- con.add(result.next());
- }
- con.commit();
-
- RDFWriter writer = Rio.createWriter(format,outputStream);
- con.export(writer);
- con.close();
- repository.shutDown();
-
- outputStream.flush();
- outputStream.close();
-
- } catch (RepositoryException e) {
- throw new IOException("query result writing failed because there was an error while creating temporary triple store",e);
- } catch (QueryEvaluationException e) {
- throw new IOException("query result writing failed because query evaluation had a problem",e);
- } catch (RDFHandlerException e) {
- throw new IOException("query result writing failed because writer could not handle rdf data",e);
- }
-
-
- }
-}