Skip to content
This repository
Browse code

minor refactoring done

  • Loading branch information...
commit 4e6198cbdc55c6b128c8ed8242c1fed6e422c9fa 1 parent 806fc67
Hemant Sachdeva authored January 10, 2012
56  pom.xml
... ...
@@ -1,15 +1,15 @@
1  
-<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/xsd/maven-4.0.0.xsd">
  1
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  2
+xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2 3
 	<modelVersion>4.0.0</modelVersion>
3 4
 	<groupId>org.springframework.social</groupId>
4 5
 	<artifactId>spring-social-flickr</artifactId>
5 6
 	<name>Spring Social Flickr</name>
6 7
 	<version>0.0.1-SNAPSHOT</version>
7  
-
  8
+	<packaging>pom</packaging>
8 9
 	<properties>
9 10
 		<spring.social.version>1.0.0.RELEASE</spring.social.version>
10 11
 		<spring.framework.version>3.1.0.RC1</spring.framework.version>
11 12
 	</properties>
12  
-
13 13
 	<description>Spring Social extension with connection support and an API binding for Flickr</description>
14 14
 	<url>https://github.com/ranjan-rk/spring-social-flickr</url>
15 15
 	<developers>
@@ -32,7 +32,7 @@
32 32
 			</snapshots>
33 33
 		</repository>
34 34
 		<repository>
35  
-			<id>org.springframework.maven.milestone</id>
  35
+			<id>org.springframework.maven.milestone</id> 
36 36
 			<name>Spring Maven Milestone Repository</name>
37 37
 			<url>http://maven.springframework.org/milestone</url>
38 38
 			<snapshots>
@@ -43,53 +43,13 @@
43 43
 
44 44
 	<dependencies>
45 45
 		<dependency>
46  
-			<groupId>org.springframework.social</groupId>
47  
-			<artifactId>spring-social-core</artifactId>
48  
-			<version>${spring.social.version}</version>
49  
-			<exclusions>
50  
-				<exclusion>
51  
-					<groupId>org.springframework</groupId>
52  
-					<artifactId>spring-web</artifactId>
53  
-				</exclusion>
54  
-			</exclusions>
55  
-		</dependency>
56  
-		<dependency>
57  
-			<groupId>org.springframework</groupId>
58  
-			<artifactId>spring-web</artifactId>
59  
-			<version>${spring.framework.version}</version>
60  
-		</dependency>
61  
-		<dependency>
62  
-			<groupId>org.codehaus.jackson</groupId>
63  
-			<artifactId>jackson-mapper-asl</artifactId>
64  
-			<version>1.8.5</version>
65  
-		</dependency>
66  
-		<dependency>
67  
-			<groupId>org.codehaus.jackson</groupId>
68  
-			<artifactId>jackson-jaxrs</artifactId>
69  
-			<version>1.9.2</version>
70  
-		</dependency>
71  
-		<dependency>
72  
-			<groupId>org.springframework.security</groupId>
73  
-			<artifactId>spring-security-core</artifactId>
74  
-			<version>3.1.0.RELEASE</version>
75  
-		</dependency>		
76  
-		<dependency>
77  
-			<groupId>xom</groupId>
78  
-			<artifactId>xom</artifactId>
79  
-			<version>1.2.5</version>
80  
-		</dependency>
81  
-		<dependency>
82  
-			<groupId>jaxen</groupId>
83  
-			<artifactId>jaxen</artifactId>
84  
-			<version>1.1.1</version>
85  
-		</dependency>
86  
-		<dependency>
87 46
 			<groupId>junit</groupId>
88 47
 			<artifactId>junit</artifactId>
89 48
 			<version>4.8.2</version>
90 49
 			<scope>test</scope>
91 50
 		</dependency>
92 51
 	</dependencies>
  52
+	
93 53
 	<build>
94 54
 		<plugins>
95 55
 			<plugin>
@@ -103,4 +63,10 @@
103 63
 			</plugin>
