Does DocuSign Connect Log include PDF Bytes? - docusignapi

While debugging my Connect listener (REST, Java), I am trying to create a PDF document based on xml in the Connect log for Demo. (I have to emulate Docusign POST request while security issues are being resolved.)
I have DocuSign Connect Service activated with “Include Documents” and "Include Certificate of Completion" checked.
I can see Attachment element in the log’s xml but not DocumentPDF element. When saving content as a byte array into PDF file and then trying to open it, it cannot be opened in Acrobat.
Is Attachment element in the Connect Log supposed to be a PDF document?
Here is my code to convert to pdf file:
String documentName = parseXMLDoc(xmlDoc, "DocumentStatus[1]/Name");
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd HHmmsss");
String nowTime = fmt.format(new Date());
OutputStream out = new FileOutputStream("c:\\temp\\"+documentName.replaceAll(".pdf","_"+nowTime+".pdf"));
BASE64Decoder decoder = new BASE64Decoder();
String encodedBytes = parseXMLDoc(xmlDoc, "Attachment/Data");
byte[] decodedBytes = decoder.decodeBuffer(encodedBytes);
out.write(decodedBytes);
out.close();
where parseXMLDoc is
public static String parseXMLDoc(Document xmlDoc, String searchToken) {
String xPathExpression;
try {
XPath xPath = XPathFactory.newInstance().newXPath();
xPathExpression = "//" + searchToken;
return (xPath.evaluate(xPathExpression, xmlDoc));
} catch (Exception e) {
throw new RuntimeException(e);
}
}

No the Connect log does NOT contain the actual document bytes... the documents are only included in the actual Connect pushes to your external listener. The log files simply contain metadata around the transaction, not the actual content.

You can possibly get a full response from DocuSign by using https://Webhook.site where you will be given a temporary URL for listening. Plug the temporary URL into the DocuSign Connection (create a new connection for testing), and open the XML packet from the dashboard on the webhook site dashboard when it arrives from DocuSign.

Related

Xl.generateReport file location does not create excel report on server

