@Override public List<String> getOptions() { return OPTIONS.get(); }
@Override public String[] getProcessNames() { List<String> processes = PROCESSES.get(); return processes.toArray(new String[processes.size()]); }
public void load() { excludeTypes = new HashSet<String>(); excludeTypes.addAll(EXCLUDE.get()); }
private boolean isWhitelisted(String host) { for (String valid : PROXY_WHITELIST.get()) { if (valid.equals(host)) { return true; } if (valid.startsWith("*") && host.endsWith(valid.substring(1))) { return true; } } return false; }
@Override public String[] getProcessNames() { List<String> result = new ArrayList<>(); for (String i : AgentUtils.AGENT_RESOURCES.get()) { result.add(String.format("%s.remove", i).toLowerCase()); } return result.toArray(new String[result.size()]); }
@Override public String toLogLine() { StringBuilder sb = new StringBuilder(); sb.append(timestamp.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)) .append(DELIM).append(httpMethod) .append(DELIM).append(uri) .append(DELIM).append(statusCode) .append(DELIM).append(durationNs / 1000) // Converting duration to microseconds. .append(DELIM).append(responseBodySize); includeMatchingHeaders(sb, LOG_RESP_HEADERS.get(), responseHeaders); includeMatchingHeaders(sb, LOG_REQ_HEADERS.get(), requestHeaders); return sb.toString(); }
protected static void addToList(List<ConfigUpdateItem> list, ConfigUpdateItem item) { if (PRIORITY_ITEMS.get().contains(item.getName())) { list.add(0, item); } else { list.add(item); } }
public static boolean shouldIgnore(File base, String path) { for (String prefix : IGNORE_PREFIX.get()) { if (path.startsWith(prefix)) { return true; } } return base == null ? false : Files.isSymbolicLink(new File(base, path).toPath()); }
public AbstractAgentBaseContextFactory() { String name = getClass().getSimpleName().replaceAll("Factory", "").replaceAll("([a-z])([A-Z])", "$1.$2").toLowerCase(); List<String> items = ArchaiusUtil.getList(String.format("item.context.%s.items", name)).get(); this.items = items.toArray(new String[items.size()]); }
@Override public boolean canSetProjectMembers(long projectId, Long usingAccount, boolean isAdmin, Set<Identity> identities) { return hasProjectRole(projectId, usingAccount, isAdmin, identities, SET_MEMBER_ROLES.get()); }
public boolean shouldCreateCredentials(Account account, ProcessState state) { return ACCOUNT_KIND_CREDENTIALS.get().contains(account.getKind()); }
@Override public Subnet doWithLock() { List<Subnet> subnets = objectManager.find(Subnet.class, SUBNET.ACCOUNT_ID, accountId, SUBNET.KIND, SubnetConstants.KIND_VIP_SUBNET); if (subnets.size() > 0) { return subnets.get(0); } Pair<String, Integer> cidr = NetUtils.getCidrAndSize(DOCKER_VIP_SUBNET_CIDR.get().get(0)); return resourceDao.createAndSchedule(Subnet.class, SUBNET.ACCOUNT_ID, accountId, SUBNET.CIDR_SIZE, cidr.getRight(), SUBNET.NETWORK_ADDRESS, cidr.getLeft(), SUBNET.KIND, SubnetConstants.KIND_VIP_SUBNET); } });
@Override public boolean isHttpsPort(String host, String port) { if (port == null && host != null) { String[] parts = host.split(":", 2); if (parts.length > 1) { port = parts[1]; } else if (ServerContext.isCustomApiHost()) { if (ServerContext.getHostApiBaseUrl(BaseProtocol.HTTP).startsWith("https")) { port = "443"; } else { port = "80"; } } } for (String p : HTTPS_PORTS.get()) { if (p.equals(port)) { return true; } } return false; }
@Override public SchemaImpl postProcess(SchemaImpl schema, SchemaFactory factory) { if(schema.getId().equals("projectMember")) { FieldImpl field = getField(schema, "externalIdType"); if(field != null){ field.getOptions().addAll(AUTH_SERVICE_EXTERNAL_ID_TYPES.get()); } } return schema; }
protected void load() { super.load(); values = parseMapFromStringList(super.get()); }
protected void load() { super.load(); values = parseMapFromStringList(super.get()); }
@Override public Map<String, String> getMap(String name) { Map<String, String> result = new LinkedHashMap<String, String>(); if (name == null) { return result; } for (String item : ArchaiusUtil.getList("agent.packages." + sanitize(name)).get()) { String key = String.format("agent.package.%s.url", sanitize(item)); DynamicStringProperty prop = values.get(key); if (prop == null) { prop = ArchaiusUtil.getString(key); values.put(key, prop); } String value = prop.get(); if (value != null) { result.put(item, value); } } return result; }
@Override protected Object authorize(Object object) { Predicate predicate = new SettingsFilter(PUBLIC_SETTINGS.get(), ApiContext.getContext().getApiRequest()); if (object instanceof List<?>) { List<Object> list = new ArrayList<>((List<?>) object); org.apache.commons.collections.CollectionUtils.filter(list, predicate); return super.authorize(list); } else if (predicate.evaluate(object)){ return super.authorize(object); } return null; }
protected ConfigUpdateRequest before(ConfigUpdateRequest request, Agent agent) { if (request == null) { request = ConfigUpdateRequest.forResource(Agent.class, agent.getId()); for (String item : ITEMS.get()) { request.addItem(item).withIncrement(false).setCheckInSyncOnly(true); } } statusManager.updateConfig(request); return request; }
@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { Account account = (Account)state.getResource(); if (!KINDS.get().contains(account.getKind())) { return null; } Map<String, Network> networksByKind = getNetworksByUuid(account); createNetwork(NetworkConstants.KIND_DOCKER_HOST, account, networksByKind, "Docker Host Network Mode", null); createNetwork(NetworkConstants.KIND_DOCKER_NONE, account, networksByKind, "Docker None Network Mode", null); createNetwork(NetworkConstants.KIND_DOCKER_CONTAINER, account, networksByKind, "Docker Container Network Mode", null); createNetwork(NetworkConstants.KIND_DOCKER_BRIDGE, account, networksByKind, "Docker Bridge Network Mode", null); ServicesPortRange portRange = DataAccessor.field(account, AccountConstants.FIELD_PORT_RANGE, jsonMapper, ServicesPortRange.class); if (portRange == null) { portRange = AccountConstants.getDefaultServicesPortRange(); } return new HandlerResult(AccountConstants.FIELD_PORT_RANGE, portRange).withShouldContinue(true); }