public static Reference From(Alfresco.RepositoryWebService.Reference contentReference)
 {
     Reference reference = new Reference();
     reference.path = contentReference.path;
     reference.store = StoreFrom(contentReference.store);
     reference.uuid = contentReference.uuid;
     return reference;
 }
 private static Store StoreFrom(Alfresco.RepositoryWebService.Store contentStore)
 {
     StoreEnum scheme = (StoreEnum)StoreEnum.Parse(typeof(StoreEnum), contentStore.scheme.ToString());
     return new Store(scheme, contentStore.address);
 }
示例#3
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);
        }
示例#4
0
        private bool writeNewContent(Alfresco.RepositoryWebService.Reference rwsRef, bool deleteOnErrFlag)
        {
            bool success = true;
            try
            {
                // write the content
                if (this.imageContentProp != null)
                {

                    try
                    {
                        foreach (AscentRelease.ImageFile image in releaseData.ImageFiles)
                        {

                            String filePath = image.FileName;
                            // get the file and check its size
                            FileInfo imageFile = new FileInfo(filePath);

                            if (imageFile.Length > ReleaseConstants.MAX_FILE_SIZE)
                            {
                                // get the smaller file
                                filePath = filePath.Insert(filePath.LastIndexOf("."), "t");
                            }

                            this.writeContentType(filePath, rwsRef, this.imageContentProp, ReleaseConstants.MIME_TYPE_TIFF);
                            break;

                        }
                    }
                    catch (Exception e)
                    {
                        Log log = new Log();
                        log.ErrorLog(".\\log\\", "KfxReleaseScript method writeNewContent " + e.Message, e.StackTrace);
                        return false;
                    }

                }

                if (this.ocrContentProp != null)
                {
                    this.writeContentType(releaseData.TextFilePath, rwsRef,this.ocrContentProp, ReleaseConstants.MIME_TYPE_TEXT);
                }

                if (this.pdfContentProp != null)
                {
                    this.writeContentType(releaseData.KofaxPDFFileName, rwsRef,this.pdfContentProp, ReleaseConstants.MIME_TYPE_PDF);
                }
                releaseData.RepositoryDocumentID = rwsRef.uuid;
            }
            catch (Exception ex)
            {
                String errorMessage = ReleaseConstants.ERR_NOT_NODE_DELETED;
                if (deleteOnErrFlag)
                {
                    this.deleteReference(rwsRef);
                    errorMessage = ReleaseConstants.ERR_NODE_DELETED;
                }
                Log log = new Log();
                log.ErrorLog(".\\log\\", "KfxReleaseScript method writeNewContent " + ex.Message, ex.StackTrace);
                success = false;
            }

            return success;
        }
示例#5
0
        private void deleteReference(Alfresco.RepositoryWebService.Reference reference)
        {
            Alfresco.RepositoryWebService.Predicate where = new Alfresco.RepositoryWebService.Predicate();
            where.Items = new Alfresco.RepositoryWebService.Reference[] { reference };

            CMLDelete cmlDelete = new CMLDelete();
            cmlDelete.where = where;

            CML cml = new CML();
            cml.delete = new CMLDelete[] { cmlDelete };
            this.repoService.update(cml);
        }
示例#6
0
        //**************************************************************
        // Function:	addFieldsFromAspect
        // Purpose:		gets the aspect fields and redraw the fields
        //            
        // Input:		String aspect   -   aspect name
        //              ClassDefinition classDefinition - class def of the aspect
        // Output:		an array of the new release links created for the aspect
        //*************************************************************/
        private ReleaseLink[] addFieldsFromAspect(String aspect,
            Alfresco.DictionaryServiceWebService.ClassDefinition classDefinition)
        {
            Alfresco.DictionaryServiceWebService.PropertyDefinition[] properties = classDefinition.properties;
            ArrayList aspectReleaseLinks = new ArrayList();
            int propLength = 0;
            if (properties != null)
            {
                int offset = 0;
                foreach (Alfresco.DictionaryServiceWebService.PropertyDefinition prop in properties)
                {
                    // dont add content type fields, these are for the tiff, ocr and pdf fields
                    String dataType = prop.dataType;

                    if (dataType.EndsWith("content"))
                    {
                        // do something with the document content fields
                        offset++;
                    }
                    else
                    {

                        String title = prop.title;
                        if (title != null && !title.Equals(""))
                        {
                            aspectReleaseLinks.Add(this.addReleaseLink(title + " (" + aspect + ")", ReleaseConstants.ASPECT + ReleaseConstants.SEPERATOR + classDefinition.name + prop.name, dataType, prop.mandatory));
                        }
                        else
                        {
                            // dont add
                            offset++;
                        }
                    }
                }
                propLength = properties.Length - offset;
            }
            this.destinationFieldCount = this.destinationFieldCount + propLength;
            if (this.destinationFieldCount < MAX_FILEDS)
            {
                this.numFieldsDisplayed = this.destinationFieldCount;
                this.vScrollBar1.Visible = false;
            }
            else
            {
                numFieldsDisplayed = MAX_FILEDS;
                // turn on the scroll bar and set the max scroll size
                this.vScrollBar1.Maximum = this.destinationFieldCount;
                this.vScrollBar1.Visible = true;
            }
            this.displayDestinations(this.currentIndexStartPos);
            return (ReleaseLink[])aspectReleaseLinks.ToArray(typeof(ReleaseLink));
        }
示例#7
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);
        }
示例#8
0
        /// <summary>
        /// Populate the list with the children of the passed reference
        /// </summary>
        /// <param name="reference"></param>
        private void populateListBox(Alfresco.RepositoryWebService.Reference reference)
        {
            // Clear the list
            listViewBrowse.Clear();

            // Set the current reference
            this.currentReference = reference;

            // Query for the children of the reference
            QueryResult result = this.repoService.queryChildren(reference);

            if (result.resultSet.rows != null)
            {
                int index = 0;
                foreach (ResultSetRow row in result.resultSet.rows)
                {
                    // Get the name of the node
                    string name = null;
                    foreach (Alfresco.RepositoryWebService.NamedValue namedValue in row.columns)
                    {
                        if (namedValue.name.Contains("name") == true)
                        {
                            name = namedValue.value;
                        }
                    }

                    // Create the list view item that will correspond to the child node
                    ListViewItem item = new ListViewItem();
                    item.Text = name;
                    if (row.node.type.Contains("folder") == true)
                    {
                        item.ImageIndex = 0;
                    }
                    else
                    {
                        item.ImageIndex = 1;
                    }
                    item.Tag = row.node;

                    // Add the item to the list
                    if (row.node.type.Contains("folder") == true)
                    {
                        listViewBrowse.Items.Insert(index, item);
                        index++;
                    }
                    else
                    {
                        listViewBrowse.Items.Add(item);
                    }
                }
            }
        }
示例#9
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);
        }