Skip to content

Instantly share code, notes, and snippets.

@VenkataA
VenkataA / readNode.ecma
Created August 7, 2023 22:15
AEM Read Node Contents via ECMAScript
var path = "/var/tsa/intake_counter.json";
var jcrsession = graniteWorkflowSession.adaptTo(Packages.javax.jcr.Session);
var node = jcrsession.getNode(path);
var is = node.getNode("jcr:content").getProperty("jcr:data").getStream();
var jsonInputString = org.apache.commons.io.IOUtils.toString(is, "UTF-8");
is.close();
@VenkataA
VenkataA / PStoPDF.java
Created February 15, 2023 16:54
Convert PS to PDF
/*
* This Java Quick Start uses the SOAP mode and contains the following JAR files
* in the class path:
* 1. adobe-distiller-client.jar
* 2. adobe-livecycle-client.jar
* 3. adobe-usermanager-client.jar
* 4. adobe-utilities.jar
* 5. jboss-client.jar (use a different JAR file if the forms server is not deployed
* on JBoss)
* 6. activation.jar (required for SOAP mode)
@VenkataA
VenkataA / gist:9a0b678666cad22b2615f6a6d5c6dc0e
Last active June 10, 2022 16:17
JavaScript Function - Check to see if date string is less than tomorrow
//Assumes a date string yyyy-mm-dd or mm/dd/yyyy
function isGreaterThanToday(inpDateField) {
var inpDate = inpDateField.rawValue;
var todaysDate = new Date();
todaysDate.setHours(0,0,0,0);
var splitDate = inpDate.split('-');
var nYear = splitDate[0];
var nMonth = splitDate[1];
@VenkataA
VenkataA / sling.properties
Created February 9, 2022 22:48
AEM Forms - update Sling.properties with these two lines added.
sling.bootdelegation.class.com.rsa.jsafe.provider.JsafeJCE=com.rsa.*
sling.bootdelegation.class.org.bouncycastle.jce.provider.BouncyCastleProvider=org.bouncycastle.*
var client = org.apache.http.impl.client.HttpClients.createDefault();
var file = new java.io.File("/home/aem/Downloads/pdf-test.pdf");
var post = new org.apache.http.client.methods.HttpPost("http://localhost:4502/api/assets/testFolder/pdf-test.pdf");
var fileBody = new org.apache.http.entity.mime.content.FileBody(file, org.apache.http.entity.ContentType.DEFAULT_BINARY);
var nameBody = new org.apache.http.entity.mime.content.StringBody("pdf-test.pdf", org.apache.http.entity.ContentType.MULTIPART_FORM_DATA);
builder = org.apache.http.entity.mime.MultipartEntityBuilder.create();
@VenkataA
VenkataA / gist:8d711b07a9961fff1668d93cacaa4e35
Created January 7, 2022 15:02
AEM - ECMA - Write data to a node
var path = "/var/app_folder/my_file.txt";
var jcrsession = graniteWorkflowSession.adaptTo(Packages.javax.jcr.Session);
var node = jcrsession.getNode(path);
var stream = new java.io.ByteArrayInputStream(new java.lang.String(updateCountInfoStr).getBytes("UTF-8") );
node.getNode("jcr:content").setProperty("jcr:data", stream);
@VenkataA
VenkataA / gist:977b673e9696b4eadb58869a301591c5
Created January 7, 2022 14:48
AEM ECMAScript - Read from a JCR Node
var path = "/var/my_app_folder/my_file.txt";
var jcrsession = graniteWorkflowSession.adaptTo(Packages.javax.jcr.Session);
var node = jcrsession.getNode(path);
var is = node.getNode("jcr:content").getProperty("jcr:data").getStream();
var stringInputStream = org.apache.commons.io.IOUtils.toString(is, "UTF-8");
is.close();
@VenkataA
VenkataA / gist:b7cc48356760e8e1f3499b1de88eac63
Created January 7, 2022 14:42
AEM Forms - Required Libraries - Yum
yum -y install glibc.i686
yum -y install libcurl.i686
yum -y install libICE.i686
yum -y install libicu.i686
yum -y install libicu
yum -y install libSM.i686
yum -y install libuuid.i686
yum -y install libX11.i686
yum -y install libXau.i686
yum -y install libxcb.i686