code...
The piece of code is:
************************************************************************
ServletContext context = getServletContext();
String inputPath = context.getInitParameter("InputPath");
String outputPath = context.getInitParameter("OutputPath");
ConnectionFactory dmConnectionFactory = null;
// Create an InitialContext object
Properties prop = new Properties();
prop.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
prop.setProperty(InitialContext.PROVIDER_URL, "localhost:1099");
prop.setProperty(InitialContext.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
InitialContext namingContext = new InitialContext(prop);
// Lookup the Data Manager service
Object dmObject = namingContext.lookup("DataManagerService");
dmConnectionFactory = (ConnectionFactory)PortableRemoteObject.narrow(dmObject,ConnectionFactory.class);
// Begin a transaction
transaction = (UserTransaction) namingContext.lookup("java:comp/UserTransaction");
transaction.begin();
// Create a DataManager object
DataManager mDataManager = DataManagerHelper.narrow((org.omg.CORBA.Object)dmConnectionFactory.getConnection());
// PDF Manipulation Module
// Declare a ConnectionFactory object
ConnectionFactory pdfConnectionFactory = null;
// Lookup the PDF Manipulation service
Object pdfObject = namingContext.lookup("PDFManipulation");
pdfConnectionFactory = (ConnectionFactory)PortableRemoteObject.narrow(pdfObject,ConnectionFactory.class);
// Use the pdfConnectionFactory object to create a PDFFactory object
PDFFactory mPDFFactory = PDFFactoryHelper.narrow((org.omg.CORBA.Object)pdfConnectionFactory.getConnection());
// Create a FileDataBuffer object to store an existing PDF document by
// calling the DataManager objects createFileDataBuffer method.
// Reference the PDF document by name
FileDataBuffer pdfFile = mDataManager.createFileDataBuffer(inputPath + "error_eReporting.pdf");
// Open the PDF object using the PDFFactory object
PDFDocument pdf = mPDFFactory.openPDFWithAPS(pdfFile, "administrator", "password");
//Specify property values
apsProps.setProperty(EDCFactory.USERNAME_PROPERTY_NAME,"administrator");
apsProps.setProperty(EDCFactory.PASSWORD_PROPERTY_NAME,"password");
apsProps.setProperty(EDCFactory.MODE_PROPERTY_NAME,"ejb");
//Establish a connection to LiveCyle Policy Server
EDCFactory apsSession = EDCFactory.connect(apsProps);
// Create a Policy Search Filter object
PolicySearchFilter Polsf = new PolicySearchFilter();
// Set the search criteria to a known Policy Name
Polsf.setName("Docs demo policy");
//Create Policy Server Manager Object
PolicyManager apsPolicyManager = apsSession.getPolicyManager();
//Get the policy object
Policy [] retPolicy = apsPolicyManager.getPolicies(Polsf,1);
//Create a Policy object and initialize it to the contents
//of the array item 0
Policy myPolicy = (Policy)retPolicy[0];
//Set the variable with the Policy ID value
String policyID = myPolicy.getId();
//Close the connection to Adobe Policy Server
apsSession.closeConnection();
//*********************************************
//End of APS Specific Code
//*********************************************
//Apply the policy retrieved from APS to a PDF document
//Parameters - policyID, username, password, documentName, alternateID)
pdf.applyPolicy(myPolicy.getId(),"administrator", "password", "securedoc", "doc");
// Convert PDF object to DataBuffer
DataBuffer destinationFile = pdf.save();
//Create byte array from data buffer contents
long bufSize = destinationFile.getBufLength();
byte[] fileData = destinationFile.getBytes(0, bufSize);
//Write byte array to file
File outputFile = new File(outputPath + "error_eReportingWP.pdf");
OutputStream myStream = new FileOutputStream(outputFile);
myStream.write(fileData);
myStream.close();
************************************************************************
The form is not password-protected, so why will the APSInsufficientPermission will be invoked? Could anybody please give me any idea? I do appreciate for any help.
cheers,
hj