[Fatal Error]  The processing instruction target matching "[xX][mM][lL]" is not allowed.

[Fatal Error] The processing instruction target matching "[xX][mM][lL]" is not allowed.

Error as below??


[Fatal Error] :2:6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:249)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)
at com.lemon.profiler.service.impl.JobServiceImpl.getJob(JobServiceImpl.java:94)
at com.lemon.profiler.action.JobAction.setUpForInsertOrUpdate(JobAction.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Total Profiles on Search by ID Returned :0
2014-04-26 18:56:22,233 ERROR com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.error:38 - Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.lemon.profiler.service.impl.JobServiceImpl.getJob(JobServiceImpl.java:155)
at com.lemon.profiler.action.JobAction.setUpForInsertOrUpdate(JobAction.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)


Solution: Check your xml for space or it doesnt start properly like <?xml version="1.0" encoding="UTF-8"?>

SVN setup in Eclipse

SVN setup in Eclipse

SVN setup in Eclipse


Quick steps.

Step 1: Download, extract and start Eclipse
Step 2: Open webbrowser and visit url : http://subclipse.tigris.org. In the download and install tab get the eclipse URL of desired SVN version say, http://subclipse.tigris.org/update_1.10.x
Step 3: Go to Help > Install New Software > In the dialog box paste the above url. Click Add and name it beautifully! Thats it.
Step 4: Select the components you want to install and accept the licence to start installation.

After a restart eclipse will be ready with SVN

10 PostgreSQL Commands for Developers

10 PostgreSQL Commands for Developers

10 PostgreSQL Commands for Developers

Windows

Start Postgres SQL Server

"pg_ctl" -D "<datafolderpath>" -l logfile start

PostgreSQL Initialize Database

Navigate to ...\pgsql\bin\ and type the following command

initdb.exe <datafolderpath>


PostgreSQL Create Database

Navigate to ...\pgsql\bin\ and type the following command

createdb databasename<enter>

PostgreSQL Create User

Navigate to ...\pgsql\bin\ and type the following command

createuser username<enter>

PostgreSQL Create Role

Navigate to ...\pgsql\bin\ and type the following command

createuser username<enter>

Maven Proxy Settings don't work!?

Maven Proxy Settings don't work!?

Maven Proxy Settings don't work!?


Tried lot of settings.xml alterations and still maven cant update its repository?? Try this

Step

1. Download  : Cntlm Authentication Proxy from here 
2.Install and Configure it with your proxy details.
3. Run it like this cntlm.exe -v -a NTLMv2 -c cntlm.ini
4. Now configure back your settings.xml under .m2 like

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository />
<interactiveMode />
<usePluginRegistry />
<offline />
<pluginGroups />
<servers />
<mirrors />
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>localhost</host>
<port>3128</port>
</proxy>
</proxies>
<profiles />
<activeProfiles />
</settings>

Thats it now you can run your maven commands from console or update the user settings in eclipse to make maven fetch the required jars or reindex them.

Happy Coding..!



Solved : No configuration found for the specified action

Solved : No configuration found for the specified action

Solved : No configuration found for the specified action 


Issue: Warning : No configuration found for the specified action on struts 2 action call..


Fix : Check your struts.xml and action mapping and map it with your jsp form submission
for example,

Action mapping 
<action name="login" method="login"
class="com.tcs.ecmui.action.CredentialWatcher">
<result name="success" type="redirect">getAllPages</result>
<result name="error">/resources/jsp/login.jsp</result>
</action>
..
.. 
<package name="readNode" extends="struts-default,json-default" namespace="/">
</package>


Jsp

<s:form action="login" method="POST">
<s:textfield name="user" label="User" />
<br>
<s:password name="password


Problematic Code :

<s:form action="/login" method="POST">
<s:textfield name="user" label="User" />
<br>
<s:password

or

<s:form action="/login.action" method="POST">
<s:textfield name="user" label="User" />
<br>
<s:password
Struts 2 Rest Convention Plugin Configuration Example

Struts 2 Rest Convention Plugin Configuration Example

Struts 2 Rest Convention Plugin Configuration Example


I was playing around with Struts 2.3.8 and I really liked it the way apache has bundled it with lots of plugins that can help developers shrink their coding efforts hugely.

I was trying with conventions plugin and a simple struts action. The action was not loading saying there is no mapping found.. After couple of tries I could make it work.. Posting the same if some one might find it helpful in saving time..

Action


package com.mycomp.recruit.actions;

import java.util.Collection;

import org.apache.struts2.rest.DefaultHttpHeaders;
import org.apache.struts2.rest.HttpHeaders;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Validateable;
import com.opensymphony.xwork2.ValidationAwareSupport;

@Results({
    @Result(name="success", type="redirectAction", params = {"actionName" , "authentication"})
})
public class AuthenticationController extends ValidationAwareSupport implements ModelDriven<Object>, Validateable{
    
    /**

*/
private static final long serialVersionUID = 1L; 
    private String id; 

    // GET /orders/1
    public HttpHeaders show() {
        return new DefaultHttpHeaders("show");
    }
    
    public HttpHeaders index(){
    System.out.println("Going thru authentication..");    
    return  new DefaultHttpHeaders("index").disableCaching();
    }


    public void validate() { 
    }

    public void setId(String id) {
        if (id != null) { 
        //do nothin!??
        }
        this.id = id;
    }
    
   public Object getModel() { 
  return null;
    }

}


struts.xml


<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
    <!--  Overwrite Convention -->
    <constant name="struts.convention.action.suffix" value="Controller"/>
    <constant name="struts.convention.action.mapAllMatches" value="true"/>
    <constant name="struts.convention.default.parent.package" value="rest-default"/>

    <constant name="struts.convention.package.locators" value="example,actions"/>
    
</struts>


JSP


/web-inf/content/authentication-index.jsp


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Authenticate..
</body>
</html>




Alfresco Authenticate -get the valid ticket & invalidate the login.

Alfresco Authenticate -get the valid ticket & invalidate the login.

Alfresco Authenticate -get the valid ticket & invalidate the login.



import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

public class AuthenticationService {

PropertyService propS = PropertyService.getInstance();

public String validateTicket(String ticket){
URL url = null;
HttpURLConnection connection = null;
try {
String adminTicket = readTicket();
String query = String.format("alf_ticket=%s",
URLEncoder.encode(adminTicket, "UTF-8"));
url = new URL(propS.getKeyValue("systemURL")+ "alfresco/service/api/login/ticket/"+ ticket+ "?"+query);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.connect();
InputStream is = connection.getInputStream();
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
Document xmlDoc = docBuilder.parse(is);
System.out.println("Validated Ticket =>" + xmlDoc.getElementsByTagName("ticket").item(0).getTextContent());
return xmlDoc.getElementsByTagName("ticket").item(0).getTextContent();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection != null) {
connection.disconnect();
}
}
return null;
}

public String readTicket() {
System.out.println("Trying to readTicket()");
URL url = null;
HttpURLConnection connection = null;
try {
String query = String.format("u=%s&pw=%s",
URLEncoder.encode(propS.getKeyValue("adminuser"), "UTF-8"),
URLEncoder.encode(propS.getKeyValue("adminpassword"), "UTF-8"));
url = new URL(propS.getKeyValue("systemURL")+"alfresco/service/api/login?"
+ query);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.connect();
InputStream is = connection.getInputStream();
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
Document xmlDoc = docBuilder.parse(is);
System.out.println("Ticket =>"
+ xmlDoc.getElementsByTagName("ticket").item(0)
.getTextContent());
return xmlDoc.getElementsByTagName("ticket").item(0)
.getTextContent();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection != null) {
connection.disconnect();
}
}
return null;
}

