Tuesday, April 26, 2011

Another web server daemon is already running

Jika mengalami kejadian dibawah ini:

Starting XAMPP for Linux 1.7.2...
XAMPP: Another web server daemon is already running.
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for Linux started.

Kemungkinannya bisa seperti ini:
1) Ada apache web server lain yg hidup, jadi matikan apache webserver tersebut dengan perintah berikut:
sudo /etc/apache2 stop

2) Jika anda menggunakan apache tomcat ini bisa menyebabkan hal yang sama. Jadi jika ingin menggunakan kedua-duanya, nyalakan dulu xampp baru kemudian apache tomcat.
Untuk menyalakan dan mematikan apache tomcat bisa seperti ini:
Menyalakan:
- /sh shutdown.sh
Mematikan:
- /sh startup.sh

Friday, April 01, 2011

Daftar Web site untuk kebutuhan security atau keamaman web anda

Ini daftar web site untuk kebutuhan security atau keamanan web

Free Dynamic Web Application Security Scanners
Burp Scanner http://www.portswigger.net
Paros Proxy http://www.parosproxy.org
OWASP WebScarab http://www.owasp.org
Grabber http://rgaucher.info/beta/grabber/
Nikto http://www.cirt.net/nikto2
ratproxy http://code.google.com/p/ratproxy/
w3af http://w3af.sourceforge.net/
skipfi sh http://code.google.com/p/skipfi sh/
Netsparker http://www.mavitunasecurity.com/netsparker/
Browser DOM Checker http://code.google.com/p/dom-checker/

Commercial Dynamic Web Application Security Scanners
Acunetix Web Vulnerability Scanner http://www.acunetix.com
Cenzic Hailstorm http://www.cenzic.com
Syhunt Sandcat Scanner http://www.syhunt.com/?n=Sandcat.Sandcat
HP WebInspect https://h10078.www1.hp.com/cda/hpms/display/main/hpms_content.jsp?zn=bto&cp=1-11-201-200^9570_4000_100__
IBM AppScan http://www-01.ibm.com/software/awdtools/appscan/
NTObjectives NTOSpider http://www.ntobjectives.com




Sample Web Applications for Security Testing
Gruyere (live) http://google-gruyere.appspot.com/
FreeBank Online (live) http://zero.webappsecurity.com/
Crack Me Bank (live) http://crackme.cenzic.com/

AltoroMutual (live) http://demo.testfi re.net/
Acunetix Acublog http://testaspnet.vulnweb.com (registration required)
Hacme Travel http://www.foundstone.com/us/resources/proddesc/hacmetravel.htm
Hacme Bank http://www.foundstone.com/us/resources/proddesc/hacmebank.htm
Hacme Shipping http://www.foundstone.com/us/resources/proddesc/hacmeshipping.htm
Hacme Casino http://www.foundstone.com/us/resources/proddesc/hacmecasino.htm
Hacme Books http://www.foundstone.com/us/resources/proddesc/hacmebooks.htm
SecuriBench http://suif.stanford.edu/~livshits/securibench/
SecuriBench Micro http://suif.stanford.edu/~livshits/work/securibench-micro/
OWASP WebGoat http://www.owasp.org/index.php/OWASP_WebGoat_Project



Command-line Tools
cURL http://curl.haxx.se/
Netcat http://netcat.sourceforge.net/
OpenSSL http://www.openssl.org/
Stunnel http://www.stunnel.org/



Crawling Tools
Wget http://www.gnu.org/software/wget/
crawler4j http://code.google.com/p/crawler4j/
HTTrack http://www.httrack.com/



Code Analysis Tools
Java Decompiler http://java.decompiler.free.fr/
JAD http://www.varaneckas.com/jad
Armorize CodeSecure http://www.armorize.com/
Checkmarx CxSuite http://www.checkmarx.com/
Fortify 360 http://www.fortify.com/
Veracode http://www.veracode.com/
Splint http://www.splint.org/
Valgrind http://www.valgrind.org/
Flawfi nder http://www.dwheeler.com/fl awfi nder/
RATS http://www.fortify.com/security-resources/rats.jsp
FXCop http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx
ITS4 http://www.cigital.com/its4/
PREfast http://msdn.microsoft.com/en-us/library/ms933794.aspx
OunceLabs Ounce http://www.ouncelabs.com/
Coverity Static Analysis http://www.coverity.com/products/static-analysis.html
OWASP Orizon http://www.owasp.org/index.php/Category:OWASP_
Orizon_Project FindBugs http://fi ndbugs.sourceforge.net/
Jlint http://jlint.sourceforge.net/
CAT.NET http://www.microsoft.com/downloads/details.aspx?FamilyId=0178e2ef-9da8-445e-9348-
c93f24cc9f9d&displaylang=en

Red Gate.NET Reflector http://www.red-gate.com/products/refl ector/




Binary Analysis
Open Reverse Code Engineering(OpenRCE) http://www.openrce.org
OllyDbg http://www.ollydbg.de
IDA Pro http://www.datarescue.com
WinDbg http://www.microsoft.com/whdc/devtools/debugging/default.mspx
Profi ling Tools Httprint http://net-square.com/httprint/
SiteDigger http://www.foundstone.com/us/resources/proddesc/sitedigger.htm
Wayback Machine http://web.archive.org
GoogleDiggity http://www.stachliu.com
BingDiggity http://www.stachliu.com
Maltego http://www.paterva.com
Shodan http://www.shodanhq.com/





Monday, January 24, 2011

Menghitung Interval Waktu dan Hari dari Awal Registrasi di MySQL

SELECT
tgl_masuk AS 'Tgl Masuk',NOW(),
DATEDIFF(NOW(), tgl_masuk) AS hari,
TIMEDIFF(NOW(), tgl_masuk) AS waktu,
FROM user;

Hasilnya Kira-kira seperti ini:

|-----Tgl Masuk-------|--------NOW()--------|-hari-|--waktu--|
|1/24/2011 7:00:00 AM |1/24/2011 9:37:29 AM | 0 |02:37:29 |

Wednesday, January 12, 2011

Contoh memanggil Web Service SOAP melalui Java Client

import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;


