Example usage for java.util Vector addElement

List of usage examples for java.util Vector addElement

Introduction

In this page you can find the example usage for java.util Vector addElement.

Prototype

public synchronized void addElement(E obj) 

Source Link

Document

Adds the specified component to the end of this vector, increasing its size by one.

Usage

From source file:com.netscape.cmscore.usrgrp.UGSubsystem.java

protected Enumeration<IUser> lbuildUsers(LDAPSearchResults res) throws EUsrGrpException {
    Vector<IUser> v = new Vector<IUser>();

    while (res.hasMoreElements()) {
        LDAPEntry entry = (LDAPEntry) res.nextElement();
        IUser user = lbuildUser(entry);//from   ww w  . ja  v  a  2  s  .co  m

        v.addElement(user);
    }
    return v.elements();
}

From source file:com.verisign.epp.codec.launch.EPPLaunchTst.java

/**
 * Tests the <code>EPPLaunchCreate</code> create command extension with use
 * of the code and mark in Sunrise Create Form. The tests include the
 * following:<br>//from  w ww.j  a  va2 s  .com
 * <br>
 * <ol>
 * <li>Test create signed mark in XML, sign it, validate it without
 * encode/decode
 * <li>Test create signed mark in Base64, sign it, validate it without
 * encode/decode
 * </ol>
 */
