Imran on August 2nd, 2017

Atlas-webapp module is the kick start of Apache Atlas server and application. When we run python code to start server it invokes the main class Atlas.java of this module. It sets required configuration for application, runs embedded jetty server and deploy application on that server. This module also loads sample data for Atlas; contains utility classes for notification, security, REST services etc. This module also contains code for different authentication mechanisms like LDAP, AD, Kerberos.

Webapp serves two types of clients web browser and command line. Atlas-dashboard views calls REST service and command line client directly executes main method of Java class. Below is the high level architecture diagram of atlas-webapp

Tags: ,

Imran on February 13th, 2017

Few common ways out many ways to manual and automatic build creation on Jenkins are:

Manual Build:

 

Polling the repository:

Now, it is possible to setup a Build Trigger to get Jenkins to poll for changes in a Git repository. You do this using the Poll SCM option on the project configuration page in Jenkins. * * * * * means it will poll every minute for new commit changes. If changes found then it will create a build.

By enabling Poll SCM and entering a cron expression * * * * * in the Schedule text box we can get Jenkins to poll the repository for changes every minute. You can enter whatever cron expression you like but this serves as a simple example.

Polling the repository is a bit ugly and inefficient. Wouldn’t it be better to get Git to notify Jenkins of a commit and to trigger a build that way? Well you can do just that using ‘Git hooks’.

Triggering a build using Git hooks:

Inside every Git repository there’s a hidden .git folder. Inside the .git folder is a hooks subfolder. This folder can hold scripts that are executed by Git when it performs certain operations. I’m not going to delve into Git hooks here.

Github WebHooks:

Whenever code is committed. Github hook will notify Jenkins and build will get started. For this setting you can got to your github/bitbucket project –> setting –> WebHooks –> Add new webhook. Give your Jenkins URL like https://USERNAME:PASSWORD@jenkins.example.com/github-webhook/

OR

http://jenkins.example.com/github-webhook/

 

 

 

Tags:

Imran on January 6th, 2017

Download DynamoDb in from AWS .zip format

After you have downloaded the archive, extract the contents and copy the extracted directory to a location of your choice.

To start DynamoDB on your computer, open a command prompt window, navigate to the directory where you extracted DynamoDBLocal.jar, and enter the following command:

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

Create Table:
————-

  1. Now install Amazon SDK for Java in eclipse.
  2. Go to Help–>Install new software and Add new repository location. Amazon services – http://aws.amazon.com/eclipse
  3. After it fetches information then select ” AWS Toolkit for Eclipse Core (Required)” and install it.
  4. After installation and restart of Eclipse, give you AWS account Access Key credentials prompted by Eclipse. These credentials are required even if you are going to use DynamoDB locally.
  5. Now go to File–>New project. Expand AWS and select “AWS Java Project”. It will generate necessary files and add required jars in your project.
  6. Now use below mentioned code to create table locally through Java.

 

Tags: , ,

Imran on October 6th, 2016

To create your own custom exception in Python. Simply create a new class of your exception:

Now use this in your code like:

Above custom exception will be printed alongwith arguments

Raising custom exception
Error … This is custom exception

Imran on September 26th, 2016

Wicket is a Java framework for creating web frontends. It allows you to create a webpage in Java, combining all kinds of components into one page.

In many projects, a subset of user interface elements are repeated over the site. Depending on your project, you can have different selection panels or popups that are used multiple times.

In the following tutorial I describe a method to write your own application specific reusable modal window popup.
Start!

For this example, we use the ModalWindow component from Wicket Extensions.If you don’t know what a ModalWindow looks like, you can see a demo. (hint: try to drag and drop it or resize it)
The example from Wicket extensions

The default example from the Wicket Extensions site contains no real reusable components, besides the ModalWindow itself. The Page inside the ModalWindow is tightly coupled to the ModalWindow. It closes its containing ModalWindow and sets a result parameter of the parent page. The components can only be reused in exactly the same way.
How can we make this more reusable?

We can make this more reusable by making the content of the ModalWindow not aware of the ModalWindow itself. The content does not know what will happen when the containing Form (or other data) is submitted. But how can we do that? The magic words are: abstract methods.

Before we start, you can download the code here, so you can get the complete picture.

The image on the right contains the structure of the page and the components we are creating. The page contains a modal window, which in turn contains a content panel.
The Content Panel

Lets start with the content panel inside the ModalWindow popup. This panel contains a selection link, a selection button and a cancel button, created in the constructor:

[..]

HTML:

You probably noticed the calls to onSelect() and onCancel(). These are the abstract methods we are declaring:

