Wednesday, November 19, 2014

How to get rid of extensions in chrome browser

Problem Statement : 


I have faced a weird problem with chrome browser. My default search engine of chrome was and is "Google" as 98% of population who surf does (Don't know how many people will be jobless if google starts charging :P). On every search I was getting adds from unknown sources which google is not supposed to show unless there is some external extension attached to the browser. I could not get rid of this extension from the browser permanently. 

Solution Approach :

Things which I have tried :

  • There was an extension which was attached to the chrome browser which is "GoSavvea".
  • Go to settings of chrome and extensions and disabling "GoSavvea" extension which was enabled.
  • Now this step helped me solve the issue temporarily but on a new browser of chrome the issue again pops up with option "Enabled" for this extension.
  • Then I have checked by enabling the developer mode and could find out the path from where the extension is being applied and manually deleted the contents from that path.
  • The below picture shows the summary of above explanation

Tuesday, November 11, 2014

Steps to configure - Custom Error Pages in IIS

IIS Version shown in the below post : 























Before setting up the custom error message in the IIS, the below message is shown.

















Follow the below steps to suppress error messages:
  • Goto Cordys Instance in the IIS.
  • Expand the Instance, there you will find the cordys folder inside.
  • Select the cordys folder 
  • Double click the Configuration Editor (as shown in the picture below.)



Now, change the default selected mode to "Application Host as show in the below picture" and make sure Section selected is "System.webServer/httpErrors".
This helps us to change the properties shown below.

Now change the properties as shown in the below picture.
Follow the steps below :

Change the properties as suggested below

  • allowAbsolutePathWhenDelegated = True
  • errormode = Custom
  • Click Apply which will be on the right side of the configuration page under Actions



Now change the mode back to "CORDBOP4312/cordys web.config" and properties as shown in the below.
  • From  as CORDBOP4312/cordys web.config (CORDBOP4312 is the instance name here)
  • errormode as Custom
  • Click Apply


After setting all the properties, now set the path of the HTM Page in the error Pages as shown in the below picture:

  • Double click the Error Pages of the cordys folder
  • Double click 404 row item (Select any error status code which you want to configure, I have configured custom 404 page for my cordys site)
  • Unchcek the check box
  • Set the path of the HTM page
  • Click OK (Refer screenshot for above steps)

Restart the Cordys Site

Now Test the same throw browser and it shows like below



You can find the same explanation in a document which is shared here

--------------------------------------------
Credits : Kacham Naresh

How to trigger a web service from stand alone java

/*
Class EndPoint
*/

package better.faster.smarter.development;

public class EndPoint {
private String hostName="";
public void setHostName(String hostName){
this.hostName=hostName;
}
public String getHostName(){
return this.hostName;
}
}

------------------------------------------------------------------------------------------
/*
Class ExecuteWebService
*/

package better.faster.smarter.development;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.URL;
import java.net.URLConnection;

public class ExecuteWebService {
//soapRequest is a string which is used for executing the web service
@SuppressWarnings("deprecation")
protected static String executeWebService(String soapRequest,EndPoint endPt,String signature)
{
String responseString="";
String hostName="";
URL url=null;
URLConnection urlC=null;
DataOutputStream out =null;
DataInputStream in = null;
String str="";
try{
//Validate the endPoint
if(null==endPt)
throw new RuntimeException("Cannot proceed with executing the web service as the end point is null");
//Get the hostName
hostName=endPt.getHostName();
//Validate the endPoint here as well
if("".equalsIgnoreCase(hostName))
throw new RuntimeException("Cannot proceed with executing the web service as the end point is empty");
//Validate the soap Request
if("".equalsIgnoreCase(soapRequest))
throw new RuntimeException("Cannot proceed with executing the web service as the soap request is invalid");
//Get the header value if header is present then add SOAPHeader else trigger direct soap request
if(signature==null)
signature="";
if(!"".equalsIgnoreCase(signature))
{
soapRequest = "<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<SOAP:Header><wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">" +
                   signature + "</wsse:Security></SOAP:Header><SOAP:Body>" + soapRequest + "</SOAP:Body></SOAP:Envelope>";
}
//Both soap request and end point are valid if the control comes here
//Initialize url and also urlConnection and all the related parameters. Hard coded few of them as 
//they are rarely used in our application
url = new URL(hostName);
urlC = url.openConnection();
urlC.setRequestProperty("Content-Type", "text/xml");
urlC.setDoInput(true);
urlC.setDoOutput(true);
urlC.setUseCaches(false);
out = new DataOutputStream(urlC.getOutputStream());
out.writeBytes(soapRequest);
in = new DataInputStream(urlC.getInputStream());
responseString="";
while(null!=((str=in.readLine())))
responseString+= str+"\n";
}
catch(Exception e)
{
CustomLogger.logEntry("Exception while executing the soap request with details "+e.getMessage());
}
finally{
hostName=null;
url=null;
urlC=null;
}
return responseString;
}
}
------------------------------------------------------------------------------------
/*
Class TriggerAssertion
*/

package better.faster.smarter.development;

public class TriggerAssertion {

public static void main(String[] args) {
// TODO Auto-generated method stub
EndPoint endPt = new EndPoint();
endPt.setHostName("http://192.168.1.10/cordys/com.eibus.web.soap.Gateway.wcp?");
String userName="icici";
String userPass="icici";
String requestString =
               "<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
               "<SOAP:Header>" +
               "<wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">" +
               "<wsse:UsernameToken xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">" +
               "<wsse:Username>" + userName + "</wsse:Username>" +
               "<wsse:Password>" + userPass + "</wsse:Password>" +
               "</wsse:UsernameToken>" +
               "</wsse:Security>" +
               "</SOAP:Header>" +
               "<SOAP:Body>" +
               "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" MajorVersion=\"1\" MinorVersion=\"1\">" +
               "<samlp:AuthenticationQuery>" +
               "<saml:Subject xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\">" +
               "<saml:NameIdentifier Format=\"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified\">" + userName + "</saml:NameIdentifier>" +
               "</saml:Subject>" +
               "</samlp:AuthenticationQuery>" +
               "</samlp:Request>" +
               "</SOAP:Body>" +
               "</SOAP:Envelope>";
String responseString = ExecuteWebService.executeWebService(requestString,endPt,"");
String getUserDetails="<GetUserDetails xmlns=\"http://schemas.cordys.com/notification/workflow/1.0\"></GetUserDetails>";
String sos= "<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
                "<SOAP:Body>" + getUserDetails + "</SOAP:Body></SOAP:Envelope>";
int ssss = responseString.indexOf("<Signature");
        int k = responseString.indexOf("</samlp:AssertionArtifact>");
        String sigresponse = responseString.substring(ssss, k+26);
responseString=ExecuteWebService.executeWebService(getUserDetails,endPt,sigresponse);
System.out.println(responseString);
}

}


Monday, November 10, 2014

How to get the current working directory from Java

package better.faster.smarter.development;

public class HowToFireWebServiceFromJava {

public static void main(String[] args) {
try{
String curWorkingDir = HowToFireWebServiceFromJava.class.getProtectionDomain().getCodeSource().getLocation().getPath();
System.out.println(curWorkingDir);
}
catch(Exception e)
{

}
}
}

Custom Logging from stand alone Java

This post shows how to log manually in a file system from Java without involving cordys.

---------------------------------------------------------------------------------------------------------------

package better.faster.smarter.development;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

public class CustomLogger {
private static Logger logger = Logger.getLogger("IsureTransUtil");
private static FileHandler fh=null;
protected static void logEntry(String message)
{
try{
DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd");
       Calendar cal = Calendar.getInstance();          
    String logFile="IsureTransUtil_"+dateFormat.format(cal.getTime())+".log"; 
//FileHandler takes two parameter 1st one being the fileName and the second one being append mode. If set to true then it will append to the existing log file else will create new one.
    fh = new FileHandler(logFile,true);        
    logger.addHandler(fh);
    SimpleFormatter formatter = new SimpleFormatter();  
       fh.setFormatter(formatter); 
       logger.log(Level.SEVERE, message);        
}
catch(Exception e)
{

}
finally{
//Until you close the file handler the bytes which were written will not get reflected.
fh.close();
}
}
}

-----------------------------------------------------------------------------------------------
Usage of the above class
----------------------------------------------------------

package better.faster.smarter.development;

public class HowToLog{

public static void main(String[] args) {
try{
CustomLogger.logEntry("Started custom Logging");
}
catch(Exception e)
{

}
}
}


Wednesday, November 5, 2014

How to enable hyperlink to a column of table

    var data = new Object();
    data = eventObject.businessObject;
    eventObject.srcElement.style.color = "blue";
    eventObject.srcElement.style.cursor = "hand";
    eventObject.srcElement.style.textDecoration = "underline";
    eventObject.srcElement.onclick = function()
    {
        if(cordys.getNodeText(data,".//*[local-name()='GDD_BENE_CODE']","") !="")
        //beneDetails is supposed to have a UI attached to it
        application.showDialog(beneDetails.XMLDocument.documentElement , data);
    }

Monday, November 3, 2014

Javascript to get the current language of the browser


function getLanguageCode() {
    var lang;
    if (getQueryVariable("language")) {
        lang = getQueryVariable("language");
    } else if (navigator) {
        if (navigator.userLanguage) {
            lang = navigator.userLanguage;
        } else if (navigator.browserLanguage) {
            lang = navigator.browserLanguage;
        } else if (navigator.systemLanguage) {
            lang = navigator.systemLanguage;
        } else if (navigator.Language) {
            lang = navigator.Language;
        } else if (navigator.language) {
            lang = navigator.language;
        }
    }
    alert(lang);
}

function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
    return false;
}

Credits : Amit Kumar 
Email : amitagl27@gmail.com