Example usage for java.util Collections unmodifiableCollection

List of usage examples for java.util Collections unmodifiableCollection

Introduction

In this page you can find the example usage for java.util Collections unmodifiableCollection.

Prototype

public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> c) 

Source Link

Document

Returns an unmodifiable view of the specified collection.

Usage

From source file:com.alfaariss.oa.engine.requestor.jdbc.JDBCFactory.java

/**
 * @see com.alfaariss.oa.engine.core.requestor.factory.IRequestorPoolFactory#getAllEnabledRequestors()
 *//*from  w w w  . ja v  a  2 s  .  c om*/
@Override
public Collection<IRequestor> getAllEnabledRequestors() throws RequestorException {
    Collection<IRequestor> collRequestors = new Vector<IRequestor>();
    Connection oConnection = null;
    PreparedStatement oPreparedStatement = null;
    ResultSet rsRequestor = null;
    ResultSet rsProperties = null;
    try {
        oConnection = _oDataSource.getConnection();

        oPreparedStatement = oConnection.prepareStatement(_sQuerySelectAllEnabledRequestors);
        oPreparedStatement.setBoolean(1, true);
        rsRequestor = oPreparedStatement.executeQuery();

        while (rsRequestor.next()) {
            oPreparedStatement = oConnection.prepareStatement(_sQuerySelectRequestorProperties);
            oPreparedStatement.setString(1, rsRequestor.getString(JDBCRequestor.COLUMN_ID));
            rsProperties = oPreparedStatement.executeQuery();

            JDBCRequestor oJDBCRequestor = new JDBCRequestor(rsRequestor, rsProperties);
            IRequestor oRequestor = oJDBCRequestor.getRequestor();
            if (oRequestor != null)
                collRequestors.add(oRequestor);

            rsProperties.close();

            _logger.debug("Retrieved requestor: " + oRequestor);
        }
    } catch (SQLException e) {
        _logger.error("Can not read all enabled requestors from database", e);
        throw new RequestorException(SystemErrors.ERROR_RESOURCE_RETRIEVE);
    } catch (RequestorException e) {
        throw e;
    } catch (Exception e) {
        _logger.fatal("Internal error during retrieval of all enabled requestors", e);
        throw new RequestorException(SystemErrors.ERROR_INTERNAL);
    } finally {
        try {
            if (rsRequestor != null)
                rsRequestor.close();
        } catch (Exception e) {
            _logger.error("Could not close requestor resultset", e);
        }

        try {
            if (rsProperties != null)
                rsProperties.close();
        } catch (Exception e) {
            _logger.error("Could not close requestor properties resultset", e);
        }

        try {
            if (oPreparedStatement != null)
                oPreparedStatement.close();
        } catch (Exception e) {
            _logger.error("Could not close statement", e);
        }

        try {
            if (oConnection != null)
                oConnection.close();
        } catch (Exception e) {
            _logger.error("Could not close connection", e);
        }
    }

    return Collections.unmodifiableCollection(collRequestors);
}

From source file:com.atlassian.jira.user.util.UserUtilImpl.java

private Collection<Group> getGroupsWithUsePermissionAndNoAdminsitrativePermissions() {
    final Collection<Group> useGroups = new ArrayList<Group>(
            globalPermissionManager.getGroupsWithPermission(Permissions.USE));
    useGroups.removeAll(globalPermissionManager.getGroupsWithPermission(Permissions.ADMINISTER));
    useGroups.removeAll(globalPermissionManager.getGroupsWithPermission(Permissions.SYSTEM_ADMIN));
    return Collections.unmodifiableCollection(useGroups);
}

From source file:com.alfaariss.oa.engine.requestor.jdbc.JDBCFactory.java

/**
 * @see com.alfaariss.oa.engine.core.requestor.factory.IRequestorPoolFactory#getAllRequestors()
 *//*from   w  ww . j  av  a 2 s .com*/
@Override
public Collection<IRequestor> getAllRequestors() throws RequestorException {
    Collection<IRequestor> collRequestors = new Vector<IRequestor>();
    Connection oConnection = null;
    PreparedStatement oPreparedStatement = null;
    ResultSet rsRequestor = null;
    ResultSet rsProperties = null;
    try {
        oConnection = _oDataSource.getConnection();

        oPreparedStatement = oConnection.prepareStatement(_sQuerySelectAllRequestors);
        rsRequestor = oPreparedStatement.executeQuery();

        while (rsRequestor.next()) {
            oPreparedStatement = oConnection.prepareStatement(_sQuerySelectRequestorProperties);
            oPreparedStatement.setString(1, rsRequestor.getString(JDBCRequestor.COLUMN_ID));
            rsProperties = oPreparedStatement.executeQuery();

            JDBCRequestor oJDBCRequestor = new JDBCRequestor(rsRequestor, rsProperties);
            IRequestor oRequestor = oJDBCRequestor.getRequestor();
            if (oRequestor != null)
                collRequestors.add(oRequestor);

            rsProperties.close();

            _logger.debug("Retrieved requestor: " + oRequestor);
        }
    } catch (SQLException e) {
        _logger.error("Can not read all requestors from database", e);
        throw new RequestorException(SystemErrors.ERROR_RESOURCE_RETRIEVE);
    } catch (RequestorException e) {
        throw e;
    } catch (Exception e) {
        _logger.fatal("Internal error during retrieval of all requestors", e);
        throw new RequestorException(SystemErrors.ERROR_INTERNAL);
    } finally {
        try {
            if (rsRequestor != null)
                rsRequestor.close();
        } catch (Exception e) {
            _logger.error("Could not close requestor resultset", e);
        }

        try {
            if (rsProperties != null)
                rsProperties.close();
        } catch (Exception e) {
            _logger.error("Could not close requestor properties resultset", e);
        }

        try {
            if (oPreparedStatement != null)
                oPreparedStatement.close();
        } catch (Exception e) {
            _logger.error("Could not close statement", e);
        }

        try {
            if (oConnection != null)
                oConnection.close();
        } catch (Exception e) {
            _logger.error("Could not close connection", e);
        }
    }

    return Collections.unmodifiableCollection(collRequestors);
}

From source file:com.tesora.dve.tools.aitemplatebuilder.CorpusStats.java

public Collection<TableStats> getStatistics() {
    return Collections.unmodifiableCollection(corpusStats.values());
}

From source file:org.alfresco.repo.audit.AuditComponentTest.java

public void testAuditOverlimitProperties() throws Exception {
    final int OVERLIMIT_SIZE = 1500;
    final RetryingTransactionCallback<Void> testCallback = new RetryingTransactionCallback<Void>() {
        public Void execute() throws Throwable {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < OVERLIMIT_SIZE; i++) {
                sb.append("a");
            }/*from   w w w.j a v  a 2 s  . co m*/

            MLText mlTextValue = new MLText();
            mlTextValue.put(Locale.ENGLISH, sb.toString());

            HashMap<String, Serializable> map = new HashMap<String, Serializable>();
            map.put("String", sb.toString());
            MLText mlTextValue1 = new MLText();
            mlTextValue1.put(Locale.ENGLISH, sb.toString());
            map.put("MLText", mlTextValue1);

            ArrayList<Serializable> list = new ArrayList<Serializable>();
            list.add(sb.toString());
            MLText mlTextValue2 = new MLText();
            mlTextValue2.put(Locale.ENGLISH, sb.toString());
            list.add(mlTextValue2);

            Map<String, Serializable> values = new HashMap<String, Serializable>(13);
            values.put("/3.1/4.1", sb.toString());
            values.put("/3.1/4.2", mlTextValue);
            values.put("map", map);
            values.put("collection", list);
            values.put("unmodifiableCollection", (Serializable) Collections.unmodifiableCollection(list));

            auditComponent.recordAuditValues("/test/one.one/two.one", values);

            return null;
        }
    };
    RunAsWork<Void> testRunAs = new RunAsWork<Void>() {
        public Void doWork() throws Exception {
            return transactionService.getRetryingTransactionHelper().doInTransaction(testCallback);
        }
    };
    AuthenticationUtil.runAs(testRunAs, "SomeOtherUser");
}

From source file:com.redhat.rhn.domain.server.Server.java

/**
 * Returns a read-only collection of VirtualInstance objects.
 * @return A read-only collection of VirtualInstance objects.
 *///w  w  w  .  java2s.co m
public Collection<VirtualInstance> getGuests() {
    Set<VirtualInstance> retval = new HashSet<VirtualInstance>();
    for (VirtualInstance vi : getVirtualGuests()) {
        // Filter out the hosts that sometimes show up in this table.
        // Hosts have no UUID defined.
        if (vi.getUuid() != null) {
            retval.add(vi);
        }
    }
    return Collections.unmodifiableCollection(retval);
}

From source file:edu.ksu.cis.indus.tools.slicer.SlicerConfiguration.java

/**
 * Provides the id of the dependences to use for slicing.
 * //from w  w w. j ava2  s .  c  om
 * @return a collection of id of the dependence analyses.
 * @post result != null
 */
Collection<IDependencyAnalysis.DependenceSort> getIDsOfDAsToUse() {
    return Collections.unmodifiableCollection(dependencesToUse);
}

From source file:biz.wolschon.fileformats.gnucash.jwsdpimpl.GnucashFileImpl.java

/**
 *
 * @see biz.wolschon.fileformats.gnucash.GnucashFile#getTransactions()
 *///from www  .j  a  va 2  s . c o m
public Collection<? extends GnucashTransaction> getTransactions() {
    if (transactionid2transaction == null) {
        throw new IllegalStateException("no root-element loaded");
    }

    return Collections.unmodifiableCollection(transactionid2transaction.values());
}

From source file:com.github.helenusdriver.driver.impl.ClassInfoImpl.java

/**
 * Gets the tables info defined by the POJO.
 *
 * @author paouelle/*from  w  ww  .  j a v a  2s .co  m*/
 *
 * @return a collection of all defined tables info
 */
public Collection<TableInfoImpl<T>> getTables() {
    return Collections.unmodifiableCollection(tables.values());
}

From source file:net.sourceforge.fenixedu.domain.student.Student.java

public Collection<Registration> getAllRegistrations() {
    return Collections.unmodifiableCollection(super.getRegistrationsSet());
}