Пример #1
0
        private void writeContentType(String filePath, Alfresco.RepositoryWebService.Reference rwsRef,
                                      String property, String mimetype)
        {
            Alfresco.ContentWebService.Reference newContentNode = new Alfresco.ContentWebService.Reference();
            newContentNode.path = rwsRef.path;
            newContentNode.uuid = rwsRef.uuid;

            Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store();
            cwsStore.address     = "SpacesStore";
            spacesStore.scheme   = Alfresco.RepositoryWebService.StoreEnum.workspace;
            newContentNode.store = cwsStore;

            // Open the file and convert to byte array
            FileStream inputStream = new FileStream(filePath, FileMode.Open);

            int bufferSize = (int)inputStream.Length;

            byte[] bytes = new byte[bufferSize];
            inputStream.Read(bytes, 0, bufferSize);
            inputStream.Close();

            ContentFormat contentFormat = new ContentFormat();

            contentFormat.mimetype = mimetype;
            WebServiceFactory.getContentService().write(newContentNode, property, bytes, contentFormat);
        }
Пример #2
0
        /// <summary>
        /// Guarda un fichero en el nodo especificado
        /// </summary>
        /// <param name="parentId">uuid del nodo donde queremos guardar el documento</param>
        /// <param name="documentPath">Ruta local de la que se debe sacar el fichero, aquí se devuelve la ruta del repositorio donde se ha guardado el  documento</param>
        /// <param name="document">raw document, si este valor es null se intentará leer el documento del documentPath</param>
        /// <returns>uuid del documento que se ha salvado</returns>
        public string CreateFileByParentId(string parentId, ref string documentName, byte[] document)
        {
            if (document == null)
            {
                return(null);
            }

            string documentId = null;
            var    mimeType   = new MimetypeMap();

            try
            {
                UpdateResult[] updateResult = CreateNode(parentId, null, Constants.TYPE_CONTENT);

                // work around to cast Alfresco.RepositoryWebService.Reference to Alfresco.ContentWebService.Reference
                RepositoryWebService.Reference rwsRef         = updateResult[0].destination;
                ContentWebService.Reference    newContentNode = new Alfresco.ContentWebService.Reference();
                newContentNode.path = rwsRef.path;
                newContentNode.uuid = rwsRef.uuid;
                ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store();
                cwsStore.address     = Constants.SPACES_STORE;
                newContentNode.store = cwsStore;

                var contentFormat = new Alfresco.ContentWebService.ContentFormat();
                contentFormat.mimetype = mimeType.GuessMimetype(Name);

                Content lContent = WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, document, contentFormat);
                documentName = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(lContent.node.path));
                documentId   = lContent.node.uuid;
            }
            catch (SoapException ex)
            {
                if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException"))
                {
                    var node     = new NodeBase();
                    var nodePath = String.Format("{0}/{1}", node.GetPathById(parentId), System.IO.Path.GetFileName(documentName));
                    var id       = node.GetIdByPath(nodePath);

                    throw new DuplicateDocumentException(id, nodePath);
                }
                else
                {
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(documentId);
        }
Пример #3
0
        /// <summary>
        /// Double click event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listViewBrowse_DoubleClick(object sender, EventArgs e)
        {
            ListViewItem item = listViewBrowse.SelectedItems[0];

            if (item != null)
            {
                ResultSetRowNode node = item.Tag as ResultSetRowNode;
                if (node != null)
                {
                    if (node.type.Contains("folder") == true)
                    {
                        // Create the reference for the node selected
                        Alfresco.RepositoryWebService.Reference reference = new Alfresco.RepositoryWebService.Reference();
                        reference.store = this.spacesStore;
                        reference.uuid  = node.id;

                        // Parent references
                        this.parentReferences.Add(this.currentReference);

                        // Populate the list with the children of the selected node
                        populateListBox(reference);
                    }
                    else
                    {
                        // Create the reference for the node selected
                        Alfresco.ContentWebService.Store spacesStore2 = new Alfresco.ContentWebService.Store();
                        spacesStore2.scheme  = Alfresco.ContentWebService.StoreEnum.workspace;
                        spacesStore2.address = "SpacesStore";

                        Alfresco.ContentWebService.Reference reference = new Alfresco.ContentWebService.Reference();
                        reference.store = spacesStore2;
                        reference.uuid  = node.id;

                        // Lets try and get the content
                        Alfresco.ContentWebService.Predicate predicate = new Alfresco.ContentWebService.Predicate();
                        predicate.Items = new Object[] { reference };
                        Content[] contents = this.contentService.read(predicate, "{http://www.alfresco.org/model/content/1.0}content");
                        Content   content  = contents[0];
                        if (content.url != null && content.url.Length != 0)
                        {
                            string url = content.url + "?ticket=" + AuthenticationUtils.Ticket;
                            webBrowser.Url = new Uri(url);
                        }
                    }
                }
            }
        }
Пример #4
0
        private Content UpdateDocument(Alfresco.RepositoryWebService.Reference reference, byte[] document)
        {
            MimetypeMap mimeType = new MimetypeMap();

            var newContentNode = new Alfresco.ContentWebService.Reference();

            newContentNode.path = reference.path;
            newContentNode.uuid = reference.uuid;
            Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store();
            cwsStore.address     = Constants.SPACES_STORE;
            newContentNode.store = cwsStore;

            var contentFormat = new Alfresco.ContentWebService.ContentFormat();

            contentFormat.mimetype = mimeType.GuessMimetype(Name);

            return(WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, document, contentFormat));
        }
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                String file = this.textBox1.Text;

                if (file.Equals(""))
                {
                    MessageBox.Show("Please select a file");
                    this.btnSelect.Focus();
                    return;
                }

                if (this.tbLocation.Text.Equals(""))
                {
                    MessageBox.Show("Please select the location");
                    this.btnLocation.Focus();
                    return;
                }

                int start = file.LastIndexOf("\\") + 1;
                int length = file.Length - start;
                // get the filename only
                String fileName = file.Substring(start, length);

                if (file == null || file.Equals(""))
                {
                    MessageBox.Show("please select a file");
                    return;
                }
                // Display a wait cursor while the file is uploaded
                Cursor.Current = Cursors.WaitCursor;

                // Initialise the reference to the spaces store
                Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store();
                spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace;
                spacesStore.address = "SpacesStore";

                // Create the parent reference, the company home folder
                Alfresco.RepositoryWebService.ParentReference parentReference = new Alfresco.RepositoryWebService.ParentReference();
                parentReference.store = spacesStore;
                //                parentReference.path = "/app:company_home";
                parentReference.uuid = this.locationUuid;

                parentReference.associationType = Constants.ASSOC_CONTAINS;
                parentReference.childName = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, fileName);

                // Create the properties list
                NamedValue nameProperty = new NamedValue();
                nameProperty.name = Constants.PROP_NAME;
                nameProperty.value = fileName;
                nameProperty.isMultiValue = false;

                NamedValue[] properties = new NamedValue[2];
                properties[0] = nameProperty;
                nameProperty = new NamedValue();
                nameProperty.name = Constants.PROP_TITLE;
                nameProperty.value = fileName;
                nameProperty.isMultiValue = false;
                properties[1] = nameProperty;

                // Create the CML create object
                CMLCreate create = new CMLCreate();
                create.parent = parentReference;
                create.id = "1";
                create.type = Constants.TYPE_CONTENT;
                create.property = properties;

                // Create and execute the cml statement
                CML cml = new CML();
                cml.create = new CMLCreate[] { create };
                UpdateResult[] updateResult = repoService.update(cml);

                // work around to cast Alfresco.RepositoryWebService.Reference to
                // Alfresco.ContentWebService.Reference
                Alfresco.RepositoryWebService.Reference rwsRef = updateResult[0].destination;
                Alfresco.ContentWebService.Reference newContentNode = new Alfresco.ContentWebService.Reference();
                newContentNode.path = rwsRef.path;
                newContentNode.uuid = rwsRef.uuid;
                Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store();
                cwsStore.address = "SpacesStore";
                spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace;
                newContentNode.store = cwsStore;

                // Open the file and convert to byte array
                FileStream inputStream = new FileStream(file, FileMode.Open);

                int bufferSize = (int)inputStream.Length;
                byte[] bytes = new byte[bufferSize];
                inputStream.Read(bytes, 0, bufferSize);

                inputStream.Close();

                Alfresco.ContentWebService.ContentFormat contentFormat = new Alfresco.ContentWebService.ContentFormat();
                contentFormat.mimetype = mimeType.GuessMimetype(file);

                WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, bytes, contentFormat);

                // Reset the cursor to the default for all controls.
                Cursor.Current = Cursors.Default;

                MessageBox.Show(file + " uploaded");

            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                MessageBox.Show(ex.StackTrace);
            }
        }
