Sitemap

Thursday, September 13, 2018

List of important StackExchange links

How can I efficiently generate a Set<Id> from a List<SObject>
https://salesforce.stackexchange.com/questions/8910/how-can-i-efficiently-generate-a-setid-from-a-listsobject-structure

Why are foreach loops slower in Apex than standard for loop?
https://salesforce.stackexchange.com/questions/227272/why-are-foreach-loops-slower-in-apex-than-standard-for-loop


Monday, April 2, 2018

Machine learning crash course from Google

https://ai.google/education#?modal_active=none
https://developers.google.com/machine-learning/crash-course/

Wednesday, May 24, 2017

AEM: SegmentNotFoundException Segment not found

A SegmentNotFoundException in the error log means a segment is not present any more although we are still trying to access it.

To resolve this, please follow the below steps:

Download oak-run jar file from here http://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/
* AEM6.0 - If using Oak 1.0.12 or later then use Oak 1.1.8 - oak-run-1.1.8.jar. If the Oak version is 1.0.11 or earlier then use oak-run 1.1.6.
Note: We are using a 1.1.x branch version of oak-run because 1.0.x branch doesn't have the "check" command implemented.

1) Stop AEM

2) Run this command:
java -jar oak-run-*.jar check -d1 --bin=-1 -p crx-quickstart/repository/segmentstore/
It which will search backwards through the revisions until it finds a consistent one, Example:
14:00:30.783 [main] INFO o.a.j.o.p.s.f.t.ConsistencyChecker - Found latest good revision afdb922d-ba53-4a1b-aa1b-1cb044b535cf:234880

3)Revert the repository to this revision by editing ./crx-quickstart/repository/segmentstore/journal.log. Delete all lines after the line containing the latest good revision.
If you would like to find out what date and time you are reverting the repository to then run this command in the segmentstore folder (replace afdb922d-ba53-4a1b-aa1b-1cb044b535cf with the latest good revision in your journal.log):
find . -type f -name "data*.tar" -exec sh -c "tar -tvf {} |grep afdb922d-ba53-4a1b-aa1b-1cb044b535cf" \; -print
The output would show you an approximate date and time of that revision.

4)Remove all ./crx-quickstart/repository/segmentstore/*.bak files.

5)If using AEM6.0 then download the oak-run version matching what is installed in AEM for the remaining steps. Download it from here http://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/

6)Run checkpoint clean-up to remove orphaned checkpoints:
java -jar oak-run-*.jar checkpoints ./crx-quickstart/repository/segmentstore rm-unreferenced

7)Finally compact the repository:
java -jar oak-run-*.jar compact ./crx-quickstart/repository/segmentstore/


After the Above steps are completed, your system should now boot up properly.

Tuesday, January 24, 2017

Utility for taking backup of AEM contents

This utility is in the form of a unix shell script. The script will take the backup of AEM contents present in production author instance, create a zip file of it, download it and keep it in a particular location as defined in the script. Once the process is completed, an email will be sent to users to let them know the status of the job, whether the process was a success or resulted in an error. To automate this entire process, a cronjob can be set up which needs to be scheduled.

The technical document and the script are attached in a zip file. Check the downloads section for the zip file.

Friday, August 5, 2016

UCM: GET_SEARCH_RESULTS iterating resultset

package com.company;

import oracle.stellent.ridc.IdcClient;
import oracle.stellent.ridc.IdcClientException;
import oracle.stellent.ridc.IdcClientManager;
import oracle.stellent.ridc.IdcContext;
import oracle.stellent.ridc.model.DataBinder;
import oracle.stellent.ridc.model.DataObject;
import oracle.stellent.ridc.model.DataResultSet;
import oracle.stellent.ridc.protocol.ServiceResponse;

import java.util.List;

/**
 * Created by Sonal_Chaudhary on 8/4/2016.
 */
