package ….;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
public interface ModeloAJD {
public static final String NAMESPACE_MODELO_CONTENIDO_AJD = "http://www.miempresa.es/model/content/ajd/1.0";
/*************** TIPOS ***************/
public static final String TYPE_AJD_ESPACIOAJD = "espacioajd";
….
/*************** ASPECTOS ***************/
….
}
package ….;
import org.alfresco.webservice.repository.UpdateResult;
import org.alfresco.webservice.types.CML;
import org.alfresco.webservice.types.CMLAddAspect;
import org.alfresco.webservice.types.CMLCreate;
import org.alfresco.webservice.types.NamedValue;
import org.alfresco.webservice.types.ParentReference;
import org.alfresco.webservice.types.Reference;
import org.alfresco.webservice.types.Store;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.Utils;
import org.alfresco.webservice.util.WebServiceFactory;
import org.alfresco.webservice.types.Predicate;
import ….ModeloAJD;
import junit.framework.Assert;
/**
* Clase que crea la jerarquía de tipos de espacio para AJD
*/
public class AJDEstructuraEspacios extends AJDBase{
private static final String USAGE = "java AJDEstructuraEspacios <carpeta raiz> <nombre del contenido>";
private String contentType;
private String contentName;
public static void main(String[] args) throws Exception {
//if (args.length != 5) doUsage(AJDEstructuraEspacios.USAGE);
AJDEstructuraEspacios scdc = new AJDEstructuraEspacios();
scdc.setUser("admin");
scdc.setPassword("admin");
scdc.setRootFolder("");
try{
// Inicio la sesion
AuthenticationUtils.startSession(scdc.getUser(), scdc.getPassword());
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
ParentReference companyHomeParent = new ParentReference(storeRef, null, "/app:company_home", Constants.ASSOC_CONTAINS, null);
Reference carpetaRaizAJD = scdc.creaCarpeta(storeRef, companyHomeParent, "Asesoría Jurídica", ModeloAJD.TYPE_AJD_ESPACIOAJD, false, "");
Assert.assertNotNull(carpetaRaizAJD);
Reference carpetaProcedimientos = scdc.creaCarpeta(storeRef, damePadreRef(storeRef,carpetaRaizAJD), "Procedimientos", ModeloAJD.TYPE_AJD_PROCEDIMIENTOS, false, "");
Assert.assertNotNull(carpetaProcedimientos);
Reference carpetaAdmtvos = scdc.creaCarpeta(storeRef, damePadreRef(storeRef,carpetaProcedimientos), "Administrativos", ModeloAJD.TYPE_AJD_PROCSADMINISTRATIVOS, false, "");
Assert.assertNotNull(carpetaAdmtvos);
Reference carpetaAGPD = scdc.creaCarpeta(storeRef, damePadreRef(storeRef,carpetaAdmtvos), "Protección de datos", ModeloAJD.TYPE_AJD_AGPD, false, ModeloAJD.ASPECT_AJD_RESUMIBLE);
Assert.assertNotNull(carpetaAGPD);
} catch(Throwable e) {
System.out.println(e.toString());
e.printStackTrace();
} finally {
// End the session
System.out.println("Estructura creada.");
AuthenticationUtils.endSession();
System.exit(0);
}/**/
}
private static ParentReference damePadreRef(Store almacen,Reference carpetaRef){
return new ParentReference(almacen,carpetaRef.getUuid(),carpetaRef.getPath(),Constants.ASSOC_CONTAINS,null);
}
private Reference creaCarpeta(Store almacen, ParentReference padre, String nombreCarpeta, String tipoEspacio, Boolean heredaDelPadre, String aspecto) throws Exception
{
padre.setChildName(Constants.createQNameString(ModeloAJD.NAMESPACE_MODELO_CONTENIDO_AJD, nombreCarpeta));
NamedValue nombreProp = Utils.createNamedValue(Constants.PROP_NAME, nombreCarpeta);
NamedValue[] propiedades = new NamedValue[] {nombreProp};
CMLCreate create = new CMLCreate(
"ref1",
padre,
null,
null,
null,
Constants.createQNameString(ModeloAJD.NAMESPACE_MODELO_CONTENIDO_AJD, tipoEspacio),
propiedades);
CML cml = new CML();
cml.setCreate(new CMLCreate[]{create});
if (aspecto.length() > 0){
CMLAddAspect cmlAddAspect = new CMLAddAspect(Constants.createQNameString(ModeloAJD.NAMESPACE_MODELO_CONTENIDO_AJD, aspecto), null, null, "ref1");
cml.setAddAspect(new CMLAddAspect[] {cmlAddAspect});
}
UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);
if (heredaDelPadre){ //si queremos que el espacio NO herede permisos de su padre
Predicate p = new Predicate(new Reference[]{results[0].getDestination()}, almacen, null);
}
return results[0].getDestination();
}
public String getContentName() {
return contentName;
}
public void setContentName(String contentName) {
this.contentName = contentName;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
}
<?xml version="1.0" encoding="ISO-8859-1"?>
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.