Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Thursday, December 22, 2016

How to setup embedded Apache DS with Spring boot

follow this url
https://spring.io/guides/gs/authenticating-ldap/#scratch


if you are getting error in ldif file not getting loaded
Error is  getting error Caused by: java.lang.RuntimeException: Failed to import LDIF file(s)

.ldapAuthentication().userDnPatterns("uid={0},ou=people").groupSearchBase("ou=groups").
.contextSource().ldif("classpath:test-server.ldif");

try

.ldif("file:test-server.ldif")

Thursday, May 28, 2015

How to add password to PDF using Apache PDFBox


AccessPermission ap = new AccessPermission();
        ap.setCanModify(false);
StandardProtectionPolicy policy = new StandardProtectionPolicy(owners_pwd, users_pwd, ap);
doc.protect(policy);
 

Tuesday, April 21, 2015

Hybris : Default username and passwords

admin/nimda
cmsmanager/1234

hybris Error- Could not reserve enough space for object hea‏p space

1. Go to \bin\platform\tomcat\conf
2. Open wrapper.conf
3. reduce values in –
wrapper.java.additional.1=-Xmx2G
wrapper.java.additional.2=-XX:MaxPermSize=300M

Monday, March 31, 2014

Saturday, December 1, 2012

Mobile Specific Routing in IBM WCS

Step 1:-
Crete a sub package com.ibm.commerce.foundation-ext

Step 2:-
Navigate to the WC_eardir/xml/config/com.ibm.commerce.foundation directory and copy the wc-devices.xml file into the extensions directory you created in the preceding step.

Step 3:-Add your devices to the wc-devices.xml extension file
(a) Open the new wc-devices.xml, located in your extensions directory.
(b) Replace the default device mappings with your own mappings
(c) Also add  your new devices

Step 4:-
For testing:-
When we try to test the above things with simulator .It won’t pick the Mobile Browser ID (User-Agent) Strings for the actual device.
It always picking a User-Agent value of that browser, on the browser we have opened a simulator.
For testing with simulator or normal browser we need to make a below entry in wc-devices.xml.
For Google Chrome:-
<_config:device name="Apple WebKit" useragentpattern=".*AppleWebKit/535.11.*">
<_config:device name="Apple WebKit1" useragentpattern="AppleWebKit/535.11">
Now browser will act as mobile device and siumulator will also work
For Internet explorer:-
<_config:device name="MSIE 9.0" useragerntpattern=".*MSIE 9.0.*">
Now internet browser will act as mobile device and simulator will also work
Best approach to print a user agent string for your browser on console and the add userAgentPattern accordingly
.Then same browser works as mobile device. We can use below code for the same
String userAgent= request.getHeader("User-Agent").
If value of userAgent comes  Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0) then we can specify
userAgerntPattern=".*MSIE 9.0.*" as above
We can get details about Mobile Browser ID (User-Agent) Strings using below URL
http://www.zytrax.com/tech/web/mobile_ids.html





 

AccountIQ install Certificate

Installing certificates-


1. C:\Users\[user]>keytool -importcert -file D:\ofbiz\ecom_Urgent_Docs\AccountIq\appdb.visor.ie.crt -keystore D:\ofbiz\ecom_Urgent_Docs\AccountIq\keystore.txt -storepass admin1


2. add to java


// System.setProperty( "javax.net.ssl.trustStore", "D:/ofbiz/ecom_Urgent_Docs/AccountIq/keystore.txt" );


// System.setProperty( "javax.net.ssl.trustStorePassword", "admin1" );

IBM WCS Shipping by Weight

