├── .classpath
├── .gitattributes
├── .gitignore
├── .project
├── .settings
├── com.google.appengine.eclipse.core.prefs
├── com.google.gdt.eclipse.core.prefs
├── org.eclipse.jdt.core.prefs
└── org.eclipse.wst.common.project.facet.core.xml
├── README.md
├── src
├── META-INF
│ ├── jdoconfig.xml
│ └── persistence.xml
├── com
│ └── mindstorm
│ │ └── famousquotes
│ │ ├── entity
│ │ └── Quote.java
│ │ └── service
│ │ ├── QuoteService.java
│ │ └── QuoteServiceAPI.java
└── log4j.properties
└── war
├── WEB-INF
├── appengine-web.xml
├── logging.properties
└── web.xml
├── favicon.ico
└── index.html
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .metadata
7 | bin/
8 | tmp/
9 | *.tmp
10 | *.bak
11 | *.swp
12 | *~.nib
13 | local.properties
14 | .loadpath
15 |
16 | # External tool builders
17 | .externalToolBuilders/
18 |
19 | # Locally stored "Eclipse launch configurations"
20 | *.launch
21 |
22 | # CDT-specific
23 | .cproject
24 |
25 | # PDT-specific
26 | .buildpath
27 |
28 |
29 | #################
30 | ## Visual Studio
31 | #################
32 |
33 | ## Ignore Visual Studio temporary files, build results, and
34 | ## files generated by popular Visual Studio add-ons.
35 |
36 | # User-specific files
37 | *.suo
38 | *.user
39 | *.sln.docstates
40 |
41 | # Build results
42 |
43 | [Dd]ebug/
44 | [Rr]elease/
45 | x64/
46 | build/
47 | [Bb]in/
48 | [Oo]bj/
49 |
50 | # MSTest test Results
51 | [Tt]est[Rr]esult*/
52 | [Bb]uild[Ll]og.*
53 |
54 | *_i.c
55 | *_p.c
56 | *.ilk
57 | *.meta
58 | *.obj
59 | *.pch
60 | *.pdb
61 | *.pgc
62 | *.pgd
63 | *.rsp
64 | *.sbr
65 | *.tlb
66 | *.tli
67 | *.tlh
68 | *.tmp
69 | *.tmp_proj
70 | *.log
71 | *.vspscc
72 | *.vssscc
73 | .builds
74 | *.pidb
75 | *.log
76 | *.scc
77 |
78 | # Visual C++ cache files
79 | ipch/
80 | *.aps
81 | *.ncb
82 | *.opensdf
83 | *.sdf
84 | *.cachefile
85 |
86 | # Visual Studio profiler
87 | *.psess
88 | *.vsp
89 | *.vspx
90 |
91 | # Guidance Automation Toolkit
92 | *.gpState
93 |
94 | # ReSharper is a .NET coding add-in
95 | _ReSharper*/
96 | *.[Rr]e[Ss]harper
97 |
98 | # TeamCity is a build add-in
99 | _TeamCity*
100 |
101 | # DotCover is a Code Coverage Tool
102 | *.dotCover
103 |
104 | # NCrunch
105 | *.ncrunch*
106 | .*crunch*.local.xml
107 |
108 | # Installshield output folder
109 | [Ee]xpress/
110 |
111 | # DocProject is a documentation generator add-in
112 | DocProject/buildhelp/
113 | DocProject/Help/*.HxT
114 | DocProject/Help/*.HxC
115 | DocProject/Help/*.hhc
116 | DocProject/Help/*.hhk
117 | DocProject/Help/*.hhp
118 | DocProject/Help/Html2
119 | DocProject/Help/html
120 |
121 | # Click-Once directory
122 | publish/
123 |
124 | # Publish Web Output
125 | *.Publish.xml
126 | *.pubxml
127 |
128 | # NuGet Packages Directory
129 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
130 | #packages/
131 |
132 | # Windows Azure Build Output
133 | csx
134 | *.build.csdef
135 |
136 | # Windows Store app package directory
137 | AppPackages/
138 |
139 | # Others
140 | sql/
141 | *.Cache
142 | ClientBin/
143 | [Ss]tyle[Cc]op.*
144 | ~$*
145 | *~
146 | *.dbmdl
147 | *.[Pp]ublish.xml
148 | *.pfx
149 | *.publishsettings
150 |
151 | # RIA/Silverlight projects
152 | Generated_Code/
153 |
154 | # Backup & report files from converting an old project file to a newer
155 | # Visual Studio version. Backup files are not needed, because we have git ;-)
156 | _UpgradeReport_Files/
157 | Backup*/
158 | UpgradeLog*.XML
159 | UpgradeLog*.htm
160 |
161 | # SQL Server files
162 | App_Data/*.mdf
163 | App_Data/*.ldf
164 |
165 | #############
166 | ## Windows detritus
167 | #############
168 |
169 | # Windows image file caches
170 | Thumbs.db
171 | ehthumbs.db
172 |
173 | # Folder config file
174 | Desktop.ini
175 |
176 | # Recycle Bin used on file shares
177 | $RECYCLE.BIN/
178 |
179 | # Mac crap
180 | .DS_Store
181 |
182 |
183 | #############
184 | ## Python
185 | #############
186 |
187 | *.py[co]
188 |
189 | # Packages
190 | *.egg
191 | *.egg-info
192 | dist/
193 | build/
194 | eggs/
195 | parts/
196 | var/
197 | sdist/
198 | develop-eggs/
199 | .installed.cfg
200 |
201 | # Installer logs
202 | pip-log.txt
203 |
204 | # Unit test / coverage reports
205 | .coverage
206 | .tox
207 |
208 | #Translations
209 | *.mo
210 |
211 | #Mr Developer
212 | .mr.developer.cfg
213 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | MyAPIProject
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.common.project.facet.core.builder
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | com.google.gdt.eclipse.core.webAppProjectValidator
20 |
21 |
22 |
23 |
24 | com.google.appengine.eclipse.core.gaeProjectChangeNotifier
25 |
26 |
27 |
28 |
29 | com.google.appengine.eclipse.core.projectValidator
30 |
31 |
32 |
33 |
34 | com.google.appengine.eclipse.core.enhancerbuilder
35 |
36 |
37 |
38 |
39 |
40 | org.eclipse.jdt.core.javanature
41 | com.google.appengine.eclipse.core.gaeNature
42 | org.eclipse.wst.common.project.facet.core.nature
43 |
44 |
45 |
--------------------------------------------------------------------------------
/.settings/com.google.appengine.eclipse.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | filesCopiedToWebInfLib=appengine-api-1.0-sdk-1.8.7.jar|appengine-api-labs.jar|appengine-endpoints.jar|appengine-jsr107cache-1.8.7.jar|asm-4.0.jar|datanucleus-api-jdo-3.1.3.jar|datanucleus-api-jpa-3.1.3.jar|datanucleus-appengine-2.1.2.jar|datanucleus-core-3.1.3.jar|geronimo-jpa_2.0_spec-1.0.jar|jdo-api-3.0.1.jar|jsr107cache-1.1.jar|jta-1.1.jar
3 | gaeDatanucleusVersion=v2
4 | gaeHrdEnabled=true
5 |
--------------------------------------------------------------------------------
/.settings/com.google.gdt.eclipse.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | warSrcDir=war
3 | warSrcDirIsOutput=true
4 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4 | org.eclipse.jdt.core.compiler.compliance=1.6
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.source=1.6
8 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | MyAPIProject
2 | ============
3 |
4 | Google Cloud Endpoints Project
5 |
6 | Blog Post : http://rominirani.com/2014/01/10/google-cloud-endpoints-tutorial-part-1/
7 | Official Documentation : https://developers.google.com/appengine/docs/java/endpoints/
8 |
--------------------------------------------------------------------------------
/src/META-INF/jdoconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/META-INF/persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | org.datanucleus.api.jpa.PersistenceProviderImpl
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/com/mindstorm/famousquotes/entity/Quote.java:
--------------------------------------------------------------------------------
1 | package com.mindstorm.famousquotes.entity;
2 |
3 | public class Quote {
4 | Integer id;
5 | String author;
6 | String message;
7 |
8 | public Quote() {
9 | }
10 |
11 | public Quote(Integer id) {
12 | super();
13 | this.id = id;
14 | }
15 |
16 | public Quote(Integer id, String author, String message) {
17 | super();
18 | this.id = id;
19 | this.author = author;
20 | this.message = message;
21 | }
22 |
23 | public Integer getId() {
24 | return id;
25 | }
26 |
27 | public void setId(Integer id) {
28 | this.id = id;
29 | }
30 |
31 | public String getAuthor() {
32 | return author;
33 | }
34 |
35 | public void setAuthor(String author) {
36 | this.author = author;
37 | }
38 |
39 | public String getMessage() {
40 | return message;
41 | }
42 |
43 | public void setMessage(String message) {
44 | this.message = message;
45 | }
46 |
47 | @Override
48 | public int hashCode() {
49 | final int prime = 31;
50 | int result = 1;
51 | result = prime * result + ((id == null) ? 0 : id.hashCode());
52 | return result;
53 | }
54 |
55 | @Override
56 | public boolean equals(Object obj) {
57 | if (this == obj)
58 | return true;
59 | if (obj == null)
60 | return false;
61 | if (getClass() != obj.getClass())
62 | return false;
63 | Quote other = (Quote) obj;
64 | if (id == null) {
65 | if (other.id != null)
66 | return false;
67 | } else if (!id.equals(other.id))
68 | return false;
69 | return true;
70 | }
71 |
72 | @Override
73 | public String toString() {
74 | return "Quote [id=" + id + ", author=" + author + ", message="
75 | + message + "]";
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/com/mindstorm/famousquotes/service/QuoteService.java:
--------------------------------------------------------------------------------
1 | package com.mindstorm.famousquotes.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import com.mindstorm.famousquotes.entity.Quote;
7 |
8 | public class QuoteService {
9 |
10 | public static List quotes = new ArrayList();
11 |
12 | public Quote addQuote(Integer id, String author, String message) throws Exception {
13 | //Check for already exists
14 | int index = quotes.indexOf(new Quote(id));
15 | if (index != -1) throw new Exception("Quote Record already exists");
16 | Quote q = new Quote(id, author, message);
17 | quotes.add(q);
18 | return q;
19 | }
20 |
21 | public Quote updateQuote(Quote q) throws Exception {
22 | int index = quotes.indexOf(q);
23 | if (index == -1) throw new Exception("Quote Record does not exist");
24 | Quote currentQuote = quotes.get(index);
25 | currentQuote.setAuthor(q.getAuthor());
26 | currentQuote.setMessage(q.getMessage());
27 | return q;
28 | }
29 |
30 | public void removeQuote(Integer id) throws Exception {
31 | int index = quotes.indexOf(new Quote(id));
32 | if (index == -1)
33 | throw new Exception("Quote Record does not exist");
34 | quotes.remove(index);
35 | }
36 |
37 | public List getQuotes() {
38 | return quotes;
39 | }
40 |
41 | public List getQuotesByAuthor(String author) {
42 | List results = new ArrayList();
43 | for (Quote quote : quotes) {
44 | if (quote.getAuthor().indexOf(author) != -1) {
45 | results.add(quote);
46 | }
47 | }
48 | return results;
49 | }
50 |
51 | public Quote getQuote(Integer id) throws Exception {
52 | int index = quotes.indexOf(new Quote(id));
53 | if (index == -1)
54 | throw new Exception("Quote Record does not exist");
55 | return quotes.get(index);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/com/mindstorm/famousquotes/service/QuoteServiceAPI.java:
--------------------------------------------------------------------------------
1 | package com.mindstorm.famousquotes.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import com.google.api.server.spi.config.Api;
7 | import com.google.api.server.spi.config.ApiMethod;
8 | import com.google.api.server.spi.config.Named;
9 | import com.google.api.server.spi.response.NotFoundException;
10 | import com.mindstorm.famousquotes.entity.Quote;
11 |
12 | @Api(name="quoteapi",version="v1", description="An API to manage famous quotes")
13 | public class QuoteServiceAPI {
14 |
15 | public static List quotes = new ArrayList();
16 |
17 | @ApiMethod(name="add")
18 | public Quote addQuote(@Named("id") Integer id, @Named("author") String author, @Named("message") String message) throws NotFoundException {
19 | //Check for already exists
20 | int index = quotes.indexOf(new Quote(id));
21 | if (index != -1) throw new NotFoundException("Quote Record already exists");
22 |
23 | Quote q = new Quote(id, author, message);
24 | quotes.add(q);
25 | return q;
26 | }
27 |
28 | @ApiMethod(name="update")
29 | public Quote updateQuote(Quote q) throws NotFoundException {
30 | int index = quotes.indexOf(q);
31 | if (index == -1)
32 | throw new NotFoundException("Quote Record does not exist");
33 | Quote currentQuote = quotes.get(index);
34 | currentQuote.setAuthor(q.getAuthor());
35 | currentQuote.setMessage(q.getMessage());
36 | return q;
37 | }
38 |
39 | @ApiMethod(name="remove")
40 | public void removeQuote(@Named("id") Integer id) throws NotFoundException {
41 | int index = quotes.indexOf(new Quote(id));
42 | if (index == -1)
43 | throw new NotFoundException("Quote Record does not exist");
44 | quotes.remove(index);
45 | }
46 |
47 | @ApiMethod(name="list")
48 | public List getQuotes() {
49 | return quotes;
50 | }
51 |
52 | @ApiMethod(name="listByAuthor")
53 | public List getQuotesByAuthor(@Named("author") String author) {
54 | List results = new ArrayList();
55 | for (Quote quote : quotes) {
56 | if (quote.getAuthor().indexOf(author) != -1) {
57 | results.add(quote);
58 | }
59 | }
60 | return results;
61 | }
62 |
63 | @ApiMethod(name="getQuote")
64 | public Quote getQuote(@Named("id") Integer id) throws NotFoundException {
65 | int index = quotes.indexOf(new Quote(id));
66 | if (index == -1)
67 | throw new NotFoundException("Quote Record does not exist");
68 | return quotes.get(index);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/log4j.properties:
--------------------------------------------------------------------------------
1 | # A default log4j configuration for log4j users.
2 | #
3 | # To use this configuration, deploy it into your application's WEB-INF/classes
4 | # directory. You are also encouraged to edit it as you like.
5 |
6 | # Configure the console as our one appender
7 | log4j.appender.A1=org.apache.log4j.ConsoleAppender
8 | log4j.appender.A1.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n
10 |
11 | # tighten logging on the DataNucleus Categories
12 | log4j.category.DataNucleus.JDO=WARN, A1
13 | log4j.category.DataNucleus.Persistence=WARN, A1
14 | log4j.category.DataNucleus.Cache=WARN, A1
15 | log4j.category.DataNucleus.MetaData=WARN, A1
16 | log4j.category.DataNucleus.General=WARN, A1
17 | log4j.category.DataNucleus.Utility=WARN, A1
18 | log4j.category.DataNucleus.Transaction=WARN, A1
19 | log4j.category.DataNucleus.Datastore=WARN, A1
20 | log4j.category.DataNucleus.ClassLoading=WARN, A1
21 | log4j.category.DataNucleus.Plugin=WARN, A1
22 | log4j.category.DataNucleus.ValueGeneration=WARN, A1
23 | log4j.category.DataNucleus.Enhancer=WARN, A1
24 | log4j.category.DataNucleus.SchemaTool=WARN, A1
25 |
--------------------------------------------------------------------------------
/war/WEB-INF/appengine-web.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | helloapi123
4 | 1
5 |
6 |
9 | true
10 |
11 |
12 |
13 |
14 |
15 |
16 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/war/WEB-INF/logging.properties:
--------------------------------------------------------------------------------
1 | # A default java.util.logging configuration.
2 | # (All App Engine logging is through java.util.logging by default).
3 | #
4 | # To use this configuration, copy it into your application's WEB-INF
5 | # folder and add the following to your appengine-web.xml:
6 | #
7 | #
8 | #
9 | #
10 | #
11 |
12 | # Set the default logging level for all loggers to WARNING
13 | .level = WARNING
14 |
--------------------------------------------------------------------------------
/war/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | index.html
4 |
5 |
6 | SystemServiceServlet
7 | com.google.api.server.spi.SystemServiceServlet
8 |
9 | services
10 | com.mindstorm.famousquotes.service.QuoteServiceAPI
11 |
12 |
13 |
14 | SystemServiceServlet
15 | /_ah/spi/*
16 |
17 |
--------------------------------------------------------------------------------
/war/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rominirani/MyAPIProject/199fe78532ef864ed66bbed274c62f87b76e5961/war/favicon.ico
--------------------------------------------------------------------------------
/war/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Hello Cloud Endpoints API
13 |
14 |
15 |
16 | Hello Cloud Endpoints API Tutorial
17 |
18 |
29 |
30 |
31 |
--------------------------------------------------------------------------------