Spring MVC Email API Integration Process

Spring MVC Email API Integration Process -

Write bean dependencies in .xml file and include his dependent jar file in work repository. 

<!-- Spring Email Sender Bean Configuration -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="mail.gmail.com" />
<property name="port" value="587" />
<property name="username" value="email@gmail.com" />
<property name="password" value="password" />

Java Instance Of Object Uses

Instance Of Uses

/* (non-Javadoc)
* @see com.techa2zsoln.allcustom.services.IUserService#registerUserCredentials(com.techa2zsoln.allcustom.dto.RegisterUserSelf)
*/
@Override
public boolean registerCredentials(Object object) {


Database Query - Standard Formats.

DB Grants & Synonym.

GRANT PRIVALAGES ON TABLE_NAME TO SCHEMA_NAME
GRANT SELECT ON TABLE_NAME TO SCHEMA_NAME

First Schema Name is target Schema, Second Schema is Actual where table is exists.
CRATE OR REPLACE SYNONYM SCHEMA_NAME.TABLE_NAME FOR SCHEMA_NAME.TABLE_NAME

SQL Query by  With Operation and creating cases.

Spring Security Web Failure Handler Using Super Class SimpleUrlAuthenticationFailureHandler

Custom Spring Security Web failure handler..

/**
 * @author Wasim Ansari
 *
 */

    <!-- custom form security developed using spring -->
    <security:http auto-config="true" use-expressions="true" >
    <!-- When we working on ip address validation through role at that time you can use hasIpAddress validation with access security interceptor -->
<!-- <security:intercept-url pattern="/successurl/**" access="hasAnyRole('ROLE_ADMIN', 'ROLE_USER') and hasIpAddress('127.0.0.1')" /> -->

<security:intercept-url pattern="/successurl/**" access="hasAnyRole('ROLE_ADMIN', 'ROLE_USER')" />

<security:form-login login-page="/login" always-use-default-target="true"
    authentication-success-handler-ref="customAuthSuccessHandler" authentication-failure-handler-ref="customAuthFailureHandler" />

<security:session-management invalid-session-url="/loginfailed" >
    <!-- <security:concurrency-control expired-url="/loginfailed" max-sessions="1" error-if-maximum-exceeded="true"  /> -->
    <security:concurrency-control expired-url="/loginfailed"  />
</security:session-management>

<security:logout invalidate-session="true" success-handler-ref="customLogoutSuccessHandler" delete-cookies="JSESSIONID"  />
<!-- by default , on back click link session will be destroyed.. -->
<!-- <security:logout invalidate-session="true" success-handler-ref="customLogoutSuccessHandler" delete-cookies="JSESSIONID"  /> -->
</security:http>

Spring security - Bean dependencies .


Server Side Pagination Using Spring

Controller class -
List<UserInfo> loadUserInfoDetails = service.getAllUserInfoDetails();
    if(loadUserInfoDetails.size() > CommonUtils.PAGE_MAX_VALUE) {
    int pageNumberRequest = 0;
    if( !request.getParameter("page").isEmpty() ) {
    pageNumberRequest = Integer.parseInt(request.getParameter("page"));
    }
    commonPaginationService.makePaginationLogic(CommonUtils.PAGE_MIN_VALUE, CommonUtils.PAGE_MAX_VALUE, loadUserInfoDetails, mav, pageNumberRequest);
    }
    mav.setViewName("admin/welcome");


Custom Security Via Hashing Password, Use Express For Roles & Handle Browser Cashe.

Servlet configuration To Manage MVC architecture.

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:int-security="http://www.springframework.org/schema/integration/security"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:security="http://www.springframework.org/schema/security"
    xmlns:jms="http://www.springframework.org/schema/jms" xmlns:amq="http://activemq.apache.org/schema/core"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/integration/security http://www.springframework.org/schema/integration/security/spring-integration-security-2.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
        http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
        http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
   

Default Spring Form Security & Custom Secuity

Follow HttpBasic configuration for web.xml configuration to add Deligating Filter Proxy for spring security and Dispatcher Servlet for manage spring mvc structure.

https://techa2zsolution.blogspot.in/2017/08/http-basic-security-using-spring.html#more

Now creating custom and default spring form like.

Http Basic Security Using Spring Framework


Http Basic Security Using Spring Framework :

In web.xml File

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/dyn-security.xml</param-value>
</context-param>

<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

Send SMS Using Java

private String smsGatewayUserId = "";
    private String smsGatewayPassword = "";
    private String smsGatewayURL = "";
    private String urlEncoding = "UTF-8";
    private String smsGatewaySID = "";

    private static String csvFilePath = "/var/www/";

    public String getMessage(String ar[]) {

        return null;
    }
  
public String sendSMS(String mobileNo, String msg) {

Creating SVN Repository In UBUNTU (Linux) System

1) Up-to-Date Installed Packages
sudo apt-get update
2) Downloading the Subversion, Subversion Tools and Libapache2 packages
you need to run svn subversion and it's tools by using commands
sudo apt-get install subversion subversion-tools libapache2-svn
3) Creating Subversion (SVN) Directory
creating svn directory, where you want to configure svn.
sudo mkdir /home/svn