So i am using selenium Webdriver+maven+TestNg.
I am trying to generate excel report using XL.generateReport method.Below is the code.
public void SendMail() throws Exception
{
String userDirector = System.getProperty("user.dir");
String resultFile = userDirector + "/Reports/";
Xl.generateReport(resultFile,"excel-report.xlsx");
Thread.sleep(3000);
Date dt = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
String strDate= formatter.format(dt);
//authentication info
final String username = "abc1#test.com";
final String password = "pass#123";
String fromEmail = "abc2#test.com";
String toEmail = "abc3#test.com";
String ccEmail= "ravi#test.com";
String ccEMail2="Rajeev#test.com";
Properties properties = new Properties();
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.smtp.host", "smtp.office365.com");
properties.put("mail.smtp.port", "587");
Session session = Session.getInstance(properties, new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username,password);
}
});
//Start our mail message
MimeMessage msg = new MimeMessage(session);
try {
msg.setFrom(new InternetAddress(fromEmail));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(toEmail));
//msg.addRecipient(Message.RecipientType.CC, new InternetAddress(ccEmail));
msg.addRecipient(Message.RecipientType.CC, new InternetAddress(ccEMail2));
msg.setSubject("Test Execution Report on "+strDate);
Multipart emailContent = new MimeMultipart();
//Text body part
MimeBodyPart textBodyPart = new MimeBodyPart();
textBodyPart.setText("Hello, Good day! \n"
+ "\n"
+ "All scenarios have been executed. Please find the attached report of the execution. \n"
+ "\n"
+ "Thanks,\n"
+ "Mahesh.");
//Attachment body part.
MimeBodyPart pdfAttachment = new MimeBodyPart();
pdfAttachment.attachFile(resultFile+ "excel-report.xlsx");
//Attach body parts
emailContent.addBodyPart(textBodyPart);
emailContent.addBodyPart(pdfAttachment);
//Attach multi-part to message
msg.setContent(emailContent);
Transport.send(msg);
System.out.println("Sent message");
} catch (MessagingException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
So above code is basically going to create a report and store in Reports folder of my project directory.
Further I am using a code to email this generated excel on my email ID.
The above code works fine for me on my local machine.
The problem is when I put this code on server.
I am creating a Runner JAR file and I create a folder with this Runner JAR file, Reports folder and TestNg.xml with some other folder to upload image and stuff.
When I execute the JAR on server, excel report is not getting generated and no email is received with report attached. Same JAR does not work on any other machine that has Microsoft office as well as JAVA on their machine.
I am not sure if there is any path related issue when I run the JAR on server.
On the server , we do not have Microsoft Office installed. But I would like a code that works fine irrespective of whether we have Microsoft office installed or not.
One more addition to this is, I am also creating .html report with same path that is used for excel and this works fine on local as well as on server. HTML report is generated under Reports folder accurately.
Also I have tried changing the excel report path to my local machine folder as well as to the path of the server folder where i have kept the package. But nothing worked
So please help and let me know for solution.
Thanks in advance.

How to download documents from liferay from outside application ..using liferay jsonws or any other way

Hi i am using liferay/api/secure/jsonws services to upload documents, getting documents, from a outside application , in the same way i want to download the documents also, i checked my liferay jsonws , there is no method or service which i can use for download , or i don't know about it , please suggest me a way to download documents from outside application , by using jsonws or any other way is also fine.
Edit after i got to know how to download document.
Hi I tried to download liferay document from outside application by using getURl, but every time for all document i am getting liferay login page content
i have already tried get-file-as-stream json-rpc call but that also giving me null response
the code which i have used is:
final HttpHost targetHost = new HttpHost(hostname.trim());
System.out.println(targetHost.getHostName());
UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password);
System.out.println(creds);
final AuthScope authscope = new AuthScope(targetHost);
httpclient.getCredentialsProvider().setCredentials(authscope, creds);
final AuthCache authCache = new BasicAuthCache();
final BasicScheme basicAuth = new BasicScheme();
authCache.put(targetHost, basicAuth);
final BasicHttpContext localContext = new BasicHttpContext();
localContext.setAttribute(ClientContext.AUTH_CACHE, authCache);
final HttpGet httpget = new HttpGet(hostname+"/documents/" + groupId + "/" + folderId + "/" + filename);
final HttpResponse response = httpclient.execute( httpget, localContext);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
final org.apache.http.HttpEntity entity = response.getEntity();
if (entity != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
entity.writeTo(baos);
return baos.toByteArray();
}
}
return null;
} finally {
httpclient.getConnectionManager().shutdown();
}
}
i am adding basic auth header will correct username and password, don't know how this login page is coming, is there any permission which i need to change or any configurations issue, please help in this.
You could use the Liferay WebDav Services to download files from your document-library. The paths to download can be inspected inside of the control-panel when clicking on a file entry (WebDAV URL toogle link). The paths usually look like: /webdav/{site-name}/document_library/{folder-name}/{file-name}
Otherwise, you could mimic the request URLs Liferay creates inside the documents-media portlet to download the file entry.
But you should take care about authentication, when your files (and folders) are not visible to guests.

How to create attachments in couchDB using RestAPI java client

I have a requirement to store attachment on CouchDB. How will I do it using Java. What APIs I can use? Is there any sample code or documentation I can refer? Currently we are using cloudantdb, but we planing to use CouchDB on Azure
com.cloudant.client.api.Database;
com.cloudant.client.api.model.Response;
Thanks
If you use LightCouch Java API
InputStream in = // .. init stream
// save under a new document, a generated UUID is assigned as id.
Response response = dbClient.saveAttachment(in, "photo.png", "image/png");
// save to an existing document
dbClient.saveAttachment(in, "file.pdf", "application/pdf", "doc-id", "doc-rev");
// save under a new document with the given id.
dbClient.saveAttachment(in, "photo.jpeg", "image/jpeg", "doc-id", null);
// get attachment
InputStream in = dbClient.find("doc-id/photo.jpeg");
// ..
in.close(); // close the stream

Domino web service provider limitation

