Skip to content

Commit 9c84343

Browse files
committed
Merge branch 'master' of https://github.com/callmeal/Flickr4Java
2 parents 1cb7dbe + c00ae71 commit 9c84343

Some content is hidden

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

53 files changed

+2488
-85
lines changed

Flickr4Java/BUILDING.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Building and Testing Flickr4Java
2+
3+
## Building
4+
5+
Flickr4Java uses [Gradle](http://www.gradle.org).
6+
Run gradle tasks from the directory that contains the `build.gradle` file.
7+
8+
The following tasks are available:
9+
10+
* Clean up: `gradle clean`
11+
* Compile (inc examples): `gradle compileJava`
12+
* Compile & test: `gradle build`
13+
* Create docs: `gradle javadoc`
14+
* Create docs jar: `gradle javadocJar`
15+
* Create src jar: `gradle sourcesJar`
16+
* Generate Eclipse project files: `gradle cleanEclipse eclipse`
17+
* Generate Idea project files: `gradle cleanIdea idea`
18+
* Show dependencies (libs etc): `gradle dependencies`
19+
20+
## Testing
21+
22+
Most of the tests are integration tests, and require hitting the actual Flickr
23+
API service with DELETE permissions. The safest and easiest way to do this is to
24+
set up a test user account, the following photos etc.:
25+
26+
1. At least one photo in one album
27+
2. At least one collection with title and description, containing at least one album
28+
(the ID of the collection can be retrieved manually via the
29+
[API explorer](https://www.flickr.com/services/api/explore/flickr.collections.getTree)
30+
and be added as `collectionid` in `src/test/resources/setup.properties`)
31+
3. *[List is incomplete]*
32+
33+
To test:
34+
35+
1. Copy `src/test/resources/setup.properties.example` to `src/test/resources/setup.properties`
36+
2. Run `gradle compiletestjava -q` — compile all sources
37+
3. Run `gradle setuptests -q` — this will prompt for authorisation and update the above `setup.properties` file
38+
4. Run `gradle test`
39+
40+
(The `-q` above just hides some of the more verbose output; it can be left out.)

Flickr4Java/BUILDING.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

Flickr4Java/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apply plugin: 'java'
22
apply plugin: 'eclipse'
33
apply plugin: 'idea'
44
apply plugin: 'maven'
5+
apply plugin: 'application'
56

67
version = '2.6'
78
group = 'com.flickr4java.flickr'
@@ -32,6 +33,12 @@ dependencies {
3233
testCompile group: 'junit', name: 'junit', version: '4.11'
3334
}
3435

36+
task setupTests(type:JavaExec, dependsOn:classes) {
37+
standardInput = System.in
38+
main = 'com.flickr4java.flickr.test.Setup'
39+
classpath = sourceSets.test.runtimeClasspath
40+
}
41+
3542
//create a javadoc jar for maven repo
3643
task javadocJar(type: Jar, dependsOn: javadoc) {
3744
classifier = 'javadoc'

Flickr4Java/src/main/java/com/flickr4java/flickr/Flickr.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.flickr4java.flickr.favorites.FavoritesInterface;
1515
import com.flickr4java.flickr.galleries.GalleriesInterface;
1616
import com.flickr4java.flickr.groups.GroupsInterface;
17+
import com.flickr4java.flickr.groups.discuss.GroupDiscussInterface;
1718
import com.flickr4java.flickr.groups.members.MembersInterface;
1819
import com.flickr4java.flickr.groups.pools.PoolsInterface;
1920
import com.flickr4java.flickr.interestingness.InterestingnessInterface;
@@ -25,6 +26,7 @@
2526
import com.flickr4java.flickr.photos.geo.GeoInterface;
2627
import com.flickr4java.flickr.photos.licenses.LicensesInterface;
2728
import com.flickr4java.flickr.photos.notes.NotesInterface;
29+
import com.flickr4java.flickr.photos.suggestions.SuggestionsInterface;
2830
import com.flickr4java.flickr.photos.transform.TransformInterface;
2931
import com.flickr4java.flickr.photos.upload.UploadInterface;
3032
import com.flickr4java.flickr.photosets.PhotosetsInterface;
@@ -154,6 +156,10 @@ public class Flickr {
154156
private StatsInterface statsInterface;
155157

156158
private CamerasInterface cameraInterface;
159+
160+
private SuggestionsInterface suggestionsInterface;
161+
162+
private GroupDiscussInterface discussionInterface;
157163

158164
/**
159165
* @see com.flickr4java.flickr.photos.PhotosInterface#setContentType(String, String)
@@ -611,5 +617,30 @@ public CamerasInterface getCamerasInterface() {
611617
}
612618
return cameraInterface;
613619
}
620+
621+
/**
622+
* Get the SuggestionsInterface.
623+
*
624+
* @return The SuggestionsInterface
625+
*/
626+
public SuggestionsInterface getSuggestionsInterface() {
627+
if (suggestionsInterface == null) {
628+
suggestionsInterface = new SuggestionsInterface(apiKey, sharedSecret, transport);
629+
}
630+
return suggestionsInterface;
631+
}
632+
633+
/**
634+
* Get the GroupDiscussInterface.
635+
*
636+
* @return The GroupDiscussInterface
637+
*/
638+
639+
public GroupDiscussInterface getDiscussionInterface() {
640+
if (discussionInterface == null) {
641+
discussionInterface= new GroupDiscussInterface(apiKey, sharedSecret, transport);
642+
}
643+
return discussionInterface;
644+
}
614645

615646
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.flickr4java.flickr.contacts;
2+
3+
import com.flickr4java.flickr.SearchResultList;
4+
5+
6+
public class ContactList<E> extends SearchResultList<Contact> {
7+
8+
// (avoid compiler warning)
9+
private static final long serialVersionUID = -4735611134085303463L;
10+
11+
}

Flickr4Java/src/main/java/com/flickr4java/flickr/contacts/ContactsInterface.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public ContactsInterface(String apiKey, String sharedSecret, Transport transport
5050
* @return The Collection of Contact objects
5151
*/
5252
public Collection<Contact> getList() throws FlickrException {
53-
List<Contact> contacts = new ArrayList<Contact>();
54-
53+
ContactList<Contact> contacts = new ContactList<Contact>();
54+
5555
Map<String, Object> parameters = new HashMap<String, Object>();
5656
parameters.put("method", METHOD_GET_LIST);
5757

@@ -61,6 +61,10 @@ public Collection<Contact> getList() throws FlickrException {
6161
}
6262

6363
Element contactsElement = response.getPayload();
64+
contacts.setPage(contactsElement.getAttribute("page"));
65+
contacts.setPages(contactsElement.getAttribute("pages"));
66+
contacts.setPerPage(contactsElement.getAttribute("perpage"));
67+
contacts.setTotal(contactsElement.getAttribute("total"));
6468
NodeList contactNodes = contactsElement.getElementsByTagName("contact");
6569
for (int i = 0; i < contactNodes.getLength(); i++) {
6670
Element contactElement = (Element) contactNodes.item(i);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.flickr4java.flickr.groups;
2+
3+
public class Blast {
4+
5+
private String dateBlastAdded;
6+
7+
private String userId;
8+
9+
private String blast;
10+
11+
/**
12+
* Unix timestamp formatted date
13+
*
14+
* @return date blast was added
15+
*/
16+
public String getDateBlastAdded() {
17+
return dateBlastAdded;
18+
}
19+
20+
public void setDateBlastAdded(String dateBlastAdded) {
21+
this.dateBlastAdded = dateBlastAdded;
22+
}
23+
24+
/**
25+
* Blaster's user_id
26+
*
27+
* @return user_id
28+
*/
29+
public String getUserId() {
30+
return userId;
31+
}
32+
33+
public void setUserId(String userId) {
34+
this.userId = userId;
35+
}
36+
37+
/**
38+
* Text of the blast
39+
*
40+
* @return blast text
41+
*/
42+
public String getBlast() {
43+
return blast;
44+
}
45+
46+
public void setBlast(String blast) {
47+
this.blast = blast;
48+
}
49+
50+
}

Flickr4Java/src/main/java/com/flickr4java/flickr/groups/Group.java

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public class Group implements BuddyIconable {
1919
private String name;
2020

2121
private int members;
22+
23+
private int poolCount;
24+
25+
private int topicCount;
2226

2327
private String privacy;
2428

@@ -29,6 +33,10 @@ public class Group implements BuddyIconable {
2933
private String description;
3034

3135
private Throttle throttle;
36+
37+
private Blast blast;
38+
39+
private Restriction restriction;
3240

3341
private String lang;
3442

@@ -87,6 +95,42 @@ public void setMembers(String members) {
8795
System.out.println("trace: Group.setMembers(String) encountered a number format " + "exception. members set to 0");
8896
}
8997
}
98+
public int getPoolCount() {
99+
return poolCount;
100+
}
101+
102+
public void setPoolCount(int poolCount) {
103+
this.poolCount = poolCount;
104+
}
105+
106+
public void setPoolCount(String poolCount) {
107+
try {
108+
if (poolCount != null)
109+
setPoolCount(Integer.parseInt(poolCount));
110+
} catch (NumberFormatException nfe) {
111+
setPoolCount(0);
112+
if (Flickr.tracing)
113+
System.out.println("trace: Group.setPoolCount(String) encountered a number format " + "exception. poolCount set to 0");
114+
}
115+
}
116+
public int getTopicCount() {
117+
return topicCount;
118+
}
119+
120+
public void setTopicCount(int topicCount) {
121+
this.topicCount = topicCount;
122+
}
123+
124+
public void setTopicCount(String topicCount) {
125+
try {
126+
if (topicCount != null)
127+
setTopicCount(Integer.parseInt(topicCount));
128+
} catch (NumberFormatException nfe) {
129+
setPoolCount(0);
130+
if (Flickr.tracing)
131+
System.out.println("trace: Group.setTopicCount(String) encountered a number format " + "exception. topicCount set to 0");
132+
}
133+
}
90134

91135
/**
92136
* @deprecated
@@ -188,15 +232,15 @@ public int getPhotoCount() {
188232
}
189233

190234
/**
191-
* @deprecated
235+
*
192236
* @param photoCount
193237
*/
194238
public void setPhotoCount(int photoCount) {
195239
this.photoCount = photoCount;
196240
}
197241

198242
/**
199-
* @deprecated
243+
*
200244
* @param photoCount
201245
*/
202246
public void setPhotoCount(String photoCount) {
@@ -313,6 +357,22 @@ public Throttle getThrottle() {
313357
public void setThrottle(Throttle throttle) {
314358
this.throttle = throttle;
315359
}
360+
361+
public Blast getBlast() {
362+
return blast;
363+
}
364+
365+
public void setBlast(Blast blast) {
366+
this.blast = blast;
367+
}
368+
369+
public Restriction getRestriction() {
370+
return restriction;
371+
}
372+
373+
public void setRestriction(Restriction restriction) {
374+
this.restriction = restriction;
375+
}
316376

317377
/**
318378
* @return the invitationOnly

Flickr4Java/src/main/java/com/flickr4java/flickr/groups/GroupsInterface.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public Group getInfo(String groupId) throws FlickrException {
140140
group.setDescription(XMLUtilities.getChildValue(groupElement, "description"));
141141
group.setMembers(XMLUtilities.getChildValue(groupElement, "members"));
142142
group.setPrivacy(XMLUtilities.getChildValue(groupElement, "privacy"));
143+
group.setPoolCount(XMLUtilities.getChildValue(groupElement, "pool_count"));
144+
group.setTopicCount(XMLUtilities.getChildValue(groupElement, "topic_count"));
143145

144146
NodeList throttleNodes = groupElement.getElementsByTagName("throttle");
145147
int n = throttleNodes.getLength();
@@ -159,6 +161,37 @@ public Group getInfo(String groupId) throws FlickrException {
159161
} else if (n > 1) {
160162
System.err.println("WARNING: more than one throttle element in group");
161163
}
164+
165+
NodeList restrictionNodes = groupElement.getElementsByTagName("restrictions");
166+
n = restrictionNodes.getLength();
167+
if (n == 1) {
168+
Element restrictionElement = (Element) restrictionNodes.item(0);
169+
Restriction restriction = new Restriction();
170+
group.setRestriction(restriction);
171+
restriction.setIsPhotosOk("1".equals(restrictionElement.getAttribute("photos_ok")));
172+
restriction.setIsVideosOk("1".equals(restrictionElement.getAttribute("videos_ok")));
173+
restriction.setIsImagesOk("1".equals(restrictionElement.getAttribute("images_ok")));
174+
restriction.setIsScreensOk("1".equals(restrictionElement.getAttribute("screens_ok")));
175+
restriction.setIsArtOk("1".equals(restrictionElement.getAttribute("art_ok")));
176+
restriction.setIsSafeOk("1".equals(restrictionElement.getAttribute("safe_ok")));
177+
restriction.setIsModerateOk("1".equals(restrictionElement.getAttribute("moderate_ok")));
178+
restriction.setIsRestrictedOk("1".equals(restrictionElement.getAttribute("restricted_ok")));
179+
restriction.setIsHasGeo("1".equals(restrictionElement.getAttribute("has_geo")));
180+
} else if (n > 1) {
181+
System.err.println("WARNING: more than one throttle element in group");
182+
}
183+
NodeList blastNodes = groupElement.getElementsByTagName("blast");
184+
n = blastNodes.getLength();
185+
if (n == 1) {
186+
Element blastElement = (Element) blastNodes.item(0);
187+
Blast blast = new Blast();
188+
group.setBlast(blast);
189+
blast.setUserId(blastElement.getAttribute("user_id"));
190+
blast.setDateBlastAdded(blastElement.getAttribute("date_blast_added"));
191+
blast.setBlast(XMLUtilities.getChildValue(groupElement,"blast"));
192+
} else if (n > 1) {
193+
System.err.println("WARNING: more than one throttle element in group");
194+
}
162195

163196
return group;
164197
}

0 commit comments

Comments
 (0)