Maths Server Using Socket Programming

It is time to implement a more comprehensive network application by using the socket programming APIs you have learned so far. A sample math client-server interaction demonstrating online math server that can perform basic math operations,

package com.techa2zsolution.intf.math;

public interface MathService {
    public double add(double firstValue, double secondValue);
    public double sub(double firstValue, double secondValue);
    public double div(double firstValue, double secondValue);
    public double mul(double firstValue, double secondValue);
}

Get the database size, Free space and last update

To get the current database size just by querying into your query browser or CLI from the INFORMATION_SCHEMA database in table TABLES.


SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;

Get the database free space

SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema;

Get the database last update ordered by update time then by create time.

SELECT MAX(UPDATE_TIME), MAX(CREATE_TIME), TABLE_SCHEMA
FROM `TABLES`
GROUP BY TABLE_SCHEMA
ORDER BY 1, 2;

JFree Chart Via Java Programming

PIE Chart Using JFree Chart :
 
First required database connection, as per connection provide sql query to retrieve data from database. 
JDBCPieDataset dataset = new JDBCPieDataset(connection);
        try {
            dataset.executeQuery("SQL QUERY");
                    JFreeChart chart = ChartFactory.createPieChart
                    ("Performance - Report", dataset, true, true, false);
                    chart.setBorderPaint(Color.white);
                    chart.setBorderStroke(new BasicStroke(10.0f));
                    chart.setBorderVisible(true);
                    if (chart != null) {
                        int width = 500;
                        int height = 350;
                        final ChartRenderingInfo info = new ChartRenderingInfo (new StandardEntityCollection());
                        response.setContentType("image/png");
                        OutputStream out=response.getOutputStream();
                        ChartUtilities.writeChartAsJPEG(out, chart, width, height,info);
                    }
        }catch (SQLException e) {
            e.printStackTrace();
        }

Excel File Data Reading Using Spring MVC

 Uploading EXCEL - 2003, 2007 file's using file uploading UI, and insert all file data into database.

                            <form:form modelAttribute="bulkfileupload" role="form" enctype="multipart/form-data" >
                                            <div class="form-group">
                                                <label>Upload Excel File !</label>
                                                <form:input type="file" path="uploadFile" id="uploadFile"  />
                                                <div class="has-error">
                                                    <form:errors path="uploadFile" class="help-inline" />
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <input type="submit" value="upload">
                                            </div>
                                        </form:form>

For handling request of multipart/form-data, required MultipartResolver interface to handle file request. for that configure bean tage in xml file or

Path Variables In Spring Framework

Spring Framework offers to handle URI method parameters by using @PathVariable annotation

@Controller
@RequestMapping("admin")
public class PathVarController {

@RequestMapping("/welcome/{springPathVariable}/{page}")
public ModelAndView pathVariableTest(@PathVariable("page") String name, @PathVariable("springPathVariable") String pathVariable ) {

ModelAndView mav = new ModelAndView("pathVariable");
mav.addObject("message", " "+ name+" Your PathVariable is : "+pathVariable);
return mav;
}
}

Shell Script Tips

Shell Script, delete last 30 day's records from system.

#!/bin/bash
# Delete log files older than 30 days in this script.

find /var/log/tomcat7/localServer/logs/ -mtime +30 -type f -delete
echo "-----------------------------------------------------"
echo "$(date)"
echo "Deleted files older than 30 days in this location :: /var/log/tomcat7/ "


Custom Tag In Java

Custom Tag Library use to make own tag in jsp by extending TagSupport class, build xml with (.tld) extension file, which specify the result would you want to use.
Java Server Page (JSP) contain standard tag library @taglib for including (.tld) file.

public class CustomTagTest extends TagSupport {

public CustomTagTest() { }

@Override
public int doStartTag() throws JspException {
JspWriter out = pageContext.getOut();//returns the instance of JspWriter
   try{

Design Pattern Tutorial


Design Pattern are best practices how to solve common know problems. This article will give an overview of best practices in object-oriented programming and has pointers to some design-pattern tutorials.
Design patterns are proven solutions approaches to specific problems. A design pattern is not a framework and is not directly deployed via code.

Design Pattern have two main usages:

Api Integration

This tutorial will focus on the basic principles and mechanics of testing a REST API with live Integration Tests with a JSON Results.
For an internal application, this kind of testing will usually run as a late step in a continuous Integration process, consuming the REST API after it has already been deployed.
When testing a REST resources, there are usually a few orthogonal responsibilities the tests should focus on:


SDLC Process

Software Development Life Cycle, or Software Development Process, defines the steps/ stages/ phases in the building of software.


software development life cycle
Software Development Life Cycle 

SDLC IN SUMMARY

  • Project Planning
  • Requirements Development
  • Estimation
  • Scheduling
  • Design
  • Coding
  • Test Build/Deployment
  • Unit Testing
  • Integration Testing
  • User Documentation
  • System Testing
  • Acceptance Testing
  • Production Build/Deployment
  • Release
  • Maintenance

SDLC stands for software development life cycle. A software development life cycle is essentially a series of steps, or phases, that provide a model for the development and life cycle management of an application or piece of software.