private List<String> getDataIndexesByAccount(KapuaId scopeId) throws ClientException { List<String> result = new ArrayList<>(); result.addAll(Arrays.asList(client.findIndexes(new IndexRequest(scopeId.toStringId() + "-*")).getIndexes())); return result; }
/** * Normalize the account index name and and the suffix '-*' * * @param scopeId * @return */ public static String getDataIndexName(KapuaId scopeId) { final StringBuilder sb = new StringBuilder(); final String prefix = DatastoreSettings.getInstance().getString(DatastoreSettingKey.INDEX_PREFIX); if (StringUtils.isNotEmpty(prefix)) { sb.append(prefix).append("-"); } String indexName = DatastoreUtils.normalizedIndexName(scopeId.toStringId()); sb.append(indexName).append("-*"); return sb.toString(); }
/** * Get the Kapua index name for the specified base name * * @param scopeId * @return * @since 1.0.0 */ public static String getRegistryIndexName(KapuaId scopeId) { final StringBuilder sb = new StringBuilder(); final String prefix = DatastoreSettings.getInstance().getString(DatastoreSettingKey.INDEX_PREFIX); if (StringUtils.isNotEmpty(prefix)) { sb.append(prefix).append("-"); } String indexName = DatastoreUtils.normalizedIndexName(scopeId.toStringId()); sb.append(".").append(indexName); return sb.toString(); }
private Map<String, Object> marshalClientInfo(ClientInfo clientInfo) throws ParseException { Map<String, Object> unmarshalledClientInfo = new HashMap<>(); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_ID, clientInfo.getClientId()); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_MESSAGE_ID, clientInfo.getFirstMessageId().toString()); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_TIMESTAMP, KapuaDateUtils.formatDate(clientInfo.getFirstMessageOn())); unmarshalledClientInfo.put(ClientInfoSchema.CLIENT_SCOPE_ID, clientInfo.getScopeId().toStringId()); return unmarshalledClientInfo; }
private Map<String, Object> marshalChannelInfo(ChannelInfo channelInfo) throws ParseException { Map<String, Object> unmarshalledChannelInfo = new HashMap<>(); unmarshalledChannelInfo.put(ChannelInfoSchema.CHANNEL_NAME, channelInfo.getName()); unmarshalledChannelInfo.put(ChannelInfoSchema.CHANNEL_TIMESTAMP, KapuaDateUtils.formatDate(channelInfo.getFirstMessageOn())); unmarshalledChannelInfo.put(ChannelInfoSchema.CHANNEL_CLIENT_ID, channelInfo.getClientId()); unmarshalledChannelInfo.put(ChannelInfoSchema.CHANNEL_SCOPE_ID, channelInfo.getScopeId().toStringId()); unmarshalledChannelInfo.put(ChannelInfoSchema.CHANNEL_MESSAGE_ID, channelInfo.getFirstMessageId().toString()); return unmarshalledChannelInfo; }
private Map<String, Object> marshalMetricInfo(MetricInfo metricInfo) throws ParseException { Map<String, Object> unmarshalledMetricInfo = new HashMap<>(); unmarshalledMetricInfo.put(MetricInfoSchema.METRIC_SCOPE_ID, metricInfo.getScopeId().toStringId()); unmarshalledMetricInfo.put(MetricInfoSchema.METRIC_CLIENT_ID, metricInfo.getClientId()); unmarshalledMetricInfo.put(MetricInfoSchema.METRIC_CHANNEL, metricInfo.getChannel()); Map<String, Object> unmarshalledMetricValue = new HashMap<>(); unmarshalledMetricValue.put(MetricInfoSchema.METRIC_MTR_NAME, metricInfo.getName()); unmarshalledMetricValue.put(MetricInfoSchema.METRIC_MTR_TYPE, DatastoreUtils.convertToClientMetricType(metricInfo.getMetricType())); unmarshalledMetricValue.put(MetricInfoSchema.METRIC_MTR_TIMESTAMP, KapuaDateUtils.formatDate(metricInfo.getFirstMessageOn())); unmarshalledMetricValue.put(MetricInfoSchema.METRIC_MTR_MSG_ID, metricInfo.getFirstMessageId().toString()); unmarshalledMetricInfo.put(MetricInfoSchema.METRIC_MTR, unmarshalledMetricValue); return unmarshalledMetricInfo; }
sb.append(prefix).append("-"); final String actualName = DatastoreUtils.normalizedIndexName(scopeId.toStringId()); sb.append(actualName).append('-'); DateTimeFormatter formatter;
@Then("^REST response containing Account$") public void restResponseContainingAccount() throws Exception { String restResponse = (String) stepData.get("restResponse"); Account account = XmlUtil.unmarshalJson(restResponse, Account.class, null); KapuaId accId = account.getId(); System.out.println("Account Id = " + accId); stepData.put("lastAccountId", accId.toStringId()); stepData.put("lastAccountCompactId", accId.toCompactId()); }
private Map<String, Object> marshalDatastoreMessage(DatastoreMessage message) throws ParseException { Map<String, Object> unmarshalledMessage = new HashMap<>(); String scopeId = message.getScopeId().toStringId(); String deviceIdStr = message.getDeviceId() == null ? null : message.getDeviceId().toStringId(); if (message.getId() != null) { unmarshalledMessage.put(MessageSchema.MESSAGE_ID, message.getId().toString());
public static void validatePermissions(@NotNull Set<Permission> permissions) throws KapuaException { if (!permissions.isEmpty()) { DomainListResult domains = DOMAIN_SERVICE.query(DOMAIN_FACTORY.newQuery(null)); for (Permission p : permissions) { if (p.getDomain() != null) { boolean matched = false; for (Domain domain : domains.getItems()) { if (domain.getName().equals(p.getDomain())) { matched = true; if (!domain.getGroupable() && p.getGroupId() != null) { throw new KapuaIllegalArgumentException(PermissionAttributes.GROUP_ID, p.getGroupId().toStringId()); } break; } } if (!matched) { throw new KapuaIllegalArgumentException(PermissionAttributes.DOMAIN, p.getDomain()); } } } } } }
public static void validatePermissions(@NotNull Set<Permission> permissions) throws KapuaException { if (!permissions.isEmpty()) { DomainListResult domains = DOMAIN_SERVICE.query(DOMAIN_FACTORY.newQuery(null)); for (Permission p : permissions) { if (p.getDomain() != null) { boolean matched = false; for (Domain domain : domains.getItems()) { if (domain.getName().equals(p.getDomain())) { matched = true; if (!domain.getGroupable() && p.getGroupId() != null) { throw new KapuaIllegalArgumentException(PermissionAttributes.GROUP_ID, p.getGroupId().toStringId()); } break; } } if (!matched) { throw new KapuaIllegalArgumentException(PermissionAttributes.DOMAIN, p.getDomain()); } } } } } }
if (parentAccountPath.contains("/" + getTargetScopeId().toStringId() + "/")) { setTargetScopeId(permission.getTargetScopeId()); setParts(toString());
if (parentAccountPath.contains("/" + getTargetScopeId().toStringId() + "/")) { setTargetScopeId(permission.getTargetScopeId()); setParts(toString());