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) {