Repository: marmotta Updated Branches: refs/heads/develop e5ee6af11 -> e21293a29
http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/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 9c25478..e43c890 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 @@ -18,13 +18,9 @@ package org.apache.marmotta.platform.core.services.modules; import com.google.common.collect.ImmutableList; +import org.apache.commons.configuration.*; import org.apache.marmotta.platform.core.api.modules.ModuleService; import org.apache.marmotta.platform.core.model.module.ModuleConfiguration; -import org.apache.commons.configuration.CompositeConfiguration; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.MapConfiguration; -import org.apache.commons.configuration.PropertiesConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,12 +62,12 @@ public class ModuleServiceImpl implements ModuleService { //default_container_name = configurationService.getStringConfiguration("kiwi.pages.default_container.name",default_container_name); //default_container_number = configurationService.getIntConfiguration("kiwi.pages.default_container.number",default_container_number); - modules = new HashSet<String>(); - containers = new HashMap<String,ArrayList<String>>(); - container_weight = new HashMap<String, Integer>(); + modules = new HashSet<>(); + containers = new HashMap<>(); + container_weight = new HashMap<>(); - configurationMap = new HashMap<String, Configuration>(); - jarURLs = new HashMap<String, Configuration>(); + configurationMap = new HashMap<>(); + jarURLs = new HashMap<>(); try { Enumeration<URL> modulePropertiesEnum = this.getClass().getClassLoader().getResources("kiwi-module.properties"); @@ -81,7 +77,7 @@ public class ModuleServiceImpl implements ModuleService { Configuration moduleProperties = null; try { - Set<Configuration> configurations = new HashSet<Configuration>(); + Set<Configuration> configurations = new HashSet<>(); // get basic module configuration moduleProperties = new PropertiesConfiguration(moduleUrl); @@ -240,7 +236,7 @@ public class ModuleServiceImpl implements ModuleService { * @return */ private List<String> sortModules(Collection<String> m) { - List<String> sorted = new ArrayList<String>(m); + List<String> sorted = new ArrayList<>(m); Collections.sort(sorted,new Comparator<String>() { @Override public int compare(String o, String o2) { @@ -370,7 +366,7 @@ public class ModuleServiceImpl implements ModuleService { Configuration config = getModuleConfiguration(moduleName).getConfiguration(); if(config != null) { if(!config.subset("adminpage.").isEmpty()) { - ArrayList<String> l = new ArrayList<String>(); + ArrayList<String> l = new ArrayList<>(); while(config.getString("adminpage."+l.size()+".link") != null) { l.add(config.getString("adminpage."+l.size()+".link")); } @@ -389,17 +385,17 @@ public class ModuleServiceImpl implements ModuleService { public List<HashMap<String,String>> getAdminPageObjects(String moduleName) { Configuration config = getModuleConfiguration(moduleName).getConfiguration(); if(config != null) { - ArrayList<HashMap<String,String>> l = new ArrayList<HashMap<String,String>>(); + ArrayList<HashMap<String,String>> l = new ArrayList<>(); if(!config.subset("adminpage").isEmpty()) { while(config.getString("adminpage."+l.size()+".link") != null) { - HashMap<String,String> map = new HashMap<String, String>(); + HashMap<String,String> map = new HashMap<>(); map.put("link",config.getString("baseurl")+config.getString("adminpage."+l.size()+".link")); map.put("title",config.getString("adminpage."+l.size()+".title")); l.add(map); } } else { for(String path : config.getStringArray("adminpages")) { - HashMap<String,String> map = new HashMap<String, String>(); + HashMap<String,String> map = new HashMap<>(); map.put("link",config.getString("baseurl")+path); String title; if(path.lastIndexOf(".") > path.lastIndexOf("/")+1) http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixCC.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixCC.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixCC.java index 54038e6..523c3bb 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixCC.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixCC.java @@ -81,12 +81,12 @@ public class PrefixCC implements PrefixProvider { it.close(); } } - log.error("Error: prefix '" + prefix + "' not found at prefix.cc"); + log.error("Error: prefix '{}' not found at prefix.cc", prefix); return null; } }); } catch (Exception e) { - log.error("Error retrieving prefix '" + prefix + "' from prefix.cc: " + e.getMessage()); + log.error("Error retrieving prefix '{}' from prefix.cc: {}", prefix, e.getMessage()); return null; } } @@ -117,12 +117,12 @@ public class PrefixCC implements PrefixProvider { it.close(); } } - log.error("Error: reverse namespace lookup for '" + namespace + "' not found at prefix.cc"); + log.error("Error: reverse namespace lookup for '{}' not found at prefix.cc", namespace); return null; } }); } catch (Exception e) { - log.error("Error trying to retrieve prefic.cc reverse lookup for namespace '" + namespace + "': " + e.getMessage()); + log.error("Error trying to retrieve prefic.cc reverse lookup for namespace '{}': {}", namespace, e.getMessage()); return null; } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixServiceImpl.java index 4ee95dc..b849f12 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixServiceImpl.java @@ -17,24 +17,22 @@ */ package org.apache.marmotta.platform.core.services.prefix; -import java.net.URISyntaxException; -import java.util.Collections; -import java.util.Map; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.event.Observes; -import javax.inject.Inject; - +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import org.apache.commons.lang3.StringUtils; +import org.apache.marmotta.commons.http.UriUtil; import org.apache.marmotta.platform.core.api.config.ConfigurationService; import org.apache.marmotta.platform.core.api.prefix.PrefixService; import org.apache.marmotta.platform.core.events.ConfigurationChangedEvent; import org.apache.marmotta.platform.core.events.SesameStartupEvent; -import org.apache.commons.lang3.StringUtils; -import org.apache.marmotta.commons.http.UriUtil; import org.slf4j.Logger; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; +import javax.inject.Inject; +import java.net.URISyntaxException; +import java.util.Collections; +import java.util.Map; /** * Prefix Manager default implementation @@ -97,7 +95,7 @@ public class PrefixServiceImpl implements PrefixService { @Override public synchronized void add(String prefix, String namespace) throws IllegalArgumentException, URISyntaxException { if (cache.containsKey(prefix)) { - log.error("prefix " + prefix + " already managed"); + log.error("prefix {} already managed", prefix); throw new IllegalArgumentException("prefix " + prefix + " already managed, use forceAdd() if you'd like to force its rewrite"); } else { String validatedNamespace = validateNamespace(namespace); @@ -106,11 +104,11 @@ public class PrefixServiceImpl implements PrefixService { cache.put(prefix, validatedNamespace); configurationService.setConfiguration(CONFIGURATION_PREFIX + "." + prefix, validatedNamespace); } catch (IllegalArgumentException e) { - log.error("namespace " + validatedNamespace + " is already bound to '" + getPrefix(validatedNamespace) + "' prefix, use forceAdd() if you'd like to force its rewrite"); + log.error("namespace {} is already bound to '{}' prefix, use forceAdd() if you'd like to force its rewrite", validatedNamespace, getPrefix(validatedNamespace)); throw new IllegalArgumentException("namespace " + validatedNamespace + " is already bound to '" + getPrefix(validatedNamespace) + "' prefix"); } } else { - log.error("Namespace <" + namespace + "> is not valid"); + log.error("Namespace <{}> is not valid", namespace); throw new URISyntaxException(namespace, "Namespace <" + namespace + "> is not valid"); } } @@ -177,7 +175,7 @@ public class PrefixServiceImpl implements PrefixService { @Override public String serializePrefixMapping() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> mapping : cache.entrySet()) { sb.append(mapping.getKey()).append(": ").append(mapping.getValue()).append("\n"); } @@ -187,7 +185,7 @@ public class PrefixServiceImpl implements PrefixService { @Override public String serializePrefixesSparqlDeclaration() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> mapping : cache.entrySet()) { sb.append("PREFIX ").append(mapping.getKey()).append(": <").append(mapping.getValue()).append("> \n"); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/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 f8c0b43..81e301a 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 @@ -17,11 +17,9 @@ */ package org.apache.marmotta.platform.core.services.ssl; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; +import org.apache.marmotta.platform.core.api.ssl.SSLService; +import org.apache.marmotta.platform.core.events.ConfigurationServiceInitEvent; +import org.slf4j.Logger; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; @@ -29,10 +27,11 @@ import javax.net.ssl.KeyManager; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; - -import org.apache.marmotta.platform.core.api.ssl.SSLService; -import org.apache.marmotta.platform.core.events.ConfigurationServiceInitEvent; -import org.slf4j.Logger; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; /** * A service managing the configuration of the SSL context needed for establishing SSL connections. @@ -65,9 +64,7 @@ public class SSLServiceImpl implements SSLService { ctx = SSLContext.getInstance("TLS"); ctx.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom()); SSLContext.setDefault(ctx); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (KeyManagementException e) { + } catch (NoSuchAlgorithmException | KeyManagementException e) { e.printStackTrace(); } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/statistics/StatisticsServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/statistics/StatisticsServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/statistics/StatisticsServiceImpl.java index 26b53d9..48d76de 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/statistics/StatisticsServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/statistics/StatisticsServiceImpl.java @@ -61,7 +61,7 @@ public class StatisticsServiceImpl implements StatisticsService { protected void initModules(@Any Instance<StatisticsModule> modules) { log.info("Apache Marmotta StatisticsService starting up ..."); - this.modules = new LinkedHashMap<String,StatisticsModule>(); + this.modules = new LinkedHashMap<>(); for(StatisticsModule module : modules) { registerModule(module.getName(),module); @@ -180,7 +180,7 @@ public class StatisticsServiceImpl implements StatisticsService { */ @Override public List<String> listModules() { - return new LinkedList<String>(modules.keySet()); + return new LinkedList<>(modules.keySet()); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/statistics/system/SystemStatisticsModule.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/statistics/system/SystemStatisticsModule.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/statistics/system/SystemStatisticsModule.java index 65e8d79..c5e1681 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/statistics/system/SystemStatisticsModule.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/statistics/system/SystemStatisticsModule.java @@ -76,7 +76,7 @@ public class SystemStatisticsModule implements StatisticsModule { */ @Override public List<String> getPropertyNames() { - List<String> result = new LinkedList<String>(); + List<String> result = new LinkedList<>(); result.add("java version"); result.add("java vendor"); @@ -97,7 +97,7 @@ public class SystemStatisticsModule implements StatisticsModule { - LinkedHashMap<String,String> result = new LinkedHashMap<String, String>(); + LinkedHashMap<String,String> result = new LinkedHashMap<>(); result.put("java version", System.getProperty("java.version")); result.put("java vendor", System.getProperty("java.vendor")); http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/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 7381a81..30ff4d8 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 @@ -17,29 +17,20 @@ */ package org.apache.marmotta.platform.core.services.task; -import java.lang.ref.WeakReference; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Stack; -import java.util.concurrent.ConcurrentMap; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; - +import com.google.common.collect.MapMaker; import org.apache.marmotta.commons.util.HashUtils; import org.apache.marmotta.platform.core.api.task.Task; import org.apache.marmotta.platform.core.api.task.TaskInfo; import org.apache.marmotta.platform.core.api.task.TaskManagerService; import org.slf4j.Logger; -import com.google.common.collect.MapMaker; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import java.lang.ref.WeakReference; +import java.util.*; +import java.util.concurrent.ConcurrentMap; @ApplicationScoped public class TaskManagerServiceImpl implements TaskManagerService { @@ -97,7 +88,7 @@ public class TaskManagerServiceImpl implements TaskManagerService { */ @Override public List<TaskInfo> getTasks() { - LinkedList<TaskInfo> ts = new LinkedList<TaskInfo>(); + LinkedList<TaskInfo> ts = new LinkedList<>(); for (Stack<TaskImpl> stack : tasks.values()) { ts.addAll(stack); } @@ -168,7 +159,7 @@ public class TaskManagerServiceImpl implements TaskManagerService { final Thread key = Thread.currentThread(); Stack<TaskImpl> stack = tasks.get(key); if (stack == null) { - stack = new Stack<TaskImpl>(); + stack = new Stack<>(); tasks.put(key, stack); } return stack; @@ -179,13 +170,13 @@ public class TaskManagerServiceImpl implements TaskManagerService { */ @Override public Map<String, List<TaskInfo>> getTasksByGroup() { - Map<String, List<TaskInfo>> result = new LinkedHashMap<String, List<TaskInfo>>(); + Map<String, List<TaskInfo>> result = new LinkedHashMap<>(); for (TaskInfo task : getTasks()) { final String group = task.getGroup(); List<TaskInfo> list = result.get(group); if (list == null) { - list = new LinkedList<TaskInfo>(); + list = new LinkedList<>(); result.put(group, list); } list.add(task); @@ -199,12 +190,12 @@ public class TaskManagerServiceImpl implements TaskManagerService { */ @Override public Map<WeakReference<Thread>, Stack<TaskInfo>> getTasksByThread() { - Map<WeakReference<Thread>, Stack<TaskInfo>> result = new LinkedHashMap<WeakReference<Thread>, Stack<TaskInfo>>(); + Map<WeakReference<Thread>, Stack<TaskInfo>> result = new LinkedHashMap<>(); for (Map.Entry<Thread, Stack<TaskImpl>> e : tasks.entrySet()) { - Stack<TaskInfo> list = new Stack<TaskInfo>(); + Stack<TaskInfo> list = new Stack<>(); list.addAll(e.getValue()); - result.put(new WeakReference<Thread>(e.getKey()), list); + result.put(new WeakReference<>(e.getKey()), list); } return result; @@ -230,14 +221,14 @@ public class TaskManagerServiceImpl implements TaskManagerService { task.updateMessage("cleaning up"); task.updateProgress(++count); try { - HashSet<Thread> dead = new HashSet<Thread>(); + HashSet<Thread> dead = new HashSet<>(); for (Thread t : tasks.keySet()) { if (!t.isAlive()) { dead.add(t); } } for (Thread t : dead) { - log.debug("Watchdog: cleaning up dead thread " + t.getName()); + log.debug("Watchdog: cleaning up dead thread {}", t.getName()); tasks.remove(t); t = null; } http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/AdminTemplatingServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/AdminTemplatingServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/AdminTemplatingServiceImpl.java index 84b0713..8601996 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/AdminTemplatingServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/AdminTemplatingServiceImpl.java @@ -17,17 +17,6 @@ */ package org.apache.marmotta.platform.core.services.templating; -import java.io.ByteArrayOutputStream; -import java.io.OutputStreamWriter; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.servlet.ServletContext; - import org.apache.marmotta.platform.core.api.config.ConfigurationService; import org.apache.marmotta.platform.core.api.modules.ModuleService; import org.apache.marmotta.platform.core.api.templating.AdminInterfaceService; @@ -36,6 +25,16 @@ import org.apache.marmotta.platform.core.exception.TemplatingException; import org.apache.marmotta.platform.core.model.template.MenuItem; import org.apache.marmotta.platform.core.model.template.MenuItemType; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.servlet.ServletContext; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * User: Thomas Kurz * Date: 22.07.11 @@ -46,7 +45,7 @@ public class AdminTemplatingServiceImpl implements AdminInterfaceService { private ServletContext context; - private static enum Properties { HEAD, CONTENT } + private enum Properties { HEAD, CONTENT } @Inject private ModuleService moduleService; @@ -91,7 +90,7 @@ public class AdminTemplatingServiceImpl implements AdminInterfaceService { menu.setActive(path); //fill data model - Map<String, Object> datamodel = new HashMap<String,Object>(); + Map<String, Object> datamodel = new HashMap<>(); for(Properties p : Properties.values()) { datamodel.put(p.name(),"<!-- "+p.name()+" not defined -->"); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/TemplatingServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/TemplatingServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/TemplatingServiceImpl.java index 6f22a43..fd3c8fc 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/TemplatingServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/TemplatingServiceImpl.java @@ -17,32 +17,26 @@ */ package org.apache.marmotta.platform.core.services.templating; -import java.io.*; -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.PostConstruct; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.event.Observes; -import javax.inject.Inject; - - import com.google.common.base.Preconditions; - +import freemarker.template.Configuration; +import freemarker.template.Template; +import freemarker.template.TemplateException; import org.apache.commons.io.FileUtils; - import org.apache.marmotta.platform.core.api.config.ConfigurationService; import org.apache.marmotta.platform.core.api.templating.TemplatingService; import org.apache.marmotta.platform.core.events.ConfigurationChangedEvent; - -import freemarker.template.Configuration; -import freemarker.template.Template; -import freemarker.template.TemplateException; - import org.apache.marmotta.platform.core.startup.MarmottaStartupService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.annotation.PostConstruct; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; +import javax.inject.Inject; +import java.io.*; +import java.util.HashMap; +import java.util.Map; + /** * Template Service Implementation * @@ -59,13 +53,13 @@ public class TemplatingServiceImpl implements TemplatingService { @Inject private MarmottaStartupService startupService; - private static Logger log = LoggerFactory.getLogger(ConfigurationService.class); + private static Logger log = LoggerFactory.getLogger(TemplatingServiceImpl.class); private File templateDir; public TemplatingServiceImpl() { super(); - common = new HashMap<String, String>(); + common = new HashMap<>(); } @PostConstruct http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/SesameServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/SesameServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/SesameServiceImpl.java index 84760eb..a80ed71 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/SesameServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/SesameServiceImpl.java @@ -46,7 +46,6 @@ import javax.enterprise.inject.Instance; import javax.enterprise.inject.Produces; import javax.enterprise.inject.UnsatisfiedResolutionException; import javax.inject.Inject; -import java.util.Iterator; /** * Offers access to the Sesame repository underlying this Apache Marmotta instance. The activation/deactivation methods @@ -149,13 +148,10 @@ public class SesameServiceImpl implements SesameService { log.warn("more than one storage backend in classpath, trying to select the most appropriate ..."); StoreProvider candidate = null; - Iterator<StoreProvider> it = storeProviders.iterator(); - while (it.hasNext()) { - StoreProvider next = it.next(); - + for (StoreProvider next : storeProviders) { log.warn("- candidate: {} (annotations: {})", next.getName(), next.getClass().getAnnotations()); - if(candidate == null || !next.getClass().isAnnotationPresent(Fallback.class)) { + if (candidate == null || !next.getClass().isAnnotationPresent(Fallback.class)) { candidate = next; } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/user/UserServiceImpl.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/user/UserServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/user/UserServiceImpl.java index dc0af66..a5e1226 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/user/UserServiceImpl.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/user/UserServiceImpl.java @@ -68,7 +68,7 @@ public class UserServiceImpl implements UserService { * Each thread gets its own User. By using {@link InheritableThreadLocal}, the user is inherited * by from the parent thread unless it is explicitly set. */ - private static InheritableThreadLocal<URI> currentUser = new InheritableThreadLocal<URI>(); + private static InheritableThreadLocal<URI> currentUser = new InheritableThreadLocal<>(); // marker to ensure that no other thread interferes while setting up default users ... private boolean users_created = false; http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/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 1343e47..eed3381 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 @@ -26,22 +26,13 @@ import org.slf4j.Logger; import javax.enterprise.inject.Any; import javax.enterprise.inject.Instance; import javax.inject.Inject; -import javax.servlet.Filter; -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; import java.io.Serializable; import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; +import java.util.*; /** * This filter is used by KiWi for initialisation of the KiWi system on startup of the server. It does not perform @@ -83,7 +74,7 @@ public class MarmottaResourceFilter implements Filter { log.info("Apache Marmotta Resource Filter {} starting up ... ", configurationService.getConfiguration("kiwi.version")); // initialise filter chain and sort it according to priority - this.filterList = new ArrayList<MarmottaHttpFilter>(); + this.filterList = new ArrayList<>(); for(MarmottaHttpFilter filter : filters) { try { http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CDIContext.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CDIContext.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CDIContext.java index 9c42d24..400abff 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CDIContext.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CDIContext.java @@ -102,7 +102,7 @@ public class CDIContext { BeanManager beanManager = getBeanManager(); - List<T> result = new ArrayList<T>(); + List<T> result = new ArrayList<>(); for(Bean<?> bean : beanManager.getBeans(type)) { CreationalContext<T> context = beanManager.createCreationalContext((Bean<T>)bean); result.add((T) beanManager.getReference(bean, type, context)); @@ -148,9 +148,7 @@ public class CDIContext { } } catch (NoSuchFieldException e) { log.warn("list observers: event field {} not found for class {}", fieldName, type.getName()); - } catch (InstantiationException e) { - log.warn("list observers: could not instantiate object of event field {} for class {}", fieldName, type.getName()); - } catch (IllegalAccessException e) { + } catch (InstantiationException | IllegalAccessException e) { log.warn("list observers: could not instantiate object of event field {} for class {}", fieldName, type.getName()); } return false; http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/LinkedHashSetBlockingQueue.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/LinkedHashSetBlockingQueue.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/LinkedHashSetBlockingQueue.java index c42d7fe..91db968 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/LinkedHashSetBlockingQueue.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/LinkedHashSetBlockingQueue.java @@ -55,11 +55,11 @@ public class LinkedHashSetBlockingQueue<E> extends AbstractQueue<E> implements B private final LinkedHashSet<E> delegate; public LinkedHashSetBlockingQueue() { - delegate = new LinkedHashSet<E>(); + delegate = new LinkedHashSet<>(); } public LinkedHashSetBlockingQueue(int capacity) { - this.delegate = new LinkedHashSet<E>(capacity); + this.delegate = new LinkedHashSet<>(capacity); this.capacity = capacity; } http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/WebServiceUtil.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/WebServiceUtil.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/WebServiceUtil.java index 48e61fc..ccc352a 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/WebServiceUtil.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/WebServiceUtil.java @@ -17,17 +17,15 @@ */ package org.apache.marmotta.platform.core.util; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.lang3.exception.ExceptionUtils; + +import javax.ws.rs.Path; import java.io.IOException; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; -import javax.ws.rs.Path; - -import org.apache.commons.lang3.exception.ExceptionUtils; - -import com.fasterxml.jackson.databind.ObjectMapper; - /** * Utility methods for web services * <p/> @@ -47,7 +45,7 @@ public class WebServiceUtil { * </code> */ public static String jsonErrorResponse(Exception e) { - Map<String,Object> result = new HashMap<String, Object>(); + Map<String,Object> result = new HashMap<>(); result.put("type", e.getClass().getSimpleName()); result.put("message", e.getMessage()); result.put("trace", ExceptionUtils.getStackTrace(e)); @@ -72,7 +70,7 @@ public class WebServiceUtil { * </code> */ public static void jsonErrorResponse(Exception ex, OutputStream out) throws IOException { - Map<String,Object> result = new HashMap<String, Object>(); + Map<String,Object> result = new HashMap<>(); result.put("type",ex.getClass().getSimpleName()); result.put("message",ex.getMessage()); http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/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 869e7d8..47c1e51 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 @@ -61,7 +61,7 @@ public class CoreApplication extends Application { if(classes == null) { - classes = new HashSet<Class<?>>(); + classes = new HashSet<>(); try { Enumeration<URL> modulePropertiesEnum = this.getClass().getClassLoader().getResources("kiwi-module.properties"); http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/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 838ce61..67635e6 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 @@ -17,36 +17,22 @@ */ package org.apache.marmotta.platform.core.webservices.config; -import java.io.BufferedReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +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; +import org.slf4j.Logger; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; - -import org.apache.commons.configuration.ConversionException; -import org.apache.marmotta.platform.core.api.config.ConfigurationService; -import org.slf4j.Logger; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.*; /** * Manage the system configuration of the Apache Marmotta Server. Provides methods for displaying and updating the configuration @@ -73,7 +59,7 @@ public class ConfigurationWebService { @Path("/list") @Produces("application/json") public Map<String,Map<String,Object>> listConfiguration(@QueryParam("prefix")String prefix) { - HashMap<String,Map<String,Object>> result = new HashMap<String,Map<String,Object>>(); + HashMap<String,Map<String,Object>> result = new HashMap<>(); if(prefix==null) { for(String key : configurationService.listConfigurationKeys()) { result.put(key, buildConfigurationMap(key)); @@ -87,7 +73,7 @@ public class ConfigurationWebService { } public Map<String,Object> buildConfigurationMap(String key) { - Map<String,Object> config = new HashMap<String, Object>(); + Map<String,Object> config = new HashMap<>(); config.put("comment",configurationService.getComment(key)); config.put("type",configurationService.getType(key)); config.put("value",configurationService.getConfiguration(key)); @@ -145,7 +131,7 @@ public class ConfigurationWebService { public Response getConfiguration(@PathParam("key") String key) { Object value = configurationService.getConfiguration(key); if(value != null) { - HashMap<String,Object> result = new HashMap<String,Object>(); + HashMap<String,Object> result = new HashMap<>(); result.put(key, value); return Response.status(200).entity(result).build(); } else @@ -213,8 +199,6 @@ public class ConfigurationWebService { return Response.status(200).build(); } catch (JsonMappingException e) { log.error("cannot parse input into json",e); - } catch (JsonParseException e) { - log.error("cannot parse input into json",e); } catch (IOException e) { log.error("cannot parse input into json",e); } @@ -244,7 +228,7 @@ public class ConfigurationWebService { } public String getContent(BufferedReader r) { - String s;StringBuffer b = new StringBuffer(); + String s;StringBuilder b = new StringBuilder(); try { while((s = r.readLine()) != null) { b.append(s); http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ExportWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ExportWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ExportWebService.java index 7bd3354..b38c83c 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ExportWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ExportWebService.java @@ -71,7 +71,7 @@ public class ExportWebService { @Path("/types") @Produces("application/json") public List<String> getTypes() { - ArrayList<String> result = new ArrayList<String>(exportService.getProducedTypes()); + ArrayList<String> result = new ArrayList<>(exportService.getProducedTypes()); Collections.sort(result); return result; http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ImportWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ImportWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ImportWebService.java index b221f2b..cac9928 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ImportWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ImportWebService.java @@ -81,9 +81,9 @@ public class ImportWebService { @Produces("application/json") public List<String> getTypes(@QueryParam("filename") String filename) { if(filename == null) - return new ArrayList<String>(importService.getAcceptTypes()); + return new ArrayList<>(importService.getAcceptTypes()); else { - List<String> result = new ArrayList<String>(); + List<String> result = new ArrayList<>(); RDFFormat format = Rio.getParserFormatForFileName(filename); if(format != null) { result.addAll(format.getMIMETypes()); http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/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 19c9ae0..069fa02 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 @@ -17,9 +17,9 @@ */ package org.apache.marmotta.platform.core.webservices.modules; +import org.apache.commons.configuration.Configuration; import org.apache.marmotta.platform.core.api.modules.ModuleService; import org.apache.marmotta.platform.core.model.module.ModuleConfiguration; -import org.apache.commons.configuration.Configuration; import javax.inject.Inject; import javax.ws.rs.GET; @@ -28,12 +28,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * Give information about modules registered in the system. @@ -78,7 +73,7 @@ public class ModuleWebService { return null; } if(cfg != null) { - Map<String,Object> result = new HashMap<String, Object>(); + Map<String,Object> result = new HashMap<>(); for(Iterator<String> it = cfg.getKeys() ; it.hasNext(); ) { String key = it.next(); result.put(key,cfg.getProperty(key)); @@ -100,14 +95,14 @@ public class ModuleWebService { @GET @Produces("application/json") public Map<String, Map<String, String>> getBuildInfo() { - HashMap<String, Map<String, String>> mods = new HashMap<String, Map<String, String>>(); + HashMap<String, Map<String, String>> mods = new HashMap<>(); for (String moduleName : moduleService.listModules()) { Configuration cfg = moduleService.getModuleConfiguration(moduleName).getConfiguration(); if (cfg != null) { ModuleConfiguration mCfg = new ModuleConfiguration(cfg); if (mCfg.hasBuildInfo()) { - Map<String, String> result = new LinkedHashMap<String, String>(); + Map<String, String> result = new LinkedHashMap<>(); result.put("id", mCfg.getModuleId()); result.put("version", mCfg.getModuleVersion()); http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/prefix/PrefixWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/prefix/PrefixWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/prefix/PrefixWebService.java index 6222670..6069c81 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/prefix/PrefixWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/prefix/PrefixWebService.java @@ -17,23 +17,16 @@ */ package org.apache.marmotta.platform.core.webservices.prefix; -import org.apache.marmotta.platform.core.api.prefix.PrefixService; import org.apache.commons.lang3.StringUtils; +import org.apache.marmotta.platform.core.api.prefix.PrefixService; import org.slf4j.Logger; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import javax.validation.constraints.NotNull; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; - import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; @@ -79,11 +72,11 @@ public class PrefixWebService { @Produces("application/json") public Response getMapping(@PathParam("prefix") String prefix) { if (prefixService.containsPrefix(prefix)) { - Map<String, String> result = new HashMap<String, String>(); + Map<String, String> result = new HashMap<>(); result.put(prefix, prefixService.getNamespace(prefix)); return Response.ok().entity(result).build(); } else { - log.error("prefix " + prefix + " mapping not found"); + log.error("prefix {} mapping not found", prefix); return Response.status(Response.Status.NOT_FOUND).entity("prefix " + prefix + " mapping not found").build(); } } @@ -136,11 +129,11 @@ public class PrefixWebService { public Response getPrefix(@QueryParam("uri") @NotNull String uri) { if (StringUtils.isNotBlank(uri)) { if (prefixService.containsNamespace(uri)) { - Map<String, String> result = new HashMap<String, String>(); + Map<String, String> result = new HashMap<>(); result.put(uri, prefixService.getPrefix(uri)); return Response.ok().entity(result).build(); } else { - log.error("namespace " + uri + " mapping not found"); + log.error("namespace {} mapping not found", uri); return Response.status(Response.Status.NOT_FOUND).entity("namespace " + uri + " mapping not found").build(); } } else { http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/InspectionWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/InspectionWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/InspectionWebService.java index 5879e04..73b35d1 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/InspectionWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/InspectionWebService.java @@ -154,7 +154,7 @@ public class InspectionWebService { } private List<TriplePoJo> buildResultList(RepositoryConnection conn, URI s, URI p, URI o, URI c, long start, int limit) throws RepositoryException { - List<TriplePoJo> result = new ArrayList<InspectionWebService.TriplePoJo>(); + List<TriplePoJo> result = new ArrayList<>(); RepositoryResult<Statement> triples = c != null ? conn.getStatements(s,p,o,true,c) : conn.getStatements(s,p,o,true); // skip until start for(int i = 0; i<start && triples.hasNext(); i++) { @@ -332,7 +332,7 @@ public class InspectionWebService { ts.next(); } if (ts.hasNext()) { - Set<Statement> triples = new HashSet<Statement>(); + Set<Statement> triples = new HashSet<>(); for(int j = 0; j<limit && ts.hasNext(); j++) { triples.add(ts.next()); } @@ -363,7 +363,7 @@ public class InspectionWebService { ts.next(); } if (ts.hasNext()) { - Set<Statement> triples = new HashSet<Statement>(); + Set<Statement> triples = new HashSet<>(); for(int j = 0; j<limit && ts.hasNext(); j++) { triples.add(ts.next()); } @@ -394,7 +394,7 @@ public class InspectionWebService { ts.next(); } if (ts.hasNext()) { - Set<Statement> triples = new HashSet<Statement>(); + Set<Statement> triples = new HashSet<>(); for(int j = 0; j<limit && ts.hasNext(); j++) { triples.add(ts.next()); } @@ -426,7 +426,7 @@ public class InspectionWebService { ts.next(); } if (ts.hasNext()) { - Set<Statement> triples = new HashSet<Statement>(); + Set<Statement> triples = new HashSet<>(); for(int j = 0; j<limit && ts.hasNext(); j++) { triples.add(ts.next()); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/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 98310d1..d4378cf 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 @@ -44,7 +44,8 @@ import javax.validation.constraints.NotNull; import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.*; +import javax.ws.rs.core.Response.ResponseBuilder; +import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.StreamingOutput; import java.io.IOException; import java.io.OutputStream; @@ -55,7 +56,8 @@ import java.util.LinkedList; import java.util.List; import static com.google.common.net.HttpHeaders.*; -import static javax.ws.rs.core.Response.*; +import static javax.ws.rs.core.Response.ok; +import static javax.ws.rs.core.Response.status; import static org.apache.marmotta.platform.core.webservices.resource.ResourceWebService.CHARSET; import static org.apache.marmotta.platform.core.webservices.resource.ResourceWebServiceHelper.appendMetaTypes; @@ -305,7 +307,7 @@ public class MetaWebService { } // create the Link headers for the response - List<String> links = new LinkedList<String>(); + List<String> links = new LinkedList<>(); // build the link to the human readable content of this resource (if it exists) String contentLink = ResourceWebServiceHelper.buildContentLink(r, contentService.getContentType(r), configurationService); http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java index 721258d..a6cc2db 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java @@ -408,7 +408,7 @@ public class ResourceWebService { response.header(CONTENT_TYPE, "text/plain; charset=UTF-8"); StringBuilder entity = new StringBuilder(); - entity.append("Could not find matching type for " + acceptedTypes + "\n"); + entity.append("Could not find matching type for ").append(acceptedTypes).append("\n"); entity.append("choose one of the following:"); for (ContentType contentType : offeredTypes) { entity.append(" ").append(contentType).append("\n"); http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebServiceHelper.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebServiceHelper.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebServiceHelper.java index ab0ecc7..98f6ae9 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebServiceHelper.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebServiceHelper.java @@ -60,7 +60,7 @@ public class ResourceWebServiceHelper { public static String buildContentLink(Resource resource, String mime, ConfigurationService configurationService) { //TODO: test if there is content - StringBuffer b = new StringBuffer(); + StringBuilder b = new StringBuilder(); if (mime != null) { b.append("<"); // b.append(configurationService.getBaseUri() + "content/" + mime + http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/statistics/StatisticsWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/statistics/StatisticsWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/statistics/StatisticsWebService.java index 412b2dc..74fa8f9 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/statistics/StatisticsWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/statistics/StatisticsWebService.java @@ -23,12 +23,7 @@ import org.slf4j.Logger; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.util.HashMap; import java.util.List; @@ -90,7 +85,7 @@ public class StatisticsWebService { @Produces("application/json") @Path("/list") public Map<String,Map<String,String>> getStatistics() { - Map<String,Map<String,String>> result = new HashMap<String, Map<String, String>>(); + Map<String,Map<String,String>> result = new HashMap<>(); for(String module : statisticsService.listModules()) { result.put(module, statisticsService.getModule(module).getStatistics()); @@ -114,7 +109,7 @@ public class StatisticsWebService { @Path("/{module}") public Response getStatistics(@PathParam("module") String module) { if(statisticsService.getModule(module) != null) { - Map<String,Map<String,String>> result = new HashMap<String, Map<String, String>>(); + Map<String,Map<String,String>> result = new HashMap<>(); result.put(module, statisticsService.getModule(module).getStatistics()); http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/task/TaskManagerWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/task/TaskManagerWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/task/TaskManagerWebService.java index 831623c..079a8d7 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/task/TaskManagerWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/task/TaskManagerWebService.java @@ -30,7 +30,6 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; - import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.List; @@ -73,7 +72,7 @@ public class TaskManagerWebService { @Path("/byThread") @Produces("application/json") public Map<String, List<TaskInfo>> listByThread() { - HashMap<String, List<TaskInfo>> result = new HashMap<String, List<TaskInfo>>(); + HashMap<String, List<TaskInfo>> result = new HashMap<>(); final Map<WeakReference<Thread>, Stack<TaskInfo>> tasksByThread = taskManagerService.getTasksByThread(); for (Map.Entry<WeakReference<Thread>, Stack<TaskInfo>> e : tasksByThread.entrySet()) { Thread t = e.getKey().get(); @@ -99,7 +98,7 @@ public class TaskManagerWebService { public Map<String, List<TaskInfo>> list(@PathParam("group") String group) { log.debug("Listing all tasks of group '{}'", group); - Map<String, List<TaskInfo>> result = new HashMap<String, List<TaskInfo>>(); + Map<String, List<TaskInfo>> result = new HashMap<>(); Map<String, List<TaskInfo>> allTasks = taskManagerService.getTasksByGroup(); if (allTasks.containsKey(group)) { http://git-wip-us.apache.org/repos/asf/marmotta/blob/e21293a2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java index 7bdb0d8..5a35180 100644 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java +++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/triplestore/ContextWebService.java @@ -74,7 +74,7 @@ public class ContextWebService { public Response listContexts(@QueryParam("labels") String labels, @QueryParam("filter") String filter) { try { if(labels == null) { - ArrayList<String> res = new ArrayList<String>(); + ArrayList<String> res = new ArrayList<>(); for(org.openrdf.model.URI r : contextService.listContexts(filter != null)) { res.add(r.stringValue()); } @@ -82,7 +82,7 @@ public class ContextWebService { } else { ArrayList<Map<String,Object>> result = new ArrayList<>(); for(org.openrdf.model.URI r : contextService.listContexts(filter != null)) { - Map<String,Object> ctxDesc = new HashMap<String, Object>(); + Map<String,Object> ctxDesc = new HashMap<>(); ctxDesc.put("uri",r.stringValue()); ctxDesc.put("label", contextService.getContextLabel(r)); ctxDesc.put("size", contextService.getContextSize(r));
