Example usage for java.util Vector addAll

List of usage examples for java.util Vector addAll

Introduction

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

Prototype

public boolean addAll(Collection<? extends E> c) 

Source Link

Document

Appends all of the elements in the specified Collection to the end of this Vector, in the order that they are returned by the specified Collection's Iterator.

Usage

From source file:org.openflexo.foundation.wkf.FlexoProcess.java

/**
 * Return a Vector of all embedded WKFObjects
 * //from w  w w.ja  v  a 2s .  com
 * @return a Vector of WKFObject instances
 */
@Override
public Vector<WKFObject> getAllEmbeddedWKFObjects() {
    Vector<WKFObject> returned = new Vector<WKFObject>();
    returned.add(this);
    if (_petriGraph != null) {
        returned.addAll(_petriGraph.getAllEmbeddedWKFObjects());
    }
    if (getPortRegistery() != null) {
        returned.addAll(getPortRegistery().getAllEmbeddedWKFObjects());
    }

    if (getServiceInterfaces() != null) {
        Enumeration en = getServiceInterfaces().elements();
        while (en.hasMoreElements()) {
            ServiceInterface service = (ServiceInterface) en.nextElement();
            returned.addAll(service.getAllEmbeddedWKFObjects());
        }
    }
    if (getStatusList() != null) {
        returned.addAll(getStatusList().getAllEmbeddedWKFObjects());
    }
    returned.addAll(getMetricsValues());

    return returned;
}

From source file:org.openflexo.foundation.wkf.FlexoProcess.java

/**
 * Return all ActionNode contained in this process
 * //www .j av  a 2 s . c o m
 * @return a Vector of ActionNode
 */
public Vector<ActionNode> getAllEmbeddedActionNodes() {
    if (_petriGraph != null) {
        Vector<ActionNode> v = new Vector<ActionNode>();
        for (AbstractActivityNode a : _petriGraph.getAllEmbeddedAbstractActivityNodes()) {
            for (OperationNode o : a.getAllEmbeddedOperationNodes()) {
                v.addAll(o.getAllEmbeddedActionNodes());
            }
        }
        return v;
    } else {
        return new Vector<ActionNode>();
    }
}

From source file:com.sos.VirtualFileSystem.FTP.SOSVfsFtp.java

/**
 * return a listing of the contents of a directory in short format on
 * the remote machine (without subdirectory)
 *
 * @param pathname on remote machine//from  w  w w  . j  av  a 2s. c  o  m
 * @return a listing of the contents of a directory on the remote machine
 * @throws IOException
 *
 * @exception Exception
 * @see #dir()
 */
private Vector<String> getFilenames(final String pstrPathName, final boolean flgRecurseSubFolders) {

    String conMethodName = "getFilenames";
    String strCurrentDirectory = null;
    // TODO vecDirectoryListing = null; prfen, ob notwendig
    Vector<String> vecDirectoryListing = null;
    if (vecDirectoryListing == null) {
        vecDirectoryListing = new Vector<String>();
        String[] fileList = null;
        strCurrentDirectory = DoPWD();
        String lstrPathName = pstrPathName.trim();
        if (lstrPathName.length() <= 0) {
            lstrPathName = ".";
        }
        if (lstrPathName.equals(".")) {
            lstrPathName = strCurrentDirectory;
        }

        //         if (1 == 1) {
        //            try {
        //               fileList = listNames(lstrPathName);
        //            }
        //            catch (IOException e) {
        //               e.printStackTrace(System.err);
        //            }
        //         }

        try {
            listFiles = Client().listFiles(lstrPathName);
        } catch (IOException e) {
            RaiseException(e, HostID(SOSVfs_E_0105.params(conMethodName)));
        }

        if (listFiles == null || listFiles.length <= 0) {
            return vecDirectoryListing;
        }

        for (FTPFile listFile : listFiles) {
            String strCurrentFile = listFile.getName();
            if (isNotHiddenFile(strCurrentFile) && strCurrentFile.trim().length() > 0) {
                //               DoCD(strCurrentFile); // is this file-entry a subfolder?
                //               boolean flgIsDirectory = isNegativeCommandCompletion() == false;
                boolean flgIsDirectory = listFile.isDirectory();
                if (flgIsDirectory == false) {
                    if (lstrPathName.startsWith("/") == false) { // JIRA SOSFTP-124
                        if (strCurrentFile.startsWith(strCurrentDirectory) == false) {
                            strCurrentFile = addFileSeparator(strCurrentDirectory) + strCurrentFile;
                        }
                    }
                    vecDirectoryListing.add(strCurrentFile);
                } else {
                    if (flgIsDirectory && flgRecurseSubFolders == true) {
                        DoCD(strCurrentDirectory);
                        if (flgRecurseSubFolders) {
                            logger.debug(String.format(""));
                            Vector<String> vecNames = getFilenames(strCurrentFile, flgRecurseSubFolders);
                            if (vecNames != null) {
                                vecDirectoryListing.addAll(vecNames);
                            }
                        }
                    }
                }
            }
        }
    }
    logger.debug("strCurrentDirectory = " + strCurrentDirectory);
    if (strCurrentDirectory != null) {
        DoCD(strCurrentDirectory);
        DoPWD();
    }
    return vecDirectoryListing;
}