public void testLaunchCreateSignedMark() {

    EPPCodecTst.printStart("testLaunchCreateSignedMark");

    EPPDomainCreateCmd theCommand;
    EPPEncodeDecodeStats commandStats;

    theCommand = new EPPDomainCreateCmd("ABC-12345", "example.tld", new EPPAuthInfo("2fooBAR"));

    if (EPPFactory.getInstance().hasService(EPPDomainMapFactory.NS_CONTACT)) {
        theCommand.setRegistrant("jd1234");
        Vector contacts = new Vector();
        contacts.addElement(new EPPDomainContact("sh8013", EPPDomainContact.TYPE_ADMINISTRATIVE));
        contacts.addElement(new EPPDomainContact("sh8013", EPPDomainContact.TYPE_TECHNICAL));
        theCommand.setContacts(contacts);
    }

    // Test create command for sunrise create using just one signed mark

    // Mark Owner
    EPPMarkContact holder = new EPPMarkContact();
    holder.setEntitlement(EPPMarkContact.ENTITLEMENT_OWNER);
    holder.setOrg("Example Inc.");
    holder.setEmail("holder@example.tld");
    // Address
    EPPMarkAddress holderAddress = new EPPMarkAddress();
    holderAddress.addStreet("123 Example Dr.");
    holderAddress.addStreet("Suite 100");
    holderAddress.setCity("Reston");
    holderAddress.setSp("VA");
    holderAddress.setPc("20190");
    holderAddress.setCc("US");
    holder.setAddress(holderAddress);

    // Mark Contact
    EPPMarkContact contact = new EPPMarkContact();
    contact.setType(EPPMarkContact.TYPE_OWNER);
    contact.setName("John Doe");
    contact.setOrg("Example Inc."); // Address
    EPPMarkAddress contactAddress = new EPPMarkAddress();
    contactAddress.addStreet("123 Example Dr.");
    contactAddress.addStreet("Suite 100");
    contactAddress.setCity("Reston");
    contactAddress.setSp("VA");
    contactAddress.setPc("20166-6503");
    contactAddress.setCc("US");
    contact.setAddress(contactAddress);
    contact.setVoice("+1.7035555555");
    contact.setVoiceExt("1234");
    contact.setFax("+1.7035555556");
    contact.setEmail("jdoe@example.tld");

    // Trademark
    EPPTrademark trademark = new EPPTrademark();
    trademark.setId("1234-2");
    trademark.setName("Example One");
    trademark.addHolder(holder);
    trademark.addContact(contact);
    trademark.setJurisdiction("US");
    trademark.addClass("35");
    trademark.addClass("36");
    trademark.addLabel("example-one");
    trademark.addLabel("exampleone");
    trademark.setGoodsAndServices("Dirigendas et eiusmodi featuring infringo in airfare et cartam servicia.");
    trademark.setRegNum("234235");
    trademark.setRegDate(new GregorianCalendar(2009, 8, 16).getTime());
    trademark.setExDate(new GregorianCalendar(2015, 8, 16).getTime());

    // Treaty or Statute
    EPPTreatyOrStatute treatyOrStatute = new EPPTreatyOrStatute();
    treatyOrStatute.setId("1234-2");
    treatyOrStatute.setName("Example One");
    treatyOrStatute.addHolder(holder);
    treatyOrStatute.addContact(contact);
    treatyOrStatute.addProtection(new EPPProtection("US", "Reston", "US"));
    treatyOrStatute.addLabel("example-one");
    treatyOrStatute.addLabel("exampleone");
    treatyOrStatute
            .setGoodsAndServices("Dirigendas et eiusmodi featuring infringo in airfare et cartam servicia.");
    treatyOrStatute.setRefNum("234235");
    treatyOrStatute.setProDate(new GregorianCalendar(2009, 8, 16).getTime());
    treatyOrStatute.setTitle("Example Title");
    treatyOrStatute.setExecDate(new GregorianCalendar(2015, 8, 16).getTime());

    // Court
    EPPCourt court = new EPPCourt();
    court.setId("1234-2");
    court.setName("Example One");
    court.addHolder(holder);
    court.addContact(contact);
    court.addLabel("example-one");
    court.addLabel("exampleone");
    court.setGoodsAndServices("Dirigendas et eiusmodi featuring infringo in airfare et cartam servicia.");
    court.setRefNum("234235");
    court.setProDate(new GregorianCalendar(2009, 8, 16).getTime());
    court.setCc("US");
    court.addRegions("Reston");
    court.setCourtName("Test Court");

    // Mark
    EPPMark mark = new EPPMark();
    mark.addTrademark(trademark);
    mark.addTreatyOrStatute(treatyOrStatute);
    mark.addCourt(court);

    EPPIssuer issuer = new EPPIssuer("2", "Example Inc.", "support@example.tld");
    issuer.setUrl("http://www.example.tld");
    issuer.setVoice("+1.7035555555");
    issuer.setVoiceExt("1234");

    EPPSignedMark signedMark = null;

    // Sign the signed mark
    try {
        signedMark = new EPPSignedMark("1-123456", issuer, new GregorianCalendar(2012, 8, 16).getTime(),
                new GregorianCalendar(2013, 8, 16).getTime(), mark);

        signedMark.sign(privateKey, certChain);
    } catch (EPPException ex) {
        Assert.fail("Error signing the signed mark: " + ex);
    }

    if (!signedMark.validate(publicKey)) {
        Assert.fail("Signed mark validation error without encode/decode");
    }

    theCommand.setExtensions(null);
    theCommand.addExtension(new EPPLaunchCreate(new EPPLaunchPhase(EPPLaunchPhase.PHASE_SUNRISE), signedMark));

    commandStats = EPPCodecTst.testEncodeDecode(theCommand);
    System.out.println(commandStats);

    if (!signedMark.validate(pkixParameters)) {
        Assert.fail(
                "testLaunchCreateSignedMark(): XML signed mark signature is NOT valid after command encode/decode");
    }

    // Base64 encode the signed mark
    EPPEncodedSignedMark encodedSignedMark = null;
    try {
        encodedSignedMark = new EPPEncodedSignedMark(signedMark);
    } catch (EPPEncodeException e1) {
        Assert.fail("testLaunchCreateSignedMark(): Error creating EPPEncodedSignedMark from signed mark");
    } catch (EPPDecodeException e) {
        Assert.fail("testLaunchCreateSignedMark(): Error creating EPPEncodedSignedMark from signed mark");
    }

    commandStats = EPPCodecTst.testEncodeDecode(theCommand);
    System.out.println(commandStats);

    if (!signedMark.validate(pkixParameters)) {
        Assert.fail(
                "testLaunchCreateSignedMark(): encoded signed mark signature is NOT valid after command encode/decode");
    }

    EPPCodecTst.printEnd("testLaunchCreateSignedMark");
}

From source file:com.netscape.admin.certsrv.Console.java

/**
 * A helper method to find an SIE DN from its ID. See -s Console option.
 * Called by createPerInstanceUI().// w  ww  .j  a  v  a  2s. c  o  m
 */