Пример #6
0
        private void writeContentType(String filePath, Alfresco.RepositoryWebService.Reference rwsRef,
            String property, String mimetype)
        {
            Alfresco.ContentWebService.Reference newContentNode = new Alfresco.ContentWebService.Reference();
            newContentNode.path = rwsRef.path;
            newContentNode.uuid = rwsRef.uuid;

            Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store();
            cwsStore.address = "SpacesStore";
            spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace;
            newContentNode.store = cwsStore;

            // Open the file and convert to byte array
            FileStream inputStream = new FileStream(filePath, FileMode.Open);

            int bufferSize = (int)inputStream.Length;
            byte[] bytes = new byte[bufferSize];
            inputStream.Read(bytes, 0, bufferSize);
            inputStream.Close();

            ContentFormat contentFormat = new ContentFormat();
            contentFormat.mimetype = mimetype;
            WebServiceFactory.getContentService().write(newContentNode, property, bytes, contentFormat);
        }
Пример #7
0
        private void button2_Click(object sender, EventArgs e)
        {
            Alfresco.RepositoryWebService.Store[] stores = this.repoService.getStores();

            Alfresco.RepositoryWebService.Store vStore = stores[3];

            ListViewItem item = listViewBrowse.SelectedItems[0];

            if (item != null)
            {
                ResultSetRowNode node = item.Tag as ResultSetRowNode;
                if (node != null)
                {
                    if (node.type.Contains("folder") == false)
                    {
                        // Create the reference for the node selected
                        Alfresco.AuthoringWebService.Store spacesStore2 = new Alfresco.AuthoringWebService.Store();
                        spacesStore2.scheme  = Alfresco.AuthoringWebService.StoreEnum.workspace;
                        spacesStore2.address = "SpacesStore";

                        Alfresco.AuthoringWebService.Reference reference = new Alfresco.AuthoringWebService.Reference();
                        reference.store = spacesStore2;
                        reference.uuid  = node.id;

                        VersionHistory VH = this.authoringService.getVersionHistory(reference);

                        int    i    = 0;
                        char[] temp = new char[1];
                        temp[0] = '0';
                        string versions = new string(temp);
                        Alfresco.AuthoringWebService.Version first;
                        foreach (Alfresco.AuthoringWebService.Version version in VH.versions)
                        {
                            if (i == 0)
                            {
                                first = version;
                            }
                            versions += version.label + (";") + version.id.uuid + (";");
                        }

                        {
                            // Create the reference for the node selected
                            Alfresco.ContentWebService.Store spacesStore3 = new Alfresco.ContentWebService.Store();
                            spacesStore3.scheme  = Alfresco.ContentWebService.StoreEnum.versionStore;
                            spacesStore3.address = vStore.address;

                            Alfresco.ContentWebService.Reference reference1 = new Alfresco.ContentWebService.Reference();
                            reference1.store = spacesStore3;
                            reference1.uuid  = VH.versions[VH.versions.GetUpperBound(0)].id.uuid;

                            // Lets try and get the content
                            Alfresco.ContentWebService.Predicate predicate = new Alfresco.ContentWebService.Predicate();
                            predicate.Items = new Object[] { reference1 };
                            Content[] contents = this.contentService.read(predicate, "{http://www.alfresco.org/model/content/1.0}content");
                            Content   content  = contents[0];
                            if (content.url != null && content.url.Length != 0)
                            {
                                string url = content.url + "?ticket=" + AuthenticationUtils.Ticket;
                                webBrowser.Url = new Uri(url);
                            }
                        }
                    }
                    else
                    {
                    }
                }
            }
        }
