Skip to content
This repository was archived by the owner on Jul 28, 2023. It is now read-only.

Commit 7f6ef6d

Browse files
author
zhangzhx
committed
AWS Toolkit for Eclipse: v201710260046 Release.
1 parent 0095935 commit 7f6ef6d

File tree

44 files changed

+267
-169
lines changed

Some content is hidden

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

44 files changed

+267
-169
lines changed

CHANGELOG.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"current": [
3+
"* Update Java SDK samples."
4+
],
5+
"v201710231659": [
36
"* Refine the Maven configuration component to have consistent behavior.",
47
"* Update AWS logo."
58
],
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
package com.amazonaws.eclipse.core.util;
16+
17+
import java.io.File;
18+
import java.io.IOException;
19+
import java.net.URI;
20+
import java.net.URISyntaxException;
21+
import java.net.URL;
22+
23+
import org.eclipse.core.runtime.FileLocator;
24+
import org.osgi.framework.Bundle;
25+
26+
/**
27+
* Utilities for Bundle management.
28+
*/
29+
public class BundleUtils {
30+
31+
/**
32+
* Return the actual file location in the bundle. The bundle could be a regular folder, or a jar file.
33+
*/
34+
public static File getFileFromBundle(Bundle bundle, String... path) throws IOException, URISyntaxException {
35+
URL rootUrl = FileLocator.toFileURL(bundle.getEntry("/"));
36+
URI resolvedUrl = new URI(rootUrl.getProtocol(), rootUrl.getPath(), null);
37+
File file = new File(resolvedUrl);
38+
for (String segment : path) {
39+
file = new File(file, segment);
40+
}
41+
return file;
42+
}
43+
}

bundles/com.amazonaws.eclipse.elasticbeanstalk/src/com/amazonaws/eclipse/elasticbeanstalk/webproject/CreateNewAwsJavaWebProjectRunnable.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.io.File;
2020
import java.io.IOException;
2121
import java.lang.reflect.InvocationTargetException;
22+
import java.net.URI;
23+
import java.net.URISyntaxException;
2224
import java.net.URL;
2325
import java.util.List;
2426

@@ -47,6 +49,7 @@
4749
import com.amazonaws.eclipse.core.AwsToolkitCore;
4850
import com.amazonaws.eclipse.core.maven.MavenFactory;
4951
import com.amazonaws.eclipse.core.model.MavenConfigurationDataModel;
52+
import com.amazonaws.eclipse.core.util.BundleUtils;
5053
import com.amazonaws.eclipse.core.validator.JavaPackageName;
5154
import com.amazonaws.eclipse.elasticbeanstalk.ElasticBeanstalkPlugin;
5255

@@ -175,16 +178,19 @@ private void addTemplateFiles(IProject project) throws IOException, CoreExceptio
175178
final String PACKAGE_NAME_PLACEHOLDER = "{PACKAGE_NAME}";
176179

177180
Bundle bundle = ElasticBeanstalkPlugin.getDefault().getBundle();
178-
URL url = FileLocator.resolve(bundle.getEntry("/"));
179-
IPath templateRoot = new Path(url.getFile(), "templates");
180-
181+
File templateRoot = null;
182+
try {
183+
templateRoot = BundleUtils.getFileFromBundle(bundle, "templates");
184+
} catch (URISyntaxException e) {
185+
throw new RuntimeException("Failed to load templates from ElasticBeanstalk bundle.", e);
186+
}
181187
AccountInfo currentAccountInfo = AwsToolkitCore.getDefault().getAccountManager().getAccountInfo(dataModel.getAccountId());
182188
File pomFile = project.getFile("pom.xml").getLocation().toFile();
183189
MavenConfigurationDataModel mavenConfig = dataModel.getMavenConfigurationDataModel();
184190

