Example usage for javax.xml.ws Holder Holder

List of usage examples for javax.xml.ws Holder Holder

Introduction

In this page you can find the example usage for javax.xml.ws Holder Holder.

Prototype

public Holder() 

Source Link

Document

Creates a new holder with a null value.

Usage

From source file:org.apache.juddi.v3.tck.UDDI_150_CustodyTransferIntegrationTest.java

/**
 * a valid transfer token issued, then modified out of band, this should
 * fail/*  w ww. j  av a 2s . c  om*/
 */
@Test
public void InvalidTransferTokenModified() {
    Assume.assumeTrue(TckPublisher.isEnabled());
    String keySamBiz = null;
    String keyJoeBiz = null;
    try {
        DatatypeFactory df = DatatypeFactory.newInstance();
        GregorianCalendar gcal = new GregorianCalendar();
        gcal.setTimeInMillis(System.currentTimeMillis());
        XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal);

        BusinessEntity myBusEntity = new BusinessEntity();
        Name myBusName = new Name();
        myBusName.setLang("en");
        myBusName.setValue("InvalidTransferTokenModified UDDI's Business" + " " + xcal.toString());
        myBusEntity.getName().add(myBusName);
        myBusEntity.setBusinessServices(new BusinessServices());
        myBusEntity.getBusinessServices().getBusinessService().add(CreateBusiness("UDDI"));
        SaveBusiness sb = new SaveBusiness();
        sb.getBusinessEntity().add(myBusEntity);
        sb.setAuthInfo(authInfoJoe);
        BusinessDetail bd = publishJoe.saveBusiness(sb);

        keyJoeBiz = bd.getBusinessEntity().get(0).getBusinessKey();

        myBusEntity = new BusinessEntity();
        myBusName = new Name();
        myBusName.setLang("en");
        myBusName.setValue("Root's Business" + " " + xcal.toString());
        myBusEntity.getName().add(myBusName);
        myBusEntity.setBusinessServices(new BusinessServices());
        myBusEntity.getBusinessServices().getBusinessService().add(CreateBusiness("root"));
        sb = new SaveBusiness();
        sb.getBusinessEntity().add(myBusEntity);
        sb.setAuthInfo(authInfoSam);
        bd = publishSam.saveBusiness(sb);

        keySamBiz = bd.getBusinessEntity().get(0).getBusinessKey();
        //String keySamBizSvc = bd.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0).getServiceKey();

        //transfers from Joe to Sam
        KeyBag kb = new KeyBag();
        kb.getKey().add(keyJoeBiz);

        Holder<String> nodeidOUT = new Holder<String>();
        Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
        Holder<byte[]> tokenOUT = new Holder<byte[]>();
        custodyTransferPortTypeJoe.getTransferToken(authInfoJoe, kb, nodeidOUT, expiresOUT, tokenOUT);

        //sam accepts
        TransferEntities te = new TransferEntities();
        te.setAuthInfo(authInfoSam);
        te.setKeyBag(kb);
        te.getKeyBag().getKey().add("uddi:uddi.joepublisher.com:" + UUID.randomUUID().toString());
        TransferToken tt = new TransferToken();
        tt.setExpirationTime(expiresOUT.value);
        tt.setNodeID(nodeidOUT.value);
        tt.setOpaqueToken(tokenOUT.value);
        te.setTransferToken(tt);

        custodyTransferPortTypeSam.transferEntities(te);
        Assert.fail();
    } catch (Exception ex) {
        //  HandleException(ex);
        logger.info("Expected exception: " + ex.getMessage());
    } finally {
        TckCommon.DeleteBusiness(keyJoeBiz, authInfoJoe, publishJoe);
        TckCommon.DeleteBusiness(keySamBiz, authInfoSam, publishSam);
    }

}

From source file:org.apache.juddi.v3.tck.UDDI_150_CustodyTransferIntegrationTest.java

@Test
public void InvalidTransferTokenServiceDoesntExist() throws Exception {
    Assume.assumeTrue(TckPublisher.isEnabled());
    try {//from  w ww  .  java 2  s  . com
        //transfers from Joe to Sam
        KeyBag kb = new KeyBag();
        kb.getKey().add("uddi:uddi.joepublisher.com:" + UUID.randomUUID().toString());

        Holder<String> nodeidOUT = new Holder<String>();
        Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
        Holder<byte[]> tokenOUT = new Holder<byte[]>();
        custodyTransferPortTypeJoe.getTransferToken(authInfoJoe, kb, nodeidOUT, expiresOUT, tokenOUT);
        Assert.fail();
    } catch (Exception ex) {
        //HandleException(ex);
        logger.info("Expected exception: " + ex.getMessage());
    }
}