From source file:org.openflexo.foundation.wkf.FlexoProcess.java

/**
 * Return all OperationNode contained in this process
 * /*  w w w. ja v  a  2s  . c om*/
 * @return a Vector of OperationNode
 */
public Vector<OperationNode> getAllEmbeddedOperationNodes() {
    Vector<OperationNode> v = new Vector<OperationNode>();
    if (isImported()) {
        return v;
    }
    if (_petriGraph != null) {
        for (AbstractActivityNode activity : _petriGraph.getAllEmbeddedAbstractActivityNodes()) {
            v.addAll(activity.getAllEmbeddedOperationNodes());
        }
        return v;
    }
    if (logger.isLoggable(Level.WARNING)) {
        logger.warning("_petriGraph is null for process:" + getName());
    }
    return v;
}

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

/**
 * DOCUMENT ME!//w  w  w.j a v  a2  s .  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.sos.VirtualFileSystem.SFTP.SOSVfsSFtp.java

/**
 * return a listing of the contents of a directory in short format on
 * the remote machine (without subdirectory)
 *
 * @param pathname on remote machine//from w w  w.  ja  v  a  2s .  co m
 * @return a listing of the contents of a directory on the remote machine
 * @throws IOException
 *
 * @exception Exception
 * @see #dir()
 */
private Vector<String> getFilenames(final String pstrPathName, final boolean flgRecurseSubFolders)
        throws Exception {
    String strCurrentDirectory = null;
    Vector<String> vecDirectoryListing = null;
    if (vecDirectoryListing == null) {
        vecDirectoryListing = new Vector<String>();
        String[] fileList = null;
        strCurrentDirectory = DoPWD();
        String lstrPathName = pstrPathName.trim();

        if (lstrPathName.length() <= 0) {
            lstrPathName = ".";
        }

        if (lstrPathName.equals(".")) {
            lstrPathName = strCurrentDirectory;
        }

        if (1 == 1) {
            try {
                fileList = listNames(lstrPathName);
            } catch (IOException e) {
                e.printStackTrace(System.err);
            }
        }

        if (fileList == null) {
            return vecDirectoryListing;
        }

        for (String strCurrentFile : fileList) {
            if (isNotHiddenFile(strCurrentFile)) {
                if (Client().lstat(strCurrentFile).isDirectory() == false) {
                    if (lstrPathName.startsWith("/") == false) { // JIRA SOSFTP-124
                        if (strCurrentFile.startsWith(strCurrentDirectory) == false) {
                            strCurrentFile = addFileSeparator(strCurrentDirectory) + strCurrentFile;
                        }
                    }
                    vecDirectoryListing.add(strCurrentFile);
                } else {
                    if (flgRecurseSubFolders) {
                        logger.debug(String.format("start scan for subdirectory '%1$s' ", strCurrentFile));
                        Vector<String> vecNames = getFilenames(strCurrentFile, flgRecurseSubFolders);
                        if (vecNames != null) {
                            vecDirectoryListing.addAll(vecNames);
                        }
                    }
                }
            }
        }
    }
    logger.debug(SOSVfs_I_126.params(strCurrentDirectory));
    if (strCurrentDirectory != null) {
        DoCD(strCurrentDirectory);
        DoPWD();
    }
    return vecDirectoryListing;

}

