12 |
--------------------------------------------------------------------------------
/mongodb-myrestaurants-analytics/src/main/java/org/springframework/data/document/web/servlet/ActionInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2010 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.document.web.servlet;
17 |
18 | public interface ActionInterceptor {
19 |
20 | boolean preHandle(ActionExecutingContext actionExecutingContext);
21 |
22 | void postHandle(ActionExecutedContext actionExecutedContext);
23 |
24 | void afterCompletion(ActionExecutedContext actionExecutedContext);
25 | }
26 |
--------------------------------------------------------------------------------
/mongodb-myrestaurants-analytics/src/main/resources/META-INF/persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | org.hibernate.ejb.HibernatePersistence
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/mongodb-myrestaurants-analytics/src/main/webapp/WEB-INF/views/restaurants/create.jspx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/http/HttpMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.http;
18 |
19 | /**
20 | * Java 5 enumeration of HTTP request methods. Intended for use
21 | * with {@link org.springframework.http.client.ClientHttpRequest}
22 | * and {@link org.springframework.web.client.RestTemplate}.
23 | *
24 | * @author Arjen Poutsma
25 | * @since 3.0
26 | */
27 | public enum HttpMethod {
28 |
29 | GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants/src/main/webapp/WEB-INF/views/useraccounts/update.jspx:
--------------------------------------------------------------------------------
1 |
2 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/http/HttpMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.http;
18 |
19 | /**
20 | * Represents the base interface for HTTP request and response messages. Consists of {@link HttpHeaders}, retrievable
21 | * via {@link #getHeaders()}.
22 | *
23 | * @author Arjen Poutsma
24 | * @since 3.0
25 | */
26 | public interface HttpMessage {
27 |
28 | /**
29 | * Return the headers of this message.
30 | * @return a corresponding HttpHeaders object
31 | */
32 | HttpHeaders getHeaders();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/mongodb-myrestaurants-analytics/src/main/webapp/WEB-INF/layouts/default.jspx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/http/HttpInputMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2010 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.http;
18 |
19 | import java.io.IOException;
20 | import java.io.InputStream;
21 |
22 | /**
23 | * Represents an HTTP input message, consisting of {@linkplain #getHeaders() headers}
24 | * and a readable {@linkplain #getBody() body}.
25 | *
26 | *
Typically implemented by an HTTP request on the server-side, or a response on the client-side.
27 | *
28 | * @author Arjen Poutsma
29 | * @since 3.0
30 | */
31 | public interface HttpInputMessage extends HttpMessage {
32 |
33 | /**
34 | * Return the body of the message as an input stream.
35 | * @return the input stream body
36 | * @throws IOException in case of I/O Errors
37 | */
38 | InputStream getBody() throws IOException;
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/http/HttpOutputMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2010 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.http;
18 |
19 | import java.io.IOException;
20 | import java.io.OutputStream;
21 |
22 | /**
23 | * Represents an HTTP output message, consisting of {@linkplain #getHeaders() headers}
24 | * and a writable {@linkplain #getBody() body}.
25 | *
26 | *
Typically implemented by an HTTP request on the client-side, or a response on the server-side.
27 | *
28 | * @author Arjen Poutsma
29 | * @since 3.0
30 | */
31 | public interface HttpOutputMessage extends HttpMessage {
32 |
33 | /**
34 | * Return the body of the message as an output stream.
35 | * @return the output stream body
36 | * @throws IOException in case of I/O Errors
37 | */
38 | OutputStream getBody() throws IOException;
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants/src/main/webapp/WEB-INF/views/footer.jspx:
--------------------------------------------------------------------------------
1 |
2 |
37 |
--------------------------------------------------------------------------------
/mongodb-myrestaurants-analytics/src/main/webapp/WEB-INF/views/footer.jspx:
--------------------------------------------------------------------------------
1 |
2 |
37 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/web/client/ResourceAccessException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.web.client;
18 |
19 | import java.io.IOException;
20 |
21 | /**
22 | * Exception thrown when an I/O error occurs.
23 | *
24 | * @author Arjen Poutsma
25 | * @since 3.0
26 | */
27 | public class ResourceAccessException extends RestClientException {
28 |
29 | /**
30 | * Construct a new {@code HttpIOException} with the given message.
31 | * @param msg the message
32 | */
33 | public ResourceAccessException(String msg) {
34 | super(msg);
35 | }
36 |
37 | /**
38 | * Construct a new {@code HttpIOException} with the given message and {@link IOException}.
39 | * @param msg the message
40 | * @param ex the {@code IOException}
41 | */
42 | public ResourceAccessException(String msg, IOException ex) {
43 | super(msg, ex);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/mongodb-hello/src/main/java/org/springframework/data/mongodb/examples/hello/domain/Account.java:
--------------------------------------------------------------------------------
1 | package org.springframework.data.mongodb.examples.hello.domain;
2 |
3 | public class Account {
4 |
5 | public enum Type {
6 | SAVINGS, CHECKING
7 | }
8 |
9 | private String id;
10 |
11 | private String accountNumber;
12 |
13 | private Account.Type accountType;
14 |
15 | private Double balance;
16 |
17 | public Account(){
18 | }
19 |
20 | public Account(String accountNumber, Type accountType, Double balance) {
21 | super();
22 | this.accountNumber = accountNumber;
23 | this.accountType = accountType;
24 | this.balance = balance;
25 | }
26 |
27 | public String getId() {
28 | return id;
29 | }
30 |
31 | public void setId(String id) {
32 | this.id = id;
33 | }
34 |
35 | public String getAccountNumber() {
36 | return accountNumber;
37 | }
38 |
39 | public void setAccountNumber(String accountNumber) {
40 | this.accountNumber = accountNumber;
41 | }
42 |
43 | public Account.Type getAccountType() {
44 | return accountType;
45 | }
46 |
47 | public void setAccountType(Account.Type accountType) {
48 | this.accountType = accountType;
49 | }
50 |
51 | public Double getBalance() {
52 | return balance;
53 | }
54 |
55 | public void setBalance(Double balance) {
56 | this.balance = balance;
57 | }
58 |
59 | @Override
60 | public String toString() {
61 | return "Account [id=" + id + ", accountNumber=" + accountNumber
62 | + ", accountType=" + accountType + ", balance=" + balance + "]";
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants/src/main/java/com/springone/myrestaurants/dao/JpaUserAccountDao.java:
--------------------------------------------------------------------------------
1 | package com.springone.myrestaurants.dao;
2 |
3 | import javax.persistence.EntityManager;
4 | import javax.persistence.PersistenceContext;
5 | import javax.persistence.Query;
6 |
7 | import org.springframework.stereotype.Repository;
8 | import org.springframework.transaction.annotation.Transactional;
9 |
10 | import com.springone.myrestaurants.domain.UserAccount;
11 |
12 | //@Repository
13 | public class JpaUserAccountDao {
14 |
15 | @PersistenceContext
16 | private EntityManager entityManager;
17 |
18 | public UserAccount findUserAccount(Long id) {
19 | if (id == null) return null;
20 | return entityManager.find(UserAccount.class, id);
21 | }
22 |
23 | public UserAccount findByName(String name) {
24 | if (name == null) return null;
25 | Query q = entityManager.createQuery("SELECT u FROM UserAccount u WHERE u.userName = :username");
26 | q.setParameter("username", name);
27 |
28 | java.util.List resultList = q.getResultList();
29 | if (resultList.size() > 0)
30 | {
31 | return (UserAccount) resultList.get(0);
32 | }
33 | return null;
34 | }
35 |
36 | @Transactional
37 | public void persist(UserAccount userAccount) {
38 | this.entityManager.persist(userAccount);
39 | }
40 |
41 | @Transactional
42 | public UserAccount merge(UserAccount userAccount) {
43 | UserAccount merged = this.entityManager.merge(userAccount);
44 | this.entityManager.flush();
45 | return merged;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/mongodb-hello/src/main/java/org/springframework/data/mongodb/examples/hello/domain/Person.java:
--------------------------------------------------------------------------------
1 | package org.springframework.data.mongodb.examples.hello.domain;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.springframework.data.annotation.Id;
7 | import org.springframework.data.mongodb.core.mapping.Document;
8 |
9 | @Document
10 | public class Person {
11 |
12 | @Id
13 | private String id;
14 |
15 | private String name;
16 |
17 | private int age;
18 |
19 | private List accounts = new ArrayList();
20 |
21 | public Person() {
22 | }
23 |
24 | public Person(String name, int age) {
25 | super();
26 | this.name = name;
27 | this.age = age;
28 | }
29 |
30 | public String getId() {
31 | return id;
32 | }
33 |
34 | public void setId(String id) {
35 | this.id = id;
36 | }
37 |
38 | public String getName() {
39 | return name;
40 | }
41 |
42 | public void setName(String name) {
43 | this.name = name;
44 | }
45 |
46 | public int getAge() {
47 | return age;
48 | }
49 |
50 | public void setAge(int age) {
51 | this.age = age;
52 | }
53 |
54 | public List getAccounts() {
55 | return accounts;
56 | }
57 |
58 | public void addAccount(Account account) {
59 | this.accounts.add(account);
60 | }
61 |
62 | public void setAccounts(List accounts) {
63 | this.accounts = accounts;
64 | }
65 |
66 | @Override
67 | public String toString() {
68 | return "Person [id=" + id + ", name=" + name + ", age=" + age
69 | + ", accounts=" + accounts + "]";
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/mongodb-myrestaurants-analytics/src/main/java/com/springone/myrestaurants/dao/UserAccountDao.java:
--------------------------------------------------------------------------------
1 | package com.springone.myrestaurants.dao;
2 |
3 | import javax.persistence.EntityManager;
4 | import javax.persistence.PersistenceContext;
5 | import javax.persistence.Query;
6 |
7 | import org.springframework.stereotype.Repository;
8 | import org.springframework.transaction.annotation.Transactional;
9 |
10 | import com.springone.myrestaurants.domain.UserAccount;
11 |
12 | @Repository
13 | public class UserAccountDao {
14 |
15 | @PersistenceContext
16 | private EntityManager entityManager;
17 |
18 | public UserAccount findUserAccount(Long id) {
19 | if (id == null) return null;
20 | return entityManager.find(UserAccount.class, id);
21 | }
22 |
23 | public UserAccount findByName(String name) {
24 | if (name == null) return null;
25 | Query q = entityManager.createQuery("SELECT u FROM UserAccount u WHERE u.userName = :username");
26 | q.setParameter("username", name);
27 |
28 | java.util.List resultList = q.getResultList();
29 | if (resultList.size() > 0)
30 | {
31 | return (UserAccount) resultList.get(0);
32 | }
33 | return null;
34 | }
35 |
36 | @Transactional
37 | public void persist(UserAccount userAccount) {
38 | this.entityManager.persist(userAccount);
39 | }
40 |
41 | @Transactional
42 | public UserAccount merge(UserAccount userAccount) {
43 | UserAccount merged = this.entityManager.merge(userAccount);
44 | this.entityManager.flush();
45 | return merged;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/res/layout/event_details.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
9 |
10 |
14 |
15 |
21 |
22 |
25 |
26 |
29 |
30 |
33 |
34 |
35 |
36 |
41 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/res/layout/signin.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
21 |
22 |
26 |
27 |
32 |
33 |
34 |
35 |
39 |
40 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/res/layout/remove_event_details.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
9 |
10 |
14 |
15 |
21 |
22 |
25 |
26 |
29 |
30 |
33 |
34 |
35 |
36 |
41 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/http/converter/HttpMessageConversionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.http.converter;
18 |
19 | import org.springframework.core.NestedRuntimeException;
20 |
21 | /**
22 | * Thrown by {@link HttpMessageConverter} implementations when the conversion fails.
23 | *
24 | * @author Arjen Poutsma
25 | * @since 3.0
26 | */
27 | public class HttpMessageConversionException extends NestedRuntimeException {
28 |
29 | /**
30 | * Create a new HttpMessageConversionException.
31 | *
32 | * @param msg the detail message
33 | */
34 | public HttpMessageConversionException(String msg) {
35 | super(msg);
36 | }
37 |
38 | /**
39 | * Create a new HttpMessageConversionException.
40 | *
41 | * @param msg the detail message
42 | * @param cause the root cause (if any)
43 | */
44 | public HttpMessageConversionException(String msg, Throwable cause) {
45 | super(msg, cause);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/web/client/RestClientException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.web.client;
18 |
19 | import org.springframework.core.NestedRuntimeException;
20 |
21 | /**
22 | * Base class for exceptions thrown by {@link RestTemplate} whenever it encounters client-side HTTP errors.
23 | *
24 | * @author Arjen Poutsma
25 | * @since 3.0
26 | */
27 | public class RestClientException extends NestedRuntimeException {
28 |
29 | /**
30 | * Construct a new instance of {@code HttpClientException} with the given message.
31 | * @param msg the message
32 | */
33 | public RestClientException(String msg) {
34 | super(msg);
35 | }
36 |
37 | /**
38 | * Construct a new instance of {@code HttpClientException} with the given message and exception.
39 | * @param msg the message
40 | * @param ex the exception
41 | */
42 | public RestClientException(String msg, Throwable ex) {
43 | super(msg, ex);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/com/springsource/myrestaurants/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.springsource.myrestaurants;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.view.View.OnClickListener;
8 |
9 | import com.springsource.myrestaurants.activities.MainTabWidget;
10 |
11 | public class MainActivity extends Activity {
12 | /** Called when the activity is first created. */
13 | @Override
14 | public void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 |
17 | setContentView(R.layout.signin);
18 |
19 | findViewById(R.id.signin_button).setOnClickListener(new OnClickListener() {
20 | public void onClick(final View view) {
21 | // uncomment the following line (and comment the line after it) to enable the OAuth stuff
22 | //startActivity(new Intent(SignInActivity.this, OAuthActivity.class));
23 | startActivity(new Intent(MainActivity.this, MainTabWidget.class));
24 | finish();
25 | }
26 | });
27 | /*
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.main);
30 | TextView view = new TextView(this);
31 | view.append("Running tests...\n\n");
32 | setContentView(view);
33 | try {
34 | RestaurantDao restDao = new RestaurantDao();
35 | List rests = restDao.findAllRestaurants();
36 | for (Restaurant restaurant : rests) {
37 | view.append(restaurant.toString());
38 | }
39 | view.append("Done!");
40 | } catch (Exception e) {
41 | view.append(e.toString());
42 | Log.e("rest-template", "this is bad", e);
43 | }*/
44 | }
45 | }
--------------------------------------------------------------------------------
/mongodb-hello/src/main/resources/META-INF/spring/applicationContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/http/converter/HttpMessageNotReadableException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.http.converter;
18 |
19 | /**
20 | * Thrown by {@link HttpMessageConverter} implementations when the
21 | * {@link HttpMessageConverter#read(Class, org.springframework.http.HttpInputMessage) read} method fails.
22 | *
23 | * @author Arjen Poutsma
24 | * @since 3.0
25 | */
26 | public class HttpMessageNotReadableException extends HttpMessageConversionException {
27 |
28 | /**
29 | * Create a new HttpMessageNotReadableException.
30 | *
31 | * @param msg the detail message
32 | */
33 | public HttpMessageNotReadableException(String msg) {
34 | super(msg);
35 | }
36 |
37 | /**
38 | * Create a new HttpMessageNotReadableException.
39 | *
40 | * @param msg the detail message
41 | * @param cause the root cause (if any)
42 | */
43 | public HttpMessageNotReadableException(String msg, Throwable cause) {
44 | super(msg, cause);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/http/client/ClientHttpRequestFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.http.client;
18 |
19 | import java.io.IOException;
20 | import java.net.URI;
21 |
22 | import org.springframework.http.HttpMethod;
23 |
24 | /**
25 | * Factory for {@link ClientHttpRequest} objects.
26 | * Requests are created by the {@link #createRequest(URI, HttpMethod)} method.
27 | *
28 | * @author Arjen Poutsma
29 | * @since 3.0
30 | */
31 | public interface ClientHttpRequestFactory {
32 |
33 | /**
34 | * Create a new {@link ClientHttpRequest} for the specified URI and HTTP method.
35 | *
The returned request can be written to, and then executed by calling
36 | * {@link ClientHttpRequest#execute()}.
37 | * @param uri the URI to create a request for
38 | * @param httpMethod the HTTP method to execute
39 | * @return the created request
40 | * @throws IOException in case of I/O errors
41 | */
42 | ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException;
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/http/converter/HttpMessageNotWritableException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.http.converter;
18 |
19 | /**
20 | * Thrown by {@link org.springframework.http.converter.HttpMessageConverter} implementations when the
21 | * {@link org.springframework.http.converter.HttpMessageConverter#write(Object, org.springframework.http.HttpOutputMessage) write} method fails.
22 | *
23 | * @author Arjen Poutsma
24 | * @since 3.0
25 | */
26 | public class HttpMessageNotWritableException extends HttpMessageConversionException {
27 |
28 | /**
29 | * Create a new HttpMessageNotWritableException.
30 | *
31 | * @param msg the detail message
32 | */
33 | public HttpMessageNotWritableException(String msg) {
34 | super(msg);
35 | }
36 |
37 | /**
38 | * Create a new HttpMessageNotWritableException.
39 | *
40 | * @param msg the detail message
41 | * @param cause the root cause (if any)
42 | */
43 | public HttpMessageNotWritableException(String msg, Throwable cause) {
44 | super(msg, cause);
45 | }
46 | }
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/web/client/HttpClientErrorException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2010 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.web.client;
18 |
19 | import org.springframework.http.HttpStatus;
20 |
21 | /**
22 | * Exception thrown when an HTTP 4xx is received.
23 | *
24 | * @author Arjen Poutsma
25 | * @since 3.0
26 | * @see DefaultResponseErrorHandler
27 | */
28 | public class HttpClientErrorException extends HttpStatusCodeException {
29 |
30 | /**
31 | * Construct a new instance of {@code HttpClientErrorException} based on a {@link HttpStatus}.
32 | * @param statusCode the status code
33 | */
34 | public HttpClientErrorException(HttpStatus statusCode) {
35 | super(statusCode);
36 | }
37 |
38 | /**
39 | * Construct a new instance of {@code HttpClientErrorException} based on a {@link HttpStatus} and status text.
40 | * @param statusCode the status code
41 | * @param statusText the status text
42 | */
43 | public HttpClientErrorException(HttpStatus statusCode, String statusText) {
44 | super(statusCode, statusText);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/web/client/HttpServerErrorException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2010 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.web.client;
18 |
19 | import org.springframework.http.HttpStatus;
20 |
21 | /**
22 | * Exception thrown when an HTTP 5xx is received.
23 | *
24 | * @author Arjen Poutsma
25 | * @since 3.0
26 | * @see DefaultResponseErrorHandler
27 | */
28 | public class HttpServerErrorException extends HttpStatusCodeException {
29 |
30 | /**
31 | * Construct a new instance of {@code HttpServerErrorException} based on a {@link HttpStatus}.
32 | * @param statusCode the status code
33 | */
34 | public HttpServerErrorException(HttpStatus statusCode) {
35 | super(statusCode);
36 | }
37 |
38 | /**
39 | * Construct a new instance of {@code HttpServerErrorException} based on a {@link HttpStatus} and status text.
40 | * @param statusCode the status code
41 | * @param statusText the status text
42 | */
43 | public HttpServerErrorException(HttpStatus statusCode, String statusText) {
44 | super(statusCode, statusText);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/mongodb-music/src/main/java/org/springframework/data/mongodb/examples/music/Stars.java:
--------------------------------------------------------------------------------
1 | package org.springframework.data.mongodb.examples.music;
2 |
3 | import java.util.Collection;
4 | import java.util.Collections;
5 | import java.util.HashSet;
6 |
7 | import org.springframework.util.Assert;
8 |
9 |
10 | /**
11 | * Stars capture a rating of a song.
12 | *
13 | * @author Oliver Gierke
14 | */
15 | public class Stars {
16 |
17 | public static final Stars ZERO = new Stars(0);
18 | public static final Stars ONE = new Stars(1);
19 | public static final Stars TWO = new Stars(2);
20 | public static final Stars THREE = new Stars(3);
21 | public static final Stars FOUR = new Stars(4);
22 | public static final Stars FIVE = new Stars(5);
23 |
24 | private static final Collection ALL = new HashSet();
25 |
26 | static {
27 | Collections.addAll(ALL, ZERO, ONE, TWO, THREE, FOUR, FIVE);
28 | }
29 |
30 | private int value;
31 |
32 |
33 | private Stars(int value) {
34 |
35 | Assert.isTrue(value >= -1, "Value must be positive or 0!");
36 | this.value = value;
37 | }
38 |
39 |
40 | public int getValue() {
41 |
42 | return value;
43 | }
44 |
45 |
46 | /*
47 | * (non-Javadoc)
48 | *
49 | * @see java.lang.Object#equals(java.lang.Object)
50 | */
51 | @Override
52 | public boolean equals(Object obj) {
53 |
54 | if (this == obj) {
55 | return true;
56 | }
57 |
58 | if (obj == null || !getClass().equals(obj.getClass())) {
59 | return false;
60 | }
61 |
62 | Stars that = (Stars) obj;
63 |
64 | return this.value == that.value;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/web/client/RequestCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.web.client;
18 |
19 | import java.io.IOException;
20 |
21 | import org.springframework.http.client.ClientHttpRequest;
22 |
23 | /**
24 | * Callback interface for code that operates on a {@link ClientHttpRequest}. Allows to manipulate the request
25 | * headers, and write to the request body.
26 | *
27 | *
Used internally by the {@link RestTemplate}, but also useful for application code.
28 | *
29 | * @author Arjen Poutsma
30 | * @see RestTemplate#execute
31 | * @since 3.0
32 | */
33 | public interface RequestCallback {
34 |
35 | /**
36 | * Gets called by {@link RestTemplate#execute} with an opened {@code ClientHttpRequest}.
37 | * Does not need to care about closing the request or about handling errors:
38 | * this will all be handled by the {@code RestTemplate}.
39 | * @param request the active HTTP request
40 | * @throws IOException in case of I/O errors
41 | */
42 | void doWithRequest(ClientHttpRequest request) throws IOException;
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants/src/main/test/java/com/springone/myrestaurants/dao/RestaurantDaoTests.java:
--------------------------------------------------------------------------------
1 | package com.springone.myrestaurants.dao;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import junit.framework.Assert;
8 |
9 | import org.codehaus.jackson.map.ObjectMapper;
10 | import org.junit.Before;
11 | import org.junit.Test;
12 | import org.springframework.http.converter.HttpMessageConverter;
13 | import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
14 | import org.springframework.web.client.RestTemplate;
15 |
16 | import com.springone.myrestaurants.domain.Restaurant;
17 | import com.springone.myrestaurants.web.CouchDbMappingJacksonHttpMessageConverter;
18 |
19 |
20 | public class RestaurantDaoTests {
21 |
22 | private RestTemplate restTemplate;
23 |
24 | private RestaurantDao restaurantDao;
25 |
26 | @Before
27 | public void setUp() {
28 | restaurantDao = new RestaurantDao();
29 |
30 |
31 | }
32 |
33 | @Test
34 | public void readRestaurants() {
35 |
36 | //List response = (List) restTemplate.getForObject("http://localhost:5984/spring_demo/_design/demo/_view/all", Restaurant.class);
37 | List response = restaurantDao.findAllRestaurants();
38 | Assert.assertEquals(50, response.size());
39 | System.out.println(response.get(0));
40 |
41 | Restaurant r = restaurantDao.findRestaurant(response.get(0).getId());
42 | Assert.assertNotNull(r);
43 | System.out.println(r);
44 |
45 | response = restaurantDao.findRestaurantEntries(1, 10);
46 | //TODO does not respect limits..
47 | Assert.assertEquals(50, response.size());
48 |
49 |
50 | }
51 |
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/web/client/ResponseExtractor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.web.client;
18 |
19 | import java.io.IOException;
20 |
21 | import org.springframework.http.client.ClientHttpResponse;
22 |
23 | /**
24 | * Generic callback interface used by {@link RestTemplate}'s retrieval methods
25 | * Implementations of this interface perform the actual work of extracting data
26 | * from a {@link ClientHttpResponse}, but don't need to worry about exception
27 | * handling or closing resources.
28 | *
29 | *
27 |
28 |
29 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/http/client/ClientHttpResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.http.client;
18 |
19 | import java.io.IOException;
20 |
21 | import org.springframework.http.HttpInputMessage;
22 | import org.springframework.http.HttpStatus;
23 |
24 | /**
25 | * Represents a client-side HTTP response. Obtained via an calling of the {@link ClientHttpRequest#execute()}.
26 | *
27 | *
A ClientHttpResponse must be {@linkplain #close() closed}, typically in a
28 | * finally block.
29 | *
30 | * @author Arjen Poutsma
31 | * @since 3.0
32 | */
33 | public interface ClientHttpResponse extends HttpInputMessage {
34 |
35 | /**
36 | * Return the HTTP status code of the response.
37 | * @return the HTTP status as an HttpStatus enum value
38 | * @throws IOException in case of I/O errors
39 | */
40 | HttpStatus getStatusCode() throws IOException;
41 |
42 | /**
43 | * Return the HTTP status text of the response.
44 | * @return the HTTP status text
45 | * @throws IOException in case of I/O errors
46 | */
47 | String getStatusText() throws IOException;
48 |
49 | /**
50 | * Closes this response, freeing any resources created.
51 | */
52 | void close();
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/mongodb-myrestaurants-analytics/src/main/webapp/WEB-INF/tags/menu/item.tagx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/mongodb-myrestaurants-analytics/src/main/java/org/springframework/data/document/analytics/MvcEvent.java:
--------------------------------------------------------------------------------
1 | package org.springframework.data.document.analytics;
2 |
3 | import java.util.Date;
4 |
5 | public class MvcEvent {
6 |
7 | private String controller;
8 |
9 | private String action;
10 |
11 | private Parameters parameters;
12 |
13 | private Date date;
14 |
15 | private String requestUri;
16 |
17 | private String requestAddress;
18 |
19 | private String remoteUser;
20 |
21 | private String view;
22 |
23 | public String getController() {
24 | return controller;
25 | }
26 |
27 | public void setController(String controller) {
28 | this.controller = controller;
29 | }
30 |
31 | public String getAction() {
32 | return action;
33 | }
34 |
35 | public void setAction(String action) {
36 | this.action = action;
37 | }
38 |
39 | public Parameters getParameters() {
40 | return parameters;
41 | }
42 |
43 | public void setParameters(Parameters parameters) {
44 | this.parameters = parameters;
45 | }
46 |
47 | public Date getDate() {
48 | return date;
49 | }
50 |
51 | public void setDate(Date date) {
52 | this.date = date;
53 | }
54 |
55 | public String getRequestUri() {
56 | return requestUri;
57 | }
58 |
59 | public void setRequestUri(String requestUri) {
60 | this.requestUri = requestUri;
61 | }
62 |
63 | public String getRequestAddress() {
64 | return requestAddress;
65 | }
66 |
67 | public void setRequestAddress(String requestAddress) {
68 | this.requestAddress = requestAddress;
69 | }
70 |
71 | public String getRemoteUser() {
72 | return remoteUser;
73 | }
74 |
75 | public void setRemoteUser(String remoteUser) {
76 | this.remoteUser = remoteUser;
77 | }
78 |
79 | //TODO
80 | //Map sessionAttributes
81 |
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/core/NestedExceptionUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2008 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.core;
18 |
19 | /**
20 | * Helper class for implementing exception classes which are capable of
21 | * holding nested exceptions. Necessary because we can't share a base
22 | * class among different exception types.
23 | *
24 | *
Mainly for use within the framework.
25 | *
26 | * @author Juergen Hoeller
27 | * @since 2.0
28 | * @see NestedRuntimeException
29 | * @see NestedCheckedException
30 | * @see NestedIOException
31 | * @see org.springframework.web.util.NestedServletException
32 | */
33 | public abstract class NestedExceptionUtils {
34 |
35 | /**
36 | * Build a message for the given base message and root cause.
37 | * @param message the base message
38 | * @param cause the root cause
39 | * @return the full exception message
40 | */
41 | public static String buildMessage(String message, Throwable cause) {
42 | if (cause != null) {
43 | StringBuilder sb = new StringBuilder();
44 | if (message != null) {
45 | sb.append(message).append("; ");
46 | }
47 | sb.append("nested exception is ").append(cause);
48 | return sb.toString();
49 | }
50 | else {
51 | return message;
52 | }
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/util/MultiValueMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.util;
18 |
19 | import java.util.List;
20 | import java.util.Map;
21 |
22 | /**
23 | * Extension of the {@code Map} interface that stores multiple values.
24 | *
25 | * @author Arjen Poutsma
26 | * @since 3.0
27 | */
28 | public interface MultiValueMap extends Map> {
29 |
30 | /**
31 | * Return the first value for the given key.
32 | * @param key the key
33 | * @return the first value for the specified key, or null
34 | */
35 | V getFirst(K key);
36 |
37 | /**
38 | * Add the given single value to the current list of values for the given key.
39 | * @param key the key
40 | * @param value the value to be added
41 | */
42 | void add(K key, V value);
43 |
44 | /**
45 | * Set the given single value under the given key.
46 | * @param key the key
47 | * @param value the value to set
48 | */
49 | void set(K key, V value);
50 |
51 | /**
52 | * Set the given values under.
53 | * @param values the values.
54 | */
55 | void setAll(Map values);
56 |
57 | /**
58 | * Returns the first values contained in this {@code MultiValueMap}.
59 | * @return a single value representation of this map
60 | */
61 | Map toSingleValueMap();
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/web/client/ResponseErrorHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2009 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.web.client;
18 |
19 | import java.io.IOException;
20 |
21 | import org.springframework.http.client.ClientHttpResponse;
22 |
23 | /**
24 | * Strategy interface used by the {@link RestTemplate} to determine whether a particular response has an error or not.
25 | *
26 | * @author Arjen Poutsma
27 | * @since 3.0
28 | */
29 | public interface ResponseErrorHandler {
30 |
31 | /**
32 | * Indicates whether the given response has any errors.
33 | * Implementations will typically inspect the {@link ClientHttpResponse#getStatusCode() HttpStatus}
34 | * of the response.
35 | * @param response the response to inspect
36 | * @return true if the response has an error; false otherwise
37 | * @throws IOException in case of I/O errors
38 | */
39 | boolean hasError(ClientHttpResponse response) throws IOException;
40 |
41 | /**
42 | * Handles the error in the given response.
43 | * This method is only called when {@link #hasError(ClientHttpResponse)} has returned true.
44 | * @param response the response with the error
45 | * @throws IOException in case of I/O errors
46 | */
47 | void handleError(ClientHttpResponse response) throws IOException;
48 | }
49 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/http/client/ClientHttpRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2002-2010 the original author or authors.
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 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.http.client;
18 |
19 | import java.io.IOException;
20 | import java.net.URI;
21 |
22 | import org.springframework.http.HttpMethod;
23 | import org.springframework.http.HttpOutputMessage;
24 |
25 | /**
26 | * Represents a client-side HTTP request. Created via an implementation of the {@link ClientHttpRequestFactory}.
27 | *
28 | *
A HttpRequest can be {@linkplain #execute() executed}, getting a {@link ClientHttpResponse}
29 | * which can be read from.
30 | *
31 | * @author Arjen Poutsma
32 | * @since 3.0
33 | * @see ClientHttpRequestFactory#createRequest(java.net.URI, HttpMethod)
34 | */
35 | public interface ClientHttpRequest extends HttpOutputMessage {
36 |
37 | /**
38 | * Return the HTTP method of the request.
39 | * @return the HTTP method as an HttpMethod enum value
40 | */
41 | HttpMethod getMethod();
42 |
43 | /**
44 | * Return the URI of the request.
45 | * @return the URI of the request
46 | */
47 | URI getURI();
48 |
49 | /**
50 | * Execute this request, resulting in a {@link ClientHttpResponse} that can be read.
51 | * @return the response result of the execution
52 | * @throws IOException in case of I/O errors
53 | */
54 | ClientHttpResponse execute() throws IOException;
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/couchdb-myrestaurants-android/src/org/springframework/web/RestTemplateActivity.java:
--------------------------------------------------------------------------------
1 | package org.springframework.web;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import org.springframework.http.converter.HttpMessageConverter;
8 | import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
9 | import org.springframework.web.client.RestTemplate;
10 |
11 | import android.app.Activity;
12 | import android.os.Bundle;
13 | import android.util.Log;
14 | import android.widget.TextView;
15 |
16 | public class RestTemplateActivity extends Activity {
17 | /** Called when the activity is first created. */
18 | @Override
19 | public void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | TextView view = new TextView(this);
22 | view.append("Running tests...\n\n");
23 | setContentView(view);
24 | try {
25 | List> converters = new ArrayList>();
26 | converters.add(new MappingJacksonHttpMessageConverter());
27 | RestTemplate restTemplate = new RestTemplate();
28 | restTemplate.setMessageConverters(converters);
29 |
30 |
31 | Map response = restTemplate.getForObject("http://127.0.0.1:5984",
32 | Map.class);
33 |
34 |
35 | view.append(response.toString());
36 |
37 |
38 | /*
39 | URL url = new URL("http:/127.0.0.1:5984");
40 | HttpURLConnection conn = (HttpURLConnection) url.openConnection();
41 | conn.setRequestMethod("GET");
42 | BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
43 | String line;
44 | List lines= new ArrayList();
45 | while((line = reader.readLine()) != null){
46 | lines.add(line);
47 | }
48 | reader.close();
49 | view.append(lines.toString());*/
50 |
51 |
52 | view.append("all ok!");
53 | } catch (Exception e) {
54 | view.append(e.toString());
55 | Log.e("rest-template","this is bad", e);
56 | }
57 |
58 | }
59 | }
--------------------------------------------------------------------------------
/couchdb-myrestaurants/src/main/webapp/WEB-INF/tags/util/panel.tagx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | ${id}
16 |
17 |
18 |
19 | ${openPane}
20 |
21 |
22 |
23 | ${title}
24 |
25 |
26 |
27 |