private String serverIDtoDN(String id) {

    LDAPConnection ldc = _info.getLDAPConnection();
    Vector<String> instances = new Vector<>();

    try {
        LDAPSearchResults res = ldc.search("o=netscapeRoot", LDAPConnection.SCOPE_SUB,
                "(nsServerID=" + id + ")", new String[] { "dn" }, false);

        while (res.hasMoreElements()) {
            LDAPEntry hostEntry = res.next();
            instances.addElement(hostEntry.getDN());
        }

        if (instances.size() == 0) {
            System.err.println("Server instance " + id + " does not exist.");
            System.exit(0);
        } else if (instances.size() == 1) {
            id = instances.elementAt(0);
        } else {

            if (_splashScreen != null) {
                _splashScreen.setVisible(false);
            }

            int idx = -1;
            while (idx == -1) {
                System.out.println("\nThere are multiple instances of server \"" + id + "\":\n");
                for (int i = 0; i < instances.size(); i++) {
                    System.out.println((i + 1) + ") " + instances.elementAt(i));
                }
                System.out.print("\nPlease select an instance form the above list [1]: ");
                try {
                    String rsp = new BufferedReader(new InputStreamReader(System.in)).readLine();
                    if (rsp.length() == 0) {
                        idx = 1;
                    } else {
                        try {
                            idx = Integer.parseInt(rsp);
                        } catch (Exception ignore) {
                        }
                    }

                    if (idx >= 1 && idx <= instances.size()) {
                        idx = idx - 1;
                    } else {
                        idx = -1;
                    }
                } catch (Exception e) {
                    break;
                }
            }
            id = instances.elementAt(idx);
        }
    } catch (Exception e) {
        if (Debug.isEnabled()) {
            e.printStackTrace();
        }
    }
    return id;
}

From source file:alter.vitro.vgw.service.VitroGatewayService.java

public VgwResponse invokeWSIService(VgwRequestObservation request) throws VitroGatewayException {
    if (!getUseIdas()) {
        VgwResponse vgwResponse = new VgwResponse();
        vgwResponse.setSuccess(false);//from ww w  .  java 2 s.  c om
        return vgwResponse;
    }

    // REDUNDANT CODE FOR DEBUGGING PURPOSES (SKIPPING THE REGISTRATION). TODO: remove later (perhaps make  gwWithNodeDescriptorList a private var, although will that create any race conditions for it?)
    CGateway myGateway = new CGateway();
    myGateway.setId(getAssignedGatewayUniqueIdFromReg());
    myGateway.setName("");
    myGateway.setDescription("");

    // TODO: transfer the code for acquiring GW description, in the createWSIDescr() method
    CGatewayWithSmartDevices gwWithNodeDescriptorList = myDCon.createWSIDescr(myGateway);
    logger.debug("nodeDescriptorList = {}", gwWithNodeDescriptorList.getSmartDevVec());
    List<CSmartDevice> alterNodeDescriptorsList = gwWithNodeDescriptorList.getSmartDevVec();
    ResourceAvailabilityService.getInstance().updateCachedNodeList(alterNodeDescriptorsList,
            ResourceAvailabilityService.INIT_DISCOVERY);
    // END OF REDUNDANT CODE

    logger.debug("request = {}", request);

    //Get requested resource
    String resourceName = request.getObsType().value();
    Resource requestedResource = Resource.getResource(resourceName);
    if (requestedResource == null) {
        throw new VitroGatewayException(resourceName + " not managed by VITRO gateway");
    }

    //List<Observation> observationList = rsController.getWSIData(requestedResource);
    Vector<QueriedMoteAndSensors> motesAndTheirSensorAndFunctsVec = new Vector<QueriedMoteAndSensors>();
    Vector<ReqFunctionOverData> reqFunctionVec = new Vector<ReqFunctionOverData>();
    ReqFunctionType rftObject = new ReqFunctionType();
    rftObject.setId(BigInteger.valueOf(1));
    rftObject.setDescription(ReqFunctionOverData.lastValFunc);
    reqFunctionVec.add(new ReqFunctionOverData(rftObject));

    //List<CSmartDevice> alterNodeDescriptorsList = gwWithNodeDescriptorList.getSmartDevVec();
    for (CSmartDevice alterNodeDescriptor : alterNodeDescriptorsList) {
        QueriedMoteAndSensors tmpQueriedMoteAndSensors = new QueriedMoteAndSensors();
        tmpQueriedMoteAndSensors.setMoteid(alterNodeDescriptor.getId());

        Vector<ReqSensorAndFunctions> QueriedSensorIdsAndFuncVec = new Vector<ReqSensorAndFunctions>();
        ReqSensorAndFunctions tmpReqSensingAndFunct = new ReqSensorAndFunctions();

        Integer thedigestInt = request.getObsType().value().hashCode();
        if (thedigestInt < 0)
            thedigestInt = thedigestInt * (-1);

        tmpReqSensingAndFunct.setSensorModelid(Integer.toString(thedigestInt));
        tmpReqSensingAndFunct.getFid().add(BigInteger.valueOf(1));
        QueriedSensorIdsAndFuncVec.add(tmpReqSensingAndFunct);

        tmpQueriedMoteAndSensors.setQueriedSensorIdsAndFuncVec(QueriedSensorIdsAndFuncVec);

        motesAndTheirSensorAndFunctsVec.addElement(tmpQueriedMoteAndSensors);
    }

    Vector<ReqResultOverData> observationsList = myDCon.translateAggrQuery(motesAndTheirSensorAndFunctsVec,
            reqFunctionVec);

    if (observationsList != null && !observationsList.isEmpty()) {
        //            // we only have one function, so only one element in the observarionList
        //            ReqResultOverData observations = observationsList.elementAt(0);
        //            Vector<ResultAggrStruct> tmpResultsStructVec = observations.getAllResultsforFunct();

        for (ReqResultOverData observations : observationsList) {
            Vector<ResultAggrStruct> tmpResultsStructVec = observations.getAllResultsforFunct();
            if (tmpResultsStructVec != null && !tmpResultsStructVec.isEmpty()) {
                for (ResultAggrStruct resultStruct : tmpResultsStructVec) {
                    if (resultStruct.getVal().equalsIgnoreCase(ReqResultOverData.specialValueNoReading)
                            || resultStruct.getVal().equalsIgnoreCase(ReqResultOverData.specialValuePending)
                            || resultStruct.getVal()
                                    .equalsIgnoreCase(ReqResultOverData.specialValueNotSupported)
                            || resultStruct.getVal().equalsIgnoreCase(ReqResultOverData.specialValueBinary)
                            || resultStruct.getVal().equalsIgnoreCase(ReqResultOverData.specialValueTimedOut)) {
                        System.out.println("Special values should not be sent!!");
                        continue;
                    }
                    Observation vgwObservation = new Observation();
                    Node theNode = new Node();
                    theNode.setId(resultStruct.getMid());

                    vgwObservation.setNode(theNode);
                    vgwObservation.setResource(requestedResource);
                    // TODO PRODUCES ERROR!!!
                    //System.out.println("Error prone!!");
                    Timestamp tmpTs = resultStruct.getTis().getFromTimestamp();
                    if (tmpTs == null) {
                        java.util.Date today = new java.util.Date();
                        tmpTs = new java.sql.Timestamp(today.getTime());
                    }
                    //System.out.println("Error prone!!");

                    vgwObservation.setTimestamp(tmpTs.getTime());//????
                    vgwObservation.setValue(resultStruct.getVal());
                    //Node node = observation.getNode();
                    String assignedSensorId = idasNodeMapping.get(resultStruct.getMid());
                    logger.debug("Node {} -> assignedSensotId {}", resultStruct.getMid(), assignedSensorId);
                    InsertObservation insertObservation = sensorMLMessageAdapter.getInsertObservationMessage(
                            assignedGatewayUniqueIdFromReg, assignedSensorId, vgwObservation);
                    InsertObservationResponse insertObservationResponse = idas
                            .insertObservation(insertObservation);
                    logger.debug("insertObservationResponse = {}", insertObservationResponse);
                }
            }
        }
    }
    VgwResponse vgwResponse = new VgwResponse();
    vgwResponse.setSuccess(true);
    return vgwResponse;
}