From source file:org.openflexo.foundation.wkf.FlexoProcess.java

public Vector<WKFAssociation> getAllAssociations() {
    Vector<WKFAssociation> returned = new Vector<WKFAssociation>() {
        @Override/* w w  w.j a  v  a2  s . c om*/
        public synchronized boolean addAll(Collection<? extends WKFAssociation> c) {
            for (WKFAssociation edge : c) {
                if (!contains(edge)) {
                    add(edge);
                }
            }
            return true;
        }
    };
    for (WKFNode n : getAllNodes()) {
        returned.addAll(n.getOutgoingAssociations());
        returned.addAll(n.getIncomingAssociations());
    }
    return returned;
}

From source file:org.openflexo.foundation.wkf.FlexoProcess.java

public Vector<FlexoPostCondition<?, ?>> getAllPostConditions() {
    Vector<FlexoPostCondition<?, ?>> returned = new Vector<FlexoPostCondition<?, ?>>() {
        @Override/* w  w w. j av a2 s . c  o m*/
        public synchronized boolean addAll(Collection<? extends FlexoPostCondition<?, ?>> c) {
            for (FlexoPostCondition<?, ?> edge : c) {
                if (!contains(edge)) {
                    add(edge);
                }
            }
            return true;
        }
    };
    for (AbstractNode n : getAllAbstractNodes()) {
        returned.addAll(n.getOutgoingPostConditions());
        returned.addAll(n.getIncomingPostConditions());
    }
    return returned;
}

From source file:org.apache.rampart.PolicyBasedResultsValidator.java

/**
 * {@inheritDoc}/* w w  w.  j a  v  a  2  s. com*/
 */