public boolean invalidatelogin(String ticket){
URL url = null;
HttpURLConnection connection = null;
try{
String adminTicket = readTicket();
String query = String.format("alf_ticket=%s",
URLEncoder.encode(adminTicket, "UTF-8"));
url = new URL(propS.getKeyValue("systemURL")+ "alfresco/service/api/login/ticket/"+ ticket+ "?"+query);

connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded" );
connection.setRequestMethod("DELETE");
int responseCode = connection.getResponseCode();

connection.connect();
System.out.println("<<<<>>>>" +responseCode);
}catch(Exception e){
e.printStackTrace();
}
finally {
if (connection != null) {
connection.disconnect();
}
}
return true;
}

//Test method
public static void main(String args[]){
String newP = "TICKET_368733fe59db7b634b5767c807538f27db9f403a";
AuthenticationService au = new AuthenticationService();
//newP = au.readTicket();
System.out.println(" Validate Ticket ::> "+newP);
au.validateTicket(newP);
// System.out.println("Deletion : "+au.invalidatelogin(newP));
}
}

10 Best SQLClients for Developers

10 Best SQLClients for Developers

10 Best SQLClients for Developers

1. Postgresql Maestro


Download URL: http://www.sqlmaestro.com/products/postgresql/maestro/

2. pgModeller


Download URL: http://pgmodeler.com.br/

3. SQLManager



Download URL: http://sqlmanager.net/

4. phpPgAdmin


Download URL: http://phppgadmin.sourceforge.net

5. TeamPostgreSQL


Download URL : http://www.teampostgresql.com/

6. Adminer


Download URL: http://www.adminer.org/

7. dbVis


Download URL: http://www.dbvis.com/

8. phpMyAdmin


