-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* #%L | ||
* Alfresco HX Insight Connector | ||
* %% | ||
* Copyright (C) 2023 - 2024 Alfresco Software Limited | ||
* %% | ||
* This file is part of the Alfresco software. | ||
* If the software was purchased under a paid Alfresco license, the terms of | ||
* the paid license agreement will prevail. Otherwise, the software is | ||
* provided under the following open source license terms: | ||
* | ||
* Alfresco is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Alfresco is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||
* #L% | ||
*/ | ||
package org.alfresco.hxi_connector.live_ingester.util.insight_api; | ||
|
||
import java.util.Map; | ||
|
||
public record HxInsightRequest(String url, Map<String, String> headers, String body) | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* #%L | ||
* Alfresco HX Insight Connector | ||
* %% | ||
* Copyright (C) 2023 - 2024 Alfresco Software Limited | ||
* %% | ||
* This file is part of the Alfresco software. | ||
* If the software was purchased under a paid Alfresco license, the terms of | ||
* the paid license agreement will prevail. Otherwise, the software is | ||
* provided under the following open source license terms: | ||
* | ||
* Alfresco is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Alfresco is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||
* #L% | ||
*/ | ||
package org.alfresco.hxi_connector.live_ingester.util.insight_api; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.UncheckedIOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
|
||
public class RequestLoader | ||
Check warning Code scanning / PMD This utility class has a non-private constructor Warning
This utility class has a non-private constructor
|
||
{ | ||
static ObjectMapper jsonMapper = new ObjectMapper(); | ||
Check warning Code scanning / PMD Do not use non-final non-private static fields Warning
Do not use non-final non-private static fields
|
||
static ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory()); | ||
Check warning Code scanning / PMD Do not use non-final non-private static fields Warning
Do not use non-final non-private static fields
|
||
|
||
public static HxInsightRequest load(String path) | ||
{ | ||
InputStream stream = HxInsightRequest.class.getResourceAsStream(path); | ||
Check warning Code scanning / PMD Ensure that resources like this InputStream object are closed after use Warning
Ensure that resources like this InputStream object are closed after use
|
||
HashMap<String, Object> data; | ||
Check warning Code scanning / PMD Avoid using implementation types like 'HashMap'; use the interface instead Warning
Avoid using implementation types like 'HashMap'; use the interface instead
|
||
try | ||
{ | ||
data = yamlMapper.readValue(stream.readAllBytes(), HashMap.class); | ||
} | ||
catch (IOException e) | ||
{ | ||
throw new UncheckedIOException(e); | ||
} | ||
Object body = data.get("body"); | ||
String bodyAsString = null; | ||
if (body != null) | ||
{ | ||
try | ||
{ | ||
bodyAsString = jsonMapper.writeValueAsString(body); | ||
} | ||
catch (JsonProcessingException e) | ||
{ | ||
throw new RuntimeException(e); | ||
Check warning Code scanning / PMD Avoid throwing raw exception types. Warning
Avoid throwing raw exception types.
|
||
} | ||
} | ||
return new HxInsightRequest((String) data.get("url"), (Map) data.get("headers"), bodyAsString); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
url: /v1/ingestion-events | ||
headers: | ||
authorization: application/json | ||
content-type: application/json | ||
hxp-environment: string | ||
user-agent: string | ||
body: [ | ||
{ | ||
"objectId": "d71dd823-82c7-477c-8490-04cb0e826e65", | ||
"sourceId" : "alfresco-dummy-source-id-0a63de491876", | ||
"eventType": "create", | ||
"sourceTimestamp": 1611227656423, | ||
"properties": { | ||
"cm:autoVersion": {"value": true}, | ||
"createdAt": {"value": 1611227655695}, | ||
"modifiedAt": {"value" : 1611227655695}, | ||
"cm:versionType": {"value": "MAJOR"}, | ||
"aspectsNames": {"value": ["cm:versionable", "cm:auditable"]}, | ||
"cm:name": { | ||
"value": "purchase-order-scan.doc", | ||
"annotation" : "name" | ||
}, | ||
"type": {"value": "cm:content"}, | ||
"createdBy": {"value": "admin"}, | ||
"modifiedBy": {"value": "admin"}, | ||
"cm:content": { | ||
"file": { | ||
"content-metadata": { | ||
"size": 531152, | ||
"name": "purchase-order-scan.doc", | ||
"content-type": "application/msword" | ||
} | ||
} | ||
}, | ||
"ALLOW_ACCESS": {"value": ["GROUP_EVERYONE"]}, | ||
"DENY_ACCESS": {"value": []} | ||
} | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
url: /v1/presigned-urls | ||
headers: | ||
authorization: string | ||
content-type: application/json | ||
hxp-environment: string | ||
user-agent: string | ||
count: string |