Example usage for javax.xml.datatype DatatypeFactory newInstance

List of usage examples for javax.xml.datatype DatatypeFactory newInstance

Introduction

In this page you can find the example usage for javax.xml.datatype DatatypeFactory newInstance.

Prototype

public static DatatypeFactory newInstance() throws DatatypeConfigurationException 

Source Link

Document

Obtain a new instance of a DatatypeFactory .

Usage

From source file:org.apache.juddi.adminconsole.hub.JUDDIRequestsAsXML.java

public static String getSampleXML(String method) {
    StringWriter sw = new StringWriter();

    if (method.equalsIgnoreCase("save_ClientSubscriptionInfo")) {
        SaveClientSubscriptionInfo obj = new SaveClientSubscriptionInfo();
        obj.getClientSubscriptionInfo().add(new ClientSubscriptionInfo());
        obj.getClientSubscriptionInfo().get(0).setFromClerk(new Clerk());
        obj.getClientSubscriptionInfo().get(0).setToClerk(new Clerk());
        obj.getClientSubscriptionInfo().get(0).setSubscriptionKey("key");

        JAXB.marshal(obj, sw);// w ww.  j  a  v a 2s .c o m
    }
    if (method.equalsIgnoreCase("invoke_SyncSubscription")) {
        SyncSubscription obj = new SyncSubscription();
        obj.getGetSubscriptionResultsList().add(new GetSubscriptionResults());
        obj.getGetSubscriptionResultsList().get(0).setSubscriptionKey("key");
        obj.getGetSubscriptionResultsList().get(0).setCoveragePeriod(new CoveragePeriod());
        DatatypeFactory newInstance;
        try {
            newInstance = DatatypeFactory.newInstance();
            obj.getGetSubscriptionResultsList().get(0).getCoveragePeriod()
                    .setEndPoint(newInstance.newXMLGregorianCalendar(new GregorianCalendar()));
            obj.getGetSubscriptionResultsList().get(0).getCoveragePeriod()
                    .setStartPoint(newInstance.newXMLGregorianCalendar(new GregorianCalendar()));

        } catch (DatatypeConfigurationException ex) {
            Logger.getLogger(JUDDIRequestsAsXML.class.getName()).log(Level.SEVERE, null, ex);
        }
        JAXB.marshal(obj, sw);
    }
    if (method.equalsIgnoreCase("admin_SaveBusiness")) {
        AdminSaveBusiness obj = new AdminSaveBusiness();
        obj.getValues().add(new AdminSaveBusinessWrapper());
        obj.getValues().get(0).setPublisherID("username");
        obj.getValues().get(0).getBusinessEntity().add(new BusinessEntity());
        obj.getValues().get(0).getBusinessEntity().get(0).getName().add(new Name("Business Name", "en"));
        JAXB.marshal(obj, sw);
    }
    if (method.equalsIgnoreCase("admin_SaveTModel")) {
        AdminSaveTModel obj = new AdminSaveTModel();
        obj.getValues().add(new AdminSaveTModelWrapper());
        obj.getValues().get(0).setPublisherID("username");
        obj.getValues().get(0).getTModel().add(new TModel());
        obj.getValues().get(0).getTModel().get(0).setName(new Name("TModel Name", "en"));
        JAXB.marshal(obj, sw);
    }

    if (method.equalsIgnoreCase("admin_SaveSubscription")) {
        AdminSaveSubscriptionRequest obj = new AdminSaveSubscriptionRequest();
        obj.setPublisherOrUsername("username");
        obj.getSubscriptions().add(new Subscription());
        obj.getSubscriptions().get(0).setSubscriptionFilter(new SubscriptionFilter());
        obj.getSubscriptions().get(0).setBrief(Boolean.TRUE);
        obj.getSubscriptions().get(0).getSubscriptionFilter().setFindBusiness(new FindBusiness());
        obj.getSubscriptions().get(0).getSubscriptionFilter().getFindBusiness().getName()
                .add(new Name(UDDIConstants.WILDCARD, null));
        obj.getSubscriptions().get(0).getSubscriptionFilter().getFindBusiness()
                .setFindQualifiers(new FindQualifiers());
        obj.getSubscriptions().get(0).getSubscriptionFilter().getFindBusiness().getFindQualifiers()
                .getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
        obj.getSubscriptions().get(0).getSubscriptionFilter().getFindBusiness().getFindQualifiers()
                .getFindQualifier().add(UDDIConstants.CASE_INSENSITIVE_MATCH);
        //obj.getSubscriptions().get(0).getSubscriptionFilter().getFindBusiness()
        JAXB.marshal(obj, sw);
    }

    if (method.equalsIgnoreCase("set_ReplicationNodes")) {
        ReplicationConfiguration replicationConfiguration = new ReplicationConfiguration();
        replicationConfiguration.setCommunicationGraph(new CommunicationGraph());
        String thisnode = "NODEID";
        try {
            thisnode = AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID);
        } catch (ConfigurationException ex) {
            Logger.getLogger(JUDDIRequestsAsXML.class.getName()).log(Level.SEVERE, null, ex);
        }

        replicationConfiguration.getCommunicationGraph().getNode().add(thisnode);
        Operator op = new Operator();
        op.setOperatorNodeID(thisnode);

        op.setOperatorStatus(OperatorStatusType.NORMAL);
        String url = "http://localhost:8080/juddiv3/services/replication";
        try {
            url = AppConfig.getConfiguration().getString(Property.DEFAULT_BASE_URL_SECURE)
                    + "/services/replication";
        } catch (ConfigurationException ex) {
            Logger.getLogger(JUDDIRequestsAsXML.class.getName()).log(Level.SEVERE, null, ex);
        }
        op.setSoapReplicationURL(url);

        replicationConfiguration.getOperator().add(op);
        replicationConfiguration.setRegistryContact(new ReplicationConfiguration.RegistryContact());
        replicationConfiguration.getRegistryContact().setContact(new Contact());
        replicationConfiguration.getRegistryContact().getContact().getPersonName()
                .add(new PersonName("UNKNOWN", "en"));

        JAXB.marshal(replicationConfiguration, sw);
    }

    return PrettyPrintXML(sw.toString());
}

