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:org.apache.webdav.lib.WebdavResource.java

/**
 * Sets the basic properties on a resource by indirectly issuing a PROPFIND
 * on the resource.//  ww  w . j  a  v a  2 s .c o  m
 *
 * <p>Properties retrieved include:
 *
 * <ul>
 *  <li>displayname</li>
 *  <li>getcontentlength</li>
 *  <li>getcontenttype</li>
 *  <li>resourcetype</li>
 *  <li>getlastmodified</li>
 *  <li>lockdiscovery</li>
 * </ul>
 *
 * @param depth The depth to find properties.
 */
protected void setBasicProperties(int depth) throws HttpException, IOException {

    Vector properties = new Vector();
    properties.addElement(DISPLAYNAME);
    properties.addElement(GETCONTENTLENGTH);
    properties.addElement(GETCONTENTTYPE);
    properties.addElement(RESOURCETYPE);
    properties.addElement(GETLASTMODIFIED);
    properties.addElement(LOCKDISCOVERY);

    setNamedProp(depth, properties);
}

From source file:org.apache.webdav.lib.WebdavResource.java

/**
 * Set the default properties on the resource by indirectly issuing a PROPFIND request
 * for a default set of properties.//from  www. j  a  v a 2 s. c om
 *
 * <p>Properties retrieved include:
 *
 * <ul>
 *  <li>creationdate</li>
 *  <li>displayname</li>
 *  <li>getcontentlanguage</li>
 *  <li>getcontentlength</li>
 *  <li>getcontenttype</li>
 *  <li>getetag</li>
 *  <li>getlastmodified</li>
 *  <li>lockdiscovery</li>
 *  <li>resourcetype</li>
 *  <li>source</li>
 *  <li>supportedlock</li>
 * </ul>
 *
 * @param depth The depth to find properties.
 */
protected void setDefaultProperties(int depth) throws HttpException, IOException {

    Vector properties = new Vector();
    properties.addElement(CREATIONDATE);
    properties.addElement(DISPLAYNAME);
    properties.addElement(GETCONTENTLANGUAGE);
    properties.addElement(GETCONTENTLENGTH);
    properties.addElement(GETCONTENTTYPE);
    properties.addElement(GETETAG);
    properties.addElement(GETLASTMODIFIED);
    properties.addElement(LOCKDISCOVERY);
    properties.addElement(RESOURCETYPE);
    properties.addElement(SOURCE);
    properties.addElement(SUPPORTEDLOCK);

    setNamedProp(depth, properties);
}

From source file:org.apache.webdav.lib.WebdavResource.java

/**
 * Return the LockDiscoveryProperty for the resource at the given path
 *
 * @param path the server relative path of the resource to request
 * @return null if the server doesn't respond with a LockDiscoveryProperty
 *///from w ww. j a v  a2 s  . c  o  m
public LockDiscoveryProperty lockDiscoveryPropertyFindMethod(String path) throws HttpException, IOException {

    setClient();

    LockDiscoveryProperty set = null;

    Vector properties = new Vector();
    properties.addElement(LockDiscoveryProperty.TAG_NAME);

    // Default depth=0, type=by_name
    PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path), DepthSupport.DEPTH_0,
            properties.elements());
    method.setDebug(debug);
    method.setFollowRedirects(this.followRedirects);
    generateTransactionHeader(method);
    generateAdditionalHeaders(method);
    client.executeMethod(method);

    Enumeration responses = method.getResponses();
    if (responses.hasMoreElements()) {
        ResponseEntity response = (ResponseEntity) responses.nextElement();
        String href = response.getHref();

        // Set status code for this resource.
        if ((thisResource == true) && (response.getStatusCode() > 0))
            setStatusCode(response.getStatusCode());
        thisResource = false;

        Enumeration responseProperties = method.getResponseProperties(href);
        while (responseProperties.hasMoreElements()) {
            Property property = (Property) responseProperties.nextElement();
            if (property instanceof LockDiscoveryProperty) {
                set = (LockDiscoveryProperty) property;
            }

        }
    }

    return set;
}

From source file:org.apache.webdav.lib.WebdavResource.java

/**
 * Return the <code>AclProperty</code> for the resource at the given path
 *
 * @param path the server relative path of the resource to request
 * @return acl property, null if the server doesn't respond with
 * <code>AclProperty</code>//ww  w.jav  a2 s  .c  om
 */
