Example usage for java.util GregorianCalendar setTimeInMillis

List of usage examples for java.util GregorianCalendar setTimeInMillis

Introduction

In this page you can find the example usage for java.util GregorianCalendar setTimeInMillis.

Prototype

public void setTimeInMillis(long millis) 

Source Link

Document

Sets this Calendar's current time from the given long value.

Usage

From source file:org.sakaiproject.sdata.tool.JCRHandler.java

@Override
public void doPut(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {// w  w  w. j  a va2 s.  co m
        snoopRequest(request);

        ResourceDefinition rp = resourceDefinitionFactory.getSpec(request);
        String mimeType = ContentTypes.getContentType(rp.getRepositoryPath(), request.getContentType());
        String charEncoding = null;
        if (mimeType.startsWith("text")) {
            charEncoding = request.getCharacterEncoding();
        }
        Node n = jcrNodeFactory.getNode(rp.getRepositoryPath());
        boolean created = false;
        if (n == null) {
            n = jcrNodeFactory.createFile(rp.getRepositoryPath(), mimeType);
            created = true;
            if (n == null) {
                throw new RuntimeException(
                        "Failed to create node at " + rp.getRepositoryPath() + " type " + JCRConstants.NT_FILE);
            }
        } else {
            NodeType nt = n.getPrimaryNodeType();
            if (!JCRConstants.NT_FILE.equals(nt.getName())) {
                response.reset();
                response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                        "Content Can only be put to a file, resource type is " + nt.getName());
                return;
            }
        }

        GregorianCalendar gc = new GregorianCalendar();
        long lastMod = request.getDateHeader(LAST_MODIFIED);
        if (lastMod > 0) {
            gc.setTimeInMillis(lastMod);
        } else {
            gc.setTime(new Date());
        }

        InputStream in = request.getInputStream();
        saveStream(n, in, mimeType, charEncoding, gc);

        in.close();
        if (created) {
            response.setStatus(HttpServletResponse.SC_CREATED);
        } else {
            response.setStatus(HttpServletResponse.SC_NO_CONTENT);
        }
    } catch (UnauthorizedException ape) {
        // catch any Unauthorized exceptions and send a 401
        response.reset();
        response.sendError(HttpServletResponse.SC_UNAUTHORIZED, ape.getMessage());
    } catch (PermissionDeniedException pde) {
        // catch any permission denied exceptions, and send a 403
        response.reset();
        response.sendError(HttpServletResponse.SC_FORBIDDEN, pde.getMessage());
    } catch (SDataException e) {
        sendError(request, response, e);
        LOG.error("Failed  To service Request " + e.getMessage());
    } catch (Exception e) {
        sendError(request, response, e);
        snoopRequest(request);
        LOG.error("Failed  TO service Request ", e);
    }
}

From source file:org.betaconceptframework.astroboa.engine.jcr.io.SerializationBean.java

private String generateXMLRepresentationOfCalendar(Calendar calendar) {

    if (calendar == null) {
        calendar = Calendar.getInstance();
    }//from   w w  w . j av a  2  s.com

    try {
        DatatypeFactory df = DatatypeFactory.newInstance();
        GregorianCalendar gregCalendar = new GregorianCalendar(calendar.getTimeZone());
        gregCalendar.setTimeInMillis(calendar.getTimeInMillis());

        return df.newXMLGregorianCalendar(gregCalendar).toXMLFormat();

    } catch (DatatypeConfigurationException e) {
        return null;
    }

}

From source file:stg.utils.immutable.Day.java

/**
 * Constructs a specific date from the time.
 * //from  ww  w  . j  av  a 2 s. co m
 * @param time
 *            long
 * @exception IllegalArgumentException
 *                if not a valid date
 * @see System#currentTimeMillis()
 */

private Day(long time, TimeZone zone) {
    GregorianCalendar calendar = getCalendarInstance(zone);
    calendar.setTimeInMillis(time);
    tzone = zone;
    year = calendar.get(Calendar.YEAR);
    month = calendar.get(Calendar.MONTH) + 1;
    day = calendar.get(Calendar.DATE);
    hour = calendar.get(Calendar.HOUR_OF_DAY);
    minutes = calendar.get(Calendar.MINUTE);
    seconds = calendar.get(Calendar.SECOND);
    milliseconds = calendar.get(Calendar.MILLISECOND);
}

From source file:org.eevolution.form.VCRP.java