I'm implementing a domino web service provider, whose purpose is to stream from the base64 format, which in the client that consumes the web service is an attachment file, transform it back into a file. In the web service provider that is developed in java, I use the Stream class and the Mime classes to, to convert the stream and file. The web service provider works well for files up to 5 MB, for larger files the error as technote is displayed. Has anyone had this problem yet? Is there any way around it?
Here is the code for the web service provider
public class criaAnexo {
private Vector itemsToRecycle;
public void attachDocument( byte[] is) {
// creating the output stream used to create the MIME attachments
try
{
itemsToRecycle = new Vector();
Session session = NotesFactory.createSession();
Database db = session.getDatabase("Serverx", "base.nsf");
if (!db.isOpen())
System.out.println("names2.nsf does not exist on snapper");
else
{
Stream outStream = session.createStream();
outStream.write(is);
session.setConvertMIME(false);
// create the MIME body
Document doc = db.createDocument();
doc.replaceItemValue("Form", "formAttachment");
MIMEEntity body = doc.createMIMEEntity();
// create a child for each attachment<br/>
MIMEEntity child = body.createChildEntity();
// find the fileSuffix<br/>
//String fileSuffix = files[i].substring(files[i].lastIndexOf(".")+1);
String fileSuffix = "pdf";
// set the child to the outstream using a mapped MIME type<br/>
// MIME type mapping see: http://www.w3schools.com/media/media_mimeref.asp
//child.setContentFromBytes(outStream, mapMIMEType(fileSuffix), MIMEEntity.ENC_IDENTITY_BINARY);
child.setContentFromBytes(outStream, "application/pdf", MIMEEntity.ENC_IDENTITY_BINARY);
// set name for file attachment<br/>
MIMEHeader header = child.createHeader("Content-Disposition");
header.setHeaderVal("attachment; filename=\"teste.pdf\"");
// set unique id for file attachment to be able to refer to it<br/>
header = child.createHeader("Content-ID");
header.setHeaderVal("teste.pdf");
//outStream.truncate();
//outStream.close();
outStream.close();
Runtime rt = Runtime.getRuntime();
long total_mem = rt.totalMemory();
long free_mem = rt.freeMemory();
long used_mem = total_mem - free_mem;
System.out.println("Total de Memória:"+total_mem);
System.out.println("Total de Memória livre:"+free_mem);
System.out.println("Total de memoria usada pelo agente: " + used_mem/1048576);
doc.save( true, true );
itemsToRecycle.add(doc);
session.recycle(itemsToRecycle); //recycle all items added to vector
session.recycle();
}
}
catch(Exception e)
{
}
}
}
Due to base64 encoding and other overhead, files larger than 5 MB may be exceeding the 10 MB limits you have configured for the Maximum size of request content and Maximum POST data settings for your server. Try increasing them.
In fact the limitation occurs in the client that consumes the web service that I implemented in the domino itself. The technote quoted in the description of the problem, implies that the problem is on the side of the provider, but in fact it is not. When I implemented the web service client on dot net the file was streamed without problems.

Issue while updating a doc when Sharepoint document ID service is activated

I am using sharepoint 2010 enterprise edition. I have activated Document ID service which will generate a doc Id for each doc when you upload. when i am first time uploading or saving the document it has no issues. It is getting saved. The issue i am facing is when i open the uploaded document and edit or update it and while saving it again it is giving the webexception "Underlying connection got disconnected. Connection closed prematurely".
I also tried to debug and found the response did not have header.
We were trying to perform in a windows application to edit and save the document.
we are trying to save the document by creating a webrequest.
please provide your idea on this issue.
please see the code below.
"
WebUrl webUrl = UrlToWebUrl(destinationUri);
System.Collections.Specialized.NameValueCollection methodData = new System.Collections.Specialized.NameValueCollection();
// Add general request to stream
methodData.Add("method","put document:" + GetServerExtensionsVersion(webUrl.SiteUrl));
methodData.Add("service_name","");
methodData.Add("put_option","overwrite,createdir,migrationsemantics");
methodData.Add("keep_checked_out","false");
HttpWebRequest req = StartWebRequest(GetAuthorURL(webUrl.SiteUrl), methodData);
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;
System.IO.Stream reqStream = req.GetRequestStream();
RemoveSourceControlProperties(properties);
WriteDocumentData(reqStream, webUrl.FileUrl, file, properties);
reqStream.Flush();
reqStream.Close();
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
try
{
if (!PutDocumentResponseSuccess(GetResponseString(response)))
{
throw new FrontPageRPCException("Failed to save document.", destinationUri);
}
}
finally
{
if (null != response) response.Close();
}
}
"

Resources