Пример #8
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                String file = this.textBox1.Text;

                if (file.Equals(""))
                {
                    MessageBox.Show("Please select a file");
                    this.btnSelect.Focus();
                    return;
                }

                if (this.tbLocation.Text.Equals(""))
                {
                    MessageBox.Show("Please select the location");
                    this.btnLocation.Focus();
                    return;
                }

                int start  = file.LastIndexOf("\\") + 1;
                int length = file.Length - start;
                // get the filename only
                String fileName = file.Substring(start, length);

                if (file == null || file.Equals(""))
                {
                    MessageBox.Show("please select a file");
                    return;
                }
                // Display a wait cursor while the file is uploaded
                Cursor.Current = Cursors.WaitCursor;

                // Initialise the reference to the spaces store
                Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store();
                spacesStore.scheme  = Alfresco.RepositoryWebService.StoreEnum.workspace;
                spacesStore.address = "SpacesStore";

                // Create the parent reference, the company home folder
                Alfresco.RepositoryWebService.ParentReference parentReference = new Alfresco.RepositoryWebService.ParentReference();
                parentReference.store = spacesStore;
                //                parentReference.path = "/app:company_home";
                parentReference.uuid = this.locationUuid;


                parentReference.associationType = Constants.ASSOC_CONTAINS;
                parentReference.childName       = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, fileName);

                // Create the properties list
                NamedValue nameProperty = new NamedValue();
                nameProperty.name         = Constants.PROP_NAME;
                nameProperty.value        = fileName;
                nameProperty.isMultiValue = false;

                NamedValue[] properties = new NamedValue[2];
                properties[0]             = nameProperty;
                nameProperty              = new NamedValue();
                nameProperty.name         = Constants.PROP_TITLE;
                nameProperty.value        = fileName;
                nameProperty.isMultiValue = false;
                properties[1]             = nameProperty;

                // Create the CML create object
                CMLCreate create = new CMLCreate();
                create.parent   = parentReference;
                create.id       = "1";
                create.type     = Constants.TYPE_CONTENT;
                create.property = properties;

                // Create and execute the cml statement
                CML cml = new CML();
                cml.create = new CMLCreate[] { create };
                UpdateResult[] updateResult = repoService.update(cml);

                // work around to cast Alfresco.RepositoryWebService.Reference to
                // Alfresco.ContentWebService.Reference
                Alfresco.RepositoryWebService.Reference rwsRef         = updateResult[0].destination;
                Alfresco.ContentWebService.Reference    newContentNode = new Alfresco.ContentWebService.Reference();
                newContentNode.path = rwsRef.path;
                newContentNode.uuid = rwsRef.uuid;
                Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store();
                cwsStore.address     = "SpacesStore";
                spacesStore.scheme   = Alfresco.RepositoryWebService.StoreEnum.workspace;
                newContentNode.store = cwsStore;

                // Open the file and convert to byte array
                FileStream inputStream = new FileStream(file, FileMode.Open);

                int    bufferSize = (int)inputStream.Length;
                byte[] bytes      = new byte[bufferSize];
                inputStream.Read(bytes, 0, bufferSize);

                inputStream.Close();

                Alfresco.ContentWebService.ContentFormat contentFormat = new Alfresco.ContentWebService.ContentFormat();
                contentFormat.mimetype = mimeType.GuessMimetype(file);

                WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, bytes, contentFormat);

                // Reset the cursor to the default for all controls.
                Cursor.Current = Cursors.Default;

                MessageBox.Show(file + " uploaded");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                MessageBox.Show(ex.StackTrace);
            }
        }