public AclProperty aclfindMethod(String path) throws HttpException, IOException {

    setClient();

    AclProperty acl = null;

    Vector properties = new Vector();
    properties.addElement(AclProperty.TAG_NAME);

    // Default depth=0, type=by_name
    PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path), DepthSupport.DEPTH_0,
            properties.elements());
    method.setDebug(debug);
    method.setFollowRedirects(this.followRedirects);

    generateTransactionHeader(method);
    generateAdditionalHeaders(method);
    client.executeMethod(method);

    Enumeration responses = method.getResponses();
    if (responses.hasMoreElements()) {
        ResponseEntity response = (ResponseEntity) responses.nextElement();
        String href = response.getHref();

        // Set status code for this resource.
        if ((thisResource == true) && (response.getStatusCode() > 0))
            setStatusCode(response.getStatusCode());
        thisResource = false;

        Enumeration responseProperties = method.getResponseProperties(href);
        while (responseProperties.hasMoreElements()) {
            Property property = (Property) responseProperties.nextElement();
            if (property instanceof AclProperty) {
                acl = (AclProperty) property;
            }

        }
    }

    return acl;
}

From source file:org.apache.webdav.lib.WebdavResource.java

/**
 * Get the <code>PrincipalCollectionSetProperty</code> for the resource.
 *
 * @param path the server relative path of the resource to request
 * @return principal collection set Property, null if the server doesn't
 * respond with a <code>PrincipalCollectionSetProperty</code>
 */// w ww.ja  v a2  s  . com
public PrincipalCollectionSetProperty principalCollectionSetFindMethod(String path)
        throws HttpException, IOException {

    setClient();

    PrincipalCollectionSetProperty set = null;

    Vector properties = new Vector();
    properties.addElement(PrincipalCollectionSetProperty.TAG_NAME);

    // Default depth=0, type=by_name
    PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path), DepthSupport.DEPTH_0,
            properties.elements());
    method.setDebug(debug);
    method.setFollowRedirects(this.followRedirects);
    generateTransactionHeader(method);
    generateAdditionalHeaders(method);
    client.executeMethod(method);

    Enumeration responses = method.getResponses();
    if (responses.hasMoreElements()) {
        ResponseEntity response = (ResponseEntity) responses.nextElement();
        String href = response.getHref();

        // Set status code for this resource.
        if ((thisResource == true) && (response.getStatusCode() > 0))
            setStatusCode(response.getStatusCode());
        thisResource = false;

        Enumeration responseProperties = method.getResponseProperties(href);
        while (responseProperties.hasMoreElements()) {
            Property property = (Property) responseProperties.nextElement();
            if (property instanceof PrincipalCollectionSetProperty) {
                set = (PrincipalCollectionSetProperty) property;
            }

        }
    }

    return set;
}

From source file:org.apache.webdav.lib.WebdavResource.java

/**
 * Get an array of pathnames denoting the WebDAV resources in the
 * collection denoted by this pathname.//  w w w.  j  a v  a  2  s . c  o  m
 *
 * @return An array of pathnames denoting the resources, null if an
 *         IOException occurs.
 */
public String[] list() {

    try {
        setNameProperties(DepthSupport.DEPTH_1);
    } catch (IOException e) {
        return null;
    }
    Enumeration hrefs = childResources.getResourceNames();

    // To be atomic.
    Vector hrefList = new Vector();
    while (hrefs.hasMoreElements()) {
        hrefList.addElement((String) hrefs.nextElement());
    }
    // Calculate the size of the string array.
    int num = hrefList.size();
    String[] pathnames = new String[num];
    for (int i = 0; i < num; i++) {
        pathnames[i] = (String) hrefList.elementAt(i);
    }

    return pathnames;
}

From source file:org.apache.webdav.lib.WebdavResource.java

/**
 * Get the activelock owners for this resource.
 *
 * @return An enumeration of owners.//from w  ww .j ava  2s . c  om
 */
public Enumeration getActiveLockOwners() {
    if (lockDiscovery == null)
        return null;
    Lock[] activeLocks = lockDiscovery.getActiveLocks();
    if (activeLocks == null)
        return null;
    Vector buff = new Vector();
    int count = activeLocks.length;
    for (int i = 0; i < count; i++) {
        buff.addElement(activeLocks[i].getOwner());
    }
    return buff.elements();
}

From source file:edu.ku.brc.dbsupport.ImportExportDB.java