From source file:org.apache.juddi.api.impl.UDDICustodyTransferImpl.java

public void getTransferToken(String authInfo, KeyBag keyBag, Holder<String> nodeID,
        Holder<XMLGregorianCalendar> expirationTime, Holder<byte[]> opaqueToken)
        throws DispositionReportFaultMessage {
    long startTime = System.currentTimeMillis();

    EntityManager em = PersistenceManager.getEntityManager();
    EntityTransaction tx = em.getTransaction();
    try {// www  .  j  a va2s.  co  m
        tx.begin();

        UddiEntityPublisher publisher = this.getEntityPublisher(em, authInfo);

        new ValidateCustodyTransfer(publisher).validateGetTransferToken(em, keyBag);

        int transferExpirationDays = DEFAULT_TRANSFEREXPIRATION_DAYS;
        try {
            transferExpirationDays = AppConfig.getConfiguration()
                    .getInt(Property.JUDDI_TRANSFER_EXPIRATION_DAYS);
            // For output
            nodeID.value = AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID);
        } catch (ConfigurationException ce) {
            throw new FatalErrorException(new ErrorMessage("errors.configuration.Retrieval"));
        }

        String transferKey = TRANSFER_TOKEN_PREFIX + UUID.randomUUID();
        org.apache.juddi.model.TransferToken transferToken = new org.apache.juddi.model.TransferToken();
        transferToken.setTransferToken(transferKey);
        // For output
        opaqueToken.value = transferKey.getBytes();

        GregorianCalendar gc = new GregorianCalendar();
        gc.add(GregorianCalendar.DAY_OF_MONTH, transferExpirationDays);

        transferToken.setExpirationDate(gc.getTime());

        try {
            DatatypeFactory df = DatatypeFactory.newInstance();
            // For output
            expirationTime.value = df.newXMLGregorianCalendar(gc);
        } catch (DatatypeConfigurationException ce) {
            throw new FatalErrorException(new ErrorMessage("errors.Unspecified"));
        }

        List<String> keyList = keyBag.getKey();
        for (String key : keyList) {
            TransferTokenKey tokenKey = new TransferTokenKey(transferToken, key);
            transferToken.getTransferKeys().add(tokenKey);
        }

        em.persist(transferToken);

        tx.commit();

        long procTime = System.currentTimeMillis() - startTime;
        serviceCounter.update(CustodyTransferQuery.GET_TRANSFERTOKEN, QueryStatus.SUCCESS, procTime);

    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        em.close();
    }
}

From source file:org.apache.juddi.api.impl.UDDISubscriptionImpl.java

