juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svi...@apache.org
Subject cvs commit: ws-juddi/samples/save_publisher SavePublisherSample.java
Date Sun, 04 Apr 2004 04:17:40 GMT
sviens      2004/04/03 20:17:40

  Modified:    samples/save_publisher SavePublisherSample.java
  Log:
  Updated and tested successfully.
  
  Revision  Changes    Path
  1.5       +47 -9     ws-juddi/samples/save_publisher/SavePublisherSample.java
  
  Index: SavePublisherSample.java
  ===================================================================
  RCS file: /home/cvs/ws-juddi/samples/save_publisher/SavePublisherSample.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SavePublisherSample.java	16 Mar 2004 14:26:16 -0000	1.4
  +++ SavePublisherSample.java	4 Apr 2004 04:17:40 -0000	1.5
  @@ -14,12 +14,17 @@
    * limitations under the License.
    */
   
  +import java.util.Properties;
   import java.util.Vector;
   
   import org.apache.juddi.datatype.publisher.Publisher;
   import org.apache.juddi.datatype.request.AuthInfo;
   import org.apache.juddi.datatype.response.AuthToken;
  +import org.apache.juddi.datatype.response.DispositionReport;
  +import org.apache.juddi.datatype.response.ErrInfo;
   import org.apache.juddi.datatype.response.PublisherDetail;
  +import org.apache.juddi.datatype.response.Result;
  +import org.apache.juddi.error.RegistryException;
   import org.apache.juddi.proxy.RegistryProxy;
   import org.apache.juddi.registry.IRegistry;
   
  @@ -31,29 +36,62 @@
   {
     public static void main(String[] args)
     {
  -    IRegistry registry = new RegistryProxy();
  +    // Option #1 (grabs properties from juddi.properties)
  +    //IRegistry registry = new RegistryProxy();
  +    
  +    // Option #2
  +    Properties props = new Properties();
  +    props.setProperty(RegistryProxy.ADMIN_ENDPOINT_PROPERTY_NAME,"http://localhost:8080/juddi/admin");
  +    props.setProperty(RegistryProxy.INQUIRY_ENDPOINT_PROPERTY_NAME,"http://localhost:8080/juddi/inquiry");
  +    props.setProperty(RegistryProxy.PUBLISH_ENDPOINT_PROPERTY_NAME,"http://localhost:8080/juddi/publish");
  +    IRegistry registry = new RegistryProxy(props);
  +
  +    String userID = "sviens";
  +    String password = "password";
   
       try
       {
  -      // execute a GetAuthToken request
  -      AuthToken token = registry.getAuthToken("sviens", "password");
  -      AuthInfo authInfo = token.getAuthInfo();
  +      System.out.println("save_tModel Sample");
  +      System.out.println("------------------");
  +      System.out.println("userID: "+userID);
  +      System.out.println("password: "+password);
  +      System.out.println("");
  +
  +      AuthToken authToken = registry.getAuthToken(userID,password);
  +      AuthInfo authInfo = authToken.getAuthInfo();
  +      System.out.println("AuthToken: "+authInfo.getValue());
   
         // create a publisher
  -      Publisher publisher = new Publisher("BlueNoteIdentifier", "Blue Note");
  +      Publisher publisher = new Publisher("acutright","Andy Cutright",false);
   
         // put the Publisher object into a Vector
         Vector vector = new Vector(1);
         vector.add(publisher);
   
         // make the request
  -      PublisherDetail detail = registry.savePublisher(authInfo, vector);
  +      PublisherDetail detail = registry.savePublisher(authInfo,vector);
   
         System.out.println("publishers saved = " + detail.getPublisherVector().size());
  -      }
  -    catch(Exception ex)
  +    }
  +    catch (RegistryException regex)
       {
  -      ex.printStackTrace();
  +      DispositionReport dispReport = regex.getDispositionReport();
  +      Vector resultVector = dispReport.getResultVector();
  +      if (resultVector != null)
  +      {
  +        Result result = (Result)resultVector.elementAt(0);
  +        int errNo = result.getErrno();
  +        System.out.println("Errno:   "+errNo);
  +
  +        ErrInfo errInfo = result.getErrInfo();
  +        if (errInfo != null)
  +        {
  +          System.out.println("ErrCode: "+errInfo.getErrCode());
  +          System.out.println("ErrMsg:  "+errInfo.getErrMsg());
  +        }        
  +      }
       }
  +
  +    System.out.println("\ndone.");    
     }
   }
  
  
  

Mime
View raw message