Research Shipping
how to change SKU and find out its weight
2. select * from CATENTSHIP where catentry_id=11729;
3. Select * from catentry where catentry_id=11729;
4.   Marker -
5. Select * from POLICY where storeent_id = (Select Store_id from Store where directory =
5.
6. 'MarkerStorefrontAssetStore') ;
7.
8. select * from policycmd where policy_id in ( Select policy_id from POLICY where storeent_id =
9. (Select Store_id from Store where directory = 'MarkerStorefrontAssetStore'));
10.
11.select CALSCALE_ID,CODE from CALSCALE with ur; 12204 'us_ground_na '
12.
13.select * from CALRANGE;
14.update CALRANGE set CALMETHOD_ID=-33 where CALSCALE_ID=12204 with ur;
15.
16.sHIPPING-
17.select * from calmethod;
18.SELECT * FROM CALRULE;
19.select * from calscale;
20.select * from calrange;
21.select * from CALUSAGE; // TAX , SHIPPING , SHIPPINGDISCOUNT ETC
22.select * from crulescale;
23.
24.
25.select * from SHiPMODE;
26.select * from SHPMODCLCD;
27.
28.//select * from calrange where calscale_id=13701 ;
29.
30.// WEIGHT ,HEIGHT ETC DETAILS
31.CATENTSHIP

Saturday, May 5, 2012

Tips and Tricks

1. What is a Templating language?
More:
Velocity is a viable alternative to Java Server Pages (JSPs) or PHP - http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html
2. What is a Vortal (vertical portal)?
Different types of portals - http://en.wikipedia.org/wiki/Web_portal

4. What is a sticky session? -
Sticky session refers to the feature of many commercial load balancing solutions for web-farms to route the requests for a particular session to the same physical machine that serviced the first request for that session. This is mainly used to ensure that a in-proc session is not lost as a result of requests for a session being routed to different servers. Since requests for a user are always routed to the same machine that first served the request for that session, sticky sessions can cause uneven load distribution across servers.
5. What is Denial of Service?
Denial of service (DoS) usually refers to an attack that attempts to make a computer resource unavailable to its intended users by flooding a network or server with requests and data. It can also simply refer to a resource, such as e-mail or a Web site, that is not functioning as usual. Often, the denial is accidental rather than a planned attack, resulting from too many legitimate requests. However, malicious DoS attacks are still prevalent against network devices, and a newer breed of DoS attack targeted specifically at applications is becoming more and more common.

6. Are UNIX and Linux same?
Linux has never been certified as being a version of UNIX, so it is described as being "Unix-like." http://www.cyberciti.biz/faq/what-is-the-difference-between-linux-and-unix/

7. Load balancing -
Most commonly, the term load balancing refers to distributing incoming HTTP requests across Web servers in a server farm, to avoid overloading any one server. Because load balancing distributes the requests based on the actual load at each server, it is excellent for ensuring availability and defending against denial of service attacks.
More:
8. Is JSP technology considered to be a deprecated presentation technology?
JSP technology is considered to be a deprecated presentation technology for JavaServer Faces. Facelets is a part of the JavaServer Faces specification and also the preferred presentation technology for building JavaServer Faces technology-based applications (Source: http://docs.oracle.com/javaee/6/tutorial/doc/giepx.html)

8.Is there something like a super version of Java? - http://groovy.codehaus.org/
More:
Groovy Web Console: Guillaume Laforge, the project lead of the Groovy scripting language created a Groovy Web Console (http://groovyconsole.appspot.com/) which is public for all on Google's App Engine. It allows everybody to quickly try out some scripts.

Monday, April 9, 2012

Tips and Tricks


Thursday, January 6, 2011

Content using session.insertContent() using XCC in MarkLogic

Code Sample to insert content using session.insertContent() using XCC in MarkLogic.
You can also specify Encoding

ContentCreateOptions createOptions = new ContentCreateOptions();
createOptions.setEncoding("UTF-8");
Content content =ContentFactory.newContent(uri, string.getBytes(), createOptions);

session.insertContent(content);

Code Example to use ThreadPoolExecutor in Java

// to create Thread Pooling use
private ThreadPoolExecutor pool=null;

pool=new ThreadPoolExecutor(DEFAULT_THREAD_COUNT,MAX_THREAD_COUNT,20,TimeUnit.SECONDS, new ArrayBlockingQueue(1000),new CallerBlocksPolicy());
        pool.prestartCoreThread();


// now repeatedly use

WorkerThread thread=new WorkerThread(pdfUri,cs);
 pool.execute(thread); // will submit new thread into the que.

// to shutdown

pool.awaitTermination(15,TimeUnit.SECONDS);
pool.shutdown();

Friday, December 24, 2010

Java PDF Library - Apache's PDFBox

Apache PDFBox is an open source Java PDF library for working with PDF documents. This project allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents. Apache PDFBox also includes several command line utilities.

Features

  • PDF to text extraction
  • Merge PDF Documents
  • PDF Document Encryption/Decryption
  • Lucene Search Engine Integration
  • Fill in form data FDF and XFDF
  • Create a PDF from a text file
  • Create images from PDF pages
  • Print a PDF
  • Source http://pdfbox.apache.org

Tuesday, May 11, 2010

Using ProcessBuilder in java to run FFMPEG command to create thumbnail

String dimension = iThumbnailHeight+"X"+iThumbnailWidth;


ProcessBuilder pb = new ProcessBuilder(pathToFFMPEG,"-i",pathToSrcFile, "-s",dimension,"-ss","00:00:01.00","-vcodec","mjpeg","-vframes","1","-f","image2",tempFilePath);

pb.redirectErrorStream(true);

System.out.println("---------"+pb.command());

Process p = pb.start();

BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));