From source file:com.duroty.application.chat.manager.ChatManager.java

/**
 * DOCUMENT ME!//w  ww . j a v a  2s. c o m
 *
 * @param hsession DOCUMENT ME!
 * @param username DOCUMENT ME!
 * @param away DOCUMENT ME!
 *
 * @throws ChatException DOCUMENT ME!
 */
public String ping(Session hsession, String username, int away) throws ChatException {
    try {
        Vector buddiesOnline = new Vector();
        Vector buddiesOffline = new Vector();
        Vector buddies = new Vector();
        Vector messages = new Vector();
        JSONObject json = new JSONObject();

        Users user = getUser(hsession, username);

        if (user.getUseIsOnline() >= 3) {
            user.setUseLastPing(new Date());
            hsession.update(user);
            hsession.flush();
        } else if (user.getUseLastState() > 0) {
            user.setUseIsOnline(user.getUseLastState());
            user.setUseLastPing(new Date());
            hsession.update(user);
            hsession.flush();
        } else {
            user.setUseIsOnline(0);
            user.setUseCustomMessage(null);
            user.setUseLastPing(new Date());
            hsession.update(user);
            hsession.flush();

            throw new NotLoggedInException();
        }

        json.put("state", user.getUseIsOnline());
        json.put("lastState", user.getUseLastState());
        json.put("awayMessage", user.getUseCustomMessage());

        Criteria crit2 = hsession.createCriteria(Conversations.class);
        crit2.add(Restrictions.eq("usersByConvRecipientIdint", user));

        ScrollableResults scroll2 = crit2.scroll();

        int numMessages = 0;

        while (scroll2.next()) {
            Conversations conversations = (Conversations) scroll2.get(0);
            messages.addElement(new ConversationsObj(conversations.getUsersByConvSenderIdint().getUseUsername(),
                    conversations.getConvMessage()));

            hsession.delete(conversations);

            numMessages++;
        }

        hsession.flush();

        json.put("numMessages", new Integer(numMessages));
        json.put("messages", messages);

        Criteria crit1 = hsession.createCriteria(BuddyList.class);
        crit1.add(Restrictions.eq("usersByBuliOwnerIdint", user));
        crit1.add(Restrictions.eq("buliActive", new Boolean(true)));
        crit1.addOrder(Order.desc("buliLastDate"));

        ScrollableResults scroll1 = crit1.scroll();

        while (scroll1.next()) {
            BuddyList buddyList = (BuddyList) scroll1.get(0);
            Users buddy = buddyList.getUsersByBuliBuddyIdint();

            if (buddy.isUseActive()) {
                String name = buddy.getUseName();

                if (StringUtils.isBlank(name)) {
                    name = buddy.getUseUsername();
                }

                if (buddy.getUseIsOnline() == 0) {
                    buddiesOffline
                            .addElement(new BuddyObj(name, buddy.getUseUsername(), buddy.getUseIsOnline()));
                } else {
                    buddiesOnline
                            .addElement(new BuddyObj(name, buddy.getUseUsername(), buddy.getUseIsOnline()));
                }
            }
        }

        if (!buddiesOnline.isEmpty()) {
            buddies.addAll(buddiesOnline);
        }

        if (!buddiesOffline.isEmpty()) {
            buddies.addAll(buddiesOffline);
        }

        json.put("buddy", buddies);

        return json.toString();
    } catch (Exception e) {
        throw new ChatException(e);
    } finally {
        GeneralOperations.closeHibernateSession(hsession);
    }
}

From source file:com.verisign.epp.codec.launch.EPPLaunchTst.java

/**
 * Tests the <code>EPPLaunchCreate</code> create command extension with use
 * of the code and mark in Sunrise Create Form. The tests include the
 * following:<br>/*w  ww  .  j  av a 2  s . c  om*/
 * <br>
 * <ol>
 * <li>Test create command for sunrise create using just one code
 * <li>Test create command for sunrise create using multiple codes
 * <li>Test create command for sunrise create using just one mark
 * <li>Test create command for sunrise create using one code and mark
 * </ol>
 */
public void testLaunchCreateCodeMark() {

    EPPCodecTst.printStart("testLaunchCreateCodeMark");

    EPPDomainCreateCmd theCommand;
    EPPEncodeDecodeStats commandStats;

    theCommand = new EPPDomainCreateCmd("ABC-12345", "example.tld", new EPPAuthInfo("2fooBAR"));

    if (EPPFactory.getInstance().hasService(EPPDomainMapFactory.NS_CONTACT)) {
        theCommand.setRegistrant("jd1234");
        Vector contacts = new Vector();
        contacts.addElement(new EPPDomainContact("sh8013", EPPDomainContact.TYPE_ADMINISTRATIVE));
        contacts.addElement(new EPPDomainContact("sh8013", EPPDomainContact.TYPE_TECHNICAL));
        theCommand.setContacts(contacts);
    }

    // Test create command for sunrise create using just one code
    theCommand.addExtension(new EPPLaunchCreate(new EPPLaunchPhase(EPPLaunchPhase.PHASE_SUNRISE),
            new EPPLaunchCodeMark("49FD46E6C4B45C55D4AC"), EPPLaunchCreate.TYPE_REGISTRATION));

    commandStats = EPPCodecTst.testEncodeDecode(theCommand);
    System.out.println(commandStats);

    // Test create command for sunrise create using multiple codes
    EPPLaunchCreate createExt = new EPPLaunchCreate(new EPPLaunchPhase(EPPLaunchPhase.PHASE_SUNRISE));

    createExt.addCodeMark(new EPPLaunchCodeMark("49FD46E6C4B45C55D4AC", "sample1"));
    createExt.addCodeMark(new EPPLaunchCodeMark("49FD46E6C4B45C55D4AD"));
    createExt.addCodeMark(new EPPLaunchCodeMark("49FD46E6C4B45C55D4AE", "sample2"));

    theCommand.setExtensions(null);
    theCommand.addExtension(createExt);

    commandStats = EPPCodecTst.testEncodeDecode(theCommand);
    System.out.println(commandStats);

    // Test create command for sunrise create using just one mark

    // Mark Owner
    EPPMarkContact holder = new EPPMarkContact();
    holder.setEntitlement(EPPMarkContact.ENTITLEMENT_OWNER);
    holder.setOrg("Example Inc.");
    holder.setEmail("holder@example.tld");
    // Address
    EPPMarkAddress holderAddress = new EPPMarkAddress();
    holderAddress.addStreet("123 Example Dr.");
    holderAddress.addStreet("Suite 100");
    holderAddress.setCity("Reston");
    holderAddress.setSp("VA");
    holderAddress.setPc("20190");
    holderAddress.setCc("US");
    holder.setAddress(holderAddress);

    // Mark Contact
    EPPMarkContact contact = new EPPMarkContact();
    contact.setType(EPPMarkContact.TYPE_OWNER);
    contact.setName("John Doe");
    contact.setOrg("Example Inc."); // Address
    EPPMarkAddress contactAddress = new EPPMarkAddress();
    contactAddress.addStreet("123 Example Dr.");
    contactAddress.addStreet("Suite 100");
    contactAddress.setCity("Reston");
    contactAddress.setSp("VA");
    contactAddress.setPc("20166-6503");
    contactAddress.setCc("US");
    contact.setAddress(contactAddress);
    contact.setVoice("+1.7035555555");
    contact.setVoiceExt("1234");
    contact.setFax("+1.7035555556");
    contact.setEmail("jdoe@example.tld");

    // Trademark
    EPPTrademark trademark = new EPPTrademark();
    trademark.setId("1234-2");
    trademark.setName("Example One");
    trademark.addHolder(holder);
    trademark.addContact(contact);
    trademark.setJurisdiction("US");
    trademark.addClass("35");
    trademark.addClass("36");
    trademark.addLabel("example-one");
    trademark.addLabel("exampleone");
    trademark.setGoodsAndServices("Dirigendas et eiusmodi featuring infringo in airfare et cartam servicia.");
    trademark.setRegNum("234235");
    trademark.setRegDate(new GregorianCalendar(2009, 8, 16).getTime());
    trademark.setExDate(new GregorianCalendar(2015, 8, 16).getTime());

    // Treaty or Statute
    EPPTreatyOrStatute treatyOrStatute = new EPPTreatyOrStatute();
    treatyOrStatute.setId("1234-2");
    treatyOrStatute.setName("Example One");
    treatyOrStatute.addHolder(holder);
    treatyOrStatute.addContact(contact);
    treatyOrStatute.addProtection(new EPPProtection("US", "Reston", "US"));
    treatyOrStatute.addLabel("example-one");
    treatyOrStatute.addLabel("exampleone");
    treatyOrStatute
            .setGoodsAndServices("Dirigendas et eiusmodi featuring infringo in airfare et cartam servicia.");
    treatyOrStatute.setRefNum("234235");
    treatyOrStatute.setProDate(new GregorianCalendar(2009, 8, 16).getTime());
    treatyOrStatute.setTitle("Example Title");
    treatyOrStatute.setExecDate(new GregorianCalendar(2015, 8, 16).getTime());

    // Court
    EPPCourt court = new EPPCourt();
    court.setId("1234-2");
    court.setName("Example One");
    court.addHolder(holder);
    court.addContact(contact);
    court.addLabel("example-one");
    court.addLabel("exampleone");
    court.setGoodsAndServices("Dirigendas et eiusmodi featuring infringo in airfare et cartam servicia.");
    court.setRefNum("234235");
    court.setProDate(new GregorianCalendar(2009, 8, 16).getTime());
    court.setCc("US");
    court.addRegions("Reston");
    court.setCourtName("Test Court");

    // Mark
    EPPMark mark = new EPPMark();
    mark.addTrademark(trademark);
    mark.addTreatyOrStatute(treatyOrStatute);
    mark.addCourt(court);

    theCommand.setExtensions(null);
    theCommand.addExtension(new EPPLaunchCreate(new EPPLaunchPhase(EPPLaunchPhase.PHASE_SUNRISE),
            new EPPLaunchCodeMark(mark), EPPLaunchCreate.TYPE_APPLICATION));

    commandStats = EPPCodecTst.testEncodeDecode(theCommand);
    System.out.println(commandStats);

    // Test create command for sunrise create using one code and mark
    theCommand.setExtensions(null);
    theCommand.addExtension(new EPPLaunchCreate(new EPPLaunchPhase(EPPLaunchPhase.PHASE_SUNRISE),
            new EPPLaunchCodeMark("49FD46E6C4B45C55D4AC", "sample", mark)));

    commandStats = EPPCodecTst.testEncodeDecode(theCommand);
    System.out.println(commandStats);

    // Test create command for sunrise create using multiple codes and marks
    theCommand.setExtensions(null);
    createExt = new EPPLaunchCreate(new EPPLaunchPhase(EPPLaunchPhase.PHASE_SUNRISE));

    createExt.addCodeMark(new EPPLaunchCodeMark("49FD46E6C4B45C55D4AC", "sample1", mark));
    createExt.addCodeMark(new EPPLaunchCodeMark("49FD46E6C4B45C55D4AD", "sample2", mark));

    theCommand.setExtensions(null);
    theCommand.addExtension(createExt);

    commandStats = EPPCodecTst.testEncodeDecode(theCommand);
    System.out.println(commandStats);

    // Test create command with mix of sunrise create model and claims
    // create model
    theCommand.setExtensions(null);
    createExt = new EPPLaunchCreate(new EPPLaunchPhase(EPPLaunchPhase.PHASE_CUSTOM, "non-tmch-sunrise"),
            EPPLaunchCreate.TYPE_APPLICATION);

    createExt.addCodeMark(new EPPLaunchCodeMark(mark));
    createExt.setNotice(new EPPLaunchNotice("49FD46E6C4B45C55D4AC", new Date(), new Date()));

    theCommand.setExtensions(null);
    theCommand.addExtension(createExt);

    commandStats = EPPCodecTst.testEncodeDecode(theCommand);
    System.out.println(commandStats);

    // Test create command with mix of sunrise create model and claims
    // create model with validatorID
    theCommand.setExtensions(null);
    createExt = new EPPLaunchCreate(new EPPLaunchPhase(EPPLaunchPhase.PHASE_CUSTOM, "non-tmch-sunrise"),
            EPPLaunchCreate.TYPE_APPLICATION);

    createExt.addCodeMark(new EPPLaunchCodeMark(mark));
    createExt.setNotice(new EPPLaunchNotice("49FD46E6C4B45C55D4AC", new Date(), new Date(), "custom"));

    theCommand.setExtensions(null);
    theCommand.addExtension(createExt);

    commandStats = EPPCodecTst.testEncodeDecode(theCommand);
    System.out.println(commandStats);

    EPPCodecTst.printEnd("testLaunchCreateCodeMark");
}

From source file:com.netscape.cmscore.usrgrp.UGSubsystem.java

protected Enumeration<IUser> buildUsers(LDAPSearchResults res) throws EUsrGrpException {
    Vector<IUser> v = new Vector<IUser>();

    if (res != null) {
        while (res.hasMoreElements()) {
            LDAPEntry entry = (LDAPEntry) res.nextElement();
            IUser user = buildUser(entry);

            v.addElement(user);
        }//from   w  ww . j av a 2 s.c  o m
    }

    // if v contains nothing, just throw exception
    if (v.size() == 0) {
        throw new EUsrGrpException(CMS.getUserMessage("CMS_USRGRP_USER_NOT_FOUND"));
    }

    return v.elements();
}

From source file:org.apache.tools.ant.taskdefs.optional.net.FTPTaskMirrorImpl.java

/**
 * Creates all parent directories specified in a complete relative
 * pathname. Attempts to create existing directories will not cause
 * errors.//from   w  ww .j a v  a 2  s .  co  m
 *
 * @param ftp the FTP client instance to use to execute FTP actions on
 *        the remote server.
 * @param filename the name of the file whose parents should be created.
 * @throws IOException under non documented circumstances
 * @throws BuildException if it is impossible to cd to a remote directory
 *
 */
protected void createParents(FTPClient ftp, String filename) throws IOException, BuildException {

    File dir = new File(filename);
    if (dirCache.contains(dir)) {
        return;
    }

    Vector parents = new Vector();
    String dirname;

    while ((dirname = dir.getParent()) != null) {
        File checkDir = new File(dirname);
        if (dirCache.contains(checkDir)) {
            break;
        }
        dir = checkDir;
        parents.addElement(dir);
    }

    // find first non cached dir
    int i = parents.size() - 1;

    if (i >= 0) {
        String cwd = ftp.printWorkingDirectory();
        String parent = dir.getParent();
        if (parent != null) {
            if (!ftp.changeWorkingDirectory(resolveFile(parent))) {
                throw new BuildException("could not change to " + "directory: " + ftp.getReplyString());
            }
        }

        while (i >= 0) {
            dir = (File) parents.elementAt(i--);
            // check if dir exists by trying to change into it.
            if (!ftp.changeWorkingDirectory(dir.getName())) {
                // could not change to it - try to create it
                task.log("creating remote directory " + resolveFile(dir.getPath()), Project.MSG_VERBOSE);
                if (!ftp.makeDirectory(dir.getName())) {
                    handleMkDirFailure(ftp);
                }
                if (!ftp.changeWorkingDirectory(dir.getName())) {
                    throw new BuildException("could not change to " + "directory: " + ftp.getReplyString());
                }
            }
            dirCache.add(dir);
        }
        ftp.changeWorkingDirectory(cwd);
    }
}

From source file:net.anidb.udp.UdpNotificationFactory.java

/**
 * <p>Returns a list of entries of all pending (not acknowledged) new
 * private message and new file notifications.</p>
 * <p>Buddy events cannot be acknowledged.</p> 
 * @return The list./*  ww  w .j a  v a2 s. com*/
 * @throws UdpConnectionException If a connection problem occured.
 * @throws AniDbException If a problem with AniDB occured.
 */
public List<NotificationListEntry> getNotifyList() throws UdpConnectionException, AniDbException {

    UdpRequest request;
    UdpResponse response;
    Vector<NotificationListEntry> list;
    int count;
    UdpResponseEntry entry;
    String type;
    long id;

    if (!this.conn.isOpen()) {
        throw new UdpConnectionException("Connection is already closed.");
    }
    if (!this.conn.isLoggedIn()) {
        throw new UdpConnectionException("Client is not logged in.");
    }
    request = new UdpRequest("NOTIFYLIST");
    response = this.conn.communicate(request);
    if (response.getReturnCode() != UdpReturnCodes.NOTIFYLIST) {
        throw new AniDbException(response.getReturnCode(), response.getReturnString(),
                response.getMessageString());
    }
    list = new Vector<NotificationListEntry>();
    count = response.getEntryCount();
    for (int index = 0; index < count; index++) {
        entry = response.getEntryAt(index);
        if (entry.getDataFieldCount() < 2) {
            throw new UdpConnectionException("Received invalid response to the command NOTIFYLIST: "
                    + "The entry has less than 2 data fields: " + response.toString());
        } else if (entry.getDataFieldCount() > 2) {
            LOG.warn("The entry of the response to the command NOTIFYLIST " + "has more than 2 data fields: "
                    + response.toString());
        }
        type = entry.getDataFieldAt(0).getValue();
        try {
            id = entry.getDataFieldAt(1).getValueAsLongValue();
        } catch (DataFieldException dfe) {
            throw new UdpConnectionException(
                    "Received invalid response entry to the command " + "NOTIFYLIST: " + response.toString(),
                    dfe);
        }
        list.addElement(new NotificationListEntry(type, id));
    }
    return list;
}

From source file:cl.utfsm.cdbChecker.CDBChecker.java

/**
 * This get the filenames of type 'type' from the given path. 
 * There could be several paths separated by ":". 
 * /*from   w w  w .ja v a 2  s .  c o m*/
 * @param path multiple paths separated by ":" to look for 'type' files.
 * @param type type of files to get.
 * @return a vector of strings with the filenames of type 'type' with absolute path.
 *         An empty vector is returned if paths is empty.
 */
protected Vector<String> getFilenames(String paths[], String type) {
    Vector<String> vector = new Vector<String>();

    String files[];

    /*
     * Scans the list of paths.
     */

    for (int i = 0; i < paths.length; i++) {
        if (paths[i].length() != 0) {
            File file = new File(paths[i]);
            if (file.exists()) {
                if (file.isFile()) { //Is a File
                    if (paths[i].endsWith("." + type))
                        vector.add(paths[i]);
                } else { //Is a directory
                    if (!(paths[i].endsWith(File.separator)))
                        paths[i] = paths[i] + File.separator;

                    //Search for files, filtering for 'type'
                    if (type.equals("xml"))
                        files = (new File(paths[i])).list(xmlFileFilter);
                    else
                        files = (new File(paths[i])).list(xsdFileFilter);

                    //Add the files to the vector.
                    if (files != null)
                        for (int j = 0; j < files.length; j++)
                            vector.addElement(paths[i] + files[j]);

                    if (this.recursive) {
                        String[] dirs = (new File(paths[i])).list(dirFileFilter);
                        if (dirs.length != 0)
                            for (int j = 0; j < dirs.length; j++) {
                                dirs[j] = paths[i] + dirs[j] + File.separator;
                            }
                        vector.addAll(getFilenames(dirs, type));
                    }
                }
            }
        }
    }
    return vector;
}