List of usage examples for java.util LinkedHashSet add
boolean add(E e);
From source file:org.apache.tajo.engine.planner.rewrite.ProjectionPushDownRule.java
@Override public LogicalNode visitPartitionedTableScan(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, PartitionedTableScanNode node, Stack<LogicalNode> stack) throws PlanningException { Context newContext = new Context(context); Target[] targets;//from www .j a v a2 s . com if (node.hasTargets()) { targets = node.getTargets(); } else { targets = PlannerUtil.schemaToTargets(node.getOutSchema()); } LinkedHashSet<Target> projectedTargets = Sets.newLinkedHashSet(); for (Iterator<Target> it = getFilteredTarget(targets, newContext.requiredSet); it.hasNext();) { Target target = it.next(); newContext.addExpr(target); } for (Iterator<Target> it = context.targetListMgr.getFilteredTargets(newContext.requiredSet); it .hasNext();) { Target target = it.next(); if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, target.getEvalTree(), node)) { projectedTargets.add(target); newContext.targetListMgr.markAsEvaluated(target); } } node.setTargets(projectedTargets.toArray(new Target[projectedTargets.size()])); LogicalPlanner.verifyProjectedFields(block, node); return node; }
From source file:com.github.richardwilly98.esdms.api.SearchTest.java
private Set<Document> getTestDocuments(int number) { LinkedHashSet<Document> docs = new LinkedHashSet<Document>(); for (int i = 0; i < number; i++) { String attributeKey = "attribute: " + i; String attributeValue = "value: " + i; String id = "id-" + i + " @time: " + System.currentTimeMillis(); String name = "name-" + i + " @time: " + System.currentTimeMillis(); String html = "<html><body><h1>This is document number: " + i + "</h1></body></html>"; byte[] content = html.getBytes(); Map<String, Object> attributes = newHashMap(); attributes.put(attributeKey, attributeValue); // DocumentTest document = new DocumentTest(new DocumentImpl(id, // name, new FileImpl(content, "test.html", "text/html"), // attributes)); Set<Version> versions = newHashSet(); versions.add(new VersionImpl.Builder().documentId(id).file(new FileImpl.Builder().content(content) .name("test" + i + ".html").contentType("text/html").build()).current(true).versionId(1) .build());//from ww w. ja va 2 s. com DocumentTest document = new DocumentTest(new DocumentImpl.Builder().versions(versions).id(id).name(name) .attributes(attributes).roles(null)); // DocumentTest document = new DocumentTest(new // DocumentImpl.Builder().file(new // FileImpl.Builder().content(content).name("test" + i + // ".html").contentType("text/html").build()).id(id).name(name).attributes(attributes).roles(null)); docs.add(document); } return docs; }
From source file:org.eclim.eclipse.EclimClasspathInitializer.java
private IClasspathEntry[] computeClasspathEntries(IJavaProject javaProject) { final ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>(); try {/*from www . java 2 s. c o m*/ final LinkedHashSet<String> bundleNames = new LinkedHashSet<String>(); final ArrayList<String> jarPaths = new ArrayList<String>(); final String projectPath = ProjectUtils.getPath(javaProject.getProject()); new File(projectPath).list(new FilenameFilter() { public boolean accept(File dir, String name) { if (name.startsWith("org.eclim")) { // first pull bundle dependencies from the manifest File manifest = new File(dir.getPath() + '/' + name + "/META-INF/MANIFEST.MF"); if (manifest.exists()) { FileInputStream fin = null; try { fin = new FileInputStream(manifest); HashMap<String, String> headers = new HashMap<String, String>(); ManifestElement.parseBundleManifest(fin, headers); String requiredBundles = headers.get("Require-Bundle"); for (String bname : requiredBundles.split(",\\s*")) { if (bname.startsWith("org.eclim")) { continue; } bundleNames.add(bname); } } catch (Exception e) { logger.error("Failed to load manifest: " + manifest, e); } finally { IOUtils.closeQuietly(fin); } } // then look for plugin jar files File lib = new File(dir.getPath() + '/' + name + "/lib"); if (lib.exists()) { for (String jar : lib.list()) { if (jar.endsWith(".jar")) { jarPaths.add(name + "/lib/" + jar); } } } } return false; } }); // load platform dependent swt jar CodeSource source = SWT.class.getProtectionDomain().getCodeSource(); if (source != null) { URL swt = source.getLocation(); if (swt != null) { logger.debug("adding swt to classpath: {}", swt.getPath()); Path path = new Path(swt.getPath()); list.add(JavaCore.newLibraryEntry(path, sourcePath(path), null, null, attributes(path), false)); } } for (String name : bundleNames) { logger.debug("adding bundle to classpath: {}", name); try { Bundle bundle = Platform.getBundle(name); if (bundle != null) { String pathName = FileLocator.getBundleFile(bundle).getPath(); Path path = new Path(pathName); list.add(JavaCore.newLibraryEntry(path, sourcePath(path), null, null, attributes(path), false)); if (path.toFile().isDirectory()) { listFiles(path.toFile(), new FileFilter() { public boolean accept(File file) { if (file.getName().endsWith(".jar")) { list.add(JavaCore.newLibraryEntry(new Path(file.getPath()), null, null, null, null, false)); } else if (file.isDirectory()) { listFiles(file, this); } return false; } }); } } } catch (IOException ioe) { logger.error("Failed to locate bundle: " + name, ioe); } } // some plugins need access to nested libraries extracted at build time, // handle adding those jars to the classpath here. listFiles(new File(projectPath + "/build/temp/lib"), new FileFilter() { public boolean accept(File file) { if (file.getName().endsWith(".jar")) { String jar = file.getPath().replace(projectPath, ""); if (jar.startsWith("/")) { jar = jar.substring(1); } jarPaths.add(jar); } if (file.isDirectory()) { listFiles(file, this); } return false; } }); for (String jarPath : jarPaths) { logger.debug("adding jar to classpath: {}", jarPath); list.add(JavaCore.newLibraryEntry(new Path(projectPath + '/' + jarPath), null, null, null, null, false)); } } catch (Exception e) { logger.error("Failed to load eclim classpath container", e); } return (IClasspathEntry[]) list.toArray(new IClasspathEntry[list.size()]); }
From source file:org.apache.tajo.engine.planner.rewrite.ProjectionPushDownRule.java
@Override public LogicalNode visitTableSubQuery(Context upperContext, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws PlanningException { Context childContext = new Context(plan, upperContext.requiredSet); stack.push(node);//from ww w . j a va 2s . c o m LogicalNode child = super.visitTableSubQuery(childContext, plan, block, node, stack); node.setSubQuery(child); stack.pop(); Target[] targets; if (node.hasTargets()) { targets = node.getTargets(); } else { targets = PlannerUtil.schemaToTargets(node.getOutSchema()); } LinkedHashSet<Target> projectedTargets = Sets.newLinkedHashSet(); for (Iterator<Target> it = getFilteredTarget(targets, upperContext.requiredSet); it.hasNext();) { Target target = it.next(); upperContext.addExpr(target); } for (Iterator<Target> it = upperContext.targetListMgr.getFilteredTargets(upperContext.requiredSet); it .hasNext();) { Target target = it.next(); if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, target.getEvalTree(), node)) { projectedTargets.add(target); upperContext.targetListMgr.markAsEvaluated(target); } } node.setTargets(projectedTargets.toArray(new Target[projectedTargets.size()])); LogicalPlanner.verifyProjectedFields(block, node); return node; }
From source file:org.wso2.carbon.identity.oauth.endpoint.authz.OAuth2AuthzEndpoint.java
/** * http://tools.ietf.org/html/rfc6749#section-4.1.2 * <p/>/*from w w w .j a v a2s. co m*/ * 4.1.2.1. Error Response * <p/> * If the request fails due to a missing, invalid, or mismatching * redirection URI, or if the client identifier is missing or invalid, * the authorization server SHOULD inform the resource owner of the * error and MUST NOT automatically redirect the user-agent to the * invalid redirection URI. * <p/> * If the resource owner denies the access request or if the request * fails for reasons other than a missing or invalid redirection URI, * the authorization server informs the client by adding the following * parameters to the query component of the redirection URI using the * "application/x-www-form-urlencoded" format * * @param clientId * @param req * @return * @throws OAuthSystemException * @throws OAuthProblemException */ private String handleOAuthAuthorizationRequest(String clientId, HttpServletRequest req) throws OAuthSystemException, OAuthProblemException { OAuth2ClientValidationResponseDTO clientDTO = null; String redirectUri = req.getParameter("redirect_uri"); String pkceChallengeCode = null; String pkceChallengeMethod = null; boolean isPKCESupportEnabled = EndpointUtil.getOAuth2Service().isPKCESupportEnabled(); if (StringUtils.isBlank(clientId)) { if (log.isDebugEnabled()) { log.debug("Client Id is not present in the authorization request"); } return EndpointUtil.getErrorPageURL(OAuth2ErrorCodes.INVALID_REQUEST, "Client Id is not present in the " + "authorization request", null); } else if (StringUtils.isBlank(redirectUri)) { if (log.isDebugEnabled()) { log.debug("Redirect URI is not present in the authorization request"); } return EndpointUtil.getErrorPageURL(OAuth2ErrorCodes.INVALID_REQUEST, "Redirect URI is not present in the" + " authorization request", null); } else { clientDTO = validateClient(clientId, redirectUri); } if (!clientDTO.isValidClient()) { return EndpointUtil.getErrorPageURL(clientDTO.getErrorCode(), clientDTO.getErrorMsg(), null); } // Now the client is valid, redirect him to the authorization page. OAuthAuthzRequest oauthRequest = new CarbonOAuthAuthzRequest(req); OAuth2Parameters params = new OAuth2Parameters(); params.setClientId(clientId); params.setRedirectURI(clientDTO.getCallbackURL()); params.setResponseType(oauthRequest.getResponseType()); params.setResponseMode(oauthRequest.getParam(RESPONSE_MODE)); params.setScopes(oauthRequest.getScopes()); if (params.getScopes() == null) { // to avoid null pointers Set<String> scopeSet = new HashSet<String>(); scopeSet.add(""); params.setScopes(scopeSet); } params.setState(oauthRequest.getState()); params.setApplicationName(clientDTO.getApplicationName()); pkceChallengeCode = req.getParameter(OAuthConstants.OAUTH_PKCE_CODE_CHALLENGE); pkceChallengeMethod = req.getParameter(OAuthConstants.OAUTH_PKCE_CODE_CHALLENGE_METHOD); // Validate PKCE parameters if (isPKCESupportEnabled) { // Check if PKCE is mandatory for the application if (clientDTO.isPkceMandatory()) { if (pkceChallengeCode == null || !OAuth2Util.validatePKCECodeChallenge(pkceChallengeCode, pkceChallengeMethod)) { return EndpointUtil.getErrorPageURL( OAuth2ErrorCodes.INVALID_REQUEST, "PKCE is mandatory for this application. " + "PKCE Challenge is not provided " + "or is not upto RFC 7636 specification.", null); } } //Check if the code challenge method value is neither "plain" or "s256", if so return error if (pkceChallengeCode != null && pkceChallengeMethod != null) { if (!OAuthConstants.OAUTH_PKCE_PLAIN_CHALLENGE.equals(pkceChallengeMethod) && !OAuthConstants.OAUTH_PKCE_S256_CHALLENGE.equals(pkceChallengeMethod)) { return EndpointUtil.getErrorPageURL(OAuth2ErrorCodes.INVALID_REQUEST, "Unsupported PKCE Challenge Method", null); } } // Check if "plain" transformation algorithm is disabled for the application if (pkceChallengeCode != null && !clientDTO.isPkceSupportPlain()) { if (pkceChallengeMethod == null || OAuthConstants.OAUTH_PKCE_PLAIN_CHALLENGE.equals(pkceChallengeMethod)) { return EndpointUtil.getErrorPageURL(OAuth2ErrorCodes.INVALID_REQUEST, "This application does not " + "support \"plain\" transformation algorithm.", null); } } // If PKCE challenge code was sent, check if the code challenge is upto specifications if (pkceChallengeCode != null && !OAuth2Util.validatePKCECodeChallenge(pkceChallengeCode, pkceChallengeMethod)) { return EndpointUtil.getErrorPageURL(OAuth2ErrorCodes.INVALID_REQUEST, "Code challenge used is not up to " + "RFC 7636 specifications.", null); } } params.setPkceCodeChallenge(pkceChallengeCode); params.setPkceCodeChallengeMethod(pkceChallengeMethod); // OpenID Connect specific request parameters params.setNonce(oauthRequest.getParam(OAuthConstants.OAuth20Params.NONCE)); params.setDisplay(oauthRequest.getParam(OAuthConstants.OAuth20Params.DISPLAY)); params.setIDTokenHint(oauthRequest.getParam(OAuthConstants.OAuth20Params.ID_TOKEN_HINT)); params.setLoginHint(oauthRequest.getParam(OAuthConstants.OAuth20Params.LOGIN_HINT)); if (StringUtils.isNotEmpty(oauthRequest.getParam(MultitenantConstants.TENANT_DOMAIN))) { params.setTenantDomain(oauthRequest.getParam(MultitenantConstants.TENANT_DOMAIN)); } else { params.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); } if (StringUtils.isNotBlank(oauthRequest.getParam("acr_values")) && !"null".equals(oauthRequest.getParam("acr_values"))) { String[] acrValues = oauthRequest.getParam("acr_values").split(" "); LinkedHashSet list = new LinkedHashSet(); for (String acrValue : acrValues) { list.add(acrValue); } params.setACRValues(list); } if (StringUtils.isNotBlank(oauthRequest.getParam("claims"))) { params.setEssentialClaims(oauthRequest.getParam("claims")); } String prompt = oauthRequest.getParam(OAuthConstants.OAuth20Params.PROMPT); params.setPrompt(prompt); /** * The prompt parameter can be used by the Client to make sure * that the End-User is still present for the current session or * to bring attention to the request. If this parameter contains * none with any other value, an error is returned * * http://openid.net/specs/openid-connect-messages- * 1_0-14.html#anchor6 * * prompt : none * The Authorization Server MUST NOT display any authentication or * consent user interface pages. An error is returned if the * End-User is not already authenticated or the Client does not have * pre-configured consent for the requested scopes. This can be used * as a method to check for existing authentication and/or consent. * * prompt : login * The Authorization Server MUST prompt the End-User for * reauthentication. * * Error : login_required * The Authorization Server requires End-User authentication. This * error MAY be returned when the prompt parameter in the * Authorization Request is set to none to request that the * Authorization Server should not display any user interfaces to * the End-User, but the Authorization Request cannot be completed * without displaying a user interface for user authentication. * */ boolean forceAuthenticate = false; boolean checkAuthentication = false; // prompt values = {none, login, consent, select_profile} String[] arrPrompt = new String[] { OAuthConstants.Prompt.NONE, OAuthConstants.Prompt.LOGIN, OAuthConstants.Prompt.CONSENT, OAuthConstants.Prompt.SELECT_ACCOUNT }; List lstPrompt = Arrays.asList(arrPrompt); boolean contains_none = (OAuthConstants.Prompt.NONE).equals(prompt); String[] prompts; if (StringUtils.isNotBlank(prompt)) { prompts = prompt.trim().split("\\s"); List lstPrompts = Arrays.asList(prompts); if (!CollectionUtils.containsAny(lstPrompts, lstPrompt)) { if (log.isDebugEnabled()) { log.debug("Invalid prompt variables passed with the authorization request" + prompt); } OAuthProblemException ex = OAuthProblemException.error(OAuth2ErrorCodes.INVALID_REQUEST, "Invalid prompt variables passed with the authorization request"); return EndpointUtil.getErrorRedirectURL(ex, params); } if (prompts.length > 1) { if (lstPrompts.contains(OAuthConstants.Prompt.NONE)) { if (log.isDebugEnabled()) { log.debug( "Invalid prompt variable combination. The value 'none' cannot be used with others " + "prompts. Prompt: " + prompt); } OAuthProblemException ex = OAuthProblemException.error(OAuth2ErrorCodes.INVALID_REQUEST, "Invalid prompt variable combination. The value \'none\' cannot be used with others prompts."); return EndpointUtil.getErrorRedirectURL(ex, params); } else if (lstPrompts.contains(OAuthConstants.Prompt.LOGIN) && (lstPrompts.contains(OAuthConstants.Prompt.CONSENT))) { forceAuthenticate = true; checkAuthentication = false; } } else { if ((OAuthConstants.Prompt.LOGIN).equals(prompt)) { // prompt for authentication checkAuthentication = false; forceAuthenticate = true; } else if (contains_none) { checkAuthentication = true; forceAuthenticate = false; } else if ((OAuthConstants.Prompt.CONSENT).equals(prompt)) { checkAuthentication = false; forceAuthenticate = false; } } } String sessionDataKey = UUIDGenerator.generateUUID(); SessionDataCacheKey cacheKey = new SessionDataCacheKey(sessionDataKey); SessionDataCacheEntry sessionDataCacheEntryNew = new SessionDataCacheEntry(); sessionDataCacheEntryNew.setoAuth2Parameters(params); sessionDataCacheEntryNew.setQueryString(req.getQueryString()); if (req.getParameterMap() != null) { sessionDataCacheEntryNew.setParamMap(new ConcurrentHashMap<String, String[]>(req.getParameterMap())); } SessionDataCache.getInstance().addToCache(cacheKey, sessionDataCacheEntryNew); try { req.setAttribute(FrameworkConstants.RequestParams.FLOW_STATUS, AuthenticatorFlowStatus.SUCCESS_COMPLETED); req.setAttribute(FrameworkConstants.SESSION_DATA_KEY, sessionDataKey); return EndpointUtil.getLoginPageURL(clientId, sessionDataKey, forceAuthenticate, checkAuthentication, oauthRequest.getScopes(), req.getParameterMap()); } catch (IdentityOAuth2Exception e) { if (log.isDebugEnabled()) { log.debug("Error while retrieving the login page url.", e); } throw new OAuthSystemException("Error when encoding login page URL"); } }
From source file:org.apache.tajo.plan.rewrite.rules.ProjectionPushDownRule.java
public LogicalNode visitScan(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, ScanNode node, Stack<LogicalNode> stack) throws TajoException { Context newContext = new Context(context); List<Target> targets; if (node.hasTargets()) { targets = node.getTargets();//from ww w.j a v a 2s. c om } else { targets = PlannerUtil.schemaToTargets(node.getLogicalSchema()); } LinkedHashSet<Target> projectedTargets = Sets.newLinkedHashSet(); for (Iterator<Target> it = getFilteredTarget(targets, newContext.requiredSet); it.hasNext();) { Target target = it.next(); newContext.addExpr(target); } for (Iterator<Target> it = context.targetListMgr.getFilteredTargets(newContext.requiredSet); it .hasNext();) { Target target = it.next(); if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, target.getEvalTree(), node)) { projectedTargets.add(target); newContext.targetListMgr.markAsEvaluated(target); } } node.setTargets(new ArrayList<>(projectedTargets)); LogicalPlanner.verifyProjectedFields(block, node); return node; }
From source file:org.apache.tajo.plan.rewrite.rules.ProjectionPushDownRule.java
@Override public LogicalNode visitPartitionedTableScan(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, PartitionedTableScanNode node, Stack<LogicalNode> stack) throws TajoException { Context newContext = new Context(context); List<Target> targets; if (node.hasTargets()) { targets = node.getTargets();//from w w w. j a v a 2 s . c o m } else { targets = PlannerUtil.schemaToTargets(node.getOutSchema()); } LinkedHashSet<Target> projectedTargets = Sets.newLinkedHashSet(); for (Iterator<Target> it = getFilteredTarget(targets, newContext.requiredSet); it.hasNext();) { Target target = it.next(); newContext.addExpr(target); } for (Iterator<Target> it = context.targetListMgr.getFilteredTargets(newContext.requiredSet); it .hasNext();) { Target target = it.next(); if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, target.getEvalTree(), node)) { projectedTargets.add(target); newContext.targetListMgr.markAsEvaluated(target); } } node.setTargets(new ArrayList<>(projectedTargets)); LogicalPlanner.verifyProjectedFields(block, node); return node; }
From source file:com.sun.faban.driver.transport.hc3.ApacheHC3Transport.java
/** * Obtains the list of cookie values by the name of the cookies. * @param name The cookie name/*from w w w . j av a 2s. com*/ * @return An array of non-duplicating cookie values. */ public String[] getCookieValuesByName(String name) { LinkedHashSet<String> valueSet = new LinkedHashSet<String>(); Cookie[] cookies = hc.getState().getCookies(); for (Cookie cookie : cookies) { if (name.equals(cookie.getName())) { valueSet.add(cookie.getValue()); } } String[] values = new String[valueSet.size()]; return valueSet.toArray(values); }
From source file:org.apache.tajo.plan.rewrite.rules.ProjectionPushDownRule.java
@Override public LogicalNode visitTableSubQuery(Context upperContext, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { Context childContext = new Context(plan, upperContext.requiredSet); stack.push(node);/*from w w w .ja v a 2s. com*/ LogicalNode child = super.visitTableSubQuery(childContext, plan, block, node, stack); node.setSubQuery(child); stack.pop(); List<Target> targets; if (node.hasTargets()) { targets = node.getTargets(); } else { targets = PlannerUtil.schemaToTargets(node.getOutSchema()); } LinkedHashSet<Target> projectedTargets = Sets.newLinkedHashSet(); for (Iterator<Target> it = getFilteredTarget(targets, upperContext.requiredSet); it.hasNext();) { Target target = it.next(); upperContext.addExpr(target); } for (Iterator<Target> it = upperContext.targetListMgr.getFilteredTargets(upperContext.requiredSet); it .hasNext();) { Target target = it.next(); if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, target.getEvalTree(), node)) { projectedTargets.add(target); upperContext.targetListMgr.markAsEvaluated(target); } } node.setTargets(new ArrayList<>(projectedTargets)); LogicalPlanner.verifyProjectedFields(block, node); return node; }
From source file:ubic.gemma.web.controller.expression.experiment.DEDVController.java
private LinkedHashSet<ExperimentalFactor> getFactorNames( LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>> eeLayouts) { LinkedHashSet<ExperimentalFactor> factorNames = new LinkedHashSet<>(); // need uniqueness & order for (BioAssayValueObject ba : eeLayouts.keySet()) { LinkedHashMap<ExperimentalFactor, Double> factorMap = eeLayouts.get(ba); for (Entry<ExperimentalFactor, Double> pair : factorMap.entrySet()) { if (pair.getKey() != null) { factorNames.add(pair.getKey()); }/*from w ww.j ava2 s . c om*/ } } return factorNames; }