public CategoryDataset createWeightDataset(Timestamp start, MResource r) {

    GregorianCalendar gc1 = new GregorianCalendar();
    gc1.setTimeInMillis(start.getTime());
    gc1.clear(Calendar.MILLISECOND);
    gc1.clear(Calendar.SECOND);//from   ww  w . ja  v  a  2 s .c o  m
    gc1.clear(Calendar.MINUTE);
    gc1.clear(Calendar.HOUR_OF_DAY);

    String namecapacity = Msg.translate(Env.getCtx(), "Capacity");
    String nameload = Msg.translate(Env.getCtx(), "Load");
    String namesummary = Msg.translate(Env.getCtx(), "Summary");
    String namepossiblecapacity = "Possible Capacity";

    MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null);

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    double currentweight = DB.getSQLValue(null,
            "Select SUM( (mo.qtyordered-mo.qtydelivered)*(Select mp.weight From m_product mp Where mo.m_product_id=mp.m_product_id )  )From mpc_order mo Where ad_client_id=?",
            r.getAD_Client_ID());
    // fjviejo e-evolution machineqty capacidad por el numero de maquinas
    // double dailyCapacity = DB.getSQLValue(null,"Select dailycapacity From s_resource Where s_resource_id=?",r.getS_Resource_ID());
    double dailyCapacity = DB.getSQLValue(null,
            "Select dailycapacity*MachineQty From s_resource Where s_resource_id=?", r.getS_Resource_ID());
    System.out.println("***** Capacidad diaria " + dailyCapacity);
    // e-evolution end
    double utilization = DB.getSQLValue(null,
            "Select percentutillization From s_resource Where s_resource_id=?", r.getS_Resource_ID());

    double summary = 0;

    int day = 0;

    /*
     *     Vit4B Modificado para que tome 28 dias y
     *
     *
     */

    while (day < 29) {

        day++;

        switch (gc1.get(Calendar.DAY_OF_WEEK)) {

        case Calendar.SUNDAY:

            if (t.isOnSunday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.MONDAY:

            if (t.isOnMonday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.TUESDAY:

            if (t.isOnTuesday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.WEDNESDAY:

            if (t.isOnWednesday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.THURSDAY:

            if (t.isOnThursday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.FRIDAY:

            if (t.isOnFriday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.SATURDAY:

            if (t.isOnSaturday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;
        }

        dataset.addValue(currentweight, nameload, new Integer(day));
        dataset.addValue(summary, namesummary, new Integer(day));

        gc1.add(Calendar.DATE, 1);
    }

    return dataset;
}

From source file:org.oscarehr.common.model.Demographic.java

public GregorianCalendar getBirthDay() {
    GregorianCalendar cal = null;

    if (dateOfBirth != null && monthOfBirth != null && yearOfBirth != null) {
        cal = new GregorianCalendar();
        cal.setTimeInMillis(0);
        cal.set(Integer.parseInt(yearOfBirth), Integer.parseInt(monthOfBirth) - 1,
                Integer.parseInt(dateOfBirth));

        // force materialisation of data
        cal.getTimeInMillis();//from   w  w  w.ja v  a 2 s  . c  o  m
    }

    return (cal);
}

From source file:org.eevolution.form.VSCRP.java

public CategoryDataset createDataset(Timestamp start, MResource r) {
    //System.out.println("Create new data set");
    GregorianCalendar gc1 = new GregorianCalendar();
    gc1.setTimeInMillis(start.getTime());
    gc1.clear(Calendar.MILLISECOND);
    gc1.clear(Calendar.SECOND);/*from www.  j  a v a2s . co m*/
    gc1.clear(Calendar.MINUTE);
    gc1.clear(Calendar.HOUR_OF_DAY);

    Timestamp date = start;
    String namecapacity = Msg.translate(Env.getCtx(), "Capacity");
    System.out.println("\n Namecapacity :" + namecapacity);
    String nameload = Msg.translate(Env.getCtx(), "Load");
    System.out.println("\n Nameload :" + nameload);
    String namesummary = Msg.translate(Env.getCtx(), "Summary");
    System.out.println("\n Namesummary :" + namesummary);
    MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null);
    System.out.println("\n Resourcetype " + t);
    int days = 1;
    long hours = 0;

    if (t.isTimeSlot()) {

        hours = MMPCMRP.getHoursAvailable(t.getTimeSlotStart(), t.getTimeSlotEnd());

    } else {
        //fjviejo e-evolution MachineQty
        if (r.getDailyCapacity().multiply(r.getMachineQty()).compareTo(Env.ZERO) != 0)
            hours = r.getDailyCapacity().multiply(r.getMachineQty()).longValue();
        else
            //fjviejo e-evolution end
            hours = 24;
    }
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    //      Long Hours = new Long(hours);                            
    int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ",
            r.getS_Resource_ID());
    MUOM uom = new MUOM(Env.getCtx(), C_UOM_ID, null);
    System.out.println("\n uom1 " + uom + "\n");
    //System.out.println("um.isHour()"+ uom.isHour() );
    if (!uom.isHour()) {
        System.out.println("\n uom2 " + uom + "\n");
        return dataset;
    }
    System.out.println("\n Dataset " + dataset + "\n");
    int summary = 0;
    int secondsAcum = 0;
    long hoursAcum = 0;

    while (days < 29) {
        //System.out.println("Day Number" + days);
        String day = new String(new Integer(date.getDate()).toString());
        System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID());
        System.out.println("Date:" + date);
        int seconds = getLoad(r.getS_Resource_ID(), date, date);
        Long Hours = new Long(hours);
        System.out.println("Summary " + summary);
        System.out.println("Capacity " + hours);
        System.out.println("Load " + seconds);

        /*
        **  Realizo la verificacin sobre que da me encuentro
        **  para graficar cada 7 dias el estado de la semana.
        **
        **  secondsAcum y hoursAcum llevan los acumulados para la semana
        **  los reinicio en cada nueva semana.
        **
        **  VIT4B - 07/12/2006
        */

        if (days == 1 || days == 8 || days == 15 || days == 22) {
            secondsAcum = 0;
            hoursAcum = 0;
        }

        secondsAcum += seconds;
        hoursAcum += hours;

        switch (gc1.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.SUNDAY:
            if (t.isOnSunday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600); //+ (Hours.intValue() - ((seconds / 3600)));
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.MONDAY:
            if (t.isOnMonday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.TUESDAY:
            if (t.isOnTuesday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.WEDNESDAY:
            if (t.isOnWednesday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.THURSDAY:
            if (t.isOnThursday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.FRIDAY:
            if (t.isOnFriday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }
                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.SATURDAY:
            if (t.isOnSaturday()) {
                /*
                                                **  Realizo la verificacin sobre que da me encuentro
                                                **  para graficar cada 7 dias el estado de la semana.
                                                **
                                                **  VIT4B - 07/12/2006
                                                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }
                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        }

        days++;

    }
    return dataset;
}

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

/**
 * invalid expiration time//  w  w w .  j ava2  s.  co  m
 *
 * @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

/**
 * set subscription, make a change as the same user, get subscription
 * results no key specified//from  www  . j av  a 2  s. c o m
 *
 * @throws DatatypeConfigurationException
 */
@Test
public void JUDDI_606_11() throws DatatypeConfigurationException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_11");
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());

    String key = null;
    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));
        data.value.add(sub);

        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        SaveBusiness sb = new SaveBusiness();
        sb.setAuthInfo(authInfoJoe);
        BusinessEntity be = new BusinessEntity();
        be.getName().add(new Name("Test business", null));
        sb.getBusinessEntity().add(be);
        BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);

        key = saveBusiness.getBusinessEntity().get(0).getBusinessKey();

        GetSubscriptionResults gsr = new GetSubscriptionResults();
        gsr.setAuthInfo(authInfoJoe);
        gsr.setSubscriptionKey(null);
        gsr.setCoveragePeriod(new CoveragePeriod());
        GregorianCalendar gcal = new GregorianCalendar();
        gcal.setTimeInMillis(System.currentTimeMillis());
        gcal.add(Calendar.HOUR, -1);
        gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal));
        gcal = new GregorianCalendar();
        gcal.setTimeInMillis(System.currentTimeMillis());
        gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal));
        tckSubscriptionJoe.subscription.getSubscriptionResults(gsr);
        Assert.fail();
    } catch (Exception ex) {
        //HandleException(ex);
        //Assert.fail();
        logger.info("Expected exception: " + ex.getMessage());
    } finally {
        TckCommon.DeleteBusiness(key, authInfoJoe, publicationJoe);
    }
}

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

/**
 * set subscription, make a change as the same user, get subscription
 * results valid find_Business//from  ww  w .j  a  va  2s .c om
 *
 * @throws DatatypeConfigurationException
 */
@Test
public void JUDDI_606_13() throws DatatypeConfigurationException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_13");
    Assume.assumeTrue(TckPublisher.isSubscriptionEnabled());

    String key = null;
    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));
        data.value.add(sub);

        tckSubscriptionJoe.subscription.saveSubscription(authInfoJoe, data);
        SaveBusiness sb = new SaveBusiness();
        sb.setAuthInfo(authInfoJoe);
        BusinessEntity be = new BusinessEntity();
        be.getName().add(new Name("Test business", null));
        sb.getBusinessEntity().add(be);
        BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);
        key = saveBusiness.getBusinessEntity().get(0).getBusinessKey();

        GetSubscriptionResults gsr = new GetSubscriptionResults();
        gsr.setAuthInfo(authInfoJoe);
        gsr.setSubscriptionKey(data.value.get(0).getSubscriptionKey());
        gsr.setCoveragePeriod(new CoveragePeriod());
        GregorianCalendar gcal = new GregorianCalendar();
        gcal.setTimeInMillis(System.currentTimeMillis());
        gcal.add(Calendar.HOUR, -1);
        gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal));
        gcal = new GregorianCalendar();
        gcal.setTimeInMillis(System.currentTimeMillis());
        gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal));
        SubscriptionResultsList subscriptionResults = tckSubscriptionJoe.subscription
                .getSubscriptionResults(gsr);
        Assert.assertNotNull(subscriptionResults);
        Assert.assertNotNull(subscriptionResults.getBusinessList());
        Assert.assertNotNull(subscriptionResults.getCoveragePeriod());
        Assert.assertNotNull(subscriptionResults.getBusinessList().getBusinessInfos());
        Assert.assertNotNull(subscriptionResults.getBusinessList().getBusinessInfos().getBusinessInfo().get(0));
        Assert.assertNotNull(subscriptionResults.getBusinessList().getBusinessInfos().getBusinessInfo().get(0)
                .getBusinessKey());
        Assert.assertNotNull(subscriptionResults.getBusinessList().getBusinessInfos().getBusinessInfo().get(0)
                .getName().get(0));

    } catch (Exception ex) {
        HandleException(ex);
        Assert.fail();
    } finally {
        TckCommon.DeleteBusiness(key, authInfoJoe, publicationJoe);
    }
}

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

