home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wsgatsam.zip / CheckIn.java < prev    next >
Text File  |  2003-02-24  |  4KB  |  119 lines

  1. /**
  2.  * %wsgw_sample_start%
  3.  * Licensed Materials - Property of IBM  
  4.  *    
  5.  * (c) Copyright IBM Corp. 2001, 2002 All Rights Reserved.  
  6.  *    
  7.  * US Government Users Restricted Rights - Use, duplication or   
  8.  * disclosure restricted by GSA ADP Schedule Contract with   
  9.  * IBM Corp.  
  10.  * %wsgw_sample_end%
  11.  */
  12.  
  13. package services.lftfileservice;
  14.  
  15. import org.apache.wsif.util.*;
  16. import org.apache.wsif.*;
  17. import com.ibm.wsdl.extensions.lft.*;
  18. import com.ibm.wsif.providers.lft.*;
  19. import com.fileService.www.*;
  20.  
  21. public class CheckIn {
  22.  
  23.   private static void doCheckIn (FileServicePort fs, String installDir)
  24.     throws Exception {
  25.     
  26.     String fileName = 
  27.       "file:"+installDir+"/samples/services/lftfileservice/demo.htm";
  28.     System.out.println("checkIn: File Name: "+fileName);
  29.     String message = 
  30.       fs.checkIn("fileId001", "changed this changed that" , fileName);
  31.     System.out.println("CheckIn: Message : " + message);
  32.   }
  33.  
  34.   /**
  35.    * Makes sure the pathName starts with one and only one '/'
  36.    * and ends with no '/'. Replaces '\' by '/'.
  37.    * @param  pathName the path name
  38.    * @return the valid path name
  39.    */
  40.   protected static String makeValidPathName(String pathName) {
  41.     // make sure there is only one '/' at start.
  42.     while (pathName.startsWith("/")) {
  43.       pathName = pathName.substring(1);
  44.     }
  45.     pathName = "/"+pathName;
  46.     
  47.     // remove '/' at end.
  48.     while (pathName.endsWith("/")) {
  49.       pathName = pathName.substring(0,pathName.length()-1);
  50.     }
  51.     // Replace '\' by '/'
  52.     return pathName.replace('\\','/');
  53.   }
  54.  
  55.   protected static void usage() {
  56.     System.out.println("The valid options are wsif, wsgw or java.");
  57.   }
  58.  
  59.   public static void main (String[] args) throws Exception {
  60.  
  61.     String portTypeName = "fileServicePort";
  62.     String portName=null;
  63.     String wsdlLocation=null;
  64.     String installDir=args[1].trim();
  65.     String gatewayHostPort=null;
  66.   
  67.     System.out.println("Starting CheckIn...");
  68.  
  69.     installDir = CheckIn.makeValidPathName(installDir);
  70.  
  71.     //System.out.println("installDir is now: "+installDir);
  72.     
  73.     if((args[0]==null)||(args[0].equals("wsif"))) {
  74.       portName = "HTTPRPort"; // Direct WSDL
  75.       wsdlLocation =
  76.         "file:"+installDir+"/samples/services/lftfileservice/LFTSample.wsdl";
  77.  
  78.     } else if (args[0].equals("wsgw")) {
  79.       portName = "fileServicePortApacheAxisBindingPort"; // Axis GW
  80.       // TBD: It shouldn't be localhost here, but the actual hostname.
  81.       wsdlLocation = "http://localhost/wsgw/ServiceDefinition?name=fileService";        
  82.     } else if (args[0].equals("java")) {
  83.       portName = "fileServicePortJavaBindingPort"; 
  84.       wsdlLocation =
  85.         "file:"+installDir+"/samples/services/lftfileservice/LFTSampleJava.wsdl";
  86.  
  87.     } else {
  88.         System.out.println("This option ("+args[0]+") is not supported");
  89.     CheckIn.usage();
  90.     }
  91.         
  92.     System.out.println("wsdlURL: " + wsdlLocation);
  93.  
  94.     WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  95.     WSIFService service = factory.getService(
  96.       wsdlLocation, 
  97.       null,                                                   // serviceNS
  98.       null,                                                   // serviceName
  99.       "http://www.fileService.com/largeFile",                 // portTypeNS
  100.       portTypeName);                                          // portTypeName
  101.  
  102.     FileServicePort fsStub = null;
  103.     
  104.     if(portName != null) {
  105.       System.out.println ("\n\nUsing '" + portName + "' port:");
  106.       System.out.println("FileServicePort.class: "
  107.                          +FileServicePort.class.toString());
  108.       fsStub =(FileServicePort)service.getStub(portName, FileServicePort.class);
  109.       if ( fsStub != null) {
  110.         doCheckIn (fsStub, installDir);
  111.       } else {
  112.         System.out.println( "fsStub is Null");
  113.       }
  114.     } 
  115.  
  116.   }
  117.  
  118. }
  119.