public void validate(ValidatorData data, Vector results) throws RampartException {

    RampartMessageData rmd = data.getRampartMessageData();

    RampartPolicyData rpd = rmd.getPolicyData();

    Set namespaces = RampartUtil.findAllPrefixNamespaces(rmd.getMsgContext().getEnvelope(),
            rpd.getDeclaredNamespaces());

    rmd.setDeclaredNamespaces(namespaces);

    // If there's Security policy present and no results
    // then we should throw an error
    if (rpd != null && results == null) {
        throw new RampartException("noSecurityResults");
    }

    // Check presence of timestamp
    WSSecurityEngineResult tsResult = null;
    if (rpd != null && rpd.isIncludeTimestamp()) {
        tsResult = WSSecurityUtil.fetchActionResult(results, WSConstants.TS);
        if (tsResult == null && !rpd.isIncludeTimestampOptional()) {
            throw new RampartException("timestampMissing");
        }

    }

    WSSecurityEngineResult krbResult;
    krbResult = WSSecurityUtil.fetchActionResult(results, WSConstants.KERBEROS_SIGN);
    if (krbResult == null) {
        krbResult = WSSecurityUtil.fetchActionResult(results, WSConstants.KERBEROS_ENCR);
    }
    if (krbResult == null) {
        krbResult = WSSecurityUtil.fetchActionResult(results, WSConstants.KERBEROS);
    }
    if (krbResult != null) {
        // TODO
        return;
    }

    Vector encryptedParts = new Vector();
    Vector signatureParts = new Vector();

    if (!rpd.getRampartConfig().isOptimizeMessageProcessingForTransportBinding()) {
        //sig/encr
        encryptedParts = RampartUtil.getEncryptedParts(rmd);
        if (rpd != null && rpd.isSignatureProtection() && isSignatureRequired(rmd)) {

            String sigId = RampartUtil.getSigElementId(rmd);

            encryptedParts.add(new WSEncryptionPart(WSConstants.SIG_LN, WSConstants.SIG_NS, "Element"));
        }

        signatureParts = RampartUtil.getSignedParts(rmd);

        //Timestamp is not included in sig parts
        if (tsResult != null || !rpd.isIncludeTimestampOptional()) {
            if (rpd != null && rpd.isIncludeTimestamp() && !rpd.isTransportBinding()) {
                signatureParts.add(new WSEncryptionPart("timestamp"));
            }
        }
    }

    if (!rmd.isInitiator()) {

        // Just an indicator for EndorsingSupportingToken signature
        SupportingToken endSupportingToken = rpd.getEndorsingSupportingTokens();
        if (endSupportingToken != null && !endSupportingToken.isOptional()) {
            SignedEncryptedParts endSignedParts = endSupportingToken.getSignedParts();
            if ((endSignedParts != null && !endSignedParts.isOptional()
                    && (endSignedParts.isBody() || endSignedParts.getHeaders().size() > 0))
                    || rpd.isIncludeTimestamp()) {
                signatureParts.add(new WSEncryptionPart("EndorsingSupportingTokens"));
            }
        }
        // Just an indicator for SignedEndorsingSupportingToken signature
        SupportingToken sgndEndSupportingToken = rpd.getSignedEndorsingSupportingTokens();
        if (sgndEndSupportingToken != null && !sgndEndSupportingToken.isOptional()) {
            SignedEncryptedParts sgndEndSignedParts = sgndEndSupportingToken.getSignedParts();
            if ((sgndEndSignedParts != null && !sgndEndSignedParts.isOptional()
                    && (sgndEndSignedParts.isBody() || sgndEndSignedParts.getHeaders().size() > 0))
                    || rpd.isIncludeTimestamp()) {
                signatureParts.add(new WSEncryptionPart("SignedEndorsingSupportingTokens"));
            }
        }

        Vector supportingToks = rpd.getSupportingTokensList();
        for (int i = 0; i < supportingToks.size(); i++) {
            SupportingToken supportingToken = (SupportingToken) supportingToks.get(i);
            if (supportingToken != null && !supportingToken.isOptional()) {
                SupportingPolicyData policyData = new SupportingPolicyData();
                policyData.build(supportingToken);
                encryptedParts.addAll(RampartUtil.getSupportingEncryptedParts(rmd, policyData));
                signatureParts.addAll(RampartUtil.getSupportingSignedParts(rmd, policyData));
            }
        }
    }

    if (!rpd.getRampartConfig().isOptimizeMessageProcessingForTransportBinding()) {
        validateEncrSig(data, encryptedParts, signatureParts, results);
    }

    if (!rpd.isTransportBinding()) {
        validateProtectionOrder(data, results);
    }

    if (!rpd.getRampartConfig().isOptimizeMessageProcessingForTransportBinding()) {
        validateEncryptedParts(data, encryptedParts, results, namespaces);

        validateSignedPartsHeaders(data, signatureParts, results);
    }

    validateRequiredElements(data, namespaces);

    // Supporting tokens
    if (!rmd.isInitiator()) {
        validateSupportingTokens(data, results);
    }

    /*
     * Now we can check the certificate used to sign the message. In the following
     * implementation the certificate is only trusted if either it itself or the certificate of
     * the issuer is installed in the keystore.
     * 
     * Note: the method verifyTrust(X509Certificate) allows custom implementations with other
     * validation algorithms for subclasses.
     */

    // Extract the signature action result from the action vector
    WSSecurityEngineResult actionResult = WSSecurityUtil.fetchActionResult(results, WSConstants.SIGN);

    if (actionResult != null) {
        X509Certificate returnCert = (X509Certificate) actionResult
                .get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);

        if (returnCert != null) {
            if (!verifyTrust(returnCert, rmd)) {
                throw new RampartException("trustVerificationError");
            }
        }
    }

    /*
     * Perform further checks on the timestamp that was transmitted in the header. In the
     * following implementation the timestamp is valid if : Timestamp->Created < 'now' <
     * Timestamp->Created < 'now' < Timestamp->Expires.
     * (Last test handled by WSS4J also if timeStampStrict enabled)
     * 
     * Note: the method verifyTimestamp(Timestamp) allows custom implementations with other
     * validation algorithms for subclasses.
     */

    // Extract the timestamp action result from the action vector
    actionResult = WSSecurityUtil.fetchActionResult(results, WSConstants.TS);

    if (actionResult != null) {
        Timestamp timestamp = (Timestamp) actionResult.get(WSSecurityEngineResult.TAG_TIMESTAMP);

        if (timestamp != null) {
            if (!verifyTimestamp(timestamp, rmd)) {
                throw new RampartException("cannotValidateTimestamp");
            }
        }
    }

    actionResult = WSSecurityUtil.fetchActionResult(results, WSConstants.SAML_TIMESTAMP);
    if (actionResult != null) {
        Timestamp timestamp = (Timestamp) actionResult.get(WSSecurityEngineResult.TAG_TIMESTAMP);

        if (timestamp != null) {
            if (!verifySAMLTokenTimestamp(timestamp, rmd)) {
                throw new RampartException("invalidTimeStampInSamlToken");
            }
        }
    }
}