Пример #9
0
        /// <summary>
        /// Double click event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listViewBrowse_DoubleClick(object sender, EventArgs e)
        {
            ListViewItem item = listViewBrowse.SelectedItems[0];
            if (item != null)
            {
                ResultSetRowNode node = item.Tag as ResultSetRowNode;
                if (node != null)
                {
                    if (node.type.Contains("folder") == true)
                    {
                        // Create the reference for the node selected
                        Alfresco.RepositoryWebService.Reference reference = new Alfresco.RepositoryWebService.Reference();
                        reference.store = this.spacesStore;
                        reference.uuid = node.id;

                        // Parent references
                        this.parentReferences.Add(this.currentReference);

                        // Populate the list with the children of the selected node
                        populateListBox(reference);
                    }
                    else
                    {
                        // Create the reference for the node selected
                        Alfresco.ContentWebService.Store spacesStore2 = new Alfresco.ContentWebService.Store();
                        spacesStore2.scheme = Alfresco.ContentWebService.StoreEnum.workspace;
                        spacesStore2.address = "SpacesStore";

                        Alfresco.ContentWebService.Reference reference = new Alfresco.ContentWebService.Reference();
                        reference.store = spacesStore2;
                        reference.uuid = node.id;

                        // Lets try and get the content
                        Alfresco.ContentWebService.Predicate predicate = new Alfresco.ContentWebService.Predicate();
                        predicate.Items = new Object[] { reference };
                        Content[] contents = this.contentService.read(predicate, "{http://www.alfresco.org/model/content/1.0}content");
                        Content content = contents[0];
                        if (content.url != null && content.url.Length != 0)
                        {
                            string url = content.url + "?ticket=" + AuthenticationUtils.Ticket;
                            webBrowser.Url = new Uri(url);
                        }
                    }
                }
            }
        }
