Skip to content

Commit d7036a5

Browse files
authored
Merge pull request #12 from jegasmlm/master
Support for katana 1.2
2 parents ec91684 + fb9e5da commit d7036a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2062
-1144
lines changed
0 Bytes
Binary file not shown.
21.1 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [1.2.0] - 2017-09-01
8+
## Added
9+
- Start support for katana 1.2
10+
## Added
11+
- Support for optional arguments in java methods
12+
## Fixed
13+
- Fix immutable classes (Response, Request, HttpRequest, HttpResponse, Action, Transport)
14+
## Fixed
15+
- Fixed Response accessors for attributes
16+
## Added
17+
- Support for request attributes from katana 1.1.12
18+
- Accessors for request id and timestamp
19+
## Added
20+
- New header methods
21+
## Fixed
22+
- Fix default property in getProperty()
23+
724
## [1.1.0] - 2017-06-01
825
### Changed
926
- Updated CONTRIBUTING.md and README.md

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Java SDK to interface with the **KATANA**™ framework (https://kusanagi.io).
1010
Requirements
1111
------------
1212

13-
* KATANA Framework 1.1
13+
* KATANA Framework 1.2
1414
* [JDK](http://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html) 1.8
1515
* [libzmq](http://zeromq.org/intro:get-the-software) 4.1.5+
1616

@@ -33,15 +33,15 @@ If using **Maven**, add the following in your `pom.xml` file:
3333
<dependency>
3434
<groupId>io.kusanagi</groupId>
3535
<artifactId>katana-sdk-java8</artifactId>
36-
<version>1.1.0</version>
36+
<version>1.2.0</version>
3737
</dependency>
3838
```
3939

4040
Or, if using **Gradle**, add the following in your `build.gradle` file:
4141

4242
```gradle
4343
dependencies {
44-
compile group: 'io.kusanagi', name: 'katana-sdk-java8', version: '1.1.0'
44+
compile group: 'io.kusanagi', name: 'katana-sdk-java8', version: '1.2.0'
4545
}
4646
```
4747

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ apply plugin: 'signing'
2020

2121
group 'io.kusanagi'
2222
archivesBaseName = "katana-sdk-java8"
23-
version '1.1.0'
23+
version '1.2.0'
2424

2525
mainClassName = 'io.kusanagi.katana.api.component.Component'
2626

src/main/java/io/kusanagi/katana/api/Api.java

Lines changed: 143 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
import io.kusanagi.katana.sdk.Callable;
2424
import io.kusanagi.katana.sdk.ServiceSchema;
2525

26+
import java.util.ArrayList;
2627
import java.util.HashMap;
28+
import java.util.List;
2729
import java.util.Map;
2830

2931
/**
3032
* Created by juan on 28/08/16.
3133
*/
32-
public class Api {
34+
public abstract class Api {
3335

3436
protected Component component;
3537

@@ -76,81 +78,31 @@ public Api(Component component, String path, String name, String version, String
7678
this.isDebug = isDebug;
7779
}
7880

79-
public Api(Api other) {
80-
this.path = other.path;
81-
this.name = other.name;
82-
this.version = other.version;
83-
this.platformVersion = other.platformVersion;
84-
this.variables = other.variables;
85-
this.isDebug = other.isDebug;
86-
}
87-
88-
/**
89-
* Path setter
90-
*
91-
* @param path Path of the call
92-
*/
93-
public void setPath(String path) {
81+
public Api(Component component, String path, String name, String version, String platformVersion,
82+
Map<String, String> variables, boolean isDebug, Mapping mapping) {
83+
this.component = component;
9484
this.path = path;
95-
}
96-
97-
/**
98-
* Name setter
99-
*
100-
* @param name Name of the Service
101-
*/
102-
public void setName(String name) {
10385
this.name = name;
104-
}
105-
106-
/**
107-
* Version setter
108-
*
109-
* @param version Version of the service
110-
*/
111-
public void setProtocolVersion(String version) {
11286
this.version = version;
113-
}
114-
115-
/**
116-
* Platform version setter
117-
*
118-
* @param platformVersion Version of the platform
119-
*/
120-
public void setPlatformVersion(String platformVersion) {
12187
this.platformVersion = platformVersion;
122-
}
123-
124-
/**
125-
* Variables setter
126-
*
127-
* @param variables Sdk variables
128-
*/
129-
public void setVariables(Map<String, String> variables) {
13088
this.variables = variables;
89+
this.isDebug = isDebug;
90+
this.mapping = mapping;
13191
}
13292

133-
/**
134-
* Debug state setter
135-
*
136-
* @param debug Debug state
137-
*/
138-
public void setDebug(boolean debug) {
139-
isDebug = debug;
93+
public Api(Api other) {
94+
this.path = other.path;
95+
this.name = other.name;
96+
this.version = other.version;
97+
this.platformVersion = other.platformVersion;
98+
this.variables = other.variables;
99+
this.isDebug = other.isDebug;
140100
}
141101

142102
public Mapping getMapping() {
143103
return mapping;
144104
}
145105

146-
public void setMapping(Mapping mapping) {
147-
this.mapping = mapping;
148-
}
149-
150-
public void setComponent(Component component) {
151-
this.component = component;
152-
}
153-
154106
// SDK Method
155107

156108
/**
@@ -165,7 +117,7 @@ public boolean isDebug() {
165117
* @return Return the version of the platform
166118
*/
167119
@JsonIgnore
168-
public String getPlatformVersion() {
120+
public String getFrameworkVersion() {
169121
return platformVersion;
170122
}
171123

@@ -201,6 +153,15 @@ public Map<String, String> getVariables() {
201153
return variables;
202154
}
203155

156+
/**
157+
*
158+
* @param name case-sensitive name argument.
159+
* @return determine if a variable has been defined with the REQUIRED case-sensitive name argument.
160+
*/
161+
public boolean hasVariable(String name) {
162+
return this.variables.containsKey(name);
163+
}
164+
204165
/**
205166
* Get the variable with the REQUIRED case-sensitive name argument, and which MUST be returned as a string.
206167
*
@@ -228,6 +189,27 @@ public Callable getResource(String name) {
228189
return this.component.getResource(name);
229190
}
230191

192+
/**
193+
*
194+
* @return return an array with the Service versions in the stored schema mapping, in which each item MUST be an
195+
* object with the key name that MUST have the name of the Service and the key version that MUST have the version of the Service.
196+
*/
197+
public List<Map<String, String>> getServices(){
198+
List<Map<String, String>> services = new ArrayList<>();
199+
200+
for (Map.Entry service : mapping.getServiceSchema().entrySet()) {
201+
Map<String, ServiceSchema> versions = mapping.getServiceSchema().get((String) service.getKey());
202+
for (Map.Entry version : versions.entrySet()) {
203+
Map<String, String> serviceMap = new HashMap<>();
204+
serviceMap.put("service", (String) service.getKey());
205+
serviceMap.put("version", (String) version.getKey());
206+
services.add(serviceMap);
207+
}
208+
}
209+
210+
return services;
211+
}
212+
231213
/**
232214
* Return an instance of the Mapping class for the Service defined by the REQUIRED case sensitive name and
233215
* version arguments, using the stored mapping of schemas.
@@ -259,6 +241,15 @@ public boolean log(String value) {
259241
return true;
260242
}
261243

244+
/**
245+
*
246+
* @return This function is only for use in an asynchronous implementation of the SDK, for any other implementation
247+
* it MUST return false.
248+
*/
249+
public boolean done(){
250+
return false;
251+
}
252+
262253
@Override
263254
public boolean equals(Object o) {
264255
if (this == o) {
@@ -320,4 +311,92 @@ public String toString() {
320311
", mapping=" + mapping +
321312
'}';
322313
}
314+
315+
public abstract static class Builder<T> {
316+
private Component component;
317+
private String path;
318+
private String name;
319+
private String version;
320+
private String platformVersion;
321+
private Map<String, String> variables;
322+
private boolean isDebug;
323+
private Mapping mapping;
324+
325+
public Builder() {
326+
}
327+
328+
public Builder<T> setComponent(Component component) {
329+
this.component = component;
330+
return this;
331+
}
332+
333+
public Builder<T> setPath(String path) {
334+
this.path = path;
335+
return this;
336+
}
337+
338+
public Builder<T> setName(String name) {
339+
this.name = name;
340+
return this;
341+
}
342+
343+
public Builder<T> setVersion(String version) {
344+
this.version = version;
345+
return this;
346+
}
347+
348+
public Builder<T> setPlatformVersion(String platformVersion) {
349+
this.platformVersion = platformVersion;
350+
return this;
351+
}
352+
353+
public Builder<T> setVariables(Map<String, String> variables) {
354+
this.variables = variables;
355+
return this;
356+
}
357+
358+
public Builder<T> setDebug(boolean debug) {
359+
isDebug = debug;
360+
return this;
361+
}
362+
363+
public Builder<T> setMapping(Mapping mapping) {
364+
this.mapping = mapping;
365+
return this;
366+
}
367+
368+
public Component getComponent() {
369+
return component;
370+
}
371+
372+
public String getPath() {
373+
return path;
374+
}
375+
376+
public String getName() {
377+
return name;
378+
}
379+
380+
public String getVersion() {
381+
return version;
382+
}
383+
384+
public String getPlatformVersion() {
385+
return platformVersion;
386+
}
387+
388+
public Map<String, String> getVariables() {
389+
return variables;
390+
}
391+
392+
public boolean isDebug() {
393+
return isDebug;
394+
}
395+
396+
public Mapping getMapping() {
397+
return mapping;
398+
}
399+
400+
public abstract T build();
401+
}
323402
}

src/main/java/io/kusanagi/katana/api/commands/ActionCommandPayload.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
import com.fasterxml.jackson.annotation.JsonProperty;
1919
import io.kusanagi.katana.api.commands.common.CommandPayload;
2020
import io.kusanagi.katana.api.component.Key;
21-
import io.kusanagi.katana.sdk.Action;
21+
import io.kusanagi.katana.api.serializers.ActionEntity;
2222

2323
/**
2424
* Created by juan on 26/09/16.
2525
*/
26-
public class ActionCommandPayload extends CommandPayload<Action> {
26+
public class ActionCommandPayload extends CommandPayload<ActionEntity> {
2727

2828
/**
2929
* The semantics of the command
@@ -81,29 +81,29 @@ public String toString() {
8181
"} " + super.toString();
8282
}
8383

84-
public static class ActionCommand extends Command<Action> {
84+
public static class ActionCommand extends Command<ActionEntity> {
8585

8686
/**
8787
* The key/value arguments for the command, if no arguments exist this property SHOULD NOT be defined
8888
*/
8989
@JsonProperty(Key.COMMAND_ARGUMENT)
90-
private Action argument;
90+
private ActionEntity argument;
9191

9292
public ActionCommand() {
9393
//Empty constructor for serialization
9494
}
9595

9696
public ActionCommand(ActionCommand other) {
9797
super(other);
98-
this.argument = new Action(other.argument);
98+
this.argument = new ActionEntity(other.argument);
9999
}
100100

101101
@Override
102-
public Action getArgument() {
102+
public ActionEntity getArgument() {
103103
return argument;
104104
}
105105

106-
public void setArgument(Action argument) {
106+
public void setArgument(ActionEntity argument) {
107107
this.argument = argument;
108108
}
109109

0 commit comments

Comments
 (0)