<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ricardo Alvarado on Medium]]></title>
        <description><![CDATA[Stories by Ricardo Alvarado on Medium]]></description>
        <link>https://medium.com/@rijoalvi?source=rss-5e8da0e14b97------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Rqw9C4gBxqae55q4.jpg</url>
            <title>Stories by Ricardo Alvarado on Medium</title>
            <link>https://medium.com/@rijoalvi?source=rss-5e8da0e14b97------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 04:23:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rijoalvi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Activating different maven profiles using Adobe Cloud Manager pipelines]]></title>
            <link>https://medium.com/@rijoalvi/activating-different-maven-profiles-using-adobe-cloud-manager-pipelines-69dbf57bfcdb?source=rss-5e8da0e14b97------2</link>
            <guid isPermaLink="false">https://medium.com/p/69dbf57bfcdb</guid>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[maven-profiles]]></category>
            <category><![CDATA[adobe-cloud-manager]]></category>
            <dc:creator><![CDATA[Ricardo Alvarado]]></dc:creator>
            <pubDate>Sat, 23 Mar 2024 01:30:38 GMT</pubDate>
            <atom:updated>2024-03-23T01:30:38.395Z</atom:updated>
            <content:encoded><![CDATA[<p>Enabling and disabling profiles in maven is a very common practice in all projects. There are integrations, configurations and tasks that we want to run on specific environments, or that we want to avoid for a specific build. However, when using Cloud Manager as your build server this becomes a bit of a challenge due to the limited documentation there is on this topic.</p><p>The purpose of this post is to save you the work of going over the whole <a href="https://experienceleague.adobe.com/docs/experience-manager-cloud-manager/content/introduction.html?lang=en">Cloud Manager documentation</a> just to find out at first sight that it looks like the only flag you can use to enable/disable a profile in Cloud Manager is env.CM_BUILD, which only tells you if your build is running in cloudmanager or not. <a href="https://experienceleague.adobe.com/docs/experience-manager-cloud-manager/content/getting-started/project-creation/project-setup.html#activating-maven-profiles-in-cloud-manager">As per Adobe’s documentation</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*Q-7T4STHIaBg2kXdBxIjeA.png" /></figure><p>The interesting thing here is that it not only shows that you can use the env.CM_BUILD flag, but you can actually use <em>any</em> environment variable present in Cloud Manager as a flag!</p><p>Therefore, looking again at the C<a href="https://experienceleague.adobe.com/docs/experience-manager-cloud-manager/content/getting-started/project-creation/build-environment.html?lang=en#environment-variables">loud Manager environment variables</a>, the following variables can be used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*ZgEYnV2X6gSW5ioiC5nQqA.png" /><figcaption>List of variables available in Adobe Cloud Manager</figcaption></figure><p>Now we are talking! with that list of variables you can create a profile that is activated for a particular program id, branch or any other of the cloud manager variables defined above. For example, here is a profile running for a specific pipeline id:</p><pre>&lt;profile&gt;<br>    &lt;id&gt;preproduction-pipeline&lt;/id&gt;<br>    &lt;activation&gt;<br>          &lt;property&gt;<br>                &lt;name&gt;env.CM_PIPELINE_ID&lt;/name&gt;<br>                &lt;value&gt;090210&lt;/value&gt;<br>          &lt;/property&gt;<br>    &lt;/activation&gt;<br>    &lt;build&gt;<br>        &lt;plugins&gt;<br>            &lt;plugin&gt;<br>                &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;<br>                &lt;version&gt;1.8&lt;/version&gt;<br>                &lt;executions&gt;<br>                    &lt;execution&gt;<br>                        &lt;phase&gt;initialize&lt;/phase&gt;<br>                        &lt;configuration&gt;<br>                            &lt;target&gt;<br>                                &lt;echo&gt;I&#39;m running only for pipeline 09210!&lt;/echo&gt;<br>                            &lt;/target&gt;<br>                        &lt;/configuration&gt;<br>                        &lt;goals&gt;<br>                            &lt;goal&gt;run&lt;/goal&gt;<br>                        &lt;/goals&gt;<br>                    &lt;/execution&gt;<br>                &lt;/executions&gt;<br>            &lt;/plugin&gt;<br>        &lt;/plugins&gt;<br>    &lt;/build&gt;<br>&lt;/profile&gt;</pre><p>I hope this helps someone else! There’s not a lot of documentation on this topic, so I guess every new document counts 😃</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69dbf57bfcdb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AEM 6.4 HttpContext use case]]></title>
            <link>https://medium.com/@rijoalvi/aem-6-4-httpcontext-use-case-5824e486ebaf?source=rss-5e8da0e14b97------2</link>
            <guid isPermaLink="false">https://medium.com/p/5824e486ebaf</guid>
            <category><![CDATA[bundle]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[httpcontext]]></category>
            <category><![CDATA[aem]]></category>
            <dc:creator><![CDATA[Ricardo Alvarado]]></dc:creator>
            <pubDate>Mon, 06 Aug 2018 19:39:46 GMT</pubDate>
            <atom:updated>2018-08-06T19:39:46.891Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VIrASrMWiySHstjaQwF4GA.jpeg" /><figcaption>Looking for the missing HttpContext service!</figcaption></figure><p>Recently, I have been working on migrating an AEM 6.2 instance to AEM 6.4 and of course, I have faced some issues and have been forced to do some modifications to have the website bundles running.</p><p>One of the main issues I had was the fact that the one of the bundles registers a servlet, but includes AEM’s default HttpContext in this registration so that we can use the system login when a user was not logged in certain paths defined in the servlet.</p><p>Here is where the problem began: It turns out that the HttpContext Service running in AEM 6.2 is not available in AEM 6.3 or 6.4 So there was no other way around than starting to research, test, cry and repeat until I found a solution.</p><p>I started by checking the <a href="https://osgi.org/javadoc/r6/cmpn/org/osgi/service/http/HttpContext.html">org.osgi.service.http.HttpContext</a> class methods: From the three methods this class has (getMimeType<em>, </em>getResource and handleSecurity) it turns out that the one used to check if a user is logged in is the <a href="https://osgi.org/javadoc/r4v41/org/osgi/service/http/HttpContext.html#handleSecurity(javax.servlet.http.HttpServletRequest,%20javax.servlet.http.HttpServletResponse)">handleSecurity</a> one. So that’s the one I had to focus.</p><p>After some time going in circles, <a href="https://forums.adobe.com/thread/2517972">I posted a question in the AEM Forums</a> where they advised me to use <a href="https://osgi.org/javadoc/r6/cmpn/org/osgi/service/http/context/ServletContextHelper.html">ServletContextHelper</a> instead of going for HttpContext. Turns out that AEM 6.4 does have a ServletContextHelper service registered and running, but it’s just its default implementation, which always returns true when calling the handleSecurity<em> </em>method.</p><p>So, after some more time researching, I found out that what the 6.2 HttpContext does when calling the handleSecurity method is just using the class <a href="https://sling.apache.org/apidocs/sling6/org/apache/sling/auth/core/AuthenticationSupport.html">org.apache.sling.auth.core.AuthenticationSupport</a> and calling its handleSecurity<em> </em>method! So, after checking in 6.4, it turned out that the AuthenticationSupport service was actually available!</p><p>So, after all of that I just had to set up the lego and let it go!<br>Basically I created a custom HttpContext object implementing the <a href="https://osgi.org/javadoc/r6/cmpn/org/osgi/service/http/HttpContext.html">HttpContext</a> interface. I set the object’s constructor to receive a ServletContextHelper and a AuthenticationSupport object.<br>Basically I use the ServletContextHelper default responses for the getMimeType and getResource methods, and I use the<em> </em>AuthenticationSupport handleSecurity method as follows:</p><pre>public class MyHttpContextImpl implements HttpContext {<br>  ServletContextHelper myServletContextHelper = null;<br>  AuthenticationSupport myAuthenticationSupport = null;<br><br>  public MyHttpContextImpl(ServletContextHelper servletContextHelper, AuthenticationSupport authenticationSupport) {<br>    myServletContextHelper = servletContextHelper;<br>    myAuthenticationSupport = authenticationSupport;<br>  }<br><br>  @Override<br>  public String getMimeType(String name) {<br>    return myServletContextHelper.getMimeType(name);<br>  }<br><br>  @Override<br>  public URL getResource(String name) {<br>    return myServletContextHelper.getResource(name);<br>  }<br><br>  @Override<br>  public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException {<br>    return myAuthenticationSupport.handleSecurity(request, response);<br>  }<br>}</pre><p>After that is just a matter of getting the AuthenticationSupport and ServletContextHelper services from the bundleContext, creating a new instance of our HttpContext and registering it as an AEM service:</p><pre>AuthenticationSupport authenticationSupport = null;<br>ServiceReference&lt;AuthenticationSupport&gt; authSupportReference = bundleContext.getServiceReference(AuthenticationSupport.class);<br>if (authSupportReference != null) {<br>  authenticationSupport = bundleContext.getService(authSupportReference);<br>}</pre><pre>ServletContextHelper servletContextHelper= null;<br>ServiceReference&lt;ServletContextHelper&gt; servletContextReference = bundleContext.getServiceReference(ServletContextHelper.class);<br>if (servletContextReference != null) {<br>  servletContextHelper = bundleContext.getService(servletContextReference);<br>}</pre><pre>ServiceRegistration&lt;HttpContext&gt; httpContextReg = null;<br>Dictionary&lt;String, Object&gt; httpContextProps = new Hashtable&lt;&gt;();<br>if (servletContextHelper != null &amp;&amp; authenticationSupport != null) {<br>  httpContextReg = bundleContext.registerService(HttpContext.class, new MyHttpContextImpl(servletContextHelper, authenticationSupport), httpContextProps);<br>}</pre><p>And that’s it! Now you have your custom HttpContext service you can use on your application!</p><p>I hope this helps someone else! I spend quite a few time finding out how to set this up, and there was few reference about this issue.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5824e486ebaf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jenkins dynamic parameters using Extended Choice Parameter Plugin and Groovy]]></title>
            <link>https://medium.com/@rijoalvi/jenkins-dynamic-parameters-using-extended-choice-parameter-plugin-and-groovy-1a6ffc41063f?source=rss-5e8da0e14b97------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a6ffc41063f</guid>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[groovy]]></category>
            <category><![CDATA[parameter]]></category>
            <category><![CDATA[curl]]></category>
            <category><![CDATA[ajax]]></category>
            <dc:creator><![CDATA[Ricardo Alvarado]]></dc:creator>
            <pubDate>Thu, 02 Nov 2017 00:08:41 GMT</pubDate>
            <atom:updated>2018-07-31T19:40:30.077Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*J5X2FGpvgWaX8BUbQsOiuw.png" /><figcaption><a href="https://jenkins.io/">Super Jenkins!!!</a></figcaption></figure><p>Lately I have been involved into Jenkins jobs creation and configuration. One of the tasks I had to face lately was adding some parameters to a job, where one the parameters was a dropdown list populated using an AJAX JSON call.</p><p>I started researching for options to do this, and I found that you need certain things to accomplish this: First of all, the out-of-the-box Jenkins functionality does not support this kind of things, so you need to search for a plugin that support script execution so you can do there the AJAX call and response processing to provide the options to the list. For this, I found out that you can do this with the <a href="https://wiki.jenkins.io/display/JENKINS/Extended+Choice+Parameter+plugin">Extended Choice Parameter Plugin</a>.</p><p>To install this plugin, you simply need to go to your jenkins instance and navigate to “/pluginManager/available”, and then search for “<strong>Extended Choice Parameter Plug-in</strong>” in the search box.<br><strong>Be careful!</strong> There is another plugin called “Extensible Choice Parameter Plug-in”. That is <strong>not</strong> the one you’re looking for!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*08CJdumWOjrs9QCNp5uMvQ.png" /><figcaption>Installing the Extended choice parameter in your Jenkins server</figcaption></figure><p>Once the plugin is installed, then you can start working on the script. This plugin uses Apache Groovy scripts. Just in case, Groovy is an object-oriented programming language for the Java platform, which means that if you know java, you’ll be fine using Groovy.</p><p>So, first things first, we need to understand how does the plugin works. When you are configuring your job, you can add parameters to it. There, you can select an Extended Choice parameter option:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E7zik8EF-KP4Ak5NjZf_ag.png" /><figcaption>Adding an Extended Choice Parameter to a Jenkins Job</figcaption></figure><p>Right after adding your parameter, you need to set a name for it. Be careful! The name would be used as both the label that is going to be displayed when building the job, and also as the variable name, so avoid using spaces!. This is something that I particularly don’t like. I would have preferred to have a field for the variable name and another one for the label (maybe there’s an option for that and I just haven’t found it yet 😅). After setting the name, you have to define if you want your parameter to be a basic one, a multi-level one or a JSON one. if you want to go and study all the options, I would recommend you to go to the <a href="https://wiki.jenkins.io/display/JENKINS/Extended+Choice+Parameter+plugin">Extended Choice Parameter Plugin wiki</a>. For this example, we are going to be using the <strong>“Basic Parameter Types”</strong> option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kIZobSZwxpQW96dQvNPNfg.png" /></figure><p>Here is where we start coding. For this example, our parameter name is going to be “version-to-build”. Also, the JSON file we are going to fetch is going to look like this:</p><pre>{<br>   &quot;data&quot;:[<br>      {<br>         &quot;text&quot;:&quot;0.0.18&quot;,<br>         &quot;isMetadata&quot;:false<br>      },<br>      {<br>         &quot;text&quot;:&quot;0.0.10&quot;,<br>         &quot;isMetadata&quot;:false<br>      },<br>      {<br>         &quot;text&quot;:&quot;metadata.xml&quot;,<br>         &quot;isMetadata&quot;:true<br>      },<br>      {<br>         &quot;text&quot;:&quot;0.0.33&quot;,<br>         &quot;isMetadata&quot;:false<br>      },<br>      {<br>         &quot;text&quot;:&quot;0.0.4&quot;,<br>         &quot;isMetadata&quot;:false<br>      }<br>   ]<br>}</pre><p>As you can see, we are going to look for the “text” elements in the objects, but we also are going to take into account the “isMetadata” property to avoid adding things like “metadata.xml” to our list of version items. Finally, as you can see, the versions are not in order, so we are going to need to sort them so they are from the most recent one to the oldest one.</p><p>So, all of that work needs to be done using Groovy. Also, it is very important to be aware that the script needs to return a list/array of Strings , which is going to be consumed by the plugin.</p><p>Ok so now let’s go to the code. We are going to start by fetching the JSON file. For this, we are using <a href="https://curl.haxx.se/">curl</a>. In case you don’t know how to install it, here’s how to do it for <a href="https://stackoverflow.com/a/16216825">windows</a>. If you have a mac you should already have it installed, but just in case, here’s a <a href="http://www.vettyofficer.com/2013/06/how-to-install-curl-in-mac-os-x.html">link </a>on how to do it.</p><p>Once you are sure that you have curl, then you can try the following code:</p><pre>import groovy.json.JsonSlurper</pre><pre>try {<br>    List&lt;String&gt; artifacts = new ArrayList&lt;String&gt;()<br>    def artifactsUrl = &quot;http://localhost:8081/data-items.json&quot;          <br>    def artifactsObjectRaw = [&quot;curl&quot;, &quot;-s&quot;, &quot;-H&quot;, &quot;accept: application/json&quot;, &quot;-k&quot;, &quot;--url&quot;, &quot;${artifactsUrl}&quot;].execute().text<br>    def jsonSlurper = new JsonSlurper()<br>    def artifactsJsonObject = jsonSlurper.parseText(artifactsObjectRaw)<br>    def dataArray = artifactsJsonObject.data<br>    for(item in dataArray){<br>        if (item.isMetadata== false)<br>        artifacts.add(item.text)<br>    } <br>    return artifacts<br>} catch (Exception e) {<br>    print &quot;There was a problem fetching the artifacts&quot;<br>}</pre><p>So, let’s analyze the code:<br>First, we’re importing the JsonSlurper class, which according <a href="http://docs.groovy-lang.org/latest/html/gapi/groovy/json/JsonSlurper.html">to the documentation</a> it “parses text or reader content into a data structure of lists and maps.” basically we’re doing a curl request to retrieve the JSON file, then parsing it to an object and going through it in a for loop, validating its “isMetadata” flag, and adding the valid elements to the artifacts array. Pretty simple, huh?<br>By the way, I based my code in the instructions given by Rahul Sharma in <a href="https://www.coveros.com/generate-parameter-values-dynamically-jenkins/">this post</a></p><p>To run this, you just need to go to your Jenkins job, and in the Extended Choice Parameter you added (the one named version-to-build), select the “Groovy Script” option under the “ Choose Source for Value” section:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o8acs9DOgOp5g5kC6BPD-w.png" /><figcaption>Adding your script to your Extended Choice Parameter</figcaption></figure><p>With this, you can save your job, build it and you will find the surprise that you need to go to the “In-Process Script Approval” section to approve your script!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ov1JHAVoB-eikNWdO4YbMA.png" /><figcaption>Trying to build your job without approving your script</figcaption></figure><p>So, just go to /scriptApproval/ in your server, and then hit the approve button. Go back and build your job:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pdbHA5CPl38KRBjoVmmhYQ.png" /><figcaption>A job with AJAX parameters!!!</figcaption></figure><p>Voila! Your job now has an AJAX parameter. But there is still one issue: They are not sorted from the newest to the oldest one!. For this, I found <a href="http://groovy.329449.n5.nabble.com/groovy-class-which-implements-version-string-ordering-tp353013p353016.html">this thread</a> to sort the versions from the oldest one to the newest one, and then <a href="http://mrhaki.blogspot.com/2009/12/groovy-goodness-putting-our-list-in.html">this post</a> to inverse the order so I can have the latest one first. I’m sure that there are many other (and some of them even better) ways to do this, but this is what I ended up doing:</p><pre>import groovy.json.JsonSlurper</pre><pre>def recurse <br>def versionArraySort = { a1, a2 -&gt; <br>    def headCompare = a1[0] &lt;=&gt; a2[0] <br>    if (a1.size() == 1 || a2.size() == 1 || headCompare != 0) { <br>        return headCompare <br>    } else { <br>        return recurse(a1[1..-1], a2[1..-1]) <br>    } <br>} <br>// fool Groovy to understand recursive closure <br>recurse = versionArraySort</pre><pre>def versionStringSort = { s1, s2 -&gt; <br>    def nums = { it.tokenize(&#39;.&#39;).collect{ it.toInteger() } } <br>    versionArraySort(nums(s1), nums(s2)) <br>}</pre><pre>try {<br>    List&lt;String&gt; artifacts = new ArrayList&lt;String&gt;()<br>    def artifactsUrl = &quot;http://localhost:8081/data-items.json&quot;<br>    def artifactsObjectRaw = [&quot;curl&quot;, &quot;-s&quot;, &quot;-H&quot;, &quot;accept: application/json&quot;, &quot;-k&quot;, &quot;--url&quot;, &quot;${artifactsUrl}&quot;].execute().text<br>    def jsonSlurper = new JsonSlurper()<br>    def artifactsJsonObject = jsonSlurper.parseText(artifactsObjectRaw)<br>    def dataArray = artifactsJsonObject.data<br>    for(item in dataArray){<br>        if (item.isMetadata == false)<br>        artifacts.add(item.text)<br>    } <br>    return artifacts.sort(versionStringSort).reverse()<br>} catch (Exception e) {<br>    print &quot;There was a problem fetching the artifacts&quot; + e<br>}</pre><p>With this code, if you run your job, you get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tpotpOI3kjzo5VwvRb6GMA.png" /><figcaption>A Jenkins job with an AJAX versions param sorted from latest to oldest one!</figcaption></figure><p>So , there you go! You have a job with an AJAX param. Now it’s just accessing the global variable ${version-to-build} you created to get the selected item!</p><p>I hope this can help someone who needs to develop something similar. I’m aware that the is not much documentation about some Jenkins plugins and sometimes it is confusing to learn how to use them. I like to think that with this I’m helping with this documentation in some way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a6ffc41063f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up an Amazon EC2 AWS Server with Tomcat7 (running on ports 80 & 443), MySQL & Oracle JDK 1.7]]></title>
            <link>https://medium.com/@rijoalvi/setting-up-an-amazon-ec2-aws-server-with-tomcat7-running-on-ports-80-443-mysql-oracle-jdk-1-68bcc42bdb94?source=rss-5e8da0e14b97------2</link>
            <guid isPermaLink="false">https://medium.com/p/68bcc42bdb94</guid>
            <category><![CDATA[tomcat]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Ricardo Alvarado]]></dc:creator>
            <pubDate>Tue, 27 Oct 2015 07:16:23 GMT</pubDate>
            <atom:updated>2017-12-12T18:43:11.249Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting up an Amazon EC2 AWS Server with Tomcat7 (running on ports 80 &amp; 443), MySQL &amp; Oracle JDK 1.7 and linking it to a domain</h3><p>I’ve been wanting to give AWS a try for a long time, but until yesterday I wasn’t fully convinced on using it. I’m sharing the experience I had with my first setup on it since it might help other people who wants to do the same thing (and save them some time surfing for guides to do it).</p><p>Here’s my scenario: I’ve been developing a java application which uses a MySQL Database and runs on Tomcat 7. I wanted to be able to publish it on the internet, so I decided to buy a domain a few weeks ago. I didn’t bought it on amazon, I bought it from a 3rd party, and I wanted to link it to my AWS DNS.</p><p>So, these are the steps I followed to achieve this:</p><ul><li>Creating an Amazon Web Services Account:<br>If you don’t have an AWS account, the first thing to do would be to create one. You can go to <a href="http://aws.amazon.com/">http://aws.amazon.com/</a>, click on “Create an AWS Account” and follow the steps. Keep in mind that you need to enter a valid phone number and have it verified before using the service. You’ll get a call from amazon asking you to enter your PIN code on the phone. Also, you need to enter your card’s data even if you’re using only the free tier (in case you start using the paid services).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*dDkPEg6pSrEcgfycO02uCQ.png" /><figcaption>Figure 1. Creating an AWS Account</figcaption></figure><ul><li>Launching an EC2 Instance:<br>Once you’re on the AWS control panel, you need to find the EC2 service, click on it and then click on the “Instances” section. After that, you need to select “Launch Instance”. Then you need to select a virtual machine to launch. In my case, I selected an “Amazon Linux AMI 2015.09 (HVM), SSD Volume Type”, which applies to the free tier. Then you need to set a name/tag to your instance, and then you need to create and download a key pair. <strong>It is very important to save this key pair in a safe place, and create a backup just in case, because there’s no way of recovering this file if you lose it, and you need it to remotely connect to your instance</strong>.<br>After downloading the file, you need to open your console and type in the following command:</li></ul><pre>$ chmod 400 my-key-pair.pem</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*yIqMqbst-PhDymiw2nxHZw.png" /><figcaption>Figure 2. Choosing the EC2 instance Machine</figcaption></figure><ul><li>Configuring your instance’s firewall:<br>To finish your instance configuration you need to configure your firewall by creating a new security group, and setting a SSH rule (so you can remotely access the machine), an “ALL ICMP” rule (for enabling ping) and a custom TCP rule for port 8080, so you can access the tomcat server default port. I also added HTTP and HTTPS rules, since I’m planning on using those ports for accessing Tomcat.</li><li>Getting your server’s public IP<br>Once you’ve launched your machine, you need to go to the “instances” section on the EC2 control panel, and find the “Public DNS row”. This is your server’s public IP, which you can use to remotely connect to it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*HQ4iOssMXa1mB6YKLuK7RQ.png" /><figcaption>Figure 3. Finding the instance’s public IP</figcaption></figure><ul><li>Connecting to your instance<br>If you’re using windows, you’ll need to use a ssh software like <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">PuTTY</a>. If you’re using linux or a mac, you can use the terminal. You can login by navigating to the folder where you have your key file and using a command like this:</li></ul><pre>ssh -i MY_KEY_FILE.pem ec2-user@MY-SERVER-PUBLIC-URL.us-west-2.compute.amazonaws.com</pre><pre><br>Once logged, you&#39;ll see something like this:</pre><pre>Authenticating with public key &quot;AWS-Tomcat&quot;<br>Passphrase for key &quot;AWS-Tomcat&quot;:<br><br>       __|  __|_  )<br>       _|  (     /   Amazon Linux AMI<br>      ___|\___|___|<br><br>See /usr/share/doc/system-release/ for latest release notes.<br>No packages needed for security; 16 packages available</pre><ul><li>Updating the server:<br>This is quite easy, you only need to run the following command:</li></ul><pre>$ sudo yum update</pre><ul><li>Installing Oracle’s JDK 1.7<br>By default, AWS instances come with Open JDK 1.7, which is not bad, but sometimes you’ll prefer the Oracle version of it. If that’s the case, you need to log in via ssh to your instance and type the following commands:</li></ul><pre># Downloading the JDK<br>$ wget — no-cookies — no-check-certificate — header “Cookie: oraclelicense=accept-securebackup-cookie” “http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.rpm&quot; -O jdk-7-linux-x64.rpm</pre><pre># Installing the JDK<br>$ sudo rpm –ivh jdk-7-linux-x64.rpm</pre><pre># Checking if the server’s default java version is Sun JDK (usually it is OpenJDK)<br>$ java -version</pre><pre># Creating an alternative for Sun JDK<br>$ sudo /usr/sbin/alternatives — install /usr/bin/java java /usr/java/jdk1.7.0_55/bin/java 20000</pre><pre># Setting Sun JDK as the default JVM<br>$ sudo /usr/sbin/alternatives — config java</pre><pre># Checking if the change was performed correctly<br>$ java -version</pre><ul><li>Installing Tomcat 7:<br>In order to download and install Tomcat7, you need to type the following commands in the console:</li></ul><pre># Installing Tomcat<br>$ sudo yum install tomcat7</pre><pre># Starting Tomcat<br>$ sudo service tomcat7 start</pre><pre># Installing Tomcat documentation, examples &amp; webapps administrator<br>$ sudo yum install tomcat7-webapps tomcat7-docs-webapp tomcat7-admin-webapps</pre><pre># Checking that tomcat is running fine in port 8080:<br>$ sudo fuser -v -n tcp 8080<br> <br># You’ll get something like this if everything’s fine<br>                        USER    PID  ACCESS  COMMAND<br> 8080/tcp:              tomcat  pid  F….     java</pre><pre># Stopping Tomcat (only use it if you need to stop the server)<br>$ sudo service tomcat7 stop</pre><ul><li>Creating a GUI user for using the Tomcat webapps manager:<br>Tomcat has a web interface that you can use to manage your webapps, but you need to configure your users file to do so. I configured mine like this:</li></ul><pre>$ sudo nano /etc/tomcat7/tomcat-users.xml</pre><pre># The file should look similar to this one:<br>&lt;tomcat-users&gt;<br>    &lt;role rolename=”tomcat”/&gt;<br>     &lt;role rolename=”role1&quot;/&gt;<br>     &lt;role rolename=”manager-gui”/&gt;<br>     &lt;user username=“myUser” password=“myPass” roles=”tomcat,role1,manager-gui/&gt;<br>&lt;tomcat-users&gt;</pre><ul><li>Installing MySQL:<br>You need to type the following commands in the console to get MySQL Running:</li></ul><pre># Installing it<br>$ sudo yum install mysql-server<br> <br># After the installation you’ll get some commands that I recommend to run if you’re planning to use the database in a production environment</pre><pre># Setting the database to start when the instance does<br>$ sudo chkconfig mysqld on</pre><pre># Starting MySQL<br>$ sudo service mysqld start</pre><ul><li>Setting tomcat to run in ports 80 &amp; 443:<br>There are many ways to achieve this. Some of them need you to install an apache server, and handle the different XML configuration files, but I think that this is a quite easy way, and you don’t need to install anything else, you just need to learn a little bit on how to use iptables so you can redirect the requests from port 80 to 8080 and from port 443 to 8443.<br>To do so, you can type in the following commands in your console:</li></ul><pre># Checking the current iptables content on the prerouting table<br>$ sudo /sbin/iptables -L -n -t nat</pre><pre># Adding the rules:<br>$ sudo /sbin/iptables -t nat -I PREROUTING -p tcp —-dport 80 -j REDIRECT --to-port 8080<br>$ sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8443</pre><pre># Checking that the rules were added succesfully<br>$ sudo /sbin/iptables -L -n -t nat</pre><pre># Saving the rules<br>$ sudo /sbin/service iptables save</pre><pre># Restarting ipTables:<br>$ sudo /etc/init.d/iptables restart</pre><pre># Checking that the rules were saved succesfully<br>$ sudo /sbin/iptables -L -n -t nat</pre><ul><li>Setting a Static IP to your instance:<br>If you want to associate a domain to your EC2 instance, you need to have a static IP. For this, amazon provides you with the “Elastic IP”, which you can find on the EC2 control panel (under “Network &amp; Security”). Once you click on this section, you need to allocate a new address and associate it to your instance (the user interface is quite intuitive for this).<br>Keep in mind that once you do this, the public ip from your instance will change, and you’ll have to go back to the EC2 control panel to copy the new address and log in again from your terminal with the new address.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*VapnaXuF8PLL4_f3-PSMtg.png" /><figcaption>Figure 4. Allocating a new Static IP Address</figcaption></figure><ul><li>Associating a domain to your EC2 instance<br>To associate your domain, you need to get your domain name servers addresses. For this, we need to use another AWS service called <a href="https://console.aws.amazon.com/route53/">Route 53</a>, which is the one in charge of domain management. The url for this service is <a href="https://console.aws.amazon.com/route53/">https://console.aws.amazon.com/route53/</a>.<br>Once you’re on the Route 53 control panel, you need to create a Public hosted zone. You need to give it the name of the domain you’re going to use. When it’s ready, you can check the “Record Sets” and you’ll find an entry with 4 name servers in it. These are the ones you need to enter on your domain management platform. In my case, since I bought my domain from Hostgator, I’m using the domain admin console they have to change the default name servers and replace them with the ones on the “Record Sets” entry.<br>Finally, once you’re done with this, you need to go back to Route 53 and create a new record set, type A — IPv4 address, value: your static IP (you can get it from the Elastic IP section on the EC2 control panel). Leave the “name” field empty.<br>Once you finish with this, you can wait for a little bit so that the new name servers are associated with your domain and then enter your domain to see the Tomcat homepage as your landing page :D</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w3So0363XdbszT2OuKcgPQ.png" /><figcaption>Figure 5. Getting the name servers and setting the static ip from your instance in AWS Route 53</figcaption></figure><p>That’s it!<br>My next steps would be adding a SSL Certificate to my instance, but I haven’t done this yet. Once I’ve done it, I’ll update the entry with this new step.</p><p>Of course I didn’t came up with this guide myself, I researched and read a lot of guides on the different topics and I put them all in this entry, so I’m leaving the urls of the different webpages I consulted so you can check them out and see where I got all this stuff.</p><ul><li><a href="http://ubuntuforums.org/showthread.php?t=1111454">http://ubuntuforums.org/showthread.php?t=1111454</a></li><li><a href="http://www.excelsior-usa.com/articles/tomcat-amazon-ec2-basic.html">http://www.excelsior-usa.com/articles/tomcat-amazon-ec2-basic.html</a></li><li><a href="http://charlie.cu.cc/2012/04/how-run-tomcat-port-80-amazon-web-service-aws/">http://charlie.cu.cc/2012/04/how-run-tomcat-port-80-amazon-web-service-aws/</a></li><li><a href="https://alextheedom.wordpress.com/cloud/amazon-free-usage-tier-installing-tomcat-7-on-an-ec2-linux-instance/">https://alextheedom.wordpress.com/cloud/amazon-free-usage-tier-installing-tomcat-7-on-an-ec2-linux-instance/</a></li><li><a href="https://gist.github.com/scottvrosenthal/11187116">https://gist.github.com/scottvrosenthal/11187116</a></li><li><a href="https://alextheedom.wordpress.com/cloud/amazon-free-usage-tier-installing-tomcat-7-on-an-ec2-linux-instance/">https://alextheedom.wordpress.com/cloud/amazon-free-usage-tier-installing-tomcat-7-on-an-ec2-linux-instance/</a></li><li><a href="http://examples.javacodegeeks.com/enterprise-java/tomcat/tomcat-users-xml-configuration-example/">http://examples.javacodegeeks.com/enterprise-java/tomcat/tomcat-users-xml-configuration-example/</a></li><li><a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html">http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html</a></li><li><a href="http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingHostedZone.html">http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingHostedZone.html</a></li><li><a href="http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/GetInfoAboutHostedZone.html">http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/GetInfoAboutHostedZone.html</a></li><li><a href="http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/rrsets-working-with.html">http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/rrsets-working-with.html</a></li><li><a href="http://stackoverflow.com/questions/5029877/i-bought-a-domain-and-i-want-to-apply-it-on-my-amazon-ec2-instance">http://stackoverflow.com/questions/5029877/i-bought-a-domain-and-i-want-to-apply-it-on-my-amazon-ec2-instance</a></li><li><a href="http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-ec2-instance.html">http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-ec2-instance.html</a></li><li><a href="http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/GetInfoAboutHostedZone.html">http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/GetInfoAboutHostedZone.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68bcc42bdb94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Customizing CQ5/AEM’s Column Control Component]]></title>
            <link>https://medium.com/@rijoalvi/customizing-cq5-aem-s-column-control-component-f463f8b1551a?source=rss-5e8da0e14b97------2</link>
            <guid isPermaLink="false">https://medium.com/p/f463f8b1551a</guid>
            <category><![CDATA[column-control]]></category>
            <category><![CDATA[cq5]]></category>
            <category><![CDATA[aem]]></category>
            <dc:creator><![CDATA[Ricardo Alvarado]]></dc:creator>
            <pubDate>Thu, 16 Apr 2015 06:17:22 GMT</pubDate>
            <atom:updated>2015-04-16T06:42:45.383Z</atom:updated>
            <content:encoded><![CDATA[<p>I ran into a situation where I had to understand how does the column control component works and how to customize it. I’m documenting it in case someone else needs some help with.</p><p><strong>How it works:</strong><br>The column control is a component that resides inside the parsys, specifically on <em>/libs/foundation/components/parsys/colctrl</em>, but its rendering functionality is managed by the parsys component, on the parsys.jsp file Here if checks if the paragraph type is START, BREAK, END or NORMAL. If it is “NORMAL”, then there’s no column control on the parsys, otherwise, It’s necessary to know if the column control component is starting, changing to a new column or ending.(this happens between lines 35 and 59 of the file parsys.jsp. I’m not posting the file portion because of the licensing).</p><p><strong>How to manage the column control component on a page:</strong><br>To manage the ammount of columns you need to go to design mode and open the column control design dialog. You can add there as many column layouts as you want. The format for each fields goes as follows:</p><p>[Number of Columns] + ‘;’ + [Columns Class] + ‘\t’ + [Format Label]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*IrS6QshvVBbyI0gd6l2MGw.png" /><figcaption>Column Control’s Design Dialog</figcaption></figure><p>Just in case, the “Format Label” is the label that is going to be displayed on a selectbox on the column’s regular dialog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*HV7DLZcQhYl8bHWbh0B7dA.png" /><figcaption>Column Control’s Standard Dialog</figcaption></figure><p>Once you have selected a column layout, you can notice by checking the source code, that the class you set on the design dialog for the selected layout is being used on the column control markup:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*0unih-jhn1qvTJjS4iGL_A.png" /><figcaption>Markup for the selected columns layout</figcaption></figure><p>Also, note that each column is assigned a class similar to the one defined on the design dialog, but with a -c0, -c1 etc. This way you can completely control the columns wrapper, and each column layout via your custom css.</p><p><strong>Modifying the columns markup to add an extra custom class to the columns wrapper:</strong><br>In my particular case, I had to modify the column control’s dialog to add a custom css class to the wrapper of it. To achieve this, I had to copy the parsys and iparsys components from its original path (<em>/libs/foundation/components/parsys</em> and <em>/libs/foundation/components/iparsys</em>) to the apps folder (<em>/apps/my-project/components/parsys</em> and <em>/apps/my-project/components/iparsys</em>). Once I did this, I modified the dialog on <em>/apps/my-component/components/parsys/colctrl/dialog</em> to add my custom property field, in this case a textfield, so it looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*jHBftjA2G9IUALx0vaJ10Q.png" /><figcaption>Custom field on the column control dialog</figcaption></figure><p>After this, the challenge was how to read this property. First thing to notice is that the colctrl.jsp file is not the one that draws the columns. The actual file where the property needs to be read is the parsys.jsp, and also iparsys.jsp<br>To read the dialog custom property and store it on a variable, you need to add the following code after line 49 of both files (parsys.jsp and iparsys.jsp)</p><pre>//adding custom class name for columns wrapper<br>Node parNode = par.adaptTo(Node.class);<br>String customClass = &quot;&quot;;<br>if(parNode.hasProperty(&quot;cl:colsClass&quot;)){<br>customClass = parNode.getProperty(&quot;cl:colsClass&quot;).getString();<br>}</pre><p>Once the value is stored on the <em>customClass</em> variable, you only need to display it wherever you want on the jsp file, using</p><pre>&lt;%= customClass %&gt;</pre><p>That’s it!<br>Now you can enjoy your custom column control component. Just keep in mind that the parsys/iparsys that you need to include on your project is the one on the apps/your-project folder instead of the one on libs/foundation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f463f8b1551a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>