Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ryan Berkheimer
messageapi
Commits
a5c76585
Commit
a5c76585
authored
Sep 10, 2020
by
Ryan Berkheimer
Browse files
added error exits in exception blocks for cases where parsing or computation issues are encountered
parent
3a527da5
Changes
23
Hide whitespace changes
Inline
Side-by-side
dist/artifacts/c/messageapi_1_0_0/messageapi.tar
View file @
a5c76585
No preview for this file type
dist/artifacts/java/messageapi_1_0_0/messageapi.tar
View file @
a5c76585
No preview for this file type
dist/docs/api/messageapi_docs.tar
View file @
a5c76585
No preview for this file type
resources/main/templates/containers/simple/clisam/collections.json
deleted
100644 → 0
View file @
3a527da5
{
"collections"
:
[
{
"id"
:
"testTable1"
,
"classifiers"
:
{
"namespace"
:
"/path/to/test.db"
},
"fields"
:
[
"key"
,
"record"
,
"filename"
,
"type"
]
},
{
"id"
:
"testTable2"
,
"classifiers"
:
{
"namespace"
:
"/path/to/test2.db"
},
"fields"
:
[
"key"
,
"type"
,
"receipt_date"
,
"insert_date"
]
}
]
}
resources/main/templates/containers/simple/clisam/metadata.json
deleted
100644 → 0
View file @
3a527da5
{
"metadata"
:
{
"id"
:
"email"
,
"version"
:
1.0
,
"classifiers"
:
{},
"description"
:
null
}
}
resources/main/templates/containers/simple/clisam/transformations.json
deleted
100644 → 0
View file @
3a527da5
{
"transformations"
:
[
{
"id"
:
"test1"
,
"type"
:
"left join"
,
"parent"
:
"testTable1"
,
"child"
:
"testTable2"
,
"field"
:
"key"
}
]
}
resources/main/templates/protocols/jdbc/clisam.json
deleted
100644 → 0
View file @
3a527da5
{
"connections"
:
[
{
"id"
:
"/path/to/test.db"
,
"url"
:
"whatever"
,
"user"
:
"test"
,
"password"
:
null
}
]
}
resources/main/templates/schemas/simple/clisam/conditions.json
deleted
100644 → 0
View file @
3a527da5
{
"conditions"
:
[
{
"id"
:
"1"
,
"type"
:
"comparison"
,
"operator"
:
">="
,
"field"
:
"key"
,
"value"
:
null
},
{
"id"
:
"2"
,
"type"
:
"comparison"
,
"operator"
:
"<"
,
"field"
:
"key"
,
"value"
:
null
},
{
"id"
:
"three"
,
"type"
:
"composite"
,
"operator"
:
"or"
,
"conditions"
:
[
"1"
,
"2"
,
"hi"
]
},
{
"id"
:
"hi"
,
"type"
:
"comparison"
,
"operator"
:
"="
,
"field"
:
"type"
,
"value"
:
null
},
{
"id"
:
"dummy"
,
"type"
:
"comparison"
,
"operator"
:
"="
,
"field"
:
"type"
,
"value"
:
null
},
{
"id"
:
"nested_join"
,
"type"
:
"composite"
,
"operator"
:
"and"
,
"conditions"
:
[
"dummy"
,
"three"
]
}
]
}
resources/main/templates/schemas/simple/clisam/fields.json
deleted
100644 → 0
View file @
3a527da5
{
"fields"
:
[
{
"id"
:
"id"
,
"type"
:
"integer"
,
"required"
:
false
},
{
"id"
:
"key"
,
"type"
:
"string"
,
"required"
:
true
},
{
"id"
:
"record"
,
"type"
:
"string"
,
"required"
:
true
},
{
"id"
:
"filename"
,
"type"
:
"string"
,
"required"
:
true
},
{
"id"
:
"type"
,
"type"
:
"string"
,
"required"
:
true
},
{
"id"
:
"receipt_date"
,
"type"
:
"datetime"
,
"required"
:
true
},
{
"id"
:
"insert_date"
,
"type"
:
"datetime"
,
"required"
:
true
}
]
}
resources/main/templates/schemas/simple/clisam/metadata.json
deleted
100644 → 0
View file @
3a527da5
{
"metadata"
:
{
"id"
:
"clisam"
,
"version"
:
1.0
,
"classifiers"
:
{},
"description"
:
null
}
}
resources/main/templates/sessions/s
qllite-jdbc-clisam
.json
→
resources/main/templates/sessions/s
tandard_session
.json
View file @
a5c76585
...
...
@@ -4,27 +4,28 @@
"schema"
:
{
"plugin"
:
"gov.noaa.messageapi.schemas.DefaultSchema"
,
"constructor"
:
{
"metadata"
:
"{}/resources/main/storage/schemas/simple/clisam/metadata.json"
,
"fields"
:
"{}/resources/main/storage/schemas/simple/clisam/fields.json"
,
"conditions"
:
"{}/resources/main/storage/schemas/simple/clisam/conditions.json"
,
"condition-operators"
:
"gov.noaa.messageapi.factories.SimpleConditionOperatorFactory"
"metadata"
:
"{_standard_}"
,
"fields"
:
"{_standard_}"
}
},
"container"
:
{
"plugin"
:
"gov.noaa.messageapi.containers.DefaultContainer"
,
"constructor"
:
{
"metadata"
:
"{}/resources/main/storage/containers/simple/clisam/metadata.json"
,
"collections"
:
"{}/resources/main/storage/containers/simple/clisam/collections.json"
,
"transformations"
:
"{}/resources/main/storage/containers/simple/clisam/transformations.json"
"metadata"
:
"{_standard_}"
,
"collections"
:
"{_standard_}"
}
},
"protocol"
:
{
"plugin"
:
"gov.noaa.messageapi.protocols.DefaultProtocol"
,
"constructor"
:
{
"metadata"
:
"{}/resources/main/storage/protocols/jdbc/metadata.json"
,
"endpoint"
:
"gov.noaa.messageapi.test.ClisamEndpoint"
,
"connections"
:
"{}/resources/main/storage/protocols/jdbc/connections.json"
"metadata"
:
"{_standard_}"
,
"endpoints"
:
[
{
"plugin"
:
"gov.noaa.messageapi.endpoints.NativeEndpoint"
,
"connections"
:
"{_standard_}"
}
]
}
}
}
}
}
\ No newline at end of file
resources/test/basic-native/manifest.json
View file @
a5c76585
...
...
@@ -18,7 +18,6 @@
"protocol"
:
{
"plugin"
:
"gov.noaa.messageapi.protocols.DefaultProtocol"
,
"constructor"
:
{
"metadata"
:
"{}/resources/test/metadata/basic-native/protocol.json"
,
"endpoints"
:
[{
"plugin"
:
"gov.noaa.messageapi.endpoints.NativeEndpoint"
,
"connections"
:
"{}/resources/test/basic-native/parameters.json"
...
...
resources/test/file-reader/manifest.json
View file @
a5c76585
...
...
@@ -17,9 +17,7 @@
"constructor"
:
{
"metadata"
:
"{}/resources/test/metadata/file-reader/container.json"
,
"collections"
:
"{}/resources/test/file-reader/parameters.json"
,
"transformations"
:
{
"map"
:
"{}/resources/test/file-reader/parameters.json"
}
"transformations"
:
"{}/resources/test/file-reader/parameters.json"
}
},
"protocol"
:
{
...
...
resources/test/native-transformation/manifest.json
View file @
a5c76585
...
...
@@ -11,7 +11,7 @@
"plugin"
:
"gov.noaa.messageapi.containers.DefaultContainer"
,
"constructor"
:
{
"collections"
:
"{}/resources/test/native-transformation/parameters.json"
,
"transformations"
:
{
"map"
:
"{}/resources/test/native-transformation/parameters.json"
}
"transformations"
:
"{}/resources/test/native-transformation/parameters.json"
}
},
"protocol"
:
{
...
...
resources/test/sessions/condition-test.json
View file @
a5c76585
...
...
@@ -12,7 +12,7 @@
"constructor"
:
{
"metadata"
:
"{}/resources/test/containers/simple/condition-test/metadata.json"
,
"collections"
:
"{}/resources/test/containers/simple/condition-test/collections.json"
,
"transformations"
:
{
"map"
:
"{}/resources/test/containers/simple/condition-test/transformations.json"
}
"transformations"
:
"{}/resources/test/containers/simple/condition-test/transformations.json"
}
},
"protocol"
:
{
...
...
resources/test/sessions/email-smtp-test.json
View file @
a5c76585
...
...
@@ -7,7 +7,7 @@
"container"
:
{
"plugin"
:
"gov.noaa.messageapi.containers.DefaultContainer"
,
"constructor"
:
{
"metadata"
:
"{}/resources/test/containers/simple/email/metadata.json"
,
"collections"
:
"{}/resources/test/containers/simple/email/collections.json"
,
"transformations"
:
{
"map"
:
"{}/resources/test/containers/simple/email/transformations.json"
}}
}
,
"transformations"
:
"{}/resources/test/containers/simple/email/transformations.json"
}},
"protocol"
:
{
"plugin"
:
"gov.noaa.messageapi.protocols.DefaultProtocol"
,
"constructor"
:
{
"metadata"
:
"{}/resources/test/protocols/email/simple/metadata.json"
,
"endpoints"
:
[{
"plugin"
:
"gov.noaa.messageapi.test.endpoints.EmailEndpointTest"
,
...
...
resources/test/sessions/sqlite-jdbc-clisam.json
View file @
a5c76585
...
...
@@ -7,7 +7,7 @@
"container"
:
{
"plugin"
:
"gov.noaa.messageapi.containers.DefaultContainer"
,
"constructor"
:
{
"metadata"
:
"{}/resources/test/containers/simple/clisam/metadata.json"
,
"collections"
:
"{}/resources/test/containers/simple/clisam/collections.json"
,
"transformations"
:
{
"map"
:
"{}/resources/test/containers/simple/clisam/transformations.json"
}}
}
,
"transformations"
:
"{}/resources/test/containers/simple/clisam/transformations.json"
}},
"protocol"
:
{
"plugin"
:
"gov.noaa.messageapi.protocols.DefaultProtocol"
,
"constructor"
:
{
"metadata"
:
"{}/resources/test/protocols/jdbc/sqlite/clisam/metadata.json"
,
"endpoints"
:
[{
"plugin"
:
"gov.noaa.messageapi.test.endpoints.EmailEndpointTest"
,
...
...
src/java/main/gov/noaa/messageapi/definitions/ContainerDefinition.java
View file @
a5c76585
...
...
@@ -28,7 +28,6 @@ public class ContainerDefinition {
private
List
<
String
>
transformations
=
null
;
private
List
<
Map
.
Entry
<
String
,
String
>>
classifiers
=
null
;
@SuppressWarnings
(
"unchecked"
)
public
ContainerDefinition
(
Map
<
String
,
Object
>
properties
)
throws
Exception
{
if
(
properties
.
containsKey
(
"metadata"
))
{
this
.
parseMetadataSpec
((
String
)
properties
.
get
(
"metadata"
));
...
...
@@ -41,7 +40,7 @@ public class ContainerDefinition {
throw
new
Exception
(
"Missing necessary 'collections' key when parsing container definition."
);
}
if
(
properties
.
containsKey
(
"transformations"
))
{
this
.
parseTransformationSpec
(
(
Map
<
String
,
String
>)
properties
.
get
(
"transformations"
));
this
.
parseTransformationSpec
(
properties
.
get
(
"transformations"
));
}
else
{
this
.
setEmptyTransformationMaps
();
}
...
...
@@ -56,7 +55,6 @@ public class ContainerDefinition {
this
.
transformationMaps
=
new
ArrayList
<
Map
<
String
,
Object
>>(
definition
.
getTransformationMaps
());
}
private
void
parseMetadataSpec
(
String
spec
)
throws
Exception
{
MetadataParser
parser
=
new
MetadataParser
(
spec
);
this
.
metadataMap
=
parser
.
getMetadataMap
();
...
...
@@ -69,12 +67,22 @@ public class ContainerDefinition {
this
.
classifiers
=
parser
.
getClassifiers
();
}
private
void
parseTransformationSpec
(
Map
<
String
,
String
>
transformationSpec
)
throws
Exception
{
if
(
transformationSpec
.
containsKey
(
"map"
))
{
TransformationParser
parser
=
new
TransformationParser
(
transformationSpec
.
get
(
"map"
));
this
.
transformationMaps
=
parser
.
getTransformationMaps
();
this
.
transformations
=
parser
.
getTransformations
();
}
else
{
@SuppressWarnings
(
"unchecked"
)
private
void
parseTransformationSpec
(
Object
transformationSpec
)
throws
Exception
{
try
{
if
(
transformationSpec
instanceof
String
)
{
TransformationParser
parser
=
new
TransformationParser
(((
String
)
transformationSpec
));
this
.
transformationMaps
=
parser
.
getTransformationMaps
();
this
.
transformations
=
parser
.
getTransformations
();
}
else
if
(
transformationSpec
instanceof
List
)
{
TransformationParser
parser
=
new
TransformationParser
((
List
<
Map
<
String
,
Object
>>)
transformationSpec
);
this
.
transformationMaps
=
parser
.
getTransformationMaps
();
this
.
transformations
=
parser
.
getTransformations
();
}
else
{
this
.
setEmptyTransformationMaps
();
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"WARNING - transformation parsing failed. Setting empty transformations."
);
this
.
setEmptyTransformationMaps
();
}
}
...
...
src/java/main/gov/noaa/messageapi/parsers/BaseParser.java
View file @
a5c76585
...
...
@@ -22,9 +22,12 @@ public abstract class BaseParser {
update
();
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Exception thrown in resource string constructor: "
+
e
.
getMessage
());
System
.
exit
(
1
);
}
}
public
BaseParser
(){}
@SuppressWarnings
(
"unchecked"
)
public
BaseParser
(
Object
jsonModel
)
throws
Exception
{
try
{
...
...
@@ -36,6 +39,7 @@ public abstract class BaseParser {
}
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Exception thrown in resource hashmap constructor: "
+
e
.
getMessage
());
System
.
exit
(
1
);
}
}
...
...
@@ -47,6 +51,7 @@ public abstract class BaseParser {
keys
=
JsonUtils
.
keys
(
jsonModel
);
}
catch
(
Exception
e
){
System
.
err
.
println
(
"Exception thrown while gathering resource keys: "
+
e
.
getMessage
());
System
.
exit
(
1
);
}
}
...
...
@@ -79,6 +84,7 @@ public abstract class BaseParser {
}
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Exception thrown while updating the resource: "
+
e
.
getMessage
());
System
.
exit
(
1
);
}
}
...
...
src/java/main/gov/noaa/messageapi/parsers/containers/TransformationParser.java
View file @
a5c76585
...
...
@@ -14,13 +14,20 @@ import gov.noaa.messageapi.utils.general.PathUtils;
*/
public
class
TransformationParser
extends
BaseParser
{
private
List
<
Map
<
String
,
Object
>>
transformationMaps
;
@SuppressWarnings
(
"unchecked"
)
public
TransformationParser
(
String
spec
)
throws
Exception
{
super
(
PathUtils
.
reconcileKeywords
(
spec
));
this
.
setTransformationMaps
((
List
<
Map
<
String
,
Object
>>)
super
.
getValue
(
"transformations"
));
}
public
TransformationParser
(
List
<
Map
<
String
,
Object
>>
transformationMapList
)
throws
Exception
{
this
.
setTransformationMaps
(
transformationMapList
);
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
Map
<
String
,
Object
>>
getTransformationMaps
()
{
return
(
List
<
Map
<
String
,
Object
>>)
super
.
getValue
(
"
transformation
s"
)
;
return
this
.
transformation
Maps
;
}
public
List
<
String
>
getTransformations
()
{
...
...
@@ -30,6 +37,10 @@ public class TransformationParser extends BaseParser {
public
void
process
(){
}
private
void
setTransformationMaps
(
List
<
Map
<
String
,
Object
>>
transformationMapList
){
this
.
transformationMaps
=
transformationMapList
;
}
public
Set
<
String
>
getRequiredKeys
()
{
Set
<
String
>
set
=
new
HashSet
<
String
>();
set
.
add
(
"transformations"
);
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment