Example usage for java.util Vector isEmpty

List of usage examples for java.util Vector isEmpty

Introduction

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

Prototype

public synchronized boolean isEmpty() 

Source Link

Document

Tests if this vector has no components.

Usage

From source file:com.naryx.tagfusion.cfm.xml.ws.javaplatform.DynamicWebServiceStubGenerator.java

private StubInfo.Operation[] findOperations(Parser wsdlParser, Port port) {
    SymbolTable symbolTable = wsdlParser.getSymbolTable();
    BindingEntry bEntry = symbolTable.getBindingEntry(port.getBinding().getQName());
    Set opSet = bEntry.getParameters().keySet();
    Iterator itr = opSet.iterator();

    StubInfo.Operation[] siOps = new StubInfo.Operation[opSet.size()];
    for (int i = 0; itr.hasNext(); i++) {
        // Get the operation and add the parameters
        Operation op = (Operation) itr.next();
        Vector parms = bEntry.getParameters(op).list;

        // Populate the parms
        StubInfo.Parameter[] siParms = new StubInfo.Parameter[parms.size()];
        StubInfo.Operation siOp = new StubInfo.Operation(op.getName(), siParms);
        siOps[i] = siOp;//from  ww w.  j a  va2 s  .c  om
        Iterator tmpItr = parms.iterator();
        for (int j = 0; tmpItr.hasNext(); j++) {
            Parameter p = (Parameter) tmpItr.next();
            siParms[j] = new StubInfo.Parameter(p.getName(), p.isNillable(), p.isOmittable());
        }

        // If there is only 1 parameter and it's a complex object,
        // gather parameter information for its properties.
        if (parms.size() == 1) {
            Vector elems = ((Parameter) parms.get(0)).getType().getContainedElements();
            if (elems != null && !elems.isEmpty()) {
                StubInfo.Parameter[] siSubParms = new StubInfo.Parameter[elems.size()];
                tmpItr = elems.iterator();
                for (int j = 0; tmpItr.hasNext(); j++) {
                    ElementDecl e = (ElementDecl) tmpItr.next();
                    siSubParms[j] = new StubInfo.Parameter(e.getName(), e.getNillable(), e.getMinOccursIs0());
                }
                siOp.setSubParameters(siSubParms);
            }
        }
    }

    // Return the operations
    return siOps;
}

From source file:org.kuali.coeus.propdev.impl.s2s.schedule.S2SPollingTask.java

/**
 * //ww w  .j av a  2  s  .c om
 * This method processes data that is to be sent by mail
 * 
 * @param propList
 * @param mailInfo
 * @return {@link MailMessage}
 */