/**
 * set subscription, make a change as the same user, get subscription
 * results valid find_services/*w  w  w . j ava  2 s  .  co  m*/
 *
 * @throws DatatypeConfigurationException
 */
@Test
public void JUDDI_606_14() throws DatatypeConfigurationException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JUDDI_606_14");
    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().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);
        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
        /*SaveService sb = new SaveService();
         sb.setAuthInfo(authInfoJoe);
         BusinessService bs = new BusinessService();
         bs.getName().add(new Name("svc", null));
         sb.getBusinessService().add(bs);
         publicationJoe.saveService(sb);*/

        GetSubscriptionResults gsr = new GetSubscriptionResults();
        gsr.setAuthInfo(authInfoJoe);
        gsr.setSubscriptionKey(data.value.get(0).getSubscriptionKey());
        gsr.setCoveragePeriod(new CoveragePeriod());
        GregorianCalendar gcal = new GregorianCalendar();
        gcal.setTimeInMillis(System.currentTimeMillis());
        gcal.add(Calendar.HOUR, -1);
        gsr.getCoveragePeriod().setStartPoint(df.newXMLGregorianCalendar(gcal));
        gcal = new GregorianCalendar();
        gcal.setTimeInMillis(System.currentTimeMillis());
        gsr.getCoveragePeriod().setEndPoint(df.newXMLGregorianCalendar(gcal));
        SubscriptionResultsList subscriptionResults = tckSubscriptionJoe.subscription
                .getSubscriptionResults(gsr);
        Assert.assertNotNull(subscriptionResults);
        Assert.assertNull(subscriptionResults.getBusinessList());
        Assert.assertNotNull(subscriptionResults.getCoveragePeriod());
        Assert.assertNotNull(subscriptionResults.getServiceList());
        Assert.assertNotNull(subscriptionResults.getServiceList().getServiceInfos().getServiceInfo().get(0));
        Assert.assertNotNull(subscriptionResults.getServiceList().getServiceInfos().getServiceInfo().get(0)
                .getBusinessKey());
        Assert.assertNotNull(subscriptionResults.getServiceList().getServiceInfos().getServiceInfo().get(0)
                .getName().get(0));

    } catch (Exception ex) {
        HandleException(ex);
        Assert.fail(ex.getMessage());
    } finally {
        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
    }
}