public class ExtractEmailIDs {
    public static void main(String[] args) {
        int startIndex = 1;
        int pageNumber = 1;
        int totalRows = 20;
        IdcClientManager manager = new IdcClientManager();
        try {
            IdcClient idcClient = manager.createClient("idc://143.127.54.171:4444");
            IdcContext userContext = new IdcContext("sysadmin");

            boolean stillLoop = true;
            while (stillLoop) {
                DataBinder dataBinder = idcClient.createBinder();
                dataBinder.putLocal("IdcService", "GET_SEARCH_RESULTS");
                dataBinder.putLocal("QueryText", "dSecurityGroup <contains> `Partner`  <AND>  xLanguage <contains> `4`  <AND>  xCountries <contains> `1`");
                dataBinder.putLocal("SearchQueryFormat", "Universal");
                dataBinder.putLocal("StartRow", Integer.toString(startIndex));
                dataBinder.putLocal("ResultCount",  Integer.toString(totalRows));
                dataBinder.putLocal("PageNumber",  Integer.toString(pageNumber));
                dataBinder.putLocal("TotalRows",  Integer.toString(totalRows));

                ServiceResponse response = idcClient.sendRequest(userContext, dataBinder);
                DataBinder responseData = response.getResponseAsBinder();
                DataResultSet resultSet = responseData.getResultSet("SearchResults");

                if (resultSet != null && resultSet.getRows() != null) {
                    List<DataObject> dataObjects = resultSet.getRows();
                    if (dataObjects.size() == totalRows) {
                        startIndex += totalRows;
                        pageNumber++;
                    } else {
                        stillLoop = false;
                    }
                    for (DataObject dataObject : dataObjects) {
                        System.out.println(dataObject.get("dID") + "," + dataObject.get("dDocName") + "," + dataObject.get("dExtension"));
                    }
                }
            }
        } catch (IdcClientException ice) {
            ice.printStackTrace();
        }
    }
}

Saturday, July 16, 2016

Java: Arrays

package com.company;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 * Created by Sonal_Chaudhary on 7/16/2016.
 */
public class TestScoreAverage {
    public static void main(String[] args) {
        final int NUMBER_OF_STUDENTS = 3;

        /**
         * The first statement declares a variable called numbers of the array type, with each element of type int. The
         * second statement allocates contiguous memory for holding 10 integers and assigns the memory address of the first
         * element to the variable numbers. The declaration and allocation can be done in the same statement like below:
         * int[] marks = new int[NUMBER_OF_STUDENTS];
         * Array literals provide a shorter and more readable syntax while initializing an array like below:
         * int[] marks = {15, 2, 9, 200, 18};
         */
        int[] marks;
        marks = new int[NUMBER_OF_STUDENTS];

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));


            for (int i = 0; i < NUMBER_OF_STUDENTS; i++) {
                System.out.print("Enter marks for student #" + (i + 1) + ": ");
                String str = reader.readLine();
                marks[i] = Integer.parseInt(str);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        //The clone method copies all the elements of the array into a new array
        int[] marksCopy = marks.clone();

        int total = 0;

        /**
         * The for-each construct is very useful if you want to traverse all the elements of the array. Specifically,
         * it allows you to iterate over collections and arrays without using iterators or index variables. The for-each
         * has certain restrictions. It can be used for accessing the array elements but not for modifying them.
         * The 'm' specifies the type of variable and its name.
         * for (int m : marks) {
         *      System.out.println (m);
         * }
         */
        for (int m : marksCopy) {
            total += m;
        }

        System.out.println("Average Marks " + (float) total / NUMBER_OF_STUDENTS);
        System.out.println(Arrays.toString(marksCopy)); //To print the contents of an array
    }
}


Wednesday, May 11, 2016

AEM Sightly

Templates
http://adobeaemclub.com/guide-for-working-with-templates-and-call-in-sightly-aem-6-1/

data-sly-repeat / data-sly-list / sly / URL manipulation
http://www.accunitysoft.com/tag/data-sly-repeat/