Adobe Enterprise Technical Enablement Reading and Writing Files Using the File Utilities service In this topic, you will learn about the File Utilities services which enable processes to interact with the file system. Objectives After completing this unit, you should be able to Read and write documents from the file system Concepts In this topic, you will learn about the following concepts Reading and writing files using the File Utilities service Copyright 2011 Adobe Systems Incorporated 1
Reading and writing files using the File Utilities service The File Utilities services enable processes to interact with the file system of the Adobe Enterprise server or other file system that the server can access The File Utilities service provides the following operations Table 1: File Utilities operations Delete Exists Find Is Absolute Is Directory Is File Is Hidden Make Directory Make Directory Tree Read Document Read String Read XML Rename To Set Read Only Write Document Write String Write XML Note: In this topic, only the Read Document and Write Document operations will be discussed. 2 Copyright 2011 Adobe Systems Incorporated
Using the Read Document operation The Read Document operation is used to read a document from the file system into a document type variable Located in Foundation > File Utilities - 1.0 Figure 1: Locating the Read Document operation of the File Utilities service Copyright 2011 Adobe Systems Incorporated 3
Setting Read Document operation properties When a Read Document operation is added to a process, the following properties can be defined in the Properties view Filename - the fully qualified name of the file to read from the file system Output Document - the XPath expression or document variable where the content of the read document is saved to Figure 2: Properties view for the Read Document operation Note: If any local paths to files or directories are specified for any operation properties, the paths are interpreted as being on the file system of the server. The user account that is used to run the server must have the required permissions to interact with the files and file locations that the service s operations target. 4 Copyright 2011 Adobe Systems Incorporated
Using the Write Document operation The Write Document operation is used to write a document to the file system Located in Foundation > File Utilities - 1.0 Figure 3: Locating the Write Document operation of the File Utilities service Copyright 2011 Adobe Systems Incorporated 5
Setting Write Document operation properties When a Write Document operation is added to a process, the following properties can be defined in the Properties view Pathname Pattern - fully qualified file name of the file to create Document - contains the content to write to the file Make Unique - specifies whether the filename should be made unique when the file is already present Overwrite the existing file - specifies whether the file should be overwritten if it already exists Figure 4: Properties panel for the Write Document operation 6 Copyright 2011 Adobe Systems Incorporated
Task 1: Reading and writing from the file system In this task, you will perform the following Open a process Configure a Read Document operation Configure a Write Document operation Test the process Setup 1. Import the Reading_And_Writing_Files.lca file. Steps Open a process 1. Login to the Workbench. 2. Open the Reading_and_Writing_Files application. 3. Expand the Processes folder, right-click the ReadingAndWritingFiles process and select Check Out. 4. Double-click the ReadingAndWritingFiles process to open it. 5. From the Variables view, create a new process variable with the following properties. Name: inworddoc Type: document Configure a Read Document operation 6. From the process diagram palette, drag the Activity Picker activity onto your process diagram. 7. In the Define Activity dialog box, expand the Foundation category. 8. From the File Utilities service, select the Read Document operation and click OK. 9. Select the Read Document operation and set the following properties. Name: Read Word Document Input Filename (literal value): C:\AdobeTraining\Doc_Services\Foundation\Reading_And_Writing _Files\Direct Deposit Agreement.doc Output Document (variable): inworddoc Configure a Write Document operation 10. From the process diagram palette, drag the Activity Picker activity onto your process diagram and drop it to the right of the Read Word Document operation. Copyright 2011 Adobe Systems Incorporated 7
11. In the Define Activity dialog box, expand the Foundation category. 12. From the File Utilities service, select the Write Document operation and click OK. 13. Select the Write Document operation and set the following properties. Name: Write Document Pathname Pattern (literal value): C:\AdobeTraining\Doc_Services\Foundation\Reading_And_Writing _Files\Direct Deposit Agreement BACKUP.doc Document (variable): inworddoc 14. Select the Overwrite the existing file option. 15. Connect the two operations with a route. 16. Confirm that the process appears as follows. 17. Save the process and Deploy the application. Test the process 18. Right-click in an empty area of the process diagram and select Invoke Process... 19. A dialog will appear stating that the process has no input variables. Click OK. 20. A dialog will appear stating that the invocation completed successfully. Click OK. 21. Verify that the Direct Deposit Agreement BACKUP.doc file was written to the C:\AdobeTraining\Doc_Services\Foundation\Reading_And_Writing_Files directory. 8 Copyright 2011 Adobe Systems Incorporated
Summary The Read Document operation is used to read a document from the file system into a document type variable The Write Document operation is used to write a document to the file system Copyright 2011 Adobe Systems Incorporated 9
Review 1. When would the Read Document operation be used in a process? 2. When would the Write Document operation be used in a process? Adobe Systems Incorporated 345 Park Avenue San Jose, CA 95110-2704 USA www.adobe.com Adobe, Acrobat, Adobe AIR, AIR, Distiller, Flash, Flash Builder, Flash Catalyst, Flex, Adobe Digital Enterprise Platform, MXML, PostScript, Reader, SiteCatalyst, SearchCenter, Discover, Recommendations, Insight, Test&Target, ReportBuilder, Survey, Search&Promote, and Social Media are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. 2011 Adobe Systems Incorporated. All rights reserved.