Faxtomail-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- 1934 discussions
r204 - in trunk: faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin faxtomail-ui-web/src/main/webapp/js
by echatellier@users.forge.codelutin.com 12 Jun '14
by echatellier@users.forge.codelutin.com 12 Jun '14
12 Jun '14
Author: echatellier
Date: 2014-06-12 19:00:35 +0200 (Thu, 12 Jun 2014)
New Revision: 204
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/204
Log:
Ajout d'un check pour les droits d'?\195?\169criture sur le dossier EDI
Added:
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationJsonAction.java
Modified:
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp
trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java 2014-06-12 16:30:47 UTC (rev 203)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java 2014-06-12 17:00:35 UTC (rev 204)
@@ -24,6 +24,7 @@
* #L%
*/
+import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -275,4 +276,22 @@
return result;
}
+
+ /**
+ * Return file information on file path.
+ *
+ * @param path path
+ * @return file info
+ */
+ public Object checkDirectory(String path) {
+ Map<String, Object> result = new HashMap<>();
+ File file = new File(path);
+ result.put("path", path);
+ result.put("exist", file.exists());
+ result.put("isDirectory", file.isDirectory());
+ result.put("canRead", file.canRead());
+ result.put("canWrite", file.canWrite());
+ result.put("canExecute", file.canExecute());
+ return result;
+ }
}
Added: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationJsonAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationJsonAction.java (rev 0)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationJsonAction.java 2014-06-12 17:00:35 UTC (rev 204)
@@ -0,0 +1,80 @@
+package com.franciaflex.faxtomail.web.action.admin;
+
+/*
+ * #%L
+ * FaxToMail :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2014 Franciaflex, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.struts2.convention.annotation.Action;
+
+import com.franciaflex.faxtomail.persistence.entities.EmailAccount;
+import com.franciaflex.faxtomail.persistence.entities.EmailAccountImpl;
+import com.franciaflex.faxtomail.services.service.ConfigurationService;
+import com.franciaflex.faxtomail.web.FaxToMailJsonAction;
+
+public class ConfigurationJsonAction extends FaxToMailJsonAction {
+
+ protected ConfigurationService configurationService;
+
+ /** Directory path to check existence and writability. */
+ protected String path;
+
+ protected EmailAccount emailAccount;
+
+ protected Object jsonData;
+
+ public void setConfigurationService(ConfigurationService configurationService) {
+ this.configurationService = configurationService;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public EmailAccount getEmailAccount() {
+ if (emailAccount == null) {
+ emailAccount = new EmailAccountImpl();
+ }
+ return emailAccount;
+ }
+
+ @Action("configuration-check-directory-json")
+ public String checkDirectory() {
+ jsonData = configurationService.checkDirectory(path);
+ return SUCCESS;
+ }
+
+ @Action("configuration-check-mail-json")
+ public String checkMail() {
+
+ return SUCCESS;
+ }
+
+ @Override
+ public Object getJsonData() {
+ return jsonData;
+ }
+
+}
Property changes on: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationJsonAction.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-12 16:30:47 UTC (rev 203)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-12 17:00:35 UTC (rev 204)
@@ -51,7 +51,9 @@
'emailAccounts': <s:property value="toJson(emailAccounts)" escapeHtml="false"/>,
// referentiels
'users': <s:property value="toJson(users)" escapeHtml="false"/>,
- 'groups': <s:property value="toJson(groups)" escapeHtml="false"/>
+ 'groups': <s:property value="toJson(groups)" escapeHtml="false"/>,
+ // remote service urls
+ 'remoteCheckFolder': "<s:url action="configuration-check-directory-json" />"
});
</script>
</head>
@@ -354,8 +356,7 @@
Définir le dossier de dépôt des demandes EDI sur le serveur :</label>
<div class="input-group" ng-if="selectedMailFolder.useCurrentLevelEdiFolder || !selectedMailFolder.$parent">
<input type="text" class="form-control" ng-model="selectedMailFolder.ediFolder">
- <span class="input-group-addon btn btn-info" ng-disabled="!selectedMailFolder.ediFolder"
- tooltip="Fonctionnalité à venir">
+ <span class="input-group-addon btn btn-info" ng-disabled="!selectedMailFolder.ediFolder" ng-click="checkRemotePath()">
<i class="fa fa-cogs"></i> Test
</span>
</div>
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-12 16:30:47 UTC (rev 203)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-12 17:00:35 UTC (rev 204)
@@ -252,8 +252,8 @@
/**
* Mail folder tab controller.
*/
-ConfigurationModule.controller('ConfigurationTreeController', ['$scope', '$window', 'ConfigurationData',
- function($scope, $window, ConfigurationData) {
+ConfigurationModule.controller('ConfigurationTreeController', ['$scope', '$window', '$http', 'ConfigurationData',
+ function($scope, $window, $http, ConfigurationData) {
// {Object} selected mail folder
$scope.selectedMailFolder;
// {String} add new customer responsible form value
@@ -547,6 +547,22 @@
}
};
+ $scope.checkRemotePath = function() {
+ $http.get(ConfigurationData.remoteCheckFolder +
+ "?path=" + encodeURIComponent($scope.selectedMailFolder.ediFolder), {cache:true})
+ .success(function(data, status, headers, config) {
+ if (data.isDirectory) {
+ if (data.canWrite) {
+ $window.alert("Le dossier existe et dispose des droits d'écriture.");
+ } else {
+ $window.alert("Le dossier existe, mais ne dispose pas des droits d'écriture !");
+ }
+ } else {
+ $window.alert("Le dossier n'existe pas !");
+ }
+ });
+ };
+
// utilisé pour mettre à jour $scope.selectedMailFolder.folderTableColumns si $scope.folderTableColumns change
$scope.$watch("folderTableColumns", function(newValue, oldValue) {
if (newValue != oldValue) {
1
0
r203 - in trunk/faxtomail-ui-web/src/main: java/com/franciaflex/faxtomail/web resources webapp/WEB-INF
by echatellier@users.forge.codelutin.com 12 Jun '14
by echatellier@users.forge.codelutin.com 12 Jun '14
12 Jun '14
Author: echatellier
Date: 2014-06-12 18:30:47 +0200 (Thu, 12 Jun 2014)
New Revision: 203
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/203
Log:
Ajout du support des actions de type json
Added:
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailJsonAction.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailJsonResultSupport.java
Modified:
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java
trunk/faxtomail-ui-web/src/main/resources/struts.xml
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators.xml
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java 2014-06-12 16:12:04 UTC (rev 202)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java 2014-06-12 16:30:47 UTC (rev 203)
@@ -63,7 +63,7 @@
protected FaxToMailSession session;
- protected Gson gson;
+ protected static Gson gson;
public void setApplicationConfig(FaxToMailConfiguration applicationConfig) {
this.applicationConfig = applicationConfig;
@@ -103,7 +103,7 @@
return result;
}
- public Gson getGson() {
+ public static Gson getGson() {
if (gson == null) {
GsonBuilder builder = new GsonBuilder();
Added: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailJsonAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailJsonAction.java (rev 0)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailJsonAction.java 2014-06-12 16:30:47 UTC (rev 203)
@@ -0,0 +1,49 @@
+package com.franciaflex.faxtomail.web;
+
+/*
+ * #%L
+ * FaxToMail :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2014 Franciaflex, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.convention.annotation.Results;
+
+
+/**
+ * Abstract action used to render custom objects as json string using gson directly in response output stream.
+ *
+ * @author Eric Chatellier
+ */
+@Results({
+ @Result(type = "faxtomail-json", name = "success")
+})
+public abstract class FaxToMailJsonAction extends FaxToMailActionSupport {
+
+ /**
+ * Method to override to get object data to render as json. Method HAS to be public because result support will use
+ * this method.
+ *
+ * @return object to render as json
+ */
+ public abstract Object getJsonData();
+
+}
Property changes on: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailJsonAction.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailJsonResultSupport.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailJsonResultSupport.java (rev 0)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailJsonResultSupport.java 2014-06-12 16:30:47 UTC (rev 203)
@@ -0,0 +1,74 @@
+package com.franciaflex.faxtomail.web;
+
+/*
+ * #%L
+ * FaxToMail :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2014 Franciaflex, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import java.io.IOException;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.dispatcher.StrutsResultSupport;
+
+import com.google.common.base.Charsets;
+import com.opensymphony.xwork2.ActionInvocation;
+
+public class FaxToMailJsonResultSupport extends StrutsResultSupport {
+
+ private static final Log log = LogFactory.getLog(FaxToMailJsonResultSupport.class);
+
+ @Override
+ protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
+ Object jsonData = invocation.getStack().findValue("jsonData");
+
+ String json = FaxToMailActionSupport.getGson().toJson(jsonData);
+
+ // Work-arround for IE to not display download dialog for json result
+ // see https://github.com/blueimp/jQuery-File-Upload/issues/1795
+ HttpServletRequest servletRequest = (HttpServletRequest) invocation.getInvocationContext().get(HTTP_REQUEST);
+ HttpServletResponse servletResponse = (HttpServletResponse) invocation.getInvocationContext().get(HTTP_RESPONSE);
+ servletResponse.setCharacterEncoding(Charsets.UTF_8.name());
+ if (servletRequest.getHeader("accept").indexOf("application/json") != -1) {
+ servletResponse.setContentType("application/json");
+ } else {
+ // IE workaround
+ servletResponse.setContentType("text/plain");
+ }
+
+ try {
+ ServletOutputStream outputStream = servletResponse.getOutputStream();
+ byte[] jsonBytes = json.getBytes(Charsets.UTF_8); // On transforme en bytes pour assurer l'encodage
+ outputStream.write(jsonBytes);
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Unable to write JSON output into Servlet Response");
+ }
+ }
+
+ }
+
+}
Property changes on: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailJsonResultSupport.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/faxtomail-ui-web/src/main/resources/struts.xml
===================================================================
--- trunk/faxtomail-ui-web/src/main/resources/struts.xml 2014-06-12 16:12:04 UTC (rev 202)
+++ trunk/faxtomail-ui-web/src/main/resources/struts.xml 2014-06-12 16:30:47 UTC (rev 203)
@@ -35,6 +35,11 @@
<package name="faxtomail" namespace="/" extends="struts-default">
+ <result-types>
+ <result-type name="faxtomail-json" default="false"
+ class="com.franciaflex.faxtomail.web.FaxToMailJsonResultSupport" />
+ </result-types>
+
<interceptors>
<interceptor name="faxToMailInterceptor" class="com.franciaflex.faxtomail.web.FaxToMailInterceptor"/>
<interceptor name="loginInterceptor" class="com.franciaflex.faxtomail.web.FaxToMailLoginInterceptor" />
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators.xml
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators.xml 2014-06-12 16:12:04 UTC (rev 202)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators.xml 2014-06-12 16:30:47 UTC (rev 203)
@@ -1,10 +1,10 @@
<!--
#%L
- Extranet ENC-AHI :: Web
+ FaxToMail :: Web
$Id$
$HeadURL$
%%
- Copyright (C) 2013 Ministère des Affaires sociales et de la Santé
+ Copyright (C) 2014 Franciaflex, Code Lutin
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -24,13 +24,10 @@
<decorators defaultdir="/WEB-INF/decorators">
<excludes>
<pattern>/css/*</pattern>
- <pattern>/img/*</pattern>
+ <pattern>/js/*</pattern>
+ <pattern>*-json*</pattern>
</excludes>
- <!--<decorator name="layout-login" page="layout-login.jsp">-->
- <!--<pattern>/authentication/login*</pattern>-->
- <!--</decorator>-->
-
<decorator name="layout" page="layout.jsp">
<pattern>/*</pattern>
</decorator>
1
0
r202 - in trunk: . faxtomail-ui-web faxtomail-ui-web/src/main/webapp/WEB-INF faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin faxtomail-ui-web/src/main/webapp/css faxtomail-ui-web/src/main/webapp/js
by echatellier@users.forge.codelutin.com 12 Jun '14
by echatellier@users.forge.codelutin.com 12 Jun '14
12 Jun '14
Author: echatellier
Date: 2014-06-12 18:12:04 +0200 (Thu, 12 Jun 2014)
New Revision: 202
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/202
Log:
Test chosen pour le filtrage (mais fonctionne pas :()
Added:
trunk/faxtomail-ui-web/src/main/webapp/css/chosen-spinner.css
trunk/faxtomail-ui-web/src/main/webapp/css/spinner.gif
trunk/faxtomail-ui-web/src/main/webapp/js/chosen.js
Modified:
trunk/faxtomail-ui-web/pom.xml
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml
trunk/faxtomail-ui-web/src/main/webapp/css/faxtomail.css
trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js
trunk/pom.xml
Modified: trunk/faxtomail-ui-web/pom.xml
===================================================================
--- trunk/faxtomail-ui-web/pom.xml 2014-06-12 15:23:11 UTC (rev 201)
+++ trunk/faxtomail-ui-web/pom.xml 2014-06-12 16:12:04 UTC (rev 202)
@@ -235,6 +235,11 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>chosen</artifactId>
+ </dependency>
<dependency>
<groupId>org.nuiton.js</groupId>
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-12 15:23:11 UTC (rev 201)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-12 16:12:04 UTC (rev 202)
@@ -961,7 +961,7 @@
<div class="form-group">
<label for="newManagedGroupField" class="control-label">Nouveau groupe :</label>
<select id="newManagedGroupField" class="form-control"
- ng-model="newManagedGroup" ng-options="group as group.fullPath for group in groups">
+ ng-model="newManagedGroup" ng-options="group as group.fullPath for group in groups" width="'100%'" searchContains="true">
</select>
<a class="btn btn-success btn-xs" ng-click="addManagedGroup()" ng-disabled="!newManagedGroup">
<span class="glyphicon glyphicon-plus"></span>
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml 2014-06-12 15:23:11 UTC (rev 201)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml 2014-06-12 16:12:04 UTC (rev 202)
@@ -28,6 +28,11 @@
<js>classpath:META-INF/resources/webjars/select2/3.4.8/select2.js</js>
<js>classpath:META-INF/resources/webjars/select2/3.4.8/select2_locale_fr.js</js>
</group>
+
+ <group name='webjar-chosen' abstract="true">
+ <css>classpath:META-INF/resources/webjars/chosen/1.1.0/chosen.css</css>
+ <js>classpath:META-INF/resources/webjars/chosen/1.1.0/chosen.jquery.js</js>
+ </group>
<group name='webjar-angular-ui-sortable' abstract="true">
<js>classpath:META-INF/resources/webjars/angular-ui-sortable/0.12.7/sortable.min.js</js>
@@ -45,6 +50,12 @@
<js>/js/select2sortable.js</js>
</group>
+ <group name='angular-chosen' abstract="true">
+ <group-ref>webjar-chosen</group-ref>
+ <js>/js/chosen.js</js>
+ <css>/css/chosen-spinner.css</css>
+ </group>
+
<group name='webjar-respond' abstract="true">
<js>classpath:META-INF/resources/webjars/respond/1.4.2/src/respond.js</js>
</group>
@@ -69,6 +80,7 @@
<group name='faxtomail-configuration'>
<group-ref>select2sortable</group-ref>
+ <group-ref>angular-chosen</group-ref>
<group-ref>webjar-angular-ui-sortable</group-ref>
<group-ref>font-awesome</group-ref>
<js>/js/configuration.js</js>
@@ -77,6 +89,7 @@
<group name='faxtomail-user-folder'>
<group-ref>select2sortable</group-ref>
+ <group-ref>angular-chosen</group-ref>
<group-ref>font-awesome</group-ref>
<js>/js/user-folder.js</js>
<css>/css/faxtomail.css</css>
Added: trunk/faxtomail-ui-web/src/main/webapp/css/chosen-spinner.css
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/css/chosen-spinner.css (rev 0)
+++ trunk/faxtomail-ui-web/src/main/webapp/css/chosen-spinner.css 2014-06-12 16:12:04 UTC (rev 202)
@@ -0,0 +1,12 @@
+/* %%Ignore-License Additional styles to display a spinner image while options are loading */
+.localytics-chosen.loading+.chosen-container-multi .chosen-choices {
+ background-image: url('spinner.gif');
+ background-repeat: no-repeat;
+ background-position: 95%;
+}
+.localytics-chosen.loading+.chosen-container-single .chosen-single span {
+ background: url('spinner.gif') no-repeat right;
+}
+.localytics-chosen.loading+.chosen-container-single .chosen-single .search-choice-close {
+ display: none;
+}
\ No newline at end of file
Property changes on: trunk/faxtomail-ui-web/src/main/webapp/css/chosen-spinner.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/faxtomail-ui-web/src/main/webapp/css/faxtomail.css
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/css/faxtomail.css 2014-06-12 15:23:11 UTC (rev 201)
+++ trunk/faxtomail-ui-web/src/main/webapp/css/faxtomail.css 2014-06-12 16:12:04 UTC (rev 202)
@@ -76,3 +76,7 @@
content:"*";
color:red;
}
+
+/*.chosen-container {
+ width:100%;
+}*/
\ No newline at end of file
Added: trunk/faxtomail-ui-web/src/main/webapp/css/spinner.gif
===================================================================
(Binary files differ)
Property changes on: trunk/faxtomail-ui-web/src/main/webapp/css/spinner.gif
___________________________________________________________________
Added: svn:mime-type
+ image/gif
Added: trunk/faxtomail-ui-web/src/main/webapp/js/chosen.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/chosen.js (rev 0)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/chosen.js 2014-06-12 16:12:04 UTC (rev 202)
@@ -0,0 +1,109 @@
+// %%Ignore-License Generated by CoffeeScript 1.6.2
+(function() {
+ var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+
+ angular.module('localytics.directives', []);
+
+ angular.module('localytics.directives').directive('chosen', function() {
+ var CHOSEN_OPTION_WHITELIST, NG_OPTIONS_REGEXP, isEmpty, snakeCase;
+
+ NG_OPTIONS_REGEXP = /^\s*(.*?)(?:\s+as\s+(.*?))?(?:\s+group\s+by\s+(.*))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+(.*?)(?:\s+track\s+by\s+(.*?))?$/;
+ CHOSEN_OPTION_WHITELIST = ['noResultsText', 'allowSingleDeselect', 'disableSearchThreshold', 'disableSearch', 'enableSplitWordSearch', 'inheritSelectClasses', 'maxSelectedOptions', 'placeholderTextMultiple', 'placeholderTextSingle', 'searchContains', 'singleBackstrokeDelete', 'displayDisabledOptions', 'displaySelectedOptions', 'width'];
+ snakeCase = function(input) {
+ return input.replace(/[A-Z]/g, function($1) {
+ return "_" + ($1.toLowerCase());
+ });
+ };
+ isEmpty = function(value) {
+ var key;
+
+ if (angular.isArray(value)) {
+ return value.length === 0;
+ } else if (angular.isObject(value)) {
+ for (key in value) {
+ if (value.hasOwnProperty(key)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ };
+ return {
+ restrict: 'A',
+ require: '?ngModel',
+ terminal: true,
+ link: function(scope, element, attr, ngModel) {
+ var chosen, defaultText, disableWithMessage, empty, initOrUpdate, match, options, origRender, removeEmptyMessage, startLoading, stopLoading, valuesExpr, viewWatch;
+
+ element.addClass('localytics-chosen');
+ options = scope.$eval(attr.chosen) || {};
+ angular.forEach(attr, function(value, key) {
+ if (__indexOf.call(CHOSEN_OPTION_WHITELIST, key) >= 0) {
+ return options[snakeCase(key)] = scope.$eval(value);
+ }
+ });
+ startLoading = function() {
+ return element.addClass('loading').attr('disabled', true).trigger('chosen:updated');
+ };
+ stopLoading = function() {
+ return element.removeClass('loading').attr('disabled', false).trigger('chosen:updated');
+ };
+ chosen = null;
+ defaultText = null;
+ empty = false;
+ initOrUpdate = function() {
+ if (chosen) {
+ return element.trigger('chosen:updated');
+ } else {
+ chosen = element.chosen(options).data('chosen');
+ return defaultText = chosen.default_text;
+ }
+ };
+ removeEmptyMessage = function() {
+ empty = false;
+ return element.attr('data-placeholder', defaultText);
+ };
+ disableWithMessage = function() {
+ empty = true;
+ return element.attr('data-placeholder', chosen.results_none_found).attr('disabled', true).trigger('chosen:updated');
+ };
+ if (ngModel) {
+ origRender = ngModel.$render;
+ ngModel.$render = function() {
+ origRender();
+ return initOrUpdate();
+ };
+ if (attr.multiple) {
+ viewWatch = function() {
+ return ngModel.$viewValue;
+ };
+ scope.$watch(viewWatch, ngModel.$render, true);
+ }
+ } else {
+ initOrUpdate();
+ }
+ attr.$observe('disabled', function() {
+ return element.trigger('chosen:updated');
+ });
+ if (attr.ngOptions && ngModel) {
+ match = attr.ngOptions.match(NG_OPTIONS_REGEXP);
+ valuesExpr = match[7];
+ return scope.$watchCollection(valuesExpr, function(newVal, oldVal) {
+ if (angular.isUndefined(newVal)) {
+ return startLoading();
+ } else {
+ if (empty) {
+ removeEmptyMessage();
+ }
+ stopLoading();
+ if (isEmpty(newVal)) {
+ return disableWithMessage();
+ }
+ }
+ });
+ }
+ }
+ };
+ });
+
+}).call(this);
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-12 15:23:11 UTC (rev 201)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-12 16:12:04 UTC (rev 202)
@@ -22,7 +22,7 @@
* #L%
*/
-var ConfigurationModule = angular.module('ConfigurationModule', ['FaxToMail', 'ui.tree', 'ui.sortable', 'ui.select2.sortable']);
+var ConfigurationModule = angular.module('ConfigurationModule', ['FaxToMail', 'ui.tree', 'localytics.directives', 'ui.select2.sortable']);
/**
* Global configuration controller.
@@ -832,7 +832,6 @@
console.log("Udpate MetaFilter");
$scope.rootFolderMailFilters = {};
updateMetaFilter();
- console.log($scope.rootFolderMailFilters);
});
// option de la configuration 'sortable'
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js 2014-06-12 15:23:11 UTC (rev 201)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js 2014-06-12 16:12:04 UTC (rev 202)
@@ -22,7 +22,7 @@
* #L%
*/
-var UserFolderModule = angular.module('UserFolderModule', ['FaxToMail', 'ui.select2.sortable']);
+var UserFolderModule = angular.module('UserFolderModule', ['FaxToMail', 'localytics.directives', 'ui.select2.sortable']);
/**
* Global configuration controller.
@@ -39,7 +39,7 @@
$scope.userFolders = UserFolderData.userFolders;
//{Array} Group list
$scope.groups = UserFolderData.groups;
-
+
// method privée recursive pour retourner l'ensemble des dossiers en les modifiant pour ajouter
// des metadata (full path from root, and root node instance)
var recursiveAddMailFolder = function(result, mailFolders, rootFolder, prefix, parent) {
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-06-12 15:23:11 UTC (rev 201)
+++ trunk/pom.xml 2014-06-12 16:12:04 UTC (rev 202)
@@ -576,6 +576,13 @@
<version>3.4.8-1</version>
<scope>runtime</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>chosen</artifactId>
+ <version>1.1.0</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.nuiton.js</groupId>
1
0
r201 - in trunk/faxtomail-ui-web/src/main: java/com/franciaflex/faxtomail/web/action/admin webapp/js
by echatellier@users.forge.codelutin.com 12 Jun '14
by echatellier@users.forge.codelutin.com 12 Jun '14
12 Jun '14
Author: echatellier
Date: 2014-06-12 17:23:11 +0200 (Thu, 12 Jun 2014)
New Revision: 201
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/201
Log:
Display folder full path
Modified:
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java
trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java 2014-06-12 15:00:44 UTC (rev 200)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java 2014-06-12 15:23:11 UTC (rev 201)
@@ -76,7 +76,7 @@
@Override
@Action("user-folder-input")
public String input() throws Exception {
- mailFolders = mailFolderService.getAllMailFolders();
+ mailFolders = mailFolderService.getRootMailFolders();
users = configurationService.getUserManagedUsers(getSession().getAuthenticatedFaxToMailUser());
// build display map
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-12 15:00:44 UTC (rev 200)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-12 15:23:11 UTC (rev 201)
@@ -45,7 +45,7 @@
$scope.mailFolders = ConfigurationData.mailFolders;
// {Map} Mail folder usage
$scope.mailFoldersUsage = ConfigurationData.mailFoldersUsage;
- //{Map<MailFolder id, Array<MailFolder>>} liste des
+ //{Map<MailFolder id, Array<MailFolder>>} liste des dossier (a plat, par dossier racine)
$scope.flatMailFolders;
//{Array} All application users
$scope.users = ConfigurationData.users;
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js 2014-06-12 15:00:44 UTC (rev 200)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js 2014-06-12 15:23:11 UTC (rev 201)
@@ -33,28 +33,45 @@
$scope.mailFolders = UserFolderData.mailFolders;
// {Array} Liste des utilisateurs ldap
$scope.users = UserFolderData.users;
+ //{Map<MailFolder id, Array<MailFolder>>} liste des
+ $scope.flatMailFolders;
//{Map} Topia id : mailFolders
$scope.userFolders = UserFolderData.userFolders;
//{Array} Group list
$scope.groups = UserFolderData.groups;
-
- // method privée recursive pour retourner l'ensemble des dossiers
- var recursiveAddMailFolder = function(result, mailFolders) {
+
+ // method privée recursive pour retourner l'ensemble des dossiers en les modifiant pour ajouter
+ // des metadata (full path from root, and root node instance)
+ var recursiveAddMailFolder = function(result, mailFolders, rootFolder, prefix, parent) {
if (mailFolders) {
angular.forEach(mailFolders, function(mailFolder) {
+
+ // warning modify input object :(
+ // use $ from this, even not recommended because angular exlude those fields when jsonify
+ mailFolder.$fullPath = prefix + "/" + mailFolder.name;
+ // ha la la, modify input object again :(
+ // use $ from this, even not recommended because angular exlude those fields when jsonify
+ mailFolder.$rootFolder = rootFolder;
+ // encore pour le parent
+ mailFolder.$parent = parent;
+
result.push(mailFolder);
- recursiveAddMailFolder(result, mailFolder.children);
+ recursiveAddMailFolder(result, mailFolder.children, rootFolder, mailFolder.$fullPath, mailFolder);
});
}
};
- // Retourne l'ensemble de l'arbre des dossiers "à plat"
- $scope.flatMailFolders = function() {
- var flatMailFolders = [];
- recursiveAddMailFolder(flatMailFolders, $scope.mailFolders);
- return flatMailFolders;
+ // update $scope.flatMailFolders when $scope.mailFolders changes
+ $scope._updateFlatMailFolders = function() {
+ console.log("Update flatMailFolders map");
+ $scope.flatMailFolders = {};
+ angular.forEach($scope.mailFolders, function(mailFolder) {
+ $scope.flatMailFolders[mailFolder.topiaId] = [];
+ recursiveAddMailFolder($scope.flatMailFolders[mailFolder.topiaId], mailFolder.children, mailFolder, mailFolder.name, mailFolder);
+ });
};
-
+ $scope._updateFlatMailFolders();
+
// fonction retournant l'ensemble des options disponibles
$scope.getObjectsData = function(term, result) {
var resultArray = [];
@@ -62,7 +79,20 @@
// select 2 require an id field
mailFolder.id = mailFolder.topiaId;
// select 2 can use 'name' for display, so it's ok
+
+ // push root
resultArray.push(mailFolder);
+
+ // build children map
+ if ($scope.flatMailFolders.hasOwnProperty(mailFolder.topiaId)) {
+ angular.forEach($scope.flatMailFolders[mailFolder.topiaId], function(childFolder) {
+ childFolder.id = childFolder.topiaId;
+ // defined text for display
+ childFolder.text = childFolder.$fullPath;
+ resultArray.push(childFolder);
+ });
+ }
+
});
result(resultArray);
};
1
0
r200 - trunk/faxtomail-ui-web/src/main/resources/i18n
by echatellier@users.forge.codelutin.com 12 Jun '14
by echatellier@users.forge.codelutin.com 12 Jun '14
12 Jun '14
Author: echatellier
Date: 2014-06-12 17:00:44 +0200 (Thu, 12 Jun 2014)
New Revision: 200
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/200
Log:
Renommage d'une valeur d'enum
Modified:
trunk/faxtomail-ui-web/src/main/resources/i18n/faxtomail-ui-web_fr_FR.properties
Modified: trunk/faxtomail-ui-web/src/main/resources/i18n/faxtomail-ui-web_fr_FR.properties
===================================================================
--- trunk/faxtomail-ui-web/src/main/resources/i18n/faxtomail-ui-web_fr_FR.properties 2014-06-12 14:59:17 UTC (rev 199)
+++ trunk/faxtomail-ui-web/src/main/resources/i18n/faxtomail-ui-web_fr_FR.properties 2014-06-12 15:00:44 UTC (rev 200)
@@ -30,7 +30,7 @@
com.franciaflex.faxtomail.persistence.entities.MailField.RECEPTION_DATE=Date de réception
com.franciaflex.faxtomail.persistence.entities.MailField.RECIPIENT=Destinataire
com.franciaflex.faxtomail.persistence.entities.MailField.REFERENCE=Référence
-com.franciaflex.faxtomail.persistence.entities.MailField.REPLY=Réponses
+com.franciaflex.faxtomail.persistence.entities.MailField.REPLIES=Réponses
com.franciaflex.faxtomail.persistence.entities.MailField.SAV_NB=Quantité de SAV
com.franciaflex.faxtomail.persistence.entities.MailField.SENDER=Expéditeur
com.franciaflex.faxtomail.persistence.entities.MailField.TAKEN_BY=Pris par
1
0
r199 - in trunk/faxtomail-ui-web/src/main/webapp: WEB-INF/content/admin js
by echatellier@users.forge.codelutin.com 12 Jun '14
by echatellier@users.forge.codelutin.com 12 Jun '14
12 Jun '14
Author: echatellier
Date: 2014-06-12 16:59:17 +0200 (Thu, 12 Jun 2014)
New Revision: 199
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/199
Log:
Correction de la gestion des droits.
Ajout de prototype utilisataires indexOfByTopiaId, containsByTopiaId
Modified:
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp
trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-12 13:40:31 UTC (rev 198)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/configuration-input.jsp 2014-06-12 14:59:17 UTC (rev 199)
@@ -88,7 +88,7 @@
</div>
<div class="form-group">
- Actions autorisées lorsque la demande n'a pas d'état d'attente et est <strong>invalide</strong> :
+ Actions autorisées lorsque la demande n'a pas d'état d'attente est <strong>invalide</strong> :
<label class="checkbox" ng-repeat="(mailAction,label) in mailActions">
<input type="checkbox" ng-checked="configuration.invalidFormDisabledActions.indexOf(mailAction) == -1"
ng-click="changeInvalidAction(mailAction)"> {{label}}
@@ -556,7 +556,7 @@
Hériter des états d'attente déclarés sur les dossiers parent :
</label>
<label class="checkbox" ng-repeat="etatAttente in etatAttentes" ng-if="selectedMailFolder.$parent && !selectedMailFolder.useCurrentLevelEtatAttente">
- <input type="checkbox" ng-checked="parentScopeValues.etatAttentes.indexOf(etatAttente) != -1"
+ <input type="checkbox" ng-checked="parentScopeValues.etatAttentes.containsByTopiaId(etatAttente)"
disabled> {{etatAttente.label}}
</label>
<label>
@@ -565,7 +565,7 @@
Définir des états d'attente pour ce dossier :
</label>
<label class="checkbox" ng-repeat="etatAttente in etatAttentes" ng-if="selectedMailFolder.useCurrentLevelEtatAttente || !selectedMailFolder.$parent">
- <input type="checkbox" ng-checked="selectedMailFolder.etatAttentes.indexOf(etatAttente) != -1"
+ <input type="checkbox" ng-checked="selectedMailFolder.etatAttentes.containsByTopiaId(etatAttente)"
ng-click="changeFolderEtatAttente(etatAttente)"> {{etatAttente.label}}
</label>
</div>
@@ -661,9 +661,9 @@
<span class="fa fa-users"></span> {{group.fullPath}}
</td>
<td>
- <label><input type="checkbox" ng-checked="parentScopeValues.readRightGroups.indexOf(group) != -1" disabled> Lecture</label>
- <label><input type="checkbox" ng-checked="parentScopeValues.writeRightGroups.indexOf(group) != -1" disabled> Écriture</label>
- <label><input type="checkbox" ng-checked="parentScopeValues.moveRightGroups.indexOf(group) != -1" disabled> Déplacement</label>
+ <label><input type="checkbox" ng-checked="parentScopeValues.readRightGroups.containsByTopiaId(group)" disabled> Lecture</label>
+ <label><input type="checkbox" ng-checked="parentScopeValues.writeRightGroups.containsByTopiaId(group)" disabled> Écriture</label>
+ <label><input type="checkbox" ng-checked="parentScopeValues.moveRightGroups.containsByTopiaId(group)" disabled> Déplacement</label>
</td>
</tr>
<tr ng-repeat="user in parentScopeValues.rightUsers" class="parentInfos">
@@ -671,9 +671,9 @@
<span class="fa fa-user"></span> {{user.firstName}} {{user.lastName}}
</td>
<td>
- <label><input type="checkbox" ng-checked="parentScopeValues.readRightUsers.indexOf(user) != -1" disabled> Lecture</label>
- <label><input type="checkbox" ng-checked="parentScopeValues.writeRightUsers.indexOf(user) != -1" disabled> Écriture</label>
- <label><input type="checkbox" ng-checked="parentScopeValues.moveRightUsers.indexOf(user) != -1" disabled> Déplacement</label>
+ <label><input type="checkbox" ng-checked="parentScopeValues.readRightUsers.containsByTopiaId(user)" disabled> Lecture</label>
+ <label><input type="checkbox" ng-checked="parentScopeValues.writeRightUsers.containsByTopiaId(user)" disabled> Écriture</label>
+ <label><input type="checkbox" ng-checked="parentScopeValues.moveRightUsers.containsByTopiaId(user)" disabled> Déplacement</label>
</td>
</tr>
</tbody>
@@ -681,50 +681,50 @@
<tr ng-repeat="group in selectedMailFolder.rightGroups">
<td>
<span class="fa fa-users"></span> {{group.fullPath}}
- <a class="pull-right btn btn-danger btn-xs pull-right" ng-click="removeWriteRightGroup($index)">
+ <a class="pull-right btn btn-danger btn-xs pull-right" ng-click="removeRightGroup($index, group)">
<span class="glyphicon glyphicon-remove"></span>
</a>
</td>
<td>
<label><input type="checkbox"
ng-model="readRightGroup"
- ng-checked="selectedMailFolder.readRightGroups.indexOf(group) != -1"
- ng-disabled="parentScopeValues.readRightGroups.indexOf(group) != -1"
+ ng-checked="selectedMailFolder.readRightGroups.containsByTopiaId(group)"
+ ng-disabled="parentScopeValues.readRightGroups.containsByTopiaId(group)"
ng-change="changeReadRightGroup(group)"> Lecture</label>
<label><input type="checkbox"
ng-model="writeRightGroup"
- ng-checked="selectedMailFolder.writeRightGroups.indexOf(group) != -1"
- ng-disabled="parentScopeValues.writeRightGroups.indexOf(group) != -1"
+ ng-checked="selectedMailFolder.writeRightGroups.containsByTopiaId(group)"
+ ng-disabled="parentScopeValues.writeRightGroups.containsByTopiaId(group)"
ng-change="changeWriteRightGroup(group)"> Écriture</label>
<label><input type="checkbox"
ng-model="moveRightGroup"
- ng-checked="selectedMailFolder.moveRightGroups.indexOf(group) != -1"
- ng-disabled="parentScopeValues.moveRightGroups.indexOf(group) != -1"
+ ng-checked="selectedMailFolder.moveRightGroups.containsByTopiaId(group)"
+ ng-disabled="parentScopeValues.moveRightGroups.containsByTopiaId(group)"
ng-change="changeMoveRightGroup(group)"> Déplacement</label>
</td>
</tr>
<tr ng-repeat="user in selectedMailFolder.rightUsers">
<td>
<span class="fa fa-user"></span> {{user.firstName}} {{user.lastName}}
- <a class="pull-right btn btn-danger btn-xs pull-right" ng-click="removeWriteRightUser($index)">
+ <a class="pull-right btn btn-danger btn-xs pull-right" ng-click="removeRightUser($index, user)">
<span class="glyphicon glyphicon-remove"></span>
</a>
</td>
<td>
<label><input type="checkbox"
ng-model="readRightUser"
- ng-checked="selectedMailFolder.readRightUsers.indexOf(user) != -1"
- ng-disabled="parentScopeValues.readRightUsers.indexOf(user) != -1"
+ ng-checked="selectedMailFolder.readRightUsers.containsByTopiaId(user)"
+ ng-disabled="parentScopeValues.readRightUsers.containsByTopiaId(user)"
ng-change="changeReadRightUser(user)"> Lecture</label>
<label><input type="checkbox"
ng-model="writeRightUser"
- ng-checked="selectedMailFolder.writeRightUsers.indexOf(user) != -1"
- ng-disabled="parentScopeValues.writeRightUsers.indexOf(user) != -1"
+ ng-checked="selectedMailFolder.writeRightUsers.containsByTopiaId(user)"
+ ng-disabled="parentScopeValues.writeRightUsers.containsByTopiaId(user)"
ng-change="changeWriteRightUser(user)"> Écriture</label>
<label><input type="checkbox"
ng-model="moveRightUser"
- ng-checked="selectedMailFolder.moveRightUsers.indexOf(user) != -1"
- ng-disabled="parentScopeValues.moveRightUsers.indexOf(user) != -1"
+ ng-checked="selectedMailFolder.moveRightUsers.containsByTopiaId(user)"
+ ng-disabled="parentScopeValues.moveRightUsers.containsByTopiaId(user)"
ng-change="changeMoveRightUser(user)"> Déplacement</label>
</td>
</tr>
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-12 13:40:31 UTC (rev 198)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js 2014-06-12 14:59:17 UTC (rev 199)
@@ -103,6 +103,11 @@
ConfigurationModule.controller('ConfigurationMiscController', ['$scope', '$window', 'ConfigurationData',
function($scope, $window, ConfigurationData) {
+ // initialisation de la configuration
+ if ($scope.configuration.invalidFormDisabledActions) {
+ $scope.configuration.invalidFormDisabledActions = [];
+ }
+
// selection/deselection d'une action
$scope.changeInvalidAction = function(action) {
var index = $scope.configuration.invalidFormDisabledActions.indexOf(action);
@@ -362,19 +367,6 @@
});
});
- // change instance (for indexOf() to work)
- if ($scope.selectedMailFolder.etatAttentes) {
- var newArray = [];
- angular.forEach($scope.selectedMailFolder.etatAttentes, function(folderEtatAttente) {
- angular.forEach($scope.etatAttentes, function(etatAttente) {
- if (etatAttente.topiaId == folderEtatAttente.topiaId) {
- newArray.push(etatAttente);
- }
- });
- });
- $scope.selectedMailFolder.etatAttentes = newArray;
- }
-
// right
$scope.selectedMailFolder.rightUsers = [];
$scope.selectedMailFolder.rightGroups = [];
@@ -666,7 +658,7 @@
// selection/deselection d'un état d'attente possible pour ce dossier
$scope.changeFolderEtatAttente = function(etatAttente) {
- var index = $scope.selectedMailFolder.etatAttentes.indexOf(etatAttente);
+ var index = $scope.selectedMailFolder.etatAttentes.indexOfByTopiaId(etatAttente);
if (index != -1) {
$scope.selectedMailFolder.etatAttentes.splice(index, 1);
} else {
@@ -674,7 +666,7 @@
}
};
- // initialise la liste des actions possibles avec celle des niveaux supérieurs
+ // initialise la liste des colonnes sélectionnées avec celle des niveaux supérieurs
$scope.initFolderColumns = function() {
if ($scope.selectedMailFolder.useCurrentLevelTableColumns) {
if ($scope.parentScopeValues.folderTableColumns) {
@@ -697,13 +689,27 @@
// add user write right
$scope.addRightUser = function() {
$scope.selectedMailFolder.rightUsers.push($scope.newRightUser);
- delete $scope.newWriteRightUser;
+ delete $scope.newRightUser;
};
// remove user write right
- $scope.removeRightUser = function(index) {
+ $scope.removeRightUser = function(index, user) {
if ($window.confirm("Êtes-vous sur de vouloir supprimer les droits de cet utilisateur ?")) {
$scope.selectedMailFolder.rightUsers.splice(index, 1);
+
+ // suppression des droits réels
+ var index = $scope.selectedMailFolder.readRightUsers.indexOfByTopiaId(user);
+ if (index != -1) {
+ $scope.selectedMailFolder.readRightUsers.splice(index, 1);
+ }
+ var index = $scope.selectedMailFolder.writeRightUsers.indexOfByTopiaId(user);
+ if (index != -1) {
+ $scope.selectedMailFolder.writeRightUsers.splice(index, 1);
+ }
+ var index = $scope.selectedMailFolder.moveRightUsers.indexOfByTopiaId(user);
+ if (index != -1) {
+ $scope.selectedMailFolder.moveRightUsers.splice(index, 1);
+ }
}
};
@@ -714,55 +720,74 @@
};
// remove group write right
- $scope.removeWriteRightGroup = function(index) {
+ $scope.removeRightGroup = function(index, group) {
if ($window.confirm("Êtes-vous sur de vouloir supprimer les droits de ce groupe ?")) {
$scope.selectedMailFolder.rightGroups.splice(index, 1);
+
+ // suppression des droits réels
+ var index = $scope.selectedMailFolder.readRightGroups.indexOfByTopiaId(group);
+ if (index != -1) {
+ $scope.selectedMailFolder.readRightGroups.splice(index, 1);
+ }
+ index = $scope.selectedMailFolder.writeRightGroups.indexOfByTopiaId(group);
+ if (index != -1) {
+ $scope.selectedMailFolder.writeRightGroups.splice(index, 1);
+ }
+ index = $scope.selectedMailFolder.moveRightGroups.indexOfByTopiaId(group);
+ if (index != -1) {
+ $scope.selectedMailFolder.moveRightGroups.splice(index, 1);
+ }
}
};
- //
+ // change le droit de lecture du groupe
$scope.changeReadRightGroup = function(group) {
- var index = $scope.selectedMailFolder.readRightGroups.indexOf(group);
+ var index = $scope.selectedMailFolder.readRightGroups.indexOfByTopiaId(group);
if (index != -1) {
$scope.selectedMailFolder.readRightGroups.splice(index, 1);
} else {
$scope.selectedMailFolder.readRightGroups.push(group);
}
};
+ // change le droit d'écriture du groupe
$scope.changeWriteRightGroup = function(group) {
- var index = $scope.selectedMailFolder.writeRightGroups.indexOf(group);
+ var index = $scope.selectedMailFolder.writeRightGroups.indexOfByTopiaId(group);
if (index != -1) {
$scope.selectedMailFolder.writeRightGroups.splice(index, 1);
} else {
$scope.selectedMailFolder.writeRightGroups.push(group);
}
};
+ // change le droit de déplacement du groupe
$scope.changeMoveRightGroup = function(group) {
- var index = $scope.selectedMailFolder.moveRightGroups.indexOf(group);
+ var index = $scope.selectedMailFolder.moveRightGroups.indexOfByTopiaId(group);
if (index != -1) {
$scope.selectedMailFolder.moveRightGroups.splice(index, 1);
} else {
$scope.selectedMailFolder.moveRightGroups.push(group);
}
};
+ // change le droit de lecture d'un utilisateur
$scope.changeReadRightUser = function(user) {
- var index = $scope.selectedMailFolder.readRightUsers.indexOf(user);
+ var index = $scope.selectedMailFolder.readRightUsers.indexOfByTopiaId(user);
if (index != -1) {
$scope.selectedMailFolder.readRightUsers.splice(index, 1);
} else {
$scope.selectedMailFolder.readRightUsers.push(user);
}
};
+ // change le droit d'écriture d'un utilisateur
$scope.changeWriteRightUser = function(user) {
- var index = $scope.selectedMailFolder.writeRightUsers.indexOf(user);
+ var index = $scope.selectedMailFolder.writeRightUsers.indexOfByTopiaId(user);
if (index != -1) {
$scope.selectedMailFolder.writeRightUsers.splice(index, 1);
} else {
$scope.selectedMailFolder.writeRightUsers.push(user);
}
};
+ // change le droit de déplacement d'un utilisateur
$scope.changeMoveRightUser = function(user) {
- var index = $scope.selectedMailFolder.moveRightUsers.indexOf(user);
+ var index = $scope.selectedMailFolder.moveRightUsers.indexOfByTopiaId(user);
if (index != -1) {
$scope.selectedMailFolder.moveRightUsers.splice(index, 1);
} else {
@@ -784,7 +809,7 @@
//{Object} New accout empty filter
$scope.newFilter = {};
- // replace filter instance with mailFolder filter instance to use same objects
+ // replace filter instance with mailFolder filter instance to use same objects (filled with fullPathInfo)
var updateMetaFilter = function() {
angular.forEach($scope.mailFilters, function(filter) {
// root folder
@@ -807,6 +832,7 @@
console.log("Udpate MetaFilter");
$scope.rootFolderMailFilters = {};
updateMetaFilter();
+ console.log($scope.rootFolderMailFilters);
});
// option de la configuration 'sortable'
@@ -823,6 +849,9 @@
// add new filter action
$scope.addNewFilter = function(rootMailFolder) {
$scope.mailFilters.push($scope.newFilter);
+ if (!$scope.rootFolderMailFilters.hasOwnProperty(rootMailFolder.topiaId)) {
+ $scope.rootFolderMailFilters[rootMailFolder.topiaId] = [];
+ }
$scope.rootFolderMailFilters[rootMailFolder.topiaId].push($scope.newFilter);
// clear form
$scope.newFilter = {};
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js 2014-06-12 13:40:31 UTC (rev 198)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js 2014-06-12 14:59:17 UTC (rev 199)
@@ -37,5 +37,30 @@
return _p8() + _p8(true) + _p8(true) + _p8();
}
+console.log("abc" === "abc");// true
+console.log("abc" === new String("abc")); // false
+console.log(new String("abc") === new String("abc")); // false
+
+/**
+ * Même fonction que indexOf mais qui compare par topiaId au lieu des références.
+ */
+Array.prototype.indexOfByTopiaId = function(obj) {
+ var i = this.length;
+ while (i--) {
+ if (this[i].topiaId == obj.topiaId) {
+ return i;
+ }
+ }
+ return -1;
+};
+
+/**
+ * Method contains par topiaId.
+ */
+Array.prototype.containsByTopiaId = function(obj) {
+ return this.indexOfByTopiaId(obj) != -1;
+};
+
+
/** Mail faxtomail application module. */
var FaxToMailModule = angular.module('FaxToMail', ['ui.bootstrap']);
1
0
r198 - trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin
by echatellier@users.forge.codelutin.com 12 Jun '14
by echatellier@users.forge.codelutin.com 12 Jun '14
12 Jun '14
Author: echatellier
Date: 2014-06-12 15:40:31 +0200 (Thu, 12 Jun 2014)
New Revision: 198
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/198
Log:
Ajout d'explication concernant l'import ldap
Modified:
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/ldap-input.jsp
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/ldap-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/ldap-input.jsp 2014-06-12 13:32:28 UTC (rev 197)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/ldap-input.jsp 2014-06-12 13:40:31 UTC (rev 198)
@@ -28,6 +28,14 @@
<html>
<head>
<title>Ldap</title>
+
+ <script type="text/javascript">
+ function disableAndSubmit() {
+ $("#submit_button").attr("disabled", true);
+ $("#submit_button").text("Mise à jour en cours...");
+ $("#main_form").submit();
+ }
+ </script>
</head>
<body>
@@ -37,14 +45,11 @@
<h1 class="page-header">Ldap</h1>
<s:form id="main_form" action="ldap" method="post">
-
- <button type="submit" class="btn btn-primary navbar-btn">Mettre à jour les groupes et utilisateurs LDAP</button>
- <nav class="navbar navbar-default navbar-fixed-bottom">
- <!-- <div class="container">
- <button type="submit" class="btn btn-primary navbar-btn pull-right">Valider</button>
- </div> -->
- </nav>
+ Cette action permet d'importer tout les utilisateurs et les groupes du serveur Active Directory dans l'application FaxToMail. Cette action peut prendre quelques minutes.
+
+ <button id="submit_button" type="button" class="btn btn-primary navbar-btn" onclick="disableAndSubmit()">Mettre à jour les groupes et utilisateurs LDAP</button>
+
</s:form>
</div>
</body>
1
0
r197 - in trunk: faxtomail-persistence/src/main/java/com/franciaflex/faxtomail faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin faxtomail-ui-web/src/main/webapp/WEB-INF/content faxtomail-ui-web/src/main/webapp/WEB-INF/decorators
by echatellier@users.forge.codelutin.com 12 Jun '14
by echatellier@users.forge.codelutin.com 12 Jun '14
12 Jun '14
Author: echatellier
Date: 2014-06-12 15:32:28 +0200 (Thu, 12 Jun 2014)
New Revision: 197
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/197
Log:
Autorisation d'acces ?\195?\160 la partie admin suivant le groupe d?\195?\169fini dans la config
Modified:
trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java
trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailSession.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/IndexAction.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LoginAction.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportAction.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/index.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/login-input.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp
Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java
===================================================================
--- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java 2014-06-12 13:32:28 UTC (rev 197)
@@ -255,7 +255,11 @@
public String getLdapBaseDn() {
return applicationConfig.getOption(FaxToMailConfigurationOption.LDAP_BASEDN.getKey());
}
-
+
+ public String getLdapAdminGroup() {
+ return applicationConfig.getOption(FaxToMailConfigurationOption.LDAP_ADMIN_GROUP.getKey());
+ }
+
public String getLdapPrincipalDomain() {
return applicationConfig.getOption(FaxToMailConfigurationOption.LDAP_PRINCIPAL_DOMAIN.getKey());
}
Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java
===================================================================
--- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java 2014-06-12 13:32:28 UTC (rev 197)
@@ -107,9 +107,13 @@
"faxtomail.ldap.basedn",
"Mot de passe pour la connexion au serveur LDAP", "DC=mac-groupe,DC=net", String.class),
+ LDAP_ADMIN_GROUP(
+ "faxtomail.ldap.admin.group",
+ "DN du groupe ldap ayant les autorisations d'accéder à la partie admin de l'interface web", null, String.class),
+
LDAP_PRINCIPAL_DOMAIN(
"faxtomail.ldap.principal.domain",
- "Mot de passe pour la connexion au serveur LDAP", "mac-groupe.net", String.class),
+ "Domaine des principals utilisés par l'authentification kerberos", "mac-groupe.net", String.class),
LDAP_TEST_PRINCIPAL(
"faxtomail.ldap.test.principal",
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java 2014-06-12 13:32:28 UTC (rev 197)
@@ -85,6 +85,10 @@
return session.getAuthenticatedFaxToMailUser() != null;
}
+ public boolean isAdmin() {
+ return session.isAdmin();
+ }
+
public FaxToMailUser getAuthenticatedUser() {
return session.getAuthenticatedFaxToMailUser();
}
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java 2014-06-12 13:32:28 UTC (rev 197)
@@ -38,6 +38,7 @@
import com.franciaflex.faxtomail.FaxToMailConfiguration;
import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaPersistenceContext;
import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser;
+import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserGroup;
import com.franciaflex.faxtomail.services.FaxToMailService;
import com.franciaflex.faxtomail.services.FaxToMailServiceContext;
import com.franciaflex.faxtomail.services.service.LdapService;
@@ -63,7 +64,6 @@
@Override
public String intercept(ActionInvocation invocation) throws Exception {
-
Object action = invocation.getAction();
if (action instanceof FaxToMailActionSupport) {
@@ -140,8 +140,17 @@
LdapService ldapService = serviceContext.newService(LdapService.class);
FaxToMailUser user = ldapService.getUserBean(faxToMailSession.getAuthenticatedUserId());
faxToMailSession.setAuthenticatedFaxToMailUser(user);
+
+ // test si l'utilisateur est admin
+ String adminGroup = serviceContext.getApplicationConfig().getLdapAdminGroup();
+ if (StringUtils.isNotBlank(adminGroup) && user.getUserGroups() != null) {
+ for (FaxToMailUserGroup group : user.getUserGroups()) {
+ if (adminGroup.equals(group.getFullPath())) {
+ faxToMailSession.setAdmin(true);
+ }
+ }
+ }
}
-
}
protected void saveLastAction(ActionInvocation invocation) {
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailSession.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailSession.java 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailSession.java 2014-06-12 13:32:28 UTC (rev 197)
@@ -41,6 +41,8 @@
protected String authenticatedUserId;
protected transient FaxToMailUser authenticatedFaxToMailUser;
+
+ protected transient boolean admin;
public Collection<String> getMessages() {
if (messages == null) {
@@ -84,4 +86,12 @@
setAuthenticatedUserId(null);
setAuthenticatedFaxToMailUser(null);
}
+
+ public boolean isAdmin() {
+ return admin;
+ }
+
+ public void setAdmin(boolean admin) {
+ this.admin = admin;
+ }
}
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/IndexAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/IndexAction.java 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/IndexAction.java 2014-06-12 13:32:28 UTC (rev 197)
@@ -32,8 +32,9 @@
import org.apache.struts2.convention.annotation.InterceptorRefs;
@InterceptorRefs({
+ @InterceptorRef("faxToMailInterceptor"),
@InterceptorRef("loginInterceptor"),
- @InterceptorRef("faxToMailStack")
+ @InterceptorRef("paramsPrepareParamsStack")
})
public class IndexAction extends FaxToMailActionSupport {
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LoginAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LoginAction.java 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LoginAction.java 2014-06-12 13:32:28 UTC (rev 197)
@@ -64,7 +64,7 @@
@Override
@Action(results = {
- @Result(type = "redirectAction", params = {"actionName", "configuration-input", "namespace", "/admin"})})
+ @Result(type = "redirectAction", params = {"actionName", "index", "namespace", "/"})})
public String execute() {
String result = SUCCESS;
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java 2014-06-12 13:32:28 UTC (rev 197)
@@ -30,6 +30,7 @@
import java.util.Map;
import com.franciaflex.faxtomail.persistence.entities.MailField;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.convention.annotation.Action;
@@ -59,8 +60,9 @@
* @since x.x
*/
@InterceptorRefs({
+ @InterceptorRef("faxToMailInterceptor"),
@InterceptorRef("loginInterceptor"),
- @InterceptorRef("faxToMailStack")
+ @InterceptorRef("paramsPrepareParamsStack")
})
public class ConfigurationAction extends FaxToMailActionSupport implements Preparable {
@@ -94,7 +96,10 @@
@Override
public void prepare() throws Exception {
-
+ // check authorization
+ if (!getSession().isAdmin()) {
+ throw new RuntimeException("Not authorized");
+ }
}
@Override
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportAction.java 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportAction.java 2014-06-12 13:32:28 UTC (rev 197)
@@ -37,12 +37,14 @@
import com.franciaflex.faxtomail.services.service.ReferentielService;
import com.franciaflex.faxtomail.web.FaxToMailActionSupport;
+import com.opensymphony.xwork2.Preparable;
@InterceptorRefs({
+ @InterceptorRef("faxToMailInterceptor"),
@InterceptorRef("loginInterceptor"),
- @InterceptorRef("faxToMailStack")
+ @InterceptorRef("paramsPrepareParamsStack")
})
-public class ImportAction extends FaxToMailActionSupport {
+public class ImportAction extends FaxToMailActionSupport implements Preparable {
private static final Log log = LogFactory.getLog(ImportAction.class);
@@ -79,6 +81,14 @@
}
@Override
+ public void prepare() throws Exception {
+ // check authorization
+ if (!getSession().isAdmin()) {
+ throw new RuntimeException("Not authorized");
+ }
+ }
+
+ @Override
@Action("import-input")
public String input() throws Exception {
return INPUT;
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java 2014-06-12 13:32:28 UTC (rev 197)
@@ -33,12 +33,14 @@
import com.franciaflex.faxtomail.services.service.LdapService;
import com.franciaflex.faxtomail.web.FaxToMailActionSupport;
+import com.opensymphony.xwork2.Preparable;
@InterceptorRefs({
+ @InterceptorRef("faxToMailInterceptor"),
@InterceptorRef("loginInterceptor"),
- @InterceptorRef("faxToMailStack")
+ @InterceptorRef("paramsPrepareParamsStack")
})
-public class LdapAction extends FaxToMailActionSupport {
+public class LdapAction extends FaxToMailActionSupport implements Preparable {
private static final Log log = LogFactory.getLog(LdapAction.class);
@@ -49,6 +51,14 @@
}
@Override
+ public void prepare() throws Exception {
+ // check authorization
+ if (!getSession().isAdmin()) {
+ throw new RuntimeException("Not authorized");
+ }
+ }
+
+ @Override
@Action("ldap-input")
public String input() throws Exception {
return INPUT;
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java 2014-06-12 13:32:28 UTC (rev 197)
@@ -44,10 +44,12 @@
import com.franciaflex.faxtomail.services.service.MailFolderService;
import com.franciaflex.faxtomail.web.FaxToMailActionSupport;
import com.google.gson.reflect.TypeToken;
+import com.opensymphony.xwork2.Preparable;
@InterceptorRefs({
+ @InterceptorRef("faxToMailInterceptor"),
@InterceptorRef("loginInterceptor"),
- @InterceptorRef("faxToMailStack")
+ @InterceptorRef("paramsPrepareParamsStack")
})
public class UserFolderAction extends FaxToMailActionSupport {
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/index.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/index.jsp 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/index.jsp 2014-06-12 13:32:28 UTC (rev 197)
@@ -33,12 +33,14 @@
<h1 class="page-header">Administration FaxToMail</h1>
<ul>
- <li><a href="<s:url action='ldap-input' namespace="/admin" />">
- <span class="fa fa-database"></span> Ldap</a></li>
- <li><a href="<s:url action='configuration-input' namespace="/admin" />">
- <span class="fa fa-cog"></span> Configuration</a></li>
- <li><a href="<s:url action='import-input' namespace="/admin" />">
- <span class="fa fa-upload"></span> Import</a></li>
+ <s:if test="admin">
+ <li><a href="<s:url action='ldap-input' namespace="/admin" />">
+ <span class="fa fa-database"></span> Ldap</a></li>
+ <li><a href="<s:url action='configuration-input' namespace="/admin" />">
+ <span class="fa fa-cog"></span> Configuration</a></li>
+ <li><a href="<s:url action='import-input' namespace="/admin" />">
+ <span class="fa fa-upload"></span> Import</a></li>
+ </s:if>
<li><a href="<s:url action='user-folder-input' namespace="/admin" />">
<span class="fa fa-folder-open"></span> Dossiers utilisateur</a></li>
</ul>
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/login-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/login-input.jsp 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/login-input.jsp 2014-06-12 13:32:28 UTC (rev 197)
@@ -40,7 +40,7 @@
<div class="form-group">
<label for="loginField" class="col-sm-2 control-label">Identifiant LDAP :</label>
<div class="col-sm-10">
- <input type="text" name="login" class="form-control" id="loginField" placeholder="nom.prenom(a)franciaflex.fr" required>
+ <input type="text" name="login" class="form-control" id="loginField" placeholder="ex: dupont" required>
</div>
</div>
<div class="form-group">
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-06-12 12:33:22 UTC (rev 196)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-06-12 13:32:28 UTC (rev 197)
@@ -55,12 +55,16 @@
<s:if test="authenticated">
<nav class="collapse navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
- <li><a href="<s:url action='ldap-input' namespace="/admin" />">
- <span class="fa fa-database"></span> Ldap</a></li>
- <li><a href="<s:url action='configuration-input' namespace="/admin" />">
- <span class="fa fa-cog"></span> Configuration</a></li>
- <li><a href="<s:url action='import-input' namespace="/admin" />">
- <span class="fa fa-upload"></span> Import</a></li>
+
+ <s:if test="admin">
+ <li><a href="<s:url action='ldap-input' namespace="/admin" />">
+ <span class="fa fa-database"></span> Ldap</a></li>
+ <li><a href="<s:url action='configuration-input' namespace="/admin" />">
+ <span class="fa fa-cog"></span> Configuration</a></li>
+ <li><a href="<s:url action='import-input' namespace="/admin" />">
+ <span class="fa fa-upload"></span> Import</a></li>
+ </s:if>
+
<li><a href="<s:url action='user-folder-input' namespace="/admin" />">
<span class="fa fa-folder-open"></span> Dossiers utilisateur</a></li>
</ul>
1
0
r196 - trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service
by echatellier@users.forge.codelutin.com 12 Jun '14
by echatellier@users.forge.codelutin.com 12 Jun '14
12 Jun '14
Author: echatellier
Date: 2014-06-12 14:33:22 +0200 (Thu, 12 Jun 2014)
New Revision: 196
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/196
Log:
Fix npe
Modified:
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java 2014-06-11 17:03:55 UTC (rev 195)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java 2014-06-12 12:33:22 UTC (rev 196)
@@ -174,28 +174,30 @@
userDN = searchEntry.getDN();
}
adminConnect.close();
- } else {
- throw new AuthenticationException("Utilisateur inconnu : " + login);
}
- // ouvre une connexion avec l'identification de l'utilisateur qui essaye de se connecter
- // à l'application (ca permet de vérifier l'authentification)
- LDAPConnection userConnect = new LDAPConnection();
- userConnect.connect(getApplicationConfig().getLdapHost(), getApplicationConfig().getLdapPort());
- userConnect.bind(userDN, password);
-
- if (userConnect.isConnected()) {
- // update in database
- FaxToMailUser user = updateUserFormLdap(searchEntry, login);
- getPersistenceContext().commit();
-
- // return copy without sensible informations
- Binder<FaxToMailUser, FaxToMailUser> faxToMailUserBinder = BinderFactory.newBinder(FaxToMailUser.class);
- result = new FaxToMailUserImpl();
- faxToMailUserBinder.copyExcluding(user, result);
- userConnect.close();
+ if (searchEntry != null) {
+ // ouvre une connexion avec l'identification de l'utilisateur qui essaye de se connecter
+ // à l'application (ca permet de vérifier l'authentification)
+ LDAPConnection userConnect = new LDAPConnection();
+ userConnect.connect(getApplicationConfig().getLdapHost(), getApplicationConfig().getLdapPort());
+ userConnect.bind(userDN, password);
+
+ if (userConnect.isConnected()) {
+ // update in database
+ FaxToMailUser user = updateUserFormLdap(searchEntry, login);
+ getPersistenceContext().commit();
+
+ // return copy without sensible informations
+ Binder<FaxToMailUser, FaxToMailUser> faxToMailUserBinder = BinderFactory.newBinder(FaxToMailUser.class);
+ result = new FaxToMailUserImpl();
+ faxToMailUserBinder.copyExcluding(user, result);
+ userConnect.close();
+ } else {
+ throw new AuthenticationException("Not connected");
+ }
} else {
- throw new AuthenticationException("Not connected");
+ throw new AuthenticationException("Utilisateur inconnu : " + login);
}
} catch (LDAPException ex) {
1
0
r195 - in trunk: faxtomail-persistence/src/main/java/com/franciaflex/faxtomail faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ldap faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service
by echatellier@users.forge.codelutin.com 11 Jun '14
by echatellier@users.forge.codelutin.com 11 Jun '14
11 Jun '14
Author: echatellier
Date: 2014-06-11 19:03:55 +0200 (Wed, 11 Jun 2014)
New Revision: 195
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/195
Log:
Import des utilisateurs et groupe du ldap (tous !!!)
Removed:
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ldap/LdapUser.java
trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/LdapServiceTest.java
Modified:
trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java
trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java
Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java
===================================================================
--- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java 2014-06-11 16:00:34 UTC (rev 194)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java 2014-06-11 17:03:55 UTC (rev 195)
@@ -251,6 +251,14 @@
public String getLdapPassword() {
return applicationConfig.getOption(FaxToMailConfigurationOption.LDAP_PASSWORD.getKey());
}
+
+ public String getLdapBaseDn() {
+ return applicationConfig.getOption(FaxToMailConfigurationOption.LDAP_BASEDN.getKey());
+ }
+
+ public String getLdapPrincipalDomain() {
+ return applicationConfig.getOption(FaxToMailConfigurationOption.LDAP_PRINCIPAL_DOMAIN.getKey());
+ }
public String getLdapTestPrincipal() {
return applicationConfig.getOption(FaxToMailConfigurationOption.LDAP_TEST_PRINCIPAL.getKey());
Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java
===================================================================
--- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java 2014-06-11 16:00:34 UTC (rev 194)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java 2014-06-11 17:03:55 UTC (rev 195)
@@ -103,6 +103,14 @@
"faxtomail.ldap.password",
"Mot de passe pour la connexion au serveur LDAP", null, String.class),
+ LDAP_BASEDN(
+ "faxtomail.ldap.basedn",
+ "Mot de passe pour la connexion au serveur LDAP", "DC=mac-groupe,DC=net", String.class),
+
+ LDAP_PRINCIPAL_DOMAIN(
+ "faxtomail.ldap.principal.domain",
+ "Mot de passe pour la connexion au serveur LDAP", "mac-groupe.net", String.class),
+
LDAP_TEST_PRINCIPAL(
"faxtomail.ldap.test.principal",
"Principal de test pour forcer un utilsateur particulier", null, String.class),
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java 2014-06-11 16:00:34 UTC (rev 194)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationService.java 2014-06-11 17:03:55 UTC (rev 195)
@@ -211,7 +211,7 @@
public List<FaxToMailUser> getAllUsers() {
FaxToMailUserTopiaDao faxToMailUserDao = getPersistenceContext().getFaxToMailUserDao();
- return faxToMailUserDao.forAll().setOrderByArguments(FaxToMailUser.PROPERTY_FIRST_NAME, FaxToMailUser.PROPERTY_LAST_NAME).find(0, 50);
+ return faxToMailUserDao.forAll().setOrderByArguments(FaxToMailUser.PROPERTY_FIRST_NAME, FaxToMailUser.PROPERTY_LAST_NAME).findAll();
}
public void saveUserFolders(Map<String, Collection<MailFolder>> userFolders) {
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java 2014-06-11 16:00:34 UTC (rev 194)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java 2014-06-11 17:03:55 UTC (rev 195)
@@ -42,7 +42,6 @@
import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserTopiaDao;
import com.franciaflex.faxtomail.services.FaxToMailServiceSupport;
import com.franciaflex.faxtomail.services.service.ldap.AuthenticationException;
-import com.franciaflex.faxtomail.services.service.ldap.LdapUser;
import com.unboundid.ldap.sdk.LDAPConnection;
import com.unboundid.ldap.sdk.LDAPException;
import com.unboundid.ldap.sdk.LDAPSearchException;
@@ -55,82 +54,42 @@
private static final Log log = LogFactory.getLog(LdapService.class);
/**
- * Get ldap connection.
- *
- * @return
- * @throws LDAPException
+ * Update all user and group from ldap.
*/
- protected LDAPConnection getLDAPConnection() throws LDAPException {
- // host, port, username and password
- return new LDAPConnection(getApplicationConfig().getLdapHost(),
- getApplicationConfig().getLdapPort(),
- getApplicationConfig().getLdapUser(),
- getApplicationConfig().getLdapPassword());
- }
+ public void updateLdapData() {
- /**
- * Get all user from ldap.
- *
- * @return ldap users with group infos
- */
- public Collection<LdapUser> getAllLdapUsers() {
- Collection<LdapUser> results = new ArrayList<>();
-
- // ldapsearch -h ldap.codelutin.home -b "ou=People,DC=codelutin,DC=home" "objectClass=posixGroup"
- // ldapsearch -h ldap.codelutin.home -b "ou=People,DC=codelutin,DC=home" "objectClass=account"
- String[] baseDNs = {
- "OU=Utilisateurs,OU=Faber,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net",
- "OU=OU Informatique,OU=France-Fermetures,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net",
-
- // OU=Franciaflex,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net
- "OU=Utilisateurs,OU=Carros,OU=Franciaflex,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net",
- "OU=Utilisateurs,OU=Checy,OU=Franciaflex,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net",
- "OU=Utilisateurs,OU=Guipry,OU=Franciaflex,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net",
- "OU=Utilisateurs,OU=LeRheu,OU=Franciaflex,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net",
- "OU=Utilisateurs,OU=Luzech,OU=Franciaflex,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net",
- "OU=Utilisateurs,OU=MaisonAlfort,OU=Franciaflex,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net",
- "OU=Utilisateurs,OU=Mauguio,OU=Franciaflex,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net",
- "OU=Utilisateurs,OU=Migennes,OU=Franciaflex,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net",
- "OU=Utilisateurs,OU=Nomades,OU=Franciaflex,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net",
- "OU=Utilisateurs,OU=RocheToirin,OU=Franciaflex,OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net"
- };
- String filter = "(objectClass=user)";
-
LDAPConnection connection = null;
try {
- connection = getLDAPConnection();
+ connection = new LDAPConnection(getApplicationConfig().getLdapHost(),
+ getApplicationConfig().getLdapPort(),
+ getApplicationConfig().getLdapUser(),
+ getApplicationConfig().getLdapPassword());
if (connection.isConnected()) {
- for (String baseDN : baseDNs) {
- SearchResult searchResult = connection.search(baseDN, SearchScope.ONE, filter);
+ String baseDN = "OU=Utilisateurs,OU=Mac-Groupe,DC=mac-groupe,DC=net";
+ // on recupere d'abord les organisationUnit
+ SearchResult unitResult = connection.search(baseDN, SearchScope.SUB, "(objectClass=organizationalUnit)");
+ List<SearchResultEntry> unitEntries = unitResult.getSearchEntries();
+ for (SearchResultEntry unitEntry : unitEntries) {
+ if (log.isDebugEnabled()) {
+ log.debug("Search for unit " + unitEntry.getDN());
+ }
+ SearchResult userResult = connection.search(unitEntry.getDN(), SearchScope.ONE, "(objectClass=user)");
- List<SearchResultEntry> searchEntries = searchResult.getSearchEntries();
- for (SearchResultEntry searchEntry : searchEntries) {
- LdapUser user = new LdapUser();
- user.setLogin(searchEntry.getAttributeValue("sn"));
+ List<SearchResultEntry> userEntries = userResult.getSearchEntries();
+ for (SearchResultEntry userEntry : userEntries) {
- // Parse name
- String fullName = searchEntry.getAttributeValue("name");
- if (fullName.indexOf(' ') != -1) {
- String lastName = fullName.substring(0, fullName.indexOf(' '));
- String firstName = fullName.substring(fullName.indexOf(' ') + 1);
- user.setFirstName(firstName);
- user.setLastName(lastName);
+ String login = userEntry.getAttributeValue("sn");
+ if (login == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("Null sn for DN " + userEntry.getDN());
+ }
} else {
- user.setFirstName("");
- user.setLastName(fullName);
+ updateUserFormLdap(userEntry, login);
}
-
- // parse groups
- String[] groups = searchEntry.getAttributeValues("memberOf");
- if (ArrayUtils.isNotEmpty(groups)) {
- for (String group : groups) {
- user.addGroup(group);
- }
- }
-
- results.add(user);
}
}
+
+ getPersistenceContext().commit();
}
} catch (LDAPException ex) {
throw new RuntimeException("Can't connect to ldap", ex);
@@ -139,72 +98,9 @@
connection.close();
}
}
-
- return results;
}
/**
- * Recupere les utilisateurs/groupes du ldap et met à jour la base locale.
- */
- public void updateLdapData() {
- if (StringUtils.isBlank(getApplicationConfig().getLdapHost())) {
- if (log.isDebugEnabled()) {
- log.debug("Ldap service not configured !");
- }
- return;
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Updating user data from ldap");
- }
- }
-
- Collection<LdapUser> ldapUsers = getAllLdapUsers();
-
- FaxToMailUserTopiaDao faxtomailUserDao = getPersistenceContext().getFaxToMailUserDao();
- FaxToMailUserGroupTopiaDao faxToMailUserGroupDao = getPersistenceContext().getFaxToMailUserGroupDao();
- Binder<FaxToMailUser, FaxToMailUser> userBinder = BinderFactory.newBinder(FaxToMailUser.class);
- for (LdapUser ldapUser : ldapUsers) {
-
- // manage user from login
- FaxToMailUser user = faxtomailUserDao.forLoginEquals(ldapUser.getLogin()).findUniqueOrNull();
- if (user == null) {
- user = new FaxToMailUserImpl();
- }
-
- // FIXME echatellier 20140601 : it's not necessary to save user in database if information didn't change
- userBinder.copyExcluding(ldapUser, user,
- FaxToMailUser.PROPERTY_TOPIA_ID,
- FaxToMailUser.PROPERTY_TOPIA_CREATE_DATE,
- FaxToMailUser.PROPERTY_TOPIA_VERSION,
- FaxToMailUser.PROPERTY_USER_GROUPS);
-
- // manage user group
- Collection<String> groups = ldapUser.getGroups();
- user.clearUserGroups();
- for (String group : groups) {
- String groupPath = getGroupFullPath(group);
- String groupName = StringUtils.substringAfterLast(groupPath, "/");
- FaxToMailUserGroup userGroup = faxToMailUserGroupDao.forNameEquals(groupName).findUniqueOrNull();
- if (userGroup == null) {
- userGroup = faxToMailUserGroupDao.create(
- FaxToMailUserGroup.PROPERTY_NAME, groupName,
- FaxToMailUserGroup.PROPERTY_FULL_PATH, groupPath);
- }
- user.addUserGroups(userGroup);
- }
-
- // persist user
- if (user.isPersisted()) {
- faxtomailUserDao.update(user);
- } else {
- faxtomailUserDao.create(user);
- }
- }
-
- getPersistenceContext().commit();
- }
-
- /**
* Transform group CN to group path.
*
* Example:
@@ -215,10 +111,18 @@
* @return
*/
protected String getGroupFullPath(String groupCN) {
- String[] part = groupCN.split(",");
- ArrayUtils.reverse(part);
- String result = StringUtils.join(part, '/');
- return result;
+ String[] parts = groupCN.split(",");
+ ArrayUtils.reverse(parts);
+
+ // join tab
+ String separator = "";
+ StringBuilder result = new StringBuilder();
+ for (String part : parts) {
+ result.append(separator);
+ result.append(StringUtils.substringAfter(part, "="));
+ separator = "/";
+ }
+ return result.toString();
}
/**
@@ -241,7 +145,7 @@
}
/**
- * Authenticate user.
+ * Authenticate and update ldap user.
*
* @param login login
* @param password password
@@ -262,34 +166,36 @@
String userDN = null;
SearchResultEntry searchEntry = null;
if (adminConnect.isConnected()) {
+ // sn est le login interne à franciaflex
String filter = String.format("(sn=%s)", login);
- SearchResult searchResult = adminConnect.search("DC=mac-groupe,DC=net", SearchScope.SUB, filter);
+ SearchResult searchResult = adminConnect.search(getApplicationConfig().getLdapBaseDn(), SearchScope.SUB, filter);
if (!searchResult.getSearchEntries().isEmpty()) {
searchEntry = searchResult.getSearchEntries().get(0);
userDN = searchEntry.getDN();
}
adminConnect.close();
+ } else {
+ throw new AuthenticationException("Utilisateur inconnu : " + login);
}
- if (searchEntry != null) {
- // ouvre une connexion avec l'identification de l'utilisateur qui essaye de se connecter
- // à l'application (ca permet de vérifier l'authentification)
- LDAPConnection userConnect = new LDAPConnection();
- userConnect.connect(getApplicationConfig().getLdapHost(), getApplicationConfig().getLdapPort());
- userConnect.bind(userDN, password);
-
- if (userConnect.isConnected()) {
- FaxToMailUser user = updateUserFormLdap(searchEntry, login);
-
- Binder<FaxToMailUser, FaxToMailUser> faxToMailUserBinder = BinderFactory.newBinder(FaxToMailUser.class);
- result = new FaxToMailUserImpl();
- faxToMailUserBinder.copyExcluding(user, result);
- userConnect.close();
- } else {
- throw new AuthenticationException("Not connected");
- }
+ // ouvre une connexion avec l'identification de l'utilisateur qui essaye de se connecter
+ // à l'application (ca permet de vérifier l'authentification)
+ LDAPConnection userConnect = new LDAPConnection();
+ userConnect.connect(getApplicationConfig().getLdapHost(), getApplicationConfig().getLdapPort());
+ userConnect.bind(userDN, password);
+
+ if (userConnect.isConnected()) {
+ // update in database
+ FaxToMailUser user = updateUserFormLdap(searchEntry, login);
+ getPersistenceContext().commit();
+
+ // return copy without sensible informations
+ Binder<FaxToMailUser, FaxToMailUser> faxToMailUserBinder = BinderFactory.newBinder(FaxToMailUser.class);
+ result = new FaxToMailUserImpl();
+ faxToMailUserBinder.copyExcluding(user, result);
+ userConnect.close();
} else {
- throw new AuthenticationException("Utilisateur inconnu : " + login);
+ throw new AuthenticationException("Not connected");
}
} catch (LDAPException ex) {
@@ -300,42 +206,16 @@
}
return result;
}
-
- protected FaxToMailUser updateUserFormLdap(SearchResultEntry searchEntry, String login) throws LDAPSearchException {
- FaxToMailUser result = null;
-
- // create or
- FaxToMailUserTopiaDao faxtomailUserDao = getPersistenceContext().getFaxToMailUserDao();
- result = faxtomailUserDao.forLoginEquals(login).findUniqueOrNull();
-
- if (result == null) {
- result = new FaxToMailUserImpl();
- result.setLogin(login);
- }
-
- // update other ldap fields
- String fullName = searchEntry.getAttributeValue("name");
- if (fullName.indexOf(' ') != -1) {
- String lastName = fullName.substring(0, fullName.indexOf(' '));
- String firstName = fullName.substring(fullName.indexOf(' ') + 1);
- result.setFirstName(firstName);
- result.setLastName(lastName);
- } else {
- result.setFirstName("");
- result.setLastName(fullName);
- }
-
- if (result.isPersisted()) {
- result = faxtomailUserDao.update(result);
- } else {
- result = faxtomailUserDao.create(result);
- }
- getPersistenceContext().commit();
-
- return result;
- }
-
+ /**
+ * Retreive user from principal and updated user database instance.
+ *
+ * This method doesn't require any password.
+ *
+ * @param principal user principal (without domain)
+ * @return user instance
+ * @throws AuthenticationException is user can't be found in ldap
+ */
public FaxToMailUser getUserFromPrincipal(String principal) throws AuthenticationException {
FaxToMailUser result = null;
@@ -350,25 +230,29 @@
String login = null;
SearchResultEntry searchEntry = null;
if (adminConnect.isConnected()) {
- String filter = String.format("(userPrincipalName=%s@%s)", principal, "mac-groupe.net");
- SearchResult searchResult = adminConnect.search("DC=mac-groupe,DC=net", SearchScope.SUB, filter);
+ // userPrincipalName est l'identifiant kerberos
+ // xxx(a)mac-groupe.net
+ String filter = String.format("(userPrincipalName=%s@%s)", principal, getApplicationConfig().getLdapPrincipalDomain());
+ SearchResult searchResult = adminConnect.search(getApplicationConfig().getLdapBaseDn(), SearchScope.SUB, filter);
if (!searchResult.getSearchEntries().isEmpty()) {
searchEntry = searchResult.getSearchEntries().get(0);
+ // sn est le 'login' interne a franciaflex
login = searchEntry.getAttributeValue("sn");
}
adminConnect.close();
- }
-
- if (searchEntry != null) {
- FaxToMailUser user = updateUserFormLdap(searchEntry, login);
-
- Binder<FaxToMailUser, FaxToMailUser> faxToMailUserBinder = BinderFactory.newBinder(FaxToMailUser.class);
- result = new FaxToMailUserImpl();
- faxToMailUserBinder.copyExcluding(user, result);
} else {
throw new AuthenticationException("Utilisateur inconnu : " + principal);
}
+ // update in database
+ FaxToMailUser user = updateUserFormLdap(searchEntry, login);
+ getPersistenceContext().commit();
+
+ // return copy without sensible informations
+ Binder<FaxToMailUser, FaxToMailUser> faxToMailUserBinder = BinderFactory.newBinder(FaxToMailUser.class);
+ result = new FaxToMailUserImpl();
+ faxToMailUserBinder.copyExcluding(user, result);
+
} catch (LDAPException ex) {
if (log.isWarnEnabled()) {
log.warn("Can't login to ldap", ex);
@@ -377,4 +261,64 @@
}
return result;
}
+
+ /**
+ * Update user (or create) in database from ldap search result entry.
+ *
+ * @param searchEntry entry containing data
+ * @param login login
+ * @return updated user
+ * @throws LDAPSearchException
+ */
+ protected FaxToMailUser updateUserFormLdap(SearchResultEntry searchEntry, String login) throws LDAPSearchException {
+
+ FaxToMailUser user = null;
+
+ // create or
+ FaxToMailUserTopiaDao faxtomailUserDao = getPersistenceContext().getFaxToMailUserDao();
+ FaxToMailUserGroupTopiaDao faxtomailUserGroupDao = getPersistenceContext().getFaxToMailUserGroupDao();
+ user = faxtomailUserDao.forLoginEquals(login).findUniqueOrNull();
+
+ if (user == null) {
+ user = new FaxToMailUserImpl();
+ user.setLogin(login);
+ }
+
+ // update other ldap fields
+ String fullName = searchEntry.getAttributeValue("name");
+ if (fullName.indexOf(' ') != -1) {
+ String lastName = fullName.substring(0, fullName.indexOf(' '));
+ String firstName = fullName.substring(fullName.indexOf(' ') + 1);
+ user.setFirstName(firstName);
+ user.setLastName(lastName);
+ } else {
+ user.setFirstName("");
+ user.setLastName(fullName);
+ }
+
+ // manage user groups
+ user.clearUserGroups();
+ String[] groups = searchEntry.getAttributeValues("memberOf");
+ if (ArrayUtils.isNotEmpty(groups)) {
+ for (String group : groups) {
+ String groupPath = getGroupFullPath(group);
+ String groupName = StringUtils.substringAfterLast(groupPath, "/");
+ FaxToMailUserGroup userGroup = faxtomailUserGroupDao.forNameEquals(groupName).findUniqueOrNull();
+ if (userGroup == null) {
+ userGroup = faxtomailUserGroupDao.create(
+ FaxToMailUserGroup.PROPERTY_NAME, groupName,
+ FaxToMailUserGroup.PROPERTY_FULL_PATH, groupPath);
+ }
+ user.addUserGroups(userGroup);
+ }
+ }
+
+ if (user.isPersisted()) {
+ user = faxtomailUserDao.update(user);
+ } else {
+ user = faxtomailUserDao.create(user);
+ }
+
+ return user;
+ }
}
Deleted: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ldap/LdapUser.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ldap/LdapUser.java 2014-06-11 16:00:34 UTC (rev 194)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ldap/LdapUser.java 2014-06-11 17:03:55 UTC (rev 195)
@@ -1,47 +0,0 @@
-package com.franciaflex.faxtomail.services.service.ldap;
-
-/*
- * #%L
- * FaxToMail :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2014 Franciaflex, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserImpl;
-
-public class LdapUser extends FaxToMailUserImpl {
-
- protected Collection<String> groups = new ArrayList<>();
-
- public Collection<String> getGroups() {
- return groups;
- }
-
- public void setGroups(Collection<String> groups) {
- this.groups = groups;
- }
-
- public void addGroup(String group) {
- this.groups.add(group);
- }
-}
Deleted: trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/LdapServiceTest.java
===================================================================
--- trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/LdapServiceTest.java 2014-06-11 16:00:34 UTC (rev 194)
+++ trunk/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/LdapServiceTest.java 2014-06-11 17:03:55 UTC (rev 195)
@@ -1,66 +0,0 @@
-package com.franciaflex.faxtomail.services.service;
-
-/*
- * #%L
- * FaxToMail :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2014 Franciaflex, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.franciaflex.faxtomail.FaxToMailConfigurationOption;
-import com.franciaflex.faxtomail.services.service.ldap.LdapUser;
-
-public class LdapServiceTest extends AbstractFaxToMailServiceTest {
-
- protected LdapService ldapService;
-
- @Before
- public void setUp() throws IOException {
- ldapService = newService(LdapService.class);
-
- // n'effectue pas les tests si la connexion n'est pas possible
- Assume.assumeTrue(StringUtils.isNotBlank(getApplicationConfig().getLdapHost()));
- }
-
- @Test
- public void testGetUsers() {
-
- Collection<LdapUser> ldapUsers = ldapService.getAllLdapUsers();
- Collection<String> groups = new HashSet<>();
- int user = 0;
- for (LdapUser ldapUser : ldapUsers) {
- System.out.println("User : " + ldapUser.getLogin());
- for (String group : ldapUser.getGroups()) {
- groups.add(group);
- }
- user++;
- }
- System.out.println(String.format("%d users, %d groups", user, groups.size()));
- }
-}
1
0