Example usage for java.util Collection toString

List of usage examples for java.util Collection toString

Introduction

In this page you can find the example usage for java.util Collection toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.datacleaner.test.full.scenarios.AnalyzeDateGapsCompareSchemasAndSerializeResultsTest.java

private void performResultAssertions(AnalysisJob job, AnalysisResult result) {
    assertEquals(1, result.getResults().size());

    Collection<ComponentJob> componentJobs = result.getResultMap().keySet();
    componentJobs = CollectionUtils2.sorted(componentJobs, ObjectComparator.getComparator());

    assertEquals("[ImmutableAnalyzerJob[name=date gap job,analyzer=Date gap analyzer]]",
            componentJobs.toString());

    // using the original component jobs not only asserts that these exist
    // in the result, but also that the their deserialized clones are equal
    // (otherwise the results cannot be retrieved from the result map).
    final AnalyzerJob analyzerJob = job.getAnalyzerJobs().iterator().next();

    final AnalyzerResult analyzerResult = result.getResult(analyzerJob);
    assertNotNull(analyzerResult);//w w w .j  av  a  2  s.  c o  m
    assertEquals("DateGapAnalyzerResult[gaps={121=[], 128=[], 141=[], 181=[], 363=[]}]",
            analyzerResult.toString());
}

From source file:nl.opengeogroep.filesetsync.client.SyncJobStatePersistence.java

private void cleanup() {
    Collection<String> statesToRemove = new ArrayList();
    for (String name : states.keySet()) {
        if (SyncConfig.getInstance().getFileset(name) == null) {
            statesToRemove.add(name);/* www. j a v  a2s .  c om*/
        }
    }
    log.debug("Removing states for filesets not in config file: " + statesToRemove.toString());
    states.keySet().removeAll(statesToRemove);
}

From source file:com.javaforge.tapestry.acegi.service.impl.SecurityUtilsImpl.java

public void checkSecurity(Object object, Collection<ConfigAttribute> attr) {
    Assert.notNull(object, "Object was null");

    if (attr != null) {
        if (getLog().isDebugEnabled()) {
            getLog().debug("Secure object: " + object.toString() + "; ConfigAttributes: " + attr.toString());
        }/*from   w ww . j  a v a2  s .  co  m*/

        // We check for just the property we're interested in (we do
        // not call Context.validate() like the ContextInterceptor)
        if (SecurityContextHolder.getContext().getAuthentication() == null) {
            throw new AuthenticationCredentialsNotFoundException(
                    messages.getMessage("AbstractSecurityInterceptor.authenticationNotFound",
                            "An Authentication object was not found in the SecurityContext"));
        }

        // Attempt authentication if not already authenticated, or user always wants reauthentication
        Authentication authenticated;

        SecurityContext ctx = SecurityContextHolder.getContext();

        if (ctx.getAuthentication() == null || !ctx.getAuthentication().isAuthenticated()
                || alwaysReauthenticate) {
            authenticated = this.authenticationManager
                    .authenticate(SecurityContextHolder.getContext().getAuthentication());

            // We don't authenticated.setAuthentication(true), because each provider should do that
            if (getLog().isDebugEnabled()) {
                getLog().debug("Successfully Authenticated: " + authenticated.toString());
            }

            SecurityContextHolder.getContext().setAuthentication(authenticated);
        } else {
            authenticated = SecurityContextHolder.getContext().getAuthentication();

            if (getLog().isDebugEnabled()) {
                getLog().debug("Previously Authenticated: " + authenticated.toString());
            }
        }

        // Attempt authorization
        this.accessDecisionManager.decide(authenticated, object, attr);

        if (getLog().isDebugEnabled()) {
            getLog().debug("Authorization successful");
        }

        // Attempt to run as a different user
        Authentication runAs = this.runAsManager.buildRunAs(authenticated, object, attr);

        if (runAs == null) {
            if (getLog().isDebugEnabled()) {
                getLog().debug("RunAsManager did not change Authentication object");
            }
        } else {
            if (getLog().isDebugEnabled()) {
                getLog().debug("Switching to RunAs Authentication: " + runAs.toString());
            }
            SecurityContextHolder.getContext().setAuthentication(runAs);
        }
    } else {
        if (getLog().isDebugEnabled()) {
            getLog().debug("Public object - authentication not attempted");
        }
    }
}

From source file:net.solarnetwork.node.job.DatumDataSourceManagedLoggerJob.java

private void persistDatum(Collection<T> datumList) {
    if (datumList == null || datumList.size() < 1) {
        return;/*  w  w  w.  j  av  a2 s  .c om*/
    }
    if (log.isInfoEnabled()) {
        log.info("Got Datum to persist: {}",
                (datumList.size() == 1 ? datumList.iterator().next().toString() : datumList.toString()));
    }
    DatumDao<T> dao = datumDao.service();
    if (dao == null) {
        log.info("No DatumDao available to persist {}, not saving", datumList);
        return;
    }
    for (T datum : datumList) {
        try {
            dao.storeDatum(datum);
            log.debug("Persisted Datum {}", datum);
        } catch (DuplicateKeyException e) {
            // we ignore duplicate key exceptions, as we sometimes collect the same 
            // datum multiple times for redundancy
            log.info("Duplicate datum {}; not persisting", datum);
        }
    }
}

From source file:de.huberlin.wbi.hiway.scheduler.Scheduler.java

public void updateRuntimeEstimates(String runId) {
    System.out.println("Updating Runtime Estimates.");

    System.out.println("HiwayDB: Querying Host Names from database.");
    Collection<String> newHostIds = dbInterface.getHostNames();
    System.out.println("HiwayDB: Retrieved Host Names " + newHostIds.toString() + " from database.");
    newHostIds.removeAll(getNodeIds());//from w w w.java2  s  . co m
    for (String newHostId : newHostIds) {
        newHost(newHostId);
    }
    System.out.println("HiwayDB: Querying Task Ids for workflow " + workflowName + " from database.");
    Collection<Long> newTaskIds = dbInterface.getTaskIdsForWorkflow(workflowName);
    System.out.println("HiwayDB: Retrieved Task Ids " + newTaskIds.toString() + " from database.");

    newTaskIds.removeAll(getTaskIds());
    for (long newTaskId : newTaskIds) {
        newTask(newTaskId);
    }

    for (String hostName : getNodeIds()) {
        long oldMaxTimestamp = maxTimestampPerHost.get(hostName);
        long newMaxTimestamp = oldMaxTimestamp;
        for (long taskId : getTaskIds()) {
            System.out.println("HiwayDB: Querying InvocStats for task id " + taskId + " on host " + hostName
                    + " since timestamp " + oldMaxTimestamp + " from database.");
            Collection<InvocStat> invocStats = dbInterface.getLogEntriesForTaskOnHostSince(taskId, hostName,
                    oldMaxTimestamp);
            System.out.println("HiwayDB: Retrieved InvocStats " + invocStats.toString() + " from database.");
            for (InvocStat stat : invocStats) {
                newMaxTimestamp = Math.max(newMaxTimestamp, stat.getTimestamp());
                updateRuntimeEstimate(stat);
                if (!runId.equals(stat.getRunId())) {
                    numberOfPreviousRunTasks++;
                    numberOfFinishedTasks++;
                }
            }
        }
        maxTimestampPerHost.put(hostName, newMaxTimestamp);
    }
}

From source file:com.pinterest.clusterservice.handler.ClusterHandler.java

public void termianteHosts(String clusterName, Collection<String> hostIds, boolean replaceHost)
        throws Exception {
    ClusterBean clusterBean = clusterDAO.getByClusterName(clusterName);
    if (clusterBean.getProvider() == CloudProvider.AWS) {
        LOG.info(String.format("Start to termiante AWS VM hosts %s from cluster %s", hostIds.toString(),
                clusterName));/*from www.  j a v  a 2s.co m*/
        ClusterManager clusterManager = createClusterManager(CloudProvider.AWS);
        if (replaceHost) {
            clusterManager.terminateHosts(clusterName, hostIds, true);
        } else {
            Collection<String> hostIdsInCluster = clusterManager.getHosts(clusterName, hostIds);
            int capacity = Math.min(clusterBean.getCapacity() - hostIdsInCluster.size(), 0);
            clusterManager.terminateHosts(clusterName, hostIdsInCluster, false);

            ClusterBean newBean = new ClusterBean();
            newBean.setCapacity(capacity);
            newBean.setLast_update(System.currentTimeMillis());
            clusterDAO.update(clusterName, newBean);
        }
    }
}

From source file:com.vmware.o11n.plugin.crypto.service.CryptoCertificateService.java

/**
 *
 * @param cert//from   ww w  . j  a va  2 s. com
 * @return
 * @throws CertificateParsingException
 */

public List<String> getSubjectAlternativeNames(X509Certificate cert) throws CertificateParsingException {
    ArrayList<String> toReturn = new ArrayList<>();
    Collection<List<?>> sans = cert.getSubjectAlternativeNames();
    if (sans != null) {
        if (log.isDebugEnabled()) {
            log.debug("Subject Alternative Names: " + sans.toString());
        }
        for (List<?> l : sans) {
            if (l.size() == 2) {
                Integer type = (Integer) l.get(0);
                if (type.equals(new Integer(2))) {
                    //DNS SAN
                    String value = (String) l.get(1);
                    toReturn.add("dns:" + value);
                } else {
                    String message = "SAN type '" + sanType.get(type) + "' not implemented";
                    log.warn(message);
                }
            } else {
                log.error("expected subject alternatives names object to have only 2 elements but " + l.size()
                        + " elements were present");
            }
        }
    } else if (log.isDebugEnabled()) {
        log.debug("Empty Subject Alternative Names");
    }
    return toReturn;
}

From source file:org.apache.maven.index.FullIndexNexusIndexerTest.java

public void testArchetype() throws Exception {
    String term = "proptest";

    Query bq = new PrefixQuery(new Term(ArtifactInfo.GROUP_ID, term));
    TermQuery tq = new TermQuery(new Term(ArtifactInfo.PACKAGING, "maven-archetype"));
    Query query = new FilteredQuery(tq, new QueryWrapperFilter(bq));

    FlatSearchResponse response = nexusIndexer.searchFlat(new FlatSearchRequest(query));

    Collection<ArtifactInfo> r = response.getResults();

    assertEquals(r.toString(), 1, r.size());
}

From source file:com.abiquo.vsm.resource.AbstractResource.java

/**
 * Get the allowed http methods for the current resource.
 * /*from   w w w.j av a  2  s.  c om*/
 * @return The allowed http methods for the current resource.
 */
protected String getMethodsAllowed() {
    Collection<String> allowed = new LinkedHashSet<String>();
    for (Method method : this.getClass().getMethods()) {
        for (Annotation annotation : method.getAnnotations()) {
            if (REST.contains(annotation.annotationType())) {
                allowed.add(annotation.annotationType().getSimpleName());
                break;
            }
        }
    }

    return allowed.toString();
}

From source file:org.kuali.rice.devtools.jpa.eclipselink.conv.parser.helper.resolver.CustomizerResolver.java

@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }//from   w  ww . j  av a 2s . co  m

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
        //handling nested classes
        return null;
    }
    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String enclosingClass = pckg + "." + name;
    final Collection<String> customizedFieldsOnNode = getFieldsOnNode(dclr, getCustomizedFields(mappedClass));
    if (customizedFieldsOnNode == null || customizedFieldsOnNode.isEmpty()) {
        LOG.info(ResolverUtil.logMsgForClass(enclosingClass, mappedClass) + " has no customized fields");
        return null;
    }
    return new NodeData(
            new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME),
                    new NameExpr("CreateCustomizerFor" + customizedFieldsOnNode.toString())),
            new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}