/** * Constructor with entity identifier not found. * * @param entityType * @param entityId */ public KapuaEntityNotFoundException(String entityType, KapuaId entityId) { super(KapuaErrorCodes.ENTITY_NOT_FOUND, entityType, entityId.getId()); this.entityType = entityType; this.entityId = entityId; }
@Override public String marshal(KapuaId v) throws Exception { return v.toCompactId(); }
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; }
@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()); }
/** * Constructor with entity identifier not found. * * @param entityType * @param entityId */ public KapuaEntityNotFoundException(String entityType, KapuaId entityId) { super(KapuaErrorCodes.ENTITY_NOT_FOUND, entityType, entityId.getId()); this.entityType = entityType; this.entityId = entityId; }
@Override public String marshal(KapuaId v) throws Exception { return v != null ? v.toCompactId() : null; }
/** * 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(); }
/** * Get the identifier numeric String formatted. * * @return * @since 1.0.0 */ default String toStringId() { return getId().toString(); }
@Override public String marshal(KapuaId v) throws Exception { return v.toCompactId(); }
/** * 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 identifier numeric String formatted. * * @return * @since 1.0.0 */ default String toStringId() { return getId().toString(); }
@Override public String marshal(KapuaId v) throws Exception { return v != null ? v.toCompactId() : null; }
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; }
public long getScopeIdAsLong() { return scopeId != null ? scopeId.getId().longValue() : 0; }
/** * Builds the jBatch job name from the {@link Job#getScopeId()} and the {@link Job#getId()}. * <p> * Format is: job-{scopeIdShort}-{jobIdShort} * * @param scopeId The scopeId of the {@link Job} * @param jobId The id of the {@link Job} * @return The jBatch {@link Job} name * @since 1.0.0 */ public static String getJbatchJobName(@NotNull KapuaId scopeId, @NotNull KapuaId jobId) { return String.format("job-%s-%s", scopeId.toCompactId(), jobId.toCompactId()); }
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; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof KapuaId)) { return false; } KapuaId other = (KapuaId) obj; if (eid == null) { if (other.getId() != null) { return false; } } else if (!eid.equals(other.getId())) { return false; } return true; } }
/** * Builds the jBatch job name from the {@link Job#getScopeId()} and the {@link Job#getId()}. * <p> * Format is: job-{scopeIdShort}-{jobIdShort} * * @param scopeId The scopeId of the {@link Job} * @param jobId The id of the {@link Job} * @return The jBatch {@link Job} name * @since 1.0.0 */ public static String getJbatchJobName(@NotNull KapuaId scopeId, @NotNull KapuaId jobId) { return String.format("job-%s-%s", scopeId.toCompactId(), jobId.toCompactId()); }
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; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof KapuaId)) { return false; } KapuaId other = (KapuaId) obj; if (eid == null) { if (other.getId() != null) { return false; } } else if (!eid.equals(other.getId())) { return false; } return true; } }