Пример #10
0
        private void button2_Click(object sender, EventArgs e)
        {
            Alfresco.RepositoryWebService.Store[] stores = this.repoService.getStores();

            Alfresco.RepositoryWebService.Store vStore = stores[3];

            ListViewItem item = listViewBrowse.SelectedItems[0];
            if (item != null)
            {
                ResultSetRowNode node = item.Tag as ResultSetRowNode;
                if (node != null)
                {
                    if (node.type.Contains("folder") == false)
                    {
                        // Create the reference for the node selected
                        Alfresco.AuthoringWebService.Store spacesStore2 = new Alfresco.AuthoringWebService.Store();
                        spacesStore2.scheme = Alfresco.AuthoringWebService.StoreEnum.workspace;
                        spacesStore2.address = "SpacesStore";

                        Alfresco.AuthoringWebService.Reference reference = new Alfresco.AuthoringWebService.Reference();
                        reference.store = spacesStore2;
                        reference.uuid = node.id;

                        VersionHistory VH = this.authoringService.getVersionHistory(reference);

                        int i = 0;
                        char[] temp = new char[1];
                        temp[0] = '0';
                        string versions = new string(temp);
                        Alfresco.AuthoringWebService.Version first;
                        foreach (Alfresco.AuthoringWebService.Version version in VH.versions)
                        {
                            if (i == 0)
                                first = version;
                            versions += version.label + (";") + version.id.uuid + (";");
                        }

                        {
                            // Create the reference for the node selected
                            Alfresco.ContentWebService.Store spacesStore3 = new Alfresco.ContentWebService.Store();
                            spacesStore3.scheme = Alfresco.ContentWebService.StoreEnum.versionStore;
                            spacesStore3.address = vStore.address;

                            Alfresco.ContentWebService.Reference reference1 = new Alfresco.ContentWebService.Reference();
                            reference1.store = spacesStore3;
                            reference1.uuid = VH.versions[VH.versions.GetUpperBound(0)].id.uuid;

                            // Lets try and get the content
                            Alfresco.ContentWebService.Predicate predicate = new Alfresco.ContentWebService.Predicate();
                            predicate.Items = new Object[] { reference1 };
                            Content[] contents = this.contentService.read(predicate, "{http://www.alfresco.org/model/content/1.0}content");
                            Content content = contents[0];
                            if (content.url != null && content.url.Length != 0)
                            {
                                string url = content.url + "?ticket=" + AuthenticationUtils.Ticket;
                                webBrowser.Url = new Uri(url);
                            }

                        }

                    }
                    else
                    {

                    }
                }
            }
        }