@SuppressWarnings("unchecked")
    protected void singleXMLImport(Element dbImport, String dbTable, String parentName, long parentId, int id,
            boolean recursion) {
        try {/* w  w  w  .jav a2s.  c  om*/
            DBTableInfo parentInfo = DBTableIdMgr.getInstance().getInfoByTableName(dbTable.toLowerCase());
            String lowerdbTable = lowerFirstChar(dbTable);
            String primaryKey = parentInfo.getPrimaryKeyName();

            Vector collectionIds = new Vector(20);
            Vector collectionNames = new Vector(20);
            // make the agent and the element
            Object agent = parentInfo.getClassObj().newInstance();
            Map<String, Object> agentMap = new HashMap<String, Object>();
            Element dbElement = dbImport;
            Iterator i = dbElement.elementIterator();
            do {// do for each element in the record
                Element element = (Element) i.next();

                Object value = findTypeSequential(element, dbTable, parentId, parentName);// the
                                                                                          // parent
                                                                                          // is
                                                                                          // itself,
                                                                                          // just
                                                                                          // a
                                                                                          // dummy
                                                                                          // variable
                                                                                          // if(value!=null && value != "collection")
                if (value != null && value != "OneToMany" && value != "ManyToMany") //$NON-NLS-1$ //$NON-NLS-2$
                {
                    agentMap.put(element.getName(), value);
                }
                // ignore many-to-many for now
                else if (recursion && (value == "OneToMany" || value == "ManyToMany")) //$NON-NLS-1$ //$NON-NLS-2$
                {// RECURSE
                 // get assoicated ids
                    List temp_collection_ids = element.selectNodes("//" + dbTable + "[" //$NON-NLS-1$ //$NON-NLS-2$
                            + primaryKey + " = \"" + id + "\"]/" + element.getName() + "/*"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    // get collection info and still dont add it
                    if (!temp_collection_ids.isEmpty()) {
                        // get child dbName
                        String childDbName = getDbName(temp_collection_ids);
                        collectionNames.addElement(childDbName);
                        for (int index = 0; index < temp_collection_ids.size(); index++) {
                            collectionIds.addElement(temp_collection_ids.get(index));
                        }
                    }
                } else
                // else, dont add it
                {
                    // if it is an id, just ignore. otherwise print out error
                    if (!element.getName().equals(lowerdbTable + "Id")) //$NON-NLS-1$
                    {
                        log.debug("did not add " + element.getName() + " to the element " //$NON-NLS-1$ //$NON-NLS-2$
                                + dbTable);
                    }
                }
            } while (i.hasNext());

            // populate and save
            BeanUtils.populate(agent, agentMap);

            this.session.save(agent);

            // if there was a collection, then recurse
            if (!collectionIds.isEmpty()) {
                long newParentId = new Long(session.getIdentifier(agent).toString()).longValue();

                sequentialXMLImportRecursion(collectionNames, collectionIds, dbTable, newParentId);
            }
        } catch (Exception ex) {
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ImportExportDB.class, ex);
            ex.printStackTrace();
        }
    }

From source file:edu.ku.brc.dbsupport.ImportExportDB.java

@SuppressWarnings("unchecked")
    protected Map buildSingleDataBaseObjectFromXMLTemp(Element dbImport, String dbTable, String parentName,
            long parentId, int id, boolean recursion) {
        //Object dbObject = new Object();
        Map<String, Object> agentMap = new HashMap<String, Object>();
        try {//w  w w  .  j  a  v  a 2s  . c  om
            DBTableInfo parentInfo = DBTableIdMgr.getInstance().getInfoByTableName(dbTable.toLowerCase());
            //String lowerdbTable = lowerFirstChar(dbTable);
            String primaryKey = parentInfo.getPrimaryKeyName();

            Vector collectionIds = new Vector(20);
            Vector collectionNames = new Vector(20);
            // make the agent and the element
            Object agent = parentInfo.getClassObj().newInstance();

            Element dbElement = dbImport;
            Iterator i = dbElement.elementIterator();
            do {// do for each element in the record
                Element element = (Element) i.next();

                // Object value = findTypeSequential(element, dbTable, parentId, parentName );//the
                // parent is itself, just a dummy variable
                Object value = findTypeDataBaseParent(element, dbTable, parentId, parentName);// the
                                                                                              // parent
                                                                                              // is
                                                                                              // itself,
                                                                                              // just
                                                                                              // a
                                                                                              // dummy
                                                                                              // variable
                if (value != null && value != "OneToMany" && value != "ManyToMany") //$NON-NLS-1$ //$NON-NLS-2$
                {
                    agentMap.put(element.getName(), value);
                }
                // ignore many-to-many for now
                else if (value == "OneToMany" || value == "ManyToMany") //$NON-NLS-1$ //$NON-NLS-2$
                {// RECURSE
                    if (recursion) {
                        // get assoicated ids
                        List temp_collection_ids = element.selectNodes("//" + dbTable + "[" //$NON-NLS-1$ //$NON-NLS-2$
                                + primaryKey + " = \"" + id + "\"]/" + element.getName() + "/*"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        // get collection info and still dont add it
                        if (!temp_collection_ids.isEmpty()) {
                            // get child dbName
                            String childDbName = getDbName(temp_collection_ids);
                            collectionNames.addElement(childDbName);
                            for (int index = 0; index < temp_collection_ids.size(); index++) {
                                collectionIds.addElement(temp_collection_ids.get(index));
                            }
                        }
                    }
                } else
                // else, dont add it
                {
                    // if it is an id, just ignore. otherwise print out error
                    if (!element.getName().equals(primaryKey)) {
                        log.debug("did not add " + element.getName() + " to the element " //$NON-NLS-1$ //$NON-NLS-2$
                                + dbTable);
                    }
                }
            } while (i.hasNext());

            // populate
            // BeanUtils.populate(agent, agentMap);
            // save it then gets its id (assigned by Hibernate)
            // this.session.save(agent);

            // if there was a collection, then recurse
            if (!collectionIds.isEmpty()) {
                long newParentId = new Long(session.getIdentifier(agent).toString()).longValue();

                sequentialXMLImportRecursion(collectionNames, collectionIds, dbTable, newParentId);
            }
            //dbObject = agent;
        } catch (Exception ex) {
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ImportExportDB.class, ex);
            ex.printStackTrace();
        }

        return agentMap;
    }

