List of usage examples for java.util LinkedHashSet LinkedHashSet
public LinkedHashSet()
From source file:com.adobe.cq.wcm.core.components.internal.models.v1.PageListItemImpl.java
private Page getRedirectTarget(@Nonnull Page page) { Page result = page;//w ww . ja va2 s .com String redirectTarget; PageManager pageManager = page.getPageManager(); Set<String> redirectCandidates = new LinkedHashSet<>(); redirectCandidates.add(page.getPath()); while (result != null && StringUtils.isNotEmpty( (redirectTarget = result.getProperties().get(PageImpl.PN_REDIRECT_TARGET, String.class)))) { result = pageManager.getPage(redirectTarget); if (result != null) { if (!redirectCandidates.add(result.getPath())) { LOGGER.warn("Detected redirect loop for the following pages: {}.", redirectCandidates.toString()); break; } } } return result; }
From source file:net.bryansaunders.jee6divelog.service.rest.UserAccountApiIT.java
/** * Test registerUser with Valid User.//from www. j a v a 2 s.co m */ @Test @UsingDataSet("Empty.yml") public void ifUserValidThenRegister() { final UserAccount newUser = new UserAccount(); newUser.setFirstName("Test"); newUser.setLastName("Testerson"); newUser.setEmail("ifUserValidThenRegister@test.com"); newUser.setPassword(VALID_PASSWORD); newUser.setPermissions(new LinkedHashSet<Permission>()); newUser.setCreated(new Date()); newUser.setUpdated(new Date()); given().contentType(ContentType.JSON).body(newUser).expect().statusCode(HttpStatus.SC_CREATED).when() .post(RestApiTest.URL_ROOT + "/user/register/"); }
From source file:ws.salient.model.Settings.java
public Set<RemoteRepository> getRemoteRepositories(Collection<String> profileIds) { Set<RemoteRepository> repositories = new LinkedHashSet(); getProfiles(profileIds).forEach(profile -> { profile.getRepositories().forEach((repository) -> { repositories.add(repository.toRemoteRepository()); });//from w w w.j a va 2s .co m }); return repositories; }
From source file:com.qwazr.server.ServletContextBuilder.java
ServletContextBuilder(ClassLoader classLoader, String contextPath, String defaultEncoding, String contextName, String jmxName) {/*from ww w . j av a 2s.c o m*/ setClassLoader(classLoader); setContextPath(contextPath == null ? "/" : contextPath); setDefaultEncoding(defaultEncoding == null ? "UTF-8" : defaultEncoding); setDeploymentName(contextName); this.jmxName = jmxName; this.endPoints = new LinkedHashSet<>(); }
From source file:org.eel.kitchen.jsonschema.validator.JsonResolver.java
/** * Resolve a schema node to the target schema node * * @see SchemaRegistry#get(URI)//from ww w . ja v a 2s . c o m * * @param schemaNode the original schema node * @return the computed schema node * @throws JsonSchemaException ref resolution failure (dangling ref, ref * loop, etc) */ SchemaNode resolve(final SchemaNode schemaNode) throws JsonSchemaException { /* * All failures at this level are fatal */ final Message.Builder msg = Domain.REF_RESOLVING.newMessage().setKeyword("$ref").setFatal(true); /* * These two elements might change during ref resolving. Set them to * their initial values. */ SchemaContainer container = schemaNode.getContainer(); JsonNode node = schemaNode.getNode(); /* * This set will store all ABSOLUTE JSON references we encounter * during ref resolution. If there is an attempt to store an already * existing reference, this means a ref loop. * * We want to preserve insertion order, therefore we have to use a * LinkedHashSet. */ final Set<JsonRef> refs = new LinkedHashSet<JsonRef>(); /* * All elements below are set during the ref resolution process. */ JsonRef source, ref, target; JsonNode refNode; while (true) { /* * We break out immediately if either there is no $ref node, * or there exists one but it is not a text node (syntax validation * will catch that). */ refNode = node.path("$ref"); if (!refNode.isTextual()) break; /* * Similarly, the constructor will fail at this point iif the text * value of the node is not an URI: break, we want this caught by * syntax validation. */ try { ref = JsonRef.fromString(refNode.textValue()); } catch (JsonSchemaException ignored) { break; } /* * Compute the target ref. Try and insert it into the set of refs * already seen: if it has been already seen, there is a ref loop. */ source = container.getLocator(); target = source.resolve(ref); if (!refs.add(target)) { msg.setMessage("ref loop detected").addInfo("path", refs); throw new JsonSchemaException(msg.build()); } /* * Should we change schema context? We should if the source ref (the * one in the current container) does not contain the target ref. In * this case, get the new container from our schema registry. If we * cannot do that, this is an error condition, bail out. */ if (!source.contains(target)) container = registry.get(target.getLocator()); /* * Finally, compute the next node in the process. If it is missing, * we have a dangling JSON Pointer: this is an error condition. */ node = target.getFragment().resolve(container.getSchema()); if (node.isMissingNode()) { msg.setMessage("dangling JSON Reference").addInfo("ref", target); throw new JsonSchemaException(msg.build()); } } return new SchemaNode(container, node); }
From source file:com.bstek.dorado.core.io.SpringResourceLoaderAdapter.java
public Resource[] getResources(String locationPattern) throws IOException { Set<Resource> resourceSet = new LinkedHashSet<Resource>(); String[] patterns = locationPattern.split(LOCATION_SEPARATOR); for (String pattern : patterns) { if (StringUtils.isNotBlank(pattern)) { pattern = transformLocation(pattern); resourceSet.addAll(getResourcesBySinglePattern(pattern)); }/* w w w. j ava2 s. c om*/ } Resource[] resources = new Resource[resourceSet.size()]; resourceSet.toArray(resources); return resources; }
From source file:de.vandermeer.skb.interfaces.antlr.IsSTGroup.java
/** * Validates the STGroup for expected chunks. * @return a set of error messages, empty if no errors found, null if no expected chunks where set or no STGroup was set *//* w w w . j a va 2 s. c o m*/ default Set<String> validate() { if (this.getExpectedChunks() == null) { return null; } if (this.getSTGroup() == null) { return null; } STGroup stg = this.getSTGroup(); Set<String> ret = new LinkedHashSet<>(); for (Entry<String, Set<String>> entry : this.getExpectedChunks().entrySet()) { if (entry.getKey() != null && !"".equals(entry.getKey())) { if (stg.isDefined(entry.getKey())) { IsST isst = IsST.create(stg.getInstanceOf(entry.getKey()), entry.getValue()); for (String s : isst.validate()) { ret.add("STGroup <" + this.getGroupName() + ">: " + s); } } else { ret.add("STGroup <" + this.getGroupName() + "> does not define expected template <" + entry.getKey() + ">"); } } } return ret; }
From source file:org.ahp.vinavidai.validator.ForgotPasswordValidator.java
/** * /*from w w w.ja v a 2 s . c om*/ * @param pLoginName * @param pErrorKeyPrefix * @return */ public Set<String> validateLoginName(String pLoginName, String pErrorKeyPrefix) { Set<String> lErrorKeySet = new LinkedHashSet<String>(); lErrorKeySet.addAll(validateEmailAddress(pLoginName, REGISTRATION_USER_ERROR_KEY_PREFIX)); User lUser = new User(); lUser.setLoginName(pLoginName); if (!this.mRegistrationService.doesUserExist(lUser)) { lErrorKeySet.add(pErrorKeyPrefix + ".email.not.exists"); } return lErrorKeySet; }
From source file:facebook4j.TargetingParameter.java
public TargetingParameter region(String region) { if (regions == null) { regions = new LinkedHashSet<String>(); }/* w w w . j a va2s . c o m*/ regions.add(region); return this; }
From source file:com.googlecode.vcsupdate.TeamCityController.java
private ModelAndView getModelAndView(HttpServletRequest request, HttpServletResponse response) { // Get all of the VCS roots specified in the request Set<SVcsRoot> roots = new LinkedHashSet<SVcsRoot>(); // Start by getting any root names from the request String[] names = request.getParameterValues(NAME_PARAM); if (names != null) { for (String name : names) { SVcsRoot root = vcsManager.findRootByName(name); if (root != null) roots.add(root);// ww w. ja v a2 s.c o m } } // Then look for any root IDs String[] ids = request.getParameterValues(ID_PARAM); if (ids != null) { for (String id : ids) { try { SVcsRoot root = vcsManager.findRootById(Long.parseLong(id)); if (root != null) roots.add(root); } catch (NumberFormatException e) { // just move on to the next ID } } } // Finally, if the request is a POST but we've found no roots, it may be // due to bugs in some POST handling libraries. In this case, we'll // update all of the roots. if (names == null && ids == null && request.getMethod().equals("POST")) { roots.addAll(vcsManager.getAllRegisteredVcsRoots()); } // Did we get a submitted form? if (!roots.isEmpty()) { List<String> forcedVcsRootNames = new ArrayList<String>(); // Iterate through the roots for (SVcsRoot root : roots) { // Find the matching configurations List<SBuildType> builds = vcsManager.getAllConfigurationUsages(root); if (builds == null) continue; // Select the best configuration SBuildType selected = null; List<SVcsRoot> selectedRoots = null; for (SBuildType build : builds) { if (!build.isPaused() && !build.isPersonal()) { List<SVcsRoot> buildRoots = build.getVcsRoots(); if (selected == null || buildRoots.size() < selectedRoots.size()) { selected = build; selectedRoots = buildRoots; } } } // Did we find a match? if (selected == null) continue; // Kick off the modification check boolean defaultInterval = root.isUseDefaultModificationCheckInterval(); int interval = (defaultInterval ? -1 : root.getModificationCheckInterval()); root.setModificationCheckInterval(5); log("Forcing check for " + selected.getName()); selected.forceCheckingForChanges(); forcedVcsRootNames.add(root.getName()); if (defaultInterval) { root.restoreDefaultModificationCheckInterval(); } else { root.setModificationCheckInterval(interval); } } // Redirect to the done page String modelObject = forcedVcsRootNames.toString(); return new ModelAndView(doneViewName, "updatedVCSRoots", modelObject); } // Build a sample URL StringBuilder sampleUrl = new StringBuilder(); sampleUrl.append(request.getRequestURL()).append('?'); boolean appendedRoot = false; // Append the list of available roots List<SVcsRoot> list = vcsManager.getAllRegisteredVcsRoots(); if (list != null) { for (SVcsRoot root : list) { if (appendedRoot) sampleUrl.append('&'); sampleUrl.append(NAME_PARAM).append('=').append(root.getName()); appendedRoot = true; } } // If we didn't get any roots, use a sample name if (!appendedRoot) { sampleUrl.append(NAME_PARAM).append('=').append(SAMPLENAME); } // Return a simple view that explains how to use the tool String query = request.getQueryString(); if (query != null) sampleUrl.append('&').append(query); String modelObject = response.encodeURL(sampleUrl.toString()); log("Creating modelview. View: " + viewName + " and model: " + modelObject); return new ModelAndView(viewName, "sampleUrl", modelObject); }