From cfc416e4ecdd0c71e84337c98f8504423ee602ba Mon Sep 17 00:00:00 2001 From: Vova Perebykivskyi Date: Thu, 12 May 2016 17:41:35 +0300 Subject: [PATCH] Update Spring stack. Code refactoring (config files, java classes, css file). Update LibrePlan version in files. --- NEWS.rst | 11 + ganttzk/pom.xml | 33 - .../main/java/org/zkoss/ganttz/Planner.java | 387 +++-- ganttzk/src/main/resources/i18n/keys.pot | 2 +- .../main/resources/web/js/ganttz/TaskRow.js | 14 +- libreplan-business/pom.xml | 30 - .../business/users/entities/UserRole.java | 4 +- .../src/main/resources/ehcache.xml | 6 +- .../libreplan-business-hibernate.cfg.xml | 8 +- .../libreplan-business-spring-config.xml | 29 +- .../business/common/EntitySequenceTest.java | 9 +- .../libreplan-business-hibernate-test.cfg.xml | 2 - libreplan-webapp/pom.xml | 66 +- .../importers/ISchedulerManager.java | 6 +- .../libreplan/importers/SchedulerManager.java | 152 +- .../libreplan/web/common/IndexController.java | 6 +- .../libreplan/web/common/LoginController.java | 15 +- .../web/error/PageForErrorOnEvent.java | 28 +- .../tabs/MultipleTabsPlannerController.java | 231 +-- .../org/libreplan/web/print/CutyPrint.java | 220 ++- .../users/bootstrap/UsersBootstrapInDB.java | 18 +- ...uthenticationProviderLoggingDecorator.java | 23 +- .../services/DBPasswordEncoderService.java | 20 +- .../users/services/DBUserDetailsService.java | 21 +- .../LDAPCustomAuthenticationProvider.java | 200 ++- .../services/LDAPUserDetailsService.java | 24 +- .../src/main/resources/i18n/es.po | 2 +- .../src/main/resources/i18n/fr.po | 2 +- .../src/main/resources/i18n/gl.po | 2 +- .../src/main/resources/i18n/it.po | 2 +- .../src/main/resources/i18n/keys.pot | 2 +- .../src/main/resources/i18n/nl.po | 2 +- .../libreplan-webapp-spring-config.xml | 71 +- ...ibreplan-webapp-spring-security-config.xml | 239 ++- .../main/resources/metainfo/zk/lang-addon.xml | 14 +- .../src/main/webapp/WEB-INF/web.xml | 18 +- .../src/main/webapp/WEB-INF/zk.xml | 6 +- .../main/webapp/common/css/libreplan_zk.css | 128 +- .../src/main/webapp/common/layout/login.zul | 29 +- .../src/main/webapp/common/layout/timeout.zul | 2 +- .../src/main/webapp/planner/index.zul | 2 +- .../importers/ExportTimesheetsToTimTest.java | 16 +- .../ws/orders/OrderElementServiceTest.java | 1327 +++++++++-------- .../libreplan-webapp-spring-config-test.xml | 8 +- ...lan-webapp-spring-security-config-test.xml | 28 +- pom.xml | 96 +- 46 files changed, 1708 insertions(+), 1853 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index da708f30b..fa02a2d02 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -49,6 +49,15 @@ Changes * Update CXF-frontend-jaxrs * Add CXF-rs-client +* Update Spring ORM +* Update Spring Context Support +* Update Spring Test +* Update Spring Web +* Update Spring Security LDAP +* Update Spring Security ACL +* Update Spring Security Web +* Update Spring Security Config + * Update MPXJ * Update Bonecp * Update Guava @@ -65,12 +74,14 @@ Changes * Update AspectJ Weaver * Update JAX-RS API * Update BeanShell +* Update Quartz Framework * Update LibrePlan version to 1.6.0 * Remove Ezmorph * Remove Json-lib +* Remove M2E plugin * Code refactoring diff --git a/ganttzk/pom.xml b/ganttzk/pom.xml index d19472033..2562e55c6 100644 --- a/ganttzk/pom.xml +++ b/ganttzk/pom.xml @@ -56,39 +56,6 @@ - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.xnap.commons - maven-gettext-plugin - [1.2.4,) - - dist - - - - - - - - - - - - - - diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/Planner.java b/ganttzk/src/main/java/org/zkoss/ganttz/Planner.java index 199249bd3..9f0a702a5 100644 --- a/ganttzk/src/main/java/org/zkoss/ganttz/Planner.java +++ b/ganttzk/src/main/java/org/zkoss/ganttz/Planner.java @@ -23,15 +23,16 @@ package org.zkoss.ganttz; import static org.zkoss.ganttz.i18n.I18nHelper._; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; + import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.List; +import java.util.Collection; +import java.util.Collections; +import java.util.ArrayList; import org.apache.commons.logging.Log; import org.zkoss.ganttz.adapters.IDisabilityConfiguration; @@ -77,64 +78,51 @@ import org.zkoss.zul.api.Combobox; public class Planner extends HtmlMacroComponent { - private static final Log PROFILING_LOG = ProfilingLogFactory - .getLog(Planner.class); + private static final Log PROFILING_LOG = ProfilingLogFactory.getLog(Planner.class); - public static boolean guessContainersExpandedByDefaultGivenPrintParameters( - Map printParameters) { + public static boolean guessContainersExpandedByDefaultGivenPrintParameters(Map printParameters) { return guessContainersExpandedByDefault(convertToURLParameters(printParameters)); } - private static Map convertToURLParameters( - Map printParameters) { - Map result = new HashMap(); + private static Map convertToURLParameters(Map printParameters) { + Map result = new HashMap<>(); for (Entry each : printParameters.entrySet()) { result.put(each.getKey(), new String[] { each.getValue() }); } + return result; } - public static boolean guessContainersExpandedByDefault( - Map queryURLParameters) { + public static boolean guessContainersExpandedByDefault(Map queryURLParameters) { String[] values = queryURLParameters.get("expanded"); - if (values == null) { - return false; - } - return toLowercaseSet(values).contains("all"); + + return values != null && toLowercaseSet(values).contains("all"); } - public static boolean guessShowAdvancesByDefault( - Map queryURLParameters) { + public static boolean guessShowAdvancesByDefault(Map queryURLParameters) { String[] values = queryURLParameters.get("advances"); - if (values == null) { - return false; - } - return toLowercaseSet(values).contains("all"); + + return values != null && toLowercaseSet(values).contains("all"); } - public static boolean guessShowReportedHoursByDefault( - Map queryURLParameters) { + public static boolean guessShowReportedHoursByDefault(Map queryURLParameters) { String[] values = queryURLParameters.get("reportedHours"); - if (values == null) { - return false; - } - return toLowercaseSet(values).contains("all"); + + return values != null && toLowercaseSet(values).contains("all"); } - public static boolean guessShowMoneyCostBarByDefault( - Map queryURLParameters) { + public static boolean guessShowMoneyCostBarByDefault(Map queryURLParameters) { String[] values = queryURLParameters.get("moneyCostBar"); - if (values == null) { - return false; - } - return toLowercaseSet(values).contains("all"); + + return values != null && toLowercaseSet(values).contains("all"); } private static Set toLowercaseSet(String[] values) { - Set result = new HashSet(); + Set result = new HashSet<>(); for (String each : values) { result.add(each.toLowerCase()); } + return result; } @@ -146,8 +134,6 @@ public class Planner extends HtmlMacroComponent { private List> contextualizedGlobalCommands; - private CommandContextualized goingDownInLastArrowCommand; - private List> commandsOnTasksContextualized; private CommandOnTaskContextualized doubleClickCommand; @@ -176,17 +162,18 @@ public class Planner extends HtmlMacroComponent { private Listbox listZoomLevels = null; - private WeakReferencedListeners chartVisibilityListeners = WeakReferencedListeners - .create(); + private WeakReferencedListeners chartVisibilityListeners = + WeakReferencedListeners.create(); public Planner() { } TaskList getTaskList() { - if (ganttPanel == null) { + if ( ganttPanel == null ) { return null; } List children = ganttPanel.getChildren(); + return ComponentsFinder.findComponentsOfType(TaskList.class, children).get(0); } @@ -194,9 +181,6 @@ public class Planner extends HtmlMacroComponent { return getTaskList().getTasksNumber(); } - private static int PIXELS_PER_TASK_LEVEL = 21; - private static int PIXELS_PER_CHARACTER = 5; - public int calculateMinimumWidthForTaskNameColumn(boolean expand) { return calculateMinimumWidthForTaskNameColumn(expand, getTaskList().getAllTasks()); } @@ -204,18 +188,22 @@ public class Planner extends HtmlMacroComponent { private int calculateMinimumWidthForTaskNameColumn(boolean expand, List tasks) { IDomainAndBeansMapper mapper = getContext().getMapper(); int widest = 0; + for(Task task : tasks) { - int numberOfAncestors = - mapper.findPositionFor(task).getAncestors().size(); + int numberOfAncestors = mapper.findPositionFor(task).getAncestors().size(); int numberOfCharacters = task.getName().length(); - widest = Math.max(widest, - numberOfCharacters * PIXELS_PER_CHARACTER + - numberOfAncestors * PIXELS_PER_TASK_LEVEL); - if(expand && !task.isLeaf()) { - widest = Math.max(widest, - calculateMinimumWidthForTaskNameColumn(expand, task.getTasks())); + int PIXELS_PER_TASK_LEVEL = 21; + int PIXELS_PER_CHARACTER = 5; + + widest = Math.max( + widest, + numberOfCharacters * PIXELS_PER_CHARACTER + numberOfAncestors * PIXELS_PER_TASK_LEVEL); + + if( expand && !task.isLeaf() ) { + widest = Math.max(widest, calculateMinimumWidthForTaskNameColumn(expand, task.getTasks())); } } + return widest; } @@ -228,50 +216,56 @@ public class Planner extends HtmlMacroComponent { } public DependencyList getDependencyList() { - if (ganttPanel == null) { + if ( ganttPanel == null ) { return null; } + List children = ganttPanel.getChildren(); - List found = ComponentsFinder.findComponentsOfType(DependencyList.class, - children); - if (found.isEmpty()) { + List found = ComponentsFinder.findComponentsOfType(DependencyList.class, children); + + if ( found.isEmpty() ) { return null; } + return found.get(0); } public void addTasks(Position position, Collection newTasks) { TaskList taskList = getTaskList(); - if (taskList != null && leftPane != null) { + if ( taskList != null && leftPane != null ) { taskList.addTasks(position, newTasks); leftPane.addTasks(position, newTasks); } } public void addTask(Position position, Task task) { - addTasks(position, Arrays.asList(task)); + addTasks(position, Collections.singletonList(task)); } void addDependencies(Collection dependencies) { DependencyList dependencyList = getDependencyList(); - if (dependencyList == null) { + if ( dependencyList == null ) { return; } - for (DependencyComponent d : getTaskList().asDependencyComponents( - dependencies)) { + + for (DependencyComponent d : getTaskList().asDependencyComponents(dependencies)) { dependencyList.addDependencyComponent(d); } } public ListModel getZoomLevels() { - ZoomLevel[] selectableZoomlevels = { ZoomLevel.DETAIL_ONE, - ZoomLevel.DETAIL_TWO, ZoomLevel.DETAIL_THREE, - ZoomLevel.DETAIL_FOUR, ZoomLevel.DETAIL_FIVE }; + ZoomLevel[] selectableZoomlevels = { + ZoomLevel.DETAIL_ONE, + ZoomLevel.DETAIL_TWO, + ZoomLevel.DETAIL_THREE, + ZoomLevel.DETAIL_FOUR, + ZoomLevel.DETAIL_FIVE }; + return new SimpleListModel(selectableZoomlevels); } public void setZoomLevel(final ZoomLevel zoomLevel, int scrollLeft) { - if (ganttPanel == null) { + if ( ganttPanel == null ) { return; } this.zoomLevel = zoomLevel; @@ -279,7 +273,7 @@ public class Planner extends HtmlMacroComponent { } public void zoomIncrease() { - if (ganttPanel == null) { + if ( ganttPanel == null ) { return; } LongOperationFeedback.execute(ganttPanel, new ILongOperation() { @@ -297,7 +291,7 @@ public class Planner extends HtmlMacroComponent { } public void zoomDecrease() { - if (ganttPanel == null) { + if ( ganttPanel == null ) { return; } LongOperationFeedback.execute(ganttPanel, new ILongOperation() { @@ -314,13 +308,14 @@ public class Planner extends HtmlMacroComponent { } public void setConfiguration(PlannerConfiguration configuration) { - if (configuration == null) { + if ( configuration == null ) { return; } - if (isShowingLabels) + if ( isShowingLabels ) Clients.evalJavaScript("ganttz.TaskList.getInstance().showAllTaskLabels()"); - if (isShowingResources) + + if ( isShowingResources ) Clients.evalJavaScript("ganttz.TaskList.getInstance().showResourceTooltips()"); this.diagramGraph = GanttDiagramGraph.create( @@ -328,24 +323,24 @@ public class Planner extends HtmlMacroComponent { configuration.getStartConstraints(), configuration.getEndConstraints(), configuration.isDependenciesConstraintsHavePriority()); - FunctionalityExposedForExtensions newContext = new FunctionalityExposedForExtensions( - this, configuration, diagramGraph); + + FunctionalityExposedForExtensions newContext = + new FunctionalityExposedForExtensions<>(this, configuration, diagramGraph); + addGraphChangeListenersFromConfiguration(configuration); - this.contextualizedGlobalCommands = contextualize(newContext, - configuration.getGlobalCommands()); - this.commandsOnTasksContextualized = contextualize(newContext, - configuration.getCommandsOnTasks()); - goingDownInLastArrowCommand = contextualize(newContext, configuration - .getGoingDownInLastArrowCommand()); - doubleClickCommand = contextualize(newContext, configuration - .getDoubleClickCommand()); + this.contextualizedGlobalCommands = contextualize(newContext, configuration.getGlobalCommands()); + this.commandsOnTasksContextualized = contextualize(newContext, configuration.getCommandsOnTasks()); + + CommandContextualized goingDownInLastArrowCommand = + contextualize(newContext, configuration.getGoingDownInLastArrowCommand()); + + doubleClickCommand = contextualize(newContext, configuration.getDoubleClickCommand()); this.context = newContext; this.disabilityConfiguration = configuration; resettingPreviousComponentsToNull(); long timeAddingData = System.currentTimeMillis(); newContext.add(configuration.getData()); - PROFILING_LOG.debug("It took to add data: " - + (System.currentTimeMillis() - timeAddingData) + " ms"); + PROFILING_LOG.debug("It took to add data: " + (System.currentTimeMillis() - timeAddingData) + " ms"); long timeSetupingAndAddingComponents = System.currentTimeMillis(); setupComponents(); setAt("insertionPointLeftPanel", leftPane); @@ -354,34 +349,38 @@ public class Planner extends HtmlMacroComponent { ganttPanel.afterCompose(); leftPane.setGoingDownInLastArrowCommand(goingDownInLastArrowCommand); - TimeTrackerComponent timetrackerheader = new TimeTrackerComponentWithoutColumns( - ganttPanel.getTimeTracker(), "timetrackerheader"); + TimeTrackerComponent timetrackerheader = + new TimeTrackerComponentWithoutColumns(ganttPanel.getTimeTracker(), "timetrackerheader"); setAt("insertionPointTimetracker", timetrackerheader); timetrackerheader.afterCompose(); Component chartComponent = configuration.getChartComponent(); - if (chartComponent != null) { + if ( chartComponent != null ) { setAt("insertionPointChart", chartComponent); } - if (!configuration.isCriticalPathEnabled()) { + if ( !configuration.isCriticalPathEnabled() ) { Button showCriticalPathButton = (Button) getFellow("showCriticalPath"); showCriticalPathButton.setVisible(false); } - if (!configuration.isExpandAllEnabled()) { + + if ( !configuration.isExpandAllEnabled() ) { Button expandAllButton = (Button) getFellow("expandAll"); expandAllButton.setVisible(false); } - if (!configuration.isFlattenTreeEnabled()) { + + if ( !configuration.isFlattenTreeEnabled() ) { Button flattenTree = (Button) getFellow("flattenTree"); flattenTree.setVisible(false); } - if (!configuration.isShowAllResourcesEnabled()) { + + if ( !configuration.isShowAllResourcesEnabled() ) { Button showAllResources = (Button) getFellow("showAllResources"); showAllResources.setVisible(false); } - if (!configuration.isMoneyCostBarEnabled()) { + + if ( !configuration.isMoneyCostBarEnabled() ) { Button showMoneyCostBarButton = (Button) getFellow("showMoneyCostBar"); showMoneyCostBarButton.setVisible(false); } @@ -391,35 +390,33 @@ public class Planner extends HtmlMacroComponent { this.visibleChart = configuration.isExpandPlanningViewCharts(); ((South) getFellow("graphics")).setOpen(this.visibleChart); - PROFILING_LOG - .debug("it took doing the setup of components and adding them: " - + (System.currentTimeMillis() - timeSetupingAndAddingComponents) - + " ms"); + PROFILING_LOG.debug( + "It took doing the setup of components and adding them: " + + (System.currentTimeMillis() - timeSetupingAndAddingComponents) + " ms"); setAuService(new AuService(){ public boolean service(AuRequest request, boolean everError){ String command = request.getCommand(); - String[] requestData; int zoomindex; int scrollLeft; - if (command.equals("onZoomLevelChange")){ + if ( command.equals("onZoomLevelChange") ){ zoomindex= (Integer) retrieveData(request, "zoomindex"); scrollLeft = (Integer) retrieveData(request, "scrollLeft"); setZoomLevel((ZoomLevel)((Listbox)getFellow("listZoomLevels")) - .getModel().getElementAt(zoomindex), - scrollLeft); + .getModel().getElementAt(zoomindex), scrollLeft); + return true; } + return false; } private Object retrieveData(AuRequest request, String key){ Object value = request.getData().get(key); - if ( value == null) - throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA, - new Object[] { key, this }); + if ( value == null ) + throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA, new Object[] { key, this }); return value; } @@ -438,36 +435,38 @@ public class Planner extends HtmlMacroComponent { } private List> contextualize( - FunctionalityExposedForExtensions context, - List> commands) { - List> result = new ArrayList>(); + FunctionalityExposedForExtensions context, List> commands) { + + List> result = new ArrayList<>(); for (ICommandOnTask c : commands) { result.add(contextualize(context, c)); } + return result; } private CommandOnTaskContextualized contextualize( - FunctionalityExposedForExtensions context, - ICommandOnTask commandOnTask) { - return CommandOnTaskContextualized.create(commandOnTask, context - .getMapper(), context); + FunctionalityExposedForExtensions context, ICommandOnTask commandOnTask) { + + return CommandOnTaskContextualized.create(commandOnTask, context.getMapper(), context); } - private CommandContextualized contextualize(IContext context, - ICommand command) { + private CommandContextualized contextualize(IContext context, ICommand command) { if (command == null) { return null; } + return CommandContextualized.create(command, context); } private List> contextualize( IContext context, Collection> commands) { - ArrayList> result = new ArrayList>(); + + ArrayList> result = new ArrayList<>(); for (ICommand command : commands) { result.add(contextualize(context, command)); } + return result; } @@ -475,16 +474,16 @@ public class Planner extends HtmlMacroComponent { insertGlobalCommands(); predicate = new FilterAndParentExpandedPredicates(context) { - @Override public boolean accpetsFilterPredicate(Task task) { return true; } }; + this.leftPane = new LeftPane(disabilityConfiguration, this, predicate); - this.ganttPanel = new GanttPanel(this, - commandsOnTasksContextualized, doubleClickCommand, - disabilityConfiguration, predicate); + + this.ganttPanel = new GanttPanel( + this, commandsOnTasksContextualized, doubleClickCommand, disabilityConfiguration, predicate); Button button = (Button) getFellow("btnPrint"); button.setDisabled(!context.isPrintEnabled()); @@ -502,16 +501,18 @@ public class Planner extends HtmlMacroComponent { private void insertGlobalCommands() { Component commontoolbar = getCommonCommandsInsertionPoint(); Component plannerToolbar = getSpecificCommandsInsertionPoint(); - if (!contextualizedGlobalCommands.isEmpty()) { + + if ( !contextualizedGlobalCommands.isEmpty() ) { commontoolbar.getChildren().removeAll(commontoolbar.getChildren()); } + for (CommandContextualized c : contextualizedGlobalCommands) { + // Comparison through icon as name is internationalized - if (c.getCommand().isPlannerCommand()) { + if ( c.getCommand().isPlannerCommand() ) { // FIXME Avoid hard-coding the number of planner commands - // At this moment we have 2 planner commands: reassign and adapt - // planning - if (plannerToolbar.getChildren().size() < 2) { + // At this moment we have 2 planner commands: reassign and adapt planning + if ( plannerToolbar.getChildren().size() < 2 ) { plannerToolbar.appendChild(c.toButton()); } } else { @@ -522,14 +523,11 @@ public class Planner extends HtmlMacroComponent { } private Component getCommonCommandsInsertionPoint() { - Component insertionPoint = getPage().getFellow( - "perspectiveButtonsInsertionPoint"); - return insertionPoint; + return getPage().getFellow("perspectiveButtonsInsertionPoint"); } private Component getSpecificCommandsInsertionPoint() { - Component insertionPoint = getFellow("plannerButtonsInsertionPoint"); - return insertionPoint; + return getFellow("plannerButtonsInsertionPoint"); } void removeTask(Task task) { @@ -537,7 +535,10 @@ public class Planner extends HtmlMacroComponent { taskList.remove(task); getDependencyList().taskRemoved(task); leftPane.taskRemoved(task); - setHeight(getHeight());// forcing smart update + + // forcing smart update + setHeight(getHeight()); + ganttPanel.adjustZoomColumnsHeight(); getDependencyList().redrawDependencies(); } @@ -609,40 +610,47 @@ public class Planner extends HtmlMacroComponent { public void showCriticalPath() { Button showCriticalPathButton = (Button) getFellow("showCriticalPath"); - if (disabilityConfiguration.isCriticalPathEnabled()) { - if (isShowingCriticalPath) { + + if ( disabilityConfiguration.isCriticalPathEnabled() ) { + if ( isShowingCriticalPath ) { context.hideCriticalPath(); diagramGraph.removePostGraphChangeListener(showCriticalPathOnChange); showCriticalPathButton.setSclass("planner-command"); showCriticalPathButton.setTooltiptext(_("Show critical path")); + } else { context.showCriticalPath(); diagramGraph.addPostGraphChangeListener(showCriticalPathOnChange); showCriticalPathButton.setSclass("planner-command clicked"); showCriticalPathButton.setTooltiptext(_("Hide critical path")); } + isShowingCriticalPath = !isShowingCriticalPath; } } public void forcedShowAdvances() { - if (!isShowingAdvances) { + if ( !isShowingAdvances ) { showAdvances(); } } public void showAdvances() { Button showAdvancesButton = (Button) getFellow("showAdvances"); - if (disabilityConfiguration.isAdvancesEnabled()) { + if ( disabilityConfiguration.isAdvancesEnabled() ) { + Combobox progressTypesCombo = (Combobox) getFellow("cbProgressTypes"); - if (isShowingAdvances) { + if ( isShowingAdvances ) { + context.hideAdvances(); diagramGraph.removePostGraphChangeListener(showAdvanceOnChange); showAdvancesButton.setSclass("planner-command"); showAdvancesButton.setTooltiptext(_("Show progress")); - if (progressTypesCombo.getItemCount() > 0) { + + if ( progressTypesCombo.getItemCount() > 0 ) { progressTypesCombo.setSelectedIndex(0); } + } else { context.showAdvances(); diagramGraph.addPostGraphChangeListener(showAdvanceOnChange); @@ -655,21 +663,19 @@ public class Planner extends HtmlMacroComponent { public void showReportedHours() { Button showReportedHoursButton = (Button) getFellow("showReportedHours"); - if (disabilityConfiguration.isReportedHoursEnabled()) { - if (isShowingReportedHours) { + + if ( disabilityConfiguration.isReportedHoursEnabled() ) { + if ( isShowingReportedHours ) { context.hideReportedHours(); - diagramGraph - .removePostGraphChangeListener(showReportedHoursOnChange); + diagramGraph.removePostGraphChangeListener(showReportedHoursOnChange); showReportedHoursButton.setSclass("planner-command"); - showReportedHoursButton - .setTooltiptext(_("Show reported hours")); + showReportedHoursButton.setTooltiptext(_("Show reported hours")); + } else { context.showReportedHours(); - diagramGraph - .addPostGraphChangeListener(showReportedHoursOnChange); + diagramGraph.addPostGraphChangeListener(showReportedHoursOnChange); showReportedHoursButton.setSclass("planner-command clicked"); - showReportedHoursButton - .setTooltiptext(_("Hide reported hours")); + showReportedHoursButton.setTooltiptext(_("Hide reported hours")); } isShowingReportedHours = !isShowingReportedHours; } @@ -677,17 +683,16 @@ public class Planner extends HtmlMacroComponent { public void showMoneyCostBar() { Button showMoneyCostBarButton = (Button) getFellow("showMoneyCostBar"); - if (disabilityConfiguration.isMoneyCostBarEnabled()) { - if (isShowingMoneyCostBar) { + + if ( disabilityConfiguration.isMoneyCostBarEnabled() ) { + if ( isShowingMoneyCostBar ) { context.hideMoneyCostBar(); - diagramGraph - .removePostGraphChangeListener(showMoneyCostBarOnChange); + diagramGraph.removePostGraphChangeListener(showMoneyCostBarOnChange); showMoneyCostBarButton.setSclass("planner-command"); showMoneyCostBarButton.setTooltiptext(_("Show money cost bar")); } else { context.showMoneyCostBar(); - diagramGraph - .addPostGraphChangeListener(showMoneyCostBarOnChange); + diagramGraph.addPostGraphChangeListener(showMoneyCostBarOnChange); showMoneyCostBarButton.setSclass("planner-command clicked"); showMoneyCostBarButton.setTooltiptext(_("Hide money cost bar")); } @@ -697,41 +702,39 @@ public class Planner extends HtmlMacroComponent { public void showAllLabels() { Button showAllLabelsButton = (Button) getFellow("showAllLabels"); - if (isShowingLabels) { + if ( isShowingLabels ) { Clients.evalJavaScript("ganttz.TaskList.getInstance().hideAllTaskLabels()"); showAllLabelsButton.setSclass("planner-command show-labels"); } else { Clients.evalJavaScript("ganttz.TaskList.getInstance().showAllTaskLabels()"); - showAllLabelsButton - .setSclass("planner-command show-labels clicked"); + showAllLabelsButton.setSclass("planner-command show-labels clicked"); } isShowingLabels = !isShowingLabels; } public void showAllResources() { Button showAllLabelsButton = (Button) getFellow("showAllResources"); - if (isShowingResources) { + if ( isShowingResources ) { Clients.evalJavaScript("ganttz.TaskList.getInstance().hideResourceTooltips()"); showAllLabelsButton.setSclass("planner-command show-resources"); } else { Clients.evalJavaScript("ganttz.TaskList.getInstance().showResourceTooltips()"); - showAllLabelsButton - .setSclass("planner-command show-resources clicked"); + showAllLabelsButton.setSclass("planner-command show-resources clicked"); } isShowingResources = !isShowingResources; } public void print() { - // Pending to raise print configuration popup. Information retrieved - // should be passed as parameter to context print method + // Pending to raise print configuration popup. + // Information retrieved should be passed as parameter to context print method. context.print(); } public ZoomLevel getZoomLevel() { - if (ganttPanel == null) { - return zoomLevel != null ? zoomLevel - : ZoomLevel.DETAIL_ONE; + if ( ganttPanel == null ) { + return zoomLevel != null ? zoomLevel : ZoomLevel.DETAIL_ONE; } + return ganttPanel.getTimeTracker().getDetailLevel(); } @@ -743,8 +746,7 @@ public class Planner extends HtmlMacroComponent { return containersExpandedByDefault; } - public void setAreContainersExpandedByDefault( - boolean containersExpandedByDefault) { + public void setAreContainersExpandedByDefault(boolean containersExpandedByDefault) { this.containersExpandedByDefault = containersExpandedByDefault; } @@ -761,8 +763,7 @@ public class Planner extends HtmlMacroComponent { this.isShowingAdvances = shownAdvanceByDefault; } - public void setAreShownReportedHoursByDefault( - boolean shownReportedHoursByDefault) { + public void setAreShownReportedHoursByDefault(boolean shownReportedHoursByDefault) { this.shownReportedHoursByDefault = shownReportedHoursByDefault; } @@ -774,8 +775,7 @@ public class Planner extends HtmlMacroComponent { return (areShownReportedHoursByDefault() || isShowingReportedHours); } - public void setAreShownMoneyCostBarByDefault( - boolean shownMoneyCostBarByDefault) { + public void setAreShownMoneyCostBarByDefault(boolean shownMoneyCostBarByDefault) { this.shownMoneyCostBarByDefault = shownMoneyCostBarByDefault; } @@ -789,8 +789,9 @@ public class Planner extends HtmlMacroComponent { public void expandAll() { Button expandAllButton = (Button) getFellow("expandAll"); - if (disabilityConfiguration.isExpandAllEnabled()) { - if (isExpandAll) { + + if ( disabilityConfiguration.isExpandAllEnabled() ) { + if ( isExpandAll ) { context.collapseAll(); expandAllButton.setSclass("planner-command"); } else { @@ -803,7 +804,7 @@ public class Planner extends HtmlMacroComponent { public void expandAllAlways() { Button expandAllButton = (Button) getFellow("expandAll"); - if (disabilityConfiguration.isExpandAllEnabled()) { + if ( disabilityConfiguration.isExpandAllEnabled() ) { context.expandAll(); expandAllButton.setSclass("planner-command clicked"); } @@ -811,8 +812,7 @@ public class Planner extends HtmlMacroComponent { public void updateSelectedZoomLevel() { ganttPanel.getTimeTracker().setZoomLevel(zoomLevel); - Listitem selectedItem = (Listitem) listZoomLevels.getItems().get( - zoomLevel.ordinal()); + Listitem selectedItem = (Listitem) listZoomLevels.getItems().get(zoomLevel.ordinal()); listZoomLevels.setSelectedItem(selectedItem); listZoomLevels.invalidate(); } @@ -827,19 +827,20 @@ public class Planner extends HtmlMacroComponent { getTaskList().setPredicate(predicate); getDependencyList().redrawDependencies(); - if (isShowingLabels) { + if ( isShowingLabels ) { Clients.evalJavaScript("ganttz.TaskList.getInstance().showAllTaskLabels();"); } - if (isShowingResources) { + if ( isShowingResources ) { Clients.evalJavaScript("ganttz.TaskList.getInstance().showResourceTooltips();"); } } public void flattenTree() { Button flattenTreeButton = (Button) getFellow("flattenTree"); - if (disabilityConfiguration.isFlattenTreeEnabled()) { - if (isFlattenTree) { + + if ( disabilityConfiguration.isFlattenTreeEnabled() ) { + if ( isFlattenTree ) { predicate.setFilterContainers(false); flattenTreeButton.setSclass("planner-command"); } else { @@ -858,31 +859,25 @@ public class Planner extends HtmlMacroComponent { public void changeChartVisibility(boolean visible) { visibleChart = visible; - chartVisibilityListeners - .fireEvent(new IListenerNotification() { - @Override - public void doNotify( - IChartVisibilityChangedListener listener) { - listener.chartVisibilityChanged(visibleChart); - } - }); + chartVisibilityListeners.fireEvent(new IListenerNotification() { + @Override + public void doNotify(IChartVisibilityChangedListener listener) { + listener.chartVisibilityChanged(visibleChart); + } + }); } public boolean isVisibleChart() { return visibleChart; } - public void addChartVisibilityListener( - IChartVisibilityChangedListener chartVisibilityChangedListener) { + public void addChartVisibilityListener(IChartVisibilityChangedListener chartVisibilityChangedListener) { chartVisibilityListeners.addListener(chartVisibilityChangedListener); } - public void addGraphChangeListenersFromConfiguration( - PlannerConfiguration configuration) { - diagramGraph.addPreChangeListeners(configuration - .getPreChangeListeners()); - diagramGraph.addPostChangeListeners(configuration - .getPostChangeListeners()); + public void addGraphChangeListenersFromConfiguration(PlannerConfiguration configuration) { + diagramGraph.addPreChangeListeners(configuration.getPreChangeListeners()); + diagramGraph.addPostChangeListeners(configuration.getPostChangeListeners()); } public boolean isShowingCriticalPath() { @@ -911,10 +906,11 @@ public class Planner extends HtmlMacroComponent { public Button findCommandComponent(String name) { for (CommandContextualized c : contextualizedGlobalCommands) { - if (c.getCommand().getName().equals(name)) { + if ( c.getCommand().getName().equals(name) ) { return c.toButton(); } } + return null; } @@ -928,7 +924,7 @@ public class Planner extends HtmlMacroComponent { public void updateCompletion(String progressType) { TaskList taskList = getTaskList(); - if (taskList != null) { + if ( taskList != null ) { taskList.updateCompletion(progressType); // FIXME Bug #1270 for (TaskComponent each : taskList.getTaskComponents()) { @@ -937,12 +933,11 @@ public class Planner extends HtmlMacroComponent { } } - public TaskComponent getTaskComponentRelatedTo( - org.zkoss.ganttz.data.Task task) { + public TaskComponent getTaskComponentRelatedTo(org.zkoss.ganttz.data.Task task) { TaskList taskList = getTaskList(); - if (taskList != null) { + if ( taskList != null ) { for (TaskComponent each : taskList.getTaskComponents()) { - if (each.getTask().equals(task)) { + if ( each.getTask().equals(task) ) { return each; } } diff --git a/ganttzk/src/main/resources/i18n/keys.pot b/ganttzk/src/main/resources/i18n/keys.pot index a12ada337..d526d423d 100644 --- a/ganttzk/src/main/resources/i18n/keys.pot +++ b/ganttzk/src/main/resources/i18n/keys.pot @@ -7,7 +7,7 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: libreplan-1.4.0\n" +"Project-Id-Version: libreplan-1.6.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2013-04-22 12:09+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/ganttzk/src/main/resources/web/js/ganttz/TaskRow.js b/ganttzk/src/main/resources/web/js/ganttz/TaskRow.js index 1b723f8e4..2f1ec3f68 100644 --- a/ganttzk/src/main/resources/web/js/ganttz/TaskRow.js +++ b/ganttzk/src/main/resources/web/js/ganttz/TaskRow.js @@ -1,21 +1,27 @@ zk.$package("ganttz"); ganttz.TaskRow = zk.$extends(zk.Widget, { + _labelsHidden : true, - showLabels : function(){ + + showLabels : function() { this._labelsHidden = false; this.firstChild.showLabels(); }, - hideLabels : function(){ + + hideLabels : function() { this._labelsHidden = true; this.firstChild.hideLabels(); }, + _resourcesHidden : true, - hideResourceTooltip : function(){ + + hideResourceTooltip : function() { this._resourcesHidden = true; this.firstChild.hideResourceTooltip(); }, - showResourceTooltip : function(){ + + showResourceTooltip : function() { this._resourcesHidden = false; this.firstChild.showResourceTooltip(); } diff --git a/libreplan-business/pom.xml b/libreplan-business/pom.xml index ab6d6d7b0..9401db1b6 100644 --- a/libreplan-business/pom.xml +++ b/libreplan-business/pom.xml @@ -207,35 +207,5 @@ - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.liquibase - liquibase-maven-plugin - [3.5.0,) - - update - - - - - - - - - - - - diff --git a/libreplan-business/src/main/java/org/libreplan/business/users/entities/UserRole.java b/libreplan-business/src/main/java/org/libreplan/business/users/entities/UserRole.java index 7eb2a4363..e01c484c8 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/users/entities/UserRole.java +++ b/libreplan-business/src/main/java/org/libreplan/business/users/entities/UserRole.java @@ -28,7 +28,7 @@ import static org.libreplan.business.i18n.I18nHelper._; * * @author Fernando Bellas Permuy * @author Manuel Rego Casasnovas - * @author Vova Perebykivskiy + * @author Vova Perebykivskyi */ public enum UserRole { @@ -100,7 +100,7 @@ public enum UserRole { private final String displayName; - private UserRole(String displayName) { + UserRole(String displayName) { this.displayName = displayName; } diff --git a/libreplan-business/src/main/resources/ehcache.xml b/libreplan-business/src/main/resources/ehcache.xml index c5ba90860..b954dfede 100644 --- a/libreplan-business/src/main/resources/ehcache.xml +++ b/libreplan-business/src/main/resources/ehcache.xml @@ -1,7 +1,7 @@ - diff --git a/libreplan-business/src/main/resources/libreplan-business-hibernate.cfg.xml b/libreplan-business/src/main/resources/libreplan-business-hibernate.cfg.xml index 2eb4c3e8a..c95785a56 100644 --- a/libreplan-business/src/main/resources/libreplan-business-hibernate.cfg.xml +++ b/libreplan-business/src/main/resources/libreplan-business-hibernate.cfg.xml @@ -10,10 +10,10 @@ ${hibernate.use_sql_comments} ${hibernate.hbm2ddl.auto} - none diff --git a/libreplan-business/src/main/resources/libreplan-business-spring-config.xml b/libreplan-business/src/main/resources/libreplan-business-spring-config.xml index d1d59767b..7ae296f0d 100644 --- a/libreplan-business/src/main/resources/libreplan-business-spring-config.xml +++ b/libreplan-business/src/main/resources/libreplan-business-spring-config.xml @@ -112,22 +112,17 @@ class="org.springframework.orm.hibernate4.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory" /> - + - + - @@ -135,26 +130,18 @@ class="org.libreplan.business.common.VersionInformation" factory-method="getInstance" lazy-init="false"> - - ${project.version} - + - - ${default.passwordsControl} - - - ${default.exampleUsersDisabled} - - - ${default.emailSendingEnabled} - + + + - + diff --git a/libreplan-business/src/test/java/org/libreplan/business/common/EntitySequenceTest.java b/libreplan-business/src/test/java/org/libreplan/business/common/EntitySequenceTest.java index d7d707a61..8913a2d25 100644 --- a/libreplan-business/src/test/java/org/libreplan/business/common/EntitySequenceTest.java +++ b/libreplan-business/src/test/java/org/libreplan/business/common/EntitySequenceTest.java @@ -58,9 +58,7 @@ public class EntitySequenceTest { for (EntitySequence sequence : entitySequenceDAO.getAll()) { try { entitySequenceDAO.remove(sequence.getId()); - } catch (InstanceNotFoundException e) { - - } + } catch (InstanceNotFoundException ignored) {} } } @@ -73,8 +71,8 @@ public class EntitySequenceTest { } catch (ValidationException e) { fail("It should not throw an exception"); } - assertTrue(entitySequenceDAO.getAll().size() == 1); + assertTrue(entitySequenceDAO.getAll().size() == 1); } @Test @@ -159,8 +157,7 @@ public class EntitySequenceTest { entitySequenceDAO.save(entitySequenceB); fail("Expected ValidationException"); - } catch (ValidationException e) { - } + } catch (ValidationException ignored) {} } @Test diff --git a/libreplan-business/src/test/resources/libreplan-business-hibernate-test.cfg.xml b/libreplan-business/src/test/resources/libreplan-business-hibernate-test.cfg.xml index 4ac657155..b9b8a7673 100644 --- a/libreplan-business/src/test/resources/libreplan-business-hibernate-test.cfg.xml +++ b/libreplan-business/src/test/resources/libreplan-business-hibernate-test.cfg.xml @@ -11,8 +11,6 @@ none - none - true jvm jvm diff --git a/libreplan-webapp/pom.xml b/libreplan-webapp/pom.xml index ca5192401..e1fc9fe81 100644 --- a/libreplan-webapp/pom.xml +++ b/libreplan-webapp/pom.xml @@ -236,62 +236,6 @@ libreplan-webapp - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-antrun-plugin - [1.8,) - - run - - - - - - - - - org.codehaus.mojo - jasperreports-maven-plugin - [1.0-beta-2,) - - compile-reports - - - - - - - - - com.googlecode.gettext-commons - gettext-maven-plugin - [1.2.4,) - - dist - - - - - - - - - - - - @@ -334,8 +278,8 @@ spring-security-config - org.springframework.security - spring-security-acl + org.springframework + spring-context-support @@ -354,12 +298,6 @@ spring-security-acl - - - org.springframework.security - spring-security-ldap - - org.springframework diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/ISchedulerManager.java b/libreplan-webapp/src/main/java/org/libreplan/importers/ISchedulerManager.java index 745ef51a3..4a5566b36 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/ISchedulerManager.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/ISchedulerManager.java @@ -21,8 +21,6 @@ package org.libreplan.importers; import org.libreplan.business.common.entities.JobSchedulerConfiguration; import org.quartz.SchedulerException; -import org.springframework.scheduling.quartz.CronTriggerBean; -import org.springframework.scheduling.quartz.JobDetailBean; /** * A manager(client) that dynamically creates jobs and cron-triggers using @@ -36,8 +34,8 @@ import org.springframework.scheduling.quartz.JobDetailBean; * {@link JobSchedulerConfiguration} entity once the scheduler starts. * *
    - *
  • Schedule job:create job {@link JobDetailBean} and cron-trigger - * {@link CronTriggerBean}, associated the trigger with the job and add it to + *
  • Schedule job:create job {@link JobDetailFactoryBean} and cron-trigger + * {@link CronTriggerFactoryBean}, associated the trigger with the job and add it to * the scheduler. *
  • *
  • Delete job: search the job in the scheduler and if found diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/SchedulerManager.java b/libreplan-webapp/src/main/java/org/libreplan/importers/SchedulerManager.java index 20afacf42..cbcfbeedc 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/SchedulerManager.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/SchedulerManager.java @@ -37,12 +37,13 @@ import org.quartz.CronTrigger; import org.quartz.JobExecutionContext; import org.quartz.Scheduler; import org.quartz.SchedulerException; +import org.quartz.TriggerKey; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Scope; -import org.springframework.scheduling.quartz.CronTriggerBean; -import org.springframework.scheduling.quartz.JobDetailBean; +import org.springframework.scheduling.quartz.CronTriggerFactoryBean; +import org.springframework.scheduling.quartz.JobDetailFactoryBean; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -71,7 +72,7 @@ public class SchedulerManager implements ISchedulerManager { /** - * suffix for trigger -group and -name + * Suffix for trigger -group and -name */ private static final String TRIGGER_SUFFIX = "-TRIGGER"; @@ -85,8 +86,7 @@ public class SchedulerManager implements ISchedulerManager { @Override public void scheduleJobs() { - List jobSchedulerConfigurations = jobSchedulerConfigurationDAO - .getAll(); + List jobSchedulerConfigurations = jobSchedulerConfigurationDAO.getAll(); for (JobSchedulerConfiguration conf : jobSchedulerConfigurations) { try { scheduleOrUnscheduleJob(conf); @@ -98,22 +98,24 @@ public class SchedulerManager implements ISchedulerManager { @Override @Transactional(readOnly = true) - public void scheduleOrUnscheduleJob( - JobSchedulerConfiguration jobSchedulerConfiguration) throws SchedulerException { + public void scheduleOrUnscheduleJob(JobSchedulerConfiguration jobSchedulerConfiguration) throws SchedulerException { - if (hasConnector(jobSchedulerConfiguration.getConnectorName())) { - if (isConnectorActivated(jobSchedulerConfiguration - .getConnectorName())) { - if (jobSchedulerConfiguration.isSchedule()) { + if ( hasConnector(jobSchedulerConfiguration.getConnectorName()) ) { + if ( isConnectorActivated(jobSchedulerConfiguration.getConnectorName()) ) { + if ( jobSchedulerConfiguration.isSchedule() ) { scheduleNewJob(jobSchedulerConfiguration); + return; } } deleteJob(jobSchedulerConfiguration); + return; } - if (!jobSchedulerConfiguration.isSchedule()) { + + if ( !jobSchedulerConfiguration.isSchedule() ) { deleteJob(jobSchedulerConfiguration); + return; } scheduleNewJob(jobSchedulerConfiguration); @@ -139,32 +141,30 @@ public class SchedulerManager implements ISchedulerManager { */ private boolean isConnectorActivated(String connectorName) { Connector connector = connectorDAO.findUniqueByName(connectorName); - if (connector == null) { - return false; - } - return connector.isActivated(); + + return connector != null && connector.isActivated(); } @Override public void deleteJob(JobSchedulerConfiguration jobSchedulerConfiguration) throws SchedulerException { - String triggerName = jobSchedulerConfiguration.getJobName() - + TRIGGER_SUFFIX; - String triggerGroup = jobSchedulerConfiguration.getJobGroup() - + TRIGGER_SUFFIX; + String triggerName = jobSchedulerConfiguration.getJobName() + TRIGGER_SUFFIX; + String triggerGroup = jobSchedulerConfiguration.getJobGroup() + TRIGGER_SUFFIX; - CronTriggerBean trigger = getTriggerBean(triggerName, triggerGroup); - if (trigger == null) { + CronTriggerFactoryBean trigger = getTriggerBean(triggerName, triggerGroup); + if ( trigger == null ) { LOG.warn("Trigger not found"); + return; } - if (isJobCurrentlyExecuting(triggerName, triggerGroup)) { + if ( isJobCurrentlyExecuting(triggerName, triggerGroup) ) { LOG.warn("Job is currently executing..."); + return; } // deleteJob doesn't work using unscheduleJob - this.scheduler.unscheduleJob(trigger.getName(), trigger.getGroup()); + this.scheduler.unscheduleJob(trigger.getObject().getKey()); } /** @@ -178,26 +178,25 @@ public class SchedulerManager implements ISchedulerManager { * @return true if job is currently running, otherwise false */ @SuppressWarnings("unchecked") - private boolean isJobCurrentlyExecuting(String triggerName, - String triggerGroup) { + private boolean isJobCurrentlyExecuting(String triggerName, String triggerGroup) { try { - List currentExecutingJobs = this.scheduler - .getCurrentlyExecutingJobs(); + List currentExecutingJobs = this.scheduler.getCurrentlyExecutingJobs(); for (JobExecutionContext jobExecutionContext : currentExecutingJobs) { - String name = jobExecutionContext.getTrigger().getName(); - String group = jobExecutionContext.getTrigger().getGroup(); - if (triggerName.equals(name) && triggerGroup.equals(group)) { + String name = jobExecutionContext.getTrigger().getKey().getName(); + String group = jobExecutionContext.getTrigger().getKey().getGroup(); + if ( triggerName.equals(name) && triggerGroup.equals(group) ) { return true; } } } catch (SchedulerException e) { LOG.error("Unable to get currently executing jobs", e); } + return false; } /** - * Creates {@link CronTriggerBean} and {@link JobDetailBean} based on the + * Creates {@link CronTriggerFactoryBean} and {@link JobDetailFactoryBean} based on the * specified {@link JobSchedulerConfiguration}. First delete * job if exist and then schedule it * @@ -206,65 +205,64 @@ public class SchedulerManager implements ISchedulerManager { * @throws SchedulerException * if unable to delete and/or schedule job */ - private void scheduleNewJob( - JobSchedulerConfiguration jobSchedulerConfiguration) throws SchedulerException { - CronTriggerBean cronTriggerBean = createCronTriggerBean(jobSchedulerConfiguration); - if (cronTriggerBean == null) { + private void scheduleNewJob(JobSchedulerConfiguration jobSchedulerConfiguration) throws SchedulerException { + CronTriggerFactoryBean cronTriggerBean = createCronTriggerBean(jobSchedulerConfiguration); + if ( cronTriggerBean == null ) { return; } - JobDetailBean jobDetailBean = createJobDetailBean(jobSchedulerConfiguration); - if (jobDetailBean == null) { + JobDetailFactoryBean jobDetailBean = createJobDetailBean(jobSchedulerConfiguration); + if ( jobDetailBean == null ) { return; } + deleteJob(jobSchedulerConfiguration); - this.scheduler.scheduleJob(jobDetailBean, cronTriggerBean); + this.scheduler.scheduleJob(jobDetailBean.getObject(), cronTriggerBean.getObject()); } /** - * Creates {@link CronTriggerBean} from the specified + * Creates {@link CronTriggerFactoryBean} from the specified * {@link JobSchedulerConfiguration} * * @param jobSchedulerConfiguration - * configuration to create CronTriggerBean - * @return the created CronTriggerBean or null if unable to + * configuration to create CronTriggerFactoryBean + * @return the created CronTriggerFactoryBean or null if unable to * create it */ - private CronTriggerBean createCronTriggerBean( - JobSchedulerConfiguration jobSchedulerConfiguration) { - CronTriggerBean cronTriggerBean = new CronTriggerBean(); + private CronTriggerFactoryBean createCronTriggerBean(JobSchedulerConfiguration jobSchedulerConfiguration) { + CronTriggerFactoryBean cronTriggerBean = new CronTriggerFactoryBean(); cronTriggerBean.setName(jobSchedulerConfiguration.getJobName() + TRIGGER_SUFFIX); - cronTriggerBean.setGroup(jobSchedulerConfiguration.getJobGroup() - + TRIGGER_SUFFIX); + cronTriggerBean.setGroup(jobSchedulerConfiguration.getJobGroup() + TRIGGER_SUFFIX); try { - cronTriggerBean.setCronExpression(new CronExpression( - jobSchedulerConfiguration.getCronExpression())); - cronTriggerBean.setJobName(jobSchedulerConfiguration.getJobName()); - cronTriggerBean - .setJobGroup(jobSchedulerConfiguration.getJobGroup()); + cronTriggerBean.setCronExpression( + String.valueOf(new CronExpression(jobSchedulerConfiguration.getCronExpression()))); + + cronTriggerBean.setName(jobSchedulerConfiguration.getJobName()); + cronTriggerBean.setGroup(jobSchedulerConfiguration.getJobGroup()); + return cronTriggerBean; + } catch (ParseException e) { LOG.error("Unable to parse cron expression", e); } + return null; } /** - * Creates {@link JobDetailBean} from the specified + * Creates {@link JobDetailFactoryBean} from the specified * {@link JobSchedulerConfiguration} * * @param jobSchedulerConfiguration - * configuration to create JobDetailBean - * @return the created JobDetailBean or null if unable to it + * configuration to create JobDetailFactoryBean + * @return the created JobDetailFactoryBean or null if unable to it */ - private JobDetailBean createJobDetailBean( - JobSchedulerConfiguration jobSchedulerConfiguration) { - JobDetailBean jobDetailBean = new JobDetailBean(); + private JobDetailFactoryBean createJobDetailBean(JobSchedulerConfiguration jobSchedulerConfiguration) { + JobDetailFactoryBean jobDetailBean = new JobDetailFactoryBean(); - Class jobClass = getJobClass(jobSchedulerConfiguration - .getJobClassName()); - if (jobClass == null) { + Class jobClass = getJobClass(jobSchedulerConfiguration.getJobClassName()); + if ( jobClass == null ) { return null; } @@ -272,9 +270,10 @@ public class SchedulerManager implements ISchedulerManager { jobDetailBean.setGroup(jobSchedulerConfiguration.getJobGroup()); jobDetailBean.setJobClass(jobClass); - Map jobDataAsMap = new HashMap(); + Map jobDataAsMap = new HashMap<>(); jobDataAsMap.put("applicationContext", applicationContext); jobDetailBean.setJobDataAsMap(jobDataAsMap); + return jobDetailBean; } @@ -287,49 +286,48 @@ public class SchedulerManager implements ISchedulerManager { */ private Class getJobClass(JobClassNameEnum jobClassName) { try { - return Class.forName(jobClassName.getPackageName() + "." - + jobClassName.getName()); + return Class.forName(jobClassName.getPackageName() + "." + jobClassName.getName()); } catch (ClassNotFoundException e) { LOG.error("Unable to get class object '" + jobClassName + "'", e); } + return null; } @Override - public String getNextFireTime( - JobSchedulerConfiguration jobSchedulerConfiguration) { + public String getNextFireTime(JobSchedulerConfiguration jobSchedulerConfiguration) { try { - CronTrigger trigger = (CronTrigger) this.scheduler.getTrigger( - jobSchedulerConfiguration.getJobName() + TRIGGER_SUFFIX, - jobSchedulerConfiguration.getJobGroup() - + TRIGGER_SUFFIX); - if (trigger != null) { + CronTrigger trigger = (CronTrigger) this.scheduler.getTrigger(TriggerKey.triggerKey( + jobSchedulerConfiguration.getJobName() + TRIGGER_SUFFIX, + jobSchedulerConfiguration.getJobGroup() + TRIGGER_SUFFIX)); + + if ( trigger != null ) { return trigger.getNextFireTime().toString(); } } catch (SchedulerException e) { LOG.error("unable to get the trigger", e); } + return ""; } /** - * gets the {@link CronTriggerBean} for the specified + * gets the {@link CronTriggerFactoryBean} for the specified * triggerName and tirggerGroup * * @param triggerName * the trigger name * @param triggerGroup * the trigger group - * @return CronTriggerBean if found, otherwise null + * @return CronTriggerFactoryBean if found, otherwise null */ - private CronTriggerBean getTriggerBean(String triggerName, - String triggerGroup) { + private CronTriggerFactoryBean getTriggerBean(String triggerName, String triggerGroup) { try { - return (CronTriggerBean) this.scheduler.getTrigger(triggerName, - triggerGroup); + return (CronTriggerFactoryBean) this.scheduler.getTrigger(TriggerKey.triggerKey(triggerName, triggerGroup)); } catch (SchedulerException e) { LOG.error("Unable to get job trigger", e); } + return null; } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/IndexController.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/IndexController.java index e3cb43dd1..87d0f6720 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/IndexController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/IndexController.java @@ -48,15 +48,15 @@ public class IndexController extends GenericForwardComposer { } private String getInitialPageURL() { - if (SecurityUtils.isUserInRole(UserRole.ROLE_SUPERUSER)) { + if ( SecurityUtils.isUserInRole(UserRole.ROLE_SUPERUSER) ) { return PLANNING_URL; } - if (SecurityUtils.isUserInRole(UserRole.ROLE_BOUND_USER)) { + if ( SecurityUtils.isUserInRole(UserRole.ROLE_BOUND_USER) ) { return USER_DASHBOARD_URL; } - if (SecurityUtils.isSuperuserOrRolePlanningOrHasAnyAuthorization()) { + if ( SecurityUtils.isSuperuserOrRolePlanningOrHasAnyAuthorization() ) { return PLANNING_URL; } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/LoginController.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/LoginController.java index 9f7de0866..15ffa6d2f 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/LoginController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/LoginController.java @@ -34,12 +34,11 @@ import org.zkoss.zk.ui.util.GenericForwardComposer; * @author Susana Montes Pedreira */ +// TODO resolve deprecated methods @Component @Scope(BeanDefinition.SCOPE_PROTOTYPE) public class LoginController extends GenericForwardComposer { - private final String autocompletLoginValue = "admin"; - @Autowired private IConfigurationDAO configurationDAO; @@ -53,11 +52,13 @@ public class LoginController extends GenericForwardComposer { * It returns the login value in function of the property autocompleteLogin. */ public String getLoginValue() { - Configuration configuration = configurationDAO - .getConfigurationWithReadOnlyTransaction(); - return ((configuration.isAutocompleteLogin()) && (!configuration - .getChangedDefaultAdminPassword())) ? this.autocompletLoginValue - : null; + Configuration configuration = configurationDAO.getConfigurationWithReadOnlyTransaction(); + String autocompleteLoginValue = "admin"; + + boolean condition = + ((configuration.isAutocompleteLogin()) && (!configuration.getChangedDefaultAdminPassword())); + + return condition ? autocompleteLoginValue : null; } } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/error/PageForErrorOnEvent.java b/libreplan-webapp/src/main/java/org/libreplan/web/error/PageForErrorOnEvent.java index fff8f0dff..1ba2fdc24 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/error/PageForErrorOnEvent.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/error/PageForErrorOnEvent.java @@ -48,26 +48,24 @@ public class PageForErrorOnEvent extends GenericForwardComposer { super.doAfterCompose(comp); logError(); modalWindow = comp; - if (stacktrace != null) { + if ( stacktrace != null ) { stacktrace.setValue(getStacktrace()); } } private void logError() { - Throwable exception = (Throwable) Executions.getCurrent().getAttribute( - "javax.servlet.error.exception"); - String errorMessage = (String) Executions.getCurrent().getAttribute( - "javax.servlet.error.message"); - Integer code = (Integer) Executions.getCurrent().getAttribute( - "javax.servlet.error.status_code"); - if (code != null) { + Throwable exception = (Throwable) Executions.getCurrent().getAttribute("javax.servlet.error.exception"); + String errorMessage = (String) Executions.getCurrent().getAttribute("javax.servlet.error.message"); + Integer code = (Integer) Executions.getCurrent().getAttribute("javax.servlet.error.status_code"); + + if ( code != null ) { errorMessage += " [Status Code: " + code + "]"; - if (code == HttpServletResponse.SC_FORBIDDEN) { - String uri = (String) Executions.getCurrent().getAttribute( - "javax.servlet.error.request_uri"); + if ( code == HttpServletResponse.SC_FORBIDDEN ) { + String uri = (String) Executions.getCurrent().getAttribute("javax.servlet.error.request_uri"); errorMessage += " [Request URI: " + uri + "]"; } } + LOG.error(errorMessage, exception); } @@ -80,20 +78,20 @@ public class PageForErrorOnEvent extends GenericForwardComposer { } public void onClick$quitSession() { - HttpServletRequest nativeRequest = (HttpServletRequest) Executions - .getCurrent().getNativeRequest(); + HttpServletRequest nativeRequest = (HttpServletRequest) Executions.getCurrent().getNativeRequest(); nativeRequest.getSession().invalidate(); Executions.sendRedirect("/"); } private String getStacktrace() { - Throwable exception = (Throwable) Executions.getCurrent().getAttribute( - "javax.servlet.error.exception"); + Throwable exception = (Throwable) Executions.getCurrent().getAttribute("javax.servlet.error.exception"); if (exception != null) { Writer stacktrace = new StringWriter(); exception.printStackTrace(new PrintWriter(stacktrace)); + return stacktrace.toString(); } + return ""; } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/MultipleTabsPlannerController.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/MultipleTabsPlannerController.java index cf628ce76..ca0c579fb 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/MultipleTabsPlannerController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/MultipleTabsPlannerController.java @@ -261,37 +261,32 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry @Override public void typeChanged(ModeType oldType, ModeType newType) { switch (newType) { + case GLOBAL: + ConfirmCloseUtil.resetConfirmClose(); + break; - case GLOBAL: - ConfirmCloseUtil.resetConfirmClose(); - break; + case ORDER: + if ( SecurityUtils.loggedUserCanWrite(mode.getOrder()) ) { + ConfirmCloseUtil.setConfirmClose( + desktop, + _("You are about to leave the planning editing. Unsaved changes will be lost!")); + } + break; - case ORDER: - if ( SecurityUtils.loggedUserCanWrite(mode.getOrder()) ) { - ConfirmCloseUtil.setConfirmClose( - desktop, - _("You are about to leave the planning editing. Unsaved changes will be lost!")); - } - break; - - default: - break; + default: + break; } } }); - planningTab = doFeedbackOn(PlanningTabCreator.create(mode, - companyPlanningController, orderPlanningController, orderDAO, - breadcrumbs, parameters, this)); - - resourceLoadTab = ResourcesLoadTabCreator.create(mode, - resourceLoadController, - resourceLoadControllerGlobal, new IOrderPlanningGate() { + planningTab = doFeedbackOn(PlanningTabCreator.create( + mode, companyPlanningController, orderPlanningController, orderDAO, breadcrumbs, parameters, this)); + resourceLoadTab = ResourcesLoadTabCreator.create( + mode, resourceLoadController, resourceLoadControllerGlobal, new IOrderPlanningGate() { @Override public void goToScheduleOf(Order order) { - getTabsRegistry() - .show(planningTab, changeModeTo(order)); + getTabsRegistry().show(planningTab, changeModeTo(order)); } @Override @@ -300,62 +295,28 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry } @Override - public void goToTaskResourceAllocation(Order order, - TaskElement task) { + public void goToTaskResourceAllocation(Order order, TaskElement task) { orderPlanningController.setShowedTask(task); - orderPlanningController.setCurrentControllerToShow(orderPlanningController.getEditTaskController()); - getTabsRegistry() - .show(planningTab, changeModeTo(order)); + + orderPlanningController + .setCurrentControllerToShow(orderPlanningController.getEditTaskController()); + + getTabsRegistry().show(planningTab, changeModeTo(order)); } @Override public void goToDashboard(Order order) { // do nothing } - }, breadcrumbs); - limitingResourcesTab = LimitingResourcesTabCreator.create(mode, - limitingResourcesController, limitingResourcesControllerGlobal, - breadcrumbs); - - ordersTab = OrdersTabCreator.create(mode, orderCRUDController, - breadcrumbs, new IOrderPlanningGate() { - - @Override - public void goToScheduleOf(Order order) { - getTabsRegistry() - .show(planningTab, changeModeTo(order)); - } - - @Override - public void goToOrderDetails(Order order) { - getTabsRegistry().show(ordersTab, changeModeTo(order)); - } - - @Override - public void goToTaskResourceAllocation(Order order, - TaskElement task) { - // do nothing - } - - @Override - public void goToDashboard(Order order) { - // do nothing - } - - }, parameters); - - dashboardTab = DashboardTabCreator.create(mode, planningStateCreator, - dashboardController, dashboardControllerGlobal, orderPlanningController, breadcrumbs, - resourcesSearcher); - - logsTab = LogsTabCreator.create(mode, logsController, logsControllerGlobal, breadcrumbs, new IOrderPlanningGate() { + limitingResourcesTab = LimitingResourcesTabCreator.create( + mode, limitingResourcesController, limitingResourcesControllerGlobal, breadcrumbs); + ordersTab = OrdersTabCreator.create(mode, orderCRUDController, breadcrumbs, new IOrderPlanningGate() { @Override public void goToScheduleOf(Order order) { - getTabsRegistry() - .show(planningTab, changeModeTo(order)); + getTabsRegistry().show(planningTab, changeModeTo(order)); } @Override @@ -364,8 +325,7 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry } @Override - public void goToTaskResourceAllocation(Order order, - TaskElement task) { + public void goToTaskResourceAllocation(Order order, TaskElement task) { // do nothing } @@ -373,37 +333,72 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry public void goToDashboard(Order order) { // do nothing } - }, parameters); + dashboardTab = DashboardTabCreator.create( + mode, + planningStateCreator, + dashboardController, + dashboardControllerGlobal, + orderPlanningController, + breadcrumbs, + resourcesSearcher); + + logsTab = LogsTabCreator.create( + mode, logsController, logsControllerGlobal, breadcrumbs, new IOrderPlanningGate() { + @Override + public void goToScheduleOf(Order order) { + getTabsRegistry().show(planningTab, changeModeTo(order)); + } + + @Override + public void goToOrderDetails(Order order) { + getTabsRegistry().show(ordersTab, changeModeTo(order)); + } + + @Override + public void goToTaskResourceAllocation(Order order, TaskElement task) { + // do nothing + } + + @Override + public void goToDashboard(Order order) { + // do nothing + } + }, parameters); + final boolean isMontecarloVisible = isMonteCarloVisible(); - if (isMontecarloVisible) { - monteCarloTab = MonteCarloTabCreator.create(mode, - planningStateCreator, monteCarloController, - orderPlanningController, breadcrumbs, + if ( isMontecarloVisible ) { + monteCarloTab = MonteCarloTabCreator.create( + mode, + planningStateCreator, + monteCarloController, + orderPlanningController, + breadcrumbs, resourcesSearcher); } final State typeChanged = typeChangedState(); - advancedAllocationTab = doFeedbackOn(AdvancedAllocationTabCreator - .create(mode, transactionService, planningStateCreator, - returnToPlanningTab(), breadcrumbs)); + + advancedAllocationTab = doFeedbackOn(AdvancedAllocationTabCreator.create( + mode, transactionService, planningStateCreator, returnToPlanningTab(), breadcrumbs)); TabsConfiguration tabsConfiguration = TabsConfiguration.create() .add(tabWithNameReloading(planningTab, typeChanged)) .add(tabWithNameReloading(ordersTab, typeChanged)); - if (SecurityUtils.isSuperuserOrUserInRoles(UserRole.ROLE_PLANNING)) { - tabsConfiguration.add( - tabWithNameReloading(resourceLoadTab, typeChanged)).add( - tabWithNameReloading(limitingResourcesTab, typeChanged)); - } else { - tabsConfiguration.add(visibleOnlyAtOrderModeWithNameReloading( - resourceLoadTab, typeChanged)); - } - tabsConfiguration.add(visibleOnlyAtOrderMode(advancedAllocationTab)) - .add(tabWithNameReloading(dashboardTab, typeChanged)); - if (isMontecarloVisible) { + if ( SecurityUtils.isSuperuserOrUserInRoles(UserRole.ROLE_PLANNING) ) { + tabsConfiguration + .add(tabWithNameReloading(resourceLoadTab, typeChanged)) + .add(tabWithNameReloading(limitingResourcesTab, typeChanged)); + } else { + tabsConfiguration.add(visibleOnlyAtOrderModeWithNameReloading(resourceLoadTab, typeChanged)); + } + tabsConfiguration + .add(visibleOnlyAtOrderMode(advancedAllocationTab)) + .add(tabWithNameReloading(dashboardTab, typeChanged)); + + if ( isMontecarloVisible ) { tabsConfiguration.add(visibleOnlyAtOrderMode(monteCarloTab)); } @@ -414,7 +409,7 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry private boolean isMonteCarloVisible() { Boolean result = configurationDAO.getConfiguration().isMonteCarloMethodTabVisible(); - return result != null ? result.booleanValue() : false; + return result != null ? result : false; } @SuppressWarnings("unchecked") @@ -458,8 +453,7 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry }; } - private ChangeableTab tabWithNameReloading(ITab tab, - final State typeChanged) { + private ChangeableTab tabWithNameReloading(ITab tab, final State typeChanged) { return configure(tab).reloadNameOn(typeChanged); } @@ -472,6 +466,7 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry typeChanged.changeValueTo(null); } }); + return typeChanged; } @@ -479,11 +474,11 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry return visibleOnlyAtOrderModeWithNameReloading(tab, null); } - private ChangeableTab visibleOnlyAtOrderModeWithNameReloading(ITab tab, - final State typeChanged) { + private ChangeableTab visibleOnlyAtOrderModeWithNameReloading(ITab tab, final State typeChanged) { final State state = State.create(mode.isOf(ModeType.ORDER)); ChangeableTab result; - if (typeChanged == null) { + + if ( typeChanged == null ) { result = configure(tab).visibleOn(state); } else { result = configure(tab).visibleOn(state).reloadNameOn(typeChanged); @@ -495,6 +490,7 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry state.changeValueTo(ModeType.ORDER == newType); } }); + return result; } @@ -503,29 +499,29 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry public void doAfterCompose(org.zkoss.zk.ui.Component comp) { Execution execution = Executions.getCurrent(); - WELCOME_URL = "http://" + execution.getServerName() + ":" + execution.getServerPort() + Executions.encodeURL("/planner/index.zul"); + WELCOME_URL = "http://" + execution.getServerName() + ":" + execution.getServerPort() + + Executions.encodeURL("/planner/index.zul"); tabsSwitcher = (TabSwitcher) comp; breadcrumbs = comp.getPage().getFellow("breadcrumbs"); - tabsSwitcher - .setConfiguration(buildTabsConfiguration(comp.getDesktop())); - final EntryPointsHandler handler = registry - .getRedirectorFor(IGlobalViewEntryPoints.class); - if (!handler.applyIfMatches(this)) { + tabsSwitcher.setConfiguration(buildTabsConfiguration(comp.getDesktop())); + + final EntryPointsHandler handler = + registry.getRedirectorFor(IGlobalViewEntryPoints.class); + + if ( !handler.applyIfMatches(this) ) { planningTab.toggleToNoFeedback(); goToCompanyScheduling(); planningTab.toggleToFeedback(); } + handler.registerBookmarkListener(this, comp.getPage()); - if (SecurityUtils - .isSuperuserOrUserInRoles(UserRole.ROLE_CREATE_PROJECTS)) { - org.zkoss.zk.ui.Component createOrderButton = comp.getPage() - .getFellowIfAny( - "createOrderButton"); - if (createOrderButton != null) { - createOrderButton.addEventListener(Events.ON_CLICK, - new EventListener() { + if ( SecurityUtils.isSuperuserOrUserInRoles(UserRole.ROLE_CREATE_PROJECTS) ) { + org.zkoss.zk.ui.Component createOrderButton = comp.getPage().getFellowIfAny("createOrderButton"); + + if ( createOrderButton != null ) { + createOrderButton.addEventListener(Events.ON_CLICK, new EventListener() { @Override public void onEvent(Event event) throws Exception { goToCreateForm(); @@ -544,8 +540,15 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry private void sendDataToServer(){ GatheredUsageStats gatheredUsageStats = new GatheredUsageStats(); - gatheredUsageStats.setupNotAutowiredClasses(userDAO, orderModel, workReportModel, workerModel, machineModel, - expenseSheetModel, materialsModel, assignedQualityFormsModel); + gatheredUsageStats.setupNotAutowiredClasses( + userDAO, + orderModel, + workReportModel, + workerModel, + machineModel, + expenseSheetModel, + materialsModel, + assignedQualityFormsModel); gatheredUsageStats.sendGatheredUsageStatsToServer(); SecurityUtils.isGatheredStatsAlreadySent = true; @@ -578,8 +581,7 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry public void goToCreateForm() { orderCRUDController.prepareForCreate(tabsSwitcher.getDesktop()); - orderCRUDController.getCreationPopup().showWindow(orderCRUDController, - this); + orderCRUDController.getCreationPopup().showWindow(orderCRUDController, this); } @@ -625,14 +627,15 @@ public class MultipleTabsPlannerController implements Composer, IGlobalViewEntry @Override public void goToAdvanceTask(Order order,TaskElement task) { orderPlanningController.setShowedTask(task); + orderPlanningController - .setCurrentControllerToShow(orderPlanningController - .getAdvanceAssignmentPlanningController()); + .setCurrentControllerToShow(orderPlanningController.getAdvanceAssignmentPlanningController()); + getTabsRegistry().show(planningTab, changeModeTo(order)); } private IBeforeShowAction changeModeTo(final Order order) { - logsController.goToOrderMode(order); + LogsController.goToOrderMode(order); return new IBeforeShowAction() { @Override public void doAction() { diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/print/CutyPrint.java b/libreplan-webapp/src/main/java/org/libreplan/web/print/CutyPrint.java index 1a0ea85d3..310cf4064 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/print/CutyPrint.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/print/CutyPrint.java @@ -59,13 +59,10 @@ public class CutyPrint { private static final Log LOG = LogFactory.getLog(CutyPrint.class); private static final String CUTYCAPT_COMMAND = "cutycapt"; + // Estimated maximum execution time (ms) - private static final int CAPTURE_DELAY = 10000; - // Taskdetails left padding - private static int TASKDETAILS_BASE_WIDTH = 310; - /** * Default width in pixels of the task name text field for depth level 1. *

    @@ -75,59 +72,49 @@ public class CutyPrint { private static final int BASE_TASK_NAME_PIXELS = 121; private static int TASK_HEIGHT = 25; - private static int PRINT_VERTICAL_PADDING = 50; - - private static int PRINT_VERTICAL_SPACING = 160; public static void print(Order order) { - print("/planner/index.zul", entryPointForShowingOrder(order), - Collections. emptyMap()); + print("/planner/index.zul", entryPointForShowingOrder(order), Collections. emptyMap()); } public static void print(Order order, Map parameters) { - print("/planner/index.zul", entryPointForShowingOrder(order), - parameters); + print("/planner/index.zul", entryPointForShowingOrder(order), parameters); } - public static void print(Order order, HashMap parameters, - Planner planner) { - print("/planner/index.zul", entryPointForShowingOrder(order), - parameters, planner); + public static void print(Order order, HashMap parameters, Planner planner) { + print("/planner/index.zul", entryPointForShowingOrder(order), parameters, planner); } public static void print() { - print("/planner/index.zul", Collections. emptyMap(), - Collections. emptyMap()); + print("/planner/index.zul", Collections. emptyMap(), Collections. emptyMap()); } public static void print(Map parameters) { - print("/planner/index.zul", Collections. emptyMap(), - parameters); + print("/planner/index.zul", Collections. emptyMap(), parameters); } public static void print(HashMap parameters, Planner planner) { - print("/planner/index.zul", Collections. emptyMap(), - parameters, planner); + print("/planner/index.zul", Collections. emptyMap(), parameters, planner); } private static Map entryPointForShowingOrder(Order order) { - final Map result = new HashMap(); + final Map result = new HashMap<>(); result.put("order", order.getCode() + ""); + return result; } - public static void print(final String forwardURL, - final Map entryPointsMap, - Map parameters) { + public static void print( + final String forwardURL, final Map entryPointsMap, Map parameters) { print(forwardURL, entryPointsMap, parameters, null); } public static void print(final String forwardURL, - final Map entryPointsMap, - Map parameters, Planner planner) { + final Map entryPointsMap, + Map parameters, + Planner planner) { - CutyCaptParameters params = new CutyCaptParameters(forwardURL, - entryPointsMap, parameters, planner); + CutyCaptParameters params = new CutyCaptParameters(forwardURL, entryPointsMap, parameters, planner); String generatedSnapshotServerPath = takeSnapshot(params); openInAnotherTab(generatedSnapshotServerPath); @@ -141,10 +128,8 @@ public class CutyPrint { private static final AtomicLong counter = new AtomicLong(); - private final HttpServletRequest request = (HttpServletRequest) Executions - .getCurrent().getNativeRequest(); - private final ServletContext context = request.getSession() - .getServletContext(); + private final HttpServletRequest request = (HttpServletRequest) Executions.getCurrent().getNativeRequest(); + private final ServletContext context = request.getSession().getServletContext(); private final String forwardURL; private final Map entryPointsMap; @@ -159,21 +144,21 @@ public class CutyPrint { private final int recentUniqueToken = (int) (counter.getAndIncrement() % 1000); public CutyCaptParameters(final String forwardURL, - final Map entryPointsMap, - Map printParameters, Planner planner) { + final Map entryPointsMap, + Map printParameters, + Planner planner) { + this.forwardURL = forwardURL; - this.entryPointsMap = entryPointsMap != null ? entryPointsMap - : Collections. emptyMap(); - this.printParameters = printParameters != null ? printParameters - : Collections. emptyMap(); + this.entryPointsMap = (entryPointsMap != null) ? entryPointsMap : Collections. emptyMap(); + + this.printParameters = + (printParameters != null) ? printParameters : Collections. emptyMap(); + this.planner = planner; - containersExpandedByDefault = Planner - .guessContainersExpandedByDefaultGivenPrintParameters(printParameters); - minWidthForTaskNameColumn = planner - .calculateMinimumWidthForTaskNameColumn(containersExpandedByDefault); - generatedSnapshotServerPath = buildCaptureDestination(printParameters - .get("extension")); + containersExpandedByDefault = Planner.guessContainersExpandedByDefaultGivenPrintParameters(printParameters); + minWidthForTaskNameColumn = planner.calculateMinimumWidthForTaskNameColumn(containersExpandedByDefault); + generatedSnapshotServerPath = buildCaptureDestination(printParameters.get("extension")); } String getGeneratedSnapshotServerPath() { @@ -181,36 +166,33 @@ public class CutyPrint { } private String buildCaptureDestination(String extension) { - if (StringUtils.isEmpty(extension)) { + if ( StringUtils.isEmpty(extension) ) { extension = ".pdf"; } - return String.format("/print/%tY% parameters = buildParameters(); for (Entry each : parameters.entrySet()) { - c.command() - .add(String.format("--%s=%s", each.getKey(), - each.getValue())); + c.command().add(String.format("--%s=%s", each.getKey(), each.getValue())); } } private Map buildParameters() { - Map result = new HashMap(); + Map result = new HashMap<>(); result.put("url", buildSnapshotURLParam()); @@ -221,8 +203,8 @@ public class CutyPrint { result.put("delay", CAPTURE_DELAY + ""); result.put("user-style-path", buildCustomCSSParam(width)); result.put("out", buildPathToOutputFileParam()); - result.put("header", String.format("Accept-Language:%s", Locales - .getCurrent().getLanguage())); + result.put("header", String.format("Accept-Language:%s", Locales.getCurrent().getLanguage())); + return result; } @@ -230,39 +212,37 @@ public class CutyPrint { IServletRequestHandler snapshotRequestHandler = executeOnOriginalContext(new IServletRequestHandler() { @Override - public void handle(HttpServletRequest request, - HttpServletResponse response) throws ServletException, - IOException { + public void handle( + HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - EntryPointsHandler.setupEntryPointsForThisRequest(request, - entryPointsMap); + EntryPointsHandler.setupEntryPointsForThisRequest(request, entryPointsMap); // Pending to forward and process additional parameters // as show labels, resources, zoom or expand all - request.getRequestDispatcher(forwardURL).forward(request, - response); + request.getRequestDispatcher(forwardURL).forward(request, response); } }); - String pageToSnapshot = CallbackServlet.registerAndCreateURLFor( - request, snapshotRequestHandler); + + String pageToSnapshot = CallbackServlet.registerAndCreateURLFor(request, snapshotRequestHandler); + return createCaptureURL(pageToSnapshot); } private String createCaptureURL(String capturePath) { String hostName = resolveLocalHost(); - String uri = String.format("%s://%s:%s", request.getScheme(), - hostName, request.getLocalPort()); + String uri = String.format("%s://%s:%s", request.getScheme(), hostName, request.getLocalPort()); UriBuilder result = UriBuilder.fromUri(uri).path(capturePath); for (Entry entry : printParameters.entrySet()) { result = result.queryParam(entry.getKey(), entry.getValue()); } + return result.build().toASCIIString(); } private String resolveLocalHost() { try { - InetAddress host = InetAddress - .getByName(request.getLocalName()); + InetAddress host = InetAddress.getByName(request.getLocalName()); + return host.getHostName(); } catch (UnknownHostException e) { throw new RuntimeException(e); @@ -270,46 +250,43 @@ public class CutyPrint { } private int buildMinWidthParam() { - if (planner != null && planner.getTimeTracker() != null) { - return planner.getTimeTracker().getHorizontalSize() - + calculateTaskDetailsWidth(); + if ( planner != null && planner.getTimeTracker() != null ) { + return planner.getTimeTracker().getHorizontalSize() + calculateTaskDetailsWidth(); } + return 0; } private int calculateTaskDetailsWidth() { - return TASKDETAILS_BASE_WIDTH - + Math.max(0, minWidthForTaskNameColumn - - BASE_TASK_NAME_PIXELS); + int TASKDETAILS_BASE_WIDTH = 310; + return TASKDETAILS_BASE_WIDTH + Math.max(0, minWidthForTaskNameColumn - BASE_TASK_NAME_PIXELS); } private int buildMinHeightParam() { - return (containersExpandedByDefault ? planner.getAllTasksNumber() - : planner.getTaskNumber()) - * TASK_HEIGHT - + PRINT_VERTICAL_SPACING; + int PRINT_VERTICAL_SPACING = 160; + return (containersExpandedByDefault ? planner.getAllTasksNumber() : + planner.getTaskNumber()) * TASK_HEIGHT + PRINT_VERTICAL_SPACING; } private String buildCustomCSSParam(int plannerWidth) { // Calculate application path and destination file relative route String absolutePath = context.getRealPath("/"); cssLinesToAppend(plannerWidth); - return createCSSFile(absolutePath + "/planner/css/print.css", - cssLinesToAppend(plannerWidth)); + + return createCSSFile(absolutePath + "/planner/css/print.css", cssLinesToAppend(plannerWidth)); } - private static String createCSSFile(String sourceFile, - String cssLinesToAppend) { + private static String createCSSFile(String sourceFile, String cssLinesToAppend) { File destination; try { destination = File.createTempFile("print", ".css"); FileUtils.copyFile(new File(sourceFile), destination); } catch (IOException e) { - LOG.error( - "Can't create a temporal file for storing the CSS files", - e); + LOG.error("Can't create a temporal file for storing the CSS files", e); + return sourceFile; } + FileWriter appendToFile = null; try { appendToFile = new FileWriter(destination, true); @@ -320,54 +297,53 @@ public class CutyPrint { LOG.error("Can't append to the created file " + destination, e); } finally { try { - if (appendToFile != null) { + if ( appendToFile != null ) { appendToFile.close(); } } catch (IOException e) { LOG.warn("error closing fileWriter", e); } } + return destination.getAbsolutePath(); } private String cssLinesToAppend(int width) { String includeCSSLines = " body { width: " + width + "px; } \n"; - if ("all".equals(printParameters.get("labels"))) { + if ( "all".equals(printParameters.get("labels")) ) { includeCSSLines += " .task-labels { display: inline !important;} \n "; } - if ("all".equals(printParameters.get("resources"))) { + + if ( "all".equals(printParameters.get("resources")) ) { includeCSSLines += " .task-resources { display: inline !important;} \n"; } includeCSSLines += heightCSS(); includeCSSLines += widthForTaskNamesColumnCSS(); + return includeCSSLines; } private String heightCSS() { - int tasksNumber = containersExpandedByDefault ? planner - .getAllTasksNumber() : planner - .getTaskNumber(); + int tasksNumber = containersExpandedByDefault ? planner.getAllTasksNumber() : planner.getTaskNumber(); + int PRINT_VERTICAL_PADDING = 50; int height = (tasksNumber * TASK_HEIGHT) + PRINT_VERTICAL_PADDING; String heightCSS = ""; - heightCSS += " body div#scroll_container { height: " + height - + "px !important;} \n"; /* 1110 */ - heightCSS += " body div#timetracker { height: " + (height + 20) - + "px !important; } \n"; - heightCSS += " body div.plannerlayout { height: " + (height + 80) - + "px !important; } \n"; - heightCSS += " body div.main-layout { height: " + (height + 90) - + "px !important; } \n"; + heightCSS += " body div#scroll_container { height: " + height + "px !important;} \n"; /* 1110 */ + heightCSS += " body div#timetracker { height: " + (height + 20) + "px !important; } \n"; + heightCSS += " body div.plannerlayout { height: " + (height + 80) + "px !important; } \n"; + heightCSS += " body div.main-layout { height: " + (height + 90) + "px !important; } \n"; + return heightCSS; } private String widthForTaskNamesColumnCSS() { String css = "/* ------ Make the area for task names wider ------ */\n"; css += "th.z-tree-col {width: 76px !important;}\n"; - css += "th.tree-text {width: " + (34 + minWidthForTaskNameColumn) - + "px !important;}\n"; + css += "th.tree-text {width: " + (34 + minWidthForTaskNameColumn) + "px !important;}\n"; css += ".taskdetailsContainer, .z-west-body, .z-tree-header, .z-tree-body {"; css += "width: " + (176 + minWidthForTaskNameColumn) + "px !important;}\n"; + return css; } @@ -378,8 +354,8 @@ public class CutyPrint { } /** - * It blocks until the snapshot is ready. It invokes cutycapt program in - * order to take a snapshot from a specified url + * It blocks until the snapshot is ready. + * It invokes cutycapt program in order to take a snapshot from a specified url. * * @return the path in the web application to access via a HTTP GET to the * generated snapshot. @@ -388,8 +364,7 @@ public class CutyPrint { ProcessBuilder capture = new ProcessBuilder(CUTYCAPT_COMMAND); params.fillParameters(capture); - String generatedSnapshotServerPath = params - .getGeneratedSnapshotServerPath(); + String generatedSnapshotServerPath = params.getGeneratedSnapshotServerPath(); Process printProcess = null; Process serverProcess = null; @@ -397,15 +372,15 @@ public class CutyPrint { LOG.info("calling printing: " + capture.command()); // If there is a not real X server environment then use Xvfb - if (StringUtils.isEmpty(System.getenv("DISPLAY"))) { - ProcessBuilder s = new ProcessBuilder("Xvfb", ":" - + params.getXvfbDisplayNumber()); + if ( StringUtils.isEmpty(System.getenv("DISPLAY")) ) { + ProcessBuilder s = new ProcessBuilder("Xvfb", ":" + params.getXvfbDisplayNumber()); serverProcess = s.start(); - capture.environment().put("DISPLAY", - ":" + params.getXvfbDisplayNumber() + ".0"); + capture.environment().put("DISPLAY", ":" + params.getXvfbDisplayNumber() + ".0"); } + printProcess = capture.start(); printProcess.waitFor(); + // once the printProcess finishes, the print snapshot is available return generatedSnapshotServerPath; } catch (InterruptedException e) { @@ -414,10 +389,10 @@ public class CutyPrint { LOG.error("error invoking command", e); throw new RuntimeException(e); } finally { - if (printProcess != null) { + if ( printProcess != null ) { destroy(printProcess); } - if (serverProcess != null) { + if ( serverProcess != null ) { destroy(serverProcess); } } @@ -431,16 +406,15 @@ public class CutyPrint { } } - private static IServletRequestHandler executeOnOriginalContext( - final IServletRequestHandler original) { - final SecurityContext originalContext = SecurityContextHolder - .getContext(); + private static IServletRequestHandler executeOnOriginalContext(final IServletRequestHandler original) { + final SecurityContext originalContext = SecurityContextHolder.getContext(); final Locale current = Locales.getCurrent(); + return new IServletRequestHandler() { @Override - public void handle(HttpServletRequest request, - HttpServletResponse response) throws ServletException, - IOException { + public void handle( + HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + Locales.setThreadLocal(current); SecurityContextHolder.setContext(originalContext); original.handle(request, response); diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/bootstrap/UsersBootstrapInDB.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/bootstrap/UsersBootstrapInDB.java index 7942dfc10..0e8d6632d 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/bootstrap/UsersBootstrapInDB.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/bootstrap/UsersBootstrapInDB.java @@ -36,7 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; /** - * Bootstrapt to create the default {@link User Users}. + * Bootstrap to create the default {@link User Users}. * * @author Fernando Bellas Permuy * @author Manuel Rego Casasnovas @@ -63,11 +63,15 @@ public class UsersBootstrapInDB implements IUsersBootstrapInDB { @Override public void loadRequiredData() { - if (userDAO.list(User.class).isEmpty()) { + if ( userDAO.list(User.class).isEmpty() ) { for (PredefinedUsers u : PredefinedUsers.values()) { - User user = User.create(u.getLoginName(), - getEncodedPassword(u), u.getInitialRoles(), + + User user = User.create( + u.getLoginName(), + getEncodedPassword(u), + u.getInitialRoles(), getProfiles(u.getInitialProfiles())); + user.setDisabled(u.isUserDisabled()); userDAO.save(user); @@ -77,7 +81,7 @@ public class UsersBootstrapInDB implements IUsersBootstrapInDB { } private Set getProfiles(Set initialProfiles) { - Set profiles = new HashSet(); + Set profiles = new HashSet<>(); for (PredefinedProfiles each : initialProfiles) { try { profiles.add(profileDAO.findByProfileName(each.getName())); @@ -85,13 +89,13 @@ public class UsersBootstrapInDB implements IUsersBootstrapInDB { throw new RuntimeException(e); } } + return profiles; } private String getEncodedPassword(PredefinedUsers u) { - return dbPasswordEncoderService.encodePassword(u.getClearPassword(), - u.getLoginName()); + return dbPasswordEncoderService.encodePassword(u.getClearPassword(), u.getLoginName()); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/AuthenticationProviderLoggingDecorator.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/AuthenticationProviderLoggingDecorator.java index 719a39e77..bf0ba4837 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/AuthenticationProviderLoggingDecorator.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/AuthenticationProviderLoggingDecorator.java @@ -27,8 +27,7 @@ import org.springframework.security.core.AuthenticationException; public class AuthenticationProviderLoggingDecorator implements AuthenticationProvider { - private static final Log LOG = LogFactory - .getLog(AuthenticationProviderLoggingDecorator.class); + private static final Log LOG = LogFactory.getLog(AuthenticationProviderLoggingDecorator.class); private AuthenticationProvider decoratedProvider; @@ -41,22 +40,20 @@ public class AuthenticationProviderLoggingDecorator implements AuthenticationPro } @Override - public Authentication authenticate(Authentication authentication) - throws AuthenticationException { - Object principal = authentication != null ? authentication - .getPrincipal() : null; + public Authentication authenticate(Authentication authentication) throws AuthenticationException { + Object principal = authentication != null ? authentication.getPrincipal() : null; LOG.info("trying to authenticate " + principal); + try { - Authentication result = decoratedProvider - .authenticate(authentication); - if (result != null) { - LOG.info("successful authentication for: " + principal - + " with provider: " + decoratedProvider); + Authentication result = decoratedProvider.authenticate(authentication); + if ( result != null ) { + LOG.info("successful authentication for: " + principal + " with provider: " + decoratedProvider); } + return result; + } catch (AuthenticationException e) { - LOG.info("unsuccessful authentication of " + principal - + " with provider: " + decoratedProvider); + LOG.info("unsuccessful authentication of " + principal + " with provider: " + decoratedProvider); throw e; } } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/DBPasswordEncoderService.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/DBPasswordEncoderService.java index 07a192498..c16831474 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/DBPasswordEncoderService.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/DBPasswordEncoderService.java @@ -30,15 +30,17 @@ import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; /** - * For maximum flexibility, the implementation uses the password encoder and - * the salt source configured in the Spring Security configuration file (in - * consequence, it is possible to change the configuration to use any password - * encoder and/or salt source without modifying the implementation of this - * service). The only restriction the implementation imposes is that when using - * a reflection-based salt source, the "username" property must be specified. + * For maximum flexibility, the implementation uses the password encoder and the salt source + * configured in the Spring Security configuration file + * (in consequence, it is possible to change the configuration to use any password encoder and/or salt source + * without modifying the implementation of this service). + * + * The only restriction the implementation imposes is that + * when using a reflection-based salt source, the "username" property must be specified. * * @author Fernando Bellas Permuy */ +// TODO resolve deprecated public class DBPasswordEncoderService implements IDBPasswordEncoderService { private SaltSource saltSource; @@ -67,12 +69,12 @@ public class DBPasswordEncoderService implements IDBPasswordEncoderService { * "ReflectionSaltSource". Note that "SystemWideSaltSource" ignores * the "user" passed as a parameter to "saltSource.getSalt". */ - UserDetails userDetails = new User(loginName, clearPassword, true, - true, true, true, Collections.emptyList()); + UserDetails userDetails = + new User(loginName, clearPassword, true, true, true, true, Collections.emptyList()); Object salt = null; - if (saltSource != null) { + if ( saltSource != null ) { salt = saltSource.getSalt(userDetails); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/DBUserDetailsService.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/DBUserDetailsService.java index 651848477..759bce66c 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/DBUserDetailsService.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/DBUserDetailsService.java @@ -35,7 +35,7 @@ import org.libreplan.business.users.entities.UserRole; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthorityImpl; +import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; @@ -56,39 +56,36 @@ public class DBUserDetailsService implements UserDetailsService { @Override @Transactional(readOnly=true) - public UserDetails loadUserByUsername(String loginName) - throws UsernameNotFoundException, DataAccessException { + public UserDetails loadUserByUsername(String loginName) throws UsernameNotFoundException, DataAccessException { User user; try { user = userDAO.findByLoginName(loginName); } catch (InstanceNotFoundException e) { - throw new UsernameNotFoundException(MessageFormat.format( - "User with username {0}: not found", loginName)); + throw new UsernameNotFoundException(MessageFormat.format("User with username {0}: not found", loginName)); } Scenario scenario = user.getLastConnectedScenario(); - if (scenario == null) { + if ( scenario == null ) { scenario = PredefinedScenarios.MASTER.getScenario(); } return new CustomUser( - user.getLoginName(), - user.getPassword(), + user.getLoginName(), user.getPassword(), !user.isDisabled(), true, // accountNonExpired true, // credentialsNonExpired true, // accountNonLocked - getGrantedAuthorities(user.getAllRoles()), - scenario); + getGrantedAuthorities(user.getAllRoles()), scenario); } private List getGrantedAuthorities(Set roles) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (UserRole r : roles) { - result.add(new GrantedAuthorityImpl(r.name())); + result.add(new SimpleGrantedAuthority(r.name())); } + return result; } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPCustomAuthenticationProvider.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPCustomAuthenticationProvider.java index 5b61c5c16..5094d19ae 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPCustomAuthenticationProvider.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPCustomAuthenticationProvider.java @@ -58,8 +58,8 @@ import org.springframework.transaction.annotation.Transactional; * An extending from AbstractUserDetailsAuthenticationProvider class which is * used to implement the authentication against LDAP. * - * This provider implements the process explained in + * This provider implements the process explained in + * * * At this time it authenticates user against LDAP and then searches it in BD to * use the BD user in application. @@ -68,9 +68,10 @@ import org.springframework.transaction.annotation.Transactional; * @author Cristina Alvarino Perez * */ -public class LDAPCustomAuthenticationProvider extends - AbstractUserDetailsAuthenticationProvider implements - AuthenticationProvider { + +// TODO resolve deprecated methods +public class LDAPCustomAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider + implements AuthenticationProvider { @Autowired private IAdHocTransactionService transactionService; @@ -94,41 +95,36 @@ public class LDAPCustomAuthenticationProvider extends private static final String USER_ID_SUBSTITUTION = "[USER_ID]"; - private static final Log LOG = LogFactory - .getLog(LDAPCustomAuthenticationProvider.class); + private static final Log LOG = LogFactory.getLog(LDAPCustomAuthenticationProvider.class); /** - * LDAP role matching could be configured using an asterix (*) to specify - * all users or groups + * LDAP role matching could be configured using an asterix (*) + * to specify all users or groups */ private static final String WILDCHAR_ALL = "*"; @Override - protected void additionalAuthenticationChecks(UserDetails arg0, - UsernamePasswordAuthenticationToken arg1) + protected void additionalAuthenticationChecks(UserDetails arg0, UsernamePasswordAuthenticationToken arg1) throws AuthenticationException { // No needed at this time } @Transactional(readOnly = true) @Override - public UserDetails retrieveUser(String username, - UsernamePasswordAuthenticationToken authentication) + public UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { String clearPassword = authentication.getCredentials().toString(); - if (StringUtils.isBlank(username) || StringUtils.isBlank(clearPassword)) { - throw new BadCredentialsException( - "Username and password can not be empty"); + if ( StringUtils.isBlank(username) || StringUtils.isBlank(clearPassword) ) { + throw new BadCredentialsException("Username and password can not be empty"); } - String encodedPassword = passwordEncoderService.encodePassword( - clearPassword, username); + String encodedPassword = passwordEncoderService.encodePassword(clearPassword, username); User user = getUserFromDB(username); // If user != null then exists in LibrePlan - if (null != user && user.isLibrePlanUser()) { + if ( null != user && user.isLibrePlanUser() ) { // is a LibrePlan user, then we must authenticate against DB return authenticateInDatabase(username, user, encodedPassword); } @@ -137,36 +133,39 @@ public class LDAPCustomAuthenticationProvider extends // Load LDAPConfiguration properties configuration = loadLDAPConfiguration(); - if (configuration.getLdapAuthEnabled()) { + if ( configuration.getLdapAuthEnabled() ) { // Sets the new context to ldapTemplate ldapTemplate.setContextSource(loadLDAPContext()); try { + // Test authentication for user against LDAP - if (authenticateAgainstLDAP(username, clearPassword)) { + if ( authenticateAgainstLDAP(username, clearPassword) ) { + // Authentication against LDAP was ok - if (null == user) { + if ( null == user ) { + // User does not exist in LibrePlan must be imported user = createLDAPUserWithRoles(username, encodedPassword); } else { + // Update password - if (configuration.isLdapSavePasswordsDB()) { + if ( configuration.isLdapSavePasswordsDB() ) { user.setPassword(encodedPassword); } + // Update roles from LDAP setRoles(user); } saveUserOnTransaction(user); + return loadUserDetails(username); } else { throw new BadCredentialsException("User is not in LDAP."); } } catch (Exception e) { - // This exception captures when LDAP authentication is not - // possible - LOG.info( - "LDAP not reachable. Trying to authenticate against database.", - e); + // This exception captures when LDAP authentication is not possible + LOG.info("LDAP not reachable. Trying to authenticate against database.", e); } } @@ -179,10 +178,9 @@ public class LDAPCustomAuthenticationProvider extends } private void setRoles(User user) { - if (configuration.getLdapSaveRolesDB()) { + if ( configuration.getLdapSaveRolesDB() ) { user.clearRoles(); - List roles = getMatchedRoles(configuration, ldapTemplate, - user.getLoginName()); + List roles = getMatchedRoles(configuration, user.getLoginName()); for (String role : roles) { user.addRole(UserRole.valueOf(UserRole.class, role)); } @@ -192,58 +190,56 @@ public class LDAPCustomAuthenticationProvider extends private User createLDAPUserWithRoles(String username, String encodedPassword) { User user = User.create(); user.setLoginName(username); - // we must check if it is needed to save LDAP - // passwords in DB - if (!configuration.isLdapSavePasswordsDB()) { + + // we must check if it is needed to save LDAP passwords in DB + if ( !configuration.isLdapSavePasswordsDB() ) { encodedPassword = null; } + user.setPassword(encodedPassword); user.setLibrePlanUser(false); user.setDisabled(false); setRoles(user); + return user; } private LDAPConfiguration loadLDAPConfiguration() { - return transactionService - .runOnReadOnlyTransaction(new IOnTransaction() { - - @Override - public LDAPConfiguration execute() { - return configurationDAO.getConfiguration() - .getLdapConfiguration(); - } - }); + return transactionService.runOnReadOnlyTransaction(new IOnTransaction() { + @Override + public LDAPConfiguration execute() { + return configurationDAO.getConfiguration().getLdapConfiguration(); + } + }); } private User getUserFromDB(String username) { final String usernameInserted = username; - return transactionService - .runOnReadOnlyTransaction(new IOnTransaction() { - @Override - public User execute() { - try { - return userDAO.findByLoginName(usernameInserted); - } catch (InstanceNotFoundException e) { - LOG.info("User " + usernameInserted - + " not found in database."); - return null; - } - } - }); + return transactionService.runOnReadOnlyTransaction(new IOnTransaction() { + @Override + public User execute() { + try { + return userDAO.findByLoginName(usernameInserted); + } catch (InstanceNotFoundException e) { + LOG.info("User " + usernameInserted + " not found in database."); + return null; + } + } + }); } private LDAPCustomContextSource loadLDAPContext() { + // Establishes the context for LDAP connection. - LDAPCustomContextSource context = (LDAPCustomContextSource) ldapTemplate - .getContextSource(); - context.setUrl(configuration.getLdapHost() + COLON - + configuration.getLdapPort()); + LDAPCustomContextSource context = (LDAPCustomContextSource) ldapTemplate.getContextSource(); + + context.setUrl(configuration.getLdapHost() + COLON + configuration.getLdapPort()); context.setBase(configuration.getLdapBase()); context.setUserDn(configuration.getLdapUserDn()); context.setPassword(configuration.getLdapPassword()); + try { context.afterPropertiesSet(); } catch (Exception e) { @@ -251,83 +247,83 @@ public class LDAPCustomAuthenticationProvider extends // properties are well-formed. LOG.error("There is a problem in LDAP connection: ", e); } + return context; } - private boolean authenticateAgainstLDAP(String username, - String clearPassword) { - return ldapTemplate.authenticate(DistinguishedName.EMPTY_PATH, - new EqualsFilter(configuration.getLdapUserId(), username) - .toString(), clearPassword); + private boolean authenticateAgainstLDAP(String username, String clearPassword) { + return ldapTemplate.authenticate( + DistinguishedName.EMPTY_PATH, + new EqualsFilter(configuration.getLdapUserId(), username).toString(), + clearPassword); } private void saveUserOnTransaction(User user) { final User userLibrePlan = user; + transactionService.runOnTransaction(new IOnTransaction() { @Override public Void execute() { userDAO.save(userLibrePlan); + return null; } }); } - private UserDetails authenticateInDatabase(String username, User user, - String encodedPassword) { - if (null != user && null != user.getPassword() - && encodedPassword.equals(user.getPassword())) { + private UserDetails authenticateInDatabase(String username, User user, String encodedPassword) { + if ( null != user && null != user.getPassword() && encodedPassword.equals(user.getPassword()) ) { return loadUserDetails(username); } else { - throw new BadCredentialsException( - "Credentials are not the same as in database."); + throw new BadCredentialsException("Credentials are not the same as in database."); } } @SuppressWarnings("unchecked") private List getRolesUsingNodeStrategy( - Set rolesLdap, String queryRoles, - final LDAPConfiguration configuration) { + Set rolesLdap, String queryRoles, final LDAPConfiguration configuration) { String roleProperty = configuration.getLdapRoleProperty(); - List rolesReturn = new ArrayList(); + List rolesReturn = new ArrayList<>(); for (ConfigurationRolesLDAP roleLDAP : rolesLdap) { - if (roleLDAP.getRoleLdap().equals(WILDCHAR_ALL)) { + if ( roleLDAP.getRoleLdap().equals(WILDCHAR_ALL) ) { rolesReturn.add(roleLDAP.getRoleLibreplan()); continue; } // We must make a search for each role-matching in nodes - List resultsSearch = new ArrayList(); + List resultsSearch = new ArrayList<>(); resultsSearch.addAll(ldapTemplate.search( - DistinguishedName.EMPTY_PATH, new EqualsFilter( - roleProperty, roleLDAP.getRoleLdap()).toString(), + DistinguishedName.EMPTY_PATH, + new EqualsFilter(roleProperty, roleLDAP.getRoleLdap()).toString(), new AttributesMapper() { @Override - public Object mapFromAttributes(Attributes attributes) - throws NamingException { + public Object mapFromAttributes(Attributes attributes) throws NamingException { return attributes.get(configuration.getLdapUserId()); } })); + for (Attribute atrib : resultsSearch) { - if (atrib.contains(queryRoles)) { + if ( atrib.contains(queryRoles) ) { rolesReturn.add(roleLDAP.getRoleLibreplan()); } } } + return rolesReturn; } private List getRolesUsingBranchStrategy( - Set rolesLdap, String queryRoles, - LDAPConfiguration configuration) { + Set rolesLdap, String queryRoles, LDAPConfiguration configuration) { String roleProperty = configuration.getLdapRoleProperty(); String groupsPath = configuration.getLdapGroupPath(); - List rolesReturn = new ArrayList(); + List rolesReturn = new ArrayList<>(); + for (ConfigurationRolesLDAP roleLdap : rolesLdap) { - if (roleLdap.getRoleLdap().equals(WILDCHAR_ALL)) { + if ( roleLdap.getRoleLdap().equals(WILDCHAR_ALL) ) { rolesReturn.add(roleLdap.getRoleLibreplan()); continue; } @@ -335,48 +331,41 @@ public class LDAPCustomAuthenticationProvider extends // We must make a search for each role matching DirContextAdapter adapter = null; try { - adapter = (DirContextAdapter) ldapTemplate - .lookup(roleLdap.getRoleLdap() + "," + groupsPath); + adapter = (DirContextAdapter) ldapTemplate.lookup(roleLdap.getRoleLdap() + "," + groupsPath); } catch (org.springframework.ldap.NamingException ne) { LOG.error(ne.getMessage()); } - if (adapter != null && adapter.attributeExists(roleProperty)) { + if ( adapter != null && adapter.attributeExists(roleProperty) ) { Attributes atrs = adapter.getAttributes(); - if (atrs.get(roleProperty).contains(queryRoles)) { + if ( atrs.get(roleProperty).contains(queryRoles) ) { rolesReturn.add(roleLdap.getRoleLibreplan()); } } } + return rolesReturn; } - private List getMatchedRoles(LDAPConfiguration configuration, - LdapTemplate ldapTemplate, String username) { + private List getMatchedRoles(LDAPConfiguration configuration, String username) { - String queryRoles = configuration.getLdapSearchQuery().replace( - USER_ID_SUBSTITUTION, username); + String queryRoles = configuration.getLdapSearchQuery().replace(USER_ID_SUBSTITUTION, username); - Set rolesLdap = configuration - .getConfigurationRolesLdap(); + Set rolesLdap = configuration.getConfigurationRolesLdap(); try { - - if (!configuration.getLdapGroupStrategy()) { + if ( !configuration.getLdapGroupStrategy() ) { // The LDAP has a node strategy for groups, // we must check the roleProperty in user node. - return getRolesUsingNodeStrategy(rolesLdap, queryRoles, - configuration); + return getRolesUsingNodeStrategy(rolesLdap, queryRoles, configuration); } else { // The LDAP has a branch strategy for groups // we must check if the user is in one of the groups. - return getRolesUsingBranchStrategy(rolesLdap, queryRoles, - configuration); + return getRolesUsingBranchStrategy(rolesLdap, queryRoles, configuration); } } catch (Exception e) { - LOG.error( - "Configuration of LDAP role-matching is wrong. Please check it.", - e); + LOG.error("Configuration of LDAP role-matching is wrong. Please check it.", e); + return Collections.emptyList(); } } @@ -385,8 +374,7 @@ public class LDAPCustomAuthenticationProvider extends return passwordEncoderService; } - public void setPasswordEncoderService( - DBPasswordEncoderService passwordEncoderService) { + public void setPasswordEncoderService(DBPasswordEncoderService passwordEncoderService) { this.passwordEncoderService = passwordEncoderService; } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPUserDetailsService.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPUserDetailsService.java index 63719c38f..627df4687 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPUserDetailsService.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/services/LDAPUserDetailsService.java @@ -32,7 +32,7 @@ import org.libreplan.business.users.entities.UserRole; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.GrantedAuthorityImpl; +import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; @@ -55,38 +55,40 @@ public class LDAPUserDetailsService implements UserDetailsService { @Override @Transactional(readOnly = true) - public UserDetails loadUserByUsername(String loginName) - throws UsernameNotFoundException, DataAccessException { + public UserDetails loadUserByUsername(String loginName) throws UsernameNotFoundException, DataAccessException { User user; try { user = userDAO.findByLoginName(loginName); } catch (InstanceNotFoundException e) { - throw new UsernameNotFoundException(MessageFormat.format( - "User with username {0}: not found", loginName)); + throw new UsernameNotFoundException(MessageFormat.format("User with username {0}: not found", loginName)); } Scenario scenario = user.getLastConnectedScenario(); - if (scenario == null) { + if ( scenario == null ) { scenario = PredefinedScenarios.MASTER.getScenario(); } String password = user.getPassword(); - if (null == password) + if ( null == password ) password = "foo"; - return new CustomUser(user.getLoginName(), password, - !user.isDisabled(), true, // accountNonExpired + + return new CustomUser( + user.getLoginName(), password, + !user.isDisabled(), + true, // accountNonExpired true, // credentialsNonExpired true, // accountNonLocked getGrantedAuthorities(user.getAllRoles()), scenario); } private List getGrantedAuthorities(Set roles) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (UserRole r : roles) { - result.add(new GrantedAuthorityImpl(r.name())); + result.add(new SimpleGrantedAuthority(r.name())); } + return result; } } diff --git a/libreplan-webapp/src/main/resources/i18n/es.po b/libreplan-webapp/src/main/resources/i18n/es.po index 46f9d3706..ceccdb8d9 100644 --- a/libreplan-webapp/src/main/resources/i18n/es.po +++ b/libreplan-webapp/src/main/resources/i18n/es.po @@ -11,7 +11,7 @@ # Lorenzo Tilve Álvaro , 2013. msgid "" msgstr "" -"Project-Id-Version: libreplan-1.4.0\n" +"Project-Id-Version: libreplan-1.6.0\n" "Report-Msgid-Bugs-To: http://bugs.libreplan.org/\n" "POT-Creation-Date: 2013-04-22 12:09+0200\n" "PO-Revision-Date: 2013-04-22 11:52+0000\n" diff --git a/libreplan-webapp/src/main/resources/i18n/fr.po b/libreplan-webapp/src/main/resources/i18n/fr.po index 555eb2c9a..1322bcbcd 100644 --- a/libreplan-webapp/src/main/resources/i18n/fr.po +++ b/libreplan-webapp/src/main/resources/i18n/fr.po @@ -11,7 +11,7 @@ # Philippe Poumaroux , 2012-2013. msgid "" msgstr "" -"Project-Id-Version: libreplan-1.4.0\n" +"Project-Id-Version: libreplan-1.6.0\n" "Report-Msgid-Bugs-To: http://bugs.libreplan.org/\n" "POT-Creation-Date: 2013-04-22 12:09+0200\n" "PO-Revision-Date: 2013-04-28 16:59+0000\n" diff --git a/libreplan-webapp/src/main/resources/i18n/gl.po b/libreplan-webapp/src/main/resources/i18n/gl.po index 46178db1e..8886c1181 100644 --- a/libreplan-webapp/src/main/resources/i18n/gl.po +++ b/libreplan-webapp/src/main/resources/i18n/gl.po @@ -10,7 +10,7 @@ # Lorenzo Tilve Álvaro , 2013. msgid "" msgstr "" -"Project-Id-Version: libreplan-1.4.0\n" +"Project-Id-Version: libreplan-1.6.0\n" "Report-Msgid-Bugs-To: http://bugs.libreplan.org/\n" "POT-Creation-Date: 2013-04-22 12:09+0200\n" "PO-Revision-Date: 2013-04-22 17:54+0000\n" diff --git a/libreplan-webapp/src/main/resources/i18n/it.po b/libreplan-webapp/src/main/resources/i18n/it.po index 8c2b38a34..a60e6f43e 100644 --- a/libreplan-webapp/src/main/resources/i18n/it.po +++ b/libreplan-webapp/src/main/resources/i18n/it.po @@ -8,7 +8,7 @@ # Giuseppe Zizza , 2012. msgid "" msgstr "" -"Project-Id-Version: libreplan-1.4.0\n" +"Project-Id-Version: libreplan-1.4\6.0\n" "Report-Msgid-Bugs-To: http://bugs.libreplan.org/\n" "POT-Creation-Date: 2013-04-22 12:09+0200\n" "PO-Revision-Date: 2013-04-22 14:14+0000\n" diff --git a/libreplan-webapp/src/main/resources/i18n/keys.pot b/libreplan-webapp/src/main/resources/i18n/keys.pot index 5c4cfef63..5ff1fbcb8 100644 --- a/libreplan-webapp/src/main/resources/i18n/keys.pot +++ b/libreplan-webapp/src/main/resources/i18n/keys.pot @@ -7,7 +7,7 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: libreplan-1.4.0\n" +"Project-Id-Version: libreplan-1.6.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2013-04-22 12:09+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/libreplan-webapp/src/main/resources/i18n/nl.po b/libreplan-webapp/src/main/resources/i18n/nl.po index e2c0da5b5..a672aa1cc 100644 --- a/libreplan-webapp/src/main/resources/i18n/nl.po +++ b/libreplan-webapp/src/main/resources/i18n/nl.po @@ -8,7 +8,7 @@ # Jeroen Baten , 2012-2013. msgid "" msgstr "" -"Project-Id-Version: libreplan-1.4.0\n" +"Project-Id-Version: libreplan-1.6.0\n" "Report-Msgid-Bugs-To: http://bugs.libreplan.org/\n" "POT-Creation-Date: 2013-04-22 12:09+0200\n" "PO-Revision-Date: 2013-04-22 11:54+0000\n" diff --git a/libreplan-webapp/src/main/resources/libreplan-webapp-spring-config.xml b/libreplan-webapp/src/main/resources/libreplan-webapp-spring-config.xml index 71eb67791..ea673191b 100644 --- a/libreplan-webapp/src/main/resources/libreplan-webapp-spring-config.xml +++ b/libreplan-webapp/src/main/resources/libreplan-webapp-spring-config.xml @@ -1,61 +1,56 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xmlns:jaxrs="http://cxf.apache.org/jaxrs" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd - + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd + + http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> + + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml b/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml index 5dea568fe..c6b2c597c 100644 --- a/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml +++ b/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml @@ -4,150 +4,144 @@ xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.1.xsd"> - + + + - - - - - - - + + + + + + + - - - - - - - - + + + + + + + + - - - - + + + + + - + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_VIRTUAL_WORKERS')" /> + + + - - - - - - - + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_CALENDAR_EXCEPTION_DAYS')" /> + + + + + + + + + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_TIMESHEETS_TEMPLATES')" /> + - - + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_EXPENSES', 'ROLE_BOUND_USER')" /> + + + + - - - + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_MAIN_SETTINGS')" /> + + + + + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_SEND_TO_SUBCONTRACTORS')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_RECEIVED_FROM_SUBCONTRACTORS')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_SEND_TO_CUSTOMERS')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_RECEIVED_FROM_CUSTOMERS')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_TIMESHEET_LINES_LIST')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_HOURS_WORKED_PER_RESOURCE_REPORT')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_TOTAL_WORKED_HOURS_BY_RESOURCE_IN_A_MONTH_REPORT')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_WORK_AND_PROGRESS_PER_PROJECT_REPORT')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_WORK_AND_PROGRESS_PER_TASK_REPORT')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_ESTIMATED_PLANNED_HOURS_PER_TASK_REPORT')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_PROJECT_COSTS_REPORT')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_TASK_SCHEDULING_STATUS_IN_PROJECT_REPORT')" /> + - + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_MATERIALS_NEED_AT_DATE_REPORT')" /> + + + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_TIMESHEETS', 'ROLE_BOUND_USER')" /> + + access="hasAnyRole('ROLE_SUPERUSER', 'ROLE_IMPORT_PROJECTS')" /> - + - + - + + - + @@ -156,12 +150,11 @@ - - + + @@ -169,10 +162,11 @@ - + @@ -182,10 +176,10 @@ p:contextSource-ref="contextSource"> - + - - - + diff --git a/libreplan-webapp/src/main/resources/metainfo/zk/lang-addon.xml b/libreplan-webapp/src/main/resources/metainfo/zk/lang-addon.xml index ab3849f8f..91cbbf925 100755 --- a/libreplan-webapp/src/main/resources/metainfo/zk/lang-addon.xml +++ b/libreplan-webapp/src/main/resources/metainfo/zk/lang-addon.xml @@ -5,10 +5,9 @@ libreplan-webapp xul/html - - - + + + twowayselector @@ -113,7 +112,6 @@ default mold/queue-list-component.js - @@ -123,14 +121,14 @@ /limitingresources/leftPane.zul + - queuecomponent + queuecomponent org.libreplan.web.limitingresources.QueueComponent limitingresources.QueueComponent default mold/queue-component.js - @@ -148,7 +146,6 @@ default mold/limiting-dependency-list.js - @@ -159,7 +156,6 @@ default mold/limiting-dependency-component.js - diff --git a/libreplan-webapp/src/main/webapp/WEB-INF/web.xml b/libreplan-webapp/src/main/webapp/WEB-INF/web.xml index 5d99d6350..61dfdd2c0 100644 --- a/libreplan-webapp/src/main/webapp/WEB-INF/web.xml +++ b/libreplan-webapp/src/main/webapp/WEB-INF/web.xml @@ -5,11 +5,10 @@ libreplan-webapp contextConfigLocation @@ -21,7 +20,6 @@ - @@ -42,7 +40,6 @@ dspLoader *.dsp - @@ -55,7 +52,6 @@ /* - org.libreplan.web.LoggingConfiguration @@ -75,7 +71,6 @@ org.springframework.web.context.request.RequestContextListener - @@ -87,8 +82,8 @@ zkLoader org.zkoss.zk.ui.http.DHtmlLayoutServlet update-uri @@ -113,7 +108,6 @@ auEngine /zkau/* - diff --git a/libreplan-webapp/src/main/webapp/WEB-INF/zk.xml b/libreplan-webapp/src/main/webapp/WEB-INF/zk.xml index 1ee93b0f9..86ce9bda5 100644 --- a/libreplan-webapp/src/main/webapp/WEB-INF/zk.xml +++ b/libreplan-webapp/src/main/webapp/WEB-INF/zk.xml @@ -1,11 +1,11 @@ - + - - + + 30 diff --git a/libreplan-webapp/src/main/webapp/common/css/libreplan_zk.css b/libreplan-webapp/src/main/webapp/common/css/libreplan_zk.css index bc3a42410..a39e99f0e 100644 --- a/libreplan-webapp/src/main/webapp/common/css/libreplan_zk.css +++ b/libreplan-webapp/src/main/webapp/common/css/libreplan_zk.css @@ -37,7 +37,6 @@ body { .logo { background-image: url("../img/v3/blue_ga.jpg"); - height: 50px; width: 300px; height: 100px; float: left; @@ -51,9 +50,9 @@ body { } table { - margin: 0px; - padding: 0px; - border: 0px; + margin: 0; + padding: 0; + border: 0; } .errorbox { @@ -75,10 +74,9 @@ body .z-window-embedded .icono .z-button-cm, body .z-window-modal .icono .z-button-cm, body .advancedallocationlayout .icono .z-button-cm { color: #007bbe; - background-color: transparent; - background-image: none; - border: 0px solid #007bbe; - padding: 0px; + background: transparent none; + border: 0 solid #007bbe; + padding: 0; } @@ -132,7 +130,7 @@ body .advancedallocationlayout .icono .z-button-cm { .sub_menu .z-button-cm { background-color: transparent !important; - border: 0px; + border: 0; color: #EDF2F7; } @@ -160,15 +158,14 @@ body .advancedallocationlayout .icono .z-button-cm { .global-action.z-button .z-button-cm { padding: 4px 25px !important; - background-position: 5px; - background-repeat: no-repeat; + background: no-repeat 5px; margin-right: 1px; } .global-action.z-button .z-button-cm:active { - margin-right: 0px; - border-bottom: 0px; - border-right: 0px; + margin-right: 0; + border-bottom: 0; + border-right: 0; } .save-button.z-button .z-button-cm { @@ -217,11 +214,11 @@ body .advancedallocationlayout .icono .z-button-cm { /* ------------- order element tree ------------- */ .orderTree input { height: 18px; - border-bottom: 0px; - border-top: 0px; + border-bottom: 0; + border-top: 0; border-left: 1px dotted #7EAAC6; padding-left: 2px; - border-right: 0px; + border-right: 0; } .orderTree .z-datebox-inp { @@ -234,7 +231,7 @@ body .advancedallocationlayout .icono .z-button-cm { } .orderTree td { - padding: 0px !important; + padding: 0 !important; } /* These constants may be reviewed when testing with 3 digit tasknumbers */ @@ -245,7 +242,7 @@ body .advancedallocationlayout .icono .z-button-cm { .orderTree .depth_5 input, .orderTree .depth_6 input { - border-right: 0px; + border-right: 0; } /* Cleaning window borders */ @@ -337,8 +334,7 @@ h4.message_WARNING { .z-window-embedded { - margin: 10px; - margin-top: 5px; + margin: 5px 10px 10px; } .main-area .z-center-body > .z-window-embedded { @@ -348,10 +344,7 @@ h4.message_WARNING { } /* Hide inner second level embed window titles */ -.z-window-embedded -.z-window-embedded -.z-window-embedded -.z-window-embedded-hl { +.z-window-embedded .z-window-embedded .z-window-embedded .z-window-embedded-hl { display: none; } @@ -436,16 +429,13 @@ div.z-row-cnt { .z-window-popup-header,.z-window-highlighted-header, .z-window-overlapped-header,.z-window-embedded-header { - background-color: #FFFFFF; color: #0081C3; font-family: Georgia, Tahoma, Arial, Helvetica, sans-serif; font-size: 18px; padding-bottom: 10px; font-weight: normal; - background-image: url(../img/header_bullet.gif); - background-repeat: no-repeat; padding-left: 22px; - background-position: 0px 3px; + background: #FFFFFF url(../img/header_bullet.gif) no-repeat 0 3px; } .caption-title .z-caption-l { @@ -490,21 +480,21 @@ div.z-footer-cnt,div.z-row-cnt,div.z-group-cnt,div.z-group-foot-cnt,div.z-column .z-tabs .z-tabs-cnt { background: none; - border-bottom: 0px; + border-bottom: 0; border-bottom: 1px solid #7EAAC6; } .z-tabs-scroll { - padding-bottom: 0px; + padding-bottom: 0; background: #F2FBFF none repeat scroll 0 0; - border: 0px solid #000000; + border: 0 solid #000000; } .z-tab .z-tab-text { font-family: Tahoma, Arial, Helvetica, sans-serif; } -.z-tab-seld .z-tab-text { /* color:#0F3B82; */ +.z-tab-seld .z-tab-text { /* color:#0F3B82; */ font-family: Tahoma, Arial, Helvetica, sans-serif; } @@ -617,7 +607,7 @@ div.z-grid { } .orderTree div.z-tree-cell-cnt { - padding:0px; + padding:0; } .orderTree td { @@ -633,8 +623,8 @@ div.z-grid { } .orderelements-tab .z-datebox-focus .z-datebox-inp { - border-top: 0px; - border-bottom: 0px; + border-top: 0; + border-bottom: 0; } .orderelements-tab .z-datebox-focus .z-datebox-inp, @@ -647,8 +637,8 @@ div.z-grid { } .listdetails .z-datebox-focus .z-datebox-inp { - border-top: 0px; - border-bottom: 0px; + border-top: 0; + border-bottom: 0; height: 17px; font-size: 11px !important; font-family: Tahoma, Arial, Helvetica, sans-serif; @@ -721,21 +711,6 @@ div.z-grid { .scheduling-graphics .z-tabs-ver-scroll { border: 0; } -.perspectives-column { - /* border-right: solid 1px; */ -} - -/* Legend colors: - - COLOR_CAPABILITY_LINE = "#000000"; // black - - COLOR_OVERLOAD = "#FF5A11"; // Red - COLOR_OVERLOAD_OTHER = "#FFD4C2"; // Soft red - - COLOR_ASSIGNED_LOAD = "#98D471"; // Green - COLOR_ASSIGNED_OTHER = "#E0F3D3"; // Soft green - -*/ .legend .capability { border-top:solid 2px #000000; @@ -807,14 +782,14 @@ div.z-grid { .z-panel-header { background:none; - border: 0px; - margin:0px 0px 0 10px + border: 0; + margin:0 0 0 10px } .z-panel-body { background:none; border: 1px solid #B1CBD5; - margin:0 10px 0px 10px; + margin:0 10px 0 10px; } .z-panel-children { @@ -931,7 +906,7 @@ span.z-dottree-line { .z-menubar-hor { border-bottom: 3px solid #2a83b4; - padding: 0px; + padding: 0; } .user_row .cerrar_sesion { @@ -939,7 +914,7 @@ span.z-dottree-line { } .migas_linea { - border: 0px; + border: 0; cursor: default; } @@ -958,8 +933,7 @@ span.z-dottree-line { .perspective .z-button-cm, .perspective-active .z-button-cm { padding-top: 60px; - background-position: 18px 10px; - background-repeat: no-repeat; + background: no-repeat 18px 10px; border-radius: 2px; } @@ -1182,18 +1156,18 @@ tr.z-treerow-seld { } tr.z-treerow-seld input { - background-color: #fdf3da; /* Soft orange */ - background-image: none; + /* Soft orange */ + background: #fdf3da none; } tr.z-treerow-over input { - background-color: #eff2f6; /* Soft blue */ - background-image: none; + /* Soft blue */ + background: #eff2f6 none; } tr.z-treerow-over input { - background-color: #eff2f6; /* Soft blue */ - background-image: none; + /* Soft blue */ + background: #eff2f6 none; } .timeplot-canvas { @@ -1248,7 +1222,6 @@ tr.z-treerow-over input { .timeplot-grid-label { font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; - font-size: 10px; z-index: 2; color: transparent; font-size:9px; @@ -1318,15 +1291,15 @@ tr.z-treerow-over input { } .allocation-satisfied .resource-allocation tr.z-grid-odd td.z-row-inner, .allocation-satisfied tr.z-grid-odd { - background-color: none; + background-color: transparent; } .allocation-satisfied td.z-row-inner { - background-color: none; + background-color: transparent; } .assignedresources .allocation-satisfied td.z-row-inner { - background-color: none; + background-color: transparent; } /* Advanced allocation */ @@ -1457,7 +1430,7 @@ tr.z-tree-row-seld .z-row-cnt { } .filter-more-options .z-groupbox-header { - margin-top: 0px; + margin-top: 0; } .filter-more-options .z-groupbox-bl { display: none; @@ -1537,10 +1510,8 @@ tr.z-tree-row-seld .z-row-cnt { .progress-types.z-combobox .z-combobox-inp { margin:0; padding:0; - border:0; color: transparent; background: transparent; - border: 0; border-width: 0; outline: none; width: 0; @@ -1571,7 +1542,7 @@ tr.z-tree-row-seld .z-row-cnt { } .advancedallocationlayout div.z-grid { - border-top: 0px; + border-top: 0; } .advancedallocationlayout .timeTrackedTableWithLeftPane .z-grid-body .z-row-inner { @@ -1596,8 +1567,8 @@ tr.z-tree-row-seld .z-row-cnt { .advanced-assignment-area td .limiting.z-intbox, .advanced-assignment-area td .limiting.z-textbox { height: 20px; - background: #61B598; // LIMITING_ASSIGNED -color: #555555; + background: #61B598; /* LIMITING_ASSIGNED */ + color: #555555; border-right: solid 1px white; opacity: 1; -moz-opacity: 1; @@ -1606,13 +1577,12 @@ color: #555555; .advanced-assignment-area td .limiting.z-intbox[value="0"], .advanced-assignment-area td .limiting.z-textbox[value="0"] { - background: #C1D9D1; // LIMITING_UNNASSIGNED -color: #555555; + background: #C1D9D1; /* LIMITING_UNNASSIGNED */ + color: #555555; } .advanced-assignment-area > .z-center-body { overflow: visible !important; - overflow: visible !important; } input.z-spinner-text-disd, diff --git a/libreplan-webapp/src/main/webapp/common/layout/login.zul b/libreplan-webapp/src/main/webapp/common/layout/login.zul index 73c489bbe..10fe5447a 100644 --- a/libreplan-webapp/src/main/webapp/common/layout/login.zul +++ b/libreplan-webapp/src/main/webapp/common/layout/login.zul @@ -35,14 +35,13 @@ controller = loginController; contextPath = Executions.getCurrent().getContextPath(); loginError = Executions.getCurrent().getParameter("login_error"); - logoLoginLink = contextPath + "/common/img/" + - org.libreplan.web.I18nHelper._("en") + "/logo_login.png"; + logoLoginLink = contextPath + "/common/img/" + org.libreplan.web.I18nHelper._("en") + "/logo_login.png"; ]]> - + @@ -64,12 +63,13 @@ - + - + - + ${i18n:_('User')} @@ -77,7 +77,8 @@

    - +
    @@ -85,11 +86,12 @@
    - +
    - + @@ -112,12 +114,13 @@ - + - + - + ${i18n:_('Supported Chrome, Firefox, Safari and Epiphany browsers')} @@ -129,7 +132,7 @@ - + diff --git a/libreplan-webapp/src/main/webapp/common/layout/timeout.zul b/libreplan-webapp/src/main/webapp/common/layout/timeout.zul index 4e73b799f..3352caa9f 100644 --- a/libreplan-webapp/src/main/webapp/common/layout/timeout.zul +++ b/libreplan-webapp/src/main/webapp/common/layout/timeout.zul @@ -26,7 +26,7 @@ - +