Download URL: http://www.phpmyadmin.net

9. Navicat


Download URL: http://www.navicat.com/

10.SQLExplorer


Download URL: http://eclipsesql.sourceforge.net/‎


Manually Start PostgreSQL Windows

Start PostgreSQL in Windows


Download and install/extract the postgre server

Create a data folder under pgsql as
C:\softwares\installed\pgsql\data

Open command prompt and Navigate to the extracted/installed folder,

For Example
C:\softwares\installed\pgsql\bin

and type the following command



pg_ctl -D C:\softwares\installed\pgsql\data -l logfile start





finally,
type initdb.exe C:\softwares\installed\pgsql\data for initializing the database


Javascript for loop Example

Javascript for loop Example

Javascript for loop Example



for(var i=0; i<=10; i++){
    alert("Counter is at "+i);
}

What to note??
From java only a small but confusing difference :

In Javascript it is :

for(var i=0;

Where as in java it is something like for(int i=0; ......... Being a java developer you will be tempted to use int i instead of a var declaration..

Example..

for(var i=0; i<=arr.length; i++){
var property = arr[i].split("=");
var propertyName = property[0];
var propertyVal = property[1];
        //... continue custom logic
 }
Alfresco - view state cannot be reconstructed

Alfresco - view state cannot be reconstructed

Alfresco - view state cannot be reconstructed 


This is a very familiar exception for Alfresco users,

Cause:

There are a lot of reasons for this exception and is noticed in Alfresco Explorer. The causes for this vary from
1. User session expiry, 
2. applying amp file, 
3. UI customizations
4. Wrong configs etc.

As per Alfresco, this is a message/exception "specially for developers". And for those who wants the details needs to refer the system logs on where it went wrong.. However few of the issues causing these has been fixed in 4.1x version of Alfresco.

Ways to find the node ids of a content in Alfresco

Ways to find the node ids of a content in Alfresco

It is a common need when working with Alfresco to find a contents node id for multiple reasons. If you are naïve or medium level techie person follow below notes to find a contents node id.
Ways,
From Alfresco Explorer
From Alfresco Share
By Javascript code,
By Alfresco SDK

From Alfresco Explorer
Hover the content
Hovering the content item in Alfresco displays its target url embedded with a servlet with its node id. Check lower left corner of your browser.. (I use google Chrome!?). Copy the target url and paste it in a notepad to make it how you want..



The same can be found in download link of the content and few of the other actions associated with it
Node Browser
Click on the Administration Console button in your Alfresco Explorer on which you can find Node Browser option.

Selecting the corresponding stores, you will be listed with contents(or Alfresco nodes) along with their node details.


Alfresco Share
Hover works with Share too but only has got a slightly different url mix up. Copy the target url and paste it in a notepad to make it how you want..



The same can be found in download link of the content and few of the other actions associated with it
Navigate to the desired content to get its detail.



Javascript API

Scriptnode holds a property “id” for storing the node id of an alfresco node.
 var name1 = userhome.properties.id
 var name2 = userhome.properties["id"];
 var name3 = userhome.properties["cm:id"];
 var name4 = userhome.properties["{http://www.alfresco.org/model/content/1.0}id"];

Any many API calls returns such nodes which can be iterated and accessed like above.
Query
var newquery = "PATH:\""+ result3 + "//*\" AND @cm\\:name:\"" +model.node.name +"\"";
model.result = newquery;
var nodes = search.luceneSearch(newquery);


Alfresco SDK
The class NodeRef holds the detail of nodes. Many SDK calls returns NodeRef or its array as response. Iterate over it and fetch the node.id


for (NodeRef node : nodes)
{..}
Alfresco webscript FTL returning XML throws  the entity nbsp was referenced but not declared exception

Alfresco webscript FTL returning XML throws the entity nbsp was referenced but not declared exception

Alfresco webscript FTL returning XML throws  the entity nbsp was referenced but not declared exception


FTL Structure:
<?xml version="1.0" encoding="UTF-8"?>
<properties>
   <node>
   <name>${node.name}</name>
   <id>${node.id}</id>
   <path>${node.displayPath}/${node.name}</path>

   <#if node.isContainer>
       <#assign isFolder="true">
       <#assign size="">
       <#assign encoding="">
       <#assign mimetype="">
  <#assign content="">
   <#else>
       <#assign isFolder="false">
       <#assign size=node.size/1024 + " KB">
       <#assign encoding=node.properties.content.encoding!>
       <#assign mimetype=node.properties.content.mimetype!>
  <#assign content=node.content>
   </#if>

   <icon16>${node.icon16}</icon16>
   <icon32>${node.icon32}</icon32>
   <isFolder>${isFolder}</isFolder>
   <title>${node.properties.title!}</title>
   <description>${node.properties.description!}</description>
   <author>${node.properties.author!}</author>
   <size>${size}</size>
   <creator>${node.properties.creator}</creator>
   <created>${node.properties.created?datetime}</created>
   <modifier>${node.properties.modifier}</modifier>
   <modified>${node.properties.modified?datetime}</modified>
   <editinline>${node.properties.editInline!}</editinline>   <encoding>${encoding}</encoding>
   <mimetype>${mimetype}</mimetype>
   <content>${content}</content> 
   <#if node.properties["sk:extranetId"]?exists>
     <extranetId>${node.properties["sk:extranetId"]?string}</extranetId>   
   <#else>
    <extranetId>Extranet Id not found</extranetId>   
   </#if>

   <#if node.properties["sk:templateId"]?exists>
     <templateId>${node.properties["sk:templateId"]?string}</templateId>   
   <#else>
    <templateId>Template Id not found</templateId>   
   </#if>


   <#if node.properties["sk:docstatus"]?exists>
     <docstatus>${node.properties["sk:docstatus"]?string}</docstatus>   
   <#else>
    <docstatus>Template Id not found</docstatus>   
   </#if>

   <#if node.properties["sk:pageId"]?exists>
     <containerId>${node.properties["sk:pageId"]?string}</containerId>   
   <#else>
    <containerId>${node.properties["sk:extranetId"]?string}</containerId>   
   </#if>
   </node>   

</properties>



Why???(Solution)

Just wrap it with the right DTD something like below,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties[
<!ELEMENT node (name, id, path, icon16, icon32, isFolder, title, description, author, size, creator, created, modifier, modified, editinline, encoding, mimetype, content, extranetId, templateId, docstatus, containerId)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT path (#PCDATA)>
<!ELEMENT icon16 (#PCDATA)>
<!ELEMENT icon32 (#PCDATA)>
<!ELEMENT isFolder (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT size (#PCDATA)>
<!ELEMENT creator (#PCDATA)>
<!ELEMENT created (#PCDATA)>
<!ELEMENT modifier (#PCDATA)>
<!ELEMENT modified (#PCDATA)>
<!ELEMENT editinline (#PCDATA)>
<!ELEMENT mimetype (#PCDATA)>
<!ELEMENT content (#PCDATA)>
<!ELEMENT extranetId (#PCDATA)>
<!ELEMENT templateId (#PCDATA)>
<!ELEMENT docstatus (#PCDATA)>
<!ELEMENT containerId (#PCDATA)> 
<!ENTITY nbsp "&#160;">
]> 
<properties>
   <node>
   <name>${node.name}</name>
   <id>${node.id}</id>
   <path>${node.displayPath}/${node.name}</path>

   <#if node.isContainer>
       <#assign isFolder="true">
       <#assign size="">
       <#assign encoding="">
       <#assign mimetype="">
  <#assign content="">
   <#else>
       <#assign isFolder="false">
       <#assign size=node.size/1024 + " KB">
       <#assign encoding=node.properties.content.encoding!>
       <#assign mimetype=node.properties.content.mimetype!>
  <#assign content=node.content>
   </#if>

   <icon16>${node.icon16}</icon16>
   <icon32>${node.icon32}</icon32>
   <isFolder>${isFolder}</isFolder>
   <title>${node.properties.title!}</title>
   <description>${node.properties.description!}</description>
   <author>${node.properties.author!}</author>
   <size>${size}</size>
   <creator>${node.properties.creator}</creator>
   <created>${node.properties.created?datetime}</created>
   <modifier>${node.properties.modifier}</modifier>
   <modified>${node.properties.modified?datetime}</modified>
   <editinline>${node.properties.editInline!}</editinline>   <encoding>${encoding}</encoding>
   <mimetype>${mimetype}</mimetype>
   <content>${content}</content> 
   <#if node.properties["sk:extranetId"]?exists>
     <extranetId>${node.properties["sk:extranetId"]?string}</extranetId>   
   <#else>
    <extranetId>Extranet Id not found</extranetId>   
   </#if>

   <#if node.properties["sk:templateId"]?exists>
     <templateId>${node.properties["sk:templateId"]?string}</templateId>   
   <#else>
    <templateId>Template Id not found</templateId>   
   </#if>


   <#if node.properties["sk:docstatus"]?exists>
     <docstatus>${node.properties["sk:docstatus"]?string}</docstatus>   
   <#else>
    <docstatus>Template Id not found</docstatus>   
   </#if>

   <#if node.properties["sk:pageId"]?exists>
     <containerId>${node.properties["sk:pageId"]?string}</containerId>   
   <#else>
    <containerId>${node.properties["sk:extranetId"]?string}</containerId>   
   </#if>
   </node>   

</properties>

Cheers!!