/**
 * Will add the expiration date to the provided subscription request.  Date is earlier of user provided date and the system default
 * /*from   w w  w. j  a v  a 2 s .c  o  m*/
 * @param apiSubscription
 * @throws DispositionReportFaultMessage
 */
private void doSubscriptionExpirationDate(org.uddi.sub_v3.Subscription apiSubscription)
        throws DispositionReportFaultMessage {

    int subscriptionExpirationDays = DEFAULT_SUBSCRIPTIONEXPIRATION_DAYS;
    try {
        subscriptionExpirationDays = AppConfig.getConfiguration()
                .getInt(Property.JUDDI_SUBSCRIPTION_EXPIRATION_DAYS);
    } catch (ConfigurationException ce) {
        throw new FatalErrorException(new ErrorMessage("errors.configuration.Retrieval"));
    }

    GregorianCalendar expirationDate = new GregorianCalendar();
    expirationDate.add(GregorianCalendar.DAY_OF_MONTH, subscriptionExpirationDays);

    // The expiration date is the earlier of the provided date and that specified by the parameter.
    if (apiSubscription.getExpiresAfter() != null) {
        GregorianCalendar userExpiration = apiSubscription.getExpiresAfter().toGregorianCalendar();
        if (userExpiration.getTimeInMillis() < expirationDate.getTimeInMillis())
            expirationDate.setTimeInMillis(userExpiration.getTimeInMillis());
    }

    try {
        DatatypeFactory df = DatatypeFactory.newInstance();
        apiSubscription.setExpiresAfter(df.newXMLGregorianCalendar(expirationDate));
    } catch (DatatypeConfigurationException ce) {
        throw new FatalErrorException(new ErrorMessage("errors.Unspecified"));
    }

}

From source file:org.apache.juddi.mapping.MappingModelToApi.java

public static void mapClientSubscriptionInfo(
        org.apache.juddi.model.ClientSubscriptionInfo modelClientSubscriptionInfo,
        org.apache.juddi.api_v3.ClientSubscriptionInfo apiClientSubscriptionInfo)
        throws DispositionReportFaultMessage {

    apiClientSubscriptionInfo.setSubscriptionKey(modelClientSubscriptionInfo.getSubscriptionKey());
    GregorianCalendar gcal = new GregorianCalendar();
    gcal.setTimeInMillis(modelClientSubscriptionInfo.getLastNotified().getTime());
    try {//www  .j a  va  2 s.  co  m
        apiClientSubscriptionInfo.setLastModified(DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal));
    } catch (DatatypeConfigurationException ex) {
        logger.warn("unable to create DatatypeFactory", ex);
    }

    if (modelClientSubscriptionInfo.getFromClerk() != null) {
        org.apache.juddi.api_v3.Clerk apiFromClerk = new org.apache.juddi.api_v3.Clerk();
        mapClerk(modelClientSubscriptionInfo.getFromClerk(), apiFromClerk);
        apiClientSubscriptionInfo.setFromClerk(apiFromClerk);
    }
    if (modelClientSubscriptionInfo.getToClerk() != null) {
        org.apache.juddi.api_v3.Clerk apiToClerk = new org.apache.juddi.api_v3.Clerk();
        mapClerk(modelClientSubscriptionInfo.getToClerk(), apiToClerk);
        apiClientSubscriptionInfo.setToClerk(apiToClerk);
    }
}

From source file:org.apache.juddi.samples.UddiCustodyTransfer.java

