diff --git a/src/main/java/sirius/biz/analytics/checks/DailyCheck.java b/src/main/java/sirius/biz/analytics/checks/DailyCheck.java index bfb35b92d..75d8b1a6f 100644 --- a/src/main/java/sirius/biz/analytics/checks/DailyCheck.java +++ b/src/main/java/sirius/biz/analytics/checks/DailyCheck.java @@ -11,6 +11,7 @@ import sirius.biz.analytics.scheduler.AnalyticalTask; import sirius.db.mixing.BaseEntity; import sirius.kernel.di.std.AutoRegister; +import sirius.kernel.health.Average; import java.time.LocalDate; @@ -28,6 +29,18 @@ @AutoRegister public abstract class DailyCheck> implements AnalyticalTask { + /** + * Contains the maximum duration of a computation in milliseconds. + */ + private long maxDurationMillis = 0; + + /** + * Contains the average duration of computations in milliseconds. + *

+ * This keeps track of the average duration via a sliding window. + */ + private final Average avgDurationMillis = new Average(); + @Override public void compute(LocalDate date, E entity, boolean bestEffort) { execute(entity); @@ -49,4 +62,27 @@ public boolean isEnabled() { public int getLevel() { return AnalyticalTask.DEFAULT_LEVEL; } + + @Override + public void trackDuration(long durationMillis) { + this.avgDurationMillis.addValue(durationMillis); + this.maxDurationMillis = Math.max(this.maxDurationMillis, durationMillis); + } + + @Override + public void resetDurations() { + this.avgDurationMillis.getAndClear(); + this.maxDurationMillis = 0; + + } + + @Override + public long getMaxDurationMillis() { + return maxDurationMillis; + } + + @Override + public Average getAvgDurationMillis() { + return avgDurationMillis; + } } diff --git a/src/main/java/sirius/biz/analytics/events/EventRecorder.java b/src/main/java/sirius/biz/analytics/events/EventRecorder.java index 6c2121ae1..465c31aba 100644 --- a/src/main/java/sirius/biz/analytics/events/EventRecorder.java +++ b/src/main/java/sirius/biz/analytics/events/EventRecorder.java @@ -438,13 +438,13 @@ public void record(@Nonnull Event event) { event.getDescriptor().beforeSave(event); buffer.offer(event); bufferedEvents.incrementAndGet(); - } catch (HandledException e) { + } catch (HandledException exception) { Log.BACKGROUND.WARN("An event was not recorded due to a before-save warning. Event: %s (%s): %s", event.toString(), event.getClass().getSimpleName(), - e.getMessage()); - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + exception.getMessage()); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); } } @@ -490,10 +490,10 @@ protected int process() { nextEvent = fetchBufferedEvent(); } - } catch (HandledException e) { - Exceptions.ignore(e); - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (HandledException exception) { + Exceptions.ignore(exception); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); } return processedEvents; @@ -512,16 +512,16 @@ private void processEvent(BatchContext ctx, Map>, InsertQuery>> queries, Event event) { try { - InsertQuery> qry = queries.computeIfAbsent((Class>) event.getClass(), - type -> (InsertQuery>) ctx.insertQuery(type, - false)); - qry.insert(event, false, true); - } catch (Exception e) { + InsertQuery> query = queries.computeIfAbsent((Class>) event.getClass(), + type -> (InsertQuery>) ctx.insertQuery(type, + false)); + query.insert(event, false, true); + } catch (Exception exception) { if (!event.retried) { event.retried = true; record(event); } - throw e; + throw exception; } } diff --git a/src/main/java/sirius/biz/analytics/explorer/DataExplorerController.java b/src/main/java/sirius/biz/analytics/explorer/DataExplorerController.java index 3af36dc94..47565035f 100644 --- a/src/main/java/sirius/biz/analytics/explorer/DataExplorerController.java +++ b/src/main/java/sirius/biz/analytics/explorer/DataExplorerController.java @@ -137,8 +137,8 @@ public Future chartApi(WebContext webContext, JSONStructuredOutput output) throw computeGranularity(range), comparisonPeriod, output); - } catch (Exception error) { - throw Exceptions.handle(Log.APPLICATION, error); + } catch (Exception exception) { + throw Exceptions.handle(Log.APPLICATION, exception); } }); } @@ -211,10 +211,10 @@ private Stream exportTimeSeriesAsDatasets(String identifier, timeSeries, comparisonPeriod) .stream(); - } catch (Exception error) { + } catch (Exception exception) { Exceptions.handle() .to(Log.BACKGROUND) - .error(error) + .error(exception) .withSystemErrorMessage("DataExplorerController: Failed to compute time series for %s: %s (%s)", identifier) .handle(); diff --git a/src/main/java/sirius/biz/analytics/flags/jdbc/SQLPerformanceFlagModifier.java b/src/main/java/sirius/biz/analytics/flags/jdbc/SQLPerformanceFlagModifier.java index b5b795d32..2bb100afa 100644 --- a/src/main/java/sirius/biz/analytics/flags/jdbc/SQLPerformanceFlagModifier.java +++ b/src/main/java/sirius/biz/analytics/flags/jdbc/SQLPerformanceFlagModifier.java @@ -70,10 +70,10 @@ public void commit() { .set(PerformanceFlagged.PERFORMANCE_DATA.inner(SQLPerformanceData.FLAGS), target.flags) .where(SQLEntity.ID, target.getOwner().getId()) .executeUpdate(); - } catch (SQLException e) { + } catch (SQLException exception) { Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to update performance flags of %s (%s): %s (%s)", target.getOwner().getIdAsString(), target.getOwner().getClass().getName()) diff --git a/src/main/java/sirius/biz/analytics/flags/mongo/MongoPerformanceFlagModifier.java b/src/main/java/sirius/biz/analytics/flags/mongo/MongoPerformanceFlagModifier.java index fdbce71af..703914fc1 100644 --- a/src/main/java/sirius/biz/analytics/flags/mongo/MongoPerformanceFlagModifier.java +++ b/src/main/java/sirius/biz/analytics/flags/mongo/MongoPerformanceFlagModifier.java @@ -81,10 +81,10 @@ public void commit() { .addEachToSet(PerformanceFlagged.PERFORMANCE_DATA.inner(MongoPerformanceData.FLAGS), flagsToAdd) .executeFor((MongoEntity) target.getOwner()); } - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to update performance flags of %s (%s): %s (%s)", target.getOwner().getIdAsString(), target.getOwner().getClass().getName()) diff --git a/src/main/java/sirius/biz/analytics/indicators/BatchIndicatorCheck.java b/src/main/java/sirius/biz/analytics/indicators/BatchIndicatorCheck.java index 9c1eb422d..cf78dd92d 100644 --- a/src/main/java/sirius/biz/analytics/indicators/BatchIndicatorCheck.java +++ b/src/main/java/sirius/biz/analytics/indicators/BatchIndicatorCheck.java @@ -42,8 +42,8 @@ protected void execute(E entity) { try { entity.getIndicators() .updateIndication(indicator.getName(), ((Indicator) indicator).executeFor(entity)); - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); entity.getIndicators().updateIndication(indicator.getName(), false); } }); diff --git a/src/main/java/sirius/biz/analytics/indicators/IndicatorData.java b/src/main/java/sirius/biz/analytics/indicators/IndicatorData.java index 082076518..4ae118a74 100644 --- a/src/main/java/sirius/biz/analytics/indicators/IndicatorData.java +++ b/src/main/java/sirius/biz/analytics/indicators/IndicatorData.java @@ -70,8 +70,8 @@ protected void beforeSave() { for (Indicator indicator : indicators) { try { executeIndicator(indicator); - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); updateIndication(indicator.getName(), false); } } diff --git a/src/main/java/sirius/biz/analytics/metrics/DailyMetricComputer.java b/src/main/java/sirius/biz/analytics/metrics/DailyMetricComputer.java index b4d459e87..5de04c1db 100644 --- a/src/main/java/sirius/biz/analytics/metrics/DailyMetricComputer.java +++ b/src/main/java/sirius/biz/analytics/metrics/DailyMetricComputer.java @@ -12,6 +12,7 @@ import sirius.db.mixing.BaseEntity; import sirius.kernel.di.std.AutoRegister; import sirius.kernel.di.std.Part; +import sirius.kernel.health.Average; import javax.annotation.Nullable; import java.time.LocalDate; @@ -32,6 +33,18 @@ public abstract class DailyMetricComputer> implements An @Nullable protected Metrics metrics; + /** + * Contains the maximum duration of a computation in milliseconds. + */ + private long maxDurationMillis = 0; + + /** + * Contains the average duration of computations in milliseconds. + *

+ * This keeps track of the average duration via a sliding window. + */ + private final Average avgDurationMillis = new Average(); + @Override public boolean isEnabled() { return true; @@ -42,6 +55,29 @@ public int getLevel() { return AnalyticalTask.DEFAULT_LEVEL; } + @Override + public void trackDuration(long durationMillis) { + this.avgDurationMillis.addValue(durationMillis); + this.maxDurationMillis = Math.max(this.maxDurationMillis, durationMillis); + } + + @Override + public void resetDurations() { + this.avgDurationMillis.getAndClear(); + this.maxDurationMillis = 0; + + } + + @Override + public long getMaxDurationMillis() { + return maxDurationMillis; + } + + @Override + public Average getAvgDurationMillis() { + return avgDurationMillis; + } + @Override public final void compute(LocalDate date, E entity, boolean bestEffort) throws Exception { boolean sameDay = LocalDate.now().equals(date); diff --git a/src/main/java/sirius/biz/analytics/metrics/MonthlyLargeMetricComputer.java b/src/main/java/sirius/biz/analytics/metrics/MonthlyLargeMetricComputer.java index 84be2f182..074a7a9d3 100644 --- a/src/main/java/sirius/biz/analytics/metrics/MonthlyLargeMetricComputer.java +++ b/src/main/java/sirius/biz/analytics/metrics/MonthlyLargeMetricComputer.java @@ -12,6 +12,7 @@ import sirius.db.mixing.BaseEntity; import sirius.kernel.di.std.AutoRegister; import sirius.kernel.di.std.Part; +import sirius.kernel.health.Average; import javax.annotation.Nullable; import java.time.LocalDate; @@ -34,6 +35,18 @@ public abstract class MonthlyLargeMetricComputer> implem @Nullable protected Metrics metrics; + /** + * Contains the maximum duration of a computation in milliseconds. + */ + private long maxDurationMillis = 0; + + /** + * Contains the average duration of computations in milliseconds. + *

+ * This keeps track of the average duration via a sliding window. + */ + private final Average avgDurationMillis = new Average(); + @Override public boolean isEnabled() { return true; @@ -44,6 +57,28 @@ public int getLevel() { return AnalyticalTask.DEFAULT_LEVEL; } + @Override + public void trackDuration(long durationMillis) { + this.avgDurationMillis.addValue(durationMillis); + this.maxDurationMillis = Math.max(this.maxDurationMillis, durationMillis); + } + + @Override + public void resetDurations() { + this.avgDurationMillis.getAndClear(); + this.maxDurationMillis = 0; + } + + @Override + public long getMaxDurationMillis() { + return maxDurationMillis; + } + + @Override + public Average getAvgDurationMillis() { + return avgDurationMillis; + } + @Override public final void compute(LocalDate date, E entity, boolean bestEffort) throws Exception { boolean sameMonth = LocalDate.now().withDayOfMonth(1).equals(date.withDayOfMonth(1)); diff --git a/src/main/java/sirius/biz/analytics/metrics/MonthlyMetricComputer.java b/src/main/java/sirius/biz/analytics/metrics/MonthlyMetricComputer.java index de4cba08e..be5e91796 100644 --- a/src/main/java/sirius/biz/analytics/metrics/MonthlyMetricComputer.java +++ b/src/main/java/sirius/biz/analytics/metrics/MonthlyMetricComputer.java @@ -12,6 +12,7 @@ import sirius.db.mixing.BaseEntity; import sirius.kernel.di.std.AutoRegister; import sirius.kernel.di.std.Part; +import sirius.kernel.health.Average; import javax.annotation.Nullable; import java.time.LocalDate; @@ -35,11 +36,46 @@ public abstract class MonthlyMetricComputer> implements @Nullable protected Metrics metrics; + /** + * Contains the maximum duration of a computation in milliseconds. + */ + private long maxDurationMillis = 0; + + /** + * Contains the average duration of computations in milliseconds. + *

+ * This keeps track of the average duration via a sliding window. + */ + private final Average avgDurationMillis = new Average(); + @Override public int getLevel() { return AnalyticalTask.DEFAULT_LEVEL; } + @Override + public void trackDuration(long durationMillis) { + this.avgDurationMillis.addValue(durationMillis); + this.maxDurationMillis = Math.max(this.maxDurationMillis, durationMillis); + } + + @Override + public void resetDurations() { + this.avgDurationMillis.getAndClear(); + this.maxDurationMillis = 0; + + } + + @Override + public long getMaxDurationMillis() { + return maxDurationMillis; + } + + @Override + public Average getAvgDurationMillis() { + return avgDurationMillis; + } + @Override public boolean isEnabled() { return true; diff --git a/src/main/java/sirius/biz/analytics/metrics/jdbc/SQLMetrics.java b/src/main/java/sirius/biz/analytics/metrics/jdbc/SQLMetrics.java index 2d29f583f..f7dc91f72 100644 --- a/src/main/java/sirius/biz/analytics/metrics/jdbc/SQLMetrics.java +++ b/src/main/java/sirius/biz/analytics/metrics/jdbc/SQLMetrics.java @@ -74,10 +74,10 @@ protected void deleteMetric(Class table, .whereIgnoreNull(MonthlyMetric.MONTH, month) .whereIgnoreNull(DailyMetric.DAY, day) .executeUpdate(); - } catch (SQLException e) { + } catch (SQLException exception) { throw Exceptions.handle() .to(Mixing.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to delete a metric in %s: %s (%s)", table) .handle(); } @@ -104,10 +104,10 @@ protected boolean updateMetric(Class table, .executeUpdate(); return numModified > 0; - } catch (SQLException e) { + } catch (SQLException exception) { throw Exceptions.handle() .to(Mixing.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to update a metric in %s: %s (%s)", table) .handle(); } @@ -190,8 +190,8 @@ protected Optional queryMetric(Class table, .asSQLQuery() .first() .map(row -> row.getValue(Fact.VALUE).asInt(0)); - } catch (SQLException ex) { - throw Exceptions.handle(OMA.LOG, ex); + } catch (SQLException exception) { + throw Exceptions.handle(OMA.LOG, exception); } } } diff --git a/src/main/java/sirius/biz/analytics/scheduler/AnalyticalEngine.java b/src/main/java/sirius/biz/analytics/scheduler/AnalyticalEngine.java index 3c55c5e3d..f13f24313 100644 --- a/src/main/java/sirius/biz/analytics/scheduler/AnalyticalEngine.java +++ b/src/main/java/sirius/biz/analytics/scheduler/AnalyticalEngine.java @@ -8,12 +8,18 @@ package sirius.biz.analytics.scheduler; +import sirius.biz.analytics.checks.DailyCheck; import sirius.biz.analytics.flags.ExecutionFlags; +import sirius.biz.analytics.metrics.DailyMetricComputer; +import sirius.biz.analytics.metrics.MonthlyLargeMetricComputer; +import sirius.biz.analytics.metrics.MonthlyMetricComputer; import sirius.biz.cluster.work.DistributedTaskExecutor; import sirius.biz.cluster.work.DistributedTasks; import sirius.kernel.async.Tasks; import sirius.kernel.commons.Explain; import sirius.kernel.commons.Json; +import sirius.kernel.commons.MultiMap; +import sirius.kernel.di.GlobalContext; import sirius.kernel.di.PartCollection; import sirius.kernel.di.std.Part; import sirius.kernel.di.std.Parts; @@ -89,6 +95,9 @@ public class AnalyticalEngine implements EveryDay { @Part private DistributedTasks cluster; + @Part + private GlobalContext globalContext; + /** * Contains the implementation which stores which scheduler was executed when. *

@@ -102,6 +111,11 @@ public class AnalyticalEngine implements EveryDay { private PartCollection schedulers; private List activeSchedulers; + private MultiMap, AnalyticalTask> dailyChecks; + private MultiMap, AnalyticalTask> dailyMetricComputers; + private MultiMap, AnalyticalTask> monthlyMetricComputers; + private MultiMap, AnalyticalTask> monthlyLargeMetricComputers; + @Override public String getConfigKeyName() { return "analytical-engine"; @@ -114,7 +128,12 @@ public void runTimer() throws Exception { } } - protected List getActiveSchedulers() { + /** + * Returns a list of all active {@linkplain AnalyticsScheduler schedulers}. + * + * @return a list of all active schedulers + */ + public List getActiveSchedulers() { if (activeSchedulers == null) { initialize(); } @@ -122,6 +141,70 @@ protected List getActiveSchedulers() { return Collections.unmodifiableList(activeSchedulers); } + /** + * Returns a map of all active {@linkplain DailyCheck daily checks} grouped by the entity type they are working on. + * + * @return a map of all active daily checks + */ + public MultiMap, AnalyticalTask> getDailyChecks() { + if (dailyChecks == null) { + dailyChecks = collectEnabledTasks(DailyCheck.class); + } + return dailyChecks; + } + + /** + * Returns a map of all active {@linkplain DailyMetricComputer daily metric computers} grouped by the entity type they are working on. + * + * @return a map of all active daily metric computers + */ + public MultiMap, AnalyticalTask> getDailyMetricComputers() { + if (dailyMetricComputers == null) { + dailyMetricComputers = collectEnabledTasks(DailyMetricComputer.class); + } + return dailyMetricComputers; + } + + /** + * Returns a map of all active {@linkplain MonthlyMetricComputer monthly metric computers} grouped by the entity type they are working on. + * + * @return a map of all active monthly metric computers + */ + public MultiMap, AnalyticalTask> getMonthlyMetricComputers() { + if (monthlyMetricComputers == null) { + monthlyMetricComputers = collectEnabledTasks(MonthlyMetricComputer.class); + } + return monthlyMetricComputers; + } + + /** + * Returns a map of all active {@linkplain MonthlyLargeMetricComputer monthly large metric computers} grouped by the entity type they are working on. + * + * @return a map of all active monthly large metric computers + */ + public MultiMap, AnalyticalTask> getMonthlyLargeMetricComputers() { + if (monthlyLargeMetricComputers == null) { + monthlyLargeMetricComputers = collectEnabledTasks(MonthlyLargeMetricComputer.class); + } + return monthlyLargeMetricComputers; + } + + /** + * Collects all enabled tasks of the given type. + * + * @param taskType the type of tasks to collect + * @return a map of all enabled tasks of the given type + */ + @SuppressWarnings("unchecked") + private MultiMap, AnalyticalTask> collectEnabledTasks(Class taskType) { + MultiMap, AnalyticalTask> result = MultiMap.create(); + globalContext.getParts((Class>) taskType) + .stream() + .filter(AnalyticalTask::isEnabled) + .forEach(task -> result.put(task.getType(), task)); + return result; + } + protected void initialize() { activeSchedulers = schedulers.getParts().stream().filter(AnalyticsScheduler::isActive).toList(); @@ -264,7 +347,7 @@ private boolean shouldExecuteAgain(AnalyticsScheduler scheduler) { * @param scheduler the scheduler to check the last execution for * @return the last execution timestamp or an empty optional */ - protected Optional getLastExecution(AnalyticsScheduler scheduler) { + public Optional getLastExecution(AnalyticsScheduler scheduler) { return flags.readExecutionFlag(computeExecutionFlagName(scheduler), EXECUTION_FLAG); } } diff --git a/src/main/java/sirius/biz/analytics/scheduler/AnalyticalTask.java b/src/main/java/sirius/biz/analytics/scheduler/AnalyticalTask.java index 91ceafb9f..6bacd62aa 100644 --- a/src/main/java/sirius/biz/analytics/scheduler/AnalyticalTask.java +++ b/src/main/java/sirius/biz/analytics/scheduler/AnalyticalTask.java @@ -9,6 +9,7 @@ package sirius.biz.analytics.scheduler; import sirius.db.mixing.BaseEntity; +import sirius.kernel.health.Average; import java.time.LocalDate; @@ -60,6 +61,32 @@ public interface AnalyticalTask> { */ int getLevel(); + /** + * Tracks the duration of the last computation. + * + * @param durationMillis the duration of the last computation in milliseconds + */ + void trackDuration(long durationMillis); + + /** + * Resets the currently kept average and maximum durations. + */ + void resetDurations(); + + /** + * Returns the maximum duration of computations in milliseconds. + * + * @return the maximum duration of computations in milliseconds + */ + long getMaxDurationMillis(); + + /** + * Returns the average duration of computations in milliseconds. + * + * @return the average duration of computations in milliseconds + */ + Average getAvgDurationMillis(); + /** * Executes the analytical task for the given entity and reference date. *

diff --git a/src/main/java/sirius/biz/analytics/scheduler/BaseAnalyticalTaskScheduler.java b/src/main/java/sirius/biz/analytics/scheduler/BaseAnalyticalTaskScheduler.java index 0e6aefdb9..a2a974cf5 100644 --- a/src/main/java/sirius/biz/analytics/scheduler/BaseAnalyticalTaskScheduler.java +++ b/src/main/java/sirius/biz/analytics/scheduler/BaseAnalyticalTaskScheduler.java @@ -172,10 +172,10 @@ private void executeTaskForEntity(B entity, Class type, LocalDate date, Analy Watch watch = Watch.start(); try { ((AnalyticalTask) task).compute(date, entity, useBestEffortScheduling()); - } catch (Exception ex) { + } catch (Exception exception) { Exceptions.handle() .to(AnalyticalEngine.LOG) - .error(ex) + .error(exception) .withSystemErrorMessage("The analytical task %s for entity %s (%s) failed: %s (%s)", task.getClass().getName(), entity == null ? "-" : entity.getIdAsString(), @@ -190,6 +190,7 @@ private void executeTaskForEntity(B entity, Class type, LocalDate date, Analy getName(), watch.duration()); } + task.trackDuration(watch.elapsedMillis()); if (Microtiming.isEnabled()) { watch.submitMicroTiming(AnalyticalEngine.MICROTIMING_KEY_ANALYTICS, Strings.apply("Executed task '%s' for '%s'", diff --git a/src/main/java/sirius/biz/analytics/scheduler/MongoAnalyticalTaskScheduler.java b/src/main/java/sirius/biz/analytics/scheduler/MongoAnalyticalTaskScheduler.java index 511c9c5c7..66fd444c4 100644 --- a/src/main/java/sirius/biz/analytics/scheduler/MongoAnalyticalTaskScheduler.java +++ b/src/main/java/sirius/biz/analytics/scheduler/MongoAnalyticalTaskScheduler.java @@ -52,8 +52,8 @@ protected void scheduleBatches(Class type, Consumer type, Consumer out.property(RESPONSE_KEY, key)); - out.endArray(); + .forEach(key -> output.property(RESPONSE_KEY, key)); + output.endArray(); } /** * Reports all autocreated NLS keys. * * @param webContext the request to handle - * @param out the output to write the JSON to + * @param output the output to write the JSON to * @param token the cluster authentication token */ @Routed("/system/nls/autocreated/:1") @InternalService - public void autocreated(WebContext webContext, JSONStructuredOutput out, String token) { + public void autocreated(WebContext webContext, JSONStructuredOutput output, String token) { if (!clusterManager.isClusterAPIToken(token)) { webContext.respondWith().error(HttpResponseStatus.UNAUTHORIZED); return; } - out.beginArray(RESPONSE_AUTOCREATED); + output.beginArray(RESPONSE_AUTOCREATED); NLS.getTranslationEngine() .getAutocreatedTranslations() .map(Translation::getKey) - .forEach(key -> out.property(RESPONSE_KEY, key)); - out.endArray(); + .forEach(key -> output.property(RESPONSE_KEY, key)); + output.endArray(); } } diff --git a/src/main/java/sirius/biz/cluster/NeighborhoodWatch.java b/src/main/java/sirius/biz/cluster/NeighborhoodWatch.java index da093ed2f..971d35683 100644 --- a/src/main/java/sirius/biz/cluster/NeighborhoodWatch.java +++ b/src/main/java/sirius/biz/cluster/NeighborhoodWatch.java @@ -143,8 +143,8 @@ public void handleEvent(ObjectNode event) { private boolean isBackgroundJobGloballyEnabled(String name) { try { return globallyEnabledState.computeIfAbsent(name, this::readGlobalState); - } catch (Exception e) { - Exceptions.handle(Cluster.LOG, e); + } catch (Exception exception) { + Exceptions.handle(Cluster.LOG, exception); return true; } } @@ -159,8 +159,8 @@ private boolean readGlobalState(String name) { db -> db.get(name + EXECUTION_ENABLED_SUFFIX)); return !STATE_DISABLED.equals(value); - } catch (Exception e) { - Exceptions.handle(Cluster.LOG, e); + } catch (Exception exception) { + Exceptions.handle(Cluster.LOG, exception); return true; } } @@ -275,8 +275,8 @@ public void backgroundLoopCompleted(String name, String executionInfo) { } executionInfos.put(syncName, executionInfo); - } catch (Exception e) { - Exceptions.handle(Cluster.LOG, e); + } catch (Exception exception) { + Exceptions.handle(Cluster.LOG, exception); } } @@ -336,8 +336,8 @@ private boolean shouldRunClusteredDailyTask(String syncName) { return false; } }); - } catch (Exception e) { - Exceptions.handle(Cluster.LOG, e); + } catch (Exception exception) { + Exceptions.handle(Cluster.LOG, exception); return false; } } @@ -413,7 +413,7 @@ private void loadAndStoreSetting(String key, Map target Value setting = Sirius.getSettings().get("orchestration." + key); try { targetMap.put(key, SynchronizeType.valueOf(setting.toUpperCase())); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException exception) { Cluster.LOG.WARN("Invalid configuration found for orchestration." + key + ": " + setting); targetMap.put(key, SynchronizeType.LOCAL); } diff --git a/src/main/java/sirius/biz/cluster/work/DistributedTaskExecutorLoadAction.java b/src/main/java/sirius/biz/cluster/work/DistributedTaskExecutorLoadAction.java index dc2721759..843a9d130 100644 --- a/src/main/java/sirius/biz/cluster/work/DistributedTaskExecutorLoadAction.java +++ b/src/main/java/sirius/biz/cluster/work/DistributedTaskExecutorLoadAction.java @@ -46,11 +46,11 @@ public void handle(@Nonnull MutableGlobalContext mutableGlobalContext, @Nonnull mutableGlobalContext.registerPart(anInstance.getClass().getName(), anInstance, DistributedTaskExecutor.class); - } catch (Exception e) { + } catch (Exception exception) { Injector.LOG.WARN("Cannot register %s as DistributedTaskExecutor: %s (%s)", aClass.getName(), - e.getMessage(), - e.getClass().getName()); + exception.getMessage(), + exception.getClass().getName()); } } } diff --git a/src/main/java/sirius/biz/cluster/work/DistributedTasks.java b/src/main/java/sirius/biz/cluster/work/DistributedTasks.java index 7cc39e33a..dfc0ef00d 100644 --- a/src/main/java/sirius/biz/cluster/work/DistributedTasks.java +++ b/src/main/java/sirius/biz/cluster/work/DistributedTasks.java @@ -169,10 +169,10 @@ protected void execute() { private void tryExecute(DistributedTaskExecutor exec) { try { exec.executeWork(task); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage( "The DistributedTaskExecutor '%s' failed with: %s (%s) for the task '%s'", exec.getClass().getName(), @@ -195,8 +195,8 @@ private void releasePenaltyToken(@Nonnull String queue, @Nullable String penalty if (Strings.isFilled(penaltyToken) && penaltyTokens != null) { penaltyTokens.decrementAndGet(queue + "-" + penaltyToken); } - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); } } } @@ -502,8 +502,8 @@ private DistributedTask tryToPullWork(DistributedQueueInfo queue) { if (task != null) { return new DistributedTask(queue, task); } - } catch (Exception e) { - Exceptions.handle(LOG, e); + } catch (Exception exception) { + Exceptions.handle(LOG, exception); } // Release the concurrency token acquired above, as we didn't yield any task... diff --git a/src/main/java/sirius/biz/cluster/work/RedisNamedCounters.java b/src/main/java/sirius/biz/cluster/work/RedisNamedCounters.java index 361e0a7eb..c5e4a642c 100644 --- a/src/main/java/sirius/biz/cluster/work/RedisNamedCounters.java +++ b/src/main/java/sirius/biz/cluster/work/RedisNamedCounters.java @@ -53,7 +53,7 @@ private Optional readCounter(Jedis db, String counter) { } else { try { return Optional.of(Long.parseLong(value)); - } catch (NumberFormatException e) { + } catch (NumberFormatException exception) { Exceptions.handle() .to(Log.BACKGROUND) .withSystemErrorMessage("Failed to parse counter value '%s' in counter '%s' of '%s'", diff --git a/src/main/java/sirius/biz/cluster/work/WorkLoaderLoop.java b/src/main/java/sirius/biz/cluster/work/WorkLoaderLoop.java index ed028ad38..c0db60833 100644 --- a/src/main/java/sirius/biz/cluster/work/WorkLoaderLoop.java +++ b/src/main/java/sirius/biz/cluster/work/WorkLoaderLoop.java @@ -90,7 +90,7 @@ private void locked(Runnable runInLock) { schedulerLock.unlock(); } } - } catch (InterruptedException e) { + } catch (InterruptedException exception) { Thread.currentThread().interrupt(); } } diff --git a/src/main/java/sirius/biz/codelists/CodeListController.java b/src/main/java/sirius/biz/codelists/CodeListController.java index c65d3d62a..0ec3069e2 100644 --- a/src/main/java/sirius/biz/codelists/CodeListController.java +++ b/src/main/java/sirius/biz/codelists/CodeListController.java @@ -47,17 +47,17 @@ public abstract class CodeListController pageHelper = getListsAsPage(); - pageHelper.withContext(ctx); + pageHelper.withContext(webContext); applyCodeListSearchFields(pageHelper); - ctx.respondWith().template("/templates/biz/codelists/code-lists.html.pasta", pageHelper.asPage()); + webContext.respondWith().template("/templates/biz/codelists/code-lists.html.pasta", pageHelper.asPage()); } protected abstract BasePageHelper getListsAsPage(); @@ -65,48 +65,48 @@ public void codeLists(WebContext ctx) { /** * Provides an editor for a code list. * - * @param ctx the current request + * @param webContext the current request * @param codeListId the id of the code list */ @LoginRequired @Permission(PERMISSION_MANAGE_CODELISTS) @Routed("/code-list/:1") - public void codeList(WebContext ctx, String codeListId) { - codeListHandler(ctx, codeListId, false); + public void codeList(WebContext webContext, String codeListId) { + codeListHandler(webContext, codeListId, false); } /** * Provides an editor for a code list. * - * @param ctx the current request + * @param webContext the current request * @param codeListId the id of the code list */ @LoginRequired @Permission(PERMISSION_MANAGE_CODELISTS) @Routed("/code-list/:1/details") - public void codeListDetails(WebContext ctx, String codeListId) { - codeListHandler(ctx, codeListId, true); + public void codeListDetails(WebContext webContext, String codeListId) { + codeListHandler(webContext, codeListId, true); } - private void codeListHandler(WebContext ctx, String codeListId, boolean forceDetails) { + private void codeListHandler(WebContext webContext, String codeListId, boolean forceDetails) { L codeList = findForTenant(codeLists.getListType(), codeListId); if (codeList.isNew() || forceDetails) { boolean requestHandled = - prepareSave(ctx).withAfterCreateURI("/code-list/${id}/details").saveEntity(codeList); + prepareSave(webContext).withAfterCreateURI("/code-list/${id}/details").saveEntity(codeList); if (!requestHandled) { - ctx.respondWith().template("/templates/biz/codelists/code-list-details.html.pasta", codeList); + webContext.respondWith().template("/templates/biz/codelists/code-list-details.html.pasta", codeList); } } else { - renderCodeList(ctx, codeList); + renderCodeList(webContext, codeList); } } - private void renderCodeList(WebContext ctx, L codeList) { + private void renderCodeList(WebContext webContext, L codeList) { BasePageHelper pageHelper = getEntriesAsPage(codeList); - pageHelper.withContext(ctx); + pageHelper.withContext(webContext); applyCodeListEntrySearchFields(pageHelper); - ctx.respondWith() + webContext.respondWith() .template("/templates/biz/codelists/code-list-entries.html.pasta", codeList, pageHelper.asPage()); } @@ -145,33 +145,33 @@ public void codeListEntry(WebContext webContext, String codeListId, String entry /** * Deletes a code list. * - * @param ctx the current request + * @param webContext the current request * @param codeListId the code list to delete */ @LoginRequired @Permission(PERMISSION_MANAGE_CODELISTS) @Routed("/code-list/:1/delete") - public void deleteCodeList(WebContext ctx, String codeListId) { + public void deleteCodeList(WebContext webContext, String codeListId) { L cl = tryFindForTenant(codeLists.getListType(), codeListId).orElse(null); if (cl != null) { cl.getMapper().delete(cl); showDeletedMessage(); } - ctx.respondWith().redirectToGet("/code-lists"); + webContext.respondWith().redirectToGet("/code-lists"); } /** * Deletes a code list entry. * - * @param ctx the current request + * @param webContext the current request * @param codeListId the code list of the entry * @param entryId the entry to delete */ @LoginRequired @Permission(PERMISSION_MANAGE_CODELISTS) @Routed("/code-list/:1/delete-entry/:2") - public void deleteCodeListEntry(WebContext ctx, String codeListId, String entryId) { + public void deleteCodeListEntry(WebContext webContext, String codeListId, String entryId) { L cl = findForTenant(codeLists.getListType(), codeListId); assertNotNew(cl); @@ -181,7 +181,7 @@ public void deleteCodeListEntry(WebContext ctx, String codeListId, String entryI showDeletedMessage(); } - renderCodeList(ctx, cl); + renderCodeList(webContext, cl); } /** diff --git a/src/main/java/sirius/biz/codelists/CodeLists.java b/src/main/java/sirius/biz/codelists/CodeLists.java index 156ef942e..ffe4a7f48 100644 --- a/src/main/java/sirius/biz/codelists/CodeLists.java +++ b/src/main/java/sirius/biz/codelists/CodeLists.java @@ -163,8 +163,8 @@ private L createCodeList(@Nonnull Tenant tenant, String codeListName) { codeList.getCodeListData().setCode(codeListName); codeList.getCodeListData().setName(codeListName); return codeList; - } catch (Exception e) { - throw Exceptions.handle(LOG, e); + } catch (Exception exception) { + throw Exceptions.handle(LOG, exception); } } @@ -373,8 +373,8 @@ protected E createEntry(L codeList, String code) { entry.getCodeListEntryData().setCode(code); entry.getCodeListEntryData().getValue().setFallback(code); return entry; - } catch (Exception e) { - throw Exceptions.handle(LOG, e); + } catch (Exception exception) { + throw Exceptions.handle(LOG, exception); } } diff --git a/src/main/java/sirius/biz/codelists/IDBFilteredLookupTable.java b/src/main/java/sirius/biz/codelists/IDBFilteredLookupTable.java index 68e7e891d..d57c5694a 100644 --- a/src/main/java/sirius/biz/codelists/IDBFilteredLookupTable.java +++ b/src/main/java/sirius/biz/codelists/IDBFilteredLookupTable.java @@ -140,10 +140,10 @@ protected Stream performQuery(String language, String lookupPa public int count() { try { return jupiter.fetchFromSmallCache(CACHE_PREFIX_CARDINALITY + filterSet.getName(), filterSet::size); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to fetch entry count of set '%s': %s (%s)", filterSet.getName()) .handle(); return 0; diff --git a/src/main/java/sirius/biz/codelists/IDBLookupTable.java b/src/main/java/sirius/biz/codelists/IDBLookupTable.java index decb1139b..6987563df 100644 --- a/src/main/java/sirius/biz/codelists/IDBLookupTable.java +++ b/src/main/java/sirius/biz/codelists/IDBLookupTable.java @@ -114,10 +114,10 @@ protected Value performFetchField(String code, String targetField) { .map(row -> row.at(0)) .filter(Value::isFilled) .orElse(Value.EMPTY)); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Error on fetch field with code '%s' field '%s' table '%s': %s (%s)", code, targetField, @@ -145,10 +145,10 @@ protected Optional performFetchTranslatedField(String code, String targe .singleRow(targetField) .map(row -> row.at(0).asString()) .filter(Strings::isFilled)); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Error on fetch translated field with code '%s' field '%s' lang '%s' table '%s': %s (%s)", code, @@ -170,10 +170,10 @@ protected Optional performNormalize(String code) { .singleRow(codeField) .map(row -> row.at(0).asString()) .filter(Strings::isFilled)); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Error on normalize code '%s' table '%s': %s (%s)", code, table.getName()) .handle(); return Optional.empty(); @@ -195,10 +195,10 @@ protected Optional performNormalizeWithMapping(String code, String mappi .singleRow(codeField) .map(row -> row.at(0).asString()) .filter(Strings::isFilled)); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Error on normalize code '%s' mapping '%s' table '%s': %s (%s)", code, mapping, @@ -218,10 +218,10 @@ protected Optional performReverseLookup(String name) { .singleRow(codeField) .map(row -> row.at(0).asString()) .filter(Strings::isFilled)); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Error on reverse lookup name '%s' table '%s': %s (%s)", name, table.getName()) @@ -247,10 +247,10 @@ private Optional fetchObjectFromIDB(Class type, String code) { .searchValue(code) .singleRow(COL_SOURCE) .map(row -> makeObject(type, Json.parseObject(row.at(0).asString()))); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Error on fetch object type '%s' code '%s' table '%s': %s (%s)", type.getName(), code, @@ -264,10 +264,10 @@ protected T makeObject(Class type, ObjectNode jsonData) { try { Constructor constructor = type.getConstructor(ObjectNode.class); return constructor.newInstance(jsonData); - } catch (Exception e) { + } catch (Exception exception) { throw new IllegalArgumentException( "Cannot create a payload object for %s - A public accessible constructor accepting a value is required!", - e); + exception); } } @@ -283,10 +283,10 @@ protected Stream performSuggest(Limit limit, String searchTerm .map(row -> new LookupTableEntry(row.at(0).asString(), row.at(1).asString(), row.at(2).getString())); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Error on suggest searchterm '%s' lang '%s' table '%s': %s (%s)", searchTerm, language, @@ -303,10 +303,10 @@ public Stream scan(String language, Limit limit) { .translate(language) .manyRows(limit, codeField, nameField, descriptionField, COL_DEPRECATED, COL_SOURCE) .map(this::processSearchOrScanRow); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Error scanning lang '%s' table '%s': %s (%s)", language, table.getName()) .handle(); return Stream.empty(); @@ -322,10 +322,10 @@ public Stream performSearch(String searchTerm, Limit limit, St .translate(language) .manyRows(limit, codeField, nameField, descriptionField, COL_DEPRECATED, COL_SOURCE) .map(this::processSearchOrScanRow); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Error scanning lang '%s' table '%s': %s (%s)", language, table.getName()) .handle(); return Stream.empty(); @@ -341,8 +341,8 @@ private LookupTableEntry processSearchOrScanRow(Values row) { if (row.at(4).isFilled()) { try { entry.withSource(Json.parseObject(row.at(4).asString())); - } catch (Exception e) { - Exceptions.ignore(e); + } catch (Exception exception) { + Exceptions.ignore(exception); } } @@ -353,10 +353,10 @@ private LookupTableEntry processSearchOrScanRow(Values row) { public int count() { try { return jupiter.fetchFromSmallCache(CACHE_PREFIX_COUNT + table.getName(), table::size); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to fetch entry count of table '%s': %s (%s)", table.getName()) .handle(); return 0; @@ -375,10 +375,10 @@ protected Stream performQuery(String language, String lookupPa .map(row -> new LookupTableEntry(row.at(0).asString(), row.at(1).asString(), row.at(2).getString())); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.createHandled() .to(Jupiter.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Error on lookup scan lang '%s' lookupPath '%s' lookupValue '%s' table '%s': %s (%s)", language, diff --git a/src/main/java/sirius/biz/codelists/LookupValuesProperty.java b/src/main/java/sirius/biz/codelists/LookupValuesProperty.java index 9f9fe34f1..091c7b08b 100644 --- a/src/main/java/sirius/biz/codelists/LookupValuesProperty.java +++ b/src/main/java/sirius/biz/codelists/LookupValuesProperty.java @@ -85,10 +85,10 @@ protected LookupValues getLookupValues(Object entity) { Object target = accessPath.apply(entity); try { return (LookupValues) field.get(target); - } catch (IllegalAccessException e) { + } catch (IllegalAccessException exception) { throw Exceptions.handle() .to(Mixing.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Cannot read property '%s' (from '%s'): %s (%s)", getName(), getDefinition()) diff --git a/src/main/java/sirius/biz/elastic/AutoBatchLoop.java b/src/main/java/sirius/biz/elastic/AutoBatchLoop.java index c61ec2077..bc05354ed 100644 --- a/src/main/java/sirius/biz/elastic/AutoBatchLoop.java +++ b/src/main/java/sirius/biz/elastic/AutoBatchLoop.java @@ -139,8 +139,8 @@ private int executeBatchInsert() { } entity = entities.poll(); } - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); frozenUntil = LocalDateTime.now().plusSeconds(10); } diff --git a/src/main/java/sirius/biz/elastic/MoveIndexAliasJobFactory.java b/src/main/java/sirius/biz/elastic/MoveIndexAliasJobFactory.java index 63fe50ddc..4d1fdc93a 100644 --- a/src/main/java/sirius/biz/elastic/MoveIndexAliasJobFactory.java +++ b/src/main/java/sirius/biz/elastic/MoveIndexAliasJobFactory.java @@ -73,10 +73,10 @@ protected String createProcessTitle(Map context) { return Strings.apply("Moving active Elasticsearch alias from index '%s' to '%s'", elastic.determineEffectiveIndex(entityDescriptorParameter.require(context)), destinationParameter.require(context)); - } catch (HandledException e) { + } catch (HandledException exception) { // In some rare cases, this might fail (if the system is inconsistent anyway). In this case // we prefer that the job fails rather than the setup / start crashes... - Exceptions.ignore(e); + Exceptions.ignore(exception); return Strings.apply("Moving active Elasticsearch alias to '%s'", destinationParameter.require(context)); } } diff --git a/src/main/java/sirius/biz/ide/Scripting.java b/src/main/java/sirius/biz/ide/Scripting.java index 47de50105..c6e114632 100644 --- a/src/main/java/sirius/biz/ide/Scripting.java +++ b/src/main/java/sirius/biz/ide/Scripting.java @@ -209,10 +209,10 @@ private void handleExecTask(ObjectNode event) { if (tenants != null) { try { tenants.runAsAdmin(() -> handleTaskForNode(event, jobNumber)); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(Log.SYSTEM) - .error(e) + .error(exception) .withSystemErrorMessage("A fatal error occurred in task %s: %s (%s)", jobNumber) .handle(); } @@ -234,10 +234,10 @@ private void handleTaskForNode(ObjectNode event, String jobNumber) { TaskContext.get().setAdapter(new JobTaskContextAdapter(this, jobNumber)); callable.call(new SimpleEnvironment()); - } catch (CompileException | ScriptingException | HandledException e) { - logInTranscript(jobNumber, e.getMessage()); - } catch (Exception e) { - logInTranscript(jobNumber, Exceptions.handle(Pasta.LOG, e).getMessage()); + } catch (CompileException | ScriptingException | HandledException exception) { + logInTranscript(jobNumber, exception.getMessage()); + } catch (Exception exception) { + logInTranscript(jobNumber, Exceptions.handle(Pasta.LOG, exception).getMessage()); } logInTranscript(jobNumber, Strings.apply("Execution completed (%s)", watch.duration())); diff --git a/src/main/java/sirius/biz/ide/ScriptingController.java b/src/main/java/sirius/biz/ide/ScriptingController.java index fad0c7809..45a9a1a38 100644 --- a/src/main/java/sirius/biz/ide/ScriptingController.java +++ b/src/main/java/sirius/biz/ide/ScriptingController.java @@ -132,8 +132,8 @@ public void submit(WebContext webContext, JSONStructuredOutput output) throws Ex output.property(RESPONSE_JOB_MESSAGE, NLS.fmtr("ScriptingController.jobMessage").set(RESPONSE_JOB, jobNumber).format()); } - } catch (CompileException e) { - throw Exceptions.createHandled().withDirectMessage(e.getMessage()).handle(); + } catch (CompileException exception) { + throw Exceptions.createHandled().withDirectMessage(exception.getMessage()).handle(); } } diff --git a/src/main/java/sirius/biz/importer/BaseImportHandler.java b/src/main/java/sirius/biz/importer/BaseImportHandler.java index f350d2f2b..3c623e078 100644 --- a/src/main/java/sirius/biz/importer/BaseImportHandler.java +++ b/src/main/java/sirius/biz/importer/BaseImportHandler.java @@ -374,9 +374,9 @@ public E newEntity() { try { return (E) descriptor.getType().getConstructor().newInstance(); } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | - IllegalAccessException e) { + IllegalAccessException exception) { throw Exceptions.handle() - .error(e) + .error(exception) .withSystemErrorMessage("Cannot create an instance of: %s", descriptor.getType().getName()) .handle(); } diff --git a/src/main/java/sirius/biz/importer/Importer.java b/src/main/java/sirius/biz/importer/Importer.java index a3fbee1e6..625e9a308 100644 --- a/src/main/java/sirius/biz/importer/Importer.java +++ b/src/main/java/sirius/biz/importer/Importer.java @@ -81,9 +81,10 @@ public > E load(Class type, Context data) { try { E entity = type.getConstructor().newInstance(); return load(type, data, entity); - } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | + IllegalAccessException exception) { throw Exceptions.handle() - .error(e) + .error(exception) .withSystemErrorMessage("Cannot create an instance of: %s", type.getName()) .handle(); } diff --git a/src/main/java/sirius/biz/importer/ImporterContext.java b/src/main/java/sirius/biz/importer/ImporterContext.java index 7005edc3e..5a628b5da 100644 --- a/src/main/java/sirius/biz/importer/ImporterContext.java +++ b/src/main/java/sirius/biz/importer/ImporterContext.java @@ -130,7 +130,7 @@ public H findHelper(Class type) { private ImportHelper instantiateHelper(Class aClass) { try { return (ImportHelper) aClass.getConstructor(ImporterContext.class).newInstance(this); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .withSystemErrorMessage("Cannot find or create the import helper of type: %s", aClass) .handle(); @@ -164,10 +164,10 @@ public Cache, String>, Object> getLocalCache() { protected void close() throws IOException { try { commit(); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(Importer.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("An error occurred while commiting an ImporterContext: %s (%s)") .handle(); } diff --git a/src/main/java/sirius/biz/importer/SQLEntityImportHandler.java b/src/main/java/sirius/biz/importer/SQLEntityImportHandler.java index d9997e646..f7f7903b8 100644 --- a/src/main/java/sirius/biz/importer/SQLEntityImportHandler.java +++ b/src/main/java/sirius/biz/importer/SQLEntityImportHandler.java @@ -144,7 +144,7 @@ protected List getMappingsToCompare() { */ protected Collection getMappingsToLoadForFind() { return findQueries.stream() - .flatMap(qry -> qry.getSecond().get().getFilterMappings().stream().map(Mapping::named)) + .flatMap(query -> query.getSecond().get().getFilterMappings().stream().map(Mapping::named)) .collect(Collectors.toSet()); } diff --git a/src/main/java/sirius/biz/importer/format/DateTimeFormatCheck.java b/src/main/java/sirius/biz/importer/format/DateTimeFormatCheck.java index f5f1efc7a..81a03d647 100644 --- a/src/main/java/sirius/biz/importer/format/DateTimeFormatCheck.java +++ b/src/main/java/sirius/biz/importer/format/DateTimeFormatCheck.java @@ -61,7 +61,7 @@ public void perform(Value value) { String stringValue = value.asString(); try { LocalDate.parse(stringValue, formatter); - } catch (DateTimeParseException e) { + } catch (DateTimeParseException exception) { throw new IllegalArgumentException(NLS.fmtr("DateTimeFormatCheck.errorMsg") .set("value", stringValue) .set("format", format) diff --git a/src/main/java/sirius/biz/importer/format/ImportDictionary.java b/src/main/java/sirius/biz/importer/format/ImportDictionary.java index e4b020ccf..3211ae402 100644 --- a/src/main/java/sirius/biz/importer/format/ImportDictionary.java +++ b/src/main/java/sirius/biz/importer/format/ImportDictionary.java @@ -539,21 +539,21 @@ public boolean detectRecordProblems(Function record, BiConsumer & ImportTransactionalEntity> void deleteUnmar Object value, @Nullable Consumer entityCallback) { - deleteUnmarked(entityType, qry -> qry.eq(field, value), entityCallback); + deleteUnmarked(entityType, query -> query.eq(field, value), entityCallback); } /** diff --git a/src/main/java/sirius/biz/isenguard/Isenguard.java b/src/main/java/sirius/biz/isenguard/Isenguard.java index 53bbbef7b..ded335410 100644 --- a/src/main/java/sirius/biz/isenguard/Isenguard.java +++ b/src/main/java/sirius/biz/isenguard/Isenguard.java @@ -97,12 +97,12 @@ public class Isenguard { public boolean isIPBlacklisted(String ipAddress) { try { return limiter != null && limiter.isIPBLacklisted(ipAddress); - } catch (Exception e) { + } catch (Exception exception) { // In case of an error e.g. Redis might not be available, // we resort to ignoring any checks and let the application run. // The other option would be to block everything and essentially // shut down the application, which isn't feasible either... - Exceptions.handle(LOG, e); + Exceptions.handle(LOG, exception); return false; } } @@ -218,12 +218,12 @@ public boolean isRateLimitReached(String scope, limitReachedOnce.run(); } }); - } catch (Exception e) { + } catch (Exception exception) { // In case of an error e.g. Redis might not be available, // we resort to ignoring any limits and let the application run. // The other option would be to block everything and essentially // shut down the application, which isn't feasible either... - Exceptions.handle(LOG, e); + Exceptions.handle(LOG, exception); return false; } } diff --git a/src/main/java/sirius/biz/isenguard/IsenguardFirewall.java b/src/main/java/sirius/biz/isenguard/IsenguardFirewall.java index 87f59faf8..b2477ec73 100644 --- a/src/main/java/sirius/biz/isenguard/IsenguardFirewall.java +++ b/src/main/java/sirius/biz/isenguard/IsenguardFirewall.java @@ -27,23 +27,23 @@ public class IsenguardFirewall implements Firewall { private Isenguard isenguard; @Override - public boolean isIPBlacklisted(WebContext ctx) { - return isenguard.isIPBlacklisted(ctx.getRemoteIP().getHostAddress()); + public boolean isIPBlacklisted(WebContext webContext) { + return isenguard.isIPBlacklisted(webContext.getRemoteIP().getHostAddress()); } @Override - public boolean handleRateLimiting(WebContext ctx, String realm) { - String ip = ctx.getRemoteIP().getHostAddress(); + public boolean handleRateLimiting(WebContext webContext, String realm) { + String ip = webContext.getRemoteIP().getHostAddress(); boolean rateLimitReached = isenguard.isRateLimitReached(ip, realm, Isenguard.USE_LIMIT_FROM_CONFIG, - () -> RateLimitingInfo.fromWebContext(ctx, null)); + () -> RateLimitingInfo.fromWebContext(webContext, + null)); if (rateLimitReached) { - ctx.respondWith().error(HttpResponseStatus.TOO_MANY_REQUESTS); + webContext.respondWith().error(HttpResponseStatus.TOO_MANY_REQUESTS); return true; } return false; } } - diff --git a/src/main/java/sirius/biz/isenguard/RateLimitingInfo.java b/src/main/java/sirius/biz/isenguard/RateLimitingInfo.java index 1148c2bd6..b14352f88 100644 --- a/src/main/java/sirius/biz/isenguard/RateLimitingInfo.java +++ b/src/main/java/sirius/biz/isenguard/RateLimitingInfo.java @@ -45,12 +45,12 @@ public RateLimitingInfo(@Nullable String ip, @Nullable String tenantId, @Nullabl /** * Boilerplate method to fill the IP and location from the given web context. * - * @param ctx the current request which caused the rate limiting event + * @param webContext the current request which caused the rate limiting event * @param tenantId the tenant id as this is most probably unknown / not determined yet * @return a rate limit info containing the remote IP and URI as location. */ - public static RateLimitingInfo fromWebContext(WebContext ctx, @Nullable String tenantId) { - return new RateLimitingInfo(ctx.getRemoteIP().getHostAddress(), tenantId, ctx.getRequestedURI()); + public static RateLimitingInfo fromWebContext(WebContext webContext, @Nullable String tenantId) { + return new RateLimitingInfo(webContext.getRemoteIP().getHostAddress(), tenantId, webContext.getRequestedURI()); } /** diff --git a/src/main/java/sirius/biz/jdbc/DatabaseController.java b/src/main/java/sirius/biz/jdbc/DatabaseController.java index 4ed7b993b..27e2787c2 100644 --- a/src/main/java/sirius/biz/jdbc/DatabaseController.java +++ b/src/main/java/sirius/biz/jdbc/DatabaseController.java @@ -84,36 +84,36 @@ public class DatabaseController extends BasicController { /** * Renders the UI to execute SQL queries. * - * @param ctx the current request + * @param webContext the current request */ @Permission(TenantUserManager.PERMISSION_SYSTEM_ADMINISTRATOR) @Routed("/system/sql") @DefaultRoute - public void sql(WebContext ctx) { + public void sql(WebContext webContext) { // Only display selectable databases which are properly configured... List availableDatabases = selectableDatabases.stream().filter(name -> databases.getDatabases().contains(name)).toList(); - ctx.respondWith().template("/templates/biz/model/sql.html.pasta", availableDatabases, defaultDatabase); + webContext.respondWith().template("/templates/biz/model/sql.html.pasta", availableDatabases, defaultDatabase); } /** * Executes the given sql query. * * @param webContext the current request - * @param out the JSON response + * @param output the JSON response * @throws SQLException in case of a database error */ @Permission(TenantUserManager.PERMISSION_SYSTEM_ADMINISTRATOR) @Routed("/system/sql/api/execute") @InternalService - public void executeQuery(WebContext webContext, JSONStructuredOutput out) throws SQLException { + public void executeQuery(WebContext webContext, JSONStructuredOutput output) throws SQLException { Watch w = Watch.start(); try { String database = webContext.get(PARAM_DATABASE).asString(defaultDatabase); Database db = determineDatabase(database); String sqlStatement = webContext.get(PARAM_QUERY).asString(); - SQLQuery qry = db.createQuery(sqlStatement).markAsLongRunning(); + SQLQuery query = db.createQuery(sqlStatement).markAsLongRunning(); OMA.LOG.INFO("Executing SQL (via /system/sql, authored by %s):%n%n%s", UserContext.getCurrentUser().getUserName(), @@ -130,18 +130,18 @@ public void executeQuery(WebContext webContext, JSONStructuredOutput out) throws .handle(); } - out.property("rowModified", qry.executeUpdate()); + output.property("rowModified", query.executeUpdate()); } else if (isModifyStatement(sqlStatement)) { - out.property("rowModified", qry.executeUpdate()); + output.property("rowModified", query.executeUpdate()); } else { Monoflop monoflop = Monoflop.create(); - qry.iterateAll(r -> outputRow(out, monoflop, r), - new Limit(0, webContext.get("limit").asInt(DEFAULT_LIMIT))); + query.iterateAll(r -> outputRow(output, monoflop, r), + new Limit(0, webContext.get("limit").asInt(DEFAULT_LIMIT))); if (monoflop.successiveCall()) { - out.endArray(); + output.endArray(); } } - out.property("duration", w.duration()); + output.property("duration", w.duration()); } catch (SQLException exception) { // In case of an invalid query, we do not want to log this into the syslog but // rather just directly output the message to the user.... @@ -207,83 +207,83 @@ private boolean isModifyStatement(String query) { || lowerCaseQuery.startsWith(KEYWORD_DELETE); } - private boolean isDDLStatement(String qry) { - String lowerCaseQuery = qry.toLowerCase().trim(); + private boolean isDDLStatement(String query) { + String lowerCaseQuery = query.toLowerCase().trim(); return lowerCaseQuery.startsWith(KEYWORD_ALTER) || lowerCaseQuery.startsWith(KEYWORD_DROP) || lowerCaseQuery.startsWith(KEYWORD_CREATE); } - private void outputRow(JSONStructuredOutput out, Monoflop monoflop, Row row) { + private void outputRow(JSONStructuredOutput output, Monoflop monoflop, Row row) { if (monoflop.firstCall()) { - out.beginArray("columns"); + output.beginArray("columns"); for (Tuple col : row.getFieldsList()) { - out.property("column", col.getFirst()); + output.property("column", col.getFirst()); } - out.endArray(); - out.beginArray("rows"); + output.endArray(); + output.beginArray("rows"); } - out.beginArray("row"); + output.beginArray("row"); for (Tuple col : row.getFieldsList()) { - out.property("column", databaseDisplayUtils.formatValueForDisplay(col.getSecond())); + output.property("column", databaseDisplayUtils.formatValueForDisplay(col.getSecond())); } - out.endArray(); + output.endArray(); } /** * Renders the schema list view. * - * @param ctx the current request + * @param webContext the current request */ @Permission(TenantUserManager.PERMISSION_SYSTEM_ADMINISTRATOR) @Routed("/system/schema") - public void changes(WebContext ctx) { - ctx.respondWith().template("/templates/biz/model/schema.html.pasta"); + public void changes(WebContext webContext) { + webContext.respondWith().template("/templates/biz/model/schema.html.pasta"); } /** * Lists all required changes as JSON * - * @param ctx the current request - * @param out the JSON response + * @param webContext the current request + * @param output the JSON response */ @Permission(TenantUserManager.PERMISSION_SYSTEM_ADMINISTRATOR) @Routed("/system/schema/api/list") @InternalService - public void changesList(WebContext ctx, JSONStructuredOutput out) { + public void changesList(WebContext webContext, JSONStructuredOutput output) { schema.computeRequiredSchemaChanges(); - out.beginArray("changes"); + output.beginArray("changes"); for (SchemaUpdateAction action : schema.getSchemaUpdateActions()) { - out.beginObject("change"); - out.property("id", action.getId()); - out.property("reason", action.getReason()); - out.property("realm", action.getRealm()); - out.property("sql", String.join(";\n", action.getSql()) + ";"); - out.property("executed", action.isExecuted()); - out.property("failed", action.isFailed()); - out.property("error", Value.of(action.getError()).asString()); - out.property("dataLossPossible", action.isDataLossPossible()); - out.endObject(); + output.beginObject("change"); + output.property("id", action.getId()); + output.property("reason", action.getReason()); + output.property("realm", action.getRealm()); + output.property("sql", String.join(";\n", action.getSql()) + ";"); + output.property("executed", action.isExecuted()); + output.property("failed", action.isFailed()); + output.property("error", Value.of(action.getError()).asString()); + output.property("dataLossPossible", action.isDataLossPossible()); + output.endObject(); } - out.endArray(); + output.endArray(); } /** * Executes the given schema change. * - * @param ctx the current request - * @param out the JSON response + * @param webContext the current request + * @param output the JSON response */ @Permission(TenantUserManager.PERMISSION_SYSTEM_ADMINISTRATOR) @Routed("/system/schema/api/execute") @InternalService - public void execute(WebContext ctx, JSONStructuredOutput out) { - SchemaUpdateAction result = schema.executeSchemaUpdateAction(ctx.get("id").asString()); + public void execute(WebContext webContext, JSONStructuredOutput output) { + SchemaUpdateAction result = schema.executeSchemaUpdateAction(webContext.get("id").asString()); if (result != null) { - out.property("errorMessage", Value.of(result.getError()).asString()); + output.property("errorMessage", Value.of(result.getError()).asString()); } else { - out.property("errorMessage", NLS.get("DatabaseController.unknownChange")); + output.property("errorMessage", NLS.get("DatabaseController.unknownChange")); } } } diff --git a/src/main/java/sirius/biz/jdbc/DatabaseDisplayUtils.java b/src/main/java/sirius/biz/jdbc/DatabaseDisplayUtils.java index 22f9c2967..8be21be16 100644 --- a/src/main/java/sirius/biz/jdbc/DatabaseDisplayUtils.java +++ b/src/main/java/sirius/biz/jdbc/DatabaseDisplayUtils.java @@ -44,8 +44,8 @@ public String formatValueForDisplay(@Nullable Object value) { return Arrays.stream((Object[]) sqlArrayValue.getArray()) .map(NLS::toUserString) .collect(Collectors.joining(", ")); - } catch (SQLException e) { - Exceptions.ignore(e); + } catch (SQLException exception) { + Exceptions.ignore(exception); } } diff --git a/src/main/java/sirius/biz/jdbc/ExportQueryResultJobFactory.java b/src/main/java/sirius/biz/jdbc/ExportQueryResultJobFactory.java index 934ba42f5..562fba780 100644 --- a/src/main/java/sirius/biz/jdbc/ExportQueryResultJobFactory.java +++ b/src/main/java/sirius/biz/jdbc/ExportQueryResultJobFactory.java @@ -89,8 +89,8 @@ private void exportRow(Row row, Monoflop monoflop) { .map(value -> databaseDisplayUtils.formatValueForDisplay(value)) .toList()); process.incCounter("Row"); - } catch (IOException e) { - throw process.handle(e); + } catch (IOException exception) { + throw process.handle(exception); } } } diff --git a/src/main/java/sirius/biz/jdbc/ExportSchemaChangesJobFactory.java b/src/main/java/sirius/biz/jdbc/ExportSchemaChangesJobFactory.java index b4b53ba2d..c1536dbb1 100644 --- a/src/main/java/sirius/biz/jdbc/ExportSchemaChangesJobFactory.java +++ b/src/main/java/sirius/biz/jdbc/ExportSchemaChangesJobFactory.java @@ -63,8 +63,8 @@ protected void execute(ProcessContext process) throws Exception { private void safeCloseWriter(PrintWriter writer, ProcessContext processContext) { try { writer.close(); - } catch (Exception e) { - processContext.handle(e); + } catch (Exception exception) { + processContext.handle(exception); } } @@ -73,8 +73,8 @@ private PrintWriter createWriter(ProcessContext process, String realm) { try { process.log(ProcessLog.info().withFormattedMessage("Creating export for realm '%s'", realm)); return new PrintWriter(new OutputStreamWriter(process.addFile(realm + ".sql"))); - } catch (IOException e) { - throw process.handle(e); + } catch (IOException exception) { + throw process.handle(exception); } } diff --git a/src/main/java/sirius/biz/jobs/BasicJobFactory.java b/src/main/java/sirius/biz/jobs/BasicJobFactory.java index 946b90c76..5feae87d5 100644 --- a/src/main/java/sirius/biz/jobs/BasicJobFactory.java +++ b/src/main/java/sirius/biz/jobs/BasicJobFactory.java @@ -332,8 +332,8 @@ public Map buildAndVerifyContext(Function paramet context.put(parameter.getName(), value); } - } catch (HandledException e) { - errorConsumer.accept(parameter, e); + } catch (HandledException exception) { + errorConsumer.accept(parameter, exception); } } diff --git a/src/main/java/sirius/biz/jobs/JobConfigData.java b/src/main/java/sirius/biz/jobs/JobConfigData.java index 2147f5ada..e4048cd71 100644 --- a/src/main/java/sirius/biz/jobs/JobConfigData.java +++ b/src/main/java/sirius/biz/jobs/JobConfigData.java @@ -133,10 +133,10 @@ protected void updateConfig() { public JobFactory getJobFactory() { try { return jobs.findFactory(getJob(), JobFactory.class); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException exception) { throw Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withNLSKey("JobConfigData.unknownJob") .set("job", job) .handle(); @@ -219,21 +219,22 @@ public Value fetchParameter(String key) { /** * Reads and validates all parameters from the given web context. * - * @param ctx the request to read the parameter values from + * @param webContext the request to read the parameter values from */ - public void loadFromContext(WebContext ctx) { + public void loadFromContext(WebContext webContext) { // Check all parameters here to notify the user about config short comings... ValueHolder errorHolder = new ValueHolder<>(null); - Map data = getJobFactory().buildAndVerifyContext(ctx::get, true, (parameter, exception) -> { - if (errorHolder.get() == null) { - errorHolder.accept(exception); - } - }); + Map data = + getJobFactory().buildAndVerifyContext(webContext::get, true, (parameter, exception) -> { + if (errorHolder.get() == null) { + errorHolder.accept(exception); + } + }); // ...however, store the original user input here as JobFactory.startInBackground will // perform another check and transform itself... getConfigMap().clear(); - data.keySet().forEach(key -> getConfigMap().put(key, ctx.getParameters(key))); + data.keySet().forEach(key -> getConfigMap().put(key, webContext.getParameters(key))); if (errorHolder.get() != null) { throw errorHolder.get(); diff --git a/src/main/java/sirius/biz/jobs/JobFactory.java b/src/main/java/sirius/biz/jobs/JobFactory.java index 262e943a3..2a138e722 100644 --- a/src/main/java/sirius/biz/jobs/JobFactory.java +++ b/src/main/java/sirius/biz/jobs/JobFactory.java @@ -190,10 +190,10 @@ Map buildAndVerifyContext(Function parameterProvi /** * Computes a JsonNode containing the required update operations for the JavaScript frontend. * - * @param ctx the web context containing the values of all the parameters + * @param webContext the web context containing the values of all the parameters * @return a JsonNode that can be handled by the JavaScript */ - JsonNode computeRequiredParameterUpdates(WebContext ctx); + JsonNode computeRequiredParameterUpdates(WebContext webContext); /** * Computes a JsonNode containing the required update operations for the JavaScript frontend. diff --git a/src/main/java/sirius/biz/jobs/JobStartingRoot.java b/src/main/java/sirius/biz/jobs/JobStartingRoot.java index 5cb857e73..82cf093df 100644 --- a/src/main/java/sirius/biz/jobs/JobStartingRoot.java +++ b/src/main/java/sirius/biz/jobs/JobStartingRoot.java @@ -69,8 +69,8 @@ protected OutputStream uploadAndTrigger(JobFactory jobToRun, buffer.delete(); } }, filename); - } catch (Exception e) { - throw Exceptions.handle(e); + } catch (Exception exception) { + throw Exceptions.handle(exception); } } diff --git a/src/main/java/sirius/biz/jobs/JobsController.java b/src/main/java/sirius/biz/jobs/JobsController.java index 334469274..b2ad2fc82 100644 --- a/src/main/java/sirius/biz/jobs/JobsController.java +++ b/src/main/java/sirius/biz/jobs/JobsController.java @@ -95,14 +95,15 @@ public void job(WebContext webContext, String jobType) { * accordingly. * * @param webContext the web context - * @param out the output to write the JSON response to + * @param output the output to write the JSON response to * @param jobType the type of the job, so we can find a suitable job factory */ @Routed("/job/params/:1") @InternalService @LoginRequired - public void params(WebContext webContext, JSONStructuredOutput out, String jobType) { - out.property("params", jobs.findFactory(jobType, JobFactory.class).computeRequiredParameterUpdates(webContext)); + public void params(WebContext webContext, JSONStructuredOutput output, String jobType) { + output.property("params", + jobs.findFactory(jobType, JobFactory.class).computeRequiredParameterUpdates(webContext)); } /** @@ -122,7 +123,7 @@ public void infos(WebContext webContext, String jobType) { * Uses a JSON call to invoke a job. * * @param webContext the current request - * @param out the output to write the JSON response to + * @param output the output to write the JSON response to * @param jobType the name of the job to launch */ @Routed("/jobs/api/:1") @@ -148,13 +149,13 @@ public void infos(WebContext webContext, String jobType) { required = true, example = "jupiter-sync") @LoginRequired - public void jsonApi(WebContext webContext, JSONStructuredOutput out, String jobType) { + public void jsonApi(WebContext webContext, JSONStructuredOutput output, String jobType) { enforceMethodPost(webContext); try { JobFactory factory = jobs.findFactory(jobType, JobFactory.class); - out.property("process", factory.startInBackground(webContext::get)); - } catch (IllegalArgumentException e) { + output.property("process", factory.startInBackground(webContext::get)); + } catch (IllegalArgumentException exception) { throw Exceptions.createHandled() .withDirectMessage(Strings.apply("Unknown factory: %s", jobType)) .hint(Controller.HTTP_STATUS, HttpResponseStatus.NOT_FOUND.code()) @@ -166,13 +167,13 @@ public void jsonApi(WebContext webContext, JSONStructuredOutput out, String jobT * A route that can handle autocompletes of parameter input fields via the {@link Autocompleter}. * * @param webContext the web context - * @param out the output to write the JSON response to + * @param output the output to write the JSON response to * @param autocompleterName the name of the autocompleter */ @Routed("/jobs/parameter-autocomplete/:1") @InternalService @LoginRequired - public void autocomplete(WebContext webContext, JSONStructuredOutput out, String autocompleterName) { + public void autocomplete(WebContext webContext, JSONStructuredOutput output, String autocompleterName) { Autocompleter autocompleter = Injector.context().getPart(autocompleterName, Autocompleter.class); AutocompleteHelper.handle(webContext, (query, result) -> autocompleter.suggest(query, webContext, result)); } diff --git a/src/main/java/sirius/biz/jobs/batch/BatchJob.java b/src/main/java/sirius/biz/jobs/batch/BatchJob.java index 00cc5f6b8..8f97297a1 100644 --- a/src/main/java/sirius/biz/jobs/batch/BatchJob.java +++ b/src/main/java/sirius/biz/jobs/batch/BatchJob.java @@ -50,8 +50,8 @@ protected BatchJob(ProcessContext process) { protected void attachFile(VirtualFile file) { try (InputStream in = file.createInputStream(); OutputStream out = process.addFile(file.name())) { Streams.transfer(in, out); - } catch (IOException e) { - process.handle(e); + } catch (IOException exception) { + process.handle(exception); } } @@ -66,8 +66,8 @@ protected void attachFile(VirtualFile file) { protected void attachFile(String filename, FileHandle file) { try (InputStream in = file.getInputStream(); OutputStream out = process.addFile(filename)) { Streams.transfer(in, out); - } catch (IOException e) { - process.handle(e); + } catch (IOException exception) { + process.handle(exception); } } diff --git a/src/main/java/sirius/biz/jobs/batch/BatchProcessTaskExecutor.java b/src/main/java/sirius/biz/jobs/batch/BatchProcessTaskExecutor.java index 4c63231a1..383a32f2f 100644 --- a/src/main/java/sirius/biz/jobs/batch/BatchProcessTaskExecutor.java +++ b/src/main/java/sirius/biz/jobs/batch/BatchProcessTaskExecutor.java @@ -64,8 +64,8 @@ protected void executeInProcess(String factoryId, ProcessContext process) { process.log(ProcessLog.info().withNLSKey("BatchProcessTaskExecutor.started")); try { jobs.findFactory(factoryId, BatchProcessJobFactory.class).executeTask(process); - } catch (Exception e) { - process.handle(e); + } catch (Exception exception) { + process.handle(exception); } finally { if (process.isErroneous()) { process.log(ProcessLog.warn().withNLSKey("BatchProcessTaskExecutor.completedButFailed")); @@ -80,8 +80,8 @@ protected void partiallyExecuteInProcess(String factoryId, ProcessContext proces Watch watch = Watch.start(); try { jobs.findFactory(factoryId, BatchProcessJobFactory.class).executeTask(process); - } catch (Exception e) { - process.handle(e); + } catch (Exception exception) { + process.handle(exception); process.log(ProcessLog.warn().withNLSKey("BatchProcessTaskExecutor.completedButFailed")); process.markCompleted((int) watch.elapsed(TimeUnit.SECONDS, false)); } diff --git a/src/main/java/sirius/biz/jobs/batch/ImportJob.java b/src/main/java/sirius/biz/jobs/batch/ImportJob.java index a27441a64..157a9608c 100644 --- a/src/main/java/sirius/biz/jobs/batch/ImportJob.java +++ b/src/main/java/sirius/biz/jobs/batch/ImportJob.java @@ -83,8 +83,8 @@ public void close() throws IOException { .asSystemMessage()); } this.importer.close(); - } catch (IOException e) { - process.handle(e); + } catch (IOException exception) { + process.handle(exception); } super.close(); } diff --git a/src/main/java/sirius/biz/jobs/batch/entity/EntityBatchJob.java b/src/main/java/sirius/biz/jobs/batch/entity/EntityBatchJob.java index 8adfa0687..8b4d1c742 100644 --- a/src/main/java/sirius/biz/jobs/batch/entity/EntityBatchJob.java +++ b/src/main/java/sirius/biz/jobs/batch/entity/EntityBatchJob.java @@ -53,8 +53,8 @@ private void handleEntity(E entity) { Watch w = Watch.start(); try { processEntity(entity); - } catch (Exception e) { - process.handle(e); + } catch (Exception exception) { + process.handle(exception); } finally { process.addTiming(descriptor.getPluralLabel(), w.elapsedMillis()); } diff --git a/src/main/java/sirius/biz/jobs/batch/file/ArchiveExportJob.java b/src/main/java/sirius/biz/jobs/batch/file/ArchiveExportJob.java index 5e76b42dd..c4385e80b 100644 --- a/src/main/java/sirius/biz/jobs/batch/file/ArchiveExportJob.java +++ b/src/main/java/sirius/biz/jobs/batch/file/ArchiveExportJob.java @@ -101,9 +101,8 @@ private void processExportedArchive(InputStream inputStream, BiConsumer getDefaultMapping() { try (Importer importer = new Importer("getDefaultMapping")) { return importer.findHandler(getExportType()).getDefaultExportMapping(); - } catch (Exception e) { - throw Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + throw Exceptions.handle(Log.BACKGROUND, exception); } } diff --git a/src/main/java/sirius/biz/jobs/batch/file/EntityImportJobFactory.java b/src/main/java/sirius/biz/jobs/batch/file/EntityImportJobFactory.java index b41d38d93..f9cd61cc3 100644 --- a/src/main/java/sirius/biz/jobs/batch/file/EntityImportJobFactory.java +++ b/src/main/java/sirius/biz/jobs/batch/file/EntityImportJobFactory.java @@ -66,8 +66,8 @@ protected ImportDictionary getDictionary() { ImportDictionary dictionary = importer.getImportDictionary(getImportType()); enhanceDictionary(importer, dictionary); return dictionary; - } catch (Exception e) { - throw Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + throw Exceptions.handle(Log.BACKGROUND, exception); } } diff --git a/src/main/java/sirius/biz/jobs/batch/file/FileExportJob.java b/src/main/java/sirius/biz/jobs/batch/file/FileExportJob.java index f3577bb7d..8c555acd7 100644 --- a/src/main/java/sirius/biz/jobs/batch/file/FileExportJob.java +++ b/src/main/java/sirius/biz/jobs/batch/file/FileExportJob.java @@ -95,8 +95,8 @@ protected OutputStream createOutputStream() { } return process.addFile(determineEffectiveFilename("", false)); - } catch (IOException e) { - throw process.handle(e); + } catch (IOException exception) { + throw process.handle(exception); } } @@ -204,8 +204,8 @@ private void processInputStream(@Nonnull Supplier inputStreamSuppli @Nonnull Consumer digester) { try (InputStream inputStream = inputStreamSupplier.get()) { digester.accept(inputStream); - } catch (IOException e) { - process.handle(e); + } catch (IOException exception) { + process.handle(exception); } } } diff --git a/src/main/java/sirius/biz/jobs/batch/file/FileImportJob.java b/src/main/java/sirius/biz/jobs/batch/file/FileImportJob.java index 7a37ad0bc..5fac2c2c1 100644 --- a/src/main/java/sirius/biz/jobs/batch/file/FileImportJob.java +++ b/src/main/java/sirius/biz/jobs/batch/file/FileImportJob.java @@ -331,13 +331,13 @@ protected boolean handleAuxiliaryFile(ExtractedFile extractedFile) { } return true; - } catch (Exception e) { + } catch (Exception exception) { process.handle(Exceptions.handle() - .error(e) + .error(exception) .to(Log.BACKGROUND) .withNLSKey("FileImportJob.copyAuxiliaryFileFailed") .set("file", extractedFile.getFilePath()) - .set("message", e.getMessage()) + .set("message", exception.getMessage()) .handle()); return false; } diff --git a/src/main/java/sirius/biz/jobs/batch/file/LineBasedExportJob.java b/src/main/java/sirius/biz/jobs/batch/file/LineBasedExportJob.java index f34cd6ed0..d31b63ed4 100644 --- a/src/main/java/sirius/biz/jobs/batch/file/LineBasedExportJob.java +++ b/src/main/java/sirius/biz/jobs/batch/file/LineBasedExportJob.java @@ -82,8 +82,8 @@ public void close() throws IOException { if (export != null) { export.close(); } - } catch (Exception e) { - process.handle(e); + } catch (Exception exception) { + process.handle(exception); } super.close(); diff --git a/src/main/java/sirius/biz/jobs/batch/file/RelationalEntityImportJob.java b/src/main/java/sirius/biz/jobs/batch/file/RelationalEntityImportJob.java index 885343b56..7bab53bf3 100644 --- a/src/main/java/sirius/biz/jobs/batch/file/RelationalEntityImportJob.java +++ b/src/main/java/sirius/biz/jobs/batch/file/RelationalEntityImportJob.java @@ -221,11 +221,11 @@ protected void createOrUpdateEntity(E entity, Context context, Watch watch) { } else { process.addTiming(NLS.get("EntityImportJob.entityUpdated"), watch.elapsedMillis()); } - } catch (HandledException e) { + } catch (HandledException exception) { throw Exceptions.createHandled() .withNLSKey("EntityImportJob.cannotHandleEntity") .set("entity", entity.toString()) - .set("message", e.getMessage()) + .set("message", exception.getMessage()) .handle(); } } diff --git a/src/main/java/sirius/biz/jobs/batch/file/RelationalEntityImportJobFactory.java b/src/main/java/sirius/biz/jobs/batch/file/RelationalEntityImportJobFactory.java index 2267d4196..dad172052 100644 --- a/src/main/java/sirius/biz/jobs/batch/file/RelationalEntityImportJobFactory.java +++ b/src/main/java/sirius/biz/jobs/batch/file/RelationalEntityImportJobFactory.java @@ -96,8 +96,8 @@ protected ImportDictionary getDictionary() { ImportDictionary dictionary = importer.getImportDictionary(getImportType()); enhanceDictionary(importer, dictionary); return dictionary; - } catch (Exception e) { - throw Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + throw Exceptions.handle(Log.BACKGROUND, exception); } } diff --git a/src/main/java/sirius/biz/jobs/batch/file/XMLExportJob.java b/src/main/java/sirius/biz/jobs/batch/file/XMLExportJob.java index 896ac056f..1852b23d5 100644 --- a/src/main/java/sirius/biz/jobs/batch/file/XMLExportJob.java +++ b/src/main/java/sirius/biz/jobs/batch/file/XMLExportJob.java @@ -59,8 +59,8 @@ public void close() throws IOException { if (requireValidFile) { try { digestExportedFile((fileName, inputStream) -> validate(inputStream)); - } catch (Exception e) { - process.handle(e); + } catch (Exception exception) { + process.handle(exception); } } } @@ -69,8 +69,8 @@ private void closeOpenStream() { if (xmlOutputStream != null) { try { xmlOutputStream.close(); - } catch (IOException e) { - process.handle(e); + } catch (IOException exception) { + process.handle(exception); } } } @@ -87,8 +87,8 @@ protected void validate(InputStream xmlInputStream) { XMLValidator xmlValidator = new XMLValidator(process); xmlValidator.validate(xmlSource, xsdSource); - } catch (Exception e) { - process.handle(e); + } catch (Exception exception) { + process.handle(exception); } } diff --git a/src/main/java/sirius/biz/jobs/interactive/InteractiveJobFactory.java b/src/main/java/sirius/biz/jobs/interactive/InteractiveJobFactory.java index d772bbb17..1d5434974 100644 --- a/src/main/java/sirius/biz/jobs/interactive/InteractiveJobFactory.java +++ b/src/main/java/sirius/biz/jobs/interactive/InteractiveJobFactory.java @@ -83,9 +83,9 @@ public void startInteractively(WebContext request) { tasks.executor(INTERACTIVE_JOBS_EXECUTOR).fork(() -> { try { generateResponse(request, context); - } catch (Exception e) { + } catch (Exception exception) { request.respondWith() - .error(HttpResponseStatus.INTERNAL_SERVER_ERROR, Exceptions.handle(Log.BACKGROUND, e)); + .error(HttpResponseStatus.INTERNAL_SERVER_ERROR, Exceptions.handle(Log.BACKGROUND, exception)); } }); } diff --git a/src/main/java/sirius/biz/jobs/interactive/LinearChartJobFactory.java b/src/main/java/sirius/biz/jobs/interactive/LinearChartJobFactory.java index 43573e78f..ffc65d670 100644 --- a/src/main/java/sirius/biz/jobs/interactive/LinearChartJobFactory.java +++ b/src/main/java/sirius/biz/jobs/interactive/LinearChartJobFactory.java @@ -53,8 +53,8 @@ protected void generateResponse(WebContext request, Map context) labels::set, datasets::add, (name, value) -> additionalMetrics.add(Tuple.create(name, value))); - } catch (Exception e) { - UserContext.handle(e); + } catch (Exception exception) { + UserContext.handle(exception); } request.respondWith() diff --git a/src/main/java/sirius/biz/jobs/interactive/ReportJobFactory.java b/src/main/java/sirius/biz/jobs/interactive/ReportJobFactory.java index d0c5c7995..60357a41b 100644 --- a/src/main/java/sirius/biz/jobs/interactive/ReportJobFactory.java +++ b/src/main/java/sirius/biz/jobs/interactive/ReportJobFactory.java @@ -40,8 +40,8 @@ protected void generateResponse(WebContext request, Map context) computeReport(context, report, (name, value) -> additionalMetrics.add(Tuple.create(NLS.smartGet(name), value))); - } catch (Exception e) { - UserContext.handle(e); + } catch (Exception exception) { + UserContext.handle(exception); } request.respondWith().template(getTemplate(), this, context, report, additionalMetrics); diff --git a/src/main/java/sirius/biz/jobs/interactive/SingleDatasetChartJobFactory.java b/src/main/java/sirius/biz/jobs/interactive/SingleDatasetChartJobFactory.java index 9d31ce8b9..55e19761e 100644 --- a/src/main/java/sirius/biz/jobs/interactive/SingleDatasetChartJobFactory.java +++ b/src/main/java/sirius/biz/jobs/interactive/SingleDatasetChartJobFactory.java @@ -35,8 +35,8 @@ protected void generateResponse(WebContext request, Map context) labels.add(label); dataset.addValue(value); }, (name, value) -> additionalMetrics.add(Tuple.create(name, value))); - } catch (Exception e) { - UserContext.handle(e); + } catch (Exception exception) { + UserContext.handle(exception); } request.respondWith() diff --git a/src/main/java/sirius/biz/jobs/params/ParameterBuilder.java b/src/main/java/sirius/biz/jobs/params/ParameterBuilder.java index 9833ad0d6..41f5747a1 100644 --- a/src/main/java/sirius/biz/jobs/params/ParameterBuilder.java +++ b/src/main/java/sirius/biz/jobs/params/ParameterBuilder.java @@ -359,11 +359,11 @@ public Optional validate(Map parameterContext) { protected String checkAndTransform(Value input) { try { return checkAndTransformValue(input); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException exception) { throw Exceptions.createHandled() .withNLSKey("Parameter.invalidValue") .set("name", getLabel()) - .set("message", e.getMessage()) + .set("message", exception.getMessage()) .handle(); } } diff --git a/src/main/java/sirius/biz/jobs/presets/JobPresetsController.java b/src/main/java/sirius/biz/jobs/presets/JobPresetsController.java index f1757b380..36560c375 100644 --- a/src/main/java/sirius/biz/jobs/presets/JobPresetsController.java +++ b/src/main/java/sirius/biz/jobs/presets/JobPresetsController.java @@ -53,40 +53,40 @@ public abstract class JobPresetsController

& JobPreset> *

* This will create or update the job preset with the given name (and job factory) for the current tenant. * - * @param ctx the request to handle - * @param out the JSON response to populate (in this case no actual output is expected) + * @param webContext the request to handle + * @param output the JSON response to populate (in this case no actual output is expected) * @throws Exception in case of an error when populating the entity */ @SuppressWarnings("unchecked") @Routed("/jobs/preset/create") @InternalService - public void create(WebContext ctx, JSONStructuredOutput out) throws Exception { + public void create(WebContext webContext, JSONStructuredOutput output) throws Exception { P preset = (P) mixing.getDescriptor(getPresetType()) .getMapper() .select(getPresetType()) .eq(TenantAware.TENANT, tenants.getRequiredTenant()) .eq(JobPreset.JOB_CONFIG_DATA.inner(JobConfigData.JOB), - ctx.get(PARAM_JOB_FACTORY).asString()) + webContext.get(PARAM_JOB_FACTORY).asString()) .eq(JobPreset.JOB_CONFIG_DATA.inner(JobConfigData.LABEL), - ctx.get(PARAM_PRESET_NAME).asString()) + webContext.get(PARAM_PRESET_NAME).asString()) .queryFirst(); if (preset == null) { preset = getPresetType().getDeclaredConstructor().newInstance(); - preset.getJobConfigData().setJob(ctx.get(PARAM_JOB_FACTORY).asString()); - preset.getJobConfigData().setLabel(ctx.get(PARAM_PRESET_NAME).asString()); + preset.getJobConfigData().setJob(webContext.get(PARAM_JOB_FACTORY).asString()); + preset.getJobConfigData().setLabel(webContext.get(PARAM_PRESET_NAME).asString()); preset.fillWithCurrentTenant(); } else { preset.getJobConfigData().getConfigMap().clear(); } preset.getJobConfigData() - .setCustomPersistencePeriod(ctx.get(PARAM_CUSTOM_PERSISTENCE_PERIOD) - .getEnum(PersistencePeriod.class) - .orElse(null)); + .setCustomPersistencePeriod(webContext.get(PARAM_CUSTOM_PERSISTENCE_PERIOD) + .getEnum(PersistencePeriod.class) + .orElse(null)); - for (String parameter : ctx.getParameterNames()) { + for (String parameter : webContext.getParameterNames()) { if (!IGNORED_PARAMETERS.contains(parameter)) { - preset.getJobConfigData().getConfigMap().put(parameter, ctx.getParameters(parameter)); + preset.getJobConfigData().getConfigMap().put(parameter, webContext.getParameters(parameter)); } } @@ -96,50 +96,50 @@ public void create(WebContext ctx, JSONStructuredOutput out) throws Exception { /** * Outputs the stored configuration (parameters) for the requested job preset. * - * @param ctx the request to handle - * @param out the JSON response to populate + * @param webContext the request to handle + * @param output the JSON response to populate */ @Routed("/jobs/preset/load") @InternalService - public void load(WebContext ctx, JSONStructuredOutput out) { - out.beginArray(RESPONSE_PARAMS); + public void load(WebContext webContext, JSONStructuredOutput output) { + output.beginArray(RESPONSE_PARAMS); P preset = mixing.getDescriptor(getPresetType()) .getMapper() - .find(getPresetType(), ctx.get(PARAM_PRESET).asString()) + .find(getPresetType(), webContext.get(PARAM_PRESET).asString()) .orElse(null); if (preset != null) { assertTenant(preset); preset.getJobConfigData().getConfigMap().forEach((name, values) -> { - out.beginObject(RESPONSE_PARAM); - out.property(RESPONSE_NAME, name); + output.beginObject(RESPONSE_PARAM); + output.property(RESPONSE_NAME, name); if (values.isEmpty()) { - out.property(RESPONSE_VALUE, null); + output.property(RESPONSE_VALUE, null); } else if (values.size() == 1) { - out.property(RESPONSE_VALUE, values.get(0)); + output.property(RESPONSE_VALUE, values.get(0)); } else { - out.property(RESPONSE_VALUE, Json.createArray(values)); + output.property(RESPONSE_VALUE, Json.createArray(values)); } - out.endObject(); + output.endObject(); }); } - out.endArray(); + output.endArray(); } /** * Deletes the requested job preset. * - * @param ctx the request to handle - * @param out the JSON response to populate (in this case no actual output is expected) + * @param webContext the request to handle + * @param output the JSON response to populate (in this case no actual output is expected) */ @Routed("/jobs/preset/delete") @InternalService - public void delete(WebContext ctx, JSONStructuredOutput out) { - if (ctx.isSafePOST()) { + public void delete(WebContext webContext, JSONStructuredOutput output) { + if (webContext.isSafePOST()) { P preset = mixing.getDescriptor(getPresetType()) .getMapper() - .find(getPresetType(), ctx.get(PARAM_PRESET).asString()) + .find(getPresetType(), webContext.get(PARAM_PRESET).asString()) .orElse(null); if (preset != null) { assertTenant(preset); diff --git a/src/main/java/sirius/biz/jobs/scheduler/JobSchedulerLoop.java b/src/main/java/sirius/biz/jobs/scheduler/JobSchedulerLoop.java index 262b3ffe3..e882f07a4 100644 --- a/src/main/java/sirius/biz/jobs/scheduler/JobSchedulerLoop.java +++ b/src/main/java/sirius/biz/jobs/scheduler/JobSchedulerLoop.java @@ -80,10 +80,10 @@ private int executeEntriesOfProvider(LocalDateTime no executeJob(provider, entry, now); startedJobs++; } - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage( "An error occurred while checking a scheduled task of %s: %s - %s (%s)", provider.getClass().getSimpleName(), @@ -99,10 +99,10 @@ private void executeJob(SchedulerEntryProvider pro try { UserInfo user = UserContext.get().getUserManager().findUserByUserId(entry.getSchedulerData().getUserId()); UserContext.get().runAs(user, () -> executeJobAsUser(provider, entry, now)); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage("An error occurred while starting a scheduled task of %s: %s - %s (%s)", provider.getClass().getSimpleName(), entry) diff --git a/src/main/java/sirius/biz/jobs/scheduler/SchedulerController.java b/src/main/java/sirius/biz/jobs/scheduler/SchedulerController.java index c7ba1695f..2250a9418 100644 --- a/src/main/java/sirius/biz/jobs/scheduler/SchedulerController.java +++ b/src/main/java/sirius/biz/jobs/scheduler/SchedulerController.java @@ -51,19 +51,19 @@ public abstract class SchedulerController & SchedulerEnt /** * Lists all scheduler entries for the current tenant. * - * @param ctx the current request + * @param webContext the current request */ @Permission(PERMISSION_MANAGE_SCHEDULER) @Routed("/jobs/scheduler") - public void schedulerEntries(WebContext ctx) { + public void schedulerEntries(WebContext webContext) { BasePageHelper pageHelper = getEntriesAsPage(); - pageHelper.withContext(ctx); + pageHelper.withContext(webContext); pageHelper.addBooleanFacet(SchedulerEntry.SCHEDULER_DATA.inner(SchedulerData.ENABLED).getName(), NLS.get("SchedulerData.enabled")); pageHelper.withSearchFields(QueryField.contains(SchedulerEntry.JOB_CONFIG_DATA.inner(JobConfigData.JOB_NAME)), QueryField.contains(SchedulerEntry.JOB_CONFIG_DATA.inner(JobConfigData.LABEL))); - ctx.respondWith().template("/templates/biz/jobs/scheduler/entries.html.pasta", pageHelper.asPage()); + webContext.respondWith().template("/templates/biz/jobs/scheduler/entries.html.pasta", pageHelper.asPage()); } /** @@ -76,37 +76,37 @@ public void schedulerEntries(WebContext ctx) { /** * Renders a details page for the given scheduler entry. * - * @param ctx the current request + * @param webContext the current request * @param entryId the id of the entry to display or new to create a new one */ @Permission(PERMISSION_MANAGE_SCHEDULER) @Routed("/jobs/scheduler/entry/:1") - public void schedulerEntry(WebContext ctx, String entryId) { + public void schedulerEntry(WebContext webContext, String entryId) { J entry = findForTenant(getEntryType(), entryId); - if (handleJobSelection(entry, ctx)) { + if (handleJobSelection(entry, webContext)) { return; } - if (handleNewEntryWithoutJob(entry, ctx)) { + if (handleNewEntryWithoutJob(entry, webContext)) { return; } - boolean requestHandled = prepareSave(ctx).withAfterSaveURI("/jobs/scheduler").withPreSaveHandler(isNew -> { - loadUser(ctx, entry); - entry.getJobConfigData().loadFromContext(ctx); + boolean requestHandled = prepareSave(webContext).withAfterSaveURI("/jobs/scheduler").withPreSaveHandler(isNew -> { + loadUser(webContext, entry); + entry.getJobConfigData().loadFromContext(webContext); }).saveEntity(entry); if (!requestHandled) { validate(entry); - ctx.respondWith().template("/templates/biz/jobs/scheduler/entry.html.pasta", entry); + webContext.respondWith().template("/templates/biz/jobs/scheduler/entry.html.pasta", entry); } } - protected void loadUser(WebContext ctx, J entry) { + protected void loadUser(WebContext webContext, J entry) { UserInfo user = UserContext.get() .getUserManager() - .findUserByUserId(ctx.get(SchedulerEntry.SCHEDULER_DATA.inner(SchedulerData.USER_ID) + .findUserByUserId(webContext.get(SchedulerEntry.SCHEDULER_DATA.inner(SchedulerData.USER_ID) .toString()).asString()); // Ensure that an active and accessible user was selected... @@ -124,23 +124,23 @@ protected void loadUser(WebContext ctx, J entry) { entry.getSchedulerData().setUserName(user.getUserName()); } - private boolean handleJobSelection(J entry, WebContext ctx) { - if (entry.isNew() && ctx.isSafePOST()) { - if (ctx.hasParameter("selectedJob")) { - entry.getJobConfigData().setJob(ctx.get("selectedJob").asString()); - ctx.respondWith().template("/templates/biz/jobs/scheduler/entry.html.pasta", entry); + private boolean handleJobSelection(J entry, WebContext webContext) { + if (entry.isNew() && webContext.isSafePOST()) { + if (webContext.hasParameter("selectedJob")) { + entry.getJobConfigData().setJob(webContext.get("selectedJob").asString()); + webContext.respondWith().template("/templates/biz/jobs/scheduler/entry.html.pasta", entry); return true; - } else if (ctx.hasParameter("job")) { - entry.getJobConfigData().setJob(ctx.get("job").asString()); + } else if (webContext.hasParameter("job")) { + entry.getJobConfigData().setJob(webContext.get("job").asString()); } } return false; } - private boolean handleNewEntryWithoutJob(J entry, WebContext ctx) { + private boolean handleNewEntryWithoutJob(J entry, WebContext webContext) { if (Strings.isEmpty(entry.getJobConfigData().getJob())) { - ctx.respondWith().template("/templates/biz/jobs/scheduler/create-entry.html.pasta", entry); + webContext.respondWith().template("/templates/biz/jobs/scheduler/create-entry.html.pasta", entry); return true; } @@ -150,25 +150,25 @@ private boolean handleNewEntryWithoutJob(J entry, WebContext ctx) { /** * Deletes the given scheduler entry. * - * @param ctx the curren request + * @param webContext the curren request * @param entryId the id of the entry to delete */ @Permission(PERMISSION_MANAGE_SCHEDULER) @Routed("/jobs/scheduler/entry/:1/delete") - public void deleteEntry(WebContext ctx, String entryId) { - deleteEntity(ctx, getEntryType(), entryId); - schedulerEntries(ctx); + public void deleteEntry(WebContext webContext, String entryId) { + deleteEntity(webContext, getEntryType(), entryId); + schedulerEntries(webContext); } /** * Autocompletion for schedulable background jobs. * - * @param ctx the current request + * @param webContext the current request */ @Permission(PERMISSION_MANAGE_SCHEDULER) @Routed("/jobs/scheduler/autocomplete") - public void backgroundJobsAutocomplete(final WebContext ctx) { - AutocompleteHelper.handle(ctx, (query, result) -> { + public void backgroundJobsAutocomplete(final WebContext webContext) { + AutocompleteHelper.handle(webContext, (query, result) -> { jobs.getAvailableJobs(query) .filter(JobFactory::canStartInBackground) .limit(AutocompleteHelper.DEFAULT_LIMIT) diff --git a/src/main/java/sirius/biz/jobs/scheduler/SchedulerData.java b/src/main/java/sirius/biz/jobs/scheduler/SchedulerData.java index ddefc1354..dee52e73b 100644 --- a/src/main/java/sirius/biz/jobs/scheduler/SchedulerData.java +++ b/src/main/java/sirius/biz/jobs/scheduler/SchedulerData.java @@ -141,11 +141,11 @@ protected void validateField(String expression, String fieldKey, Consumer T performWithFailover(Supplier description, } catch (JedisConnectionException ignored) { executeOnFailover.run(); return performWithoutFailover(description, task, fallback); - } catch (Exception e) { - throw Exceptions.handle(Jupiter.LOG, e); + } catch (Exception exception) { + throw Exceptions.handle(Jupiter.LOG, exception); } } @@ -148,8 +148,8 @@ private T performWithoutFailover(Supplier description, Function T perform(Supplier description, Jedis jedis, Function update for (Runnable runnable : updateTasks) { try { runnable.run(); - } catch (Exception ex) { - processContext.handle(ex); + } catch (Exception exception) { + processContext.handle(exception); } } } @@ -518,9 +518,9 @@ private void syncLocalRepository(ProcessContext processContext, repositoryFiles, updateTaskConsumer, filesToDelete); - } catch (Exception e) { + } catch (Exception exception) { processContext.handle(Exceptions.handle() - .error(e) + .error(exception) .withSystemErrorMessage( "Failed to check the local repository %s for %s: %s (%s)", localRepoSpaceName, diff --git a/src/main/java/sirius/biz/jupiter/JupiterYamlDataProvider.java b/src/main/java/sirius/biz/jupiter/JupiterYamlDataProvider.java index 17c410b26..f06a27b07 100644 --- a/src/main/java/sirius/biz/jupiter/JupiterYamlDataProvider.java +++ b/src/main/java/sirius/biz/jupiter/JupiterYamlDataProvider.java @@ -36,9 +36,9 @@ public void execute(OutputStream outputStream) throws Exception { try { yaml.dump(yamlObject, writer); writer.write("---\n"); - } catch (IOException e) { + } catch (IOException exception) { throw Exceptions.handle() - .error(e) + .error(exception) .to(Jupiter.LOG) .withSystemErrorMessage("Failed to write %s (%s): %s (%s)", getFilename(), diff --git a/src/main/java/sirius/biz/locks/BasicLockManager.java b/src/main/java/sirius/biz/locks/BasicLockManager.java index c43d6f44f..888212cba 100644 --- a/src/main/java/sirius/biz/locks/BasicLockManager.java +++ b/src/main/java/sirius/biz/locks/BasicLockManager.java @@ -34,8 +34,8 @@ public boolean tryLock(@Nonnull String lockName, @Nullable Duration acquireTimeo waitInMillis = Math.min(getMaxWait(), waitInMillis + getWaitIncrement()); } while (System.currentTimeMillis() < timeout); return false; - } catch (Exception e) { - Exceptions.handle(Locks.LOG, e); + } catch (Exception exception) { + Exceptions.handle(Locks.LOG, exception); return false; } } diff --git a/src/main/java/sirius/biz/locks/jdbc/SQLLockManager.java b/src/main/java/sirius/biz/locks/jdbc/SQLLockManager.java index 2cda91ed7..3cb1b1b8f 100644 --- a/src/main/java/sirius/biz/locks/jdbc/SQLLockManager.java +++ b/src/main/java/sirius/biz/locks/jdbc/SQLLockManager.java @@ -80,12 +80,12 @@ protected boolean acquireLock(@Nonnull String lockName) { .set(ManagedLock.THREAD.getName(), Thread.currentThread().getName()) .set(ManagedLock.ACQUIRED.getName(), Instant.now().toEpochMilli())); return true; - } catch (SQLIntegrityConstraintViolationException e) { + } catch (SQLIntegrityConstraintViolationException exception) { // Lock is locked - retry if possible :-( - Exceptions.ignore(e); + Exceptions.ignore(exception); return false; - } catch (SQLException e) { - throw Exceptions.handle(Locks.LOG, e); + } catch (SQLException exception) { + throw Exceptions.handle(Locks.LOG, exception); } } @@ -106,7 +106,7 @@ public void unlock(String lock, boolean force) { } deleteStatement.executeUpdate(); - } catch (SQLException e) { + } catch (SQLException exception) { throw Exceptions.handle() .to(OMA.LOG) .withSystemErrorMessage("An error occurred while unlocking %s: %s - %s", lock) diff --git a/src/main/java/sirius/biz/model/InternationalAddressData.java b/src/main/java/sirius/biz/model/InternationalAddressData.java index 428825e9a..506398bd4 100644 --- a/src/main/java/sirius/biz/model/InternationalAddressData.java +++ b/src/main/java/sirius/biz/model/InternationalAddressData.java @@ -101,11 +101,11 @@ public void clear() { public void verifyCountry(@Nullable String fieldLabel) { try { country.verifyValue(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.createHandled() .withNLSKey("AddressData.invalidCountry") .set("name", determineFieldLabel(fieldLabel)) - .set("error", e.getMessage()) + .set("error", exception.getMessage()) .handle(); } } @@ -123,10 +123,10 @@ public void verifyCountry(@Nullable String fieldLabel) { public void validateCountry(@Nullable String fieldLabel, Consumer validationMessageConsumer) { try { country.verifyValue(); - } catch (Exception e) { + } catch (Exception exception) { validationMessageConsumer.accept(NLS.fmtr("AddressData.invalidCountry") .set("name", determineFieldLabel(fieldLabel)) - .set("error", e.getMessage()) + .set("error", exception.getMessage()) .format()); } } @@ -153,8 +153,8 @@ public void verifyZip(@Nullable String fieldLabel) { .set("zip", getZip()) .handle(); } - } catch (PatternSyntaxException e) { - Exceptions.handle(e); + } catch (PatternSyntaxException exception) { + Exceptions.handle(exception); } } @@ -180,8 +180,8 @@ public void validateZIP(@Nullable String fieldLabel, Consumer validation .set("zip", getZip()) .format()); } - } catch (PatternSyntaxException e) { - Exceptions.handle(e); + } catch (PatternSyntaxException exception) { + Exceptions.handle(exception); } } diff --git a/src/main/java/sirius/biz/model/PBKDF2SHA256Function.java b/src/main/java/sirius/biz/model/PBKDF2SHA256Function.java index 63261e351..368d746f7 100644 --- a/src/main/java/sirius/biz/model/PBKDF2SHA256Function.java +++ b/src/main/java/sirius/biz/model/PBKDF2SHA256Function.java @@ -55,8 +55,8 @@ public String computeHash(@Nullable String username, @Nullable String salt, @Non SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); byte[] hash = f.generateSecret(spec).getEncoded(); return Base64.getEncoder().encodeToString(hash); - } catch (Exception e) { - Exceptions.handle(Log.APPLICATION, e); + } catch (Exception exception) { + Exceptions.handle(Log.APPLICATION, exception); return null; } } diff --git a/src/main/java/sirius/biz/model/PermissionData.java b/src/main/java/sirius/biz/model/PermissionData.java index 5b9f9f33f..b31c0b942 100644 --- a/src/main/java/sirius/biz/model/PermissionData.java +++ b/src/main/java/sirius/biz/model/PermissionData.java @@ -161,10 +161,10 @@ public Config getConfig() { if (Strings.isFilled(configString)) { try { config = ConfigFactory.parseString(configString); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(BizController.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Cannot load config of %s (%s): %s (%s)", parent, parent.getId()) diff --git a/src/main/java/sirius/biz/model/PersonData.java b/src/main/java/sirius/biz/model/PersonData.java index 7bed41191..c1e1d0dc2 100644 --- a/src/main/java/sirius/biz/model/PersonData.java +++ b/src/main/java/sirius/biz/model/PersonData.java @@ -106,10 +106,10 @@ public class PersonData extends Composite { public void verifySalutation() { try { salutation.verifyValue(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.createHandled() .withNLSKey("PersonData.invalidSalutation") - .set("error", e.getMessage()) + .set("error", exception.getMessage()) .handle(); } } @@ -126,9 +126,9 @@ public void verifySalutation() { public void validateSalutation(Consumer validationMessageConsumer) { try { salutation.verifyValue(); - } catch (Exception e) { + } catch (Exception exception) { validationMessageConsumer.accept(NLS.fmtr("PersonData.invalidSalutation") - .set("error", e.getMessage()) + .set("error", exception.getMessage()) .format()); } } diff --git a/src/main/java/sirius/biz/model/QueryController.java b/src/main/java/sirius/biz/model/QueryController.java index c178da656..6fea0f451 100644 --- a/src/main/java/sirius/biz/model/QueryController.java +++ b/src/main/java/sirius/biz/model/QueryController.java @@ -131,12 +131,12 @@ public void query(WebContext webContext) { } return result; - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException exception) { // The QueryCompiler generates an IllegalArgumentException for invalid fields and tokens. // In our case we don't want to write them into the syslog but just output the message... - UserContext.message(Message.error().withTextMessage(e.getMessage())); - } catch (Exception e) { - handle(e); + UserContext.message(Message.error().withTextMessage(exception.getMessage())); + } catch (Exception exception) { + handle(exception); } return Collections.emptyList(); diff --git a/src/main/java/sirius/biz/model/ResaveEntitiesJobFactory.java b/src/main/java/sirius/biz/model/ResaveEntitiesJobFactory.java index e91774f94..a000e97d7 100644 --- a/src/main/java/sirius/biz/model/ResaveEntitiesJobFactory.java +++ b/src/main/java/sirius/biz/model/ResaveEntitiesJobFactory.java @@ -128,8 +128,8 @@ private void processEntity(BaseEntity entity) { } } process.addTiming("Success", watch.elapsedMillis()); - } catch (Exception e) { - HandledException handledException = Exceptions.handle(BizController.LOG, e); + } catch (Exception exception) { + HandledException handledException = Exceptions.handle(BizController.LOG, exception); process.addTiming("Failure", watch.elapsedMillis()); process.log(ProcessLog.error() .withFormattedMessage("Failed to save entity %s with id: %s - %s", diff --git a/src/main/java/sirius/biz/process/ExportLogsAsFileTaskExecutor.java b/src/main/java/sirius/biz/process/ExportLogsAsFileTaskExecutor.java index d55ca3ccd..0d3464a84 100644 --- a/src/main/java/sirius/biz/process/ExportLogsAsFileTaskExecutor.java +++ b/src/main/java/sirius/biz/process/ExportLogsAsFileTaskExecutor.java @@ -106,10 +106,10 @@ private void executeInProcess(ObjectNode context, ProcessContext processContext) processContext.fetchOutputEntries(outputName, (columns, labels) -> { try { export.addListRow(labels); - } catch (IOException e) { + } catch (IOException exception) { throw Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage("An error occurred while exporting a row: %s (%s)") .handle(); } @@ -120,18 +120,18 @@ private void executeInProcess(ObjectNode context, ProcessContext processContext) .format()); export.addListRow(values); return true; - } catch (IOException e) { + } catch (IOException exception) { throw Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage("An error occurred while exporting a row: %s (%s)") .handle(); } }); processContext.forceUpdateState(NLS.fmtr("Process.rowsExported").set("rows", rowCount.get()).format()); - } catch (Exception e) { - processContext.handle(e); + } catch (Exception exception) { + processContext.handle(exception); } processContext.log(ProcessLog.success().withNLSKey("ExportLogsAsFileTaskExecutor.completed")); } diff --git a/src/main/java/sirius/biz/process/ProcessContext.java b/src/main/java/sirius/biz/process/ProcessContext.java index 22da986a5..488ad581a 100644 --- a/src/main/java/sirius/biz/process/ProcessContext.java +++ b/src/main/java/sirius/biz/process/ProcessContext.java @@ -119,10 +119,10 @@ public interface ProcessContext extends TaskContextAdapter { *

* This will invoke {@link Exceptions#handle()} and log the result. * - * @param e the exception to handle + * @param exception the exception to handle * @return the handled exception for further processing */ - HandledException handle(Exception e); + HandledException handle(Exception exception); /** * Logs the given log entry. diff --git a/src/main/java/sirius/biz/process/ProcessController.java b/src/main/java/sirius/biz/process/ProcessController.java index 862d025a9..bd93e23c3 100644 --- a/src/main/java/sirius/biz/process/ProcessController.java +++ b/src/main/java/sirius/biz/process/ProcessController.java @@ -162,8 +162,10 @@ public void process(WebContext webContext, String processId) { DateRange.THIS_MONTH, DateRange.LAST_MONTH); pageHelper.addTermAggregation(ProcessLog.NODE); - pageHelper.addSortFacet(Tuple.create("$ProcessController.sortDesc", qry -> qry.orderDesc(ProcessLog.SORT_KEY)), - Tuple.create("$ProcessController.sortAsc", qry -> qry.orderAsc(ProcessLog.SORT_KEY))); + pageHelper.addSortFacet(Tuple.create("$ProcessController.sortDesc", + query -> query.orderDesc(ProcessLog.SORT_KEY)), + Tuple.create("$ProcessController.sortAsc", + query -> query.orderAsc(ProcessLog.SORT_KEY))); pageHelper.withSearchFields(QueryField.contains(ProcessLog.SEARCH_FIELD)); webContext.respondWith() @@ -266,8 +268,8 @@ public void executeLogAction(WebContext webContext, String processId, String pro } handleDefaultAction(webContext, log, action, returnUrl); - } catch (Exception e) { - UserContext.handle(e); + } catch (Exception exception) { + UserContext.handle(exception); webContext.respondWith().redirectToGet(returnUrl); } } @@ -335,8 +337,8 @@ public void processOutput(WebContext webContext, String processId, String name) .withTextMessage(NLS.fmtr("ProcessController.unknownOutput") .set("output", name) .format())); - } catch (Exception e) { - UserContext.handle(e); + } catch (Exception exception) { + UserContext.handle(exception); webContext.respondWith().redirectToGet("/ps/" + processId); } } @@ -395,7 +397,7 @@ public void exportOutput(WebContext webContext, String processId, String name, S * Provides a JSON representation of the given process. * * @param webContext the current request - * @param out the output to write the JSON data to + * @param output the output to write the JSON data to * @param processId the process to output */ @Routed("/ps/:1/api") @@ -440,7 +442,7 @@ public void exportOutput(WebContext webContext, String processId, String name, S example = "KR8E6I36AK7POAK0IP9L3KB0Q1") @LoginRequired @Permission(PERMISSION_VIEW_PROCESSES) - public void processAPI(WebContext webContext, JSONStructuredOutput out, String processId) { + public void processAPI(WebContext webContext, JSONStructuredOutput output, String processId) { Process process = processes.fetchProcessForUser(processId).orElse(null); if (process == null) { throw Exceptions.createHandled() @@ -449,44 +451,44 @@ public void processAPI(WebContext webContext, JSONStructuredOutput out, String p .handle(); } - out.property("id", processId); - out.property("title", process.getTitle()); - out.property("state", process.getState()); - out.property("started", process.getStarted()); - out.property("completed", process.getCompleted()); - out.property("erroneous", process.isErrorneous()); - out.property("processType", process.getProcessType()); - out.property("stateMessage", process.getStateMessage()); - out.beginArray("counters"); + output.property("id", processId); + output.property("title", process.getTitle()); + output.property("state", process.getState()); + output.property("started", process.getStarted()); + output.property("completed", process.getCompleted()); + output.property("erroneous", process.isErrorneous()); + output.property("processType", process.getProcessType()); + output.property("stateMessage", process.getStateMessage()); + output.beginArray("counters"); for (String counter : process.getCounterList()) { - out.beginObject("counter"); - out.property("name", counter); - out.property("counter", process.getCounterValue(counter)); - out.property("timing", process.getCounterTiming(counter)); - out.endObject(); + output.beginObject("counter"); + output.property("name", counter); + output.property("counter", process.getCounterValue(counter)); + output.property("timing", process.getCounterTiming(counter)); + output.endObject(); } - out.endArray(); + output.endArray(); - out.beginArray("links"); + output.beginArray("links"); for (ProcessLink link : process.getLinks()) { - out.beginObject("link"); - out.property("label", link.getLabel()); - out.property("uri", link.getUri()); - out.endObject(); + output.beginObject("link"); + output.property("label", link.getLabel()); + output.property("uri", link.getUri()); + output.endObject(); } - out.endArray(); + output.endArray(); - out.beginArray("lastMessages"); + output.beginArray("lastMessages"); for (ProcessLog log : buildLogsQuery(process).limit(50).orderDesc(ProcessLog.SORT_KEY).queryList()) { - out.beginObject("message"); - out.property("type", log.getType().name()); - out.property("timestamp", log.getTimestamp()); - out.property("message", log.getMessage()); - out.property("node", log.getNode()); - out.property("state", log.getState() != null ? log.getState().name() : null); - out.property("messageType", log.getMessageType()); - out.endObject(); + output.beginObject("message"); + output.property("type", log.getType().name()); + output.property("timestamp", log.getTimestamp()); + output.property("message", log.getMessage()); + output.property("node", log.getNode()); + output.property("state", log.getState() != null ? log.getState().name() : null); + output.property("messageType", log.getMessageType()); + output.endObject(); } - out.endArray(); + output.endArray(); } } diff --git a/src/main/java/sirius/biz/process/ProcessEnvironment.java b/src/main/java/sirius/biz/process/ProcessEnvironment.java index 1ec902e69..3c8b8c395 100644 --- a/src/main/java/sirius/biz/process/ProcessEnvironment.java +++ b/src/main/java/sirius/biz/process/ProcessEnvironment.java @@ -253,8 +253,8 @@ public void debug(ProcessLog logEntry) { } @Override - public HandledException handle(Exception e) { - HandledException handledException = Exceptions.handle(Log.BACKGROUND, e); + public HandledException handle(Exception exception) { + HandledException handledException = Exceptions.handle(Log.BACKGROUND, exception); log(ProcessLog.error().withHandledException(handledException)); return handledException; } @@ -463,8 +463,8 @@ public OutputStream addZipFile(String zipArchiveName, String filename) throws IO zipOutputStream.closeEntry(); zipOutputStream.close(); addFile(zipArchiveName, zipFile); - } catch (Exception e) { - throw Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + throw Exceptions.handle(Log.BACKGROUND, exception); } finally { sirius.kernel.commons.Files.delete(zipFile); } @@ -493,8 +493,8 @@ public Future performInSideTask(UnitOfWork parallelTask) { try { parallelTask.execute(); future.success(); - } catch (Exception e) { - future.fail(e); + } catch (Exception exception) { + future.fail(exception); } }).onFailure(future::fail); diff --git a/src/main/java/sirius/biz/process/Processes.java b/src/main/java/sirius/biz/process/Processes.java index e2bbe3320..ddaf1c710 100644 --- a/src/main/java/sirius/biz/process/Processes.java +++ b/src/main/java/sirius/biz/process/Processes.java @@ -1086,17 +1086,17 @@ public Optional fetchProcessLogForUser(String processLogId) { * * @param processLog the log entry to modify * @param newState the new state to set - * @param ctx the request to respond to + * @param webContext the request to respond to * @param returnUrl the URL to redirect the request to once the modification has been performed and is visible */ public void updateProcessLogStateAndReturn(ProcessLog processLog, ProcessLogState newState, - WebContext ctx, + WebContext webContext, String returnUrl) { processLog.withState(newState); elastic.update(processLog); JournalData.addJournalEntry(processLog, NLS.get("ProcessLog.state") + ": " + newState.toString()); - delayLine.forkDelayed(Tasks.DEFAULT, 1, () -> ctx.respondWith().redirectToGet(returnUrl)); + delayLine.forkDelayed(Tasks.DEFAULT, 1, () -> webContext.respondWith().redirectToGet(returnUrl)); } protected Optional fetchOutput(String processId, String outputName) { diff --git a/src/main/java/sirius/biz/process/output/ChartProcessOutputType.java b/src/main/java/sirius/biz/process/output/ChartProcessOutputType.java index 4a72f6288..c79fc0342 100644 --- a/src/main/java/sirius/biz/process/output/ChartProcessOutputType.java +++ b/src/main/java/sirius/biz/process/output/ChartProcessOutputType.java @@ -62,8 +62,8 @@ public String parseChartData(ProcessLog chart) { // We decode and re-encode here to ensure that only proper data is output into the HTML page ObjectNode obj = Json.parseObject(chart.getMessage()); return Json.write(obj); - } catch (Exception e) { - Exceptions.ignore(e); + } catch (Exception exception) { + Exceptions.ignore(exception); return "{}"; } } diff --git a/src/main/java/sirius/biz/process/output/ProcessOutputType.java b/src/main/java/sirius/biz/process/output/ProcessOutputType.java index 7c26d47a2..1e46f183c 100644 --- a/src/main/java/sirius/biz/process/output/ProcessOutputType.java +++ b/src/main/java/sirius/biz/process/output/ProcessOutputType.java @@ -20,11 +20,11 @@ public interface ProcessOutputType extends Named { /** * Renders the given output for the given process. * - * @param ctx the request to respond to + * @param webContext the request to respond to * @param process the process which contains the output * @param output the output to render */ - void render(WebContext ctx, Process process, ProcessOutput output); + void render(WebContext webContext, Process process, ProcessOutput output); /** * Defines the icon to be used in menus and lists when enumerating outputs of this type. diff --git a/src/main/java/sirius/biz/protocol/DelegateJournalData.java b/src/main/java/sirius/biz/protocol/DelegateJournalData.java index 37da4cc8b..e285a2d17 100644 --- a/src/main/java/sirius/biz/protocol/DelegateJournalData.java +++ b/src/main/java/sirius/biz/protocol/DelegateJournalData.java @@ -191,8 +191,8 @@ private void createJournalEntry(Supplier messageSupplier) { if (Strings.isFilled(message)) { createJournalEntry(targetType.get(), targetId.get(), owner.getClass(), owner.getIdAsString(), message); } - } catch (Exception e) { - Exceptions.handle(e); + } catch (Exception exception) { + Exceptions.handle(exception); } } diff --git a/src/main/java/sirius/biz/protocol/JournalData.java b/src/main/java/sirius/biz/protocol/JournalData.java index 8ea9d5490..07b365a79 100644 --- a/src/main/java/sirius/biz/protocol/JournalData.java +++ b/src/main/java/sirius/biz/protocol/JournalData.java @@ -72,8 +72,8 @@ protected void onSave() { if (changes.length() > 0) { addJournalEntry(owner, changes, batchLog); } - } catch (Exception e) { - Exceptions.handle(e); + } catch (Exception exception) { + Exceptions.handle(exception); } } @@ -177,8 +177,8 @@ private static void addJournalEntry(String targetType, } elastic.update(entry); - } catch (Exception e) { - Exceptions.handle(Elastic.LOG, e); + } catch (Exception exception) { + Exceptions.handle(Elastic.LOG, exception); } } @@ -187,8 +187,8 @@ protected void onDelete() { if (!silent) { try { addJournalEntry(owner, Strings.apply("Entity '%s' has been deleted.", owner.toString()), batchLog); - } catch (Exception e) { - Exceptions.handle(e); + } catch (Exception exception) { + Exceptions.handle(exception); } } } diff --git a/src/main/java/sirius/biz/protocol/MailController.java b/src/main/java/sirius/biz/protocol/MailController.java index caf822f0d..255c5ddc5 100644 --- a/src/main/java/sirius/biz/protocol/MailController.java +++ b/src/main/java/sirius/biz/protocol/MailController.java @@ -56,13 +56,13 @@ public void mails(final WebContext webContext) { /** * Shows the details of a selected mail. * - * @param ctx the current request + * @param webContext the current request * @param id the id of the mail to show */ @Permission(Protocols.PERMISSION_SYSTEM_PROTOCOLS) @Routed("/system/mail/:1") - public void mail(final WebContext ctx, String id) { + public void mail(final WebContext webContext, String id) { MailProtocol mailLogEntry = find(MailProtocol.class, id); - ctx.respondWith().template("/templates/biz/protocol/mail.html.pasta", mailLogEntry); + webContext.respondWith().template("/templates/biz/protocol/mail.html.pasta", mailLogEntry); } } diff --git a/src/main/java/sirius/biz/protocol/Protocols.java b/src/main/java/sirius/biz/protocol/Protocols.java index b704db9a8..a160657d1 100644 --- a/src/main/java/sirius/biz/protocol/Protocols.java +++ b/src/main/java/sirius/biz/protocol/Protocols.java @@ -134,8 +134,8 @@ public void handle(Incident incident) throws Exception { si.setLastOccurrence(LocalDateTime.now()); elastic.update(si); - } catch (Exception e) { - Elastic.LOG.SEVERE(e); + } catch (Exception exception) { + Elastic.LOG.SEVERE(exception); disableForOneMinute(); } } @@ -155,8 +155,8 @@ public void handleLogMessage(LogMessage message) { msg.setUser(UserContext.getCurrentUser().getProtocolUsername()); autoBatch.insertAsync(msg); - } catch (Exception e) { - Exceptions.ignore(e); + } catch (Exception exception) { + Exceptions.ignore(exception); disableForOneMinute(); } } @@ -226,8 +226,8 @@ public void logSentMail(boolean success, msg.setType(type); elastic.update(msg); - } catch (Exception e) { - Exceptions.handle(e); + } catch (Exception exception) { + Exceptions.handle(exception); } } } diff --git a/src/main/java/sirius/biz/sequences/Sequences.java b/src/main/java/sirius/biz/sequences/Sequences.java index 219a18fdf..dc58f9cdc 100644 --- a/src/main/java/sirius/biz/sequences/Sequences.java +++ b/src/main/java/sirius/biz/sequences/Sequences.java @@ -80,10 +80,10 @@ public long generateId(String sequence) { } return generateInLock(sequence); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to generate an unique number for %s: %s (%s)", sequence) .handle(); } @@ -132,10 +132,10 @@ private long generateInLock(String sequence) throws Exception { public void setNextValue(String sequence, long nextValue, boolean force) { try { sequenceStrategy.setNextValue(sequence, nextValue, force); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Failed to specify the next value for sequence %s due to an error: %s (%s)", sequence) @@ -156,10 +156,10 @@ public void setNextValue(String sequence, long nextValue, boolean force) { public long peekNextValue(String sequence) { try { return sequenceStrategy.peekNextValue(sequence); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Failed to peek the next value for sequence %s due to an error: %s (%s)", sequence) @@ -179,10 +179,10 @@ public List getKnownSequences() { List result = new ArrayList<>(); sequenceStrategy.collectKnownSequences(result::add); return result; - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Failed to determine the list of known sequences due to an error: %s (%s)") .handle(); diff --git a/src/main/java/sirius/biz/sequences/jdbc/SQLSequenceStrategy.java b/src/main/java/sirius/biz/sequences/jdbc/SQLSequenceStrategy.java index 3e48698a7..94a4d51b4 100644 --- a/src/main/java/sirius/biz/sequences/jdbc/SQLSequenceStrategy.java +++ b/src/main/java/sirius/biz/sequences/jdbc/SQLSequenceStrategy.java @@ -81,9 +81,9 @@ private Long createSequence(String sequence) { result.setNextValue(2); oma.update(result); return 1L; - } catch (HandledException e) { + } catch (HandledException exception) { // This only happens if another thread / server inserted the entity already... - Exceptions.ignore(e); + Exceptions.ignore(exception); return null; } } diff --git a/src/main/java/sirius/biz/sequences/mongo/MongoSequenceStrategy.java b/src/main/java/sirius/biz/sequences/mongo/MongoSequenceStrategy.java index d0987d9a0..072e6824e 100644 --- a/src/main/java/sirius/biz/sequences/mongo/MongoSequenceStrategy.java +++ b/src/main/java/sirius/biz/sequences/mongo/MongoSequenceStrategy.java @@ -86,15 +86,15 @@ private Long createSequence(String sequence) { .into(MongoSequenceCounter.class); return 1L; - } catch (MongoWriteException e) { - if (e.getError().getCode() == 11000) { + } catch (MongoWriteException exception) { + if (exception.getError().getCode() == 11000) { // This only happens if another thread / server inserted the entity already... - Exceptions.ignore(e); + Exceptions.ignore(exception); return null; } else { throw Exceptions.handle() .to(Mongo.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to create the sequence: %s - %s (%s)", sequence) .handle(); } diff --git a/src/main/java/sirius/biz/storage/layer1/FSObjectStorageSpace.java b/src/main/java/sirius/biz/storage/layer1/FSObjectStorageSpace.java index 0e847c330..4da78c219 100644 --- a/src/main/java/sirius/biz/storage/layer1/FSObjectStorageSpace.java +++ b/src/main/java/sirius/biz/storage/layer1/FSObjectStorageSpace.java @@ -77,10 +77,10 @@ private File resolveEffectiveBaseDir(Extension extension) { extension.getId(), root); root.mkdirs(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 1/fs: Unable to resolve the base directory of space '%s' ('%s')" + " into a directory: %s (%s)!", @@ -220,11 +220,11 @@ protected FileHandle getData(String objectKey, ByteBlockTransformer transformer) Streams.transfer(in, out); } return FileHandle.temporaryFileHandle(dest); - } catch (Exception e) { + } catch (Exception exception) { Files.delete(dest); throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 1/fs: An error occurred while trying to download: %s/%s - %s (%s)", name, @@ -239,8 +239,8 @@ protected Promise getDataAsync(String objectId, ByteBlockTransformer Promise result = new Promise<>(); try { result.success(getData(objectId, transformer)); - } catch (IOException e) { - result.fail(e); + } catch (IOException exception) { + result.fail(exception); } return result; diff --git a/src/main/java/sirius/biz/storage/layer1/ObjectStorage.java b/src/main/java/sirius/biz/storage/layer1/ObjectStorage.java index 05c0b7719..0c5a40f41 100644 --- a/src/main/java/sirius/biz/storage/layer1/ObjectStorage.java +++ b/src/main/java/sirius/biz/storage/layer1/ObjectStorage.java @@ -96,9 +96,9 @@ private ObjectStorageSpace createSpace(Extension extension) { ObjectStoraceSpaceFactory.class); return factory.create(extension.getId(), extension); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() - .error(e) + .error(exception) .to(StorageUtils.LOG) .withSystemErrorMessage( "Layer 1: Failed to create the object storage space '%s' of type '%s': %s (%s)", diff --git a/src/main/java/sirius/biz/storage/layer1/ObjectStorageSpace.java b/src/main/java/sirius/biz/storage/layer1/ObjectStorageSpace.java index a606270f5..d2d000dcc 100644 --- a/src/main/java/sirius/biz/storage/layer1/ObjectStorageSpace.java +++ b/src/main/java/sirius/biz/storage/layer1/ObjectStorageSpace.java @@ -551,22 +551,21 @@ private boolean shouldHandleAsLargeFile(Response response, boolean largeFileExpe return largeFileExpected && !response.getWebContext().getHeaderValue(HttpHeaderNames.RANGE).isFilled(); } - private void handleDeliveryError(Response response, String objectId, Exception exception) { - if (isExceptionOf(exception, ClosedChannelException.class) - || isExceptionOf(exception, - ConnectionClosedException.class) - || isExceptionOf(exception, SocketException.class)) { + private void handleDeliveryError(Response response, String objectId, Exception error) { + if (isExceptionOf(error, ClosedChannelException.class) + || isExceptionOf(error, ConnectionClosedException.class) + || isExceptionOf(error, SocketException.class)) { // If the user unexpectedly closes the connection, we do not need to log an error... - Exceptions.ignore(exception); + Exceptions.ignore(error); return; } try { response.error(HttpResponseStatus.INTERNAL_SERVER_ERROR); - } catch (Exception ex) { - Exceptions.ignore(ex); + } catch (Exception exception) { + Exceptions.ignore(exception); } throw Exceptions.handle() - .error(exception) + .error(error) .to(StorageUtils.LOG) .withSystemErrorMessage("Layer 1: An error occurred when delivering %s (%s) for %s: %s (%s)", objectId, diff --git a/src/main/java/sirius/biz/storage/layer1/S3ObjectStorageSpace.java b/src/main/java/sirius/biz/storage/layer1/S3ObjectStorageSpace.java index 4fb4ed717..3c4a0a6e9 100644 --- a/src/main/java/sirius/biz/storage/layer1/S3ObjectStorageSpace.java +++ b/src/main/java/sirius/biz/storage/layer1/S3ObjectStorageSpace.java @@ -156,8 +156,8 @@ protected void deliverPhysicalObject(Response response, protected FileHandle getData(String objectKey) throws IOException { try { return FileHandle.temporaryFileHandle(store.download(bucketName(), objectKey)); - } catch (FileNotFoundException e) { - Exceptions.ignore(e); + } catch (FileNotFoundException exception) { + Exceptions.ignore(exception); return null; } } @@ -166,8 +166,8 @@ protected FileHandle getData(String objectKey) throws IOException { protected Promise getDataAsync(String objectId) { try { return store.downloadAsync(bucketName(), objectId); - } catch (FileNotFoundException ex) { - Exceptions.ignore(ex); + } catch (FileNotFoundException exception) { + Exceptions.ignore(exception); return new Promise<>(null); } } @@ -183,11 +183,11 @@ protected FileHandle getData(String objectKey, ByteBlockTransformer transformer) Streams.transfer(in, out); } return FileHandle.temporaryFileHandle(dest); - } catch (Exception e) { + } catch (Exception exception) { Files.delete(dest); throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 1/S3: An error occurred while trying to download: %s/%s - %s (%s)", name, @@ -205,9 +205,9 @@ protected Promise getDataAsync(String objectId, ByteBlockTransformer tasks.executor(ObjectStore.EXECUTOR_S3).fork(() -> { try { result.success(getData(objectId, transformer)); - } catch (Exception ex) { + } catch (Exception exception) { result.fail(Exceptions.handle() - .error(ex) + .error(exception) .to(StorageUtils.LOG) .withSystemErrorMessage( "Layer 1/S3: An error occurred when downloading %s (%s): %s (%s)", diff --git a/src/main/java/sirius/biz/storage/layer1/replication/ForceReplicationJob.java b/src/main/java/sirius/biz/storage/layer1/replication/ForceReplicationJob.java index 8ead570ec..27134d186 100644 --- a/src/main/java/sirius/biz/storage/layer1/replication/ForceReplicationJob.java +++ b/src/main/java/sirius/biz/storage/layer1/replication/ForceReplicationJob.java @@ -95,8 +95,8 @@ protected void execute(ProcessContext process) throws Exception { process.debug(ProcessLog.info() .withFormattedMessage("Ignored unmodified object: %s", metadata.getKey())); } - } catch (Exception e) { - process.handle(e); + } catch (Exception exception) { + process.handle(exception); } return true; diff --git a/src/main/java/sirius/biz/storage/layer1/replication/jdbc/SQLReplicationTaskStorage.java b/src/main/java/sirius/biz/storage/layer1/replication/jdbc/SQLReplicationTaskStorage.java index f9af81d65..2571b9e95 100644 --- a/src/main/java/sirius/biz/storage/layer1/replication/jdbc/SQLReplicationTaskStorage.java +++ b/src/main/java/sirius/biz/storage/layer1/replication/jdbc/SQLReplicationTaskStorage.java @@ -91,10 +91,10 @@ protected void markTaskAsScheduled(SQLReplicationTask task, String txnId) { .where(SQLReplicationTask.EARLIEST_EXECUTION, Operator.LT, LocalDateTime.now()) .where(SQLReplicationTask.ID, task.getId()) .executeUpdate(); - } catch (SQLException e) { + } catch (SQLException exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 1/replication: Failed to mark SQL replication task %s as scheduled: %s (%s)", task.getId()) @@ -141,7 +141,7 @@ private void executeTask(SQLReplicationTask task) { task.getContentLength(), task.isPerformDelete()); oma.delete(task); - } catch (Exception ex) { + } catch (Exception exception) { try { task = oma.refreshOrFail(task); task.setLastExecution(LocalDateTime.now()); @@ -153,7 +153,7 @@ private void executeTask(SQLReplicationTask task) { task.setFailed(true); Exceptions.handle() .to(StorageUtils.LOG) - .error(ex) + .error(exception) .withSystemErrorMessage( "Layer 1/replication: A storage replication task (%s) ultimately failed: Primary space: %s, object: %s - %s (%s)", task.getIdAsString(), @@ -163,11 +163,11 @@ private void executeTask(SQLReplicationTask task) { } oma.update(task); - } catch (Exception e) { + } catch (Exception innerException) { // If a task cannot be refreshed or update it was most probably deleted // or updated by an administrative task -> simply ignore this error as we're either done // or we'll eventually re-process this task... - Exceptions.ignore(e); + Exceptions.ignore(innerException); } } } diff --git a/src/main/java/sirius/biz/storage/layer1/replication/mongo/MongoReplicationTaskStorage.java b/src/main/java/sirius/biz/storage/layer1/replication/mongo/MongoReplicationTaskStorage.java index 9630060dc..5a945984a 100644 --- a/src/main/java/sirius/biz/storage/layer1/replication/mongo/MongoReplicationTaskStorage.java +++ b/src/main/java/sirius/biz/storage/layer1/replication/mongo/MongoReplicationTaskStorage.java @@ -97,10 +97,10 @@ protected void markTaskAsScheduled(MongoReplicationTask task, String txnId) { .where(QueryBuilder.FILTERS.lt(MongoReplicationTask.EARLIEST_EXECUTION, LocalDateTime.now())) .where(MongoReplicationTask.ID, task.getId()) .executeForOne(MongoReplicationTask.class); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 1/replication: Failed to mark MongoDB replication task %s as scheduled: %s (%s)", task.getId()) @@ -147,7 +147,7 @@ private void executeTask(MongoReplicationTask task) { task.getContentLength(), task.isPerformDelete()); mango.delete(task); - } catch (Exception ex) { + } catch (Exception exception) { try { Updater updater = mongo.update() .where(MongoReplicationTask.ID, task.getId()) @@ -170,7 +170,7 @@ private void executeTask(MongoReplicationTask task) { Exceptions.handle() .to(StorageUtils.LOG) - .error(ex) + .error(exception) .withSystemErrorMessage( "Layer 1/replication: A storage replication task (%s) ultimately failed: Primary space: %s, object: %s - %s (%s)", task.getIdAsString(), @@ -180,8 +180,8 @@ private void executeTask(MongoReplicationTask task) { } updater.executeForOne(MongoReplicationTask.class); - } catch (Exception e) { - Exceptions.handle(StorageUtils.LOG, e); + } catch (Exception innerException) { + Exceptions.handle(StorageUtils.LOG, innerException); } } } diff --git a/src/main/java/sirius/biz/storage/layer1/transformer/CipherTransformer.java b/src/main/java/sirius/biz/storage/layer1/transformer/CipherTransformer.java index d4c824503..2e19101dd 100644 --- a/src/main/java/sirius/biz/storage/layer1/transformer/CipherTransformer.java +++ b/src/main/java/sirius/biz/storage/layer1/transformer/CipherTransformer.java @@ -66,8 +66,8 @@ public Optional complete() throws IOException { } else { return Optional.empty(); } - } catch (IllegalBlockSizeException | BadPaddingException e) { - throw new IOException("Invalid cipher data", e); + } catch (IllegalBlockSizeException | BadPaddingException exception) { + throw new IOException("Invalid cipher data", exception); } } } diff --git a/src/main/java/sirius/biz/storage/layer1/transformer/CombinedTransformer.java b/src/main/java/sirius/biz/storage/layer1/transformer/CombinedTransformer.java index 87e12e2c6..93137a7fe 100644 --- a/src/main/java/sirius/biz/storage/layer1/transformer/CombinedTransformer.java +++ b/src/main/java/sirius/biz/storage/layer1/transformer/CombinedTransformer.java @@ -63,8 +63,8 @@ public Optional complete() throws IOException { protected Optional forwardToSecond(ByteBuf intermediateBuffer) { try { return second.apply(intermediateBuffer); - } catch (IOException e) { - throw new IllegalStateException(e); + } catch (IOException exception) { + throw new IllegalStateException(exception); } } } diff --git a/src/main/java/sirius/biz/storage/layer1/transformer/InflateTransformer.java b/src/main/java/sirius/biz/storage/layer1/transformer/InflateTransformer.java index a05713bea..3325d68dd 100644 --- a/src/main/java/sirius/biz/storage/layer1/transformer/InflateTransformer.java +++ b/src/main/java/sirius/biz/storage/layer1/transformer/InflateTransformer.java @@ -49,8 +49,8 @@ public Optional apply(ByteBuf input) throws IOException { try { int outputLength = inflater.inflate(inflateBuffer); outputBuffer.writeBytes(inflateBuffer, 0, outputLength); - } catch (DataFormatException e) { - throw new IOException(e); + } catch (DataFormatException exception) { + throw new IOException(exception); } } @@ -71,8 +71,8 @@ public Optional complete() throws IOException { try { int outputLength = inflater.inflate(inflateBuffer); outputBuffer.writeBytes(inflateBuffer, 0, outputLength); - } catch (DataFormatException e) { - throw new IOException(e); + } catch (DataFormatException exception) { + throw new IOException(exception); } } diff --git a/src/main/java/sirius/biz/storage/layer1/transformer/SecretKeyCipherProvider.java b/src/main/java/sirius/biz/storage/layer1/transformer/SecretKeyCipherProvider.java index 3d1394844..b9322cb4b 100644 --- a/src/main/java/sirius/biz/storage/layer1/transformer/SecretKeyCipherProvider.java +++ b/src/main/java/sirius/biz/storage/layer1/transformer/SecretKeyCipherProvider.java @@ -39,10 +39,10 @@ public Cipher createEncryptionCipher() { Cipher cipher = Cipher.getInstance(algorithm); cipher.init(Cipher.ENCRYPT_MODE, secretKey); return cipher; - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 1: Failed to create an encryption cipher: %s (%s)") .handle(); } @@ -54,10 +54,10 @@ public Cipher createDecryptionChiper() { Cipher cipher = Cipher.getInstance(algorithm); cipher.init(Cipher.DECRYPT_MODE, secretKey); return cipher; - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 1: Failed to create an encryption cipher: %s (%s)") .handle(); } diff --git a/src/main/java/sirius/biz/storage/layer2/BasicBlobStorageSpace.java b/src/main/java/sirius/biz/storage/layer2/BasicBlobStorageSpace.java index 01dc200ba..3efb5efae 100644 --- a/src/main/java/sirius/biz/storage/layer2/BasicBlobStorageSpace.java +++ b/src/main/java/sirius/biz/storage/layer2/BasicBlobStorageSpace.java @@ -414,8 +414,8 @@ protected R findOrCreateWithOptimisticLock(Producer throw errorHandler.apply(new IllegalStateException(Strings.apply( "Failed to execute an optimistic locked update after %s retries", NUMBER_OF_ATTEMPTS_FOR_OPTIMISTIC_LOCKS))); - } catch (Exception e) { - throw errorHandler.apply(e); + } catch (Exception exception) { + throw errorHandler.apply(exception); } } @@ -1081,8 +1081,8 @@ public Optional download(String blobKey, String variant) { } return getPhysicalSpace().download(physicalKey.getFirst()); - } catch (Exception e) { - handleFailedConversion(blobKey, variant, e); + } catch (Exception exception) { + handleFailedConversion(blobKey, variant, exception); return Optional.empty(); } @@ -1128,18 +1128,18 @@ private Optional tryDelegateDownload(String blobKey, String variant, } else { throw connectException; } - } catch (IOException ex) { + } catch (IOException exception) { Files.delete(temporaryFile); - throw ex; + throw exception; } return Optional.of(FileHandle.temporaryFileHandle(temporaryFile)); } - private void handleFailedConversion(String blobKey, String variant, Exception e) { - failedVariantHandlers.forEach(handler -> handler.handle(e, blobKey, variant)); + private void handleFailedConversion(String blobKey, String variant, Exception exception) { + failedVariantHandlers.forEach(handler -> handler.handle(exception, blobKey, variant)); Exceptions.handle() - .error(e) + .error(exception) .to(StorageUtils.LOG) .withSystemErrorMessage("Layer2: Failed to perform conversion of %s for %s: %s (%s)", blobKey, @@ -1188,16 +1188,16 @@ public void updateContent(B blob, @Nullable String filename, File file) { } blobByPathCache.removeAll(REMOVE_BY_FILENAME, blob.getFilename()); - } catch (Exception e) { + } catch (Exception exception) { try { getPhysicalSpace().delete(nextPhysicalId); - } catch (Exception ex) { - Exceptions.ignore(ex); + } catch (Exception innnerException) { + Exceptions.ignore(innnerException); } throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 2: Cannot update the contents of %s in %s: %s (%s)", blob.getBlobKey(), spaceName) @@ -1244,15 +1244,15 @@ public void updateContent(B blob, String filename, InputStream data, long conten } blobByPathCache.removeAll(REMOVE_BY_FILENAME, blob.getFilename()); - } catch (Exception e) { + } catch (Exception exception) { try { getPhysicalSpace().delete(nextPhysicalId); - } catch (Exception ex) { - Exceptions.ignore(ex); + } catch (Exception innerException) { + Exceptions.ignore(innerException); } - if (e instanceof InterruptedIOException || e.getCause() instanceof InterruptedIOException) { + if (exception instanceof InterruptedIOException || exception.getCause() instanceof InterruptedIOException) { throw Exceptions.createHandled() - .error(e) + .error(exception) .withSystemErrorMessage("Layer 2: Interrupted updating contents of %s in %s: %s (%s)", blob.getBlobKey(), spaceName) @@ -1261,7 +1261,7 @@ public void updateContent(B blob, String filename, InputStream data, long conten throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 2: Cannot update the contents of %s in %s: %s (%s)", blob.getBlobKey(), spaceName) @@ -1301,10 +1301,10 @@ public OutputStream createOutputStream(B blob, @Nullable String filename, @Nulla Files.delete(file); } }); - } catch (IOException e) { + } catch (IOException exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 2: Cannot create a local buffer to provide an output stream for %s (%s) in %s: %s (%s)", blob.getBlobKey(), @@ -1338,10 +1338,10 @@ public void deliver(String blobKey, String variant, Response response, Runnable deliverAsync(blobKey, variant, response); } - } catch (IllegalArgumentException e) { - response.notCached().error(HttpResponseStatus.BAD_REQUEST, e.getMessage()); - } catch (Exception e) { - handleFailedConversion(blobKey, variant, e); + } catch (IllegalArgumentException exception) { + response.notCached().error(HttpResponseStatus.BAD_REQUEST, exception.getMessage()); + } catch (Exception exception) { + handleFailedConversion(blobKey, variant, exception); response.notCached().error(HttpResponseStatus.INTERNAL_SERVER_ERROR); } } @@ -1438,8 +1438,8 @@ protected Optional tryResolvePhysicalKey(String blobKey, String variantN } else { return Optional.ofNullable(keyAndCacheFlag.getFirst()); } - } catch (Exception e) { - handleFailedConversion(blobKey, variantName, e); + } catch (Exception exception) { + handleFailedConversion(blobKey, variantName, exception); return Optional.empty(); } } @@ -1498,10 +1498,10 @@ protected V findOrCreateVariant(B blob, String variantName, boolean nonblocking) variantName, nonblocking, NUMBER_OF_ATTEMPTS_FOR_OPTIMISTIC_LOCKS - 1); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 2: Failed to find or create the variant %s of %s in %s: %s (%s)", variantName, @@ -1911,8 +1911,8 @@ private void deliverAsync(String blobKey, String variant, Response response) { Boolean.TRUE.equals(physicalKey.getSecond()) ? "cache" : "computed"); getPhysicalSpace().deliver(response, physicalKey.getFirst(), false); } - } catch (Exception e) { - handleFailedConversion(blobKey, variant, e); + } catch (Exception exception) { + handleFailedConversion(blobKey, variant, exception); response.notCached().error(HttpResponseStatus.INTERNAL_SERVER_ERROR); } }); @@ -1993,8 +1993,8 @@ private Optional determineDelegateConversionUrl(String blobKey, String vari try { return Optional.of(URI.create(conversionUrl).toURL()); - } catch (MalformedURLException e) { - throw Exceptions.handle(e); + } catch (MalformedURLException exception) { + throw Exceptions.handle(exception); } } diff --git a/src/main/java/sirius/biz/storage/layer2/BlobController.java b/src/main/java/sirius/biz/storage/layer2/BlobController.java index 3fb8792a7..9c0d929ff 100644 --- a/src/main/java/sirius/biz/storage/layer2/BlobController.java +++ b/src/main/java/sirius/biz/storage/layer2/BlobController.java @@ -54,45 +54,49 @@ public class BlobController extends BizController { * deleted. However, if an entity references the blob via a {@link BlobHardRef}, it will be marked * as permanent. * - * @param ctx the request to handle - * @param out the response to the AJAX call - * @param spaceName the {@link BlobStorageSpace} to store the object in - * @param upload the content of the upload + * @param webContext the request to handle + * @param output the response to the AJAX call + * @param spaceName the {@link BlobStorageSpace} to store the object in + * @param upload the content of the upload */ @Routed(value = "/dasd/upload-file/:1", preDispatchable = true) @InternalService @LoginRequired - public void uploadFile(final WebContext ctx, - JSONStructuredOutput out, + public void uploadFile(final WebContext webContext, + JSONStructuredOutput output, String spaceName, InputStreamHandler upload) { Blob blob = blobStorage.getSpace(spaceName).createTemporaryBlob(); try { try (upload) { - ctx.markAsLongCall(); + webContext.markAsLongCall(); //TODO SIRI-96 remove legacy qqfile once library is updated... - String name = ctx.get(KEY_FILENAME).asString(ctx.get(KEY_FILE).asString()); - blob.updateContent(name, upload, Long.parseLong(ctx.getHeader(HttpHeaderNames.CONTENT_LENGTH))); + String name = webContext.get(KEY_FILENAME).asString(webContext.get(KEY_FILE).asString()); + blob.updateContent(name, upload, Long.parseLong(webContext.getHeader(HttpHeaderNames.CONTENT_LENGTH))); - out.property(KEY_FILE_ID, blob.getBlobKey()); + output.property(KEY_FILE_ID, blob.getBlobKey()); // TODO SIRI-96 remove once the blobHardRefField has been refactored - out.property(KEY_PREVIEW_URL, blob.url().asDownload().buildURL().orElse("")); - out.property(KEY_IMAGE_URL, blob.url().withVariant(ctx.get("variant").asString("raw")).buildURL().orElse("")); + output.property(KEY_PREVIEW_URL, blob.url().asDownload().buildURL().orElse("")); + output.property(KEY_IMAGE_URL, + blob.url() + .withVariant(webContext.get("variant").asString("raw")) + .buildURL() + .orElse("")); - out.property(KEY_DOWNLOAD_URL, blob.url().asDownload().buildURL().orElse("")); - out.property(KEY_FILENAME, blob.getFilename()); - out.property(KEY_SIZE, blob.getSize()); - out.property(KEY_FORMATTED_SIZE, NLS.formatSize(blob.getSize())); + output.property(KEY_DOWNLOAD_URL, blob.url().asDownload().buildURL().orElse("")); + output.property(KEY_FILENAME, blob.getFilename()); + output.property(KEY_SIZE, blob.getSize()); + output.property(KEY_FORMATTED_SIZE, NLS.formatSize(blob.getSize())); } - } catch (IOException e) { + } catch (IOException exception) { blob.delete(); - throw Exceptions.createHandled().error(e).handle(); - } catch (Exception e) { + throw Exceptions.createHandled().error(exception).handle(); + } catch (Exception exception) { blob.delete(); throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to upload a file into space '%s': %s (%s)", spaceName) .handle(); } @@ -102,13 +106,13 @@ public void uploadFile(final WebContext ctx, * Finds the {@link Blob} for a given path and returns info about it. * * @param webContext the request to handle - * @param out the response to the AJAX call + * @param output the response to the AJAX call * @param spaceName the {@link BlobStorageSpace} to find the object in */ @Routed("/dasd/blob-info-for-path/:1") @InternalService @LoginRequired - public void blobInfoForPath(final WebContext webContext, JSONStructuredOutput out, String spaceName) { + public void blobInfoForPath(final WebContext webContext, JSONStructuredOutput output, String spaceName) { String path = webContext.getParameter(KEY_PATH); BlobStorageSpace space = blobStorage.getSpace(spaceName); @@ -127,10 +131,10 @@ public void blobInfoForPath(final WebContext webContext, JSONStructuredOutput ou spaceName) .handle()); - out.property(KEY_FILE_ID, blob.getBlobKey()); - out.property(KEY_FILENAME, blob.getFilename()); - out.property(KEY_SIZE, blob.getSize()); - out.property(KEY_FORMATTED_SIZE, NLS.formatSize(blob.getSize())); - out.property(KEY_DOWNLOAD_URL, blob.url().asDownload().buildURL().orElse("")); + output.property(KEY_FILE_ID, blob.getBlobKey()); + output.property(KEY_FILENAME, blob.getFilename()); + output.property(KEY_SIZE, blob.getSize()); + output.property(KEY_FORMATTED_SIZE, NLS.formatSize(blob.getSize())); + output.property(KEY_DOWNLOAD_URL, blob.url().asDownload().buildURL().orElse("")); } } diff --git a/src/main/java/sirius/biz/storage/layer2/BlobDispatcher.java b/src/main/java/sirius/biz/storage/layer2/BlobDispatcher.java index dd480f7e0..722d96b73 100644 --- a/src/main/java/sirius/biz/storage/layer2/BlobDispatcher.java +++ b/src/main/java/sirius/biz/storage/layer2/BlobDispatcher.java @@ -145,7 +145,7 @@ private void executeHook(String uri, String hook, String payload) { if (dispatcherHook != null) { dispatcherHook.hook(payload); } - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(StorageUtils.LOG) .withSystemErrorMessage( diff --git a/src/main/java/sirius/biz/storage/layer2/BlobRefProperty.java b/src/main/java/sirius/biz/storage/layer2/BlobRefProperty.java index cb0bd4428..13f341d48 100644 --- a/src/main/java/sirius/biz/storage/layer2/BlobRefProperty.java +++ b/src/main/java/sirius/biz/storage/layer2/BlobRefProperty.java @@ -60,10 +60,10 @@ protected BlobRefProperty(@Nonnull EntityDescriptor descriptor, public BlobHardRef getRef(Object entity) { try { return (BlobHardRef) super.getValueFromField(entity); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(OMA.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Unable to obtain the BlobHardRef object from blob ref field ('%s' in '%s'): %s (%s)", getName(), diff --git a/src/main/java/sirius/biz/storage/layer2/BlobSoftRefProperty.java b/src/main/java/sirius/biz/storage/layer2/BlobSoftRefProperty.java index 020956d47..88a0e70f8 100644 --- a/src/main/java/sirius/biz/storage/layer2/BlobSoftRefProperty.java +++ b/src/main/java/sirius/biz/storage/layer2/BlobSoftRefProperty.java @@ -99,10 +99,10 @@ private BlobSoftRef getReferenceBlobSoftRef() { if (blobSoftRef == null) { try { blobSoftRef = (BlobSoftRef) field.get(accessPath.apply(descriptor.getReferenceInstance())); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(Mixing.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Unable to obtain a reference object from blob ref field ('%s' in '%s'): %s (%s)", getName(), @@ -131,12 +131,12 @@ protected void link() { forEachBlobType(entityDescriptor -> entityDescriptor.addCascadeDeleteHandler(this::onDeleteSetNull)); } - } catch (Exception e) { + } catch (Exception exception) { Mixing.LOG.WARN("Error when linking property %s of %s: %s (%s)", this, getDescriptor(), - e.getMessage(), - e.getClass().getSimpleName()); + exception.getMessage(), + exception.getClass().getSimpleName()); } } diff --git a/src/main/java/sirius/biz/storage/layer2/ProcessBlobChangesLoop.java b/src/main/java/sirius/biz/storage/layer2/ProcessBlobChangesLoop.java index 5820f8061..bba4cd6b1 100644 --- a/src/main/java/sirius/biz/storage/layer2/ProcessBlobChangesLoop.java +++ b/src/main/java/sirius/biz/storage/layer2/ProcessBlobChangesLoop.java @@ -127,8 +127,8 @@ private void invokeBlobChangedHandlers(Blob blob, handlers.forEach(handler -> { try { handler.execute(blob); - } catch (Exception e) { - buildStorageException(e).withSystemErrorMessage( + } catch (Exception exception) { + buildStorageException(exception).withSystemErrorMessage( "Layer 2: %s failed to process %s blob %s (%s) in %s: (%s)", changeType, handler.getClass().getSimpleName(), @@ -139,31 +139,31 @@ private void invokeBlobChangedHandlers(Blob blob, }); } - protected void handleBlobDeletionException(@Nonnull Blob blob, Exception e) { - buildStorageException(e).withSystemErrorMessage("Layer 2: Failed to finally delete the blob %s (%s) in %s: (%s)", + protected void handleBlobDeletionException(@Nonnull Blob blob, Exception exception) { + buildStorageException(exception).withSystemErrorMessage("Layer 2: Failed to finally delete the blob %s (%s) in %s: (%s)", blob.getBlobKey(), blob.getFilename(), blob.getSpaceName()).handle(); } - protected void handleDirectoryDeletionException(@Nonnull Directory dir, Exception e) { - buildStorageException(e).withSystemErrorMessage( + protected void handleDirectoryDeletionException(@Nonnull Directory dir, Exception exception) { + buildStorageException(exception).withSystemErrorMessage( "Layer 2: Failed to finally delete the directory %s (%s) in %s: (%s)", dir.getIdAsString(), dir.getName(), dir.getSpaceName()).handle(); } - protected void handleDirectoryRenameException(@Nonnull Directory dir, Exception e) { - buildStorageException(e).withSystemErrorMessage( + protected void handleDirectoryRenameException(@Nonnull Directory dir, Exception exception) { + buildStorageException(exception).withSystemErrorMessage( "Layer 2: Failed to process rename of directory %s (%s) in %s: (%s)", dir.getIdAsString(), dir.getName(), dir.getSpaceName()).handle(); } - protected Exceptions.ErrorHandler buildStorageException(Exception e) { - return Exceptions.handle().to(StorageUtils.LOG).error(e); + protected Exceptions.ErrorHandler buildStorageException(Exception exception) { + return Exceptions.handle().to(StorageUtils.LOG).error(exception); } /** diff --git a/src/main/java/sirius/biz/storage/layer2/StorageCleanupTask.java b/src/main/java/sirius/biz/storage/layer2/StorageCleanupTask.java index 43cb3b7db..6b7608917 100644 --- a/src/main/java/sirius/biz/storage/layer2/StorageCleanupTask.java +++ b/src/main/java/sirius/biz/storage/layer2/StorageCleanupTask.java @@ -40,8 +40,8 @@ public void execute() throws Exception { if (blobStorage != null) { try { blobStorage.getSpaces().forEach(BlobStorageSpace::runCleanup); - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); } } } diff --git a/src/main/java/sirius/biz/storage/layer2/jdbc/SQLProcessBlobChangesLoop.java b/src/main/java/sirius/biz/storage/layer2/jdbc/SQLProcessBlobChangesLoop.java index 252067ff1..b1779cea6 100644 --- a/src/main/java/sirius/biz/storage/layer2/jdbc/SQLProcessBlobChangesLoop.java +++ b/src/main/java/sirius/biz/storage/layer2/jdbc/SQLProcessBlobChangesLoop.java @@ -36,8 +36,8 @@ protected void deleteBlobs(Runnable counter) { deletePhysicalObject(blob); oma.delete(blob); counter.run(); - } catch (Exception e) { - handleBlobDeletionException(blob, e); + } catch (Exception exception) { + handleBlobDeletionException(blob, exception); } }); } @@ -50,8 +50,8 @@ protected void deleteDirectories(Runnable counter) { propagateDelete(dir); oma.delete(dir); counter.run(); - } catch (Exception e) { - handleDirectoryDeletionException(dir, e); + } catch (Exception exception) { + handleDirectoryDeletionException(dir, exception); } }); }); @@ -102,8 +102,8 @@ protected void propagateDelete(Directory dir) { .where(SQLBlob.DELETED, false) .where(SQLBlob.PARENT, directoryId) .executeUpdate(); - } catch (SQLException e) { - buildStorageException(e).withSystemErrorMessage( + } catch (SQLException exception) { + buildStorageException(exception).withSystemErrorMessage( "Layer 2: Failed to propagate deletion for directory %s (%s) in %s: (%s)", directoryId, dir.getName(), @@ -122,8 +122,8 @@ protected void processRenamedDirectories(Runnable counter) { .where(SQLDirectory.ID, dir.getId()) .executeUpdate(); counter.run(); - } catch (Exception e) { - handleDirectoryDeletionException(dir, e); + } catch (Exception exception) { + handleDirectoryDeletionException(dir, exception); } }); }); @@ -141,8 +141,8 @@ protected void propagateRename(Directory dir) { .set(SQLBlob.PARENT_CHANGED, true) .where(SQLBlob.PARENT, directoryId) .executeUpdate(); - } catch (SQLException e) { - buildStorageException(e).withSystemErrorMessage( + } catch (SQLException exception) { + buildStorageException(exception).withSystemErrorMessage( "Layer 2: Failed to propagate rename for directory %s (%s) in %s: (%s)", directoryId, dir.getName(), @@ -174,8 +174,8 @@ private void fetchAndProcessBlobs(Consumer> queryExtender, update.where(SQLBlob.ID, blob.getId()).executeUpdate(); counter.run(); - } catch (SQLException e) { - buildStorageException(e).withSystemErrorMessage( + } catch (SQLException exception) { + buildStorageException(exception).withSystemErrorMessage( "Layer 2: Failed to reset blob %s (%s) in %s as %s: (%s)", blob.getBlobKey(), blob.getFilename(), diff --git a/src/main/java/sirius/biz/storage/layer2/mongo/MongoBlobStorageSpace.java b/src/main/java/sirius/biz/storage/layer2/mongo/MongoBlobStorageSpace.java index d60de2a09..7815a791a 100644 --- a/src/main/java/sirius/biz/storage/layer2/mongo/MongoBlobStorageSpace.java +++ b/src/main/java/sirius/biz/storage/layer2/mongo/MongoBlobStorageSpace.java @@ -887,10 +887,10 @@ private void deleteOldBlobs() { LocalDateTime.now().minusDays(retentionDays))) .streamBlockwise() .forEach(this::markBlobAsDeleted); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 2/Mongo: Failed to delete old blobs in %s: %s (%s)", spaceName) .handle(); } @@ -905,10 +905,10 @@ protected void deleteTemporaryBlobs() { .where(QueryBuilder.FILTERS.lt(MongoBlob.LAST_MODIFIED, LocalDateTime.now().minusHours(4))) .streamBlockwise() .forEach(this::markBlobAsDeleted); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 2/Mongo: Failed to delete temporary blobs in %s: %s (%s)", spaceName) .handle(); diff --git a/src/main/java/sirius/biz/storage/layer2/mongo/MongoProcessBlobChangesLoop.java b/src/main/java/sirius/biz/storage/layer2/mongo/MongoProcessBlobChangesLoop.java index 5d4f2591b..f306f023c 100644 --- a/src/main/java/sirius/biz/storage/layer2/mongo/MongoProcessBlobChangesLoop.java +++ b/src/main/java/sirius/biz/storage/layer2/mongo/MongoProcessBlobChangesLoop.java @@ -42,8 +42,8 @@ protected void deleteBlobs(Runnable counter) { deletePhysicalObject(blob); mango.delete(blob); counter.run(); - } catch (Exception e) { - handleBlobDeletionException(blob, e); + } catch (Exception exception) { + handleBlobDeletionException(blob, exception); } }); } @@ -55,8 +55,8 @@ protected void deleteDirectories(Runnable counter) { propagateDelete(dir); mango.delete(dir); counter.run(); - } catch (Exception e) { - handleDirectoryDeletionException(dir, e); + } catch (Exception exception) { + handleDirectoryDeletionException(dir, exception); } }); } @@ -114,8 +114,8 @@ protected void processRenamedDirectories(Runnable counter) { .where(MongoDirectory.ID, dir.getId()) .executeForOne(MongoDirectory.class); counter.run(); - } catch (Exception e) { - handleDirectoryRenameException(dir, e); + } catch (Exception exception) { + handleDirectoryRenameException(dir, exception); } }); } diff --git a/src/main/java/sirius/biz/storage/layer2/variants/ConversionEngine.java b/src/main/java/sirius/biz/storage/layer2/variants/ConversionEngine.java index f80608c9a..b17d9e190 100644 --- a/src/main/java/sirius/biz/storage/layer2/variants/ConversionEngine.java +++ b/src/main/java/sirius/biz/storage/layer2/variants/ConversionEngine.java @@ -156,9 +156,9 @@ private Converter createConverter(String variant) { try { return globalContext.findPart(variantConfigSupplier.apply(CONFIG_KEY_TYPE).asString(), ConverterFactory.class).createConverter(variantConfigSupplier); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() - .error(e) + .error(exception) .to(StorageUtils.LOG) .withSystemErrorMessage("Failed to create a converter of type %s for %s: %s (%s)", variantConfigSupplier.apply(CONFIG_KEY_CONVERTER), diff --git a/src/main/java/sirius/biz/storage/layer3/Transfer.java b/src/main/java/sirius/biz/storage/layer3/Transfer.java index 52f90abcf..608a0a2d5 100644 --- a/src/main/java/sirius/biz/storage/layer3/Transfer.java +++ b/src/main/java/sirius/biz/storage/layer3/Transfer.java @@ -370,11 +370,11 @@ protected void transferFileTo(VirtualFile sourceFile, VirtualFile destinationFil try (InputStream input = sourceFile.createInputStream()) { destinationFile.consumeStream(input, sourceFile.size()); return; - } catch (Exception e) { - if (attempt.shouldThrow(e)) { + } catch (Exception exception) { + if (attempt.shouldThrow(exception)) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/VFS: An error occurred when transferring '%s' to '%s': %s (%s)", sourceFile.path(), diff --git a/src/main/java/sirius/biz/storage/layer3/VirtualFileSystem.java b/src/main/java/sirius/biz/storage/layer3/VirtualFileSystem.java index 75e2c1d6d..a46113b4e 100644 --- a/src/main/java/sirius/biz/storage/layer3/VirtualFileSystem.java +++ b/src/main/java/sirius/biz/storage/layer3/VirtualFileSystem.java @@ -151,12 +151,12 @@ public VirtualFile createTemporaryUplink(Function config) { return globalContext.findPart(generatedId, UplinkFactory.class) .make(Strings.generateCode(32), provideShortIdleTimeout(config)) .getFile(root()); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) .withSystemErrorMessage( "Layer 3: An error occurred while initializing a temporary uplink: %s") - .error(e) + .error(exception) .handle(); } } diff --git a/src/main/java/sirius/biz/storage/layer3/VirtualFileSystemController.java b/src/main/java/sirius/biz/storage/layer3/VirtualFileSystemController.java index 8da1b0c5c..385706125 100644 --- a/src/main/java/sirius/biz/storage/layer3/VirtualFileSystemController.java +++ b/src/main/java/sirius/biz/storage/layer3/VirtualFileSystemController.java @@ -147,7 +147,7 @@ private Page computeChildrenAsPage(WebContext webContext, VirtualFi * Uploads a new file or replaces the contents of an existing one. * * @param webContext the request to handle - * @param out the JSON response + * @param output the JSON response * @param inputStream the contents to process * @throws Exception in case of an error */ @@ -155,7 +155,7 @@ private Page computeChildrenAsPage(WebContext webContext, VirtualFi @Routed(value = "/fs/upload", preDispatchable = true) @InternalService @Permission(PERMISSION_VIEW_FILES) - public void upload(WebContext webContext, JSONStructuredOutput out, InputStreamHandler inputStream) + public void upload(WebContext webContext, JSONStructuredOutput output, InputStreamHandler inputStream) throws Exception { VirtualFile parent = vfs.resolve(webContext.get("path").asString()); parent.assertExistingDirectory(); @@ -180,18 +180,18 @@ public void upload(WebContext webContext, JSONStructuredOutput out, InputStreamH } } - out.property("file", file.path()); - out.property("refresh", true); - } catch (Exception e) { + output.property("file", file.path()); + output.property("refresh", true); + } catch (Exception exception) { if (!exists) { try { file.delete(); - } catch (Exception ex) { - Exceptions.ignore(ex); + } catch (Exception innerException) { + Exceptions.ignore(innerException); } } - throw Exceptions.createHandled().error(e).handle(); + throw Exceptions.createHandled().error(exception).handle(); } } @@ -211,8 +211,8 @@ public void delete(WebContext webContext) { file.delete(); showDeletedMessage(); } - } catch (Exception e) { - UserContext.handle(e); + } catch (Exception exception) { + UserContext.handle(exception); } webContext.respondWith() .redirectToGet(new LinkBuilder("/fs").append("path", file.parent().path()).toString()); @@ -238,8 +238,8 @@ public void rename(WebContext webContext) { file.rename(name); UserContext.message(Message.info().withTextMessage(NLS.get("VFSController.renamed"))); } - } catch (Exception e) { - UserContext.handle(e); + } catch (Exception exception) { + UserContext.handle(exception); } webContext.respondWith() .redirectToGet(new LinkBuilder("/fs").append("path", file.parent().path()).toString()); @@ -272,8 +272,8 @@ public void createDirectory(WebContext webContext) { UserContext.message(Message.info().withTextMessage(NLS.get("VFSController.directoryCreated"))); webContext.respondWith() .redirectToGet(new LinkBuilder("/fs").append("path", newDirectory.path()).toString()); - } catch (Exception e) { - UserContext.handle(e); + } catch (Exception exception) { + UserContext.handle(exception); webContext.respondWith().redirectToGet(new LinkBuilder("/fs").append("path", parent.path()).toString()); } } else { @@ -309,8 +309,8 @@ public void move(WebContext webContext) { UserContext.message(Message.info().withTextMessage(NLS.get("VFSController.moved"))); } } - } catch (Exception e) { - UserContext.handle(e); + } catch (Exception exception) { + UserContext.handle(exception); } webContext.respondWith().redirectToGet(new LinkBuilder("/fs").append("path", file.parent().path()).toString()); @@ -333,8 +333,8 @@ public void unlock(WebContext webContext) { try { file.updateReadOnlyFlag(false); - } catch (Exception e) { - UserContext.handle(e); + } catch (Exception exception) { + UserContext.handle(exception); } webContext.respondWith().redirectToGet(new LinkBuilder("/fs").append("path", file.parent().path()).toString()); @@ -346,29 +346,29 @@ public void unlock(WebContext webContext) { * This is used by the selectVFSFile or selectVFSDirectory JavaScript calls/modals. * * @param webContext the request to handle - * @param out the JSON response to populate + * @param output the JSON response to populate */ @LoginRequired @Routed("/fs/list") @InternalService @Permission(PERMISSION_VIEW_FILES) - public void listAPI(WebContext webContext, JSONStructuredOutput out) { + public void listAPI(WebContext webContext, JSONStructuredOutput output) { VirtualFile parent = vfs.resolve(webContext.get("path").asString("/")); if (parent.exists() && !parent.isDirectory()) { parent = parent.parent(); } parent.assertExistingDirectory(); - outputPath(out, parent); - outputChildren(webContext, out, parent); + outputPath(output, parent); + outputChildren(webContext, output, parent); - out.property("canCreateChildren", parent.canCreateChildren()); + output.property("canCreateChildren", parent.canCreateChildren()); } - private void outputChildren(WebContext webContext, JSONStructuredOutput out, VirtualFile parent) { - out.beginArray("children"); + private void outputChildren(WebContext webContext, JSONStructuredOutput output, VirtualFile parent) { + output.beginArray("children"); - FileSearch search = FileSearch.iterateAll(child -> outputFile(out, child.name(), child)); + FileSearch search = FileSearch.iterateAll(child -> outputFile(output, child.name(), child)); if (webContext.get("onlyDirectories").asBoolean()) { search.withOnlyDirectories(); } @@ -392,7 +392,7 @@ private void outputChildren(WebContext webContext, JSONStructuredOutput out, Vir if (skip > 0) { skip--; } else { - outputFile(out, PARENT_DIR, parent.parent()); + outputFile(output, PARENT_DIR, parent.parent()); if (limit != null) { limit--; } @@ -401,34 +401,35 @@ private void outputChildren(WebContext webContext, JSONStructuredOutput out, Vir search.withLimit(new Limit(skip, limit)); parent.children(search); - out.endArray(); + output.endArray(); } - private void outputPath(JSONStructuredOutput out, VirtualFile parent) { - out.beginArray("path"); + private void outputPath(JSONStructuredOutput output, VirtualFile parent) { + output.beginArray("path"); for (VirtualFile element : parent.pathList()) { - out.beginObject("element"); - out.property("name", element.name()); - out.property("path", element.path()); - out.endObject(); + output.beginObject("element"); + output.property("name", element.name()); + output.property("path", element.path()); + output.endObject(); } - out.endArray(); + output.endArray(); } - private void outputFile(JSONStructuredOutput out, String name, VirtualFile child) { - out.beginObject("child"); + private void outputFile(JSONStructuredOutput output, String name, VirtualFile child) { + output.beginObject("child"); try { - out.property("name", name); - out.property("path", child.path()); - out.property("directory", child.isDirectory()); - out.property("size", child.isDirectory() ? 0 : child.size()); - out.property("sizeString", child.isDirectory() ? "" : NLS.formatSize(child.size())); - out.property("lastModified", child.isDirectory() ? null : NLS.toMachineString(child.lastModifiedDate())); - out.property("lastModifiedString", child.isDirectory() ? "" : NLS.toUserString(child.lastModifiedDate())); - out.property("lastModifiedSpokenString", - child.isDirectory() ? "" : NLS.toSpokenDate(child.lastModifiedDate())); + output.property("name", name); + output.property("path", child.path()); + output.property("directory", child.isDirectory()); + output.property("size", child.isDirectory() ? 0 : child.size()); + output.property("sizeString", child.isDirectory() ? "" : NLS.formatSize(child.size())); + output.property("lastModified", child.isDirectory() ? null : NLS.toMachineString(child.lastModifiedDate())); + output.property("lastModifiedString", + child.isDirectory() ? "" : NLS.toUserString(child.lastModifiedDate())); + output.property("lastModifiedSpokenString", + child.isDirectory() ? "" : NLS.toSpokenDate(child.lastModifiedDate())); } finally { - out.endObject(); + output.endObject(); } } } diff --git a/src/main/java/sirius/biz/storage/layer3/downlink/ftp/BridgeFile.java b/src/main/java/sirius/biz/storage/layer3/downlink/ftp/BridgeFile.java index 926fb18f3..6c57d17e9 100644 --- a/src/main/java/sirius/biz/storage/layer3/downlink/ftp/BridgeFile.java +++ b/src/main/java/sirius/biz/storage/layer3/downlink/ftp/BridgeFile.java @@ -184,10 +184,10 @@ public boolean move(FtpFile destination) { } } return this.delete(); - } catch (IOException e) { + } catch (IOException exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer3/FTP: Cannot move file %s to %s - %s (%s)", getAbsolutePath(), destination.getAbsolutePath()); diff --git a/src/main/java/sirius/biz/storage/layer3/downlink/ftp/BridgeUserManager.java b/src/main/java/sirius/biz/storage/layer3/downlink/ftp/BridgeUserManager.java index dc9f16767..96bb2a9ce 100644 --- a/src/main/java/sirius/biz/storage/layer3/downlink/ftp/BridgeUserManager.java +++ b/src/main/java/sirius/biz/storage/layer3/downlink/ftp/BridgeUserManager.java @@ -101,8 +101,8 @@ public BridgeUser authenticate(Authentication authentication) throws Authenticat StorageUtils.LOG.FINE("Layer 3/FTP: User is authorized..."); return new BridgeUser(authUser, UserContext.getCurrentScope().getScopeId()); - } catch (Exception e) { - throw new AuthenticationFailedException(e.getMessage()); + } catch (Exception exception) { + throw new AuthenticationFailedException(exception.getMessage()); } } diff --git a/src/main/java/sirius/biz/storage/layer3/downlink/ftp/FTPServer.java b/src/main/java/sirius/biz/storage/layer3/downlink/ftp/FTPServer.java index 9847a2851..87c1aaa52 100644 --- a/src/main/java/sirius/biz/storage/layer3/downlink/ftp/FTPServer.java +++ b/src/main/java/sirius/biz/storage/layer3/downlink/ftp/FTPServer.java @@ -107,10 +107,10 @@ public void stopped() { if (server != null) { try { server.stop(); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer3/FTP: Failed to stop FTP server on port %s (%s): %s (%s)", ftpPort, bindAddress) @@ -123,10 +123,10 @@ private void startFTPServer() { try { server.start(); StorageUtils.LOG.INFO("Layer3/FTP: Started FTP server on port %s (%s)", ftpPort, bindAddress); - } catch (FtpException e) { + } catch (FtpException exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer3/FTP: Failed to start FTP server on port %s (%s): %s (%s)", ftpPort, bindAddress) diff --git a/src/main/java/sirius/biz/storage/layer3/downlink/ssh/NoopShell.java b/src/main/java/sirius/biz/storage/layer3/downlink/ssh/NoopShell.java index ea4d1841c..ebdb6ef9d 100644 --- a/src/main/java/sirius/biz/storage/layer3/downlink/ssh/NoopShell.java +++ b/src/main/java/sirius/biz/storage/layer3/downlink/ssh/NoopShell.java @@ -87,8 +87,8 @@ private void processInput(IoReadFuture future) { outputStream.writeBuffer(future.getBuffer()); readBuffer.clear(); inputStream.read(readBuffer).addListener(this::processInput); - } catch (IOException e) { - Exceptions.ignore(e); + } catch (IOException exception) { + Exceptions.ignore(exception); exitCallback.onExit(-1); } } diff --git a/src/main/java/sirius/biz/storage/layer3/downlink/ssh/SSHServer.java b/src/main/java/sirius/biz/storage/layer3/downlink/ssh/SSHServer.java index 801599299..f8aaa3779 100644 --- a/src/main/java/sirius/biz/storage/layer3/downlink/ssh/SSHServer.java +++ b/src/main/java/sirius/biz/storage/layer3/downlink/ssh/SSHServer.java @@ -117,8 +117,8 @@ public void started() { server.start(); StorageUtils.LOG.INFO("Layer 3/SSH: Successfully started the SSH server on port %s", port); - } catch (IOException e) { - StorageUtils.LOG.WARN("Layer 3/SSH: Failed to start the SSH server: %s", e.getMessage()); + } catch (IOException exception) { + StorageUtils.LOG.WARN("Layer 3/SSH: Failed to start the SSH server: %s", exception.getMessage()); } } @@ -212,8 +212,8 @@ public void stopped() { if (server != null && server.isStarted()) { try { server.stop(); - } catch (IOException e) { - StorageUtils.LOG.WARN("Layer 3/SSH: Failed to stop the SSH server: %s", e.getMessage()); + } catch (IOException exception) { + StorageUtils.LOG.WARN("Layer 3/SSH: Failed to stop the SSH server: %s", exception.getMessage()); } } } @@ -223,8 +223,8 @@ public void awaitTermination() { if (server != null && server.isStarted()) { try { server.stop(true); - } catch (IOException e) { - StorageUtils.LOG.WARN("Layer 3/SSH: Failed to terminate the SSH server: %s", e.getMessage()); + } catch (IOException exception) { + StorageUtils.LOG.WARN("Layer 3/SSH: Failed to terminate the SSH server: %s", exception.getMessage()); } } } diff --git a/src/main/java/sirius/biz/storage/layer3/downlink/ssh/scp/BridgeScpCommand.java b/src/main/java/sirius/biz/storage/layer3/downlink/ssh/scp/BridgeScpCommand.java index 1753cbd21..c038b0a9e 100644 --- a/src/main/java/sirius/biz/storage/layer3/downlink/ssh/scp/BridgeScpCommand.java +++ b/src/main/java/sirius/biz/storage/layer3/downlink/ssh/scp/BridgeScpCommand.java @@ -55,10 +55,10 @@ public void run() { } UserContext.get().runAs(user, super::run); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/SCP: An error occurred: %s (%s)") .handle(); } diff --git a/src/main/java/sirius/biz/storage/layer3/downlink/ssh/sftp/BridgeSeekableByteChannel.java b/src/main/java/sirius/biz/storage/layer3/downlink/ssh/sftp/BridgeSeekableByteChannel.java index 535548828..06a10a4ff 100644 --- a/src/main/java/sirius/biz/storage/layer3/downlink/ssh/sftp/BridgeSeekableByteChannel.java +++ b/src/main/java/sirius/biz/storage/layer3/downlink/ssh/sftp/BridgeSeekableByteChannel.java @@ -131,16 +131,16 @@ public void close() throws IOException { try { in.close(); in = null; - } catch (IOException e) { - Exceptions.ignore(e); + } catch (IOException exception) { + Exceptions.ignore(exception); } } if (out != null) { try { out.close(); out = null; - } catch (IOException e) { - Exceptions.ignore(e); + } catch (IOException exception) { + Exceptions.ignore(exception); } } } diff --git a/src/main/java/sirius/biz/storage/layer3/downlink/ssh/sftp/BridgeSftpSubsystem.java b/src/main/java/sirius/biz/storage/layer3/downlink/ssh/sftp/BridgeSftpSubsystem.java index cc7835d1e..b55f10e11 100644 --- a/src/main/java/sirius/biz/storage/layer3/downlink/ssh/sftp/BridgeSftpSubsystem.java +++ b/src/main/java/sirius/biz/storage/layer3/downlink/ssh/sftp/BridgeSftpSubsystem.java @@ -52,10 +52,10 @@ public void run() { } UserContext.get().runAs(user, super::run); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/SFTP: An error occurred: %s (%s)") .handle(); } diff --git a/src/main/java/sirius/biz/storage/layer3/uplink/ConfigBasedUplinksRoot.java b/src/main/java/sirius/biz/storage/layer3/uplink/ConfigBasedUplinksRoot.java index 46b35df17..47fd7ee72 100644 --- a/src/main/java/sirius/biz/storage/layer3/uplink/ConfigBasedUplinksRoot.java +++ b/src/main/java/sirius/biz/storage/layer3/uplink/ConfigBasedUplinksRoot.java @@ -67,15 +67,15 @@ private ConfigBasedUplink makeUplink(Extension extension) { try { return ctx.findPart(extension.get("type").asString(), UplinkFactory.class) .make(extension.get("name").asString(extension.getId()), extension::getRaw); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException exception) { StorageUtils.LOG.SEVERE(Strings.apply( "Layer 3: An error occurred while initializing the uplink '%s' from the system configuration: %s", extension.getId(), - e.getMessage())); - } catch (Exception e) { + exception.getMessage())); + } catch (Exception exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3: An error occurred while initializing the uplink '%s' from the system configuration: %s (%s)", extension.getId()) diff --git a/src/main/java/sirius/biz/storage/layer3/uplink/cifs/CIFSUplink.java b/src/main/java/sirius/biz/storage/layer3/uplink/cifs/CIFSUplink.java index af64305fd..fdd57b172 100644 --- a/src/main/java/sirius/biz/storage/layer3/uplink/cifs/CIFSUplink.java +++ b/src/main/java/sirius/biz/storage/layer3/uplink/cifs/CIFSUplink.java @@ -68,15 +68,15 @@ public ConfigBasedUplink make(String id, Function config) { CIFSContext context = new BaseContext(new BaseConfiguration(true)); return new CIFSUplink(id, config, context, new SmbFile(url, context)); } - } catch (CIFSException e) { + } catch (CIFSException exception) { throw new IllegalArgumentException(Strings.apply( "An error occurred when talking to the CIFS file system: %s - %s", url, - e.getMessage())); - } catch (MalformedURLException e) { + exception.getMessage())); + } catch (MalformedURLException exception) { throw new IllegalArgumentException(Strings.apply("An invalid url (%s) was given: %s", url, - e.getMessage())); + exception.getMessage())); } } @@ -90,10 +90,10 @@ public String getName() { private static final Comparator SORT_BY_DIRECTORY = Comparator.comparing(file -> { try { return file.isDirectory() ? 0 : 1; - } catch (SmbException e) { + } catch (SmbException exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot determine if the file: %s is a directory: %s (%s)", file.getName()) .handle(); @@ -124,10 +124,10 @@ protected VirtualFile findChildInDirectory(VirtualFile parent, String name) { return wrapSmbFile(parent, new SmbFile(parentFile, name + "/")); } return wrapSmbFile(parent, child); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot resolve file: %s in parent: %s - %s (%s)", name, parent) @@ -166,10 +166,10 @@ private boolean fastMoveHandler(VirtualFile file, VirtualFile newParent) { try { file.as(SmbFile.class).renameTo(new SmbFile(newParent.as(SmbFile.class), file.name())); return true; - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot move %s to %s: %s (%s)", file, name) .handle(); } @@ -184,10 +184,10 @@ private boolean renameHandler(VirtualFile file, String name) { try { file.as(SmbFile.class).renameTo(new SmbFile(file.parent().as(SmbFile.class), name)); return true; - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot rename %s to %s: %s (%s)", file, name) .handle(); } @@ -197,10 +197,10 @@ private boolean createDirectoryHandler(VirtualFile file) { try { file.as(SmbFile.class).mkdirs(); return true; - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot create %s as directory: %s (%s)", file) .handle(); } @@ -209,10 +209,10 @@ private boolean createDirectoryHandler(VirtualFile file) { private boolean existsFlagSupplier(VirtualFile file) { try { return file.as(SmbFile.class).exists(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot determine if %s exists: %s (%s)", file) .handle(); } @@ -221,10 +221,10 @@ private boolean existsFlagSupplier(VirtualFile file) { private InputStream inputStreamSupplier(VirtualFile file) { try { return file.as(SmbFile.class).getInputStream(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot open InputStream for %s: %s (%s)", file) .handle(); } @@ -233,10 +233,10 @@ private InputStream inputStreamSupplier(VirtualFile file) { private OutputStream outputStreamSupplier(VirtualFile file) { try { return file.as(SmbFile.class).getOutputStream(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot open OutputStream for %s: %s (%s)", file) .handle(); } @@ -246,10 +246,10 @@ private boolean deleteHandler(VirtualFile file) { try { file.as(SmbFile.class).delete(); return true; - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot delete %s: %s (%s)", file) .handle(); } @@ -263,10 +263,10 @@ private boolean readOnlyHandler(VirtualFile file, boolean readOnly) { file.as(SmbFile.class).setReadWrite(); } return true; - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot change read-only state on %s to %s: %s (%s)", file, readOnly) @@ -282,10 +282,10 @@ private boolean isReadOnlySupplier(VirtualFile file) { } SmbFile parentFile = new SmbFile(smbFile.getParent(), smbFile.getContext()); return !parentFile.exists() || !parentFile.isDirectory() || !parentFile.canWrite(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot determine if %s is read-only: %s (%s)", file) .handle(); } @@ -294,10 +294,10 @@ private boolean isReadOnlySupplier(VirtualFile file) { private boolean isDirectoryFlagSupplier(VirtualFile file) { try { return file.as(SmbFile.class).isDirectory(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot determine if %s is a directory: %s (%s)", file) .handle(); @@ -312,10 +312,10 @@ private long sizeSupplier(VirtualFile file) { } return smbFile.length(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot determine the size of %s - %s (%s)", file) .handle(); } @@ -324,10 +324,10 @@ private long sizeSupplier(VirtualFile file) { private long lastModifiedSupplier(VirtualFile file) { try { return file.as(SmbFile.class).getLastModified(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot determine last modified of %s - %s (%s)", file) .handle(); @@ -348,10 +348,10 @@ protected void enumerateDirectoryChildren(@Nonnull VirtualFile parent, FileSearc return; } } - } catch (SmbException e) { + } catch (SmbException exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/CIFS: Cannot iterate over children of %s - %s (%s)", parent) .handle(); diff --git a/src/main/java/sirius/biz/storage/layer3/uplink/fs/LocalDirectoryUplink.java b/src/main/java/sirius/biz/storage/layer3/uplink/fs/LocalDirectoryUplink.java index c83ed316c..f11bda6ff 100644 --- a/src/main/java/sirius/biz/storage/layer3/uplink/fs/LocalDirectoryUplink.java +++ b/src/main/java/sirius/biz/storage/layer3/uplink/fs/LocalDirectoryUplink.java @@ -84,10 +84,10 @@ protected VirtualFile findChildInDirectory(VirtualFile parent, String name) { parent))); File child = new File(parentFile, name); return wrapFile(parent, child); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot resolve file: %s in parent: %s - %s (%s)", name, parent) @@ -125,10 +125,10 @@ private boolean fastMoveHandler(VirtualFile file, VirtualFile newParent) { try { Files.move(file.as(File.class).toPath(), new File(newParent.as(File.class), file.name()).toPath()); return true; - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot move %s to %s: %s (%s)", file, name) .handle(); } @@ -144,10 +144,10 @@ private boolean renameHandler(VirtualFile file, String name) { try { File unwrappedFile = file.as(File.class); return unwrappedFile.renameTo(new File(unwrappedFile.getParentFile(), name)); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot rename %s to %s: %s (%s)", file, name) .handle(); } @@ -162,10 +162,10 @@ private boolean isReadOnlySupplier(VirtualFile file) { return unwrappedFile.getParentFile() == null || !Files.isWritable(unwrappedFile.getParentFile() .toPath()); } - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot determine if %s is read-only: %s (%s)", file) .handle(); } @@ -175,10 +175,10 @@ private boolean setWritableHandler(VirtualFile file, boolean readOnly) { try { File unwrappedFile = file.as(File.class); return unwrappedFile.setWritable(!readOnly); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot set %s writable to %s: %s (%s)", file, !readOnly) @@ -189,10 +189,10 @@ private boolean setWritableHandler(VirtualFile file, boolean readOnly) { private boolean createDirectoryHandler(VirtualFile file) { try { return file.as(File.class).mkdirs(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot create %s as directory: %s (%s)", file) .handle(); } @@ -201,10 +201,10 @@ private boolean createDirectoryHandler(VirtualFile file) { private boolean existsFlagSupplier(VirtualFile file) { try { return file.as(File.class).exists(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot determine if %s exists: %s (%s)", file) .handle(); } @@ -218,10 +218,10 @@ private boolean deleteHandler(VirtualFile file) { sirius.kernel.commons.Files.delete(file.as(File.class)); } return true; - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot delete %s: %s (%s)", file) .handle(); } @@ -230,10 +230,10 @@ private boolean deleteHandler(VirtualFile file) { private boolean isDirectoryFlagSupplier(VirtualFile file) { try { return file.as(File.class).isDirectory(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot determine if %s is a directory: %s (%s)", file) .handle(); } @@ -242,10 +242,10 @@ private boolean isDirectoryFlagSupplier(VirtualFile file) { private long sizeSupplier(VirtualFile file) { try { return file.as(File.class).length(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot determine the size of %s - %s (%s)", file) .handle(); } @@ -254,10 +254,10 @@ private long sizeSupplier(VirtualFile file) { private long lastModifiedSupplier(VirtualFile file) { try { return file.as(File.class).lastModified(); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot determine the last modified of %s - %s (%s)", file) .handle(); @@ -271,10 +271,10 @@ private boolean isExistingFile(VirtualFile file) { private InputStream inputStreamSupplier(VirtualFile file) { try { return new FileInputStream(file.as(File.class)); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot open input stream of %s - %s (%s)", file) .handle(); } @@ -283,10 +283,10 @@ private InputStream inputStreamSupplier(VirtualFile file) { private FileHandle fileHandleSupplier(VirtualFile file) { try { return FileHandle.permanentFileHandle(file.as(File.class)); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot create a file handle of %s - %s (%s)", file) .handle(); } @@ -295,10 +295,10 @@ private FileHandle fileHandleSupplier(VirtualFile file) { private OutputStream outputStreamSupplier(VirtualFile file) { try { return new FileOutputStream(file.as(File.class)); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot open output stream of %s - %s (%s)", file) .handle(); } @@ -321,10 +321,10 @@ protected void enumerateDirectoryChildren(VirtualFile parent, FileSearch search) return; } } - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/FS: Cannot iterate over children of %s - %s (%s)", parent) .handle(); } diff --git a/src/main/java/sirius/biz/storage/layer3/uplink/sftp/SFTPUplink.java b/src/main/java/sirius/biz/storage/layer3/uplink/sftp/SFTPUplink.java index de571a660..396b891e2 100644 --- a/src/main/java/sirius/biz/storage/layer3/uplink/sftp/SFTPUplink.java +++ b/src/main/java/sirius/biz/storage/layer3/uplink/sftp/SFTPUplink.java @@ -89,11 +89,11 @@ protected void enumerateDirectoryChildren(@Nonnull VirtualFile parent, FileSearc try (UplinkConnector connector = connectorPool.obtain(sftpConfig)) { processListing(parent, search, remoteParent, connector); return; - } catch (Exception e) { - if (attempt.shouldThrow(e)) { + } catch (Exception exception) { + if (attempt.shouldThrow(exception)) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: Cannot iterate over children of '%s' in uplink '%s' - %s (%s)", parent, @@ -170,11 +170,11 @@ private boolean fastMoveHandler(VirtualFile file, VirtualFile newParent) { .rename(file.as(RemotePath.class).getPath(), newParent.as(RemotePath.class).child(file.name()).getPath()); return true; - } catch (Exception e) { - if (attempt.shouldThrow(e)) { + } catch (Exception exception) { + if (attempt.shouldThrow(exception)) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: Cannot move '%s' to '%s' in uplink '%s': %s (%s)", file, @@ -195,11 +195,11 @@ private boolean renameHandler(VirtualFile file, String newName) { .rename(file.as(RemotePath.class).getPath(), file.parent().as(RemotePath.class).child(newName).getPath()); return true; - } catch (Exception e) { - if (attempt.shouldThrow(e)) { + } catch (Exception exception) { + if (attempt.shouldThrow(exception)) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: Cannot rename '%s' to '%s' in uplink '%s': %s (%s)", file, @@ -230,25 +230,25 @@ private SftpClient.Attributes getAttributes(VirtualFile file) { SftpClient.Attributes stat = connector.connector().stat(file.as(RemotePath.class).getPath()); file.attach(stat); return stat; - } catch (SftpException e) { - if (e.getStatus() == SftpConstants.SSH_FX_NO_SUCH_FILE - || e.getStatus() == SftpConstants.SSH_FX_PERMISSION_DENIED) { + } catch (SftpException exception) { + if (exception.getStatus() == SftpConstants.SSH_FX_NO_SUCH_FILE + || exception.getStatus() == SftpConstants.SSH_FX_PERMISSION_DENIED) { return new SftpClient.Attributes(); } throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: Cannot determine the attributes of '%s' in uplink '%s': %s (%s)", file, sftpConfig) .handle(); - } catch (Exception e) { - if (attempt.shouldThrow(e)) { + } catch (Exception exception) { + if (attempt.shouldThrow(exception)) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: Cannot determine the attributes of '%s' in uplink '%s': %s (%s)", file, @@ -293,11 +293,11 @@ private boolean createDirectoryHandler(VirtualFile file) { try (UplinkConnector connector = connectorPool.obtain(sftpConfig)) { connector.connector().mkdir(relativePath); return true; - } catch (Exception e) { - if (attempt.shouldThrow(e)) { + } catch (Exception exception) { + if (attempt.shouldThrow(exception)) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: Failed to create a directory for '%s' in uplink '%s': %s (%s)", relativePath, @@ -326,11 +326,11 @@ private void deleteFileHandler(VirtualFile file) { try (UplinkConnector connector = connectorPool.obtain(sftpConfig)) { connector.connector().remove(relativePath); return; - } catch (Exception e) { - if (attempt.shouldThrow(e)) { + } catch (Exception exception) { + if (attempt.shouldThrow(exception)) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: Failed to delete '%s' in uplink '%s': %s (%s)", relativePath, @@ -347,11 +347,11 @@ private void deleteDirectoryHandler(VirtualFile file) { try (UplinkConnector connector = connectorPool.obtain(sftpConfig)) { connector.connector().rmdir(relativePath); return; - } catch (Exception e) { - if (attempt.shouldThrow(e)) { + } catch (Exception exception) { + if (attempt.shouldThrow(exception)) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: Failed to delete '%s' in uplink '%s': %s (%s)", relativePath, @@ -370,12 +370,12 @@ private InputStream inputStreamSupplier(VirtualFile file) { InputStream rawStream = connector.connector().read(path); return new WatchableInputStream(new BufferedInputStream(rawStream)).onCompletion(connector::safeClose); - } catch (Exception e) { + } catch (Exception exception) { connector.safeClose(); - if (attempt.shouldThrow(e)) { + if (attempt.shouldThrow(exception)) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: Failed to initiate a download for '%s' in uplink '%s': %s (%s)", path, @@ -396,12 +396,12 @@ private OutputStream outputStreamSupplier(VirtualFile file) { OutputStream rawStream = connector.connector().write(path); return new WatchableOutputStream(rawStream).onCompletion(connector::safeClose); - } catch (Exception e) { + } catch (Exception exception) { connector.safeClose(); - if (attempt.shouldThrow(e)) { + if (attempt.shouldThrow(exception)) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: Failed to initiate an upload for '%s' in uplink '%s': %s (%s)", path, diff --git a/src/main/java/sirius/biz/storage/layer3/uplink/sftp/SFTPUplinkConnectorConfig.java b/src/main/java/sirius/biz/storage/layer3/uplink/sftp/SFTPUplinkConnectorConfig.java index 912187f41..13fa5b4a6 100644 --- a/src/main/java/sirius/biz/storage/layer3/uplink/sftp/SFTPUplinkConnectorConfig.java +++ b/src/main/java/sirius/biz/storage/layer3/uplink/sftp/SFTPUplinkConnectorConfig.java @@ -69,9 +69,9 @@ public HostConfigEntry resolveEffectiveHost(String host, protected SftpClient create() { try { return createSession(); - } catch (IOException e) { + } catch (IOException exception) { throw Exceptions.handle() - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: An error occurred while connecting the uplink %s: %s (%s)", this) @@ -85,12 +85,12 @@ private SftpClient createSession() throws IOException { session.addPasswordIdentity(password); session.auth().verify(connectTimeoutMillis); return DefaultSftpClientFactory.INSTANCE.createSftpClient(session); - } catch (Exception e) { + } catch (Exception exception) { safeAbortLaunch(session); throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: An error occurred while connecting the uplink %s: %s (%s)", this) @@ -101,8 +101,8 @@ private SftpClient createSession() throws IOException { private void safeAbortLaunch(ClientSession session) { try { session.close(); - } catch (Exception ex) { - Exceptions.ignore(ex); + } catch (Exception exception) { + Exceptions.ignore(exception); } } @@ -116,10 +116,10 @@ protected void safeClose(SftpClient connector) { ClientSession session = connector.getSession(); try { connector.close(); - } catch (IOException e) { + } catch (IOException exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: An error occurred while disconnecting the uplink %s: %s (%s)", this) @@ -127,10 +127,10 @@ protected void safeClose(SftpClient connector) { } try { session.close(); - } catch (IOException e) { + } catch (IOException exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Layer 3/SFTP: An error occurred while disconnecting the uplink %s: %s (%s)", this) diff --git a/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnector.java b/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnector.java index 029e1dfa2..396ef7687 100644 --- a/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnector.java +++ b/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnector.java @@ -62,12 +62,12 @@ public void forceClose() { try { StorageUtils.LOG.FINE("Layer 3/Uplinks: Force-closing: %s", this); forceCloseCallback.accept(connector); - } catch (Exception e) { + } catch (Exception exception) { StorageUtils.LOG.FINE("Layer 3/Uplinks: Force-closing of %s failed: %s", this, - e.getMessage(), - e.getClass().getName()); - Exceptions.ignore(e); + exception.getMessage(), + exception.getClass().getName()); + Exceptions.ignore(exception); } } @@ -77,10 +77,10 @@ public void forceClose() { public void safeClose() { try { closeCallback.accept(this); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/Uplinks: An error occurred while closing a connector: %s (%s)") .handle(); } diff --git a/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnectorFactory.java b/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnectorFactory.java index 19cc4ef6e..41d12ce50 100644 --- a/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnectorFactory.java +++ b/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnectorFactory.java @@ -94,8 +94,8 @@ protected void safeCloseOperation(PooledObject> pooledObject) try { pooledObject.getObject().operation.close(); - } catch (Exception e) { - Exceptions.ignore(e); + } catch (Exception exception) { + Exceptions.ignore(exception); } pooledObject.getObject().operation = null; diff --git a/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnectorPool.java b/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnectorPool.java index a3d706b01..12e7747f4 100644 --- a/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnectorPool.java +++ b/src/main/java/sirius/biz/storage/layer3/uplink/util/UplinkConnectorPool.java @@ -51,10 +51,10 @@ public UplinkConnector obtain(UplinkConnectorConfig config) { try { return (UplinkConnector) fetchPools().computeIfAbsent(config, this::createPool) .borrowObject(config.maxWaitMillis); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Layer 3/Uplinks: Failed to obtain a connection for '%s' - %s (%s)", config) .handle(); diff --git a/src/main/java/sirius/biz/storage/legacy/FSStorageEngine.java b/src/main/java/sirius/biz/storage/legacy/FSStorageEngine.java index fb367aca0..59af9b234 100644 --- a/src/main/java/sirius/biz/storage/legacy/FSStorageEngine.java +++ b/src/main/java/sirius/biz/storage/legacy/FSStorageEngine.java @@ -45,8 +45,8 @@ private File getBaseDir() { if (!root.exists()) { try { root.mkdirs(); - } catch (Exception e) { - Exceptions.handle(Storage.LOG, e); + } catch (Exception exception) { + Exceptions.handle(Storage.LOG, exception); } } else { if (!root.isDirectory()) { @@ -102,17 +102,17 @@ public InputStream getData(String bucket, String physicalKey) { try { return new FileInputStream(file); - } catch (FileNotFoundException e) { - Exceptions.ignore(e); + } catch (FileNotFoundException exception) { + Exceptions.ignore(exception); return null; } } @Override - public void deliver(WebContext ctx, String bucket, String physicalKey, String fileExtension) { + public void deliver(WebContext webContext, String bucket, String physicalKey, String fileExtension) { File file = getFile(bucket, physicalKey); - Response response = ctx.respondWith().infinitelyCached(); - String name = ctx.get("name").asString(); + Response response = webContext.respondWith().infinitelyCached(); + String name = webContext.get("name").asString(); if (Strings.isFilled(name)) { response.download(name); } else { diff --git a/src/main/java/sirius/biz/storage/legacy/PhysicalStorageEngine.java b/src/main/java/sirius/biz/storage/legacy/PhysicalStorageEngine.java index de61e33e9..6c644f54e 100644 --- a/src/main/java/sirius/biz/storage/legacy/PhysicalStorageEngine.java +++ b/src/main/java/sirius/biz/storage/legacy/PhysicalStorageEngine.java @@ -46,12 +46,12 @@ void storePhysicalObject(String bucket, String physicalKey, InputStream data, St /** * Delivers the requested object to the given request as response. * - * @param ctx the request to provide a response for + * @param webContext the request to provide a response for * @param bucket the bucket of the object to deliver * @param physicalKey the id of the object to deliver * @param fileExtension the file extension e.g. to setup a matching Content-Type */ - void deliver(WebContext ctx, String bucket, String physicalKey, String fileExtension); + void deliver(WebContext webContext, String bucket, String physicalKey, String fileExtension); /** * Can provide a custom download URL for a given builder. diff --git a/src/main/java/sirius/biz/storage/legacy/Storage.java b/src/main/java/sirius/biz/storage/legacy/Storage.java index a7e21adfa..ea344fd7d 100644 --- a/src/main/java/sirius/biz/storage/legacy/Storage.java +++ b/src/main/java/sirius/biz/storage/legacy/Storage.java @@ -346,12 +346,12 @@ protected void deleteReferencedObjects(String reference, @Nullable String exclud if (Strings.isEmpty(reference)) { return; } - SmartQuery qry = oma.select(VirtualObject.class).eq(VirtualObject.REFERENCE, reference); + SmartQuery query = oma.select(VirtualObject.class).eq(VirtualObject.REFERENCE, reference); if (Strings.isFilled(excludedObjectKey)) { - qry.ne(VirtualObject.OBJECT_KEY, excludedObjectKey); + query.ne(VirtualObject.OBJECT_KEY, excludedObjectKey); } - qry.delete(); + query.delete(); } /** @@ -374,10 +374,10 @@ protected void markAsUsed(String reference, String objectKey) { .set("reference", reference) .set("objectKey", objectKey) .executeUpdate(); - } catch (SQLException e) { + } catch (SQLException exception) { Exceptions.handle() .to(LOG) - .error(e) + .error(exception) .withSystemErrorMessage("An error occurred, when marking the object '%s' as used: %s (%s)", objectKey) .handle(); @@ -408,10 +408,10 @@ public void updateFile(@Nonnull StoredObject file, @Nonnull File data, @Nullable String md5 = calculateMd5(data); updateFile(file, in, filename, md5, data.length()); } - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Cannot upload the file: %s (%s) - %s (%s)", file, filename) .handle(); } @@ -455,8 +455,8 @@ public void updateFile(@Nonnull StoredObject file, // Delete old file engine.deletePhysicalObject(object.getBucket(), oldPhysicalKey); - } catch (IOException e) { - throw Exceptions.handle().to(LOG).error(e).withNLSKey("Storage.uploadFailed").handle(); + } catch (IOException exception) { + throw Exceptions.handle().to(LOG).error(exception).withNLSKey("Storage.uploadFailed").handle(); } } @@ -539,17 +539,18 @@ protected boolean verifyHash(String key, String hash) { /** * Delivers a pyhsical file or object. * - * @param ctx the request to respond to + * @param webContext the request to respond to * @param bucket the bucket to deliver from * @param physicalKey the physical file to deliver * @param fileExtension the file extension of the file (to determine the Content-Type) */ - protected void deliverPhysicalFile(WebContext ctx, String bucket, String physicalKey, String fileExtension) { + protected void deliverPhysicalFile(WebContext webContext, String bucket, String physicalKey, String fileExtension) { if (shouldLogDeprecated(bucket)) { - DEPRECATION_LOG.WARN("A file from the deprecated storage was requested: %s", ctx.getRequest().toString()); + DEPRECATION_LOG.WARN("A file from the deprecated storage was requested: %s", + webContext.getRequest().toString()); } - getStorageEngine(bucket).deliver(ctx, bucket, physicalKey, fileExtension); + getStorageEngine(bucket).deliver(webContext, bucket, physicalKey, fileExtension); } /** diff --git a/src/main/java/sirius/biz/storage/legacy/StorageCleanupTask.java b/src/main/java/sirius/biz/storage/legacy/StorageCleanupTask.java index 7e986f4ac..2af5edfc6 100644 --- a/src/main/java/sirius/biz/storage/legacy/StorageCleanupTask.java +++ b/src/main/java/sirius/biz/storage/legacy/StorageCleanupTask.java @@ -60,8 +60,8 @@ protected void runCleanup() { try { cleanupTemporaryUploads(); cleanupBuckets(); - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); } } diff --git a/src/main/java/sirius/biz/storage/legacy/StorageController.java b/src/main/java/sirius/biz/storage/legacy/StorageController.java index fe5d0a652..74f4e300f 100644 --- a/src/main/java/sirius/biz/storage/legacy/StorageController.java +++ b/src/main/java/sirius/biz/storage/legacy/StorageController.java @@ -54,30 +54,30 @@ public class StorageController extends BizController { /** * Lists all buckets visible to the current user. * - * @param ctx the request to handle + * @param webContext the request to handle */ @DefaultRoute @Routed("/storage") @LoginRequired - public void listBuckets(WebContext ctx) { + public void listBuckets(WebContext webContext) { UserInfo currentUser = UserContext.getCurrentUser(); - ctx.respondWith() - .template("/templates/biz/storage/buckets.html.pasta", - storage.getBuckets() - .stream() - .filter(bucket -> currentUser.hasPermission(bucket.getPermission())) - .collect(Collectors.toList())); + webContext.respondWith() + .template("/templates/biz/storage/buckets.html.pasta", + storage.getBuckets() + .stream() + .filter(bucket -> currentUser.hasPermission(bucket.getPermission())) + .collect(Collectors.toList())); } /** * Lists all objects of the given bucket. * - * @param ctx the request to handle + * @param webContext the request to handle * @param bucketName the bucket to list */ @Routed("/storage/bucket/:1") @LoginRequired - public void listObjects(WebContext ctx, String bucketName) { + public void listObjects(WebContext webContext, String bucketName) { BucketInfo bucket = storage.getBucket(bucketName).orElse(null); if (isBucketUnaccessible(bucket)) { throw cannotAccessBucketException(bucketName); @@ -89,12 +89,12 @@ public void listObjects(WebContext ctx, String bucketName) { .ne(VirtualObject.PATH, null) .orderDesc(VirtualObject.TRACE.inner(TraceData.CHANGED_AT)); - applyQuery(ctx.get("query").asString(), baseQuery, bucket.isAlwaysUseLikeSearch(), false); + applyQuery(webContext.get("query").asString(), baseQuery, bucket.isAlwaysUseLikeSearch(), false); SQLPageHelper pageHelper = - SQLPageHelper.withQuery(tenants.forCurrentTenant(baseQuery)).withContext(ctx); + SQLPageHelper.withQuery(tenants.forCurrentTenant(baseQuery)).withContext(webContext); - ctx.respondWith().template("/templates/biz/storage/objects.html.pasta", bucket, pageHelper.asPage()); + webContext.respondWith().template("/templates/biz/storage/objects.html.pasta", bucket, pageHelper.asPage()); } private boolean isBucketUnaccessible(BucketInfo bucket) { @@ -111,13 +111,13 @@ private HandledException cannotAccessBucketException(String bucketName) { /** * Provides an autocomplete for objects within a bucket. * - * @param ctx the request to handle + * @param webContext the request to handle * @param bucketName the name of the bucket to search in */ @Routed("/storage/autocomplete/:1") @LoginRequired - public void autocompleteObjects(WebContext ctx, String bucketName) { - AutocompleteHelper.handle(ctx, (query, result) -> findObjectsForQuery(bucketName, query, result)); + public void autocompleteObjects(WebContext webContext, String bucketName) { + AutocompleteHelper.handle(webContext, (query, result) -> findObjectsForQuery(bucketName, query, result)); } private void findObjectsForQuery(String bucketName, String query, Consumer result) { @@ -190,44 +190,44 @@ private void applyQuery(String query, /** * Provides a detail view for an object within a bucket. * - * @param ctx the request to handle + * @param webContext the request to handle * @param bucketName the name of the bucket in which the object resides * @param objectKey the key of the object */ @Routed("/storage/object/:1/:2") @LoginRequired - public void editObject(WebContext ctx, String bucketName, String objectKey) { + public void editObject(WebContext webContext, String bucketName, String objectKey) { StoredObject object = findObjectByKey(bucketName, objectKey); VirtualObject virtualObject = (VirtualObject) object; assertTenant(virtualObject); BucketInfo bucket = storage.getBucket(virtualObject.getBucket()).orElse(null); - if (isBucketUnaccessible(bucket) || (ctx.isUnsafePOST() && !bucket.isCanEdit())) { + if (isBucketUnaccessible(bucket) || (webContext.isUnsafePOST() && !bucket.isCanEdit())) { throw cannotAccessBucketException(virtualObject.getBucket()); } - ctx.respondWith() - .template("/templates/biz/storage/object.html.pasta", - bucket, - object, - oma.select(VirtualObjectVersion.class) - .eq(VirtualObjectVersion.VIRTUAL_OBJECT, virtualObject) - .orderDesc(VirtualObjectVersion.CREATED_DATE) - .queryList()); + webContext.respondWith() + .template("/templates/biz/storage/object.html.pasta", + bucket, + object, + oma.select(VirtualObjectVersion.class) + .eq(VirtualObjectVersion.VIRTUAL_OBJECT, virtualObject) + .orderDesc(VirtualObjectVersion.CREATED_DATE) + .queryList()); } /** * Uploads a new file / object to a bucket * - * @param ctx the request to handle - * @param out the response to the AJAX call + * @param webContext the request to handle + * @param output the response to the AJAX call * @param bucketName the name of the bucket to upload to * @param upload the data being uploaded */ @Routed(value = "/storage/upload/:1", preDispatchable = true, jsonCall = true) @LoginRequired - public void uploadObject(final WebContext ctx, - JSONStructuredOutput out, + public void uploadObject(final WebContext webContext, + JSONStructuredOutput output, String bucketName, InputStreamHandler upload) { StoredObject file = null; @@ -237,7 +237,7 @@ public void uploadObject(final WebContext ctx, throw cannotAccessBucketException(bucketName); } - String name = ctx.get("filename").asString(ctx.get("qqfile").asString()); + String name = webContext.get("filename").asString(webContext.get("qqfile").asString()); if (bucket.isCanCreate()) { file = storage.findOrCreateObjectByPath((SQLTenant) tenants.getRequiredTenant(), bucketName, name); } else { @@ -249,35 +249,35 @@ public void uploadObject(final WebContext ctx, } try (upload) { - ctx.markAsLongCall(); + webContext.markAsLongCall(); storage.updateFile(file, upload, null, null, - Long.parseLong(ctx.getHeader(HttpHeaderNames.CONTENT_LENGTH))); + Long.parseLong(webContext.getHeader(HttpHeaderNames.CONTENT_LENGTH))); } - out.property(RESPONSE_FILE_ID, file.getObjectKey()); - out.property(RESPONSE_REFRESH, true); - } catch (Exception e) { + output.property(RESPONSE_FILE_ID, file.getObjectKey()); + output.property(RESPONSE_REFRESH, true); + } catch (Exception exception) { storage.delete(file); - throw Exceptions.createHandled().error(e).handle(); + throw Exceptions.createHandled().error(exception).handle(); } } /** * Uploads new contents for the given file. * - * @param ctx the request to handle - * @param out the response to the AJAX call + * @param webContext the request to handle + * @param output the response to the AJAX call * @param bucketName the name of the bucket to upload to * @param objectId the id of the object for replace * @param upload the upload to handle */ @Routed(value = "/storage/replace/:1/:2", preDispatchable = true, jsonCall = true) @LoginRequired - public void uploadObject(final WebContext ctx, - JSONStructuredOutput out, + public void uploadObject(final WebContext webContext, + JSONStructuredOutput output, String bucketName, String objectId, InputStreamHandler upload) { @@ -291,18 +291,18 @@ public void uploadObject(final WebContext ctx, .orElseThrow(() -> cannotAccessBucketException(bucketName)); try (upload) { - ctx.markAsLongCall(); + webContext.markAsLongCall(); storage.updateFile(file, upload, null, null, - Long.parseLong(ctx.getHeader(HttpHeaderNames.CONTENT_LENGTH))); + Long.parseLong(webContext.getHeader(HttpHeaderNames.CONTENT_LENGTH))); } - out.property(RESPONSE_FILE_ID, file.getObjectKey()); - out.property(RESPONSE_REFRESH, true); - } catch (Exception e) { - throw Exceptions.createHandled().error(e).handle(); + output.property(RESPONSE_FILE_ID, file.getObjectKey()); + output.property(RESPONSE_REFRESH, true); + } catch (Exception exception) { + throw Exceptions.createHandled().error(exception).handle(); } } @@ -312,16 +312,16 @@ public void uploadObject(final WebContext ctx, * If an object for this reference already exists, it is updated, otherwise a new one is created. * xx * - * @param ctx the request to handle - * @param out the response to the AJAX call + * @param webContext the request to handle + * @param output the response to the AJAX call * @param bucketName the bucket name to put the object into * @param reference the reference for which an object is uploaded * @param upload the content of the upload */ @Routed(value = "/storage/upload-reference/:1/:2", preDispatchable = true, jsonCall = true) @LoginRequired - public void uploadObjectForReference(final WebContext ctx, - JSONStructuredOutput out, + public void uploadObjectForReference(final WebContext webContext, + JSONStructuredOutput output, String bucketName, String reference, InputStreamHandler upload) { @@ -331,37 +331,37 @@ public void uploadObjectForReference(final WebContext ctx, if (bucket == null) { throw cannotAccessBucketException(bucketName); } - String name = ctx.get("filename").asString(ctx.get("qqfile").asString()); + String name = webContext.get("filename").asString(webContext.get("qqfile").asString()); file = storage.createTemporaryObject((SQLTenant) tenants.getRequiredTenant(), bucketName, NO_REFERENCE.equals(reference) ? null : reference, name); try (upload) { - ctx.markAsLongCall(); + webContext.markAsLongCall(); storage.updateFile(file, upload, null, null, - Long.parseLong(ctx.getHeader(HttpHeaderNames.CONTENT_LENGTH))); + Long.parseLong(webContext.getHeader(HttpHeaderNames.CONTENT_LENGTH))); } - out.property(RESPONSE_FILE_ID, file.getObjectKey()); - out.property("previewUrl", file.prepareURL().buildURL().orElse("")); - } catch (Exception e) { + output.property(RESPONSE_FILE_ID, file.getObjectKey()); + output.property("previewUrl", file.prepareURL().buildURL().orElse("")); + } catch (Exception exception) { storage.delete(file); - throw Exceptions.createHandled().error(e).handle(); + throw Exceptions.createHandled().error(exception).handle(); } } /** * Deletes the object in the given bucket with the given id. * - * @param ctx the request to handle + * @param webContext the request to handle * @param bucketName the bucket in which the object resides * @param objectKey the unique object key */ @Routed("/storage/delete/:1/:2") - public void deleteObject(WebContext ctx, String bucketName, String objectKey) { + public void deleteObject(WebContext webContext, String bucketName, String objectKey) { StoredObject object = findObjectByKey(bucketName, objectKey); VirtualObject virtualObject = (VirtualObject) object; assertTenant(virtualObject); @@ -372,18 +372,18 @@ public void deleteObject(WebContext ctx, String bucketName, String objectKey) { storage.delete(object); showDeletedMessage(); - listObjects(ctx, virtualObject.getBucket()); + listObjects(webContext, virtualObject.getBucket()); } /** * Removes the reference binding for the given object. * - * @param ctx the request to handle + * @param webContext the request to handle * @param bucketName the bucket in which the object resides * @param objectKey the unique object key */ @Routed("/storage/unreference/:1/:2") - public void unreferenceObject(WebContext ctx, String bucketName, String objectKey) { + public void unreferenceObject(WebContext webContext, String bucketName, String objectKey) { BucketInfo bucket = storage.getBucket(bucketName).orElse(null); if (isBucketUnaccessible(bucket) || !bucket.isCanDelete()) { throw cannotAccessBucketException(bucketName); @@ -396,7 +396,7 @@ public void unreferenceObject(WebContext ctx, String bucketName, String objectKe virtualObject.setReference(null); oma.update(virtualObject); - ctx.respondWith().redirectToGet(Strings.apply("/storage/object/%s/%s", bucketName, objectKey)); + webContext.respondWith().redirectToGet(Strings.apply("/storage/object/%s/%s", bucketName, objectKey)); } private StoredObject findObjectByKey(String bucket, String objectKey) { @@ -414,22 +414,22 @@ private StoredObject findObjectByKey(String bucket, String objectKey) { * This is the handler of the download URLS which are generated by default. The content is actually delivered by the * {@link PhysicalStorageEngine}. * - * @param ctx the request to handle + * @param webContext the request to handle * @param bucket the bucket containing the object * @param authHash the authentication hash which ensures access * @param physicalFileKey the physical object to download */ @Routed("/storage/physical/:1/:2/:3") - public void downloadPhysicalObject(WebContext ctx, String bucket, String authHash, String physicalFileKey) { + public void downloadPhysicalObject(WebContext webContext, String bucket, String authHash, String physicalFileKey) { Tuple keyAndExtension = determineKeyAndExtension(physicalFileKey); String key = keyAndExtension.getFirst(); if (!storage.verifyHash(key, authHash)) { - ctx.respondWith().error(HttpResponseStatus.FORBIDDEN); + webContext.respondWith().error(HttpResponseStatus.FORBIDDEN); return; } - storage.deliverPhysicalFile(ctx, bucket, key, keyAndExtension.getSecond()); + storage.deliverPhysicalFile(webContext, bucket, key, keyAndExtension.getSecond()); } private Tuple determineKeyAndExtension(String physicalFileKey) { diff --git a/src/main/java/sirius/biz/storage/legacy/StoredObjectRefProperty.java b/src/main/java/sirius/biz/storage/legacy/StoredObjectRefProperty.java index 734b3cea1..c672c04f3 100644 --- a/src/main/java/sirius/biz/storage/legacy/StoredObjectRefProperty.java +++ b/src/main/java/sirius/biz/storage/legacy/StoredObjectRefProperty.java @@ -32,6 +32,7 @@ /** * Handles fields of the type {@link StoredObjectRef} within an {@link SQLEntity}. + * * @deprecated use the new storage APIs */ @Deprecated @@ -75,10 +76,10 @@ private StoredObjectRefProperty(@Nonnull EntityDescriptor descriptor, protected StoredObjectRef getStoredObjectRef(Object entity) { try { return (StoredObjectRef) super.getValueFromField(this.accessPath.apply(entity)); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(OMA.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "Unable to obtain StoredObjectRef object from entity ref field ('%s' in '%s'): %s (%s)", getName(), diff --git a/src/main/java/sirius/biz/storage/legacy/VersionManager.java b/src/main/java/sirius/biz/storage/legacy/VersionManager.java index 386f6f57c..0d73d0eb5 100644 --- a/src/main/java/sirius/biz/storage/legacy/VersionManager.java +++ b/src/main/java/sirius/biz/storage/legacy/VersionManager.java @@ -200,10 +200,10 @@ private void performVersionComputation(VirtualObjectVersion objectVersion) { extendedSize.getFirst(), extendedSize.getSecond(), imageFormat); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(Storage.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to convert %s (%s): %s (%s)", object.getObjectKey(), object.getPath()) @@ -332,10 +332,10 @@ private File convertUsingCLI(VirtualObject object, try { Exec.exec(command); - } catch (Exec.ExecException e) { + } catch (Exec.ExecException exception) { Exceptions.handle() .to(Storage.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to invoke: %s to resize %s (%s) to %sx%s in %s imageFormat", command, object.getObjectKey(), diff --git a/src/main/java/sirius/biz/storage/legacy/VersionedFiles.java b/src/main/java/sirius/biz/storage/legacy/VersionedFiles.java index 67a8ef86a..3da3ea78f 100644 --- a/src/main/java/sirius/biz/storage/legacy/VersionedFiles.java +++ b/src/main/java/sirius/biz/storage/legacy/VersionedFiles.java @@ -124,8 +124,8 @@ public List getContent(VersionedFile file) { } try (InputStream data = storage.getData(file.getStoredFile().getObject())) { return new BufferedReader(new InputStreamReader(data)).lines().collect(Collectors.toList()); - } catch (IOException e) { - throw Exceptions.handle(Storage.LOG, e); + } catch (IOException exception) { + throw Exceptions.handle(Storage.LOG, exception); } } @@ -184,8 +184,8 @@ private StoredObject generateNewFile(VersionedFile file, String uniqueIdentifier try (OutputStream out = storage.updateFile(object)) { out.write(code.getBytes()); - } catch (IOException e) { - throw Exceptions.handle(Storage.LOG, e); + } catch (IOException exception) { + throw Exceptions.handle(Storage.LOG, exception); } return object; diff --git a/src/main/java/sirius/biz/storage/util/Attempt.java b/src/main/java/sirius/biz/storage/util/Attempt.java index cd65d42db..09a538748 100644 --- a/src/main/java/sirius/biz/storage/util/Attempt.java +++ b/src/main/java/sirius/biz/storage/util/Attempt.java @@ -26,8 +26,8 @@ * try { * ...do something * return; - * } catch(Exception e) { - * if (attempt.shouldThrow(e)) { + * } catch(Exception exception) { + * if (attempt.shouldThrow(exception)) { * throw Exceptions.handle... * } * } diff --git a/src/main/java/sirius/biz/storage/util/StorageUtils.java b/src/main/java/sirius/biz/storage/util/StorageUtils.java index ded25682a..cf6902cbc 100644 --- a/src/main/java/sirius/biz/storage/util/StorageUtils.java +++ b/src/main/java/sirius/biz/storage/util/StorageUtils.java @@ -285,10 +285,10 @@ public OutputStream createLocallyBufferedStream(Consumer dataConsum return createLocalBuffer(bufferFile -> { try (InputStream in = new FileInputStream(bufferFile)) { dataConsumer.accept(in); - } catch (IOException e) { + } catch (IOException exception) { throw Exceptions.handle() .to(StorageUtils.LOG) - .error(e) + .error(exception) .withSystemErrorMessage( "An error occurred while reading from a temporary buffer: %s (%s)") .handle(); diff --git a/src/main/java/sirius/biz/storage/util/WatchableInputStream.java b/src/main/java/sirius/biz/storage/util/WatchableInputStream.java index 573631a6e..a7125aaa2 100644 --- a/src/main/java/sirius/biz/storage/util/WatchableInputStream.java +++ b/src/main/java/sirius/biz/storage/util/WatchableInputStream.java @@ -82,15 +82,15 @@ public boolean markSupported() { public void close() throws IOException { try { delegate.close(); - } catch (IOException e) { + } catch (IOException exception) { // Close might be invoked several times (e.g. by some ZIP implementations). // Therefore, we filter this to only execute the handler once. if (failureHandler != null && !closeHandled) { closeHandled = true; - failureHandler.accept(e); + failureHandler.accept(exception); } - throw e; + throw exception; } // Filter duplicate executions (s.a.)... diff --git a/src/main/java/sirius/biz/storage/util/WatchableOutputStream.java b/src/main/java/sirius/biz/storage/util/WatchableOutputStream.java index e3dec0ac8..608183685 100644 --- a/src/main/java/sirius/biz/storage/util/WatchableOutputStream.java +++ b/src/main/java/sirius/biz/storage/util/WatchableOutputStream.java @@ -57,15 +57,15 @@ public void flush() throws IOException { public void close() throws IOException { try { delegate.close(); - } catch (IOException e) { + } catch (IOException exception) { // Close might be invoked several times (e.g. by some ZIP implementations). // Therefore, we filter this to only execute the handler once. if (failureHandler != null && !closeHandled) { closeHandled = true; - failureHandler.accept(e); + failureHandler.accept(exception); } - throw e; + throw exception; } // Filter duplicate executions (s.a.)... diff --git a/src/main/java/sirius/biz/tenants/SAMLController.java b/src/main/java/sirius/biz/tenants/SAMLController.java index 03a81716c..0f5f45916 100644 --- a/src/main/java/sirius/biz/tenants/SAMLController.java +++ b/src/main/java/sirius/biz/tenants/SAMLController.java @@ -53,12 +53,12 @@ public class SAMLController & Te /** * Lists all possible SAML tenants or permits to create a login form for a custom SAML provider. * - * @param ctx the current request + * @param webContext the current request */ @Routed(SAML_URI_PREFIX) - public void saml(WebContext ctx) { + public void saml(WebContext webContext) { List tenants = querySAMLTenants(); - ctx.respondWith().template("/templates/biz/tenants/saml.html.pasta", tenants); + webContext.respondWith().template("/templates/biz/tenants/saml.html.pasta", tenants); } /** @@ -74,16 +74,16 @@ protected Class getTenantClass() { /** * Processes a SAML response and tries to create or update a user which is then logged in. * - * @param ctx the SAML response as request + * @param webContext the SAML response as request */ @Routed(SAML_URI_PREFIX + "/login") - public void samlLogin(WebContext ctx) { - if (!ctx.isUnsafePOST()) { - ctx.respondWith().redirectToGet(SAML_URI_PREFIX); + public void samlLogin(WebContext webContext) { + if (!webContext.isUnsafePOST()) { + webContext.respondWith().redirectToGet(SAML_URI_PREFIX); return; } - SAMLResponse response = saml.parseSAMLResponse(ctx); + SAMLResponse response = saml.parseSAMLResponse(webContext); if (Strings.isEmpty(response.getNameId())) { throw Exceptions.createHandled() @@ -93,25 +93,25 @@ public void samlLogin(WebContext ctx) { TenantUserManager manager = (TenantUserManager) UserContext.getCurrentScope().getUserManager(); - UserInfo user = manager.findUserByName(ctx, response.getNameId()); + UserInfo user = manager.findUserByName(webContext, response.getNameId()); if (user == null) { - user = tryCreateUser(ctx, response); + user = tryCreateUser(webContext, response); } else { verifyUser(response, user); } - manager.onExternalLogin(ctx, user); + manager.onExternalLogin(webContext, user); // Re-resolve and install the newly created or updated user in the session. // This also flushes all caches again, as we updated some internal data within // "onExternalLogin" above... UserContext userContext = UserContext.get(); - userContext.setCurrentUser(manager.findUserByName(ctx, response.getNameId())); + userContext.setCurrentUser(manager.findUserByName(webContext, response.getNameId())); - ctx.respondWith().template("/templates/biz/tenants/saml-complete.html.pasta", response); + webContext.respondWith().template("/templates/biz/tenants/saml-complete.html.pasta", response); } - private UserInfo tryCreateUser(WebContext ctx, SAMLResponse response) { + private UserInfo tryCreateUser(WebContext webContext, SAMLResponse response) { if (Strings.isEmpty(response.getIssuer())) { throw Exceptions.createHandled().withSystemErrorMessage("SAML Error: No issuer in request!").handle(); } @@ -134,14 +134,14 @@ private UserInfo tryCreateUser(WebContext ctx, SAMLResponse response) { TenantUserManager manager = (TenantUserManager) UserContext.getCurrentScope().getUserManager(); - UserInfo user = manager.findUserByName(ctx, response.getNameId()); + UserInfo user = manager.findUserByName(webContext, response.getNameId()); if (user == null) { throw Exceptions.createHandled().withSystemErrorMessage("SAML Error: Failed to create a user").handle(); } return user; - } catch (Exception e) { - throw Exceptions.handle(BizController.LOG, e); + } catch (Exception exception) { + throw Exceptions.handle(BizController.LOG, exception); } } diff --git a/src/main/java/sirius/biz/tenants/TenantData.java b/src/main/java/sirius/biz/tenants/TenantData.java index b2848fef5..2be77df54 100644 --- a/src/main/java/sirius/biz/tenants/TenantData.java +++ b/src/main/java/sirius/biz/tenants/TenantData.java @@ -348,10 +348,10 @@ protected void validate(Consumer validationConsumer) { /** * Checks if the ip of the request matches the ip range of the tenant. * - * @param ctx the current request + * @param webContext the current request * @return true if the ip address matches the range or if non was configured, false otherwise */ - public boolean matchesIPRange(WebContext ctx) { + public boolean matchesIPRange(WebContext webContext) { if (Strings.isEmpty(ipRange)) { return true; } @@ -359,14 +359,14 @@ public boolean matchesIPRange(WebContext ctx) { if (rangeSet == null) { try { rangeSet = IPRange.parseRangeSet(ipRange); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException exception) { // if an invalid range was configured we can not remove any permission - Exceptions.ignore(e); + Exceptions.ignore(exception); return true; } } - return rangeSet.accepts(ctx.getRemoteIP()); + return rangeSet.accepts(webContext.getRemoteIP()); } /** @@ -416,10 +416,10 @@ public Config getConfig() { if (Strings.isFilled(configString)) { try { config = ConfigFactory.parseString(configString); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(BizController.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Cannot load config of %s (%s): %s (%s)", tenantObject, tenantObject.getId()) diff --git a/src/main/java/sirius/biz/tenants/Tenants.java b/src/main/java/sirius/biz/tenants/Tenants.java index 12f295259..778e2492a 100644 --- a/src/main/java/sirius/biz/tenants/Tenants.java +++ b/src/main/java/sirius/biz/tenants/Tenants.java @@ -237,14 +237,14 @@ public void assertTenantOrParentTenant(TenantAware tenantAware) { /** * Applies an appropriate filter to the given query to only return entities which belong to the current tenant. * - * @param qry the query to extend - * @param the type of entities processed by the query - * @param the type of the query which is being extended + * @param query the query to extend + * @param the type of entities processed by the query + * @param the type of the query which is being extended * @return the query with an additional constraint filtering on the current tenant * @throws sirius.kernel.health.HandledException if there is currently no user / tenant available */ - public & TenantAware, Q extends Query> Q forCurrentTenant(Q qry) { - return qry.eq(TenantAware.TENANT, getRequiredTenant()); + public & TenantAware, Q extends Query> Q forCurrentTenant(Q query) { + return query.eq(TenantAware.TENANT, getRequiredTenant()); } /** @@ -503,13 +503,13 @@ public void runAsAdminProcess(String processName, Callback task) processes.execute(processId, processContext -> { try { task.invoke(processContext); - } catch (Exception ex) { - processContext.handle(ex); + } catch (Exception exception) { + processContext.handle(exception); } }); }); - } catch (Exception e) { - throw new IllegalArgumentException(e); + } catch (Exception exception) { + throw new IllegalArgumentException(exception); } } diff --git a/src/main/java/sirius/biz/tenants/deletion/DeleteTenantJobFactory.java b/src/main/java/sirius/biz/tenants/deletion/DeleteTenantJobFactory.java index fb65c3ce6..b3e6c1ae5 100644 --- a/src/main/java/sirius/biz/tenants/deletion/DeleteTenantJobFactory.java +++ b/src/main/java/sirius/biz/tenants/deletion/DeleteTenantJobFactory.java @@ -103,10 +103,10 @@ protected void execute(ProcessContext process) throws Exception { if (shouldExecute) { task.execute(process, tenant); } - } catch (Exception e) { + } catch (Exception exception) { process.handle(Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage( "An error occurred while executing the deletion task %s: %s (%s)", task.getClass().getName()) diff --git a/src/main/java/sirius/biz/tenants/jdbc/SQLTenantController.java b/src/main/java/sirius/biz/tenants/jdbc/SQLTenantController.java index 91d2ebf2b..26714a85a 100644 --- a/src/main/java/sirius/biz/tenants/jdbc/SQLTenantController.java +++ b/src/main/java/sirius/biz/tenants/jdbc/SQLTenantController.java @@ -32,16 +32,16 @@ public class SQLTenantController extends TenantController { @Override - protected BasePageHelper getTenantsAsPage(WebContext ctx) { + protected BasePageHelper getTenantsAsPage(WebContext webContext) { SmartQuery query = oma.select(SQLTenant.class).orderAsc(Tenant.TENANT_DATA.inner(TenantData.NAME)); - SQLPageHelper pageHelper = createTenantPageHelper(ctx, query); + SQLPageHelper pageHelper = createTenantPageHelper(webContext, query); pageHelper.applyExtenders("/tenants"); return pageHelper; } - private SQLPageHelper createTenantPageHelper(WebContext ctx, SmartQuery query) { - SQLPageHelper pageHelper = SQLPageHelper.withQuery(query).withContext(ctx); + private SQLPageHelper createTenantPageHelper(WebContext webContext, SmartQuery query) { + SQLPageHelper pageHelper = SQLPageHelper.withQuery(query).withContext(webContext); pageHelper.withSearchFields(QueryField.contains(Tenant.TENANT_DATA.inner(TenantData.NAME)), QueryField.contains(Tenant.TENANT_DATA.inner(TenantData.ACCOUNT_NUMBER)), QueryField.contains(Tenant.TENANT_DATA.inner(TenantData.ADDRESS) @@ -56,10 +56,11 @@ private SQLPageHelper createTenantPageHelper(WebContext ctx, SmartQue } @Override - protected BasePageHelper getSelectableTenantsAsPage(WebContext ctx, SQLTenant currentTenant) { + protected BasePageHelper getSelectableTenantsAsPage(WebContext webContext, + SQLTenant currentTenant) { SmartQuery query = queryPossibleTenants(currentTenant).orderAsc(Tenant.TENANT_DATA.inner(TenantData.NAME)); - SQLPageHelper pageHelper = createTenantPageHelper(ctx, query); + SQLPageHelper pageHelper = createTenantPageHelper(webContext, query); pageHelper.applyExtenders("/tenants/select"); return pageHelper; diff --git a/src/main/java/sirius/biz/tenants/jdbc/SQLTenantUserManager.java b/src/main/java/sirius/biz/tenants/jdbc/SQLTenantUserManager.java index b843f4606..0723fb3d5 100644 --- a/src/main/java/sirius/biz/tenants/jdbc/SQLTenantUserManager.java +++ b/src/main/java/sirius/biz/tenants/jdbc/SQLTenantUserManager.java @@ -73,8 +73,8 @@ protected void recordLogin(UserInfo user, boolean external) { // We need to invalidate the cache to reflect our changes... userAccountCache.remove(account.getUniqueName()); - } catch (Exception e) { - Exceptions.handle(BizController.LOG, e); + } catch (Exception exception) { + Exceptions.handle(BizController.LOG, exception); } } @@ -85,8 +85,8 @@ protected void updateLastSeen(SQLUserAccount user) { .setToToday(UserAccount.USER_ACCOUNT_DATA.inner(UserAccountData.LOGIN).inner(LoginData.LAST_SEEN)) .where(SQLUserAccount.ID, user.getId()) .executeUpdate(); - } catch (Exception e) { - Exceptions.handle(BizController.LOG, e); + } catch (Exception exception) { + Exceptions.handle(BizController.LOG, exception); } } } diff --git a/src/main/java/sirius/biz/tenants/jdbc/SQLUserAccount.java b/src/main/java/sirius/biz/tenants/jdbc/SQLUserAccount.java index 5bab82752..69442dffa 100644 --- a/src/main/java/sirius/biz/tenants/jdbc/SQLUserAccount.java +++ b/src/main/java/sirius/biz/tenants/jdbc/SQLUserAccount.java @@ -117,10 +117,10 @@ public void updatePreference(String key, Object value) { .where(SQLUserAccount.ID, id) .executeUpdate(); TenantUserManager.flushCacheForUserAccount(this); - } catch (SQLException | JsonProcessingException e) { + } catch (SQLException | JsonProcessingException exception) { throw Exceptions.handle() .to(Log.SYSTEM) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to update user preference '%s' to '%s' for %s: %s (%s)", key, value, diff --git a/src/main/java/sirius/biz/tenants/mongo/MongoTenantController.java b/src/main/java/sirius/biz/tenants/mongo/MongoTenantController.java index 44c9dcf72..29f6ed2be 100644 --- a/src/main/java/sirius/biz/tenants/mongo/MongoTenantController.java +++ b/src/main/java/sirius/biz/tenants/mongo/MongoTenantController.java @@ -39,8 +39,8 @@ public class MongoTenantController extends TenantController getTenantsAsPage(WebContext ctx) { - MongoPageHelper pageHelper = createTenantPageHelper(ctx, + protected BasePageHelper getTenantsAsPage(WebContext webContext) { + MongoPageHelper pageHelper = createTenantPageHelper(webContext, mango.select(MongoTenant.class) .orderAsc(MongoTenant.SORT_FIELD.inner( SortField.SORT_FIELD))); @@ -49,17 +49,17 @@ public class MongoTenantController extends TenantController getSelectableTenantsAsPage(WebContext ctx, + protected BasePageHelper getSelectableTenantsAsPage(WebContext webContext, MongoTenant currentTenant) { - MongoPageHelper pageHelper = createTenantPageHelper(ctx, + MongoPageHelper pageHelper = createTenantPageHelper(webContext, queryPossibleTenants(currentTenant).orderAsc( Tenant.TENANT_DATA.inner(TenantData.NAME))); pageHelper.applyExtenders("/tenants/select"); return pageHelper; } - private MongoPageHelper createTenantPageHelper(WebContext ctx, MongoQuery query) { - MongoPageHelper pageHelper = MongoPageHelper.withQuery(query).withContext(ctx); + private MongoPageHelper createTenantPageHelper(WebContext webContext, MongoQuery query) { + MongoPageHelper pageHelper = MongoPageHelper.withQuery(query).withContext(webContext); pageHelper.withSearchFields(QueryField.startsWith(MongoTenant.SEARCH_PREFIXES)); diff --git a/src/main/java/sirius/biz/tenants/mongo/MongoTenantUserManager.java b/src/main/java/sirius/biz/tenants/mongo/MongoTenantUserManager.java index 09067c9ad..9e6b2e0b6 100644 --- a/src/main/java/sirius/biz/tenants/mongo/MongoTenantUserManager.java +++ b/src/main/java/sirius/biz/tenants/mongo/MongoTenantUserManager.java @@ -79,8 +79,8 @@ protected void recordLogin(UserInfo user, boolean external) { // We need to invalidate the cache to reflect our changes... userAccountCache.remove(account.getUniqueName()); - } catch (Exception e) { - Exceptions.handle(BizController.LOG, e); + } catch (Exception exception) { + Exceptions.handle(BizController.LOG, exception); } } @@ -91,8 +91,8 @@ protected void updateLastSeen(MongoUserAccount user) { .set(UserAccount.USER_ACCOUNT_DATA.inner(UserAccountData.LOGIN).inner(LoginData.LAST_SEEN), LocalDate.now()) .executeFor(user); - } catch (Exception e) { - Exceptions.handle(BizController.LOG, e); + } catch (Exception exception) { + Exceptions.handle(BizController.LOG, exception); } } } diff --git a/src/main/java/sirius/biz/tenants/mongo/MongoUserAccount.java b/src/main/java/sirius/biz/tenants/mongo/MongoUserAccount.java index ac1c940fc..6db4aa511 100644 --- a/src/main/java/sirius/biz/tenants/mongo/MongoUserAccount.java +++ b/src/main/java/sirius/biz/tenants/mongo/MongoUserAccount.java @@ -163,10 +163,10 @@ public void updatePreference(String key, Object value) { .where(MongoUserAccount.ID, id) .executeForOne(MongoUserAccount.class); TenantUserManager.flushCacheForUserAccount(this); - } catch (JsonProcessingException e) { + } catch (JsonProcessingException exception) { throw Exceptions.handle() .to(Log.SYSTEM) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to update user preference '%s' to '%s' for %s: %s (%s)", key, value, diff --git a/src/main/java/sirius/biz/translations/MultiLanguageStringProperty.java b/src/main/java/sirius/biz/translations/MultiLanguageStringProperty.java index 5a87db3de..732cec7a5 100644 --- a/src/main/java/sirius/biz/translations/MultiLanguageStringProperty.java +++ b/src/main/java/sirius/biz/translations/MultiLanguageStringProperty.java @@ -187,10 +187,10 @@ protected void onValidate(Object entity, Consumer validationConsumer) { public MultiLanguageString getMultiLanguageString(Object target) { try { return (MultiLanguageString) field.get(accessPath.apply(target)); - } catch (IllegalAccessException e) { + } catch (IllegalAccessException exception) { throw Exceptions.handle() .to(Mixing.LOG) - .error(e) + .error(exception) .withSystemErrorMessage("Cannot read property '%s' (from '%s'): %s (%s)", getName(), getDefinition()) diff --git a/src/main/java/sirius/biz/tycho/academy/OnboardingController.java b/src/main/java/sirius/biz/tycho/academy/OnboardingController.java index 4083b995a..1359d84ce 100644 --- a/src/main/java/sirius/biz/tycho/academy/OnboardingController.java +++ b/src/main/java/sirius/biz/tycho/academy/OnboardingController.java @@ -146,7 +146,7 @@ public void video(WebContext webContext, String target, String accessToken, Stri * Provides a JSON API to update the statistics which record which video has been viewed or skipped. * * @param webContext the request to respond to - * @param out the JSON response + * @param output the JSON response * @param target the target entity * @param accessToken the security token to authenticate the target * @param videoId the id of the onboarding video to update @@ -154,7 +154,7 @@ public void video(WebContext webContext, String target, String accessToken, Stri @Routed(value = "/academy/:1/:2/update/:3", priority = 999) @InternalService public void updateVideo(WebContext webContext, - JSONStructuredOutput out, + JSONStructuredOutput output, String target, String accessToken, String videoId) { diff --git a/src/main/java/sirius/biz/tycho/academy/OnboardingEngine.java b/src/main/java/sirius/biz/tycho/academy/OnboardingEngine.java index eb8d0430b..52f558296 100644 --- a/src/main/java/sirius/biz/tycho/academy/OnboardingEngine.java +++ b/src/main/java/sirius/biz/tycho/academy/OnboardingEngine.java @@ -80,8 +80,8 @@ protected List fetchAcademyVideos(String academy) { ACADEMY_VIDEOS_FETCHED_FLAG, LocalDateTime.now(), Period.ofDays(2)); - } catch (Exception e) { - throw Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + throw Exceptions.handle(Log.BACKGROUND, exception); } } diff --git a/src/main/java/sirius/biz/tycho/academy/RecomputeOnboardingVideosCheck.java b/src/main/java/sirius/biz/tycho/academy/RecomputeOnboardingVideosCheck.java index a02eb0353..c6c355443 100644 --- a/src/main/java/sirius/biz/tycho/academy/RecomputeOnboardingVideosCheck.java +++ b/src/main/java/sirius/biz/tycho/academy/RecomputeOnboardingVideosCheck.java @@ -107,8 +107,8 @@ protected void perform() { onboardingEngine.markOutdatedOnboardingVideosAsDeleted(academy, entity.getUniqueName(), syncToken); updateStatistics(); persistStatistics(); - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); } } diff --git a/src/main/java/sirius/biz/tycho/academy/jdbc/SQLAcademyReport.java b/src/main/java/sirius/biz/tycho/academy/jdbc/SQLAcademyReport.java index c3564362b..63eb0bafa 100644 --- a/src/main/java/sirius/biz/tycho/academy/jdbc/SQLAcademyReport.java +++ b/src/main/java/sirius/biz/tycho/academy/jdbc/SQLAcademyReport.java @@ -76,8 +76,8 @@ SELECT count(*) AS total, Tuple.create(COLUMN_SKIPPED, cells.of(skipped)), Tuple.create(COLUMN_RECOMMENDED, cells.of(recommended)), Tuple.create(COLUMN_PERCENT_WATCHED, cells.of(percentWatched)))); - } catch (SQLException e) { - throw Exceptions.handle(Log.APPLICATION, e); + } catch (SQLException exception) { + throw Exceptions.handle(Log.APPLICATION, exception); } }); } diff --git a/src/main/java/sirius/biz/tycho/academy/jdbc/SQLOnboardingEngine.java b/src/main/java/sirius/biz/tycho/academy/jdbc/SQLOnboardingEngine.java index ad92536be..08d19611c 100644 --- a/src/main/java/sirius/biz/tycho/academy/jdbc/SQLOnboardingEngine.java +++ b/src/main/java/sirius/biz/tycho/academy/jdbc/SQLOnboardingEngine.java @@ -70,8 +70,8 @@ protected void markOutdatedAcademyVideosAsDeleted(String academy, String tokenTo video.getAcademyVideoData().setLastUpdated(LocalDateTime.now()); video.getAcademyVideoData().setDeleted(true); oma.update(video); - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); } }); } @@ -135,8 +135,8 @@ public void markOutdatedOnboardingVideosAsDeleted(String academy, String owner, video.getOnboardingVideoData().setLastUpdated(LocalDateTime.now()); video.getOnboardingVideoData().setDeleted(true); oma.update(video); - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); } }); } @@ -215,12 +215,12 @@ public void recordVideoShown(String owner, String videoId) { .inc(SQLOnboardingVideo.ONBOARDING_VIDEO_DATA.inner(OnboardingVideoData.NUM_SHOWN_IN_UI)) .where(SQLOnboardingVideo.ID, Long.parseLong(videoId)) .executeUpdate(); - } catch (NumberFormatException e) { - Exceptions.ignore(e); - } catch (SQLException e) { + } catch (NumberFormatException exception) { + Exceptions.ignore(exception); + } catch (SQLException exception) { Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage( "Failed to record that an onboarding video was offered to the user: %s (%s)") .handle(); @@ -235,12 +235,12 @@ public void recordVideoStarted(String owner, String videoId) { .inc(SQLOnboardingVideo.ONBOARDING_VIDEO_DATA.inner(OnboardingVideoData.NUM_WATCHED)) .where(SQLOnboardingVideo.ID, Long.parseLong(videoId)) .executeUpdate(); - } catch (NumberFormatException e) { - Exceptions.ignore(e); - } catch (SQLException e) { + } catch (NumberFormatException exception) { + Exceptions.ignore(exception); + } catch (SQLException exception) { Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage( "Failed to record that playback of an onboarding video was commenced: %s (%s)") .handle(); @@ -276,12 +276,12 @@ public void updateWatchedPercent(String owner, String videoId, int seenInPercent .set(SQLOnboardingVideo.ONBOARDING_VIDEO_DATA.inner(OnboardingVideoData.WATCHED), markAsWatched) .where(SQLOnboardingVideo.ID, video.getId()) .executeUpdate(); - } catch (NumberFormatException e) { - Exceptions.ignore(e); - } catch (SQLException e) { + } catch (NumberFormatException exception) { + Exceptions.ignore(exception); + } catch (SQLException exception) { Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to record the view progress of an onboarding video: %s (%s)") .handle(); } @@ -296,12 +296,12 @@ public void markAsSkipped(String owner, String videoId) { .where(SQLOnboardingVideo.ID, Long.parseLong(videoId)) .where(SQLOnboardingVideo.ONBOARDING_VIDEO_DATA.inner(OnboardingVideoData.WATCHED), false) .executeUpdate(); - } catch (NumberFormatException e) { - Exceptions.ignore(e); - } catch (SQLException e) { + } catch (NumberFormatException exception) { + Exceptions.ignore(exception); + } catch (SQLException exception) { Exceptions.handle() .to(Log.BACKGROUND) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to record that an onboarding video should be skipped: %s (%s)") .handle(); } diff --git a/src/main/java/sirius/biz/tycho/academy/mongo/MongoOnboardingEngine.java b/src/main/java/sirius/biz/tycho/academy/mongo/MongoOnboardingEngine.java index 8b07628a0..e2c377b9d 100644 --- a/src/main/java/sirius/biz/tycho/academy/mongo/MongoOnboardingEngine.java +++ b/src/main/java/sirius/biz/tycho/academy/mongo/MongoOnboardingEngine.java @@ -73,8 +73,8 @@ protected void markOutdatedAcademyVideosAsDeleted(String academy, String tokenTo video.getAcademyVideoData().setLastUpdated(LocalDateTime.now()); video.getAcademyVideoData().setDeleted(true); mango.update(video); - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); } }); } @@ -139,8 +139,8 @@ public void markOutdatedOnboardingVideosAsDeleted(String academy, String owner, video.getOnboardingVideoData().setLastUpdated(LocalDateTime.now()); video.getOnboardingVideoData().setDeleted(true); mango.update(video); - } catch (Exception e) { - Exceptions.handle(Log.BACKGROUND, e); + } catch (Exception exception) { + Exceptions.handle(Log.BACKGROUND, exception); } }); } diff --git a/src/main/java/sirius/biz/tycho/metrics/MetricsApiController.java b/src/main/java/sirius/biz/tycho/metrics/MetricsApiController.java index c76a5e91b..87ded451e 100644 --- a/src/main/java/sirius/biz/tycho/metrics/MetricsApiController.java +++ b/src/main/java/sirius/biz/tycho/metrics/MetricsApiController.java @@ -71,10 +71,10 @@ private void fetchKeyMetric(ObjectNode obj, JSONStructuredOutput output) { obj.path("target").asText(null), obj.path("metric").asText(null)); metric.writeJson(output); - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(Log.APPLICATION) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to fetch key metric for: %s - %s (%s)", Json.write(obj)) .handle(); } diff --git a/src/main/java/sirius/biz/tycho/search/OpenSearchController.java b/src/main/java/sirius/biz/tycho/search/OpenSearchController.java index 23d0e4b79..23ca06ec9 100644 --- a/src/main/java/sirius/biz/tycho/search/OpenSearchController.java +++ b/src/main/java/sirius/biz/tycho/search/OpenSearchController.java @@ -169,13 +169,13 @@ private void executeQuery(String query, WebContext webContext, Timeout timeout) allTasksCompleted.asFuture().await(SEARCH_TIMEOUT); outputStream.write(RESPONSE_COMPLETED_MESSAGE); - } catch (IOException e) { - Exceptions.ignore(e); + } catch (IOException exception) { + Exceptions.ignore(exception); } finally { try { outputStream.close(); - } catch (IOException e) { - Exceptions.ignore(e); + } catch (IOException exception) { + Exceptions.ignore(exception); } } } @@ -206,12 +206,12 @@ private void performSearch(String query, OpenSearchProvider provider, OutputStre } outputStream.flush(); } - } catch (IOException e) { - Exceptions.ignore(e); - } catch (Exception e) { + } catch (IOException exception) { + Exceptions.ignore(exception); + } catch (Exception exception) { Exceptions.handle() .to(Log.APPLICATION) - .error(e) + .error(exception) .withSystemErrorMessage("Failed to execute an OpenSearchProvider (%s): %s (%s)", provider.getClass().getName()) .handle(); diff --git a/src/main/java/sirius/biz/tycho/search/OpenSearchResult.java b/src/main/java/sirius/biz/tycho/search/OpenSearchResult.java index cfd1ec437..15715e8cd 100644 --- a/src/main/java/sirius/biz/tycho/search/OpenSearchResult.java +++ b/src/main/java/sirius/biz/tycho/search/OpenSearchResult.java @@ -84,8 +84,8 @@ public OpenSearchResult withTemplateFromCode(String template, Object... args) { TemplateCompiler templateCompiler = new TemplateCompiler(context); templateCompiler.compile(); this.htmlDescription = context.getTemplate().renderToString(args); - } catch (RenderException | CompileException e) { - Exceptions.handle(Log.APPLICATION, e); + } catch (RenderException | CompileException exception) { + Exceptions.handle(Log.APPLICATION, exception); } return this; } @@ -105,8 +105,8 @@ public OpenSearchResult withTemplateFromPath(String path, Object... args) { return this; } this.htmlDescription = template.get().renderToString(args); - } catch (RenderException | CompileException e) { - Exceptions.handle(Log.APPLICATION, e); + } catch (RenderException | CompileException exception) { + Exceptions.handle(Log.APPLICATION, exception); } return this; } diff --git a/src/main/java/sirius/biz/tycho/updates/UpdateManager.java b/src/main/java/sirius/biz/tycho/updates/UpdateManager.java index c106d9c8b..08a39666a 100644 --- a/src/main/java/sirius/biz/tycho/updates/UpdateManager.java +++ b/src/main/java/sirius/biz/tycho/updates/UpdateManager.java @@ -112,9 +112,9 @@ private void fetchUpdatesFromFeed() { } this.globalUpdates = nextUpdates; this.lastFetch = LocalDateTime.now(); - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException exception) { Exceptions.handle() - .error(e) + .error(exception) .to(Log.BACKGROUND) .withSystemErrorMessage("Failed to fetch updates feed: %s (%s)") .handle(); diff --git a/src/main/java/sirius/biz/tycho/updates/UpdatesReport.java b/src/main/java/sirius/biz/tycho/updates/UpdatesReport.java index f8f2b7a3f..d4d57e9bb 100644 --- a/src/main/java/sirius/biz/tycho/updates/UpdatesReport.java +++ b/src/main/java/sirius/biz/tycho/updates/UpdatesReport.java @@ -108,7 +108,7 @@ private boolean isURL(String guid) { try { URI.create(guid).toURL(); return true; - } catch (MalformedURLException e) { + } catch (MalformedURLException exception) { return false; } } diff --git a/src/main/java/sirius/biz/util/ArchiveExtractor.java b/src/main/java/sirius/biz/util/ArchiveExtractor.java index 98d76e2cc..d14d83291 100644 --- a/src/main/java/sirius/biz/util/ArchiveExtractor.java +++ b/src/main/java/sirius/biz/util/ArchiveExtractor.java @@ -219,9 +219,9 @@ public void extract(String filename, } else { extract7z(archiveFile, enhanceFileFilter(filter), extractedFileConsumer); } - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() - .error(e) + .error(exception) .withSystemErrorMessage("An error occurred while unzipping an archive (%s): %s (%s)", filename) .handle(); diff --git a/src/main/java/sirius/biz/util/ArchiveHelper.java b/src/main/java/sirius/biz/util/ArchiveHelper.java index 3d0c012dd..7e30464c2 100644 --- a/src/main/java/sirius/biz/util/ArchiveHelper.java +++ b/src/main/java/sirius/biz/util/ArchiveHelper.java @@ -79,8 +79,10 @@ public static void extract(File archiveFile, Predicate progressAndStopProvider) throws IOException { try { initSevenZipLib(); - } catch (SevenZipNativeInitializationException e) { - throw new IOException(NLS.fmtr("XMLImporter.sevenZipInitFailed").set("details", e.getMessage()).format()); + } catch (SevenZipNativeInitializationException exception) { + throw new IOException(NLS.fmtr("XMLImporter.sevenZipInitFailed") + .set("details", exception.getMessage()) + .format()); } try (RandomAccessFile randomAccessFile = new RandomAccessFile(archiveFile, "r")) { diff --git a/src/main/java/sirius/biz/util/ExtractedFileBuffer.java b/src/main/java/sirius/biz/util/ExtractedFileBuffer.java index 547ee6bb6..12929a729 100644 --- a/src/main/java/sirius/biz/util/ExtractedFileBuffer.java +++ b/src/main/java/sirius/biz/util/ExtractedFileBuffer.java @@ -74,7 +74,7 @@ public InputStream getInputStream() { } try { return new FileInputStream(buffer.getFile()); - } catch (FileNotFoundException e) { + } catch (FileNotFoundException exception) { throw Exceptions.createHandled().withSystemErrorMessage("No file found inside buffer").handle(); } } @@ -101,10 +101,10 @@ public void cleanup() { if (!buffer.isInMemory()) { Files.delete(buffer.getFile()); } - } catch (Exception e) { + } catch (Exception exception) { Exceptions.handle() .to(Log.SYSTEM) - .error(e) + .error(exception) .withSystemErrorMessage( "Failed to close a temporary buffer created when extracting an archive: %s (%s)"); } diff --git a/src/main/java/sirius/biz/util/ExtractedZipFile.java b/src/main/java/sirius/biz/util/ExtractedZipFile.java index 6c6f396a5..2e2da96b6 100644 --- a/src/main/java/sirius/biz/util/ExtractedZipFile.java +++ b/src/main/java/sirius/biz/util/ExtractedZipFile.java @@ -47,9 +47,9 @@ public InputStream openInputStream() throws IOException { return CloseShieldInputStream.wrap(inputStreamSupplier.create()); } catch (IOException ioException) { throw ioException; - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() - .error(e) + .error(exception) .withSystemErrorMessage("Failed to unzip file from an archive: %s (%s)") .handle(); } diff --git a/src/main/java/sirius/biz/util/LocalArchiveExtractCallback.java b/src/main/java/sirius/biz/util/LocalArchiveExtractCallback.java index 76abcc400..795b56ad5 100644 --- a/src/main/java/sirius/biz/util/LocalArchiveExtractCallback.java +++ b/src/main/java/sirius/biz/util/LocalArchiveExtractCallback.java @@ -93,8 +93,8 @@ public ISequentialOutStream getStream(int index, ExtractAskMode extractAskMode) try { buffer.write(data); return data.length; - } catch (IOException e) { - throw new SevenZipException(e); + } catch (IOException exception) { + throw new SevenZipException(exception); } }; } @@ -136,8 +136,8 @@ private String fixWindowsEncoding(@Nonnull String filePath, String hostOS) { try { // the string has an encoding error with very very very high probability, repair it... return new String(filePath.getBytes(StandardCharsets.ISO_8859_1), "IBM437"); - } catch (UnsupportedEncodingException e) { - Exceptions.ignore(e); + } catch (UnsupportedEncodingException exception) { + Exceptions.ignore(exception); break; } } diff --git a/src/main/java/sirius/biz/util/RedisController.java b/src/main/java/sirius/biz/util/RedisController.java index fa77d8a7d..845f449ac 100644 --- a/src/main/java/sirius/biz/util/RedisController.java +++ b/src/main/java/sirius/biz/util/RedisController.java @@ -53,12 +53,12 @@ public void redis(WebContext webContext) { * Executes the given Redis query. * * @param webContext the current request - * @param out the JSON response + * @param output the JSON response */ @Permission(TenantUserManager.PERMISSION_SYSTEM_ADMINISTRATOR) - @Routed( "/system/redis/api/execute") + @Routed("/system/redis/api/execute") @InternalService - public void executeQuery(WebContext webContext, JSONStructuredOutput out) { + public void executeQuery(WebContext webContext, JSONStructuredOutput output) { Watch watch = Watch.start(); String database = webContext.get("pool").asString(Redis.POOL_SYSTEM); @@ -71,16 +71,16 @@ public void executeQuery(WebContext webContext, JSONStructuredOutput out) { db.getClient().sendCommand(() -> SafeEncoder.encode(parser.parseCommand()), parser.getArgArray()); return db.getClient().getOne(); - } catch (Exception e) { + } catch (Exception exception) { // In case of an invalid query, we do not want to log this into the syslog but // rather just directly output the message to the user.... - throw Exceptions.createHandled().error(e).withDirectMessage(e.getMessage()).handle(); + throw Exceptions.createHandled().error(exception).withDirectMessage(exception.getMessage()).handle(); } }); StringBuilder resultBuilder = new StringBuilder(); renderResult(result, "", resultBuilder); - out.property("result", resultBuilder.toString()); - out.property("duration", watch.duration()); + output.property("result", resultBuilder.toString()); + output.property("duration", watch.duration()); } private void renderResult(Object result, String offset, StringBuilder resultBuilder) { diff --git a/src/main/java/sirius/biz/util/SevenZipAdapter.java b/src/main/java/sirius/biz/util/SevenZipAdapter.java index bcd3c935b..ec6deaab1 100644 --- a/src/main/java/sirius/biz/util/SevenZipAdapter.java +++ b/src/main/java/sirius/biz/util/SevenZipAdapter.java @@ -103,8 +103,8 @@ public ISequentialOutStream getStream(int index, ExtractAskMode extractAskMode) try { currentBuffer.write(data); return data.length; - } catch (IOException e) { - throw new SevenZipException(e); + } catch (IOException exception) { + throw new SevenZipException(exception); } }; } @@ -154,10 +154,10 @@ public void setOperationResult(ExtractOperationResult extractOperationResult) th lastModified, progress); stop = !extractCallback.apply(extracted7ZFile); - } catch (Exception e) { + } catch (Exception exception) { throw Exceptions.handle() .to(Log.SYSTEM) - .error(e) + .error(exception) .withSystemErrorMessage( "An error occurred while handling an extracted file: %s - %s (%s)", currentFilePath) diff --git a/src/main/java/sirius/biz/web/BasePageHelper.java b/src/main/java/sirius/biz/web/BasePageHelper.java index c727f3b12..04ea36bbd 100644 --- a/src/main/java/sirius/biz/web/BasePageHelper.java +++ b/src/main/java/sirius/biz/web/BasePageHelper.java @@ -396,8 +396,8 @@ public Page asPage() { baseQuery.count(), w.elapsedMillis()))); } - } catch (Exception e) { - UserContext.handle(e); + } catch (Exception exception) { + UserContext.handle(exception); } return result; diff --git a/src/main/java/sirius/biz/web/DisasterController.java b/src/main/java/sirius/biz/web/DisasterController.java index 78250b4ef..0f46a244e 100644 --- a/src/main/java/sirius/biz/web/DisasterController.java +++ b/src/main/java/sirius/biz/web/DisasterController.java @@ -78,8 +78,8 @@ public void disaster(WebContext webContext) { webContext.get("previewMessage").getString(), webContext.get("lockMessage").getString()); showSavedMessage(); - } catch (Exception e) { - handle(e); + } catch (Exception exception) { + handle(exception); } } diff --git a/src/main/java/sirius/biz/web/QueryTagController.java b/src/main/java/sirius/biz/web/QueryTagController.java index 6d4afb9e0..bd2688cec 100644 --- a/src/main/java/sirius/biz/web/QueryTagController.java +++ b/src/main/java/sirius/biz/web/QueryTagController.java @@ -41,29 +41,29 @@ public class QueryTagController extends BasicController { /** * Provides suggestions for the given entity type and query. * - * @param ctx the current request - * @param out the JSON response - * @param type the entity type for provide suggestions for + * @param webContext the current request + * @param output the JSON response + * @param type the entity type for provide suggestions for */ @LoginRequired @SuppressWarnings("unchecked") @Routed("/system/search/suggestions/:1") @InternalService - public void suggestions(WebContext ctx, JSONStructuredOutput out, String type) { - String query = ctx.get("query").asString(); - out.beginArray("suggestions"); + public void suggestions(WebContext webContext, JSONStructuredOutput output, String type) { + String query = webContext.get("query").asString(); + output.beginArray("suggestions"); if (Strings.isFilled(query)) { Class entityType = mixing.findDescriptor(type).map(EntityDescriptor::getType).orElse(null); for (QueryTagSuggester suggester : suggesters) { suggester.computeQueryTags(type, (Class>) entityType, query, tag -> { - out.beginObject("suggestion"); - out.property("name", tag.getLabel()); - out.property("color", tag.getColor()); - out.property("value", tag.toString()); - out.endObject(); + output.beginObject("suggestion"); + output.property("name", tag.getLabel()); + output.property("color", tag.getColor()); + output.property("value", tag.toString()); + output.endObject(); }); } } - out.endArray(); + output.endArray(); } } diff --git a/src/main/java/sirius/biz/web/RssFeedHelper.java b/src/main/java/sirius/biz/web/RssFeedHelper.java index ae45631a4..595eca70f 100644 --- a/src/main/java/sirius/biz/web/RssFeedHelper.java +++ b/src/main/java/sirius/biz/web/RssFeedHelper.java @@ -33,8 +33,8 @@ public SyndFeed processFeed(String feedUrl) { try { Outcall outcall = new Outcall(new URI(feedUrl)); return new SyndFeedInput().build(new StringReader(outcall.getData())); - } catch (Exception e) { - Exceptions.handle(Log.APPLICATION, e); + } catch (Exception exception) { + Exceptions.handle(Log.APPLICATION, exception); return new SyndFeedImpl(); } } diff --git a/src/main/java/sirius/biz/web/SQLPageHelper.java b/src/main/java/sirius/biz/web/SQLPageHelper.java index cb2fdf6b1..e4a0f560b 100644 --- a/src/main/java/sirius/biz/web/SQLPageHelper.java +++ b/src/main/java/sirius/biz/web/SQLPageHelper.java @@ -87,8 +87,8 @@ public SQLPageHelper addQueryFacet(String name, } }, (facet, query) -> { try { - SQLQuery qry = queryTransformer.apply(query); - qry.iterateAll(r -> { + SQLQuery smartQuery = queryTransformer.apply(query); + smartQuery.iterateAll(r -> { Iterator> iter = r.getFieldsList().iterator(); if (!iter.hasNext()) { return; @@ -100,8 +100,8 @@ public SQLPageHelper addQueryFacet(String name, } facet.addItem(key, labelProvider.apply(label), -1); }, new Limit(0, 100)); - } catch (SQLException e) { - Exceptions.handle(OMA.LOG, e); + } catch (SQLException exception) { + Exceptions.handle(OMA.LOG, exception); } }); } diff --git a/src/main/java/sirius/biz/web/SaveHelper.java b/src/main/java/sirius/biz/web/SaveHelper.java index d9b8f364a..247e5960e 100644 --- a/src/main/java/sirius/biz/web/SaveHelper.java +++ b/src/main/java/sirius/biz/web/SaveHelper.java @@ -28,7 +28,7 @@ public class SaveHelper { private final BizController bizController; - private final WebContext ctx; + private final WebContext webContext; private Consumer preSaveHandler; private Consumer postSaveHandler; private UnaryOperator skipCreatePredicate; @@ -40,9 +40,9 @@ public class SaveHelper { private boolean acceptUnsafePOST = false; private boolean saveMessage = true; - SaveHelper(BizController bizController, WebContext ctx) { + SaveHelper(BizController bizController, WebContext webContext) { this.bizController = bizController; - this.ctx = ctx; + this.webContext = webContext; } /** @@ -188,18 +188,18 @@ public SaveHelper disableSaveMessage() { @Explain("The method is understandable and readable.") public boolean saveEntity(BaseEntity entity) { try { - if (!((acceptUnsafePOST && ctx.isUnsafePOST()) || ctx.ensureSafePOST())) { + if (!((acceptUnsafePOST && webContext.isUnsafePOST()) || webContext.ensureSafePOST())) { return false; } boolean wasNew = entity.isNew(); if (autoload) { - bizController.load(ctx, entity); + bizController.load(webContext, entity); } if (mappings != null && !mappings.isEmpty()) { - bizController.load(ctx, entity, mappings); + bizController.load(webContext, entity, mappings); } if (preSaveHandler != null) { @@ -216,8 +216,8 @@ public boolean saveEntity(BaseEntity entity) { } if (wasNew && Strings.isFilled(createdURI)) { - ctx.respondWith() - .redirectToGet(Formatter.create(createdURI).set("id", entity.getIdAsString()).format()); + webContext.respondWith() + .redirectToGet(Formatter.create(createdURI).set("id", entity.getIdAsString()).format()); return true; } @@ -226,8 +226,8 @@ public boolean saveEntity(BaseEntity entity) { } if (!entity.getMapper().hasValidationWarnings(entity) && Strings.isFilled(afterSaveURI)) { - ctx.respondWith() - .redirectToGet(Formatter.create(afterSaveURI).set("id", entity.getIdAsString()).format()); + webContext.respondWith() + .redirectToGet(Formatter.create(afterSaveURI).set("id", entity.getIdAsString()).format()); return true; } } catch (Exception exception) { diff --git a/src/main/resources/biz_de.properties b/src/main/resources/biz_de.properties index eac0e0bee..46cb916f3 100644 --- a/src/main/resources/biz_de.properties +++ b/src/main/resources/biz_de.properties @@ -881,6 +881,8 @@ SQLUserAccountExportJobFactory.description = Exportiert Anwender in eine CSV ode SQLUserAccountExportJobFactory.label = Anwender exportieren SQLUserAccountImportJobFactory.description = Importiert Anwender aus einer CSV oder Excel Datei. SQLUserAccountImportJobFactory.label = Anwender importieren +ScheduleInterval.DAILY = Täglich +ScheduleInterval.MONTHLY = Monatlich SchedulerController.parameters = Parameter SchedulerController.planning = Planung SchedulerData.dayOfMonth = Tag diff --git a/src/main/resources/default/templates/biz/cluster/analytics-tasks-cards.html.pasta b/src/main/resources/default/templates/biz/cluster/analytics-tasks-cards.html.pasta new file mode 100644 index 000000000..5f303a990 --- /dev/null +++ b/src/main/resources/default/templates/biz/cluster/analytics-tasks-cards.html.pasta @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Computer +
Average Duration
+ Maximum Duration +
@taskName +
+ + @toUserString(task.getAvgDurationMillis().getAvg()) ms + (@task.getAvgDurationMillis().getSampleCount()) + +
+ @toUserString(task.getMaxDurationMillis()) ms +
@taskName
+
+
+
+
diff --git a/src/main/resources/default/templates/biz/cluster/analytics.html.pasta b/src/main/resources/default/templates/biz/cluster/analytics.html.pasta new file mode 100644 index 000000000..705c0ee34 --- /dev/null +++ b/src/main/resources/default/templates/biz/cluster/analytics.html.pasta @@ -0,0 +1,78 @@ + + +

  • Analytics
  • + + + + + Reset + + + + + + + + + + + + + + + + + + + + + + + +
    + Name
    + Interval +
    + Scheduler Queue
    + Task Queue +
    Last Execution
    + @scheduler.getName()
    + @scheduler.getInterval() +
    + + @schedulerQueue (@distributedTasks.getQueueLength(schedulerQueue))
    + + @taskQueue (@distributedTasks.getQueueLength(taskQueue)) +
    + @toUserString(analyticalEngine.getLastExecution(scheduler).orElse(null))
    +
    + +
    +
    +
    + + + Note: The average and maximum durations shown below are only representing the metrics calculated on the current + node. + It may be a good idea to switch to a specific node via the Nodes screen. + + + + + + + + + + diff --git a/src/main/resources/default/templates/biz/cluster/cluster.html.pasta b/src/main/resources/default/templates/biz/cluster/cluster.html.pasta index 3791b88de..cb54edadd 100644 --- a/src/main/resources/default/templates/biz/cluster/cluster.html.pasta +++ b/src/main/resources/default/templates/biz/cluster/cluster.html.pasta @@ -30,8 +30,15 @@ label="End of Day Tasks" url="/system/cluster/eod-tasks" active="page == 'eod-tasks'"/> + - + diff --git a/src/test/java/sirius/biz/web/autoloading/AutoLoadController.java b/src/test/java/sirius/biz/web/autoloading/AutoLoadController.java index ccd664d8a..2af0c4c14 100644 --- a/src/test/java/sirius/biz/web/autoloading/AutoLoadController.java +++ b/src/test/java/sirius/biz/web/autoloading/AutoLoadController.java @@ -17,11 +17,11 @@ public class AutoLoadController extends BizController { @Routed("/auto-load-controller/:1") - public void route(WebContext ctx, String id) { + public void route(WebContext webContext, String id) { AutoLoadEntity entity = find(AutoLoadEntity.class, id); - boolean a = prepareSave(ctx).saveEntity(entity); + boolean a = prepareSave(webContext).saveEntity(entity); - ctx.respondWith().json().beginResult().property("id", entity.getId()).endResult(); + webContext.respondWith().json().beginResult().property("id", entity.getId()).endResult(); } }