use of com.formkiq.stacks.common.objects.DynamicObject in project formkiq-core by formkiq.
the class DocumentIdRequestHandler method putObjectToStaging.
/**
* Put Object to Staging Bucket.
*
* @param logger {@link LambdaLogger}
* @param awsservice {@link AwsServiceCache}
* @param maxDocumentCount {@link String}
* @param siteId {@link String}
* @param item {@link DynamicObject}
*/
private void putObjectToStaging(final LambdaLogger logger, final AwsServiceCache awsservice, final String maxDocumentCount, final String siteId, final DynamicObject item) {
List<DynamicObject> documents = item.getList("documents");
item.put("documents", documents);
String s = GSON.toJson(item);
byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
String key = createDatabaseKey(siteId, item.getString("documentId") + FORMKIQ_DOC_EXT);
logger.log("s3 putObject " + key + " into bucket " + awsservice.stages3bucket());
S3Service s3 = awsservice.s3Service();
try (S3Client client = s3.buildClient()) {
s3.putObject(client, awsservice.stages3bucket(), key, bytes, item.getString("contentType"));
if (maxDocumentCount != null) {
awsservice.documentCountService().incrementDocumentCount(siteId);
}
}
}
use of com.formkiq.stacks.common.objects.DynamicObject in project formkiq-core by formkiq.
the class WebhooksServiceImplTest method testAddTags01.
/**
* Add Webhook Tag.
*/
@Test
public void testAddTags01() {
// given
String hook0 = this.service.saveWebhook(null, "test", "joe", null, "true");
String hook1 = this.service.saveWebhook(null, "test2", "joe2", null, "true");
DocumentTag tag0 = new DocumentTag(hook0, "category", "person", new Date(), "joe");
DocumentTag tag1 = new DocumentTag(hook0, "type", "person2", new Date(), "joe");
// when
this.service.addTags(null, hook0, Arrays.asList(tag0, tag1), null);
// then
assertNull(this.service.findTag(null, hook1, "category"));
DynamicObject tag = this.service.findTag(null, hook0, "category");
assertEquals("category", tag.getString("tagKey"));
assertEquals("person", tag.getString("tagValue"));
assertEquals(2, this.service.findTags(null, hook0, null).getResults().size());
assertEquals(0, this.service.findTags(null, hook1, null).getResults().size());
}
use of com.formkiq.stacks.common.objects.DynamicObject in project formkiq-core by formkiq.
the class WebhooksServiceImplTest method testUpdateWebhooks01.
/**
* Test Updating webhooks.
*/
@Test
public void testUpdateWebhooks01() {
// given
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
Date ttl = Date.from(now.toInstant());
ZonedDateTime tomorrow = ZonedDateTime.now(ZoneOffset.UTC).plusDays(1);
Date tomorrowttl = Date.from(tomorrow.toInstant());
for (String siteId : Arrays.asList(null, UUID.randomUUID().toString())) {
String webhookId = this.service.saveWebhook(siteId, "test", "joe", ttl, "true");
DynamicObject obj = new DynamicObject(Map.of("name", "test2", "TimeToLive", tomorrowttl));
// when
this.service.updateWebhook(siteId, webhookId, obj);
// then
DynamicObject result = this.service.findWebhook(siteId, webhookId);
assertEquals("test2", result.getString("path"));
assertNotNull(result.getString("documentId"));
assertNotNull(result.getString("path"));
assertNotNull(result.getString("userId"));
assertNotNull(result.getString("inserteddate"));
assertEquals(String.valueOf(tomorrowttl.getTime() / MILLISECONDS), result.getString("TimeToLive"));
}
}
Aggregations