Exemplo n.º 1
0
        ///// <summary>
        ///// Copia un archivo de una localización a otroa
        ///// </summary>
        ///// <param name="uuidNodeToCopy"></param>
        ///// <param name="DestinationNodePath"></param>
        ///// <returns>En DestinationNodePath se devuelve la ruta final del archivo</returns>
        //public string CopyFile(string uuidNodeToCopy, ref string DestinationNodePath)
        //{
        //    if (string.IsNullOrEmpty(uuidNodeToCopy) || string.IsNullOrEmpty(DestinationNodePath))
        //        return null;

        //    string documentId = null;
        //    RepositoryWebService.Store cwsStore = new RepositoryWebService.Store();
        //    cwsStore.address = Constants.SPACES_STORE;

        //    try
        //    {
        //        //Obtenemos la ruta donde se copiara el documento, o la creamos si no existe
        //        FolderNode nod = new FolderNode();
        //        string destNodeId = nod.CreatePathRecursive(DestinationNodePath);

        //        this.Name = GetNodeById(uuidNodeToCopy).Name;
        //        UpdateResult[] rsrDest = CreateNode(destNodeId, null, Constants.TYPE_CONTENT);


        //        ResultSetRow rsrOrigin = FindNodeById(uuidNodeToCopy);
        //        RepositoryWebService.Reference refOrigin = GetReferenceFromResultSetRow(rsrOrigin);


        //        RepositoryWebService.Predicate sourcePredicate = new RepositoryWebService.Predicate(
        //            new Alfresco.RepositoryWebService.Reference[] { refOrigin }, cwsStore, null);


        //        //reference for the target space
        //        RepositoryWebService.ParentReference targetSpace = new RepositoryWebService.ParentReference();
        //        targetSpace.store = spacesStore;
        //        targetSpace.path = DestinationNodePath;
        //        targetSpace.associationType = Constants.ASSOC_CONTAINS;
        //        targetSpace.childName = Name;



        //        //copy content
        //        CMLCopy copy = new CMLCopy();
        //        copy.where = sourcePredicate;
        //        copy.to = targetSpace;

        //        CML cmlCopy = new CML();
        //        cmlCopy.copy = new CMLCopy[] { copy };

        //        //perform a CML update to move the node
        //        UpdateResult[] updateResult = WebServiceFactory.getRepositoryService().update(cmlCopy);
        //        DestinationNodePath = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(updateResult[0].destination.path));

        //        documentId = updateResult[0].destination.uuid;
        //    }
        //    catch (SoapException ex)
        //    {
        //        if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException"))
        //        {
        //            var node = new NodeBase();
        //            var nodePath = String.Format("{0}/{1}", DestinationNodePath, this.Name);
        //            var id = node.GetIdByPath(nodePath);

        //            throw new DuplicateDocumentException(id, nodePath);
        //        }
        //        else
        //            throw ex;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }

        //    return documentId;
        //}

        //public string CopyFile(string uuidNodeToCopy, ref string DestinationNodePath)
        //{
        //    if (string.IsNullOrEmpty(uuidNodeToCopy) || string.IsNullOrEmpty(DestinationNodePath))
        //        return null;

        //    string documentId = null;

        //    try
        //    {
        //        this.Name = GetNodeById(uuidNodeToCopy).Name;

        //        //Obtenemos la ruta donde se copiara el documento, o la creamos si no existe
        //        FolderNode nod = new FolderNode();
        //        string destNodeId = nod.CreatePathRecursive(DestinationNodePath);


        //        UpdateResult[] updateNode = CreateNode(destNodeId, null, Constants.TYPE_CONTENT);

        //        //reference for the target space
        //        RepositoryWebService.ParentReference targetSpace = new RepositoryWebService.ParentReference();
        //        targetSpace.store = spacesStore;
        //        targetSpace.path = updateNode[0].destination.path;
        //        targetSpace.associationType = Constants.ASSOC_CONTAINS;
        //        targetSpace.childName = Name;



        //        RepositoryWebService.Predicate Source = new RepositoryWebService.Predicate(
        //            new Alfresco.RepositoryWebService.Reference[] { GetReferenceFromResultSetRow(FindNodeById(uuidNodeToCopy)) }, spacesStore, null);


        //        //copy content
        //        CMLCopy copy = new CMLCopy();
        //        copy.where = Source;
        //        copy.to = targetSpace;

        //        CML cmlCopy = new CML();
        //        cmlCopy.copy = new CMLCopy[] { copy };

        //        //perform a CML update to move the node
        //        RepositoryWebService.UpdateResult[] updateResult = WebServiceFactory.getRepositoryService().update(cmlCopy);
        //        DestinationNodePath = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(updateResult[0].destination.path));

        //        documentId = updateResult[0].destination.uuid;
        //    }
        //    catch (SoapException ex)
        //    {
        //        if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException"))
        //        {
        //            var node = new NodeBase();
        //            var nodePath = String.Format("{0}/{1}", DestinationNodePath, this.Name);
        //            var id = node.GetIdByPath(nodePath);

        //            throw new DuplicateDocumentException(id, nodePath);
        //        }
        //        else
        //            throw ex;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }

        //    return documentId;
        //}

        public string CopyFile(string uuidNodeToCopy, ref string DestinationNodePath)
        {
            if (string.IsNullOrEmpty(uuidNodeToCopy) || string.IsNullOrEmpty(DestinationNodePath))
            {
                return(null);
            }

            string documentId = null;

            try
            {
                this.Name = GetNodeById(uuidNodeToCopy).Name;

                //Obtenemos la ruta donde se copiara el documento, o la creamos si no existe
                FolderNode nod        = new FolderNode();
                string     destNodeId = nod.CreatePathRecursive(DestinationNodePath);

                RepositoryWebService.Predicate Source = new RepositoryWebService.Predicate(
                    new Alfresco.RepositoryWebService.Reference[] { GetReferenceFromResultSetRow(FindNodeById(uuidNodeToCopy)) },
                    spacesStore,
                    null);

                //copy content
                CMLCopy copy = new CMLCopy();
                copy.where = Source;
                copy.to    = createParentReference(destNodeId, Constants.ASSOC_CONTAINS, Name);

                CML cmlCopy = new CML();
                cmlCopy.copy = new CMLCopy[] { copy };

                //perform a CML update to move the node
                RepositoryWebService.UpdateResult[] updateResult = WebServiceFactory.getRepositoryService().update(cmlCopy);
                DestinationNodePath = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(updateResult[0].destination.path));

                documentId = updateResult[0].destination.uuid;
            }
            catch (SoapException ex)
            {
                if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException"))
                {
                    var node     = new NodeBase();
                    var nodePath = String.Format("{0}/{1}", DestinationNodePath, this.Name);
                    var id       = node.GetIdByPath(nodePath);

                    throw new DuplicateDocumentException(id, nodePath);
                }
                else
                {
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(documentId);
        }
Exemplo n.º 2
0
        private void DeleteNodes(Alfresco.RepositoryWebService.Reference[] references)
        {
            var predicate = new RepositoryWebService.Predicate(references, spacesStore, null);

            //delete content
            CMLDelete delete = new CMLDelete();

            delete.where = predicate;

            CML cmlRemove = new CML();

            cmlRemove.delete = new CMLDelete[] { delete };

            //perform a CML update to remove the node
            WebServiceFactory.getRepositoryService().update(cmlRemove);
        }
Exemplo n.º 3
0
        private void DeleteNodes(Alfresco.RepositoryWebService.Reference[] references)
        {
            var predicate = new RepositoryWebService.Predicate(references, spacesStore, null);

            //delete content
            CMLDelete delete = new CMLDelete();
            delete.where = predicate;

            CML cmlRemove = new CML();
            cmlRemove.delete = new CMLDelete[] { delete };

            //perform a CML update to remove the node
            WebServiceFactory.getRepositoryService().update(cmlRemove);
        }
Exemplo n.º 4
0
        ///// <summary>
        ///// Copia un archivo de una localización a otroa
        ///// </summary>
        ///// <param name="uuidNodeToCopy"></param>
        ///// <param name="DestinationNodePath"></param>
        ///// <returns>En DestinationNodePath se devuelve la ruta final del archivo</returns>
        //public string CopyFile(string uuidNodeToCopy, ref string DestinationNodePath)
        //{
        //    if (string.IsNullOrEmpty(uuidNodeToCopy) || string.IsNullOrEmpty(DestinationNodePath))
        //        return null;
        //    string documentId = null;
        //    RepositoryWebService.Store cwsStore = new RepositoryWebService.Store();
        //    cwsStore.address = Constants.SPACES_STORE;
        //    try
        //    {
        //        //Obtenemos la ruta donde se copiara el documento, o la creamos si no existe
        //        FolderNode nod = new FolderNode();
        //        string destNodeId = nod.CreatePathRecursive(DestinationNodePath);
        //        this.Name = GetNodeById(uuidNodeToCopy).Name;
        //        UpdateResult[] rsrDest = CreateNode(destNodeId, null, Constants.TYPE_CONTENT);
        //        ResultSetRow rsrOrigin = FindNodeById(uuidNodeToCopy);
        //        RepositoryWebService.Reference refOrigin = GetReferenceFromResultSetRow(rsrOrigin);
        //        RepositoryWebService.Predicate sourcePredicate = new RepositoryWebService.Predicate(
        //            new Alfresco.RepositoryWebService.Reference[] { refOrigin }, cwsStore, null);
        //        //reference for the target space
        //        RepositoryWebService.ParentReference targetSpace = new RepositoryWebService.ParentReference();
        //        targetSpace.store = spacesStore;
        //        targetSpace.path = DestinationNodePath;
        //        targetSpace.associationType = Constants.ASSOC_CONTAINS;
        //        targetSpace.childName = Name;
        //        //copy content
        //        CMLCopy copy = new CMLCopy();
        //        copy.where = sourcePredicate;
        //        copy.to = targetSpace;
        //        CML cmlCopy = new CML();
        //        cmlCopy.copy = new CMLCopy[] { copy };
        //        //perform a CML update to move the node
        //        UpdateResult[] updateResult = WebServiceFactory.getRepositoryService().update(cmlCopy);
        //        DestinationNodePath = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(updateResult[0].destination.path));
        //        documentId = updateResult[0].destination.uuid;
        //    }
        //    catch (SoapException ex)
        //    {
        //        if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException"))
        //        {
        //            var node = new NodeBase();
        //            var nodePath = String.Format("{0}/{1}", DestinationNodePath, this.Name);
        //            var id = node.GetIdByPath(nodePath);
        //            throw new DuplicateDocumentException(id, nodePath);
        //        }
        //        else
        //            throw ex;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //    return documentId;
        //}
        //public string CopyFile(string uuidNodeToCopy, ref string DestinationNodePath)
        //{
        //    if (string.IsNullOrEmpty(uuidNodeToCopy) || string.IsNullOrEmpty(DestinationNodePath))
        //        return null;
        //    string documentId = null;
        //    try
        //    {
        //        this.Name = GetNodeById(uuidNodeToCopy).Name;
        //        //Obtenemos la ruta donde se copiara el documento, o la creamos si no existe
        //        FolderNode nod = new FolderNode();
        //        string destNodeId = nod.CreatePathRecursive(DestinationNodePath);
        //        UpdateResult[] updateNode = CreateNode(destNodeId, null, Constants.TYPE_CONTENT);
        //        //reference for the target space
        //        RepositoryWebService.ParentReference targetSpace = new RepositoryWebService.ParentReference();
        //        targetSpace.store = spacesStore;
        //        targetSpace.path = updateNode[0].destination.path;
        //        targetSpace.associationType = Constants.ASSOC_CONTAINS;
        //        targetSpace.childName = Name;
        //        RepositoryWebService.Predicate Source = new RepositoryWebService.Predicate(
        //            new Alfresco.RepositoryWebService.Reference[] { GetReferenceFromResultSetRow(FindNodeById(uuidNodeToCopy)) }, spacesStore, null);
        //        //copy content
        //        CMLCopy copy = new CMLCopy();
        //        copy.where = Source;
        //        copy.to = targetSpace;
        //        CML cmlCopy = new CML();
        //        cmlCopy.copy = new CMLCopy[] { copy };
        //        //perform a CML update to move the node
        //        RepositoryWebService.UpdateResult[] updateResult = WebServiceFactory.getRepositoryService().update(cmlCopy);
        //        DestinationNodePath = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(updateResult[0].destination.path));
        //        documentId = updateResult[0].destination.uuid;
        //    }
        //    catch (SoapException ex)
        //    {
        //        if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException"))
        //        {
        //            var node = new NodeBase();
        //            var nodePath = String.Format("{0}/{1}", DestinationNodePath, this.Name);
        //            var id = node.GetIdByPath(nodePath);
        //            throw new DuplicateDocumentException(id, nodePath);
        //        }
        //        else
        //            throw ex;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //    return documentId;
        //}
        public string CopyFile(string uuidNodeToCopy, ref string DestinationNodePath)
        {
            if (string.IsNullOrEmpty(uuidNodeToCopy) || string.IsNullOrEmpty(DestinationNodePath))
                return null;

            string documentId = null;

            try
            {
                this.Name = GetNodeById(uuidNodeToCopy).Name;

                //Obtenemos la ruta donde se copiara el documento, o la creamos si no existe
                FolderNode nod = new FolderNode();
                string destNodeId = nod.CreatePathRecursive(DestinationNodePath);

                RepositoryWebService.Predicate Source = new RepositoryWebService.Predicate(
                    new Alfresco.RepositoryWebService.Reference[] { GetReferenceFromResultSetRow(FindNodeById(uuidNodeToCopy)) },
                    spacesStore,
                    null);

                //copy content
                CMLCopy copy = new CMLCopy();
                copy.where = Source;
                copy.to = createParentReference(destNodeId, Constants.ASSOC_CONTAINS, Name);

                CML cmlCopy = new CML();
                cmlCopy.copy = new CMLCopy[] { copy };

                //perform a CML update to move the node
                RepositoryWebService.UpdateResult[] updateResult = WebServiceFactory.getRepositoryService().update(cmlCopy);
                DestinationNodePath = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(updateResult[0].destination.path));

                documentId = updateResult[0].destination.uuid;
            }
            catch (SoapException ex)
            {
                if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException"))
                {
                    var node = new NodeBase();
                    var nodePath = String.Format("{0}/{1}", DestinationNodePath, this.Name);
                    var id = node.GetIdByPath(nodePath);

                    throw new DuplicateDocumentException(id, nodePath);
                }
                else
                    throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return documentId;
        }