Showing posts with label Tools. Show all posts
Showing posts with label Tools. Show all posts

Saturday, 21 April 2018

aemsync tool

AEM sync tool pushed code to multiple AEM instances instantly when there is a file change.

Prerequisites:

Install npm on your machine.

Installation

Run below npm command to install aemsync

npm install aemsync -g
The tool pushes code changes to AEM instance(s) upon a file change.
  • There is no vault dependency.
  • It can push to multiple instances at the same time (e.g. author and publish).
  • IDE/editor agnostic.
  • Works on Windows, Linux and Mac.

Tuesday, 4 July 2017

Currency converter service

I am attaching simple program about, How to write Simple Currency Converter using Java Program. The program was written using Fixer Currency Converter Webservice. In this example, I am using Gson 2.8.0 API to convert JSON to Object in Java. you can download API from here.

CurrencyConversionResponse.java

package com.kishore.generic;

import java.util.Map;
import java.util.TreeMap;

public class CurrencyConversionResponse {

    private String base;
    private String date;

    private Map<String, String> rates = new TreeMap<String, String>();

    public Map<String, String> getRates() {
        return rates;
    }

    public void setRates(Map<String, String> rates) {
        this.rates = rates;
    }

    public String getBase() {
        return base;
    }

    public void setBase(String base) {
        this.base = base;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

}

CurrencyConvertor.java

package com.kishore.generic;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;

import com.google.gson.Gson;

public class CurrencyConvertor {

    // API Provider URL
    private static final String API_PROVDIER = "http://api.fixer.io/";

    public static double convert(String fromCurrencyCode, String toCurrencyCode) {

        if ((fromCurrencyCode != null && !fromCurrencyCode.isEmpty())
                && (toCurrencyCode != null && !toCurrencyCode.isEmpty())) {

            CurrencyConversionResponse response = getResponse(API_PROVDIER
                    + "/latest?base=" + fromCurrencyCode);

            if (response != null) {

                String rate = response.getRates().get(toCurrencyCode);

                double conversionRate = Double.valueOf((rate != null) ? rate: "0.0");

                return conversionRate;
            }

        }

        return 0.0;
    }

    // Method to get the response from API
    private static CurrencyConversionResponse getResponse(String strUrl) {

        CurrencyConversionResponse response = null;

        Gson gson = new Gson();
        StringBuffer sb = new StringBuffer();

        if (strUrl == null || strUrl.isEmpty()) {

            System.out.println("Application Error");
            return null;
        }

        URL url;
        try {
            url = new URL(strUrl);

            HttpURLConnection connection = (HttpURLConnection) url
                    .openConnection();

            InputStream stream = connection.getInputStream();

            int data = stream.read();

            while (data != -1) {

                sb.append((char) data);

                data = stream.read();
            }

            stream.close();

            response = gson.fromJson(sb.toString(),
                    CurrencyConversionResponse.class);

        } catch (MalformedURLException e) {

            System.out.println(e.getMessage());
            e.printStackTrace();

        } catch (IOException e) {

            System.out.println(e.getMessage());
            e.printStackTrace();
        }

        return response;
    }

    public static void main(String[] args) throws IOException {

        Scanner scanner = new Scanner(System.in);

        System.out.println("What is your currency code ?");
        String fromCurrencyCode = scanner.next();

        System.out.println("Enter the Amount :");
        double amount = scanner.nextDouble();

        System.out
                .println("Enter the Currency Code that you want to covert : ");
        String toCurrencyCode = scanner.next();

        fromCurrencyCode = fromCurrencyCode.toUpperCase();
        toCurrencyCode = toCurrencyCode.toUpperCase();

        // Currency Conversion
        double coversionRate = convert(fromCurrencyCode, toCurrencyCode);

        System.out.println("Hi, The " + amount + " " + fromCurrencyCode
                + " is equivalent to " + (coversionRate * amount) + " "
                + toCurrencyCode + " today.");

        scanner.close();
    }

}

Output

What is your currency code ?
USD
Enter the Amount :
1
Enter the Currency Code that you want to covert : 
GBP
Hi, The 1.0 USD is equivalent to 0.77341 GBP today.



Monday, 4 July 2016

Dialog Conversion Tool

The dialog conversion tool is provided to help you extend existing components that only have a dialog defined for the classic UI (based on ExtJS). The tool uses this original dialog to create a duplicate dialog designed for the touch-optimized UI (based on Granite UI/CoralUI).

Download and Install the Dialog Conversion Tool

  1. Install the package on your instance.file

Wednesday, 1 June 2016

Bulk Editor in AEM

The Bulk Editor allows for very efficient editing when the visual page context is not needed as it lets you:
  • search for (and display) content from multiple pages; this is done using GQL (Google Query Language)
  • edit this content directly in the bulk editor
  • save the changes (to the originating pages)
  • export this content to a tab-separated (.tsv) spreadsheet file
file

Thursday, 28 April 2016

Learn Sightly with Read–Eval–Print Loop in AEM 6.x

A great live code editing environment for Sightly templates with optional server-side JavaScript logic, executed on an Adobe Experience Manager instance. This little tool is great for learning Sightly and for experimenting with it, because the resulting output is displayed as you type.
To get started you need minimum Adobe Experience Manager 6+, there are you two ways you can setup your environment and start experimenting:-
1. Install as a Package
  • Download the built package: com.adobe.granite.sightly.repl-1.0.2.zip.
  • On your running AEM instance, go to Package Manager, click on Upload Package, browse to the previously downloaded package, and hit OK.
  • Install the package com.adobe.granite.sightly.repl-1.0.2.zip. Don’t mind the missing dependencies, simply click the Install button and confirm.
2. Maven Method
  • Checked-out https://github.com/Adobe-Marketing-Cloud/aem-sightly-repl repository with Git clone.
  • Build and install it with following command line instruction:
    mvn clean install content-package:install
Once any of the above steps are performed for installation, go to the following URL on AEM instance localhost:4502/content/repl.html
Sightly Read Eval Print Loop (REPL)
Sightly Read Eval Print Loop (REPL) will give you three options:-
  1. Source :- Shows the generated HTML Structure of webpage
  2. View :- Output of webpage can be seen here, this is the same which you will see in your browser
  3. Java :- Complied sightly Java class
It’s a great environment for people who are willing to get hands on Sightly and want to gain some experience in it.

Thursday, 21 April 2016

Creating a custom Excel Service for Adobe Experience Manager

You can create a custom AEM service that accepts an Excel spreadsheet, extracts the data from the spreadsheet, and persists the data in the AEM JCR. For example, consider the following spreadsheet that contains customer data. Once you upload this file to AEM, the custom AEM Excel service reads the customer data and persists the data in the AEM JCR.