From source file:org.apache.juddi.webconsole.hub.UddiHub.java

/**
 * attempts to save subscription/*w ww  .  j a  va  2s . c  om*/
 *
 * @param sub
 * @return a success or fail message
 */
public String AddSubscription(Subscription sub) {
    Holder<List<Subscription>> data = new Holder<List<Subscription>>();
    data.value = new ArrayList<Subscription>();
    data.value.add(sub);
    try {
        try {
            subscription.saveSubscription(GetToken(), data);
        } catch (Exception ex) {
            if (isExceptionExpiration(ex)) {
                token = null;
                subscription.saveSubscription(GetToken(), data);

            } else {
                throw ex;
            }
        }
        return ResourceLoader.GetResource(session, "messages.success") + " <a href=\"editSubscription.jsp?id="
                + URLEncoder.encode(data.value.get(0).getSubscriptionKey(), "UTF8") + "\">"
                + StringEscapeUtils.escapeHtml(data.value.get(0).getSubscriptionKey()) + "</a>";
    } catch (Exception ex) {
        return HandleException(ex);
    }
}

From source file:org.apache.juddi.webconsole.hub.UddiHub.java

private String SendAdvancedQueryPublish(String method, Object request) {
    Object response = null;//from  w  w  w . java  2 s. c o m
    try {
        if (method.equalsIgnoreCase("addPublisherAssertions")) {
            ((AddPublisherAssertions) request).setAuthInfo(GetToken());
            try {
                publish.addPublisherAssertions((AddPublisherAssertions) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((AddPublisherAssertions) request).setAuthInfo(GetToken());
                    publish.addPublisherAssertions((AddPublisherAssertions) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("deleteBinding")) {
            try {
                ((DeleteBinding) request).setAuthInfo(GetToken());
                publish.deleteBinding((DeleteBinding) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((DeleteBinding) request).setAuthInfo(GetToken());
                    publish.deleteBinding((DeleteBinding) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("deleteBusiness")) {
            try {
                ((DeleteBusiness) request).setAuthInfo(GetToken());
                publish.deleteBusiness((DeleteBusiness) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((DeleteBusiness) request).setAuthInfo(GetToken());
                    publish.deleteBusiness((DeleteBusiness) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("deletePublisherAssertions")) {
            try {
                ((DeletePublisherAssertions) request).setAuthInfo(GetToken());
                publish.deletePublisherAssertions((DeletePublisherAssertions) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((DeleteBusiness) request).setAuthInfo(GetToken());
                    publish.deletePublisherAssertions((DeletePublisherAssertions) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("deleteService")) {
            try {
                ((DeleteService) request).setAuthInfo(GetToken());
                publish.deleteService((DeleteService) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((DeleteBusiness) request).setAuthInfo(GetToken());
                    publish.deleteService((DeleteService) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("deleteTModel")) {
            try {
                ((DeleteTModel) request).setAuthInfo(GetToken());
                publish.deleteTModel((DeleteTModel) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((DeleteTModel) request).setAuthInfo(GetToken());
                    publish.deleteTModel((DeleteTModel) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("getAssertionStatusReport")) {
            CompletionStatus stat = ((GetAssertionStatusReport) request).getCompletionStatus();
            try {
                response = publish.getAssertionStatusReport(GetToken(), stat);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    response = publish.getAssertionStatusReport(GetToken(), stat);

                } else {
                    throw ex;
                }
            }

        }
        if (method.equalsIgnoreCase("getPublisherAssertions")) {
            try {
                response = publish.getPublisherAssertions(GetToken());
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    response = publish.getPublisherAssertions(GetToken());

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("getRegisteredInfo")) {
            try {
                ((GetRegisteredInfo) request).setAuthInfo(GetToken());
                response = publish.getRegisteredInfo((GetRegisteredInfo) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((GetRegisteredInfo) request).setAuthInfo(GetToken());
                    publish.getRegisteredInfo((GetRegisteredInfo) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("saveBinding")) {
            try {
                ((SaveBinding) request).setAuthInfo(GetToken());
                response = publish.saveBinding((SaveBinding) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((SaveBinding) request).setAuthInfo(GetToken());
                    publish.saveBinding((SaveBinding) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("saveBusiness")) {
            try {
                ((SaveBusiness) request).setAuthInfo(GetToken());
                response = publish.saveBusiness((SaveBusiness) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((SaveBusiness) request).setAuthInfo(GetToken());
                    publish.saveBusiness((SaveBusiness) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("saveTModel")) {
            try {
                ((SaveTModel) request).setAuthInfo(GetToken());
                response = publish.saveTModel((SaveTModel) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((SaveTModel) request).setAuthInfo(GetToken());
                    publish.saveTModel((SaveTModel) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("saveService")) {
            try {
                ((SaveService) request).setAuthInfo(GetToken());
                response = publish.saveService((SaveService) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((SaveService) request).setAuthInfo(GetToken());
                    publish.saveService((SaveService) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("setPublisherAssertions")) {
            Holder<List<PublisherAssertion>> list = new Holder<List<PublisherAssertion>>();
            list.value = ((SetPublisherAssertions) request).getPublisherAssertion();
            try {
                publish.setPublisherAssertions(GetToken(), list);
                response = list.value;
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((SetPublisherAssertions) request).setAuthInfo(GetToken());
                    publish.setPublisherAssertions(GetToken(), list);
                    response = list.value;

                } else {
                    throw ex;
                }
            }

        }
        if (response == null) {
            return "The operation completed without error";
        }
        StringWriter sw = new StringWriter();
        JAXB.marshal(response, sw);
        return sw.toString();
    } catch (Exception ex) {
        return HandleException(ex);
    }
}

From source file:org.apache.juddi.webconsole.hub.UddiHub.java

private String SendAdvancedQueryCustody(String method, Object request) {
    Object response = null;/*from   ww w . j  a  v  a  2 s.  c  o  m*/
    try {

        if (method.equalsIgnoreCase("discardTransferToken")) {
            try {
                ((DiscardTransferToken) request).setAuthInfo(GetToken());
                custody.discardTransferToken((DiscardTransferToken) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((DiscardTransferToken) request).setAuthInfo(GetToken());
                    custody.discardTransferToken((DiscardTransferToken) request);

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("getTransferToken")) {
            GetTransferToken r = ((GetTransferToken) request);
            TransferToken tt = new TransferToken();
            Holder<String> node = new Holder<String>();
            Holder<XMLGregorianCalendar> xcal = new Holder<XMLGregorianCalendar>();
            Holder<byte[]> ttoken = new Holder<byte[]>();
            try {
                custody.getTransferToken(GetToken(), r.getKeyBag(), node, xcal, ttoken);
                tt.setNodeID(node.value);
                tt.setOpaqueToken(ttoken.value);
                tt.setExpirationTime(xcal.value);
                response = tt;
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    custody.getTransferToken(GetToken(), r.getKeyBag(), node, xcal, ttoken);
                    tt.setNodeID(node.value);
                    tt.setOpaqueToken(ttoken.value);
                    tt.setExpirationTime(xcal.value);
                    response = tt;

                } else {
                    throw ex;
                }
            }
        }
        if (method.equalsIgnoreCase("transferEntities")) {
            try {
                ((TransferEntities) request).setAuthInfo(GetToken());
                custody.transferEntities((TransferEntities) request);
            } catch (Exception ex) {
                if (isExceptionExpiration(ex)) {
                    token = null;
                    ((TransferEntities) request).setAuthInfo(GetToken());
                    custody.transferEntities((TransferEntities) request);

                } else {
                    throw ex;
                }
            }
        }

        if (response == null) {
            return "The operation completed without error";
        }
        StringWriter sw = new StringWriter();
        JAXB.marshal(response, sw);
        return sw.toString();
    } catch (Exception ex) {
        return HandleException(ex);
    }
}

From source file:org.apache.servicecomb.foundation.vertx.VertxUtils.java

public static <VERTICLE extends Verticle> boolean blockDeploy(Vertx vertx, Class<VERTICLE> cls,
        DeploymentOptions options) throws InterruptedException {
    Holder<Boolean> result = new Holder<>();

    CountDownLatch latch = new CountDownLatch(1);
    vertx.deployVerticle(cls.getName(), options, ar -> {
        result.value = ar.succeeded();/* w  ww .j a va  2  s . c  om*/

        if (ar.failed()) {
            LOGGER.error("deploy vertx failed, cause ", ar.cause());
        }

        latch.countDown();
    });

    latch.await();

    return result.value;
}

From source file:org.apache.servicecomb.loadbalance.TestLoadbalanceHandler.java

@Test
public void send_noEndPoint() {
    new Expectations(loadBalancer) {
        {/*from www . ja va  2  s .c o m*/
            loadBalancer.chooseServer(invocation);
            result = null;
        }
    };

    Holder<Throwable> result = new Holder<>();
    Deencapsulation.invoke(handler, "send", invocation, (AsyncResponse) resp -> {
        result.value = (Throwable) resp.getResult();
    }, loadBalancer);

    Assert.assertEquals(
            "InvocationException: code=490;msg=CommonExceptionData [message=Cse Internal Bad Request]",
            result.value.getMessage());
    Assert.assertEquals(
            "No available address found. microserviceName=ms, version=null, discoveryGroupName=null",
            result.value.getCause().getMessage());
}

From source file:org.apache.servicecomb.loadbalance.TestLoadbalanceHandler.java

@Test
public void send_failed() {
    CacheEndpoint cacheEndpoint = new CacheEndpoint("rest://localhost:8080", null);
    CseServer server = new CseServer(restTransport, cacheEndpoint);
    new MockUp<System>() {
        @Mock//from   w  w  w.  j  av  a  2  s .c om
        long currentTimeMillis() {
            return 123;
        }
    };
    new Expectations(loadBalancer) {
        {
            loadBalancer.chooseServer(invocation);
            result = server;
        }
    };
    int continuousFailureCount = server.getCountinuousFailureCount();

    sendResponse = Response.create(Status.BAD_REQUEST, "send failed");

    Holder<Throwable> result = new Holder<>();
    Deencapsulation.invoke(handler, "send", invocation, (AsyncResponse) resp -> {
        result.value = (Throwable) resp.getResult();
    }, loadBalancer);

    Assert.assertEquals(123, server.getLastVisitTime());
    Assert.assertEquals(1, loadBalancer.getLoadBalancerStats().getSingleServerStat(server)
            .getSuccessiveConnectionFailureCount());
    Assert.assertEquals("InvocationException: code=400;msg=send failed", result.value.getMessage());
    Assert.assertEquals(continuousFailureCount + 1, server.getCountinuousFailureCount());
}

From source file:org.apache.servicecomb.loadbalance.TestLoadbalanceHandler.java

@Test
public void send_success() {
    CacheEndpoint cacheEndpoint = new CacheEndpoint("rest://localhost:8080", null);
    CseServer server = new CseServer(restTransport, cacheEndpoint);
    new MockUp<System>() {
        @Mock/*from  w  w w. ja v  a2  s .  c  om*/
        long currentTimeMillis() {
            return 123;
        }
    };
    new Expectations(loadBalancer) {
        {
            loadBalancer.chooseServer(invocation);
            result = server;
        }
    };
    server.incrementContinuousFailureCount();

    sendResponse = Response.ok("success");

    Holder<String> result = new Holder<>();
    Deencapsulation.invoke(handler, "send", invocation, (AsyncResponse) resp -> {
        result.value = resp.getResult();
    }, loadBalancer);

    Assert.assertEquals(123, server.getLastVisitTime());
    Assert.assertEquals(1,
            loadBalancer.getLoadBalancerStats().getSingleServerStat(server).getActiveRequestsCount());
    Assert.assertEquals("success", result.value);
    Assert.assertEquals(0, server.getCountinuousFailureCount());
}

From source file:org.apache.servicecomb.loadbalance.TestLoadbalanceHandler.java

@Test
public void sendWithRetry() {
    Holder<String> result = new Holder<>();
    Deencapsulation.invoke(handler, "sendWithRetry", invocation, (AsyncResponse) resp -> {
        result.value = resp.getResult();
    }, loadBalancer);//  w  w w  .  j a  v a  2  s .  c o  m

    // no exception
}