Set Document Upload security based on the entry template associated with the folder

Source: Internet
Author: User

On XT, You can preset an entry template (entrytemplate) to control the security and attributes of uploaded documents in templated mode. Entrytemplate itself can be associated with folder (one folder can be associated with multiple entrytemplates ), in this way, we can set the document security and attribute information according to the value we want to set when uploading under a folder on XT, eliminating the need for manual operations, this is necessary for the business of Zhy Tianjin branch because the customer has three basic groups here, which grant the same permissions to all documents under the folder, another special group may be different depending on different folder.

This work can be easily completed through configuration on XT, but as a customized application, the customer did not have this requirement at the initial implementation, in the beginning, special permission management can be customized to meet this special requirement, but this can only be an indicator, because this will also be done by the customer in two sets of actions, one on the XT, the other is on a custom application. The best way is to set the entrytemplate permission for subsequent applications to directly read XT when the corresponding folde is passed down to javaset.

However, filenet does not provide an API for obtaining entrytemplate directly based on folder. If you want to retrieve the entrytemplate corresponding to the folder by traversing the entire entrytemplate, one application needs to maintain a relationship (in a sense, the customer needs to perform two sets of actions, instead of always consistent.

After analyzing the features of entrytemplate and folder of Zhy Tianjin Branch, we can find that the annotations of folder contains the serial number of the document corresponding to entrytemplate, And we can obtain the content of the relevant entrytemplate according to it, then parse the relevant permissions and set them. The special feature of this case is that only the serial number of entrytemplate exists in annotations of folder (stored as a file and the value of specific notes needs to be parsed ). The specific operation procedure code is as follows:

// Obtain the idpublic void testwhatisfolderannotationstextid () {connection = cehelper. getconnection (); cehelper. pushsubject (connection); ObjectStore OS = cehelper. getobjectstore (connection); try {folder = factory. folder. fetchinstance (OS, new ID ("{F78C8CE7-94FE-47CA-94E4-19A78EEBBF9E}"), null); annotationset get_annotations = folder. get_annotations (); iterator = Get_annotations.iterator (); While (iterator. hasnext () {annotation = (annotation) iterator. next (); logger.info ("annotation. get_name () = "+ annotation. get_name (); documentbuilderfactory docbuilderfactory = javax. XML. parsers. documentbuilderfactory. newinstance (); documentbuilder docbuilder = NULL; docbuilder = docbuilderfactory. newdocumentbuilder (); Org. w3C. dom. document Doc = docbuilder. parse (Annotation. accesscontentstream (0); nodelist parameters = Doc. getelementsbytagname ("object"); node rootnode = NULL; If (parameters! = NULL) {rootnode = parameters. item (0);} element ele = (element) rootnode; nodelist elementsbytagname = ELE. getelementsbytagname ("setting"); node item = elementsbytagname. item (1); logger.info ("item. getnodename () = "+ item. getnodename (); logger.info ("item. getnodevalue () = "+ item. getnodevalue (); logger.info ("item. gettextcontent () = "+ item. gettextcontent () ;}} catch (exception e) {e. printstacktrace ();} finally {cehelper. popsubject () ;}}// obtain the security and other content of the corresponding entry template based on the sequence ID public void testgetversionseries () {connection = cehelper. getconnection (); cehelper. pushsubject (connection); ObjectStore OS = cehelper. getobjectstore (connection); try {string docid = "{60cfdd81-c2000046f3-a98e-b49a125930f9}"; versionseries fetchinstance = factory. versionseries. fetchinstance (OS, new ID (docid), null); logger.info (fetchinstance. get_id (). tostring (); document DOC = (document) fetchinstance. get_currentversion (); Org. w3C. dom. document w3cdoc = wcmxmlutil. getdocumentfrominputstream (Doc. accesscontentstream (0); entrytemplateparser parser = new entrytemplateparser (w3cdoc); string classname = parser. getclassname (); string classid = parser. GETID (); List permissionlist = parser. getpermissionlist (); List propertylist = parser. getpropertylist (); iterator = permissionlist. iterator (); While (iterator. hasnext () {string item = (string) iterator. next (); logger.info (item. tostring () ;}} catch (exception e) {e. printstacktrace ();} finally {cehelper. popsubject () ;}}// set the document security public void testpermission () {connection = cehelper. getconnection (); cehelper. pushsubject (connection); ObjectStore OS = cehelper. getobjectstore (connection); try {document DOC = factory. document. createinstance (OS, "generalclass"); accesspermissionlist createlist = factory. accesspermission. createlist (); accesspermission createinstance2 = factory. accesspermission. createinstance (); createinstance2.set _ accessmask (131073); createinstance2.set _ accesstype (accesstype. allow); createinstance2.set _ granteename ("# authenticated-users"); createinstance2.set _ inheritabledepth (-1); accesspermission createinstane3 = factory. accesspermission. createinstance (); createinstance3.set _ accessmask (998871); createinstance3.set _ accesstype (accesstype. allow); createinstance3.set _ granteename ("fnadmins"); createinstance3.set _ inheritabledepth (-1); createlist. add (createinstance2); createlist. add (createinstane3); Doc. getproperties (). putvalue ("documenttitle", "log4j_3.log"); string mintype = "application/octet-stream"; Doc. set_mimetype (mintype); Doc. checkin (autoclassify. do_not_auto_classify, checkintype. major_version); Doc. save (refreshmode. refresh); folder = factory. folder. fetchinstance (OS, new ID ("{0bca05b3-6a0a-407c-b17a-503fa4070193}"), null); referentialcontainmentrelationship RCR = folder. file (Doc, autouniquename. not_auto_unique, null, definesecurityparentage. do_not_define_security_parentage); RCR. save (refreshmode. refresh); Doc. set_permissions (createlist); Doc. save (refreshmode. no_refresh);} catch (exception e) {e. printstacktrace ();} finally {cehelper. popsubject ();}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.