String line = null;

while((line=br.readLine())!=null){

System.out.println("---------"+line);

}

System.out.println("----wait over--- "+p.waitFor());
Note: Notice number of argumants to ProcessBuilder Constructor . You should same number of arguments , as command line input options. Check each  option is send separately as argument.

Thursday, April 22, 2010

Create Faster Jar file in java

1. Create manifest file
      Manifest-Version: 1.0
      Main-Class: mypackage1.package.mainclsss
      Class-Path: log4j.jar mail.jar xcc.jar
2. copy all the class files with package structure  in a foler say name "code"
3. put manifest file as sibling to folder code
4. Create jar from inside code folder
    jar cvfm MyJarName.jar MANIFEST.MF *.*
5. Put all required resources including external jars in the same folder as MyJarName.jar
6. Run the jar using
   java -jar MyJarName.jar anyargument

Monday, May 19, 2008

Useful Linux Commands

Installing Java:
1. chmod 744 jre-1_5_0_15-linux-amd64-rpm.bin
2. Run ./jre-1_5_0_15-linux-amd64-rpm.bin \
java is intalled.
Now to make it active do following:
1. edit .bashrc
2. add PATH=$PATH:/usr/local/bin
where /usr/local/bin is the pate where java is installed.
If you dont want to edit Path variable than create symbolic link (ln) in directory /usr/bin for java, javac , and other utilities you want to use of jre.

Installing Tomcat:
1. Unjar tomcat.tar in the directory you wish to set up tomcat.
2. put following tomcat script in /etc/init.d/
---------------script tomcat----------------------
# This is the init script for starting up the
# Jakarta Tomcat server
#
# chkconfig: 345 91 10
# description: Starts and stops the Tomcat daemon.
#
# Source function library. . /etc/rc.d/init.d/functions
# Get config. . /etc/sysconfig/network
# Check that networking is up.[ "${NETWORKING}" = "no" ] && exit 0
tomcat=/usr/local/tomcat/apache-tomcat-6.0.16
startup=$tomcat/bin/startup.sh
shutdown=$tomcat/bin/shutdown.sh
start(){
echo -n $"Starting Tomcat service: "
#daemon -c
$startup
RETVAL=$?
echo
}
stop(){
action $"Stopping Tomcat service: " $shutdown
RETVAL=$?
echo
}
restart(){
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
# This doesn't work ;)
status tomcat
;;
restart )
restart
;;
*)
echo $"Usage: $0 {startstopstatusrestart}"
exit 1
esac
exit 0
-----------------------------------------------------------------------------------
3. chmod a+x tomcat
4. chkconfig --add tomcat and your service is set :
use "service tomcat start" command to test your service
5. to check tomcat is running ------------------ netstat -vatn grep 8080
6. " dos2unix tomcat" to fix dos to unix conversion issue tomcat" to fix dos to unix conversion issue