Repository: marmotta Updated Branches: refs/heads/develop e21293a29 -> 7160bd1c1
more code hygiene, clean up redundant or unnecessary code Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/7160bd1c Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/7160bd1c Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/7160bd1c Branch: refs/heads/develop Commit: 7160bd1c155375681feb46d9aaa99ae59854aae8 Parents: e21293a Author: Sebastian Schaffert <[email protected]> Authored: Sun Nov 20 13:19:09 2016 +0100 Committer: Sebastian Schaffert <[email protected]> Committed: Sun Nov 20 13:19:09 2016 +0100 ---------------------------------------------------------------------- .../main/resources/web/admin/configuration.html | 2 +- .../services/kiwi/FileLDCacheSailProvider.java | 12 ++--- .../core/filters/ModuleResourceFilter.java | 9 +--- .../platform/core/filters/TemplatingFilter.java | 2 +- .../config/ConfigurationServiceImpl.java | 48 ++++++-------------- .../services/content/ContentServiceImpl.java | 2 +- .../services/modules/ModuleServiceImpl.java | 2 +- .../sesame/ResourceSubjectMetadata.java | 4 +- .../core/services/ssl/SSLServiceImpl.java | 2 +- .../services/task/TaskManagerServiceImpl.java | 2 - .../triplestore/ContextServiceImpl.java | 19 ++++---- .../core/servlet/MarmottaResourceFilter.java | 2 +- .../core/webservices/CoreApplication.java | 2 +- .../config/ConfigurationWebService.java | 3 -- .../webservices/modules/ModuleWebService.java | 2 +- .../webservices/resource/ContentWebService.java | 2 +- .../webservices/resource/MetaWebService.java | 2 +- .../src/main/resources/web/admin/export.html | 16 ++++--- .../resources/web/admin/js/widgets/system.js | 4 +- .../resources/web/public/style/blue/rdfhtml.css | 2 - .../resources/web/public/style/red/rdfhtml.css | 2 - .../services/sparql/SparqlServiceImpl.java | 24 ++++------ .../sparqlio/sparqlhtml/SPARQLHTMLSettings.java | 4 +- .../sparqlhtml/SPARQLResultsHTMLWriter.java | 23 ++++------ .../sparqlhtml/SPARQLResultsHTMLWriterXSL.java | 15 ++---- .../sparql/webservices/SparqlWebService.java | 11 ++--- .../main/resources/web/admin/configuration.html | 2 +- .../main/resources/web/admin/configuration.js | 2 +- 28 files changed, 80 insertions(+), 142 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/backends/marmotta-backend-kiwi/src/main/resources/web/admin/configuration.html ---------------------------------------------------------------------- diff --git a/platform/backends/marmotta-backend-kiwi/src/main/resources/web/admin/configuration.html b/platform/backends/marmotta-backend-kiwi/src/main/resources/web/admin/configuration.html index 0b36d1c..49f67a6 100644 --- a/platform/backends/marmotta-backend-kiwi/src/main/resources/web/admin/configuration.html +++ b/platform/backends/marmotta-backend-kiwi/src/main/resources/web/admin/configuration.html @@ -29,7 +29,7 @@ container : "kiwi_configurator", prefix : 'database', blacklist: ['database.type','database.url','database.user','database.password','database.h2.','database.postgres.','database.mysql.'] - } + }; var configurator = new Configurator(options); }); </script> http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java ---------------------------------------------------------------------- diff --git a/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java b/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java index 02066d3..d4c612e 100644 --- a/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java +++ b/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java @@ -27,7 +27,6 @@ import org.apache.marmotta.ldclient.api.ldclient.LDClientService; import org.apache.marmotta.platform.core.model.filter.MarmottaLocalFilter; import org.apache.marmotta.platform.ldcache.api.ldcache.LDCacheSailProvider; import org.openrdf.model.Resource; -import org.openrdf.repository.RepositoryException; import org.openrdf.sail.NotifyingSail; import org.openrdf.sail.helpers.NotifyingSailWrapper; import org.slf4j.Logger; @@ -84,14 +83,9 @@ public class FileLDCacheSailProvider extends LDCacheSailProvider { directory = new File(configurationService.getHome() + File.separator + "ldcache"); - try { - backend = new LDCachingFileBackend(directory); - sail = new GenericLinkedDataSail(parent, backend, new NotFilter<Resource>(cacheFilters), ldclientConfig); - return sail; - } catch (RepositoryException e) { - log.error("could not initialize LDCache file backend",e); - return null; - } + backend = new LDCachingFileBackend(directory); + sail = new GenericLinkedDataSail(parent, backend, new NotFilter<Resource>(cacheFilters), ldclientConfig); + return sail; } http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/ModuleResourceFilter.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/ModuleResourceFilter.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/ModuleResourceFilter.java index 4513079..4128905 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/ModuleResourceFilter.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/ModuleResourceFilter.java @@ -21,16 +21,11 @@ import org.apache.marmotta.platform.core.api.config.ConfigurationService; import org.apache.marmotta.platform.core.api.modules.MarmottaHttpFilter; import org.apache.marmotta.platform.core.api.modules.MarmottaResourceService; import org.apache.marmotta.platform.core.api.modules.ResourceEntry; -import org.jboss.resteasy.spi.BadRequestException; import org.slf4j.Logger; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -110,7 +105,7 @@ public class ModuleResourceFilter implements MarmottaHttpFilter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { URL url = null; - String prefix = null, path = null; + String prefix, path = null; if (request instanceof HttpServletRequest) { url = new URL(((HttpServletRequest)request).getRequestURL().toString()); prefix = ((HttpServletRequest)request).getContextPath(); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/TemplatingFilter.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/TemplatingFilter.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/TemplatingFilter.java index a84d153..5fbaf13 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/TemplatingFilter.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/TemplatingFilter.java @@ -115,7 +115,7 @@ public class TemplatingFilter implements MarmottaHttpFilter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { URL url = null; - String prefix = null, path = null; + String prefix, path = null; if (request instanceof HttpServletRequest) { url = new URL(((HttpServletRequest)request).getRequestURL().toString()); prefix = ((HttpServletRequest)request).getContextPath(); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java index 69db839..ef8aa0d 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java @@ -192,24 +192,24 @@ public class ConfigurationServiceImpl implements ConfigurationService { if (getHome() != null) { File f1 = new File(getHome()); if (!f1.exists()) { - f1.mkdirs(); + Preconditions.checkState(f1.mkdirs(), "could not create directory "+f1); } // ensure directory for user configuration files File f2 = new File(getHome() + File.separator + DIR_CONFIG); if(!f2.exists()) { - f2.mkdirs(); + Preconditions.checkState(f2.mkdirs(), "could not create directory "+f2); } // ensure directory for logging messages File f3 = new File(getHome() + File.separator + DIR_LOG); if(!f3.exists()) { - f3.mkdirs(); + Preconditions.checkState(f3.mkdirs(), "could not create directory "+f3); } // ensure directory for importing data File f4 = new File(getHome() + File.separator + DIR_IMPORT); if(!f4.exists()) { - f4.mkdirs(); + Preconditions.checkState(f4.mkdirs(), "could not create directory "+f4); } } @@ -667,13 +667,9 @@ public class ConfigurationServiceImpl implements ConfigurationService { lock.readLock().lock(); try { - if (config instanceof AbstractConfiguration) { - ((AbstractConfiguration) config).setDelimiterParsingDisabled(true); - } + config.setDelimiterParsingDisabled(true); String result = config.getString(key); - if (config instanceof AbstractConfiguration) { - ((AbstractConfiguration) config).setDelimiterParsingDisabled(false); - } + config.setDelimiterParsingDisabled(false); return result; } finally { lock.readLock().unlock(); @@ -687,13 +683,9 @@ public class ConfigurationServiceImpl implements ConfigurationService { lock.readLock().lock(); try { - if (config instanceof AbstractConfiguration) { - ((AbstractConfiguration) config).setDelimiterParsingDisabled(true); - } + config.setDelimiterParsingDisabled(true); String result = config.getString(key, defaultValue); - if (config instanceof AbstractConfiguration) { - ((AbstractConfiguration) config).setDelimiterParsingDisabled(false); - } + config.setDelimiterParsingDisabled(false); return result; } finally { lock.readLock().unlock(); @@ -1048,13 +1040,9 @@ public class ConfigurationServiceImpl implements ConfigurationService { lock.writeLock().lock(); try { - if (config instanceof AbstractConfiguration) { - ((AbstractConfiguration) config).setDelimiterParsingDisabled(true); - } + config.setDelimiterParsingDisabled(true); config.setProperty(key, value); - if (config instanceof AbstractConfiguration) { - ((AbstractConfiguration) config).setDelimiterParsingDisabled(false); - } + config.setDelimiterParsingDisabled(false); save(); } finally { lock.writeLock().unlock(); @@ -1082,13 +1070,9 @@ public class ConfigurationServiceImpl implements ConfigurationService { lock.writeLock().lock(); try { - if (config instanceof AbstractConfiguration) { - ((AbstractConfiguration) config).setDelimiterParsingDisabled(true); - } + config.setDelimiterParsingDisabled(true); config.setProperty(key, value); - if (config instanceof AbstractConfiguration) { - ((AbstractConfiguration) config).setDelimiterParsingDisabled(false); - } + config.setDelimiterParsingDisabled(false); save(); } finally { lock.writeLock().unlock(); @@ -1104,15 +1088,11 @@ public class ConfigurationServiceImpl implements ConfigurationService { lock.writeLock().lock(); try { - if (config instanceof AbstractConfiguration) { - ((AbstractConfiguration) config).setDelimiterParsingDisabled(true); - } + config.setDelimiterParsingDisabled(true); for (Map.Entry<String, ?> entry : values.entrySet()) { config.setProperty(entry.getKey(), entry.getValue()); } - if (config instanceof AbstractConfiguration) { - ((AbstractConfiguration) config).setDelimiterParsingDisabled(false); - } + config.setDelimiterParsingDisabled(false); save(); } finally { lock.writeLock().unlock(); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/ContentServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/ContentServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/ContentServiceImpl.java index dc9d2a7..f47ef82 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/ContentServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/ContentServiceImpl.java @@ -103,7 +103,7 @@ public class ContentServiceImpl implements ContentService { log.debug("Initializing content provider {}", configName); ContentReader reader = null; ContentWriter writer = null; - Pattern pattern = null; + Pattern pattern; if(readerClass != null) { for(ContentReader r : readers) { if(r.getClass().getCanonicalName().startsWith(readerClass)) { http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/ModuleServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/ModuleServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/ModuleServiceImpl.java index e43c890..7f6b6d6 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/ModuleServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/modules/ModuleServiceImpl.java @@ -75,7 +75,7 @@ public class ModuleServiceImpl implements ModuleService { while(modulePropertiesEnum.hasMoreElements()) { URL moduleUrl = modulePropertiesEnum.nextElement(); - Configuration moduleProperties = null; + Configuration moduleProperties; try { Set<Configuration> configurations = new HashSet<>(); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/ResourceSubjectMetadata.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/ResourceSubjectMetadata.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/ResourceSubjectMetadata.java index 38f762f..56e4f01 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/ResourceSubjectMetadata.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/ResourceSubjectMetadata.java @@ -39,7 +39,7 @@ public class ResourceSubjectMetadata extends RepositoryConnectionInterceptorAdap @Override public boolean add(RepositoryConnection conn, Resource s, org.openrdf.model.URI p, Value o, Resource... contexts) { - boolean denyAdd = true; + boolean denyAdd; if (s instanceof org.openrdf.model.URI && subject instanceof org.openrdf.model.URI ) { // if s is a URI and subject a KiWiUriResource, return // true if they are different @@ -58,7 +58,7 @@ public class ResourceSubjectMetadata extends RepositoryConnectionInterceptorAdap @Override public boolean remove(RepositoryConnection conn, Resource s, org.openrdf.model.URI p, Value o, Resource... contexts) { - boolean denyRemove = true; + boolean denyRemove; if (s instanceof org.openrdf.model.URI && subject instanceof org.openrdf.model.URI ) { // if s is a URI and subject a KiWiUriResource, return // true if they are different http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/ssl/SSLServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/ssl/SSLServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/ssl/SSLServiceImpl.java index 81e301a..0f7e4f4 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/ssl/SSLServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/ssl/SSLServiceImpl.java @@ -59,7 +59,7 @@ public class SSLServiceImpl implements SSLService { private void initSSLconfiguration() { log.info("SETUP: initialising SSL configuration ..."); /* Nervige SSL configuration */ - SSLContext ctx = null; + SSLContext ctx; try { ctx = SSLContext.getInstance("TLS"); ctx.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom()); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/task/TaskManagerServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/task/TaskManagerServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/task/TaskManagerServiceImpl.java index 30ff4d8..006866f 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/task/TaskManagerServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/task/TaskManagerServiceImpl.java @@ -230,10 +230,8 @@ public class TaskManagerServiceImpl implements TaskManagerService { for (Thread t : dead) { log.debug("Watchdog: cleaning up dead thread {}", t.getName()); tasks.remove(t); - t = null; } dead.clear(); - dead = null; task.updateMessage("sleeping"); synchronized (ThreadWatchdog.this) { this.wait(millis); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java index 3b34f4e..5b12265 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java @@ -27,7 +27,6 @@ import org.apache.marmotta.platform.core.api.importer.ImportService; import org.apache.marmotta.platform.core.api.triplestore.ContextService; import org.apache.marmotta.platform.core.api.triplestore.SesameService; import org.apache.marmotta.platform.core.api.user.UserService; -import org.apache.marmotta.platform.core.exception.InvalidArgumentException; import org.apache.marmotta.platform.core.exception.io.MarmottaImportException; import org.apache.marmotta.platform.core.qualifiers.kspace.ActiveKnowledgeSpaces; import org.apache.marmotta.platform.core.qualifiers.kspace.DefaultKnowledgeSpace; @@ -116,19 +115,17 @@ public class ContextServiceImpl implements ContextService { public List<URI> listContexts(boolean filter) { //TODO: configuration final Set<URI> contexts = listContextsSesame(); - //final Set<URI> contexts = listContextsSparql(); - if (filter) { - Collections2.filter(contexts, new Predicate<URI>() { - @Override - public boolean apply(URI uri) { - return uri.stringValue().startsWith(configurationService.getBaseContext()); - } - }); + if (!filter) { + return new ArrayList<>(contexts); } - return new ArrayList<>(contexts); - + return new ArrayList<>(Collections2.filter(contexts, new Predicate<URI>() { + @Override + public boolean apply(URI uri) { + return uri.stringValue().startsWith(configurationService.getBaseContext()); + } + })); } /** http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaResourceFilter.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaResourceFilter.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaResourceFilter.java index eed3381..3967d67 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaResourceFilter.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaResourceFilter.java @@ -110,7 +110,7 @@ public class MarmottaResourceFilter implements Filter { */ @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - URL url = null; + URL url; String prefix, path = null; if (request instanceof HttpServletRequest) { url = new URL(((HttpServletRequest)request).getRequestURL().toString()); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/CoreApplication.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/CoreApplication.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/CoreApplication.java index 47c1e51..03aa47d 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/CoreApplication.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/CoreApplication.java @@ -69,7 +69,7 @@ public class CoreApplication extends Application { while(modulePropertiesEnum.hasMoreElements()) { URL moduleUrl = modulePropertiesEnum.nextElement(); - Configuration moduleProperties = null; + Configuration moduleProperties; try { moduleProperties = new PropertiesConfiguration(moduleUrl); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/config/ConfigurationWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/config/ConfigurationWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/config/ConfigurationWebService.java index 67635e6..ac6e472 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/config/ConfigurationWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/config/ConfigurationWebService.java @@ -18,7 +18,6 @@ package org.apache.marmotta.platform.core.webservices.config; import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.configuration.ConversionException; import org.apache.marmotta.platform.core.api.config.ConfigurationService; @@ -197,8 +196,6 @@ public class ConfigurationWebService { if(type!=null) configurationService.setType(key,type); if(comment!=null) configurationService.setComment(key,comment); return Response.status(200).build(); - } catch (JsonMappingException e) { - log.error("cannot parse input into json",e); } catch (IOException e) { log.error("cannot parse input into json",e); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/modules/ModuleWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/modules/ModuleWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/modules/ModuleWebService.java index 069fa02..8111444 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/modules/ModuleWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/modules/ModuleWebService.java @@ -66,7 +66,7 @@ public class ModuleWebService { @GET @Produces("application/json") public Map<String,Object> getConfiguration(@QueryParam("name") String moduleName) { - Configuration cfg = null; + Configuration cfg; try { cfg = moduleService.getModuleConfiguration(URLDecoder.decode(moduleName, "UTF-8")).getConfiguration(); } catch (UnsupportedEncodingException e) { http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ContentWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ContentWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ContentWebService.java index 6a520d5..174b15b 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ContentWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ContentWebService.java @@ -307,7 +307,7 @@ public class ContentWebService { long length = contentService.getContentLength(resource,mimetype); // build response - Response response = null; + Response response; long fromL = 0; if(range != null) { response = Response.status(206).entity(is).build(); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java index d4378cf..112791f 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java @@ -239,7 +239,7 @@ public class MetaWebService { try { conn.begin(); - Resource r = null; + Resource r; if (UriUtil.validate(resource)) { r = ResourceUtils.getUriResource(conn, resource); } else { http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/resources/web/admin/export.html ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/resources/web/admin/export.html b/platform/marmotta-core/src/main/resources/web/admin/export.html index 295fa56..2cf3ce0 100644 --- a/platform/marmotta-core/src/main/resources/web/admin/export.html +++ b/platform/marmotta-core/src/main/resources/web/admin/export.html @@ -45,25 +45,27 @@ $(document).ready(function() { // load contexts $.get(_SERVER_URL + "context/list?labels=true", function(data) { - $("#contexts").empty(); - $("#contexts").append("<option>all</option>"); + var contexts = $("#contexts"); + contexts.empty(); + contexts.append("<option>all</option>"); $.each(data, function(row,item) { - $("#contexts").append("<option value='"+item.uri+"'>"+item.label+"</option>"); + contexts.append("<option value='"+item.uri+"'>"+item.label+"</option>"); }); - $("#contexts").change(updateDownloadLink); + contexts.change(updateDownloadLink); updateDownloadLink(); }, "json"); // load supported formats $.get(_SERVER_URL + "export/types", function(data) { - $("#formats").empty(); + var formats = $("#formats"); + formats.empty(); $.each(data, function(row,item) { - $("#formats").append("<option>"+item+"</option>"); + formats.append("<option>"+item+"</option>"); }); - $("#formats").change(updateDownloadLink); + formats.change(updateDownloadLink); updateDownloadLink(); }, "json"); http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/resources/web/admin/js/widgets/system.js ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/resources/web/admin/js/widgets/system.js b/platform/marmotta-core/src/main/resources/web/admin/js/widgets/system.js index a596f8a..3bd4ffe 100644 --- a/platform/marmotta-core/src/main/resources/web/admin/js/widgets/system.js +++ b/platform/marmotta-core/src/main/resources/web/admin/js/widgets/system.js @@ -80,9 +80,9 @@ $(function() { $("tr.toRemove", tBody).slideUp("slow", function() { $(this).remove(); }); $("a.toRemove", jl).hide("slow", function() { $(this).remove(); }); - $('#messages div.error').slideUp('slow', function() { $(this).remove(); }); + $('#messages').find('div.error').slideUp('slow', function() { $(this).remove(); }); }).error(function() { - var t = $('#messages div.error'); + var t = $('#messages').find('div.error'); if (t.size() == 0) { $('#messages').append($("<div>", {'class':'error'}).text("Statistic update failed!")); } else { http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/resources/web/public/style/blue/rdfhtml.css ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/resources/web/public/style/blue/rdfhtml.css b/platform/marmotta-core/src/main/resources/web/public/style/blue/rdfhtml.css index e35af18..f3b591a 100644 --- a/platform/marmotta-core/src/main/resources/web/public/style/blue/rdfhtml.css +++ b/platform/marmotta-core/src/main/resources/web/public/style/blue/rdfhtml.css @@ -37,5 +37,3 @@ div#top_serialisation_links a { #table_buttons { margin-bottom: 10px; } - -@import "blue.css"; http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-core/src/main/resources/web/public/style/red/rdfhtml.css ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/resources/web/public/style/red/rdfhtml.css b/platform/marmotta-core/src/main/resources/web/public/style/red/rdfhtml.css index 640b698..f3b591a 100644 --- a/platform/marmotta-core/src/main/resources/web/public/style/red/rdfhtml.css +++ b/platform/marmotta-core/src/main/resources/web/public/style/red/rdfhtml.css @@ -37,5 +37,3 @@ div#top_serialisation_links a { #table_buttons { margin-bottom: 10px; } - -@import "red.css"; http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparql/SparqlServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparql/SparqlServiceImpl.java b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparql/SparqlServiceImpl.java index 6c612e4..4297dfa 100644 --- a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparql/SparqlServiceImpl.java +++ b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparql/SparqlServiceImpl.java @@ -176,10 +176,10 @@ public class SparqlServiceImpl implements SparqlService { connection.close(); } } catch(RepositoryException e) { - log.error("error while getting repository connection: {}", e); + log.error("error while getting repository connection", e); throw new MarmottaException("error while getting repository connection", e); } catch (QueryEvaluationException e) { - log.error("error while evaluating query: {}", e.getMessage()); + log.error("error while evaluating query", e.getMessage()); throw new MarmottaException("error while writing query result in format ", e); } @@ -241,7 +241,7 @@ public class SparqlServiceImpl implements SparqlService { connection.close(); } } catch(RepositoryException e) { - log.error("error while getting repository connection: {}", e); + log.error("error while getting repository connection", e); throw new MarmottaException("error while getting repository connection", e); } catch (QueryEvaluationException e) { log.error("error while evaluating query: {}", e.getMessage()); @@ -304,13 +304,13 @@ public class SparqlServiceImpl implements SparqlService { connection.close(); } } catch(RepositoryException e) { - log.error("error while getting repository connection: {}", e); + log.error("error while getting repository connection", e); throw new MarmottaException("error while getting repository connection", e); } catch (QueryEvaluationException e) { - log.error("error while evaluating query: {}", e); + log.error("error while evaluating query", e); throw new MarmottaException("error while evaluating query ", e); } catch (MalformedQueryException e) { - log.error("error because malformed query: {}", e); + log.error("error because malformed query", e); throw new MarmottaException("error because malformed query", e); } @@ -370,13 +370,9 @@ public class SparqlServiceImpl implements SparqlService { private void query(GraphQuery query, OutputStream output, RDFFormat format) throws QueryEvaluationException { try { QueryResultIO.write(query.evaluate(), format, output); - } catch (IOException e) { - throw new QueryEvaluationException("error while writing query graph result: ",e); - } - catch(RDFHandlerException e) { + } catch (IOException | RDFHandlerException e) { throw new QueryEvaluationException("error while writing query graph result: ",e); - } - catch(UnsupportedRDFormatException e) { + } catch(UnsupportedRDFormatException e) { throw new QueryEvaluationException("Could not find requested output RDF format for results of query: ",e); } } @@ -396,7 +392,7 @@ public class SparqlServiceImpl implements SparqlService { log.debug("executing {} query:\n{}", queryLanguage.getName(), query); - List<Map<String,Value>> result = new LinkedList<Map<String, Value>>(); + List<Map<String,Value>> result = new LinkedList<>(); try { RepositoryConnection connection = sesameService.getConnection(); @@ -407,7 +403,7 @@ public class SparqlServiceImpl implements SparqlService { try { while (r.hasNext()) { BindingSet s = r.next(); - Map<String, Value> map = new HashMap<String, Value>(); + Map<String, Value> map = new HashMap<>(); for (Binding binding : s) { map.put(binding.getName(), binding.getValue()); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLHTMLSettings.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLHTMLSettings.java b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLHTMLSettings.java index b590ab2..1d4279b 100644 --- a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLHTMLSettings.java +++ b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLHTMLSettings.java @@ -33,6 +33,6 @@ public final class SPARQLHTMLSettings * <p> * Defaults to null */ - public static final RioSetting<TemplatingService> TEMPLATING_SERVICE = new RioSettingImpl<TemplatingService>( - "org.apache.marmotta.platform.sparql.services.sparqlio.sparqlhtml.templatingservice", "Templating service for SPARQL Results HTML Writer", null); + public static final RioSetting<TemplatingService> TEMPLATING_SERVICE = new RioSettingImpl<>( + "org.apache.marmotta.platform.sparql.services.sparqlio.sparqlhtml.templatingservice", "Templating service for SPARQL Results HTML Writer", null); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLResultsHTMLWriter.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLResultsHTMLWriter.java b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLResultsHTMLWriter.java index 5e37757..7752e6d 100644 --- a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLResultsHTMLWriter.java +++ b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLResultsHTMLWriter.java @@ -17,15 +17,6 @@ */ package org.apache.marmotta.platform.sparql.services.sparqlio.sparqlhtml; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - import org.apache.marmotta.platform.core.api.templating.TemplatingService; import org.openrdf.query.BindingSet; import org.openrdf.query.QueryResultHandlerException; @@ -39,6 +30,10 @@ import org.openrdf.rio.WriterConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.*; + /** * SPARQL results to HTML writer using Freemarker * @@ -58,7 +53,7 @@ public class SPARQLResultsHTMLWriter extends TupleQueryResultHandlerBase impleme static { - HashSet<RioSetting<?>> tempSettings = new HashSet<RioSetting<?>>(); + HashSet<RioSetting<?>> tempSettings = new HashSet<>(); tempSettings.add(SPARQLHTMLSettings.TEMPLATING_SERVICE); SUPPORTED_SETTINGS = Collections.unmodifiableSet(tempSettings); } @@ -94,7 +89,7 @@ public class SPARQLResultsHTMLWriter extends TupleQueryResultHandlerBase impleme throw new IllegalStateException("Templating service was not setup"); } } - Map<String, Object> data = new HashMap<String, Object>(); + Map<String, Object> data = new HashMap<>(); data.put("vars", vars); this.vars = vars; try { @@ -107,9 +102,9 @@ public class SPARQLResultsHTMLWriter extends TupleQueryResultHandlerBase impleme @Override public void handleSolution(BindingSet binding) throws TupleQueryResultHandlerException { - Map<String, Object> data = new HashMap<String, Object>(); + Map<String, Object> data = new HashMap<>(); data.put("vars", vars); - Map<String, String> result = new HashMap<String, String>(); + Map<String, String> result = new HashMap<>(); for (String var: vars) { if (binding.hasBinding(var)) { result.put(var, binding.getBinding(var).getValue().stringValue()); @@ -128,7 +123,7 @@ public class SPARQLResultsHTMLWriter extends TupleQueryResultHandlerBase impleme @Override public void endQueryResult() throws TupleQueryResultHandlerException { - Map<String, Object> data = new HashMap<String, Object>(); + Map<String, Object> data = new HashMap<>(); try { templatingService.process(SPARQLResultsHTMLWriter.class, END_TEMPLATE, data, new OutputStreamWriter(out)); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLResultsHTMLWriterXSL.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLResultsHTMLWriterXSL.java b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLResultsHTMLWriterXSL.java index c3b67c0..3b70e27 100644 --- a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLResultsHTMLWriterXSL.java +++ b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/services/sparqlio/sparqlhtml/SPARQLResultsHTMLWriterXSL.java @@ -35,18 +35,9 @@ import org.openrdf.rio.WriterConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerFactory; +import javax.xml.transform.*; import javax.xml.transform.stream.StreamSource; -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; +import java.io.*; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collection; @@ -207,7 +198,7 @@ public class SPARQLResultsHTMLWriterXSL implements TupleQueryResultWriter { */ @Override public Collection<RioSetting<?>> getSupportedSettings() { - return new ArrayList<RioSetting<?>>(); + return new ArrayList<>(); } /** http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebService.java b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebService.java index 19a404d..ed4dab7 100644 --- a/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebService.java +++ b/platform/marmotta-sparql/src/main/java/org/apache/marmotta/platform/sparql/webservices/SparqlWebService.java @@ -20,7 +20,6 @@ package org.apache.marmotta.platform.sparql.webservices; import com.google.common.collect.Lists; import com.google.common.io.CharStreams; import org.apache.commons.collections.EnumerationUtils; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.marmotta.commons.http.ContentType; import org.apache.marmotta.commons.http.MarmottaHttpUtils; @@ -266,7 +265,7 @@ public class SparqlWebService { } else if (QueryType.BOOL.equals(queryType)) { offeredTypes = MarmottaHttpUtils.parseQueryResultFormatList(BooleanQueryResultWriterRegistry.getInstance().getKeys()); } else if (QueryType.GRAPH.equals(queryType)) { - Set<String> producedTypes = new HashSet<String>(exportService.getProducedTypes()); + Set<String> producedTypes = new HashSet<>(exportService.getProducedTypes()); producedTypes.remove("application/xml"); producedTypes.remove("text/plain"); producedTypes.remove("text/html"); @@ -451,7 +450,7 @@ public class SparqlWebService { * @return parameters */ private Map<String,String> parseEncodedQueryParameters(String body) { - Map<String,String> params = new HashMap<String,String>(); + Map<String,String> params = new HashMap<>(); for (String pair : body.split("&")) { int eq = pair.indexOf("="); try { @@ -505,7 +504,7 @@ public class SparqlWebService { final RDFWriter writer = Rio.createWriter(format, outputStream); sparqlService.createServiceDescription(writer, request.getRequestURL().toString(), isUpdate); } catch (RDFHandlerException e) { - log.warn("Could not send SpaqlServiceDescription: {}", e); + log.warn("Could not send SpaqlServiceDescription", e); throw new NoLogWebApplicationException(e, Response.serverError().entity(e).build()); } } @@ -520,10 +519,8 @@ public class SparqlWebService { public void write(OutputStream output) throws IOException, WebApplicationException { try { sparqlService.query(QueryLanguage.SPARQL, query, output, format.getMime(), configurationService.getIntConfiguration("sparql.timeout", 60)); - } catch (MarmottaException ex) { + } catch (MarmottaException | MalformedQueryException ex) { throw new WebApplicationException(ex.getCause(), Response.status(Response.Status.BAD_REQUEST).entity(WebServiceUtil.jsonErrorResponse(ex)).build()); - } catch (MalformedQueryException e) { - throw new WebApplicationException(e.getCause(), Response.status(Response.Status.BAD_REQUEST).entity(WebServiceUtil.jsonErrorResponse(e)).build()); } catch (TimeoutException e) { throw new WebApplicationException(e.getCause(), Response.status(Response.Status.GATEWAY_TIMEOUT).entity(WebServiceUtil.jsonErrorResponse(e)).build()); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-sparql/src/main/resources/web/admin/configuration.html ---------------------------------------------------------------------- diff --git a/platform/marmotta-sparql/src/main/resources/web/admin/configuration.html b/platform/marmotta-sparql/src/main/resources/web/admin/configuration.html index 15b8fdb..06e0b17 100644 --- a/platform/marmotta-sparql/src/main/resources/web/admin/configuration.html +++ b/platform/marmotta-sparql/src/main/resources/web/admin/configuration.html @@ -34,7 +34,7 @@ url : _SERVER_URL, container : "sparql_configurator", prefix : 'sparql' - } + }; var configurator = new Configurator(options); }); </script> http://git-wip-us.apache.org/repos/asf/marmotta/blob/7160bd1c/platform/marmotta-sparql/src/main/resources/web/admin/configuration.js ---------------------------------------------------------------------- diff --git a/platform/marmotta-sparql/src/main/resources/web/admin/configuration.js b/platform/marmotta-sparql/src/main/resources/web/admin/configuration.js index 39e5c35..bf27f34 100644 --- a/platform/marmotta-sparql/src/main/resources/web/admin/configuration.js +++ b/platform/marmotta-sparql/src/main/resources/web/admin/configuration.js @@ -25,6 +25,6 @@ $(function() { blacklist_keys : [ ], toplink : true, prefix : 'sparql' - } + }; $('#search_configurator').lmf_configurator(settings); });
