Commit e14d20f8 authored by Romain Bioteau's avatar Romain Bioteau Committed by Adrien
Browse files

feat(accessControl) validation message localization (#759)

Closes [BS-17371](https://bonitasoft.atlassian.net/browse/BS-17371)
parent 9a10a282
/**
* Copyright (C) 2017 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* 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 2.0 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/>.
*/
package org.bonitasoft.studio.ui.dialog;
import java.util.function.Function;
import org.bonitasoft.engine.api.result.Status;
public class Defaultl10nStatusFunction implements Function<Status, String> {
/*
* (non-Javadoc)
* @see java.util.function.Function#apply(java.lang.Object)
*/
@Override
public String apply(Status status) {
//No l10n, use technical message.
return status.getMessage();
}
}
......@@ -22,23 +22,17 @@ import org.eclipse.core.runtime.Status;
public class EngineStatusMapper implements Function<org.bonitasoft.engine.api.result.Status, Status> {
private Function<org.bonitasoft.engine.api.result.Status, String> l10nFunction;
private EngineStatusMapper(Function<org.bonitasoft.engine.api.result.Status, String> l10nFunction) {
this.l10nFunction = l10nFunction;
}
/*
* (non-Javadoc)
* @see java.util.function.Function#apply(java.lang.Object)
*/
@Override
public Status apply(org.bonitasoft.engine.api.result.Status engineStatus) {
return new Status(levelToSeverity(engineStatus), UIPlugin.PLUGIN_ID, l10n(engineStatus));
return new Status(levelToSeverity(engineStatus), UIPlugin.PLUGIN_ID, localizedMessage(engineStatus));
}
private String l10n(org.bonitasoft.engine.api.result.Status engineStatus) {
return l10nFunction.apply(engineStatus);
protected String localizedMessage(org.bonitasoft.engine.api.result.Status engineStatus) {
return engineStatus.getMessage();
}
private int levelToSeverity(org.bonitasoft.engine.api.result.Status engineStatus) {
......@@ -54,9 +48,4 @@ public class EngineStatusMapper implements Function<org.bonitasoft.engine.api.re
}
}
public static Function<org.bonitasoft.engine.api.result.Status, Status> instance(
Function<org.bonitasoft.engine.api.result.Status, String> l10nFunction) {
return new EngineStatusMapper(l10nFunction);
}
}
......@@ -83,7 +83,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment