List of usage examples for java.util Set toString
public String toString()
From source file:org.apache.sling.jcr.repository.it.CommonTests.java
@Test public void testOsgiResourceEvents() throws RepositoryException { final ResourceEventListener listener = new ResourceEventListener(); final ServiceRegistration reg = listener.register(bundleContext, SlingConstants.TOPIC_RESOURCE_ADDED); final Session s = repository.loginAdministrative(null); final int nPaths = 2500 * TEST_SCALE; final int timeoutMsec = 2 * nPaths; final String prefix = uniqueName("testOsgiResourceEvents"); // Create N nodes with a unique name under / // and verify that ResourceEventListener gets an event // for each of them try {// w w w . j av a 2s . c o m for (int i = 0; i < nPaths; i++) { s.getRootNode().addNode(prefix + i); } s.save(); log.info("Added {} nodes, checking what ResourceEventListener got...", nPaths); final long timeout = System.currentTimeMillis() + timeoutMsec; final Set<String> missing = new HashSet<String>(); while (System.currentTimeMillis() < timeout) { missing.clear(); final Set<String> paths = listener.getPaths(); for (int i = 0; i < nPaths; i++) { final String path = "/" + prefix + i; if (!paths.contains(path)) { missing.add(path); } } if (missing.isEmpty()) { break; } } if (!missing.isEmpty()) { final String missingStr = missing.size() > 10 ? missing.size() + " paths missing" : missing.toString(); fail("OSGi add resource events are missing for " + missing.size() + "/" + nPaths + " paths after " + timeoutMsec + " msec: " + missingStr); } } finally { reg.unregister(); s.logout(); } log.info("Successfuly detected OSGi observation events for " + nPaths + " paths"); }
From source file:com.globalsight.everest.webapp.pagehandler.projects.workflows.WorkflowHandlerHelper.java
public static void zippedFolder(HttpServletRequest p_request, HttpServletResponse p_response, long companyId, Set<Long> jobIdSet, Set<File> exportListFiles, Set<String> locales) { String zipFileName = AmbFileStoragePathUtils.getReportsDir(companyId) + File.separator + ReportConstants.REPORT_QA_CHECKS_REPORT + ".zip"; File zipFile = new File(zipFileName); Map<File, String> entryFileToFileNameMap = getEntryFileToFileNameMap(exportListFiles, jobIdSet, locales, AmbFileStoragePathUtils.getReportsDir(companyId).getPath() + File.separator + ReportConstants.REPORT_QA_CHECKS_REPORT); try {//from w w w .j a va 2s . com ZipIt.addEntriesToZipFile(zipFile, entryFileToFileNameMap, ""); String downloadFileName = zipFile.getName(); if (entryFileToFileNameMap.entrySet().size() > 0) { if (jobIdSet != null && jobIdSet.size() == 1) { Long jobId = jobIdSet.iterator().next(); downloadFileName = ReportConstants.REPORT_QA_CHECKS_REPORT + "_(" + jobId + ").zip"; } else if (jobIdSet != null && jobIdSet.size() > 1) { String tempS = jobIdSet.toString(); String jobNamesstr = tempS.substring(1, tempS.length() - 1); downloadFileName = ReportConstants.REPORT_QA_CHECKS_REPORT + "_(" + jobNamesstr + ").zip"; } } else { downloadFileName = "No Report Download.zip"; } // write zip file to client p_response.setContentType("application/zip"); p_response.setHeader("Content-Disposition", "attachment; filename=\"" + downloadFileName + "\";"); if (p_request.isSecure()) { PageHandler.setHeaderForHTTPSDownload(p_response); } p_response.setContentLength((int) zipFile.length()); // Send the data to the client byte[] inBuff = new byte[4096]; FileInputStream fis = new FileInputStream(zipFile); int bytesRead = 0; while ((bytesRead = fis.read(inBuff)) != -1) { p_response.getOutputStream().write(inBuff, 0, bytesRead); } if (bytesRead > 0) { p_response.getOutputStream().write(inBuff, 0, bytesRead); } fis.close(); FileUtil.deleteFile(zipFile); } catch (Exception e) { logger.error(e); } finally { if (zipFile.exists()) zipFile.deleteOnExit(); } }
From source file:com.simpligility.maven.plugins.androidndk.phase05compile.NdkBuildMojo.java
/** * @throws MojoExecutionException//from w w w.j a va 2 s . c om * @throws MojoFailureException */ public void execute() throws MojoExecutionException, MojoFailureException { if (skip) { getLog().info("Skipping execution as per configuration"); return; } if (!attachLibrariesArtifacts && NativeHelper.isNativeArtifactProject(project)) { getLog().warn("Configured to not attach artifacts, this may cause an error at install/deploy time"); } // Validate the NDK final File ndkBuildFile = new File(getAndroidNdk().getNdkBuildPath()); NativeHelper.validateNDKVersion(ndkBuildFile.getParentFile()); validateMakefile(project, makefile); final String[] resolvedNDKArchitectures = NativeHelper.getNdkArchitectures(architectures, applicationMakefile, project.getBasedir()); // Resolve all dependencies final Set<Artifact> nativeLibraryArtifacts = findNativeLibraryDependencies(); // If there are any static libraries the code needs to link to, include those in the make file final Set<Artifact> resolvedNativeLibraryArtifacts = getArtifactResolverHelper() .resolveArtifacts(nativeLibraryArtifacts); getLog().debug("resolveArtifacts found " + resolvedNativeLibraryArtifacts.size() + ": " + resolvedNativeLibraryArtifacts.toString()); CompileCommand compileCommand = new CompileCommand(); compileCommand.nativeLibraryDepedencies = resolvedNativeLibraryArtifacts; compileCommand.resolvedArchitectures = resolvedNDKArchitectures; setupOutputDirectories(compileCommand); compile(compileCommand); }
From source file:act.installer.metacyc.OrganismCompositionMongoWriter.java
private String singletonSet2Str(Set<String> ecnums, String metadata) { switch (ecnums.size()) { case 0://from w w w . j a v a 2 s .c o m return ""; case 1: return ecnums.toArray(new String[0])[0]; default: return ecnums.toString(); // e.g., [2.7.1.74 , 2.7.1.76 , 2.7.1.145] for http://www.metacyc.org/META/NEW-IMAGE?object=DEOXYADENOSINE-KINASE-RXN } }
From source file:br.com.bluesoft.pronto.controller.TicketController.java
private void definirTestadores(final Ticket ticket, final String[] testador) throws SegurancaException { final Set<Usuario> testadoresAntigos = new TreeSet<Usuario>( ticketDao.listarTestadoresDoTicket(ticket.getTicketKey())); if (testador != null && testador.length > 0) { ticket.setTestadores(new TreeSet<Usuario>()); for (final String username : testador) { ticket.addTestador(usuarioDao.obter(username)); }//from w w w .j av a 2 s . co m } final String testadoresAntigosStr = testadoresAntigos == null || testadoresAntigos.size() == 0 ? "nenhum" : testadoresAntigos.toString(); final String testadoresNovosStr = ticket.getTestadores() == null || ticket.getTestadores().size() == 0 ? "nenhum" : ticket.getTestadores().toString(); if (!testadoresAntigosStr.equals(testadoresNovosStr)) { ticket.addLogDeAlteracao("testadores", testadoresAntigosStr, testadoresNovosStr); } }
From source file:com.github.mbenson.privileged.weaver.FilesystemWeaver.java
/** * Clear the way by deleting classfiles woven with a different * {@link Policy}.//from ww w . j a v a2s . com * * @throws NotFoundException */ public void prepare() throws NotFoundException { info("preparing %s; policy = %s", target, policy); final Set<File> toDelete = new TreeSet<File>(); for (final Class<?> type : getDeclaringClasses(findPrivilegedMethods())) { final CtClass ctClass = classPool.get(type.getName()); final String policyValue = toString(ctClass.getAttribute(generateName(POLICY_NAME))); if (policyValue == null || policyValue.equals(policy.name())) { continue; } debug("class %s previously woven with policy %s", type.getName(), policyValue); final File packageDir = new File(target, StringUtils.replaceChars(ctClass.getPackageName(), '.', File.separatorChar)); // simple classname of outermost class, plus any inner classes: final String pattern = new StringBuilder(getOutermost(type).getSimpleName()).append("(\\$.+)??\\.class") .toString(); debug("searching %s for pattern '%s'", packageDir.getAbsolutePath(), pattern); toDelete.addAll(FileUtils.listFiles(packageDir, new RegexFileFilter(pattern), null)); } if (toDelete.isEmpty()) { return; } info("Deleting %s files...", toDelete.size()); debug(toDelete.toString()); for (File f : toDelete) { if (!f.delete()) { debug("Failed to delete %s", f); } } }
From source file:uk.ac.imperial.presage2.core.simulator.RunnableSimulation.java
protected void loadParameters(Map<String, String> provided) throws IllegalArgumentException, IllegalAccessException, UndefinedParameterException { // collect parameters from field annotations loadParametersFromFields();//from ww w .j a v a 2s . c om // fill out given parameters Set<String> missing = new HashSet<String>(); Set<String> unknown = new HashSet<String>(); for (DeclaredParameter p : parameters) { if (provided.containsKey(p.name)) { p.setValue(provided.get(p.name)); provided.remove(p.name); } else if (!p.optional) { missing.add(p.name); } logger.debug("Parameter: " + p.name + "=" + p.stringValue); } // check for unknown or missing parameters unknown.addAll(provided.keySet()); String error = ""; if (missing.size() > 0) { error += "Required parameters not specified: " + missing.toString() + "; "; } if (unknown.size() > 0) { error += "Undefined parameters specified: " + unknown.toString() + ";"; } if (error.length() > 0) { throw new UndefinedParameterException(error); } }
From source file:com.simpligility.maven.plugins.androidndk.phase05compile.NdkBuildMojo.java
private Set<Artifact> findNativeLibraryDependencies() throws MojoExecutionException { final NativeHelper nativeHelper = getNativeHelper(); final Set<Artifact> staticLibraryArtifacts = nativeHelper.getNativeDependenciesArtifacts(false); final Set<Artifact> sharedLibraryArtifacts = nativeHelper.getNativeDependenciesArtifacts(true); final Set<Artifact> mergedArtifacts = new LinkedHashSet<Artifact>(); filterNativeDependencies(mergedArtifacts, staticLibraryArtifacts); filterNativeDependencies(mergedArtifacts, sharedLibraryArtifacts); getLog().debug("findNativeLibraryDependencies found " + mergedArtifacts.size() + ": " + mergedArtifacts.toString()); return mergedArtifacts; }
From source file:de.pixida.logtest.automatondefinitions.JsonAutomatonDefinition.java
private INodeDefinition.Type readTypeDefinedByDeprecatedFlags(final JSONObject node) { final Set<INodeDefinition.Flag> flags = new HashSet<>(); this.readDeprecatedFlag(node, JsonKey.NODE_INITIAL, INodeDefinition.Flag.IS_INITIAL, flags); this.readDeprecatedFlag(node, JsonKey.NODE_FAILURE, INodeDefinition.Flag.IS_FAILURE, flags); this.readDeprecatedFlag(node, JsonKey.NODE_SUCCESS, INodeDefinition.Flag.IS_SUCCESS, flags); if (flags.size() > 1) { throw new AutomatonLoadingException("A node can have only one type. Use property '" + JsonKey.NODE_TYPE.getKey() + "' instead of deprecated flag properties."); }//w w w . j av a 2 s .c o m if (flags.isEmpty()) { return null; } if (flags.contains(INodeDefinition.Flag.IS_INITIAL)) { return INodeDefinition.Type.INITIAL; } else if (flags.contains(INodeDefinition.Flag.IS_FAILURE)) { return INodeDefinition.Type.FAILURE; } else if (flags.contains(INodeDefinition.Flag.IS_SUCCESS)) { return INodeDefinition.Type.SUCCESS; } throw new RuntimeException("Internal error. No type for deprecated flag(s): " + flags.toString()); }
From source file:org.openmrs.User.java
/** * Returns all roles attributed to this user by expanding the role list to include the parents * of the assigned roles/*from w w w . j a v a 2 s. c o m*/ * * @return all roles (inherited from parents and given) for this user */ public Set<Role> getAllRoles() { // the user's immediate roles Set<Role> baseRoles = new HashSet<Role>(); // the user's complete list of roles including // the parent roles of their immediate roles Set<Role> totalRoles = new HashSet<Role>(); if (getRoles() != null) { baseRoles.addAll(getRoles()); totalRoles.addAll(getRoles()); } if (log.isDebugEnabled()) { log.debug("User's base roles: " + baseRoles); } try { for (Role r : baseRoles) { totalRoles.addAll(r.getAllParentRoles()); } } catch (ClassCastException e) { log.error("Error converting roles for user: " + this); log.error("baseRoles.class: " + baseRoles.getClass().getName()); log.error("baseRoles: " + baseRoles.toString()); Iterator<Role> iter = baseRoles.iterator(); while (iter.hasNext()) { log.error("baseRole: '" + iter.next() + "'"); } } return totalRoles; }