private MailMessage parseNGetMailAttr(Vector<SubmissionData> propList, MailInfo mailInfo) {
    if (propList == null || propList.isEmpty()) {
        return null;
    }

    MailMessage mailMessage = mailInfo.getMailMessage();
    StringBuffer message = new StringBuffer(mailMessage.getMessage());

    for (SubmissionData submissionData : propList) {

        S2sAppSubmission appSubmission = submissionData.getS2sAppSubmission();
        Timestamp lastNotifiedDate = appSubmission.getLastNotifiedDate();
        Timestamp statusChangedDate = appSubmission.getLastModifiedDate();
        Calendar lastNotifiedDateCal = Calendar.getInstance();

        if (lastNotifiedDate != null) {
            lastNotifiedDateCal.setTimeInMillis(lastNotifiedDate.getTime());
        }
        Calendar statusChangedDateCal = Calendar.getInstance();
        if (statusChangedDate != null) {
            statusChangedDateCal.setTimeInMillis(statusChangedDate.getTime());
        }
        Calendar recDateCal = Calendar.getInstance();
        recDateCal.setTimeInMillis(appSubmission.getReceivedDate().getTime());

        long lastModifiedTime = statusChangedDate == null ? appSubmission.getReceivedDate().getTime()
                : statusChangedDate.getTime();
        Timestamp today = new Timestamp(new Date().getTime());
        long delta = today.getTime() - lastModifiedTime;
        double deltaHrs = ((double) Math.round((delta / (1000.0d * 60.0d * 60.0d)) * Math.pow(10.0, 2))) / 100;

        int days = 0;
        int hrs = 0;
        if (deltaHrs > 0) {
            days = (int) deltaHrs / 24;
            hrs = (int) (((double) Math.round((deltaHrs % 24) * Math.pow(10.0, 2))) / 100);

        }
        if (propList.size() > 0) {
            SubmissionData prevSubmissionData = propList.elementAt(propList.size() - 1);
            if (!prevSubmissionData.getSortId().equals(submissionData.getSortId())) {
                message.append("\n\n");
                message.append(sortMsgKeyMap.get(submissionData.getSortId()));
                message.append("\n____________________________________________________");
            }
        } else {
            message.append("\n\n");
            message.append(sortMsgKeyMap.get(submissionData.getSortId()));
            message.append("\n____________________________________________________");
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
        message.append('\n');
        message.append("Proposal Number : " + appSubmission.getProposalNumber() + "\n");
        message.append("Received Date : ");
        message.append(dateFormat.format(appSubmission.getReceivedDate()));
        message.append('\n');
        message.append("Grants.Gov Tracking Id : ");
        message.append(appSubmission.getGgTrackingId());
        message.append('\n');
        String agTrackId = appSubmission.getAgencyTrackingId() == null ? "Not updated yet"
                : appSubmission.getAgencyTrackingId();
        message.append("Agency Tracking Id : ");
        message.append(agTrackId);
        message.append('\n');
        message.append("Current Status : ");
        message.append(appSubmission.getStatus());
        message.append('\n');
        String stChnageDate = appSubmission.getLastModifiedDate() == null ? "Not updated yet"
                : dateFormat.format(appSubmission.getLastModifiedDate());
        message.append("Last Status Change : " + stChnageDate + "\t *** " + days + " day(s) and " + hrs
                + " hour(s) ***\n");
        message.append('\n');
    }
    message.append('\n');
    message.append(mailInfo.getFooter());
    mailMessage.setMessage(message.toString());

    return mailMessage;
}

From source file:org.kuali.kra.s2s.polling.S2SPollingTask.java

/**
 * /*w w  w  . jav  a2  s.co m*/
 * This method processes data that is to be sent by mail
 * 
 * @param propList
 * @param mailInfo
 * @return {@link MailMessage}
 */
private MailMessage parseNGetMailAttr(Vector<SubmissionData> propList, MailInfo mailInfo) {
    if (propList == null || propList.isEmpty()) {
        return null;
    }

    MailMessage mailMessage = mailInfo.getMailMessage();
    StringBuffer message = new StringBuffer(mailMessage.getMessage());

    for (SubmissionData submissionData : propList) {

        S2sAppSubmission appSubmission = submissionData.getS2sAppSubmission();
        Timestamp lastNotifiedDate = appSubmission.getLastNotifiedDate();
        Timestamp statusChangedDate = appSubmission.getLastModifiedDate();
        Calendar lastNotifiedDateCal = dateTimeService.getCurrentCalendar();

        if (lastNotifiedDate != null) {
            lastNotifiedDateCal.setTimeInMillis(lastNotifiedDate.getTime());
        }
        Calendar statusChangedDateCal = dateTimeService.getCurrentCalendar();
        if (statusChangedDate != null) {
            statusChangedDateCal.setTimeInMillis(statusChangedDate.getTime());
        }
        Calendar recDateCal = dateTimeService.getCurrentCalendar();
        recDateCal.setTimeInMillis(appSubmission.getReceivedDate().getTime());

        long lastModifiedTime = statusChangedDate == null ? appSubmission.getReceivedDate().getTime()
                : statusChangedDate.getTime();
        Timestamp today = dateTimeService.getCurrentTimestamp();
        long delta = today.getTime() - lastModifiedTime;
        double deltaHrs = ((double) Math.round((delta / (1000.0d * 60.0d * 60.0d)) * Math.pow(10.0, 2))) / 100;

        int days = 0;
        int hrs = 0;
        if (deltaHrs > 0) {
            days = (int) deltaHrs / 24;
            hrs = (int) (((double) Math.round((deltaHrs % 24) * Math.pow(10.0, 2))) / 100);

        }
        if (propList.size() > 0) {
            SubmissionData prevSubmissionData = propList.elementAt(propList.size() - 1);
            if (!prevSubmissionData.getSortId().equals(submissionData.getSortId())) {
                message.append("\n\n");
                message.append(sortMsgKeyMap.get(submissionData.getSortId()));
                message.append("\n____________________________________________________");
            }
        } else {
            message.append("\n\n");
            message.append(sortMsgKeyMap.get(submissionData.getSortId()));
            message.append("\n____________________________________________________");
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
        message.append('\n');
        message.append("Proposal Number : " + appSubmission.getProposalNumber() + "\n");
        message.append("Received Date : ");
        message.append(dateFormat.format(appSubmission.getReceivedDate()));
        message.append('\n');
        message.append("Grants.Gov Tracking Id : ");
        message.append(appSubmission.getGgTrackingId());
        message.append('\n');
        String agTrackId = appSubmission.getAgencyTrackingId() == null ? "Not updated yet"
                : appSubmission.getAgencyTrackingId();
        message.append("Agency Tracking Id : ");
        message.append(agTrackId);
        message.append('\n');
        message.append("Current Status : ");
        message.append(appSubmission.getStatus());
        message.append('\n');
        String stChnageDate = appSubmission.getLastModifiedDate() == null ? "Not updated yet"
                : dateFormat.format(appSubmission.getLastModifiedDate());
        message.append("Last Status Change : " + stChnageDate + "\t *** " + days + " day(s) and " + hrs
                + " hour(s) ***\n");
        message.append('\n');
    }
    message.append('\n');
    message.append(mailInfo.getFooter());
    mailMessage.setMessage(message.toString());

    return mailMessage;
}

From source file:org.ops4j.pax.web.service.spi.util.ResourceDelegatingBundleClassLoader.java

@Override
protected Enumeration<URL> findResources(String name) throws IOException {
    Vector<URL> resources = getFromCache(name);

    if (resources == null) {
        resources = new Vector<>();
        for (Bundle delegate : bundles) {
            try {
                Enumeration<URL> urls = delegate.getResources(name);
                if (urls != null) {
                    while (urls.hasMoreElements()) {
                        resources.add(urls.nextElement());
                    }/*  w ww.  j av  a  2  s.  c  o m*/
                }
            } catch (IllegalStateException exc) {
                // ignore
            }
        }
        if (!resources.isEmpty()) {
            addToCache(name, resources);
        }
    }

    return resources.elements();
}

From source file:edu.ucsb.nceas.metacattest.UploadIPCCDataTest.java

private Vector getDocumentList() {
    Vector list = null;
    try {/*from w  w w  .j av a 2 s.co m*/
        //First, try to get eml doc list from text file
        list = getDocumentListFromFile();
        if (list == null || list.isEmpty()) {
            throw new Exception("The eml doclist is empty in text file");
        }
    } catch (Exception e) {
        System.err.println("Couldn't get eml document list from text file: " + e.getMessage());
        // If an exception happened, try to get eml doc list from metacat
        list = getDocumentListFromMetacat();
    }
    if (list != null) {
        System.out.println("the list is " + list);
    }
    return list;
}

From source file:vitro.vspEngine.service.communication.DummyDCACommUtils.java

/**
 * TODO: perhaps we could remove this eventually. This servlet will remain but only for browsing/managing registered islands for a WSI...
 * TODO: the requests per smartdev capabilities should be threaded!
 *//*w w  w  . jav a  2  s .c o m*/
public void startDCAEngine(UserNode refUserNode) {
    // global in-memory. TODO: add persistency!
    HashMap<String, GatewayWithSmartNodes> gatewaysToSmartDevsHM = refUserNode.getGatewaysToSmartDevsHM(); // new HashMap<String, GatewayWithSmartNodes>();    // will contain maps from a gateway id to GatewayWithSmartNodes  objects
    HashMap<String, Vector<SensorModel>> capHMap = refUserNode.getCapabilitiesTable(); // new HashMap<String, Vector<SensorModel>> ();

    Vector<DCAConcentrator> dcaRegisteredVGWs = getDCAConcentratorsList();
    Vector<DCADataDevice> dcaRegisteredDevices = get_ALL_DCADataDevicesList();
    // make the connection between Reg VGWs and their Devices;
    // THIS IS IMPORTANT (it could be integrated in the get_ALL_DCADataDevices though (TODO)
    connectDataDevicesToConcentrators(dcaRegisteredVGWs, dcaRegisteredDevices);

    // for each gateway THAT IS ALSO stored as REGISTERED IN THE LOCAL DB, populate the  gatewaysToSmartDevsHM and the capHMap hashmaps.
    if (dcaRegisteredVGWs != null && dcaRegisteredDevices != null) {
        for (int i = 0; i < dcaRegisteredVGWs.size(); i++) {
            DCAConcentrator tmpCurrDCAConcentrator = dcaRegisteredVGWs.elementAt(i);
            DBRegisteredGateway dbRegGw = DBCommons.getDBCommons()
                    .getRegisteredGateway(tmpCurrDCAConcentrator.id);
            if (dbRegGw != null) // only for registered VGWs (in DCA) that are also in the local DB
            {
                // for each registered Smart Node in this gateway!
                if (tmpCurrDCAConcentrator.dataDevicesVec != null
                        && tmpCurrDCAConcentrator.dataDevicesVec.size() > 0) {
                    // we now parse the "Capabilities" from the XML message for the SmartDevice
                    for (int k = 0; k < tmpCurrDCAConcentrator.dataDevicesVec.size(); k++) {
                        // "local" versions of the global corresponding hashmaps, for dealing with each separate smart device. Later merged with globals
                        HashMap<String, Vector<SensorModel>> ps_advCapsToSensModels = new HashMap<String, Vector<SensorModel>>();
                        Vector<SmartNode> ps_advSmDevs = new Vector<SmartNode>(); // will only contain one device

                        DCADataDevice tmpCurrDCADataDev = tmpCurrDCAConcentrator.dataDevicesVec.elementAt(k);

                        // We use the name here to remove the additional VGW prefix
                        String tmpDevName = "Name";
                        tmpDevName = tmpCurrDCADataDev.id
                                .replaceAll(Pattern.quote(tmpCurrDCAConcentrator.id + "."), "");
                        // TODO: set device coordinates IF they are available in the SensorML for its registration
                        SmartNode smDev = new SmartNode(tmpCurrDCADataDev.id, tmpDevName, "LocationDesc",
                                new GeoPoint(), tmpCurrDCADataDev.creationTime,
                                tmpCurrDCADataDev.registrationTime, tmpCurrDCADataDev.status);
                        Vector<SensorModel> thisNodesSensorModelsVec = retrievePhenomenaByDevice(
                                tmpCurrDCAConcentrator.id, tmpCurrDCADataDev.id, ps_advCapsToSensModels);
                        if (!thisNodesSensorModelsVec.isEmpty()) {
                            smDev.setCapabilitiesVector(thisNodesSensorModelsVec);
                            ps_advSmDevs.add(smDev);
                            DBCommons.getDBCommons().mergeAdvDataToGateway(gatewaysToSmartDevsHM, capHMap,
                                    ps_advCapsToSensModels, ps_advSmDevs, tmpCurrDCAConcentrator.id,
                                    dbRegGw.getFriendlyName(), tmpCurrDCAConcentrator.ipv4,
                                    tmpCurrDCAConcentrator.locationStr);
                        }
                    }
                    DBCommons.getDBCommons().updateRcvGatewayAdTimestamp(tmpCurrDCAConcentrator.id, false);
                }
            }
        }
    }
}

From source file:org.uva.itast.TestOMRProcessor.java

/**
 * Test method for {@link org.uva.itast.blended.omr.OMRProcessor#processPath(java.lang.String)}.
 *//*from  w ww  .jav  a  2s. c  om*/
@Test
public void testProcessPath() {
    try {
        URL url = getClass().getClassLoader().getResource("Doc1.pdf");
        File testPath = new File(url.toURI());
        prepareConfig(testPath);

        Vector<PageImage> errores;
        // deteccin de errores
        errores = processor.processPath("nonexistentfile.png");
        assertTrue("Errors not detected ", errores.size() == 1);

        processor.setMedianFilter(true);
        errores = processor.processPath(testPath.getAbsolutePath()); //se leen las pginas escaneadas
        assertTrue("Errors encountered." + errores, errores.isEmpty());

        url = getClass().getClassLoader().getResource("OMR_imagePage850x1170.png");
        testPath = new File(url.toURI());

        detectErrors(testPath);

        url = getClass().getClassLoader().getResource("Doc2.pdf");
        testPath = new File(url.toURI());

        detectErrors(testPath);

    } catch (Exception e) {
        e.printStackTrace();
        fail("Can't configure test case." + e);
    }
}

From source file:edu.lternet.pasta.dml.database.SimpleDatabaseLoader.java

/**
 * /*from   w  w  w.  j  a v a 2s. c o  m*/
 */
public void run() {

    if (entity == null) {
        success = false;
        completed = true;
        return;
    }

    //don't reload data if we have it
    if (doesDataExist(entity.getEntityIdentifier())) {
        return;
    }

    AttributeList attributeList = entity.getAttributeList();
    String tableName = entity.getDBTableName();

    String insertSQL = "";
    Vector rowVector = new Vector();
    Connection connection = null;

    try {
        rowVector = this.dataReader.getOneRowDataVector();
        connection = DataManager.getConnection();
        if (connection == null) {
            success = false;
            exception = new Exception("The connection to db is null");
            completed = true;
            return;
        }
        connection.setAutoCommit(false);
        while (!rowVector.isEmpty()) {
            insertSQL = databaseAdapter.generateInsertSQL(attributeList, tableName, rowVector);
            if (insertSQL != null) {
                PreparedStatement statement = connection.prepareStatement(insertSQL);
                statement.execute();
            }
            rowVector = this.dataReader.getOneRowDataVector();
        }

        connection.commit();
        success = true;
    } catch (Exception e) {
        log.error("problem while loading data into table.  Error message: " + e.getMessage());
        e.printStackTrace();
        log.error("SQL string to insert row:\n" + insertSQL);

        success = false;
        exception = e;

        try {
            connection.rollback();
        } catch (Exception ee) {
            System.err.println(ee.getMessage());
        }
    } finally {
        try {
            connection.setAutoCommit(true);
        } catch (Exception ee) {
            log.error(ee.getMessage());
        }

        DataManager.returnConnection(connection);
    }
}

From source file:presentation.webgui.vitroappservlet.uploadService.UploadServlet.java

private void doFileUpload(HttpSession session, HttpServletRequest request, HttpServletResponse response)
        throws IOException {

    String fname = "";
    HashMap<String, String> myFileRequestParamsHM = new HashMap<String, String>();

    try {//from  w w  w .j av  a  2s .c  o m
        FileUploadListener listener = new FileUploadListener(request.getContentLength());
        FileItemFactory factory = new MonitoredDiskFileItemFactory(listener);

        ServletFileUpload upload = new ServletFileUpload(factory);
        //        upload.setSizeMax(83886080); /* the unit is bytes */

        FileItem fileItem = null;
        fileItem = myrequestGetParameter(upload, request, myFileRequestParamsHM);

        String mode = myFileRequestParamsHM.get("mode");

        session.setAttribute("FILE_UPLOAD_STATS" + mode, listener.getFileUploadStats());

        boolean hasError = false;

        if (fileItem != null) {
            /**
             * (for KML only files) ( not prefabs (collada) or icons or images)
             */
            WstxInputFactory f = null;
            XMLStreamReader2 sr = null;
            SMInputCursor iroot = null;
            if (mode.equals("3dFile") || mode.equals("LinePlaceMarksFile")
                    || mode.equals("RoomCenterPointsFile")) {
                f = new WstxInputFactory();
                f.configureForConvenience();
                // Let's configure factory 'optimally'...
                f.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
                f.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);

                sr = (XMLStreamReader2) f.createXMLStreamReader(fileItem.getInputStream());
                iroot = SMInputFactory.rootElementCursor(sr);
                // If we needed to store some information about preceding siblings,
                // we should enable tracking. (we need it for  mygetElementValueStaxMultiple method)
                iroot.setElementTracking(SMInputCursor.Tracking.PARENTS);

                iroot.getNext();
                if (!"kml".equals(iroot.getLocalName().toLowerCase())) {
                    hasError = true;
                    listener.getFileUploadStats().setCurrentStatus("finito");
                    session.setAttribute("FILE_UPLOAD_STATS" + mode, listener.getFileUploadStats());
                    sendCompleteResponse(myFileRequestParamsHM, response, hasError,
                            "Root element not kml, as expected, but " + iroot.getLocalName());
                    return;
                }
            }

            fname = "";
            if (mode.equals("3dFile")) {
                if ((fileItem.getSize() / 1024) > 25096) { // with woodstox stax, file size should not be a problem. Let's put some limit however!
                    hasError = true;
                    listener.getFileUploadStats().setCurrentStatus("finito");
                    session.setAttribute("FILE_UPLOAD_STATS" + mode, listener.getFileUploadStats());
                    sendCompleteResponse(myFileRequestParamsHM, response, hasError,
                            "File is very large for XML handler to process!");
                    return;
                }

                fname = "";
                String[] elementsToFollow = { "document", "name" };
                Vector<String> resultValues = SMTools.mygetElementValueStax(iroot, elementsToFollow, 0);
                if (resultValues != null && !resultValues.isEmpty()) {
                    fname = resultValues.elementAt(0);
                }

                if (!fname.equals("")) {
                    // check for kml extension and Add it if necessary!!
                    int lastdot = fname.lastIndexOf('.');
                    if (lastdot != -1) {
                        if (lastdot == 0) // if it is the first char then ignore it and add an extension anyway
                        {
                            fname += ".kml";
                        } else if (lastdot < fname.length() - 1) {
                            if (!(fname.substring(lastdot + 1).toLowerCase().equals("kml"))) {
                                fname += ".kml";
                            }
                        } else if (lastdot == fname.length() - 1) {
                            fname += "kml";
                        }
                    } else {
                        fname += ".kml";
                    }

                    String realPath = this.getServletContext().getRealPath("/");
                    int lastslash = realPath.lastIndexOf(File.separator);
                    realPath = realPath.substring(0, lastslash);
                    // too slow
                    //FileWriter out = new FileWriter(realPath+File.separator+"KML"+File.separator+fname);
                    //document.sendToWriter(out);
                    // too slow
                    //StringWriter outString = new StringWriter();
                    //document.sendToWriter(outString);
                    //out.close();

                    // fast - do not process and store xml file, just store it.
                    File outFile = new File(realPath + File.separator + "Models" + File.separator + "Large"
                            + File.separator + fname);
                    outFile.createNewFile();
                    FileWriter tmpoutWriter = new FileWriter(outFile);
                    BufferedWriter buffWriter = new BufferedWriter(tmpoutWriter);
                    buffWriter.write(new String(fileItem.get()));
                    buffWriter.flush();
                    buffWriter.close();
                    tmpoutWriter.close();
                } else {
                    hasError = true;
                    listener.getFileUploadStats().setCurrentStatus("finito");
                    session.setAttribute("FILE_UPLOAD_STATS" + mode, listener.getFileUploadStats());
                    sendCompleteResponse(myFileRequestParamsHM, response, hasError,
                            "No name tag found inside the KML file!");
                    return;
                }
            } else if (mode.equals("LinePlaceMarksFile")) {
                fname = "";
                String[] elementsToFollow = { "document", "folder", "placemark", "point", "coordinates" };
                Vector<String> resultValues = SMTools.mygetElementValueStax(iroot, elementsToFollow, 0);
                if (resultValues != null && resultValues.size() < 2) {
                    hasError = true;
                    listener.getFileUploadStats().setCurrentStatus("finito");
                    session.setAttribute("FILE_UPLOAD_STATS" + mode, listener.getFileUploadStats());
                    sendCompleteResponse(myFileRequestParamsHM, response, hasError,
                            "File does not contain 2 placemarks!");
                    return;
                }

                for (int i = 0; (i < resultValues.size()) && (i < 2); i++) {
                    fname = fname + ":" + resultValues.elementAt(i);
                }
            } else if (mode.equals("RoomCenterPointsFile")) {
                fname = "";
                // here: process PlaceMarks for rooms (centerpoints) in the building
                String[] elementsToFollow0 = { "document", "folder", "placemark", "point", "coordinates" };
                String[] elementsToFollow1 = { "document", "folder", "placemark", "name" };
                // add elements to follow for room names and coordinates        
                Vector<String[]> elementsToFollow = new Vector<String[]>();
                elementsToFollow.add(elementsToFollow0);
                elementsToFollow.add(elementsToFollow1);
                Vector<Vector<String>> resultValues = new Vector<Vector<String>>();
                SMTools.mygetMultipleElementValuesStax(iroot, elementsToFollow, resultValues);

                Vector<String> resultValuesForCoords = resultValues.elementAt(0);
                Vector<String> resultValuesForNames = resultValues.elementAt(1);

                if (resultValuesForCoords == null || resultValuesForCoords.size() == 0
                        || resultValuesForNames == null || resultValuesForCoords.size() == 0
                        || resultValuesForCoords.size() != resultValuesForNames.size()) {
                    hasError = true;
                    listener.getFileUploadStats().setCurrentStatus("finito");
                    session.setAttribute("FILE_UPLOAD_STATS" + mode, listener.getFileUploadStats());
                    sendCompleteResponse(myFileRequestParamsHM, response, hasError,
                            "File does not contain valid data for rooms!");
                    return;
                }

                for (int i = 0; i < resultValuesForNames.size(); i++) {
                    // since we use ;  and ':' to seperate rooms, we replace the comma's in the rooms' names.
                    if (resultValuesForNames.elementAt(i).indexOf(';') >= 0
                            || resultValuesForNames.elementAt(i).indexOf(':') >= 0) {
                        String tmp = new String(resultValuesForNames.elementAt(i));
                        tmp.replace(';', ' ');
                        tmp.replace(':', ' ');
                        resultValuesForNames.set(i, tmp);
                    }
                    fname = fname + ";" + resultValuesForNames.elementAt(i) + ":"
                            + resultValuesForCoords.elementAt(i);
                }

            } else if (mode.equals("DefaultIconfile") || mode.equals("DefaultPrefabfile")
                    || mode.equals("SpecialValueIconfile") || mode.equals("SpecialValuePrefabfile")
                    || mode.equals("NumericRangeIconfile") || mode.equals("NumericRangePrefabfile")) {
                fname = "";
                if ((fileItem.getSize() / 1024) > 10096) { // no more than 10 Mbs of size for small prefabs or icons
                    hasError = true;
                    listener.getFileUploadStats().setCurrentStatus("finito");
                    session.setAttribute("FILE_UPLOAD_STATS" + mode, listener.getFileUploadStats());
                    sendCompleteResponse(myFileRequestParamsHM, response, hasError, "File is very large!");
                    return;
                }
                fname = fileItem.getName();
                if (!fname.equals("")) {
                    String realPath = this.getServletContext().getRealPath("/");
                    int lastslash = realPath.lastIndexOf(File.separator);
                    realPath = realPath.substring(0, lastslash);

                    File outFile = new File(realPath + File.separator + "Models" + File.separator + "Media"
                            + File.separator + fname);
                    outFile.createNewFile();
                    /*
                    FileWriter tmpoutWriter = new FileWriter(outFile);
                    BufferedWriter buffWriter = new BufferedWriter(tmpoutWriter);                      
                    buffWriter.write(new String(fileItem.get()));
                    buffWriter.flush();
                    buffWriter.close();
                    tmpoutWriter.close();
                    */
                    fileItem.write(outFile);
                } else {
                    hasError = true;
                    listener.getFileUploadStats().setCurrentStatus("finito");
                    session.setAttribute("FILE_UPLOAD_STATS" + mode, listener.getFileUploadStats());
                    sendCompleteResponse(myFileRequestParamsHM, response, hasError,
                            "No valid name for uploaded file!");
                    return;
                }
            }

            fileItem.delete();
        }

        if (!hasError) {
            sendCompleteResponse(myFileRequestParamsHM, response, hasError, fname);
        } else {
            hasError = true;
            sendCompleteResponse(myFileRequestParamsHM, response, hasError,
                    "Could not process uploaded file. Please see log for details.");
        }
    } catch (Exception e) {
        boolean hasError = true;
        sendCompleteResponse(myFileRequestParamsHM, response, hasError, "::" + fname + "::" + e.getMessage());
    }
}

From source file:org.globus.ftp.test.GridFTPClientTest.java

private void testNList(int mode, int type) throws Exception {
    logger.info("show list output using GridFTPClient");

    GridFTPClient client = connect();//from  www.  j av  a 2  s .  co m
    client.setType(type);
    client.setMode(mode);
    client.changeDir(TestEnv.serverADir);
    Vector v = client.nlist();
    logger.debug("list received");
    while (!v.isEmpty()) {
        FileInfo f = (FileInfo) v.remove(0);
        logger.info(f.toString());
    }
    client.close();
}