185191
switch (dataModel.getProjectTemplate()) {
186192
case WORKER:
187-
replacePomFile(templateRoot.append("worker/pom.xml").toFile(),
193+
replacePomFile(new File(templateRoot, "worker/pom.xml"),
188194
mavenConfig.getGroupId(), mavenConfig.getArtifactId(), mavenConfig.getVersion(), pomFile);
189195
String packageName = dataModel.getMavenConfigurationDataModel().getPackageName();
190196

@@ -194,7 +200,7 @@ private void addTemplateFiles(IProject project) throws IOException, CoreExceptio
194200
location = location.append(component);
195201
}
196202

197-
FileUtils.copyDirectory(templateRoot.append("worker/src").toFile(),
203+
FileUtils.copyDirectory(new File(templateRoot, "worker/src"),
198204
location.toFile());
199205

200206
File workerServlet = location.append("WorkerServlet.java").toFile();
@@ -205,19 +211,19 @@ private void addTemplateFiles(IProject project) throws IOException, CoreExceptio
205211

206212
location = project.getFile("src/main/webapp").getLocation();
207213
FileUtils.copyDirectory(
208-
templateRoot.append("worker/WebContent/").toFile(),
214+
new File(templateRoot, "worker/WebContent/"),
209215
location.toFile());
210216
File webXml = location.append("WEB-INF/web.xml").toFile();
211217
replaceStringInFile(webXml, PACKAGE_NAME_PLACEHOLDER, packageName);
212218
break;
213219

214220
case DEFAULT:
215-
replacePomFile(templateRoot.append("basic/pom.xml").toFile(),
221+
replacePomFile(new File(templateRoot, "basic/pom.xml"),
216222
mavenConfig.getGroupId(), mavenConfig.getArtifactId(), mavenConfig.getVersion(), pomFile);
217223

218224
location = project.getFile("src/main/webapp").getLocation();
219225
FileUtils.copyDirectory(
220-
templateRoot.append("basic/WebContent").toFile(),
226+
new File(templateRoot, "basic/WebContent"),
221227
location.toFile());
222228

223229
File indexJsp = location.append("index.jsp").toFile();

bundles/com.amazonaws.eclipse.lambda/src/com/amazonaws/eclipse/lambda/model/LambdaFunctionDataModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public String getInputType() {
7474
}
7575

7676
public void setInputType(String inputType) {
77-
this.setProperty(P_INPUT_TYPE, inputType, this::getInputType, (newValue) -> this.inputType = newValue);
7877
this.selectedBlueprint = getLambdaBlueprint(inputType);
78+
this.setProperty(P_INPUT_TYPE, inputType, this::getInputType, (newValue) -> this.inputType = newValue);
7979
}
8080

8181
public LambdaBlueprint getSelectedBlueprint() {

bundles/com.amazonaws.eclipse.lambda/src/com/amazonaws/eclipse/lambda/project/wizard/util/LambdaFunctionComposite.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.io.IOException;
2626

2727
import org.eclipse.core.databinding.DataBindingContext;
28-
import org.eclipse.core.databinding.beans.PojoObservables;
28+
import org.eclipse.core.databinding.beans.PojoProperties;
2929
import org.eclipse.jdt.internal.ui.JavaPlugin;
3030
import org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer;
3131
import org.eclipse.jdt.internal.ui.text.SimpleJavaSourceViewerConfiguration;
@@ -117,7 +117,7 @@ public void createClassNameControl() {
117117
this.classNameComplex = TextComplex.builder()
118118
.composite(inputComposite)
119119
.dataBindingContext(dataBindingContext)
120-
.pojoObservableValue(PojoObservables.observeValue(dataModel, P_CLASS_NAME))
120+
.pojoObservableValue(PojoProperties.value(LambdaFunctionDataModel.class, P_CLASS_NAME).observe(dataModel))
121121
.addValidator(new NotEmptyValidator("Please provide a valid class name for the handler"))
122122
.labelValue("Class Name:")
123123
.defaultValue(dataModel.getClassName())
@@ -129,7 +129,7 @@ public void createInputTypeControl() {
129129
this.inputTypeComplex = ComboComplex.<LambdaBlueprint> builder()
130130
.composite(inputComposite)
131131
.dataBindingContext(dataBindingContext)
132-
.pojoObservableValue(PojoObservables.observeValue(dataModel, P_INPUT_TYPE))
132+
.pojoObservableValue(PojoProperties.value(LambdaFunctionDataModel.class, P_INPUT_TYPE).observe(dataModel))
133133
.labelValue("Input Type:")
134134
.items(lambdaBlueprintConfig.getBlueprints().values())
135135
.defaultItemName(dataModel.getInputType())

bundles/com.amazonaws.eclipse.sdk.ui/samples/AmazonDynamoDB/AmazonDynamoDBSample.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.
@@ -21,7 +21,8 @@
2121
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
2222
import com.amazonaws.regions.Region;
2323
import com.amazonaws.regions.Regions;
24-
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
24+
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
25+
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
2526
import com.amazonaws.services.dynamodbv2.model.AttributeDefinition;
2627
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
2728
import com.amazonaws.services.dynamodbv2.model.ComparisonOperator;
@@ -58,7 +59,7 @@ public class AmazonDynamoDBSample {
5859
* the credentials file in your source directory.
5960
*/
6061

61-
static AmazonDynamoDBClient dynamoDB;
62+
static AmazonDynamoDB dynamoDB;
6263

6364
/**
6465
* The only information needed to create a client are security credentials
@@ -77,19 +78,20 @@ private static void init() throws Exception {
7778
* credential profile by reading from the credentials file located at
7879
* (~/.aws/credentials).
7980
*/
80-
AWSCredentials credentials = null;
81+
ProfileCredentialsProvider credentialsProvider = new ProfileCredentialsProvider();
8182
try {
82-
credentials = new ProfileCredentialsProvider().getCredentials();
83+
credentialsProvider.getCredentials();
8384
} catch (Exception e) {
8485
throw new AmazonClientException(
8586
"Cannot load the credentials from the credential profiles file. " +
8687
"Please make sure that your credentials file is at the correct " +
8788
"location (~/.aws/credentials), and is in valid format.",
8889
e);
8990
}
90-
dynamoDB = new AmazonDynamoDBClient(credentials);
91-
Region usWest2 = Region.getRegion(Regions.US_WEST_2);
92-
dynamoDB.setRegion(usWest2);
91+
dynamoDB = AmazonDynamoDBClientBuilder.standard()
92+
.withCredentials(credentialsProvider)
93+
.withRegion("us-west-2")
94+
.build();
9395
}
9496

9597
public static void main(String[] args) throws Exception {

bundles/com.amazonaws.eclipse.sdk.ui/samples/AmazonDynamoDBDocumentAPI/quick-start/com/amazonaws/services/dynamodbv2/document/quickstart/A_CreateTableTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.

bundles/com.amazonaws.eclipse.sdk.ui/samples/AmazonDynamoDBDocumentAPI/quick-start/com/amazonaws/services/dynamodbv2/document/quickstart/B_PutItemJacksonTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.

bundles/com.amazonaws.eclipse.sdk.ui/samples/AmazonDynamoDBDocumentAPI/quick-start/com/amazonaws/services/dynamodbv2/document/quickstart/B_PutItemJsonTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.

bundles/com.amazonaws.eclipse.sdk.ui/samples/AmazonDynamoDBDocumentAPI/quick-start/com/amazonaws/services/dynamodbv2/document/quickstart/B_PutItemTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
55
* You may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)