104 64
 		</plugins>
105 65
 	</build>
  66
+	
  67
+	<modules>
  68
+		<module>core</module>
  69
+		<module>web</module>
  70
+	</modules>
  71
+	
106 72
 </project>
24  src/main/java/org/springframework/social/flickr/api/Flickr.java
... ...
@@ -1,24 +0,0 @@
1  
-/*
2  
- * Copyright 2011 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.social.flickr.api;
17  
-
18  
-import org.springframework.social.ApiBinding;
19  
-
20  
-public interface Flickr extends ApiBinding{
21  
-
22  
-    FlickrProfile getUserProfile();
23  
-
24  
-}
46  src/main/java/org/springframework/social/flickr/api/FlickrProfile.java
... ...
@@ -1,46 +0,0 @@
1  
-/*
2  
- * Copyright 2011 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.social.flickr.api;
17  
-
18  
-public class FlickrProfile {
19  
-    private String nsid;
20  
-    private String url;
21  
-    private String stat;
22  
-
23  
-    public String getNsid() {
24  
-	return nsid;
25  
-    }
26  
-
27  
-    public void setNsid(String nsid) {
28  
-	this.nsid = nsid;
29  
-    }
30  
-
31  
-    public String getUrl() {
32  
-	return url;
33  
-    }
34  
-
35  
-    public void setUrl(String url) {
36  
-	this.url = url;
37  
-    }
38  
-
39  
-    public String getStat() {
40  
-	return stat;
41  
-    }
42  
-
43  
-    public void setStat(String stat) {
44  
-	this.stat = stat;
45  
-    }
46  
-}
17  src/main/java/org/springframework/social/flickr/api/FlickrProfileMixin.java
... ...
@@ -1,17 +0,0 @@
1  
-package org.springframework.social.flickr.api;
2  
-
3  
-import org.codehaus.jackson.annotate.JsonCreator;
4  
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
5  
-import org.codehaus.jackson.annotate.JsonProperty;
6  
-
7  
-@JsonIgnoreProperties(ignoreUnknown = true)
8  
-public class FlickrProfileMixin {
9  
-    @JsonCreator
10  
-    FlickrProfileMixin(@JsonProperty("nsid") long nsid){}
11  
-    
12  
-    @JsonProperty("url")
13  
-    private String url;
14  
-    
15  
-    @JsonProperty("stat")
16  
-    private String stat;
17  
-}
37  src/main/java/org/springframework/social/flickr/api/impl/FlickrModule.java
... ...
@@ -1,37 +0,0 @@
1  
-/*
2  
- * Copyright 2011 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.social.flickr.api.impl;
17  
-
18  
-import org.codehaus.jackson.Version;
19  
-import org.codehaus.jackson.map.module.SimpleModule;
20  
-import org.springframework.social.flickr.api.FlickrProfile;
21  
-import org.springframework.social.flickr.api.FlickrProfileMixin;
22  
-
23  
-public class FlickrModule extends SimpleModule {
24  
-
25  
-    public FlickrModule(String name, Version version) {
26  
-	super(name, version);
27  
-    }
28  
-
29  
-    public FlickrModule() {
30  
-	super("FlickrModule", new Version(1, 0, 0, null));
31  
-    }
32  
-
33  
-    @Override
34  
-    public void setupModule(SetupContext context) {
35  
-	context.setMixInAnnotations(FlickrProfile.class, FlickrProfileMixin.class);
36  
-    }
37  
-}
53  src/main/java/org/springframework/social/flickr/api/impl/FlickrTemplate.java
... ...
@@ -1,53 +0,0 @@
1  
-/*
2  
- * Copyright 2011 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.social.flickr.api.impl;
17  
-
18  
-import java.util.ArrayList;
19  
-import java.util.List;
20  
-
21  
-import org.codehaus.jackson.map.ObjectMapper;
22  
-import org.springframework.http.MediaType;
23  
-import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
24  
-import org.springframework.social.flickr.api.Flickr;
25  
-import org.springframework.social.flickr.api.FlickrProfile;
26  
-import org.springframework.social.oauth1.AbstractOAuth1ApiBinding;
27  
-
28  
-public class FlickrTemplate extends AbstractOAuth1ApiBinding implements Flickr {
29  
-    private String URL_TO_ACCESS_PROFILE = "URL_TO_ACCESS_PROFILE";
30  
-
31  
-    public FlickrTemplate(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret) {
32  
-	super(consumerKey, consumerSecret, accessToken, accessTokenSecret);
33  
-    }
34  
-
35  
-    @Override
36  
-    public FlickrProfile getUserProfile() {
37  
-	FlickrProfile flickrProfile = getRestTemplate().getForObject(URL_TO_ACCESS_PROFILE, FlickrProfile.class);
38  
-	return flickrProfile;
39  
-    }
40  
-
41  
-    @Override
42  
-    protected MappingJacksonHttpMessageConverter getJsonMessageConverter() {
43  
-	MappingJacksonHttpMessageConverter converter = super.getJsonMessageConverter();
44  
-	ObjectMapper objectMapper = new ObjectMapper();
45  
-	objectMapper.registerModule(new FlickrModule());
46  
-	List<MediaType> supportedMediaTypes = new ArrayList<MediaType>();
47  
-	supportedMediaTypes.add(MediaType.TEXT_PLAIN);
48  
-	supportedMediaTypes.add(MediaType.TEXT_XML);
49  
-	converter.setSupportedMediaTypes(supportedMediaTypes);
50  
-	converter.setObjectMapper(objectMapper);
51  
-	return converter;
52  
-    }
53  
-}
4  src/main/java/org/springframework/social/flickr/api/impl/package-info.java
... ...
@@ -1,4 +0,0 @@
1  
-/**
2  
- * Implementation of Spring Social's Service API for Flickr
3  
- */
4  
-package org.springframework.social.flickr.api.impl;
4  src/main/java/org/springframework/social/flickr/api/package-info.java
... ...
@@ -1,4 +0,0 @@
1  
-/**
2  
- * Spring Social's Service API for Flickr
3  
- */
4  
-package org.springframework.social.flickr.api;
51  src/main/java/org/springframework/social/flickr/connect/FlickrAdapter.java
... ...
@@ -1,51 +0,0 @@
1  
-/*
2  
- * Copyright 2011 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.social.flickr.connect;
17  
-
18  
-import org.springframework.social.connect.ApiAdapter;
19  
-import org.springframework.social.connect.ConnectionValues;
20  
-import org.springframework.social.connect.UserProfile;
21  
-import org.springframework.social.flickr.api.Flickr;
22  
-import org.springframework.web.client.HttpClientErrorException;
23  
-
24  
-public class FlickrAdapter implements ApiAdapter<Flickr> {
25  
-
26  
-    public boolean test(Flickr flickr) {
27  
-	try {
28  
-	    flickr.getUserProfile();
29  
-	    return true;
30  
-	} catch (HttpClientErrorException e) {
31  
-	    e.printStackTrace();
32  
-	    return false;
33  
-	}
34  
-    }
35  
-
36  
-    @Override
37  
-    public UserProfile fetchUserProfile(Flickr api) {
38  
-	System.out.println("TODO : Implement fetchUserProfile");
39  
-	return null;
40  
-    }
41  
-
42  
-    @Override
43  
-    public void setConnectionValues(Flickr api, ConnectionValues values) {
44  
-	// TODO Auto-generated method stub
45  
-
46  
-    }
47  
-
48  
-    public void updateStatus(Flickr flickr, String message) {
49  
-	throw new UnsupportedOperationException();
50  
-    }
51  
-}
27  src/main/java/org/springframework/social/flickr/connect/FlickrConnectionFactory.java
... ...
@@ -1,27 +0,0 @@
1  
-/*
2  
- * Copyright 2011 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.social.flickr.connect;
17  
-
18  
-import org.springframework.social.connect.support.OAuth1ConnectionFactory;
19  
-import org.springframework.social.flickr.api.Flickr;
20  
-
21  
-public class FlickrConnectionFactory extends OAuth1ConnectionFactory<Flickr> {
22  
-
23  
-    public FlickrConnectionFactory(String consumerKey, String consumerSecret) {
24  
-	super("flickr", new FlickrServiceProvider(consumerKey, consumerSecret), new FlickrAdapter());
25  
-    }
26  
-
27  
-}
37  src/main/java/org/springframework/social/flickr/connect/FlickrServiceProvider.java
... ...
@@ -1,37 +0,0 @@
1  
-/*
2  
- * Copyright 2011 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.social.flickr.connect;
17  
-
18  
-import org.springframework.social.flickr.api.Flickr;
19  
-import org.springframework.social.flickr.api.impl.FlickrTemplate;
20  
-import org.springframework.social.oauth1.AbstractOAuth1ServiceProvider;
21  
-import org.springframework.social.oauth1.OAuth1Template;
22  
-
23  
-public class FlickrServiceProvider extends AbstractOAuth1ServiceProvider<Flickr> {
24  
-
25  
-	public FlickrServiceProvider(String consumerKey, String consumerSecret) {
26  
-		super(consumerKey, consumerSecret, new OAuth1Template(consumerKey, consumerSecret,
27  
-			"http://www.flickr.com/services/oauth/request_token",
28  
-			"http://www.flickr.com/services/oauth/authorize",
29  
-			"http://www.flickr.com/services/oauth/authenticate",			
30  
-			"http://www.flickr.com/services/oauth/access_token"));
31  
-	}
32  
-
33  
-	public Flickr getApi(String accessToken, String secret) {
34  
-		return new FlickrTemplate(getConsumerKey(), getConsumerSecret(), accessToken, secret);
35  
-	}
36  
-	
37  
-}
4  src/main/java/org/springframework/social/flickr/connect/package-info.java
... ...
@@ -1,4 +0,0 @@
1  
-/**
2  
- * Flickr service provider connection repository and API adapter implementations. 
3  
- */
4  
-package org.springframework.social.flickr.connect;
40  src/test/java/org/springframework/social/flickr/connect/FlickrServiceProviderTest.java
... ...
@@ -1,40 +0,0 @@
1  
-/*
2  
- * Copyright 2011 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.social.flickr.connect;
17  
-
18  
-import org.junit.Test;
19  
-import org.springframework.social.flickr.api.Flickr;
20  
-import org.springframework.social.flickr.api.FlickrProfile;
21  
-import org.springframework.social.flickr.api.impl.FlickrTemplate;
22  
-import org.springframework.social.oauth1.OAuth1Operations;
23  
-import org.springframework.social.oauth1.OAuthToken;
24  
-
25  
-public class FlickrServiceProviderTest {
26  
-    private String consumerKey = "consumerKey";
27  
-    private String consumerSecret = "consumerSecret";
28  
-    private String callbackUrl = "https://my-callback-url";
29  
-
30  
-    @Test
31  
-    public void getFlickrTemplate() {
32  
-	FlickrConnectionFactory flickrConnectionFactory = new FlickrConnectionFactory(consumerKey, consumerSecret);
33  
-	OAuth1Operations oauthOperations = flickrConnectionFactory.getOAuthOperations();
34  
-	OAuthToken fetchRequestToken = oauthOperations.fetchRequestToken(callbackUrl, null);
35  
-
36  
-	Flickr flickr = new FlickrTemplate(consumerKey, consumerSecret, fetchRequestToken.getValue(), fetchRequestToken.getSecret());
37  
-	FlickrProfile userProfile = flickr.getUserProfile();
38  
-	System.out.println(userProfile);
39  
-    }
40  
-}

0 notes on commit 4e6198c

Please sign in to comment.
Something went wrong with that request. Please try again.