Пример #11
0
        private void UploadNow(string fileName, string file)
        {
            // Initialise the reference to the spaces store
            Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store();
            spacesStore.scheme  = Alfresco.RepositoryWebService.StoreEnum.workspace;
            spacesStore.address = "SpacesStore";

            // Create the parent reference, the company home folder
            Alfresco.RepositoryWebService.ParentReference parentReference = new Alfresco.RepositoryWebService.ParentReference();
            parentReference.store = spacesStore;
            //parentReference.path = "/app:company_home"
            parentReference.uuid            = LocationUuid;
            parentReference.associationType = Constants.ASSOC_CONTAINS;
            parentReference.childName       = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, fileName);

            // Create the properties list
            NamedValue nameProperty = new NamedValue();

            nameProperty.name         = Constants.PROP_NAME;
            nameProperty.value        = fileName;
            nameProperty.isMultiValue = false;

            NamedValue[] properties = new NamedValue[2];
            properties[0]             = nameProperty;
            nameProperty              = new NamedValue();
            nameProperty.name         = Constants.PROP_TITLE;
            nameProperty.value        = fileName;
            nameProperty.isMultiValue = false;
            properties[1]             = nameProperty;

            // Create the CML create object
            CMLCreate create = new CMLCreate();

            create.parent   = parentReference;
            create.id       = "1";
            create.type     = Constants.TYPE_CONTENT;
            create.property = properties;

            // Create and execute the cml statement
            CML cml = new CML();

            cml.create = new CMLCreate[] { create };
            UpdateResult[] updateResult = repoService.update(cml);

            // work around to cast Alfresco.RepositoryWebService.Reference to
            // Alfresco.ContentWebService.Reference
            Alfresco.RepositoryWebService.Reference rwsRef         = updateResult[0].destination;
            Alfresco.ContentWebService.Reference    newContentNode = new Alfresco.ContentWebService.Reference();
            newContentNode.path = rwsRef.path;
            newContentNode.uuid = rwsRef.uuid;
            Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store();
            cwsStore.address     = "SpacesStore";
            spacesStore.scheme   = Alfresco.RepositoryWebService.StoreEnum.workspace;
            newContentNode.store = cwsStore;

            // Open the file and convert to byte array
            FileStream inputStream = new FileStream(file, FileMode.Open);

            int bufferSize = (int)inputStream.Length;

            byte[] bytes = new byte[bufferSize];
            inputStream.Read(bytes, 0, bufferSize);

            inputStream.Close();

            ContentFormat contentFormat = new ContentFormat();

            if (rdjpeg.Checked == true)
            {
                contentFormat.mimetype = "image/jpeg";
            }
            else if (rdgif.Checked == true)
            {
                contentFormat.mimetype = "image/gif";
            }
            else if (rdtiff.Checked == true)
            {
                contentFormat.mimetype = "image/tiff";
            }

            WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, bytes, contentFormat);
        }
Пример #12
0
        private Content UpdateDocument(Alfresco.RepositoryWebService.Reference reference, byte[] document)
        {
            MimetypeMap mimeType = new MimetypeMap();

            var newContentNode = new Alfresco.ContentWebService.Reference();
            newContentNode.path = reference.path;
            newContentNode.uuid = reference.uuid;
            Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store();
            cwsStore.address = Constants.SPACES_STORE;
            newContentNode.store = cwsStore;

            var contentFormat = new Alfresco.ContentWebService.ContentFormat();
            contentFormat.mimetype = mimeType.GuessMimetype(Name);

            return WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, document, contentFormat);
        }
Пример #13
0
        /// <summary>
        /// Guarda un fichero en el nodo especificado
        /// </summary>
        /// <param name="parentId">uuid del nodo donde queremos guardar el documento</param>
        /// <param name="documentPath">Ruta local de la que se debe sacar el fichero, aquí se devuelve la ruta del repositorio donde se ha guardado el  documento</param>
        /// <param name="document">raw document, si este valor es null se intentará leer el documento del documentPath</param>
        /// <returns>uuid del documento que se ha salvado</returns>
        public string CreateFileByParentId(string parentId, ref string documentName, byte[] document)
        {
            if (document == null) return null;

            string documentId = null;
            var mimeType = new MimetypeMap();

            try
            {
                UpdateResult[] updateResult = CreateNode(parentId, null, Constants.TYPE_CONTENT);

                // work around to cast Alfresco.RepositoryWebService.Reference to Alfresco.ContentWebService.Reference
                RepositoryWebService.Reference rwsRef = updateResult[0].destination;
                ContentWebService.Reference newContentNode = new Alfresco.ContentWebService.Reference();
                newContentNode.path = rwsRef.path;
                newContentNode.uuid = rwsRef.uuid;
                ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store();
                cwsStore.address = Constants.SPACES_STORE;
                newContentNode.store = cwsStore;

                var contentFormat = new Alfresco.ContentWebService.ContentFormat();
                contentFormat.mimetype = mimeType.GuessMimetype(Name);

                Content lContent = WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, document, contentFormat);
                documentName = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(lContent.node.path));
                documentId = lContent.node.uuid;
            }
            catch (SoapException ex)
            {
                if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException"))
                {
                    var node = new NodeBase();
                    var nodePath = String.Format("{0}/{1}", node.GetPathById(parentId), System.IO.Path.GetFileName(documentName));
                    var id = node.GetIdByPath(nodePath);

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