From source file:edu.ku.brc.dbsupport.ImportExportDB.java

@SuppressWarnings("unchecked")
    protected Object buildSingleDBObjectFromXML(Element dbImport, String dbTable, String parentName, long parentId,
            int id, boolean recursion) {
        Object dbObject = new Object();
        try {/* ww  w  . j a v a  2  s .com*/
            DBTableInfo parentInfo = DBTableIdMgr.getInstance().getInfoByTableName(dbTable.toLowerCase());
            String primaryKey = parentInfo.getPrimaryKeyName();

            Vector collectionIds = new Vector(20);
            Vector collectionNames = new Vector(20);
            // make the agent and the element
            Object agent = parentInfo.getClassObj().newInstance();
            Map<String, Object> agentMap = new HashMap<String, Object>();
            Element dbElement = dbImport;
            Iterator i = dbElement.elementIterator();
            do {// do for each element in the record
                Element element = (Element) i.next();

                // Object value = findTypeSequential(element, dbTable, parentId, parentName );//the
                // parent is itself, just a dummy variable
                Object value = findTypeRecordSet(element, dbTable, parentId, parentName);// the
                                                                                         // parent
                                                                                         // is
                                                                                         // itself,
                                                                                         // just
                                                                                         // a
                                                                                         // dummy
                                                                                         // variable
                if (value != null && value != "OneToMany" && value != "ManyToMany") //$NON-NLS-1$ //$NON-NLS-2$
                {
                    agentMap.put(element.getName(), value);
                }
                // ignore many-to-many for now
                else if (value == "OneToMany" || value == "ManyToMany") //$NON-NLS-1$ //$NON-NLS-2$
                {// RECURSE
                    if (recursion) {
                        // get assoicated ids
                        List temp_collection_ids = element.selectNodes("//" + dbTable + "[" //$NON-NLS-1$ //$NON-NLS-2$
                                + primaryKey + " = \"" + id + "\"]/" + element.getName() + "/*"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        // get collection info and still dont add it
                        if (!temp_collection_ids.isEmpty()) {
                            // get child dbName
                            String childDbName = getDbName(temp_collection_ids);
                            collectionNames.addElement(childDbName);
                            for (int index = 0; index < temp_collection_ids.size(); index++) {
                                collectionIds.addElement(temp_collection_ids.get(index));
                            }
                        }
                    }
                } else
                // else, dont add it
                {
                    // if it is an id, just ignore. otherwise print out error
                    if (!element.getName().equals(primaryKey)) {
                        log.debug("did not add " + element.getName() + " to the element " //$NON-NLS-1$ //$NON-NLS-2$
                                + dbTable);
                    }
                }
            } while (i.hasNext());

            // populate
            BeanUtils.populate(agent, agentMap);
            // save it then gets is id (assigned by Hibernate)
            this.session.save(agent);

            // if there was a collection, then recurse
            if (!collectionIds.isEmpty()) {
                long newParentId = new Long(session.getIdentifier(agent).toString()).longValue();

                sequentialXMLImportRecursion(collectionNames, collectionIds, dbTable, newParentId);
            }
            dbObject = agent;
        } catch (Exception ex) {
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ImportExportDB.class, ex);
            ex.printStackTrace();
        }

        return dbObject;
    }