abstract void onCancel(AjaxRequestTarget target);
abstract void onSelect(AjaxRequestTarget target, String selection);

These methods are abstract, that way the code that is calling this panel must implement these methods. Because we are calling these methods, this effectively gives the result to the consuming code, without ever knowing what will happen with it.

To use abstract methods, the class itself must be abstract:
public abstract class SelectContentPanel extends Panel
The Modal Window

The Modal Window initializes itself with some values. You can just as easily set these values from the calling class, but for now we keep it local.

HTML:

The setContent() function call is interesting. Here we create a new SelectContentPanel and implement the methods onCancel() and onSelect(). It is possible to do some extra actions here, but here it is passed one-on-one to the abstract methods of the ModalWindow itself:

abstract void onCancel(AjaxRequestTarget target);
abstract void onSelect(AjaxRequestTarget target, String selection);

The Home Page

The Home Page itself can now instantiate the ModalWindow, override the methods and do something with the data. One big advantage is that you can see from the HomePage class directly what is going to happen after the user selects something or cancels the action:

Further customization

This example is just passing a String around, you can change it to a more specific class. You can change the onSelect to something more appropriate for your use case. You can even put a Form inside the panel and return the resulting object of the form

Imran on July 14th, 2016

You seem to be doing this in SQL*Plus or SQL Developer, from the variable declaration. You need to do the assignment in a PL/SQL block, either with an explicit begin/end or with the exec call that hides that:

variable imageID number;
exec select SEQ_IMAGE_ID.CURRVAL into :imageID from dual;
select * from IMAGES where IMAGE_ID = :imageID;

If you’re using 11g you don’t need to select, you can just assign:

variable imageID number;
exec :image_id := SEQ_IMAGE_ID.CURRVAL;
select * from IMAGES where IMAGE_ID = :imageID;

You could also use a substitution variable:

column tmp_imageid new_value image_id;
select SEQ_IMAGE_ID.CURRVAL as tmp_imageID from dual;
select * from IMAGES where IMAGE_ID = &imageID;

Note the change from : to indicate a bind variable, to & to indicate a substitution variable.

Tags:

Imran on June 28th, 2016

The following table briefly summarizes the conversion characters defined by log4j:

What to print Conversion character Performance
Category name (or logger name) c Fast
Fully qualified class name C Slow
Date and time d

d{format}

Slow if using JDK’s formatters.

Fast if using log4j’s formatters.

File name of Java class F Extremely slow
Location (class, method and line number) l Extremely slow
Line number only L Extremely slow
Log message m Fast
Method name M Extremely slow
Priority (level) p Fast
New line separator n Fast
Thread name t Fast
Time elapsed (milliseconds) r Fast
Thread’s nested diagnostic context x Fast
Thread’s mapped diagnostic context X Fast
Percent sign %% Fast

And next are some useful patterns compiled by us for common usage and specific needs.

Standard conversion pattern

A standard (and probably most used) pattern would contain the following information: priority, date and time, category, method, and message.

Pattern: [%p] %d %c %M – %m%n

Example output: [INFO] 2012-11-02 22:46:43,896 MyClass foo – this is a log message

Ref

Tags: , ,

Imran on January 6th, 2016

Configuration for spring security of users to be authenticated from LDAP is:

<security:authentication-manager>
<security:ldap-authentication-provider
user-search-filter=”${ldap.userfilter}”
user-search-base=”${ldap.userbase}”
group-search-filter=”${ldap.groupfilter}”
group-search-base=”${ldap.groupbase}”   />
</security:authentication-manager>

<security:ldap-server url=”${ldap.servers}”
manager-dn=”${ldap.binddn}”
manager-password=”${ldap.bindpwd}” />

Tags: ,

Imran on December 9th, 2015

com.sun.net.httpserver.HttpServer can do so. A HttpServer is bound to an IP address and port number and listens for incoming TCP connections from clients on this address.

Tags:

Imran on December 2nd, 2015

Spring Security uses Spring EL for expression support and you should look at how that works if you are interested in understanding the topic in more depth. Expressions are evaluated with a “root object” as part of the evaluation context. Below is the configuration for “applicationContext.xml”. Security will be active for any url with pattern /admin. Only user with ADMIN role can access this resource. For this spring config is:

 

To permit all users to a particular resource user:

 

To block any other request use:

security form login can be setup as:

For logout:

Users are also configured in spring configuration file. It can also be configured to authenticate users from some datasource like ldap.

Full “applicationContext.xml”

—————-

Spring security filtering in web.xml

Tags: , ,