Skip to content

Commit

Permalink
Releasing alexa-skills-kit-1.2
Browse files Browse the repository at this point in the history
- added locale and audioplayer directives
  • Loading branch information
Brendan Clement committed Nov 16, 2016
1 parent 121336d commit d52a5f4
Show file tree
Hide file tree
Showing 113 changed files with 5,104 additions and 593 deletions.
140 changes: 140 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.amazon.alexa</groupId>
<artifactId>alexa-skills-kit</artifactId>
<packaging>jar</packaging>
<version>1.2</version>
<name>Alexa Skills Kit</name>
<description>Contains classes used by the Alexa Skills Kit.</description>
<url>http://developer.amazon.com/ask</url>
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<name>Alexa Skills Kit</name>
<email>dis-sdk-team@amazon.com</email>
<organization>Alexa</organization>
<organizationUrl>http://developer.amazon.com/ask</organizationUrl>
</developer>
</developers>
<scm>
<connection>scm:git:https://github.com/amzn/alexa-skills-kit-java.git</connection>
<developerConnection>scm:git:https://github.com/amzn/alexa-skills-kit-java.git</developerConnection>
<url>https://github.com/amzn/alexa-skills-kit-java.git</url>
</scm>

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>publishing</id>
<build>
<plugins>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.5.1</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype-nexus-staging</serverId>
<nexusUrl>https://oss.sonatype.org</nexusUrl>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
24 changes: 12 additions & 12 deletions src/com/amazon/speech/Sdk.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/**
Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
/*
Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
*/

package com.amazon.speech;
Expand Down Expand Up @@ -112,8 +115,8 @@ public final class Sdk {
* <p>
* The {@link com.amazon.speech.speechlet.servlet.SpeechletServlet} class enforces request
* signing to ensure that all requests processed by your web service are legitimate and come
* from the Alexa service. In order to test your service with a tool like {@code curl}, you
* need to disable this mechanism. This is controlled by the
* from the Alexa service. In order to test your service with a tool like {@code curl}, you need
* to disable this mechanism. This is controlled by the
* {@code com.amazon.speech.speechlet.servlet.disableRequestSignatureCheck} system property,
* which is defined by this constant.
* </p>
Expand All @@ -133,11 +136,10 @@ public final class Sdk {
* <java classname="Launcher" classpathref="java.sdk.classpath" fork="true">
* <sysproperty key="com.amazon.speech.speechlet.servlet.disableRequestSignatureCheck"
* value="true" />
* </java>
* }
* </pre>
*
* </p>
*
* <p>
* Disabling request signing verification is only acceptable for developing and testing. Your
* production system should always verify incoming requests.
Expand Down Expand Up @@ -174,10 +176,9 @@ public final class Sdk {
* <java classname="Launcher" classpathref="java.sdk.classpath" fork="true">
* <sysproperty key="com.amazon.speech.speechlet.servlet.supportedApplicationIds"
* value="amzn1.echo-sdk-ams.app.1234,amzn1.echo-sdk-ams.app.5678" />
* </java>
* }
* </pre>
*
* </p>
*/
public static final String SUPPORTED_APPLICATION_IDS_SYSTEM_PROPERTY =
"com.amazon.speech.speechlet.servlet.supportedApplicationIds";
Expand Down Expand Up @@ -206,11 +207,10 @@ public final class Sdk {
* <java classname="Launcher" classpathref="java.sdk.classpath" fork="true">
* <sysproperty key="com.amazon.speech.speechlet.servlet.timestampTolerance"
* value="150" />
* </java>
* }
* </pre>
*
* </p>
*
* <p>
* Disabling timestamp verification is only acceptable for developing and testing. Your
* production system should always verify timestamps on incoming requests. We permit a tolerance
Expand Down
49 changes: 49 additions & 0 deletions src/com/amazon/speech/json/ContextDeserializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
*/

package com.amazon.speech.json;

import java.io.IOException;

import com.amazon.speech.speechlet.Context;
import com.amazon.speech.speechlet.State;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;

class ContextDeserializer extends StdDeserializer<Context> {
ContextDeserializer() {
super(Context.class);
}

@Override
public Context deserialize(JsonParser parser, DeserializationContext context)
throws IOException {
ObjectMapper underlyingMapper = ((ObjectMapper) parser.getCodec());
JsonNode messageNode = parser.readValueAsTree();
Context.Builder contextBuilder = Context.builder();

for (SerializedInterface interfaceName : SerializedInterface.values()) {
if (messageNode.has(interfaceName.name())) {
State<?> state =
underlyingMapper.convertValue(messageNode.get(interfaceName.name()),
interfaceName.getStateClass());
contextBuilder.addState(state);
}
}

return contextBuilder.build();
}
}
45 changes: 45 additions & 0 deletions src/com/amazon/speech/json/ContextSerializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
*/

package com.amazon.speech.json;

import java.io.IOException;

import com.amazon.speech.speechlet.Context;
import com.amazon.speech.speechlet.State;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

class ContextSerializer extends StdSerializer<Context> {
ContextSerializer() {
super(Context.class);
}

@Override
public void serialize(Context context, JsonGenerator jgen, SerializerProvider provider)
throws IOException {
jgen.writeStartObject();

for (SerializedInterface interfaceName : SerializedInterface.values()) {
if (context.hasState(interfaceName.getInterfaceClass())) {
@SuppressWarnings("unchecked")
State<?> state = context.getState(interfaceName.getInterfaceClass(), State.class);
jgen.writeFieldName(interfaceName.name());
jgen.writeObject(state);
}
}

jgen.writeEndObject();
}
}
43 changes: 43 additions & 0 deletions src/com/amazon/speech/json/SerializedInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
*/

package com.amazon.speech.json;

import com.amazon.speech.speechlet.Interface;
import com.amazon.speech.speechlet.State;
import com.amazon.speech.speechlet.interfaces.audioplayer.AudioPlayerInterface;
import com.amazon.speech.speechlet.interfaces.audioplayer.AudioPlayerState;
import com.amazon.speech.speechlet.interfaces.system.SystemInterface;
import com.amazon.speech.speechlet.interfaces.system.SystemState;

enum SerializedInterface {
AudioPlayer(AudioPlayerInterface.class, AudioPlayerState.class),
System(SystemInterface.class, SystemState.class);

private final Class<? extends Interface> interfaceClass;
private final Class<? extends State> stateClass;

SerializedInterface(final Class<? extends Interface> interfaceClass,
final Class<? extends State> stateClass) {
this.interfaceClass = interfaceClass;
this.stateClass = stateClass;
}

protected <T extends Interface> Class<T> getInterfaceClass() {
return (Class<T>) interfaceClass;
}

protected <T extends State> Class<T> getStateClass() {
return (Class<T>) stateClass;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
*/

package com.amazon.speech.json;

import com.amazon.speech.speechlet.Context;
import com.amazon.speech.speechlet.SupportedInterfaces;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.DeserializationConfig;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier;

class SpeechletRequestBeanDeserializerModifier extends BeanDeserializerModifier {
@Override
public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config,
BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
if (Context.class.isAssignableFrom(beanDesc.getBeanClass())) {
return new ContextDeserializer();
} else if (SupportedInterfaces.class.isAssignableFrom(beanDesc.getBeanClass())) {
return new SupportedInterfacesDeserializer();
} else {
return deserializer;
}
}
}

0 comments on commit d52a5f4

Please sign in to comment.