public void TransferBusiness(String fromUser, String fromUserAuthToken, String toUser, String toUserAuthToken,
        String BusinessKey) throws Exception {

    System.out.println("Transfering business key " + BusinessKey);
    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gcal = new GregorianCalendar();
    gcal.setTimeInMillis(System.currentTimeMillis());
    XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal);

    //Create a transfer token from fromUser to toUser
    KeyBag kb = new KeyBag();
    kb.getKey().add(BusinessKey);//  w w  w.  j  a  v  a2  s  . co m
    Holder<String> nodeidOUT = new Holder<String>();
    Holder<XMLGregorianCalendar> expiresOUT = new Holder<XMLGregorianCalendar>();
    Holder<byte[]> tokenOUT = new Holder<byte[]>();
    custodyTransferPortType.getTransferToken(fromUserAuthToken, kb, nodeidOUT, expiresOUT, tokenOUT);

    System.out.println("Transfer token obtained. Give this to user " + toUser);
    System.out.println("Expires " + expiresOUT.value.toXMLFormat());
    System.out.println("Node " + nodeidOUT.value);
    System.out.println("Token " + org.apache.commons.codec.binary.Base64.encodeBase64String(tokenOUT.value));

    if (toUser == null || toUser.length() == 0 || toUserAuthToken == null || toUserAuthToken.length() == 0) {
        System.out
                .println("The toUser parameters are either null or empty, I can't complete the transfer here");
        return;
    }

    //The magic part happens here, the user ROOT needs to give the user UDDI the token information out of band
    //in practice, all values must match exactly
    //UDDI now accepts the transfer
    TransferEntities te = new TransferEntities();
    te.setAuthInfo(toUserAuthToken);
    te.setKeyBag(kb);
    TransferToken tt = new TransferToken();
    tt.setExpirationTime(expiresOUT.value);
    tt.setNodeID(nodeidOUT.value);
    tt.setOpaqueToken(tokenOUT.value);
    te.setTransferToken(tt);
    System.out.println("Excuting transfer...");
    custodyTransferPortType.transferEntities(te);
    System.out.println("Complete! verifing ownership change...");

    //confirm the transfer
    GetOperationalInfo go = new GetOperationalInfo();
    go.setAuthInfo(fromUserAuthToken);
    go.getEntityKey().add(BusinessKey);
    OperationalInfos operationalInfo = uddiInquiryService.getOperationalInfo(go);
    boolean ok = false;
    boolean found = false;
    for (int i = 0; i < operationalInfo.getOperationalInfo().size(); i++) {
        if (operationalInfo.getOperationalInfo().get(i).getEntityKey().equalsIgnoreCase(BusinessKey)) {
            found = true;
            if (operationalInfo.getOperationalInfo().get(i).getAuthorizedName().equalsIgnoreCase(fromUser)) {
                System.out.println("Transfer unexpected failed");
            }
            if (operationalInfo.getOperationalInfo().get(i).getAuthorizedName().equalsIgnoreCase(toUser)) {
                ok = true;
            }

        }
    }
    if (!found) {
        System.out.println("Could get the operational info the transfed business");
    }
    System.out.println("Transfer " + (ok ? "success" : " failed"));
}

From source file:org.apache.juddi.subscription.SubscriptionNotifier.java

protected GetSubscriptionResults buildGetSubscriptionResults(Subscription subscription, Date endPoint)
        throws DispositionReportFaultMessage, DatatypeConfigurationException {

    GetSubscriptionResults getSubscriptionResults = null;
    Duration duration = TypeConvertor.convertStringToDuration(subscription.getNotificationInterval());
    Date startPoint = subscription.getLastNotified();
    Date nextDesiredNotificationDate = null;
    if (startPoint == null)
        startPoint = subscription.getCreateDate();
    nextDesiredNotificationDate = new Date(startPoint.getTime());
    duration.addTo(nextDesiredNotificationDate);
    //nextDesiredNotificationDate = lastTime + the Interval Duration, which should be:
    //AFTER the lastNotified time and BEFORE the endTime (current time). If it is
    //after the endTime, then the user does not want a notification yet, so we accumulate.
    if (subscription.getLastNotified() == null
            || nextDesiredNotificationDate.after(startPoint) && nextDesiredNotificationDate.before(endPoint)) {
        getSubscriptionResults = new GetSubscriptionResults();
        CoveragePeriod period = new CoveragePeriod();
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTimeInMillis(startPoint.getTime());
        period.setStartPoint(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
        calendar.setTimeInMillis(endPoint.getTime());
        period.setEndPoint(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
        if (log.isDebugEnabled())
            log.debug("Period " + period.getStartPoint() + " " + period.getEndPoint());
        getSubscriptionResults.setCoveragePeriod(period);
    } else {//from  ww  w .  ja  va2 s.  com
        log.debug("Client does not yet want a notification. The next desidered notification Date "
                + nextDesiredNotificationDate + ". The current interval [" + startPoint + " , " + endPoint
                + "] therefore skipping this notification cycle.");
        if (desiredDate == null || nextDesiredNotificationDate.getTime() < desiredDate.getTime()) {
            desiredDate = nextDesiredNotificationDate;
        }
    }
    return getSubscriptionResults;

}

From source file:org.apache.juddi.v3.client.mapping.UDDIServiceCache.java

/**
 * Create a subscription for changes in any Service in the Registry
 * @throws DatatypeConfigurationException 
 * @param bindingKey the binding key/* w  w  w . ja v a2 s . c o m*/
 */
public void registerSubscription(String bindingKey) throws DatatypeConfigurationException {

    String subscriptionKey = UDDIKeyConvention.getSubscriptionKey(properties);
    //Create a subscription for changes in any Service in the Registry
    FindService findAllServices = new FindService();
    FindQualifiers qualifiers = new FindQualifiers();
    qualifiers.getFindQualifier().add("approximateMatch");

    findAllServices.setFindQualifiers(qualifiers);

    Name name = new Name();
    name.setValue("%");
    findAllServices.getName().add(name);

    SubscriptionFilter filter = new SubscriptionFilter();
    filter.setFindService(findAllServices);

    Subscription subscription = new Subscription();
    subscription.setSubscriptionFilter(filter);
    subscription.setBindingKey(bindingKey);
    subscription.setBrief(true);
    Duration oneMinute = DatatypeFactory.newInstance().newDuration("PT1M");
    subscription.setNotificationInterval(oneMinute);
    subscription.setSubscriptionKey(subscriptionKey);
    clerk.register(subscription);
    this.subscriptionKey = subscriptionKey;
}

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

@Test
public void SubscriptionCallbackTest1() throws Exception {
    //first some setup
    Assume.assumeTrue(TckPublisher.isEnabled());
    reset();//from   w  ww .  j a  v  a2  s .c o m

    TModel createKeyGenator = UDDIClerk.createKeyGenator("somebusiness",
            "A test key domain SubscriptionCallbackTest1", "SubscriptionCallbackTest1");
    Assert.assertNotNull(createKeyGenator);
    clerk.register(createKeyGenator);
    logger.info("Registered tModel keygen: " + createKeyGenator.getTModelKey());

    //setup the business to attach to
    BusinessEntity be = new BusinessEntity();
    be.setBusinessKey("uddi:somebusiness:somebusinesskey");
    be.getName().add(new Name("somebusiness SubscriptionCallbackTest1", null));
    be.setBusinessServices(new BusinessServices());
    BusinessService bs = new BusinessService();
    bs.setBusinessKey("uddi:somebusiness:somebusinesskey");
    bs.setServiceKey("uddi:somebusiness:someservicekey");
    bs.getName().add(new Name("service SubscriptionCallbackTest1", null));
    be.getBusinessServices().getBusinessService().add(bs);
    BusinessEntity register = clerk.register(be);
    logger.info("Registered business keygen: " + register.getBusinessKey());

    //start up our listener
    BindingTemplate start = SubscriptionCallbackListener.start(manager, "uddiv3");
    Assert.assertNotNull(start);

    if (TckCommon.isDebug()) {
        PrintUDDI<BindingTemplate> p = new PrintUDDI<BindingTemplate>();
        logger.info(p.print(start));
    }

    //register for callbacks
    SubscriptionCallbackListener.registerCallback(this);

    Subscription sub = new Subscription();

    sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(1000));
    sub.setBindingKey(start.getBindingKey());
    sub.setSubscriptionFilter(new SubscriptionFilter());
    sub.getSubscriptionFilter().setFindBusiness(new FindBusiness());
    sub.getSubscriptionFilter().getFindBusiness().setFindQualifiers(new FindQualifiers());
    sub.getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier()
            .add(UDDIConstants.APPROXIMATE_MATCH);
    sub.getSubscriptionFilter().getFindBusiness().getName().add(new Name(UDDIConstants.WILDCARD, null));

    Subscription subscription = clerk.register(sub);
    if (TckCommon.isDebug()) {
        PrintUDDI<Subscription> p2 = new PrintUDDI<Subscription>();
        logger.info(p2.print(subscription));
    }
    Assert.assertNotNull(subscription);
    Assert.assertNotNull(subscription.getBindingKey());
    Assert.assertNotNull(subscription.getSubscriptionKey());
    logger.info("Registered subscription key: " + (subscription.getSubscriptionKey()) + " bindingkey: "
            + subscription.getBindingKey());

    //fetch the business just to verify binding registration
    BusinessEntity businessDetail = clerk.getBusinessDetail("uddi:somebusiness:somebusinesskey");
    Assert.assertNotNull(businessDetail);
    Assert.assertNotNull(businessDetail.getBusinessKey());
    Assert.assertNotNull(businessDetail.getBusinessServices());
    Assert.assertNotNull(businessDetail.getBusinessServices().getBusinessService().get(0));
    Assert.assertNotNull(
            businessDetail.getBusinessServices().getBusinessService().get(0).getBindingTemplates());
    Assert.assertNotNull(businessDetail.getBusinessServices().getBusinessService().get(0).getBindingTemplates()
            .getBindingTemplate().get(0));
    if (TckCommon.isDebug()) {
        PrintUDDI<BusinessEntity> p2 = new PrintUDDI<BusinessEntity>();
        logger.info(p2.print(businessDetail));
    }

    //trigger the callback
    BusinessEntity trigger = new BusinessEntity();
    trigger.getName().add(new Name("somebusiness trigger SubscriptionCallbackTest1", null));
    BusinessEntity triggered = clerk.register(trigger);
    //wait up to 30 seconds or until we get something
    long wait = TckPublisher.getSubscriptionTimeout();
    while (wait > 0 && notifications == 0) {
        Thread.sleep(1000);
        System.out.print(".");
        wait--;
    }

    logger.info("Callback check." + notifications);
    //Thread.sleep(2000);
    SubscriptionCallbackListener.stop(manager, "uddiv3", start.getBindingKey());
    clerk.unRegisterSubscription(subscription.getSubscriptionKey());
    clerk.unRegisterTModel(createKeyGenator.getTModelKey());

    clerk.unRegisterBusiness(triggered.getBusinessKey());
    clerk.unRegisterBusiness(businessDetail.getBusinessKey());
    //verify
    logger.info("Callback check." + notifications);
    Assert.assertTrue("No notifications received! " + notifications, notifications > 0);

}

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

/**
 * invalid expiration time/*from  w w  w  .j a va  2  s .  c om*/
 *
 * @throws DatatypeConfigurationException
 */
@Test
public void JUDDI_606_2() throws DatatypeConfigurationException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_2");
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());
    // invalid expiration time
    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gcal = new GregorianCalendar();
    gcal.setTimeInMillis(System.currentTimeMillis());
    gcal.add(Calendar.DATE, -1);
    XMLGregorianCalendar newXMLGregorianCalendar = df.newXMLGregorianCalendar(gcal);

    Subscription sub = new Subscription();
    Holder<List<Subscription>> data = new Holder<List<Subscription>>();
    data.value = new ArrayList<Subscription>();
    sub.setBrief(true);
    sub.setExpiresAfter(newXMLGregorianCalendar);
    sub.setMaxEntities(1);
    sub.setNotificationInterval(null);
    sub.setBindingKey(null);
    sub.setSubscriptionFilter(new SubscriptionFilter());
    sub.getSubscriptionFilter().setFindService(new FindService());
    sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
    sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier()
            .add(UDDIConstants.APPROXIMATE_MATCH);
    sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null));
    data.value.add(sub);
    try {
        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.fail();
    } catch (Exception ex) {
        //HandleException(ex);
        logger.info("Expected exception: " + ex.getMessage());
    }
}

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

