Ya me imagino lo que pasa. Esto tiene su historia. En la versión community ahora mismo tiene un pequeño defecto en relación al path contains, el tema en que el pathcontains y el resto esta evaluando el path origen no el path destino. Por eso te funciona con un create pero no te funciona al realizar el move. Este y otros pequeños problemas de este estilo no han sido "bien" solucionados hasta lo que será la versión 6.5.
Aun así lo puedes solucionar implementando tu propio PathContains, esta es la implementación actual:
Code: Select all/**
* OpenKM, Open Document Management System (http://www.openkm.com)
* Copyright (c) 2006-2014 Paco Avila & Josep Llort
*
* No bytes were intentionally harmed during the development of this application.
*
* 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 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.openkm.automation.validation;
import java.util.Map;
import net.xeoh.plugins.base.annotations.PluginImplementation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.openkm.api.OKMRepository;
import com.openkm.automation.AutomationUtils;
import com.openkm.automation.Validation;
import com.openkm.dao.bean.Automation;
/**
* Check if the current parent path contains a designed one. The only
* parameter is a path and will test if this one is included in the
* actual parent.
*
* @author pavila
*/
@PluginImplementation
public class PathContains implements Validation {
private static Logger log = LoggerFactory.getLogger(PathContains.class);
@Override
public boolean isValid(Map<String, Object> env, Object... params) {
try {
String uuid = AutomationUtils.getString(0, params);
String parentPath = AutomationUtils.getParentPath(env);
String path = OKMRepository.getInstance().getNodePath(null, uuid);
if (parentPath.startsWith(path)) {
return true;
} else {
return false;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return false;
}
@Override
public boolean hasPost() {
return true;
}
@Override
public boolean hasPre() {
return false;
}
@Override
public String getName() {
return "PathContains";
}
@Override
public String getParamType00() {
return Automation.PARAM_TYPE_TEXT;
}
@Override
public String getParamSrc00() {
return Automation.PARAM_SOURCE_FOLDER;
}
@Override
public String getParamDesc00() {
return "String";
}
@Override
public String getParamType01() {
return Automation.PARAM_TYPE_EMPTY;
}
@Override
public String getParamSrc01() {
return Automation.PARAM_SOURCE_EMPTY;
}
@Override
public String getParamDesc01() {
return "";
}
@Override
public String getParamType02() {
return Automation.PARAM_TYPE_EMPTY;
}
@Override
public String getParamSrc02() {
return Automation.PARAM_SOURCE_EMPTY;
}
@Override
public String getParamDesc02() {
return "";
}
}
Fíjate como el parentPath se esta pillando de una variable de entorno String parentPath = AutomationUtils.getParentPath(env); , esta parte es la que te interesa, porque el parentPath que se ha almacenado es el del documento antes de que se moviese con lo cual aqui realmente lo que te interesa es obtener el path actual:
Code: Select allString docUuid = AutomationUtils.getUuid(env);
String parentPath = OKMRepository.getInstance().getNodePath(null, docUuid);
El move es un caso complicado porque no sabes si tienes que valorar el origen o el destino o ambos. Al final llegamos a la conclusión que tiene mas sentido evaluar el destino que no el origen en el caso del PathContains y en la 6.5 la lógica ya tiene en cuenta muchas mas cosas, como el tipo de evento que ha disparado la validación etc.., pero vamos que todo forma parte de la acción.
Simplemente compila la clase -> crea un jar -> crear una carpeta plugins dentro de tomcat/plugin , lo pones ahí y al reiniciar el tomcat ya te aparecerá.