public class WMClientInvoke {

private static String qnameService = "bhangunWSDL_bhangunService";
private static String qnamePort = "bhangunWSDL_bhangunPortType";
private static String endpoint ="http://localhost:5555/soap/rpc";
private static String BODY_NAMESPACE_VALUE ="bhangunWSDL.bhangun";
private static String ENCODING_STYLE_PROPERTY =
"javax.xml.rpc.encodingstyle.namespace.uri";
private static String URI_ENCODING =
"http://schemas.xmlsoap.org/soap/encoding/";

public static void main(String[] args) {



try {

ServiceFactory factory =
ServiceFactory.newInstance();
Service service =
factory.createService(new QName(qnameService));

QName port = new QName(qnamePort);

Call call = service.createCall(port);
call.setTargetEndpointAddress(endpoint);
call.setProperty(Call.USERNAME_PROPERTY,"myusername");
call.setProperty(Call.PASSWORD_PROPERTY,"mypassword");
call.setProperty(Call.SOAPACTION_USE_PROPERTY,
new Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
call.setProperty(ENCODING_STYLE_PROPERTY,
URI_ENCODING);


call.setOperationName(new QName(BODY_NAMESPACE_VALUE,
"panggilNama"));
call.addParameter("nama", new QName(
"http://www.w3.org/2001/XMLSchema", "string"),
String.class, javax.xml.rpc.ParameterMode.IN);
call.setReturnType(new QName(
"http://www.w3.org/2001/XMLSchema", "string"));
String[] params = { "bhangun" };

String result = (String)call.invoke(params);
System.out.println(result);

} catch (Exception ex) {
ex.printStackTrace();
}
}
}

Friday, July 30, 2010

Maven Spring Source Repository


Obtaining Spring Releases From Maven Central

You do not have to add a repository to your .pom to obtain final releases of Spring projects from Maven Central. Simply add the dependencies your project requires.

A .pom snippet for each Spring Framework 3 artifact as it will be indexed in Maven Central is listed below.
view source
print?
001
002
003 3.0.0.RELEASE
004

005
006
010
011 org.springframework
012 spring-core
013 ${org.springframework.version}
014

015
016
020
021 org.springframework
022 spring-expression
023 ${org.springframework.version}
024

025
026
030
031 org.springframework
032 spring-beans
033 ${org.springframework.version}
034

035
036
040
041 org.springframework
042 spring-aop
043 ${org.springframework.version}
044

045
046
050
051 org.springframework
052 spring-context
053 ${org.springframework.version}
054

055
056
060
061 org.springframework
062 spring-context-support
063 ${org.springframework.version}
064

065
066
071
072 org.springframework
073 spring-tx
074 ${org.springframework.version}
075

076
077
081
082 org.springframework
083 spring-jdbc
084 ${org.springframework.version}
085

086
087
092
093 org.springframework
094 spring-orm
095 ${org.springframework.version}
096

097
098
103
104 org.springframework
105 spring-oxm
106 ${org.springframework.version}
107

108
109
114
115 org.springframework
116 spring-web
117 ${org.springframework.version}
118

119
120
124
125 org.springframework
126 spring-webmvc
127 ${org.springframework.version}
128

129
130
134
135 org.springframework
136 spring-webmvc-portlet
137 ${org.springframework.version}
138

139
140
144
145 org.springframework
146 spring-test
147 ${org.springframework.version}
148 test
149

Obtaining Spring Releases From The Enterprise Bundle Repository (EBR)

To obtain final releases of Spring projects from the EBR, add the following repositories to your .pom:
view source
print?
01
02 com.springsource.repository.bundles.release
03 EBR Spring Release Repository
04 http:// repository.springsource.com/maven/bundles/release
05

06
07 com.springsource.repository.bundles.external
08 EBR External Release Repository
09 http:// repository.springsource.com/maven/bundles/external
10


Then simply add the dependencies your project requires, keeping in mind the EBR artifact naming conventions.

A .pom snippet for each Spring Framework 3 artifact as it will be indexed in the EBR is listed below:
view source
print?
001
002
003 3.0.0.RELEASE
004

005
006
010
011 org.springframework
012 org.springframework.core
013 ${org.springframework.version}
014

015
016
020
021 org.springframework
022 org.springframework.expression
023 ${org.springframework.version}
024

025
026
030
031 org.springframework
032 org.springframework.beans
033 ${org.springframework.version}
034

035
036
040
041 org.springframework
042 org.springframework.aop
043 ${org.springframework.version}
044

045
046
050
051 org.springframework
052 org.springframework.context
053 ${org.springframework.version}
054

055
056
060
061 org.springframework
062 org.springframework.context.support
063 ${org.springframework.version}
064

065
066
071
072 org.springframework
073 org.springframework.transaction
074 ${org.springframework.version}
075

076
077
081
082 org.springframework
083 org.springframework.jdbc
084 ${org.springframework.version}
085

086
087
092
093 org.springframework
094 org.springframework.orm
095 ${org.springframework.version}
096

097
098
103
104 org.springframework
105 org.springframework.oxm
106 ${org.springframework.version}
107

108
109
113
114 org.springframework
115 org.springframework.web
116 ${org.springframework.version}
117

118
119
123
124 org.springframework
125 org.springframework.web.servlet
126 ${org.springframework.version}
127

128
129
133
134 org.springframework
135 org.springframework.web.portlet
136 ${org.springframework.version}
137




org.springframework
org.springframework.test
${org.springframework.version}
test

Obtaining Spring Milestone Releases

Milestones and Release Candidates may not be published directly to Maven Central, and in general are published separately from final releases. SpringSource hosts two repositories for obtaining Spring milestones. The first one should be used in conjunction with Maven Central, and the second one in conjunction with the EBR.
Obtaining Milestones from the Maven Central Compatible Repository

To obtain Spring milestones from the Maven Central compatible repository, add the following repository to your .pom:
view source
print?

org.springframework.maven.milestone
Maven Central Compatible Spring Milestone Repository
http:// maven.springframework.org/milestone


The milestone version number format is ...M#; for example, 3.0.0.M4. The release candidate version number format is ...RC#; for example, 3.0.0.RC3.

For example, adding the following dependency would retrieve version 3.0.0.RC3 of the spring-context artifact:
view source
print?

org.springframework
spring-context
3.0.0.RC3

Obtaining Milestones from the Enterprise Bundle Repository (EBR)

To obtain Spring milestones from the EBR, add the following repository to your .pom:
view source
print?

com.springsource.repository.bundles.milestone
EBR Spring Milestone Repository
http:// repository.springsource.com/maven/bundles/milestone


Be sure to keep in mind the distinct EBR artifact naming convention. For example, adding the following dependency would retrieve version 3.0.0.RC3 of the org.springframework.context artifact:
view source
print?

org.springframework
org.springframework.context
3.0.0.RC3

Obtaining Nightly Spring Snapshots

Snapshots of Spring projects are published each night, allowing users to verify that reported issues have been resolved before the next release. Like Milestones, there is a separate Maven Central compatible snapshot repository and an EBR snapshot repository.
Obtaining Snapshots from the Maven Central Compatible Repository

To obtain Spring nightly snapshots from the Maven Central compatible repository, add the following repository to your .pom:
view source
print?

org.springframework.maven.snapshot
Maven Central Compatible Spring Snapshot Repository
http:// maven.springframework.org/snapshot


The snapshot version format is ...BUILD-SNAPSHOT; for example, 3.0.1.BUILD-SNAPSHOT.

For example, adding the following dependency would retrieve the latest snapshot of the spring-context artifact:
view source
print?

org.springframework
spring-context
3.0.1.BUILD-SNAPSHOT


Notice the ...BUILD-SNAPSHOT format differs slightly from the traditional Maven 2 snapshot format of ..-SNAPSHOT. This is because x.y.z-SNAPSHOT is not a valid OSGi version number. All Spring projects now follow the OSGi version numbering scheme (Maven 3 will as well).
Obtaining Snapshots from the Enterprise Bundle Repository (EBR)

To obtain Spring nightly snapshots from the EBR, add the following repository to your .pom:
view source
print?

com.springsource.repository.bundles.snapshot
EBR Spring Snapshot Repository
http:// repository.springsource.com/maven/bundles/snapshot


As an final example, adding the following dependency would retrieve the latest snapshot of the org.springframework.context artifact:
view source
print?

org.springframework
org.springframework.context
3.0.1.BUILD-SNAPSHOT


sumber: http://blog.springsource.com/2009/12/02/obtaining-spring-3-artifacts-with-maven/

Tuesday, February 16, 2010

Model Event Untuk Mendapatkan Range Tanggal, Bulan dan Tahun

Ketika membuat suatu event biasanya kita membutuhkan model untuk mendapatkan rentang tanggal, bulan ataupun tahun. Disini saya sudah membuat class EventModel untuk bisa mendapatkan rentang tanggal, bulan ataupun ahun tadi. Bagi yang membutuhkan silahkan di copy semoga bisa membantu, dan jika ada masukan atau ada algoritma yg lebih efektif silahkan balas thread ini.

Untuk mencoba model ini cukup gampang. Pertama Anda bisa mendefinisikan terlebih dahulu kalender untuk menentukan tanggal awal dan akhir seperti dibawah:
GregorianCalendar awal = new GregorianCalendar();
GregorianCalendar akhir = new GregorianCalendar();
awal.set(2009, 1, 25);
akhir.set(2012, 5, 28);
Lalu buat instan baru EventModel dan masukan tanggal tadi:
EventModel event=new EventModel(awal.getTime(),akhir.getTime());
Kemudian tinggal panggil event.getYearModel() untuk mendapatkan model tahun, event.getMonthModel() untuk model bulan, dan event.getDateModel() untuk model tanggal.
Source lebih lengkapnya ada di halaman berikut.
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;

/**
*
* @author bhangun
*
*/
public class EventModel {
int[] numDays = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
private SimpleDateFormat y;
private SimpleDateFormat m;
private SimpleDateFormat d;
private Integer startMonth;
private Integer startYear;
private Integer startDate;
private Integer endYear;
private Integer endMonth;
private Integer endDate;
private int lengthMonth;
private int lengthYear;
private Integer[][] dateModel;
private Integer[][] monthModel;

/**
* Konstruktor untuk mendapatkan awal dan akhir tanggal
* @param start awal tanggal dengan tipe Date
* @param end akhir tanggal dengan tipe Date
*/
public EventModel(Date start, Date end) {
y = new SimpleDateFormat("yyyy");
m = new SimpleDateFormat("M");
d = new SimpleDateFormat("d");

startYear = Integer.valueOf(y.format(start));
startMonth = (Integer.valueOf(m.format(start))-1);
startDate = (Integer.valueOf(d.format(start))-1);

endYear = Integer.valueOf(y.format(end));
endMonth = (Integer.valueOf(m.format(end))-1);
endDate = (Integer.valueOf(d.format(end))-1);

lengthYear =getYearModel().length;
setMonthModel(getYearModel());
Integer[][] month=getMonthModel();
lengthMonth = monthLength(month);
setDateModel(lengthMonth,startDate,endDate,month);
}

public int getMonthLength(){
return lengthMonth;
}

private int monthLength(Integer[][] month){
int length=0;
for(int i=0;i< month.length;i++){ length+=(month[i][1]-month[i][0])+1; } return length; } /** * Untuk mendapatkan model tahun * @return model tahun dalam bentuk array satu dimensi */ public Integer[] getYearModel() { int l=(endYear-startYear)+1; Integer[] range = new Integer[l]; int n = 0; int ytemp = startYear; if(startYear.equals(endYear)) range[0]=startYear; else while (ytemp <= endYear) { range[n] = ytemp; n++; ytemp++; } return range; } /** * Untuk mendapatkan model bulan dalam bentuk array * @param yearModel model tahun didapatkan dari getYearModel() * @return model bulan dalam bentuk array dua dimensi bertipe dengan format berikut: * getMonthModel()[i][0]=awal bulan, * getMonthModel()[i][1]=akhir bulan, * getMonthModel()[i][2]=tahun */ private void setMonthModel(Integer[] yearModel) { int yearLength = yearModel.length; //System.out.println("length tahun>"+yearLength);

Integer[][] range = new Integer[yearLength][3];
int n = 0;

if (yearLength==1 ) {
//System.out.println("tahun yg sama");
range[n][0]=startMonth;
range[n][1]=endMonth;
range[n][2]=yearModel[0];

} else if (yearLength >1) {
System.out.println("lebih dari 1 tahun");
range[n][0]=startMonth;
range[n][1]=11;
range[n][2]=yearModel[0];
n++;

if (yearLength > 2) {
//System.out.println("lebih dari 2 tahun");
for (int x = 2; x < yearLength; x++) { range[n][0] = 0; range[n][1] = 11; range[n][2] = yearModel[x-1]; n++; } } //--range bulan di tahun terakhir range[n][0]=0; range[n][1]=endMonth; range[n][2]=yearModel[yearLength-1]; } monthModel = range; } public Integer[][] getMonthModel(){ return monthModel; } /** * Untuk mendapatkan model tanggal event dalam bentu array * @param length banyaknya bulan dari awal hingga akhir * @param start awal bulan event * @param end akhir bulan event * @param monthModel model bulan diambil dari getMonthModel() * @return model tanggal dalam bentuk array dua dimensi bertipe integer dengan format berikut: * getDateModel()[i][0]=awal tanggal, * getDateModel()[i][1]=akhir tanggal, * getDateModel()[i][2]=bulan */ private void setDateModel(int length, int start,int end,Integer[][] monthModel) { //System.out.println("length bulan>"+length);
int sufix=1;
int fmonth = monthModel[0][0];
Integer[][] range = new Integer[length][3];
int n = 0;

if (length==1 ) {
//System.out.println("bulan yg sama");
range[n][0]=start+sufix;
range[n][1]=end+sufix;
range[n][2]=fmonth;

} else if (length >1) {
//System.out.println("lebih dari 1 bulan");
range[n][0]=start+sufix;
range[n][1]=daysInMonth(startYear, monthModel[0][0]) ;
range[n][2]=fmonth;
n++;

if (length > 2) {
//System.out.println("lebih dari 2 bulan");

//ditambah 1 untuk mulai dari digit kedua
fmonth++;

for (int x = 2; x < length; x++) { range[n][0] = sufix; int iyear=0; if (fmonth < 12) { range[n][1] = daysInMonth(monthModel[iyear][2],fmonth); range[n][2] = fmonth; fmonth++; } else { fmonth = 0; iyear++; range[n][1] = daysInMonth(monthModel[iyear][2],fmonth); range[n][2] = fmonth; fmonth++; } n++; } } //--range tanggal di bulan terakhir range[n][0]=1; range[n][1]=end+sufix; range[n][2]=monthModel[lengthYear-1][1]; } dateModel = range; } public Integer[][] getDateModel(){ return dateModel; } /** * * @param year * @param month * @return */ public Integer[] getMonth(int year, int month) { GregorianCalendar cal = new GregorianCalendar(); Integer[] days= new Integer[31]; cal.set(year, month, 1); int offset = cal.get(GregorianCalendar.DAY_OF_WEEK) - 1; offset += 7; int num = daysInMonth(year, month); for (int i = 0; i < num; ++i) { days[i]=i + 1; System.out.println(Integer.toString(i + 1)); ++offset; } return days; } /** * * @param year * @return */ public boolean isLeapYear(int year) { if (year % 4 == 0) return true; return false; } /** * * @param year * @param month * @return */ public int daysInMonth(int year, int month) { int days = numDays[month]; if (month == 1 && isLeapYear(year)) ++days; return days; } public static void main(String[] args){ GregorianCalendar awal = new GregorianCalendar(); GregorianCalendar akhir = new GregorianCalendar(); awal.set(2009, 1, 25); akhir.set(2012, 5, 28); System.out.println(awal.getTime()+"-----"+akhir.getTime()); EventModel event=new EventModel(awal.getTime(),akhir.getTime()); System.out.println("Model Tahun:"); Integer[] rangey=event.getYearModel(); for (int i = 0; i < rangey.length; i++) if(rangey[i]!=null) System.out.println("-"+rangey[i]); System.out.println("Model Bulan:"); Integer[][] rangem=event.getMonthModel(); for (int i = 0; i < rangem.length; i++) if(rangem[i][0]!=null) System.out.println(rangem[i][2]+"> " + rangem[i][0]+" - "+rangem[i][1]);

System.out.println("Model Tanggal:");
Integer[][] range=event.getDateModel();
for (int i = 0; i < range.length; i++) if(range[i][0]!=null) System.out.println((i+1)+") bulan : "+range[i][2]+" > " + range[i][0]+" - "+range[i][1]);

}
}

Monday, January 25, 2010

iText tutorial: Merge & Split PDF files using iText JAR

In previous article about Generating PDF files using iText JAR, Kiran Hegde had described a nice and basic way of generating PDF files in Java using iTest JAR. It is a great starter tutorial for those who wants to start working with iText.
In one of the requirement, I had to merge two or more PDF files and generate a single PDF file out of it. I thought of implementing the functionality from scratch in iText, but then thought to google it and see if already someone have written code for what I was looking for.

As expected, I got a nice implementation of java code that merges 2 or more PDF files using iText jar. I thought of dissecting the code in this post and give credit to original author of the post.
Merge PDF files in Java using iText JAR

So here we go. First let us see the code.
view source
print?

001 package net.viralpatel.itext.pdf;
002
003 import java.io.FileInputStream;
004 import java.io.FileOutputStream;
005 import java.io.IOException;
006 import java.io.InputStream;
007 import java.io.OutputStream;
008 import java.util.ArrayList;
009 import java.util.Iterator;
010 import java.util.List;
011
012 import com.lowagie.text.Document;
013 import com.lowagie.text.pdf.BaseFont;
014 import com.lowagie.text.pdf.PdfContentByte;
015 import com.lowagie.text.pdf.PdfImportedPage;
016 import com.lowagie.text.pdf.PdfReader;
017 import com.lowagie.text.pdf.PdfWriter;
018
019 public class MergePDF {
020
021 public static void main(String[] args) {
022 try {
023 List pdfs = new ArrayList();
024 pdfs.add(new FileInputStream("c:\\1.pdf"));
025 pdfs.add(new FileInputStream("c:\\2.pdf"));
026 OutputStream output = new FileOutputStream("c:\\merge.pdf");
027 MergePDF.concatPDFs(pdfs, output, true);
028 } catch (Exception e) {
029 e.printStackTrace();
030 }
031 }
032
033 public static void concatPDFs(List streamOfPDFFiles,
034 OutputStream outputStream, boolean paginate) {
035
036 Document document = new Document();
037 try {
038 List pdfs = streamOfPDFFiles;
039 List readers = new ArrayList();
040 int totalPages = 0;
041 Iterator iteratorPDFs = pdfs.iterator();
042
043 // Create Readers for the pdfs.
044 while (iteratorPDFs.hasNext()) {
045 InputStream pdf = iteratorPDFs.next();
046 PdfReader pdfReader = new PdfReader(pdf);
047 readers.add(pdfReader);
048 totalPages += pdfReader.getNumberOfPages();
049 }
050 // Create a writer for the outputstream
051 PdfWriter writer = PdfWriter.getInstance(document, outputStream);
052
053 document.open();
054 BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
055 BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
056 PdfContentByte cb = writer.getDirectContent(); // Holds the PDF
057 // data
058
059 PdfImportedPage page;
060 int currentPageNumber = 0;
061 int pageOfCurrentReaderPDF = 0;
062 Iterator iteratorPDFReader = readers.iterator();
063
064 // Loop through the PDF files and add to the output.
065 while (iteratorPDFReader.hasNext()) {
066 PdfReader pdfReader = iteratorPDFReader.next();
067
068 // Create a new page in the target for each source page.
069 while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) { 070 document.newPage(); 071 pageOfCurrentReaderPDF++; 072 currentPageNumber++; 073 page = writer.getImportedPage(pdfReader, 074 pageOfCurrentReaderPDF); 075 cb.addTemplate(page, 0, 0); 076 077 // Code for pagination. 078 if (paginate) { 079 cb.beginText(); 080 cb.setFontAndSize(bf, 9); 081 cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "" 082 + currentPageNumber + " of " + totalPages, 520, 083 5, 0); 084 cb.endText(); 085 } 086 } 087 pageOfCurrentReaderPDF = 0; 088 } 089 outputStream.flush(); 090 document.close(); 091 outputStream.close(); 092 } catch (Exception e) { 093 e.printStackTrace(); 094 } finally { 095 if (document.isOpen()) 096 document.close(); 097 try { 098 if (outputStream != null) 099 outputStream.close(); 100 } catch (IOException ioe) { 101 ioe.printStackTrace(); 102 } 103 } 104 } 105 } If you see what the code does is pretty simple. 1. In main() method, we create a List of InputStream objects that points to all the input PDF files we need to merge 2. We call MergePDF.concatPDFs() static method passing list of input PDFs, OutputStream object for merged output PDF and a boolean flag that represents whether you need to include page numbers at the end of each page as command line arguments 3. In concatPDFs() method, first we convert List of InputStream objects to List of PdfReader objects in first while loop. And also we keep count of the total pages in all the input PDF files. 4. Next we create BaseFont object using BaseFont.createFont() method. This will be the font for writing page numbers 5. Next we create output objects to write our merged PDF file using Document class object and PdfWriter.getInstance() method 6. Finally we write all the input PDFs into merged output PDF iterating each PDF and then writing each page of it in two while loops 7. And then, close all the streams and clear all the buffers. Good boys do this ;-) So now we know how to merge PDF files into one, let us see the way to split a PDF file or extract a part of PDF into another PDF. Split PDF files in Java using iText JAR Let us see the code. view source print? 01 /** 02 * @author viralpatel.net 03 * 04 * @param inputStream Input PDF file 05 * @param outputStream Output PDF file 06 * @param fromPage start page from input PDF file 07 * @param toPage end page from input PDF file 08 */ 09 public static void splitPDF(InputStream inputStream, 10 OutputStream outputStream, int fromPage, int toPage) { 11 Document document = new Document(); 12 try { 13 PdfReader inputPDF = new PdfReader(inputStream); 14 15 int totalPages = inputPDF.getNumberOfPages(); 16 17 //make fromPage equals to toPage if it is greater 18 if(fromPage > toPage ) {
19 fromPage = toPage;
20 }
21 if(toPage > totalPages) {
22 toPage = totalPages;
23 }
24
25 // Create a writer for the outputstream
26 PdfWriter writer = PdfWriter.getInstance(document, outputStream);
27
28 document.open();
29 PdfContentByte cb = writer.getDirectContent(); // Holds the PDF data
30 PdfImportedPage page;
31
32 while(fromPage <= toPage) { 33 document.newPage(); 34 page = writer.getImportedPage(inputPDF, fromPage); 35 cb.addTemplate(page, 0, 0); 36 fromPage++; 37 } 38 outputStream.flush(); 39 document.close(); 40 outputStream.close(); 41 } catch (Exception e) { 42 e.printStackTrace(); 43 } finally { 44 if (document.isOpen()) 45 document.close(); 46 try { 47 if (outputStream != null) 48 outputStream.close(); 49 } catch (IOException ioe) { 50 ioe.printStackTrace(); 51 } 52 } 53 } In above code, we have created a method splitPDF () that can be used to extracts pages out of a PDF and write it into another PDF. The code is pretty much self explanatory and is similar to the one to merge PDF files. Thus, if you need to split an input.pdf (having 20 pages) into output1.pdf (1-12 pages of input.pdf) and output2.pdf (13-20 of input.pdf), you can call the above method as follow: view source print? 01 public static void main(String[] args) { 02 try { 03 MergePDF.splitPDF(new FileInputStream("C:\\input.pdf"), 04 new FileOutputStream("C:\\output1.pdf"), 1, 12); 05 MergePDF.splitPDF(new FileInputStream("C:\\input.pdf"), 06 new FileOutputStream("C:\\output2.pdf"), 13, 20); 07 08 } catch (Exception e) { 09 e.printStackTrace(); 10 } 11 } Feel free to bookmark the code and share it if you feel it will be useful to you sumber: http://viralpatel.net/blogs/2009/06/itext-tutorial-merge-split-pdf-files-using-itext-jar.html

Monday, November 02, 2009

REPOSITORY KARMIC KOALA LOKAL -INDONESIA

## REPOSITORY LOKAL -INDONESIA



##kambing.ui.edu (UI, Telkom, Indosat, OpenIXP, INHERENT)

deb http://kambing.ui.edu/ubuntu karmic main restricted universe multiverse

deb http://kambing.ui.edu/ubuntu karmic-updates main restricted universe multiverse

deb http://kambing.ui.edu/ubuntu karmic-security main restricted universe multiverse

deb http://kambing.ui.edu/ubuntu karmic-backports main restricted universe multiverse

deb http://kambing.ui.edu/ubuntu karmic-proposed main restricted universe multiverse






##mirror.cbn.net.id (OpenIXP)

deb http://ubuntu.cbn.net.id/Ubuntu karmic main restricted universe multiverse

deb http://ubuntu.cbn.net.id/Ubuntu karmic-updates main restricted universe multiverse

deb http://ubuntu.cbn.net.id/Ubuntu karmic-security main restricted universe multiverse

deb http://ubuntu.cbn.net.id/Ubuntu karmic-backports main restricted universe multiverse

deb http://ubuntu.cbn.net.id/Ubuntu karmic-proposed main restricted universe multiverse



##komo.vlsm.org

deb http://komo.vlsm.org/ubuntu karmic main restricted universe multiverse

deb http://komo.vlsm.org/ubuntu karmic-updates main restricted universe multiverse

deb http://komo.vlsm.org/ubuntu karmic-security main restricted universe multiverse

deb http://komo.vlsm.org/ubuntu karmic-backports main restricted universe multiverse

deb http://komo.vlsm.org/ubuntu karmic-proposed main restricted universe multiverse



##indika.net.id (OpenIXP)

deb http://ubuntu.indika.net.id/ karmic main restricted universe multiverse

deb http://ubuntu.indika.net.id/ karmic-updates main restricted universe multiverse

deb http://ubuntu.indika.net.id/ karmic-security main restricted universe multiverse

deb http://ubuntu.indika.net.id/ karmic-backports main restricted universe multiverse

deb http://ubuntu.indika.net.id/ karmic-proposed main restricted universe multiverse



##ftp.itb.ac.id (ITB, INHERENT)

deb ftp://ftp.itb.ac.id/pub/ubuntu karmic main restricted universe multiverse

deb ftp://ftp.itb.ac.id/pub/ubuntu karmic-updates main restricted universe multiverse

deb ftp://ftp.itb.ac.id/pub/ubuntu karmic-security main restricted universe multiverse

deb ftp://ftp.itb.ac.id/pub/ubuntu karmic-backports main restricted universe multiverse

deb ftp://ftp.itb.ac.id/pub/ubuntu karmic-proposed main restricted universe multiverse



## www.foss-id.web.id (Telkom)

deb http://dl2.foss-id.web.id/ubuntu karmic main restricted universe multiverse

deb http://dl2.foss-id.web.id/ubuntu karmic-updates main restricted universe multiverse

deb http://dl2.foss-id.web.id/ubuntu karmic-security main restricted universe multiverse

deb http://dl2.foss-id.web.id/ubuntu karmic-backports main restricted universe multiverse

deb http://dl2.foss-id.web.id/ubuntu karmic-proposed main restricted universe multiverse

Monday, October 26, 2009

Memanggil Service WebMethods melalui PL/SQL

Pada contoh ini, ada beberapa fungsi penting yang digunakan untuk memanggil webservices yang terdapat pada Oracle, yaitu UTL_HTTP dan XMLTYPE, tapi fungsi-fungsi ini hanya bisa dijalankan untuk veri 9i keatas, untuk 8i kayaknya harus bikin fungsi pakai native Java-nya. Fungsi utama untuk memanggil webservice atau request (dengan metode POST/GET) pada PL/SQL terletak pada fungsi UTL_HTTP. Sedangkan XMLTYPE digunakan untuk parsing xml.

Berikut ini adalah contoh API untuk memanggil services pada webMethods, setelah disesuaikan format envelope-nya dengan API pada webmethods.


----------------------------code------------------------------------------------

CREATE OR REPLACE PACKAGE WEBMETHOD.soap_api AS
-- --------------------------------------------------------------------------
-- Name : http://forum.swamedia.co.id
-- Author : Bhangun
-- Description : API untuk memanggil web services pada webMethods.
-- Ammedments :
-- When Who What
-- =========== ======== =================================================
-- 21-OCT-2009 Bhangun Initial Creation
-- --------------------------------------------------------------------------

TYPE t_request IS RECORD (
method VARCHAR2(256),
service VARCHAR2(256),
namespace VARCHAR2(256),
body VARCHAR2(32767),
envelope_tag VARCHAR2(30)
);

TYPE t_response IS RECORD
(
doc XMLTYPE,
envelope_tag VARCHAR2(30)
);



PROCEDURE set_proxy_authentication(p_username IN VARCHAR2,
p_password IN VARCHAR2);

FUNCTION new_request(p_method IN VARCHAR2,
p_service IN VARCHAR2,
p_namespace IN VARCHAR2,
p_envelope_tag IN VARCHAR2 DEFAULT 'SOAP-ENV')
RETURN t_request;


PROCEDURE add_parameter(p_request IN OUT NOCOPY t_request,
p_name IN VARCHAR2,
p_type IN VARCHAR2,
p_value IN VARCHAR2);

FUNCTION invoke(p_request IN OUT NOCOPY t_request,
p_url IN VARCHAR2,
p_action IN VARCHAR2)
RETURN t_response;

FUNCTION get_return_value(p_response IN OUT NOCOPY t_response,
p_name IN VARCHAR2,
p_namespace IN VARCHAR2)
RETURN VARCHAR2;

END soap_api;
/
--------------------------------------------------------------------------


ini Body-nya
-------------------------code-------------------------------------------------
CREATE OR REPLACE PACKAGE BODY WEBMETHOD.soap_api AS
-- --------------------------------------------------------------------------
-- Name : http://www.oracle-base.com/dba/miscellaneous/soap_api
-- Author : DR Timothy S Hall
-- Description : SOAP related functions for consuming web services.
-- Ammedments :
-- When Who What
-- =========== ======== =================================================
-- 04-OCT-2003 Tim Hall Initial Creation
-- 23-FEB-2006 Tim Hall Parameterized the "soap" envelope tags.
-- 08-JUN-2006 Tim Hall Add proxy authentication functionality.
-- --------------------------------------------------------------------------

g_proxy_username VARCHAR2(50) := NULL;
g_proxy_password VARCHAR2(50) := NULL;


-- ---------------------------------------------------------------------
PROCEDURE set_proxy_authentication(p_username IN VARCHAR2,
p_password IN VARCHAR2) AS
-- ---------------------------------------------------------------------
BEGIN
g_proxy_username := p_username;
g_proxy_password := p_password;
END;
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
FUNCTION new_request(p_method IN VARCHAR2,
p_service IN VARCHAR2,
p_namespace IN VARCHAR2,
p_envelope_tag IN VARCHAR2 DEFAULT 'SOAP-ENV')
RETURN t_request AS
-- ---------------------------------------------------------------------
l_request t_request;
BEGIN
l_request.method := p_method;
l_request.service := p_service;
l_request.namespace := p_namespace;
l_request.envelope_tag := p_envelope_tag;
RETURN l_request;
END;
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
PROCEDURE add_parameter(p_request IN OUT NOCOPY t_request,
p_name IN VARCHAR2,
p_type IN VARCHAR2,
p_value IN VARCHAR2) AS
-- ---------------------------------------------------------------------
BEGIN
p_request.body := p_request.body||'<'||p_name||' xsi:type="'||p_type||'">'||p_value||'';
--DBMS_OUTPUT.PUT_LINE('<'||p_name||' xsi:type="'||p_type||'">'||p_value||'');
END;
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
PROCEDURE generate_envelope(p_request IN OUT NOCOPY t_request,
p_env IN OUT NOCOPY VARCHAR2) AS
-- ---------------------------------------------------------------------
BEGIN

p_env := '<'||p_request.envelope_tag||':Envelope xmlns:'||p_request.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/" ' ||
' xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' ||
'<'||p_request.envelope_tag||':Body>' ||
'<'||p_request.method||':'||p_request.service||' xmlns:'||p_request.method||'="'||p_request.namespace||'">' ||
p_request.body ||
'' ||
'' ||
'';


END;
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
PROCEDURE show_envelope(p_env IN VARCHAR2) AS
-- ---------------------------------------------------------------------
i PLS_INTEGER;
l_len PLS_INTEGER;
BEGIN
i := 1; l_len := LENGTH(p_env);
WHILE (i <= l_len) LOOP
DBMS_OUTPUT.put_line(SUBSTR(p_env, i, 60));
i := i + 60;
END LOOP;
END;
-- ---------------------------------------------------------------------

-- ---------------------------------------------------------------------
PROCEDURE check_fault(p_response IN OUT NOCOPY t_response,
p_env IN VARCHAR2) AS
-- ---------------------------------------------------------------------
l_fault_node XMLTYPE;
l_fault_code VARCHAR2(256);
l_fault_string VARCHAR2(32767);
BEGIN
l_fault_node := p_response.doc.extract('/'||p_response.envelope_tag||':Fault',
'xmlns:'||p_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/');
IF (l_fault_node IS NOT NULL) THEN
l_fault_code := l_fault_node.extract('/'||p_response.envelope_tag||':Fault/faultcode/child::text()',
'xmlns:'||p_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
l_fault_string := l_fault_node.extract('/'||p_response.envelope_tag||':Fault/faultstring/child::text()',
'xmlns:'||p_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
--RAISE_APPLICATION_ERROR(-20000, l_fault_code || ' - ' || l_fault_string||'-->>'||p_env);
RAISE_APPLICATION_ERROR(-20000, p_env);
END IF;
END;
-- ---------------------------------------------------------------------

-- ---------------------------------------------------------------------
FUNCTION invoke(p_request IN OUT NOCOPY t_request,
p_url IN VARCHAR2,
p_action IN VARCHAR2)
RETURN t_response AS
-- ---------------------------------------------------------------------
l_envelope VARCHAR2(32767);
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_response t_response;
BEGIN
generate_envelope(p_request, l_envelope);
show_envelope(l_envelope);
l_http_request := UTL_HTTP.begin_request(p_url, 'POST','HTTP/1.0');
IF g_proxy_username IS NOT NULL THEN
UTL_HTTP.set_authentication(r => l_http_request,
username => g_proxy_username,
password => g_proxy_password,
scheme => 'Basic',
for_proxy => TRUE);
END IF;
UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml');
UTL_HTTP.set_header(l_http_request, 'Content-Length', LENGTH(l_envelope));
--UTL_HTTP.set_header(l_http_request, 'SOAPAction', p_action);
UTL_HTTP.write_text(l_http_request, l_envelope);
l_http_response := UTL_HTTP.get_response(l_http_request);
UTL_HTTP.read_text(l_http_response, l_envelope);
UTL_HTTP.end_response(l_http_response);
l_response.doc := XMLTYPE.createxml(l_envelope);
l_response.envelope_tag := p_request.envelope_tag;
l_response.doc := l_response.doc.extract('/'||l_response.envelope_tag||':Envelope/'||l_response.envelope_tag||':Body/child::node()',
'xmlns:'||l_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/"');
------------------liat
show_envelope(l_response.doc.getstringval());
check_fault(l_response,l_envelope);
RETURN l_response;
END;
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
FUNCTION get_return_value(p_response IN OUT NOCOPY t_response,
p_name IN VARCHAR2,
p_namespace IN VARCHAR2)
RETURN VARCHAR2 AS
-- ---------------------------------------------------------------------
BEGIN
RETURN p_response.doc.extract('//'||p_name||'/child::text()',p_namespace).getstringval();
END;
-- ---------------------------------------------------------------------

END soap_api;
/
---------------------------------------------------------------------------


ini fungsi untuk memanggil soap_api
-----------------------------code----------------------------------------------
CREATE OR REPLACE FUNCTION WEBMETHOD.getdata (param IN VARCHAR2)
RETURN VARCHAR2
AS
l_request soap_api.t_request;
l_response soap_api.t_response;
l_return VARCHAR2(32767);
l_url VARCHAR2(32767);
l_namespace VARCHAR2(32767);
l_method VARCHAR2(32767);
l_service VARCHAR2(32767);
l_soap_action VARCHAR2(32767);
l_result_name VARCHAR2(32767);

BEGIN
-- Set proxy details if no direct net connection.
--UTL_HTTP.set_proxy('server', NULL);
--UTL_HTTP.set_persistent_conn_support(TRUE);

-- Set proxy authentication if necessary.
soap_api.set_proxy_authentication(p_username => 'Administrator',
p_password => 'manage');

l_url := 'http://localhost:5555/soap/rpc';
l_method := 'riset';
l_namespace := 'http://www.webmethods.com/'||l_method;
l_service := 'getUp';
l_soap_action := '';
l_result_name := 'hasil';

l_request := soap_api.new_request(p_method => l_method,
p_service => l_service,
p_namespace => l_namespace);

soap_api.add_parameter(p_request => l_request,
p_name => 'input',
p_type => 'xsd:string',
p_value => param);

l_response := soap_api.invoke(p_request => l_request,
p_url => l_url,
p_action => l_soap_action);

--l_return := soap_api.get_return_value(p_response => l_response,
-- p_name => l_result_name,
-- p_namespace => l_namespace);

RETURN null;--l_return;
END;
/

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



ini contoh untuk memanggil fungsinya:

----------------------------code------------------------------------------------
DECLARE
RetVal VARCHAR2(200);
PARAM VARCHAR2(200);

BEGIN
PARAM := 'bhangun';

RetVal := WEBMETHOD.GETDATA ( PARAM );
COMMIT;
END;
----------------------------------------------------------------------------


dan ini adalah hasilnya :

----------------------------hasil------------------------------------------------
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">


bhangun


xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENC:root="1">
BHANGUN


----------------------------hasil------------------------------------------------


Untuk sementara ini fungsi soap_api.get_return_value sengaja tidak digunakan karena belum nemu format XPath untuk response-nya di webMethod. Keluarannya juga baru dalam bentuk output di konsol tapi nanti bisa disesuaikan dengan kebutuhan, mau dimasukan kedalam tabel, langsung diambil value-nya ato terserah.... Laughing hehhe maklum soalnya baru nyoba PL/SQL lagi jadi kudu belajar dulu yg lain-lainya Wink

Silahkan dikembangkan lagi.... Selamat mencoba!!

Friday, October 09, 2009

Driver untuk Toshiba Satellite A215-s5818

Driver untuk Toshiba Satellite A215-s5818 di link ini:

http://www.laptopbeep.com/drivers-for-satellite-a215-s5818

Monday, September 14, 2009

Customize Path Setting di .bashrc

## CUSTOMIZE PATH SETTING di .bashrc

######### APPLICATION HOME tulis disini

JAVA_HOME=/home/homename/opt/java/current
MAVEN_HOME=/home/homename/opt/maven/current
GLASSFISH_HOME=/home/homename/opt/glassfish/current
ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
##ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client
LAMPP_HOME=/home/homename/opt/lampp
JAVAFX_HOME=/home/homename/opt/javafx/current
DERBY_HOME=/home/homename/opt/glassfish/current/javadb

######### Tambahkan pada path disini mengikuti pola yg sudah ada.
######### ingat #PATH selalu disimpan terakhir

PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$ORACLE_HOME/bin:$GLASSFISH_HOME/bin:$LAMPP_HOME:$ORA/etc/init.d:$JAVAFX_HOME/bin:$DERBY_HOME/bin$PATH
##
ORACLE_SID=XE;

######### export masing-masing path, dipisahkan per baris lebih memudahkan
######### ingat PATH selalu ditempatkan terakhir
export JAVA_HOME
export MAVEN_HOME
export GLASSFISH_HOME
export ORACLE_HOME
export ORA
export ORACLE_SID
export LAMPP_HOME
export JAVAFX_HOME
export DERBY_HOME
export PATH


Thursday, July 30, 2009

Calling WebMethods services Menggunakan SOAP-RPC pakai Java

ini adalah contoh class manggil service webmethods menggunakan SOAP-RPC.
Ini belum baca langsung dari file WSDL tapi ngambil infonya dari WSDL.
Untuk baca langsung dari file WSDL nanti nyusul.
Service yang dipake toUpper, mangga dicobian.... Very Happy

/* ini library yang dibutuhkan:
* axis-1_2/lib/axis.jar
* axis-1_2/lib/jaxrpc.jar
* axis-1_2/lib/saaj.jar
* axis-1_2/lib/commons-logging.jar
* axis-1_2/lib/commons-discovery.jar
* axis-1_2/lib/wsdl4j.jar
*
* bisa di download di:
* http://archive.apache.org/dist/ws/axis/1_2/
*/

package wsdl;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
/**
*
* @author bhangun
*
*/
public class TesWSDL {
public static void main(String[] args) {
String namespaceURI = "http://www.webmethods.com/pub.string";
String endpoint = "http://localhost:5555/soap/rpc";
String localPart = "toUpper";
String username = "Administrator";
String pass = "manage";
String paramName = "inString";
String nsReturnType= "http://www.w3.org/2001/XMLSchema";
String returnType = "String";
QName xmlType = org.apache.axis.Constants.XSD_STRING;
ParameterMode parameterMode = ParameterMode.IN;

try {

Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName(namespaceURI, localPart));
call.setUsername(username);
call.setPassword(pass);
call.addParameter(paramName, xmlType, parameterMode);
call.setReturnType(new QName(nsReturnType,returnType));
String ret = (String) call.invoke(new Object[] { "bismillah!" });

System.out.println("Coba ku urang di cobian, '" + ret + "'");
} catch (Exception e) {
System.err.println(e.toString());
}
}
}


Wednesday, June 10, 2009

JavaFX 1.2 Can Run on linux

This is what i'am waiting for, JavaFX can run on linux.
But when i was trying to use transparent fill to Stage, there is still a bug.

Stage {
title: "Testing Transparent"
width: 250
height: 80
scene: Scene {
content: Text {
font : Font {
size : 24
}
x: 10, y: 30
content: "Testing Transparent"
}
}
opacity:0.0
}

result on the console:
Warning: Transparent windows are not supported by the current platform.


Is this JavaFX bugs or conflict whith Compiz, i do not know. May be some know about this?

Wednesday, April 29, 2009

Repository Indonesia Ubuntu Intrepid Ibex (8.10)

## REPOSITORY LOKAL -INDONESIA

##kambing.ui.edu (UI, Telkom, Indosat, OpenIXP, INHERENT)
deb http://kambing.ui.edu/ubuntu intrepid main restricted universe multiverse
deb http://kambing.ui.edu/ubuntu intrepid-updates main restricted universe multiverse
deb http://kambing.ui.edu/ubuntu intrepid-security main restricted universe multiverse
deb http://kambing.ui.edu/ubuntu intrepid-backports main restricted universe multiverse
deb http://kambing.ui.edu/ubuntu intrepid-proposed main restricted universe multiverse



##mirror.cbn.net.id (OpenIXP)
deb http://ubuntu.cbn.net.id/Ubuntu intrepid main restricted universe multiverse
deb http://ubuntu.cbn.net.id/Ubuntu intrepid-updates main restricted universe multiverse
deb http://ubuntu.cbn.net.id/Ubuntu intrepid-security main restricted universe multiverse
deb http://ubuntu.cbn.net.id/Ubuntu intrepid-backports main restricted universe multiverse
deb http://ubuntu.cbn.net.id/Ubuntu intrepid-proposed main restricted universe multiverse

##komo.vlsm.org
deb http://komo.vlsm.org/ubuntu intrepid main restricted universe multiverse
deb http://komo.vlsm.org/ubuntu intrepid-updates main restricted universe multiverse
deb http://komo.vlsm.org/ubuntu intrepid-security main restricted universe multiverse
deb http://komo.vlsm.org/ubuntu intrepid-backports main restricted universe multiverse
deb http://komo.vlsm.org/ubuntu intrepid-proposed main restricted universe multiverse

##indika.net.id (OpenIXP)
deb http://ubuntu.indika.net.id/ intrepid main restricted universe multiverse
deb http://ubuntu.indika.net.id/ intrepid-updates main restricted universe multiverse
deb http://ubuntu.indika.net.id/ intrepid-security main restricted universe multiverse
deb http://ubuntu.indika.net.id/ intrepid-backports main restricted universe multiverse
deb http://ubuntu.indika.net.id/ intrepid-proposed main restricted universe multiverse

##ftp.itb.ac.id (ITB, INHERENT)
deb ftp://ftp.itb.ac.id/pub/ubuntu intrepid main restricted universe multiverse
deb ftp://ftp.itb.ac.id/pub/ubuntu intrepid-updates main restricted universe multiverse
deb ftp://ftp.itb.ac.id/pub/ubuntu intrepid-security main restricted universe multiverse
deb ftp://ftp.itb.ac.id/pub/ubuntu intrepid-backports main restricted universe multiverse
deb ftp://ftp.itb.ac.id/pub/ubuntu intrepid-proposed main restricted universe multiverse

## www.foss-id.web.id (Telkom)
deb http://dl2.foss-id.web.id/ubuntu intrepid main restricted universe multiverse
deb http://dl2.foss-id.web.id/ubuntu intrepid-updates main restricted universe multiverse
deb http://dl2.foss-id.web.id/ubuntu intrepid-security main restricted universe multiverse
deb http://dl2.foss-id.web.id/ubuntu intrepid-backports main restricted universe multiverse
deb http://dl2.foss-id.web.id/ubuntu intrepid-proposed main restricted universe multiverse


Saturday, April 18, 2009

Instal Toad Windows di linux

Step 1. Installing wine
[root@it99 ~]# apt-get install wine
[test@it99 /]# exit
[test@it99 /]$ wine –version
wine-0.9.58

Step 2.) Configuring wine
[test@it99 /]$ winecfg


TOAD 8 run PCLINUXOS 2007

Nopember 15, 2008 in Linux, Oracle Tools, oracle | Tags: Linux, oracle, toad | No comments

source :
http://nik.chankov.net/2007/05/04/how-to-run-toad-86-on-ubuntu/

Step 1. Installing wine
[root@it99 ~]# apt-get install wine
[test@it99 /]# exit
[test@it99 /]$ wine –version
wine-0.9.58

Step 2.) Configuring wine
[test@it99 /]$ winecfg

Step 3.) Downloading Instant client for Oracle (instantclient-basic-win32-10.2.0.3-20061115.zip)
Step 4.) Creating directories for instant client
[test@it99 ~]$ cd ~
[test@it99 ~]$ cd .wine
[test@it99 .wine]$ cd drive_c
[test@it99 drive_c]$ mkdir -p ORA/BIN
[test@it99 drive_c]$ mkdir -p ORA/NETWORK/ADMIN

Step 5.) Decompress contents from instant client archive
Decompress files to $HOME/.wine/drive_c/ORA/BIN
[test@it99 ~]$ unzip instantclient-basic-win32-10.2.0.3-20061115.zip
Archive: instantclient-basic-win32-10.2.0.3-20061115.zip
creating: instantclient_10_2/
inflating: instantclient_10_2/classes12.jar
inflating: instantclient_10_2/oci.dll
inflating: instantclient_10_2/ocijdbc10.dll
inflating: instantclient_10_2/ociw32.dll
inflating: instantclient_10_2/ojdbc14.jar
inflating: instantclient_10_2/orannzsbb10.dll
inflating: instantclient_10_2/oraocci10.dll
inflating: instantclient_10_2/oraociei10.dll
[test@it99 ~]$ cp ~/instantclient_10_2/* ~/.wine/drive_c/ORA/BIN/

Step 6.) Creating Oracle Related Variables (ORACLE_HOME)

[test@it99 ~]$ wine regedit

create key Oracle as example. in that key add label ORACLE_HOME with value C:ORA

toad_01

add ot PATH C:ORA;C:ORABIN. PATH value is under HKEY_LOCAL_MACHINE > System > CurrentControlSet > Control > SessionManager > Environment

toad_02

Step 7.) Create/Get copy of tnsnames.ora
[test@it99 ~]$ vi ~/.wine/drive_c/ORA/NETWORK/ADMIN/tnsnames.ora
ppc =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.20.141.25)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ppc)
(INSTANCE_NAME = ppc)
)
)

Step 8.) Copy folder Toad from windows to ~/.wine/drive_c
[test@it99 TOAD]$ ls
BACKUP/ ReportParams.ini*
Cfx4032.dll* Reports/
CHC.REV* Revbase.dll*
CONNECTIONS.INI* RNetCHK.dll*
CVS.dll* RNetPin.dll*
DatabaseProbe.txt* Rnetpin.ini*
DBA.sdf* ROBOEX32.DLL*
desktops.xml* RuleSets/
docs/ RuleUniverse.XML*
FmtOptions.exe* Sample Project/
FmtOptions.INI* SCC.dll*
FmtPlus0.dll* Schema Objects.sdf*
FmtPlus.dll* ScriptMgr/
FmtPlus.exe* SfxBar.dll*
FmtPlus_V1.4.1.106_IDE.exe* SPServer.dll*
FMTUSER.INI* SQLMNTR.chm*
FullToad.lic* SQLMonitor.exe*
Help/ sqlnet.log*
INETWH32.dll* SQLS.DAT*
INSTALL.LOG* temps/
install.txt* TOAD.chm*
kbasemap.dat* TOAD.exe*
KXauth.dll* TOAD_GUI.INI*
KXpertPLSQLSetup80.exe* TOAD.INI*
mfc42.dll* toad.lic*
Oracle 8i Data Dictionary.sdf* toadload.wav*
PERSSQLS.DAT* TOADMAIL.INI*
Project_bak.tpr* TOADMONITORS.INI*
ProjectConfig.txt* TOADReports.exe*
Project.tpr* TOADServerSide.exe*
PVCS.dll* TOAD_SESSBROWFILTERS.INI*
QC0450.chm* Tuning_Lab/
QSAuth11.key* UnidbHook.dll*
QSR.chm* unidbsrv.dll*
qsr.exe* Uninstall.exe*
readonly.lic* unixjobs/
reflector.class* VSS.dll*
relnotes_top.gif*
[test@it99 TOAD]$

Step 9.) Run Toad
[test@it99 TOAD]$ wine TOAD.exe

toad_03



Instal Toad Windows di linux

Step 1. Installing wine
[root@it99 ~]# apt-get install wine
[test@it99 /]# exit
[test@it99 /]$ wine –version
wine-0.9.58

Step 2.) Configuring wine
[test@it99 /]$ winecfg


TOAD 8 run PCLINUXOS 2007

Nopember 15, 2008 in Linux, Oracle Tools, oracle | Tags: Linux, oracle, toad | No comments

source :
http://nik.chankov.net/2007/05/04/how-to-run-toad-86-on-ubuntu/

Step 1. Installing wine
[root@it99 ~]# apt-get install wine
[test@it99 /]# exit
[test@it99 /]$ wine –version
wine-0.9.58

Step 2.) Configuring wine
[test@it99 /]$ winecfg

Step 3.) Downloading Instant client for Oracle (instantclient-basic-win32-10.2.0.3-20061115.zip)
Step 4.) Creating directories for instant client
[test@it99 ~]$ cd ~
[test@it99 ~]$ cd .wine
[test@it99 .wine]$ cd drive_c
[test@it99 drive_c]$ mkdir -p ORA/BIN
[test@it99 drive_c]$ mkdir -p ORA/NETWORK/ADMIN

Step 5.) Decompress contents from instant client archive
Decompress files to $HOME/.wine/drive_c/ORA/BIN
[test@it99 ~]$ unzip instantclient-basic-win32-10.2.0.3-20061115.zip
Archive: instantclient-basic-win32-10.2.0.3-20061115.zip
creating: instantclient_10_2/
inflating: instantclient_10_2/classes12.jar
inflating: instantclient_10_2/oci.dll
inflating: instantclient_10_2/ocijdbc10.dll
inflating: instantclient_10_2/ociw32.dll
inflating: instantclient_10_2/ojdbc14.jar
inflating: instantclient_10_2/orannzsbb10.dll
inflating: instantclient_10_2/oraocci10.dll
inflating: instantclient_10_2/oraociei10.dll
[test@it99 ~]$ cp ~/instantclient_10_2/* ~/.wine/drive_c/ORA/BIN/

Step 6.) Creating Oracle Related Variables (ORACLE_HOME)

[test@it99 ~]$ wine regedit

create key Oracle as example. in that key add label ORACLE_HOME with value C:ORA

toad_01

add ot PATH C:ORA;C:ORABIN. PATH value is under HKEY_LOCAL_MACHINE > System > CurrentControlSet > Control > SessionManager > Environment

toad_02

Step 7.) Create/Get copy of tnsnames.ora
[test@it99 ~]$ vi ~/.wine/drive_c/ORA/NETWORK/ADMIN/tnsnames.ora
ppc =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.20.141.25)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ppc)
(INSTANCE_NAME = ppc)
)
)

Step 8.) Copy folder Toad from windows to ~/.wine/drive_c
[test@it99 TOAD]$ ls
BACKUP/ ReportParams.ini*
Cfx4032.dll* Reports/
CHC.REV* Revbase.dll*
CONNECTIONS.INI* RNetCHK.dll*
CVS.dll* RNetPin.dll*
DatabaseProbe.txt* Rnetpin.ini*
DBA.sdf* ROBOEX32.DLL*
desktops.xml* RuleSets/
docs/ RuleUniverse.XML*
FmtOptions.exe* Sample Project/
FmtOptions.INI* SCC.dll*
FmtPlus0.dll* Schema Objects.sdf*
FmtPlus.dll* ScriptMgr/
FmtPlus.exe* SfxBar.dll*
FmtPlus_V1.4.1.106_IDE.exe* SPServer.dll*
FMTUSER.INI* SQLMNTR.chm*
FullToad.lic* SQLMonitor.exe*
Help/ sqlnet.log*
INETWH32.dll* SQLS.DAT*
INSTALL.LOG* temps/
install.txt* TOAD.chm*
kbasemap.dat* TOAD.exe*
KXauth.dll* TOAD_GUI.INI*
KXpertPLSQLSetup80.exe* TOAD.INI*
mfc42.dll* toad.lic*
Oracle 8i Data Dictionary.sdf* toadload.wav*
PERSSQLS.DAT* TOADMAIL.INI*
Project_bak.tpr* TOADMONITORS.INI*
ProjectConfig.txt* TOADReports.exe*
Project.tpr* TOADServerSide.exe*
PVCS.dll* TOAD_SESSBROWFILTERS.INI*
QC0450.chm* Tuning_Lab/
QSAuth11.key* UnidbHook.dll*
QSR.chm* unidbsrv.dll*
qsr.exe* Uninstall.exe*
readonly.lic* unixjobs/
reflector.class* VSS.dll*
relnotes_top.gif*
[test@it99 TOAD]$

Step 9.) Run Toad
[test@it99 TOAD]$ wine TOAD.exe

toad_03



Tuesday, March 31, 2009

Method untuk ngambil waktu sistem

Format waktu adalah hh:MM:ss
public String getDate(){
Formatter fmt = new Formatter();
Calendar cal = Calendar.getInstance();
fmt = new Formatter();
fmt.format("%tl:%tM:%tS", cal,cal, cal);
return fmt.toString();
}

Monday, March 30, 2009

Sorting Map berdasarkan Key atau Value di Java

Walau agak aneh sih harus bikin sorting map di java tapi siapa tau berguna.

Ini sort berdasarkan key:

@SuppressWarnings("unchecked")
public static Map sortByKey(Map map) {
List list = new LinkedList(map.entrySet());
Collections.sort(list, new Comparator() {
public int compare(Object o1, Object o2) {
return ((Comparable) ((Map.Entry) (o1)).getKey())
.compareTo(((Map.Entry) (o2)).getKey());
}
});
// logger.info(list);
Map result = new LinkedHashMap();
for (Iterator it = list.iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
result.put(entry.getKey(), entry.getValue());
}
return result;
}

Ini sort berdasarkan value:
@SuppressWarnings("unchecked")
public static Map sortByValue(Map map) {
List list = new LinkedList(map.entrySet());
Collections.sort(list, new Comparator() {
public int compare(Object o1, Object o2) {
return ((Comparable) ((Map.Entry) (o1)).getValue())
.compareTo(((Map.Entry) (o2)).getValue());
}
});
// logger.info(list);
Map result = new LinkedHashMap();
for (Iterator it = list.iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
result.put(entry.getKey(), entry.getValue());
}
return result;
}

Tuesday, March 03, 2009

Menghapus menu booting di komputer dengan dual Sistem Operasi (Ubuntu & Windows)

Nah mungkin bagi kamu yang punya komputer terus diinstal dua sistem operasi kayak Ubuntu dan Windows, pasti baka menemukan pas booting ada menu untuk masuk ke Ubuntu dan ke Windows. Cuma masalahnya menu yang Ubuntu terkadang ketika beberapa kali di update ada penambahan menu beberapa versi kernelnya.

Nah sebenarnya itu gak masalah, karena itu disediakan agar ketika ada salah satu kernel yg eror, bisa pake kernel yang lainnya. Tapi yang ribet emang di menunya, karena semakin sering diupdate kernelnyanya tentu menunya bertambah. pasti bikin risih.

Nah biar gak ribet ilangin aja menunya.....
Lho caranya gimana ?!!?!?!?!


Ini dia caranya:
1. MAsuk dulu ke ubuntu nya.
2. Buka terminal terus edit deh file menu.lst, caranya ketikan perintah di bawah ini:
prompt$ sudo vim /boot/grub/menu.lst

3. Nah terus arahkan kursor ke bagian paling bawah, nanti akan menemukan daftar kayak di bawah ini:

## ## End Default Options ##

title Ubuntu 8.10, kernel 2.6.27-9-generic
uuid f1dc7c96-cb80-47c6-94dd-9f23789600ed
kernel /boot/vmlinuz-2.6.27-9-generic root=UUID=f1dc7c96-cb80-47c6-94dd-9f23789600ed ro quiet splash vga=791
initrd /boot/initrd.img-2.6.27-9-generic
quiet

title Ubuntu 8.10, kernel 2.6.27-9-generic (recovery mode)
uuid f1dc7c96-cb80-47c6-94dd-9f23789600ed
kernel /boot/vmlinuz-2.6.27-9-generic root=UUID=f1dc7c96-cb80-47c6-94dd-9f23789600ed ro single
initrd /boot/initrd.img-2.6.27-9-generic

title Ubuntu 8.10, kernel 2.6.27-7-generic
uuid f1dc7c96-cb80-47c6-94dd-9f23789600ed
kernel /boot/vmlinuz-2.6.27-7-generic root=UUID=f1dc7c96-cb80-47c6-94dd-9f23789600ed ro quiet splash
initrd /boot/initrd.img-2.6.27-7-generic
quiet

title Ubuntu 8.10, kernel 2.6.27-7-generic (recovery mode)
uuid f1dc7c96-cb80-47c6-94dd-9f23789600ed
kernel /boot/vmlinuz-2.6.27-7-generic root=UUID=f1dc7c96-cb80-47c6-94dd-9f23789600ed ro single
initrd /boot/initrd.img-2.6.27-7-generic

title Ubuntu 8.10, memtest86+
uuid f1dc7c96-cb80-47c6-94dd-9f23789600ed
kernel /boot/memtest86+.bin
quiet
### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda2
title Windows Vista ##Windows Vista/Longhorn (loader)
root (hd0,1)
savedefault
makeactive
chainloader +1


4. Keliatan kan disitu ada beberapa daftar menu kernel. Nah daftar itu bisa saja dihapus. Tapi amannya mending di kasi komentar aja menu yang gak mo dimunculin pas booting. caranya kasi tanda '#'. Ni contohnya:

#title Ubuntu 8.10, kernel 2.6.27-7-generic
#uuid f1dc7c96-cb80-47c6-94dd-9f23789600ed
#kernel /boot/vmlinuz-2.6.27-7-generic root=UUID=f1dc7c96-cb80-47c6-94dd-9f23789600ed ro quiet splash
#initrd /boot/initrd.img-2.6.27-7-generic
#quiet

#title Ubuntu 8.10, kernel 2.6.27-7-generic (recovery mode)
#uuid f1dc7c96-cb80-47c6-94dd-9f23789600ed
#kernel /boot/vmlinuz-2.6.27-7-generic root=UUID=f1dc7c96-cb80-47c6-94dd-9f23789600ed ro single
#initrd /boot/initrd.img-2.6.27-7-generic


5. Begitu seterusnya. Selesai deh. Oh iya klo ada yang mo ganti redaksi judulnya juga bisa, tinggal diganti aja title nya.

Untuk baca record dalam file

Method ini untuk membaca record dalam suatu file

public List read(String path){
List list = new ArrayList();
try
{
String in=null;

FileInputStream fStream = new FileInputStream(path);
BufferedReader dInput = new BufferedReader(new InputStreamReader(fStream));

while (dInput.ready())
{
in = dInput.readLine();
System.out.println(in);

list.add(in);

}
dInput.close();

}
catch (Exception e)
{
System.err.println("There was a error : " + e.toString());
}
return list;
}