/**
 * more filters that expected/*  w ww.ja  v a 2  s  .c  o m*/
 *
 * @throws DatatypeConfigurationException
 */
@Test
public void JUDDI_606_7() throws DatatypeConfigurationException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_7");
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());
    //
    DatatypeFactory df = DatatypeFactory.newInstance();
    try {

        Holder<List<Subscription>> data = new Holder<List<Subscription>>();
        data.value = new ArrayList<Subscription>();
        Subscription sub = new Subscription();
        sub.setBrief(false);
        sub.setExpiresAfter(null);
        sub.setMaxEntities(null);
        sub.setNotificationInterval(null);
        sub.setBindingKey(null);
        sub.setSubscriptionFilter(new SubscriptionFilter());
        sub.getSubscriptionFilter().setFindBusiness(new FindBusiness());
        sub.getSubscriptionFilter().getFindBusiness().setFindQualifiers(new FindQualifiers());
        sub.getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier()
                .add(UDDIConstants.APPROXIMATE_MATCH);
        sub.getSubscriptionFilter().getFindBusiness().getName().add(new Name("%", null));
        sub.getSubscriptionFilter().setFindService(new FindService());
        sub.getSubscriptionFilter().getFindService().setFindQualifiers(new FindQualifiers());
        sub.getSubscriptionFilter().getFindService().getFindQualifiers().getFindQualifier()
                .add(UDDIConstants.APPROXIMATE_MATCH);
        sub.getSubscriptionFilter().getFindService().getName().add(new Name("%", null));

        data.value.add(sub);

        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        Assert.fail();
    } catch (Exception ex) {
        logger.info(ex.getMessage());

    }
}