Highlighted

Need to print the value cq:properties from cq:AuditEvent query

Avatar

Avatar

loydzedric

Avatar

loydzedric

loydzedric

27-06-2018

Hi,

I am a bit lost on how to get the value of the cq:properties which has a datatype of Binary into our custom reports.

InputStream is = null;

if (auditNode.hasProperty("cq:properties")) {

   is = auditNode.getProperty("cq:properties").getBinary().getStream();
   java.util.Properties rawProps = new java.util.Properties();
   rawProps.load(is);
   Enumeration e = rawProps.propertyNames();
   String value = "";
  while (e.hasMoreElements())

  {

  String key = (String)e.nextElement();
   String rawValue = rawProps.getProperty(key);
   value = new String(rawValue.getBytes("ISO-8859-1"), "UTF-8");
   logger.info("TEST BINARY: "+ value);
   logger.info("TEST KEY: " + key);
   logger.info("TEST RAWVALUE: " + rawValue);
   }

}

Current Output (this is the problem):

TEST BINARY: modifiedDatesr  java.util.Datehj? KYt    xpw    d ?9?xt  changessr  java.util.HashSet?D?????4   xpw     ?@      t  jcr:content/flow/process/timeoutt )jcr:content/flow/process/EXTERNAL_PROCESSt Fjcr:content/flow/process/metaData/offloadingOutputIncludeWorkflowModelt +jcr:content/flow/process/jcr:lastModifiedByt 2jcr:content/flow/process/metaData/advanceOnTimeoutt Ejcr:content/flow/process/metaData/offloadingInputIncludeWorkflowModelt Jjcr:content/model/nodes/node2/metaData/offloadingInputIncludeWorkflowModelt  jcr:content/flow/process/periodt )jcr:content/flow/process/advanceOnTimeoutt Kjcr:content/model/nodes/node2/metaData/offloadingOutputIncludeWorkflowModelt )jcr:content/flow/process/jcr:lastModifiedt  jcr:content/cq:lastModifiedt *jcr:content/model/metaData/cq:lastModifiedt -jcr:content/flow/process/PROCESS_AUTO_ADVANCEx

Expected Output:

jcr:content/flow/process/timeout

jcr:content/flow/process/EXTERNAL_PROCESS

jcr:content/flow/process/metaData/offloadingOutputIncludeWorkflowModel

jcr:content/flow/process/jcr:lastModifiedBy

jcr:content/flow/process/metaData/advanceOnTimeout

jcr:content/flow/process/metaData/offloadingInputIncludeWorkflowModel

jcr:content/model/nodes/node2/metaData/offloadingInputIncludeWorkflowModel

jcr:content/flow/process/period

jcr:content/flow/process/advanceOnTimeout

jcr:content/model/nodes/node2/metaData/offloadingOutputIncludeWorkflowModel

jcr:content/flow/process/jcr:lastModified

jcr:content/cq:lastModified

jcr:content/model/metaData/cq:lastModified

jcr:content/flow/process/PROCESS_AUTO_ADVANCE

I have tried logging it first, it retrieves all values with different characters, which is incorrect.

Our objective is to build a custom report which will replicate audit-log-search OOB functionalities. We have done the report, we just only have issue retrieving the column "cq:properties" because it has abnormal characters.