From source file:edu.ku.brc.specify.tasks.WorkbenchTask.java

/**
 * Creates a report./*from w  ww. j  av a  2 s.c  om*/
 * @param cmdAction the command that initiated it
 */
protected void doReport(final CommandAction cmdAction) {
    Workbench workbench = selectWorkbench(cmdAction, "WorkbenchReporting"); // XXX ADD HELP
    if (workbench == null) {
        return;
    }

    DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
    session.attach(workbench);
    WorkbenchTemplate workbenchTemplate = workbench.getWorkbenchTemplate();
    Set<WorkbenchTemplateMappingItem> mappings = workbenchTemplate.getWorkbenchTemplateMappingItems();
    Vector<WorkbenchTemplateMappingItem> items = new Vector<WorkbenchTemplateMappingItem>();
    items.addAll(mappings);
    session.close();

    String actionStr = cmdAction.getPropertyAsString("action");
    if (StringUtils.isNotEmpty(actionStr) && !actionStr.equals("PrintWBItems")) {
        boolean isBasicLabel = actionStr.equals("PrintBasicLabel");
        boolean go = false;
        if (isBasicLabel) {
            go = askUserForReportProps();
        } else {
            //XXX general prop getting stuff will be handled in ReportTask???
            go = true;
        }

        if (go) {
            RecordSet rs = new RecordSet();
            rs.initialize();
            rs.setDbTableId(Workbench.getClassTableId());
            rs.addItem(workbench.getWorkbenchId());

            session = DataProviderFactory.getInstance().createSession();
            session.attach(workbench);

            workbench.forceLoad();
            WorkbenchJRDataSource dataSrc = new WorkbenchJRDataSource(workbench,
                    workbench.getWorkbenchRowsAsList(), !isBasicLabel, null);
            session.close();

            final CommandAction cmd = new CommandAction(ReportsBaseTask.REPORTS, ReportsBaseTask.PRINT_REPORT,
                    dataSrc);

            if (isBasicLabel) {
                cmd.setProperty("title", "Labels");
                cmd.setProperty("file", "basic_label.jrxml");
                cmd.setProperty("skip-parameter-prompt", "true");
                // params hard-coded for harvard demo:
                cmd.setProperty("params", "title="
                        + AppPreferences.getLocalPrefs().get("reportProperties.title", "") + ";subtitle="
                        + AppPreferences.getLocalPrefs().get("reportProperties.subTitle", "") + ";footer="
                        + AppPreferences.getLocalPrefs().get("reportProperties.footer", ""));
                cmd.setProperty("icon", IconManager.getIcon("Labels16"));
            } else {
                //XXX icon and file props??? 
            }
            cmd.setProperty(NavBoxAction.ORGINATING_TASK, this);

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    CommandDispatcher.dispatch(cmd);
                }
            });
        }
        return;
    }

    WorkbenchTemplateMappingItem selectMappingItem = selectMappingItem(items);

    if (selectMappingItem != null) {
        RecordSet rs = new RecordSet();
        rs.initialize();
        rs.setDbTableId(Workbench.getClassTableId());
        rs.addItem(workbench.getWorkbenchId());

        final CommandAction cmd = new CommandAction(ReportsBaseTask.REPORTS, ReportsBaseTask.PRINT_REPORT, rs);
        cmd.setProperty("title", selectMappingItem.getCaption());
        cmd.setProperty("file", "wb_items.jrxml");
        cmd.setProperty("params", "colnum=" + selectMappingItem.getWorkbenchTemplateMappingItemId() + ";"
                + "title=" + selectMappingItem.getCaption());
        cmd.setProperty(NavBoxAction.ORGINATING_TASK, this);
        ImageIcon cmdIcon = (ImageIcon) cmdAction.getProperty("icon");
        if (cmdIcon != null) {
            cmd.getProperties().put("icon", cmdIcon);
        }
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                CommandDispatcher.dispatch(cmd);
            }
        });
    }
}