Repository: incubator-streams Updated Branches: refs/heads/master 67497a488 -> 2c83c574c
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/serializer/InstagramUserInfoDataConverter.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/serializer/InstagramUserInfoDataConverter.java b/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/serializer/InstagramUserInfoDataConverter.java index 1109163..6c19167 100644 --- a/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/serializer/InstagramUserInfoDataConverter.java +++ b/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/serializer/InstagramUserInfoDataConverter.java @@ -20,11 +20,11 @@ package org.apache.streams.instagram.serializer; import org.apache.streams.data.ActivityObjectConverter; import org.apache.streams.exceptions.ActivityConversionException; +import org.apache.streams.instagram.pojo.UserInfo; import org.apache.streams.pojo.json.ActivityObject; import org.apache.streams.pojo.json.Image; import org.apache.streams.pojo.json.Provider; -import org.jinstagram.entity.users.basicinfo.UserInfoData; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.slf4j.Logger; @@ -34,9 +34,9 @@ import java.util.HashMap; import java.util.Map; /** - * InstagramUserInfoDataConverter + * InstagramUserInfoDataConverter. */ -public class InstagramUserInfoDataConverter implements ActivityObjectConverter<UserInfoData> { +public class InstagramUserInfoDataConverter implements ActivityObjectConverter<UserInfo> { private static final Logger LOGGER = LoggerFactory.getLogger(InstagramUserInfoDataConverter.class); @@ -46,7 +46,7 @@ public class InstagramUserInfoDataConverter implements ActivityObjectConverter<U @Override public Class requiredClass() { - return UserInfoData.class; + return UserInfo.class; } @Override @@ -55,12 +55,12 @@ public class InstagramUserInfoDataConverter implements ActivityObjectConverter<U } @Override - public UserInfoData fromActivityObject(ActivityObject deserialized) throws ActivityConversionException { + public UserInfo fromActivityObject(ActivityObject deserialized) throws ActivityConversionException { return null; } @Override - public ActivityObject toActivityObject(UserInfoData serialized) throws ActivityConversionException { + public ActivityObject toActivityObject(UserInfo serialized) throws ActivityConversionException { ActivityObject activityObject = new ActivityObject(); activityObject.setObjectType("page"); Provider provider = new Provider(); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/serializer/util/InstagramActivityUtil.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/serializer/util/InstagramActivityUtil.java b/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/serializer/util/InstagramActivityUtil.java index 2b4cb66..147a6e1 100644 --- a/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/serializer/util/InstagramActivityUtil.java +++ b/streams-contrib/streams-provider-instagram/src/main/java/org/apache/streams/instagram/serializer/util/InstagramActivityUtil.java @@ -21,21 +21,20 @@ package org.apache.streams.instagram.serializer.util; import org.apache.streams.exceptions.ActivityConversionException; import org.apache.streams.exceptions.ActivitySerializerException; +import org.apache.streams.instagram.pojo.Comment; +import org.apache.streams.instagram.pojo.Comments; +import org.apache.streams.instagram.pojo.Images; +import org.apache.streams.instagram.pojo.Media; +import org.apache.streams.instagram.pojo.UserInfo; +import org.apache.streams.instagram.pojo.UserInfoCounts; +import org.apache.streams.instagram.pojo.Videos; import org.apache.streams.pojo.extensions.ExtensionUtil; import org.apache.streams.pojo.json.Activity; import org.apache.streams.pojo.json.ActivityObject; import org.apache.streams.pojo.json.Image; +import org.apache.streams.pojo.json.ImageParent; import org.apache.streams.pojo.json.Provider; -import org.jinstagram.entity.comments.CommentData; -import org.jinstagram.entity.common.Comments; -import org.jinstagram.entity.common.ImageData; -import org.jinstagram.entity.common.Images; -import org.jinstagram.entity.common.VideoData; -import org.jinstagram.entity.common.Videos; -import org.jinstagram.entity.users.basicinfo.Counts; -import org.jinstagram.entity.users.basicinfo.UserInfoData; -import org.jinstagram.entity.users.feed.MediaFeedData; import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,7 +61,7 @@ public class InstagramActivityUtil { * @throws ActivityConversionException ActivityConversionException */ - public static void updateActivity(MediaFeedData item, Activity activity) throws ActivityConversionException { + public static void updateActivity(Media item, Activity activity) throws ActivityConversionException { activity.setActor(buildActor(item)); activity.setVerb("post"); @@ -90,25 +89,25 @@ public class InstagramActivityUtil { * @param activity the target of the updates. Will receive all values from the tweet. * @throws ActivitySerializerException ActivitySerializerException */ - public static void updateActivity(UserInfoData item, Activity activity) throws ActivitySerializerException { + public static void updateActivity(UserInfo item, Activity activity) throws ActivitySerializerException { activity.setActor(buildActor(item)); activity.setId(null); activity.setProvider(getProvider()); } /** - * Builds an Actor object given a UserInfoData object. - * @param item UserInfoData item + * Builds an Actor object given a UserInfo object. + * @param item UserInfo item * @return Actor object */ - public static ActivityObject buildActor(UserInfoData item) { + public static ActivityObject buildActor(UserInfo item) { ActivityObject actor = new ActivityObject(); try { Image image = new Image(); image.setUrl(item.getProfilePicture()); - Counts counts = item.getCounts(); + UserInfoCounts counts = item.getCounts(); Map<String, Object> extensions = new HashMap<>(); @@ -134,27 +133,27 @@ public class InstagramActivityUtil { /** * Builds the actor. - * @param item MediaFeedData item + * @param item Media item * @return a valid ActivityObject */ - public static ActivityObject buildActor(MediaFeedData item) { + public static ActivityObject buildActor(Media item) { ActivityObject actor = new ActivityObject(); try { Image image = new Image(); - image.setUrl(item.getUser().getProfilePictureUrl()); + image.setUrl(item.getUser().getProfilePicture()); Map<String, Object> extensions = new HashMap<>(); - extensions.put("screenName", item.getUser().getUserName()); + extensions.put("screenName", item.getUser().getUsername()); actor.setDisplayName(item.getUser().getFullName()); actor.setSummary(item.getUser().getBio()); - actor.setUrl(item.getUser().getWebsiteUrl()); + actor.setUrl(item.getUser().getWebsite()); actor.setId(formatId(String.valueOf(item.getUser().getId()))); actor.setImage(image); actor.setAdditionalProperty("extensions", extensions); - actor.setAdditionalProperty("handle", item.getUser().getUserName()); + actor.setAdditionalProperty("handle", item.getUser().getUsername()); } catch (Exception ex) { LOGGER.error("Exception trying to build actor object: {}", ex.getMessage()); } @@ -167,20 +166,20 @@ public class InstagramActivityUtil { * @param item the item * @return a valid Activity Object */ - public static ActivityObject buildActivityObject(MediaFeedData item) { + public static ActivityObject buildActivityObject(Media item) { ActivityObject actObj = new ActivityObject(); - actObj.setObjectType(item.getType()); + actObj.setObjectType(item.getType().toString()); actObj.setAttachments(buildActivityObjectAttachments(item)); Image standardResolution = new Image(); if (item.getType().equals("image") && item.getImages() != null) { - ImageData standardResolutionData = item.getImages().getStandardResolution(); - standardResolution.setHeight((long) standardResolutionData.getImageHeight()); - standardResolution.setWidth((long) standardResolutionData.getImageWidth()); - standardResolution.setUrl(standardResolutionData.getImageUrl()); + ImageParent standardResolutionData = item.getImages().getStandardResolution(); + standardResolution.setHeight((long) standardResolutionData.getHeight()); + standardResolution.setWidth((long) standardResolutionData.getWidth()); + standardResolution.setUrl(standardResolutionData.getUrl()); } else if (item.getType().equals("video") && item.getVideos() != null) { - VideoData standardResolutionData = item.getVideos().getStandardResolution(); + ImageParent standardResolutionData = item.getVideos().getStandardResolution(); standardResolution.setHeight((long) standardResolutionData.getHeight()); standardResolution.setWidth((long) standardResolutionData.getWidth()); standardResolution.setUrl(standardResolutionData.getUrl()); @@ -192,12 +191,12 @@ public class InstagramActivityUtil { } /** - * Builds all of the attachments associated with a MediaFeedData object. + * Builds all of the attachments associated with a Media object. * * @param item item * @return result */ - public static List<ActivityObject> buildActivityObjectAttachments(MediaFeedData item) { + public static List<ActivityObject> buildActivityObjectAttachments(Media item) { List<ActivityObject> attachments = new ArrayList<>(); addImageObjects(attachments, item); @@ -211,27 +210,27 @@ public class InstagramActivityUtil { * @param attachments attachments * @param item item */ - public static void addImageObjects(List<ActivityObject> attachments, MediaFeedData item) { + public static void addImageObjects(List<ActivityObject> attachments, Media item) { Images images = item.getImages(); if (images != null) { try { - ImageData thumbnail = images.getThumbnail(); - ImageData lowResolution = images.getLowResolution(); + ImageParent thumbnail = images.getThumbnail(); + ImageParent lowResolution = images.getLowResolution(); ActivityObject thumbnailObject = new ActivityObject(); Image thumbnailImage = new Image(); - thumbnailImage.setUrl(thumbnail.getImageUrl()); - thumbnailImage.setHeight((long) thumbnail.getImageHeight()); - thumbnailImage.setWidth((long) thumbnail.getImageWidth()); + thumbnailImage.setUrl(thumbnail.getUrl()); + thumbnailImage.setHeight((long) thumbnail.getHeight()); + thumbnailImage.setWidth((long) thumbnail.getWidth()); thumbnailObject.setImage(thumbnailImage); thumbnailObject.setObjectType("image"); ActivityObject lowResolutionObject = new ActivityObject(); Image lowResolutionImage = new Image(); - lowResolutionImage.setUrl(lowResolution.getImageUrl()); - lowResolutionImage.setHeight((long) lowResolution.getImageHeight()); - lowResolutionImage.setWidth((long) lowResolution.getImageWidth()); + lowResolutionImage.setUrl(lowResolution.getUrl()); + lowResolutionImage.setHeight((long) lowResolution.getHeight()); + lowResolutionImage.setWidth((long) lowResolution.getWidth()); lowResolutionObject.setImage(lowResolutionImage); lowResolutionObject.setObjectType("image"); @@ -248,12 +247,12 @@ public class InstagramActivityUtil { * @param attachments attachments * @param item item */ - public static void addVideoObjects(List<ActivityObject> attachments, MediaFeedData item) { + public static void addVideoObjects(List<ActivityObject> attachments, Media item) { Videos videos = item.getVideos(); if (videos != null) { try { - VideoData lowResolutionVideo = videos.getLowResolution(); + ImageParent lowResolutionVideo = videos.getLowResolution(); ActivityObject lowResolutionVideoObject = new ActivityObject(); Image lowResolutionVideoImage = new Image(); @@ -275,7 +274,7 @@ public class InstagramActivityUtil { * @param item the object to use as the source * @return a list of links corresponding to the expanded URL */ - public static List<String> getLinks(MediaFeedData item) { + public static List<String> getLinks(Media item) { return new ArrayList<>(); } @@ -284,7 +283,7 @@ public class InstagramActivityUtil { * @param activity the Activity object to update * @param item the object to use as the source */ - public static void addLocationExtension(Activity activity, MediaFeedData item) { + public static void addLocationExtension(Activity activity, Media item) { Map<String, Object> extensions = ExtensionUtil.getInstance().ensureExtensions(activity); if (item.getLocation() != null) { @@ -321,9 +320,9 @@ public class InstagramActivityUtil { * Takes various parameters from the instagram object that are currently not part of the * activity schema and stores them in a generic extensions attribute. * @param activity Activity activity - * @param item MediaFeedData item + * @param item Media item */ - public static void addInstagramExtensions(Activity activity, MediaFeedData item) { + public static void addInstagramExtensions(Activity activity, Media item) { Map<String, Object> extensions = ExtensionUtil.getInstance().ensureExtensions(activity); addLocationExtension(activity, item); @@ -334,14 +333,20 @@ public class InstagramActivityUtil { extensions.put("likes", likes); } + if (item.getComments() != null) { + Map<String, Object> comments = new HashMap<>(); + comments.put("count", item.getComments().getCount()); + extensions.put("comments", comments); + } + extensions.put("hashtags", item.getTags()); Comments comments = item.getComments(); String commentsConcat = ""; if (comments != null) { - for (CommentData commentData : comments.getComments()) { - commentsConcat += " " + commentData.getText(); + for (Comment comment : comments.getData()) { + commentsConcat += " " + comment.getText(); } } if (item.getCaption() != null) { http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/InstagramConfiguration.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/InstagramConfiguration.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/InstagramConfiguration.json deleted file mode 100644 index 891c1da..0000000 --- a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/InstagramConfiguration.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-03/schema", - "$license": [ - "http://www.apache.org/licenses/LICENSE-2.0" - ], - "id": "#", - "type": "object", - "javaType" : "org.apache.streams.instagram.InstagramConfiguration", - "javaInterfaces": ["java.io.Serializable"], - "properties": { - "clientId": { - "type": "string", - "description": "Your Instagram Client Id" - }, - "usersInfo": { - "type": "object", - "javaInterfaces" : ["java.io.Serializable"], - "properties": { - "authorizedTokens": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - }, - "description": "Instagram tokens for authorized users of your client/app" - }, - "users": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "object", - "$ref": "#/definitions/user" - }, - "description": "List of user ids to gather data for. Type of data gathered depends on provider" - }, - "defaultAfterDate": { - "type": "string", - "format": "date-time", - "description": "If the api allows to gather data by date range, this date will be used as the start of the range for the request for all users that don't have date ranges specified. If this is null it will pull from the earliest possible time" - }, - "defaultBeforeDate": { - "type": "string", - "format": "date-time", - "description": "If the api allows to gather data by date range, this date will be used as the end of the range for the request for all users that don't have date ranges specified. If this is null it will pull till current time." - } - } - } - }, - "definitions": { - "user": { - "type": "object", - "javaInterfaces" : ["java.io.Serializable"], - "properties": { - "userId": { - "type": "string", - "description": "instagram user id" - }, - "afterDate": { - "type": "string", - "format": "date-time", - "description": "If the api allows to gather data by date range, this date will be used as the start of the range for the request for this user. If this is null it will use the defaultBeforeDate." - }, - "beforeDate": { - "type": "string", - "format": "date-time", - "description": "If the api allows to gather data by date range, this date will be used as the end of the range for the request for this user.. If this is null it will use the defaultAfterDate." - } - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/InstagramUserInformationConfiguration.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/InstagramUserInformationConfiguration.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/InstagramUserInformationConfiguration.json deleted file mode 100644 index 42eb5d6..0000000 --- a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/InstagramUserInformationConfiguration.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-03/schema", - "$license": [ - "http://www.apache.org/licenses/LICENSE-2.0" - ], - "id": "#", - "type": "object", - "javaType" : "org.apache.streams.instagram.InstagramUserInformationConfiguration", - "extends": {"$ref":"InstagramConfiguration.json"}, - "javaInterfaces": ["java.io.Serializable"], - "properties": { - "userIds": { - "type": "array", - "description": "A list of user IDs, indicating the users whose posts should be delivered on the stream", - "items": { - "type": "string" - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/CommentsResponse.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/CommentsResponse.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/CommentsResponse.json new file mode 100644 index 0000000..e315871 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/CommentsResponse.json @@ -0,0 +1,26 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.CommentsResponse", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "../pojo/Comment.json" + } + }, + "meta": { + "javaType": "org.apache.streams.instagram.api.Meta" + }, + "pagination": { + "javaType": "org.apache.streams.instagram.api.Pagination" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/MediaResponse.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/MediaResponse.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/MediaResponse.json new file mode 100644 index 0000000..cbf4ebc --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/MediaResponse.json @@ -0,0 +1,23 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.MediaResponse", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "data": { + "$ref": "../pojo/Media.json" + }, + "meta": { + "javaType": "org.apache.streams.instagram.api.Meta" + }, + "pagination": { + "javaType": "org.apache.streams.instagram.api.Pagination" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/Meta.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/Meta.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/Meta.json new file mode 100644 index 0000000..956f478 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/Meta.json @@ -0,0 +1,23 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.Meta", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "code": { + "type": "integer" + }, + "error_message": { + "type": "string" + }, + "error_type": { + "type": "string" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/Pagination.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/Pagination.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/Pagination.json new file mode 100644 index 0000000..315c416 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/Pagination.json @@ -0,0 +1,20 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.Pagination", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "next_url": { + "type": "string" + }, + "next_max_id": { + "type": "string" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/RecentMediaResponse.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/RecentMediaResponse.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/RecentMediaResponse.json new file mode 100644 index 0000000..4dc61db --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/RecentMediaResponse.json @@ -0,0 +1,26 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.RecentMediaResponse", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "../pojo/Media.json" + } + }, + "meta": { + "javaType": "org.apache.streams.instagram.api.Meta" + }, + "pagination": { + "javaType": "org.apache.streams.instagram.api.Pagination" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchMediaRequest.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchMediaRequest.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchMediaRequest.json new file mode 100644 index 0000000..da1b790 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchMediaRequest.json @@ -0,0 +1,26 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.SearchMediaRequest", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "distance": { + "description": "Default is 1km (distance=1000), max distance is 5km.", + "type": "integer" + }, + "lat": { + "description": "Latitude of the center search coordinate. If used, lng is required.", + "type": "integer" + }, + "lng": { + "description": "Longitude of the center search coordinate. If used, lat is required.", + "type": "integer" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchMediaResponse.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchMediaResponse.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchMediaResponse.json new file mode 100644 index 0000000..a95e3c2 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchMediaResponse.json @@ -0,0 +1,26 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.SearchMediaResponse", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "../pojo/Media.json" + } + }, + "meta": { + "javaType": "org.apache.streams.instagram.api.Meta" + }, + "pagination": { + "javaType": "org.apache.streams.instagram.api.Pagination" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchUsersRequest.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchUsersRequest.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchUsersRequest.json new file mode 100644 index 0000000..4ec3064 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchUsersRequest.json @@ -0,0 +1,22 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.SearchUsersRequest", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "q": { + "description": "query", + "type": "string" + }, + "count": { + "description": "count", + "type": "integer" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchUsersResponse.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchUsersResponse.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchUsersResponse.json new file mode 100644 index 0000000..28a5a56 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SearchUsersResponse.json @@ -0,0 +1,26 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.SearchUsersResponse", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "../pojo/UserInfo.json" + } + }, + "meta": { + "javaType": "org.apache.streams.instagram.api.Meta" + }, + "pagination": { + "javaType": "org.apache.streams.instagram.api.Pagination" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SelfLikedMediaRequest.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SelfLikedMediaRequest.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SelfLikedMediaRequest.json new file mode 100644 index 0000000..a56196e --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SelfLikedMediaRequest.json @@ -0,0 +1,22 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.SelfLikedMediaRequest", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "max_like_id": { + "description": "max_like_id", + "type": "integer" + }, + "count": { + "description": "count", + "type": "integer" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SelfRecentMediaRequest.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SelfRecentMediaRequest.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SelfRecentMediaRequest.json new file mode 100644 index 0000000..19d7a29 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/SelfRecentMediaRequest.json @@ -0,0 +1,26 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.SelfRecentMediaRequest", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "max_id": { + "description": "max_id", + "type": "integer" + }, + "min_id": { + "description": "min_id", + "type": "integer" + }, + "count": { + "description": "count", + "type": "integer" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UserInfoResponse.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UserInfoResponse.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UserInfoResponse.json new file mode 100644 index 0000000..cc38cfd --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UserInfoResponse.json @@ -0,0 +1,23 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.UserInfoResponse", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "data": { + "$ref": "../pojo/UserInfo.json" + }, + "meta": { + "javaType": "org.apache.streams.instagram.api.Meta" + }, + "pagination": { + "javaType": "org.apache.streams.instagram.api.Pagination" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UserRecentMediaRequest.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UserRecentMediaRequest.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UserRecentMediaRequest.json new file mode 100644 index 0000000..5ade8bc --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UserRecentMediaRequest.json @@ -0,0 +1,19 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.pojo.UserRecentMediaRequest", + "javaInterfaces": [ + "java.io.Serializable" + ], + "extends": {"$ref":"SelfRecentMediaRequest.json"}, + "properties": { + "user_id": { + "description": "user_id", + "type": "string" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UsersInfoResponse.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UsersInfoResponse.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UsersInfoResponse.json new file mode 100644 index 0000000..95c468d --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/api/UsersInfoResponse.json @@ -0,0 +1,26 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.api.UsersInfoResponse", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "../pojo/UserInfo.json" + } + }, + "meta": { + "javaType": "org.apache.streams.instagram.api.Meta" + }, + "pagination": { + "javaType": "org.apache.streams.instagram.api.Pagination" + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramConfiguration.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramConfiguration.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramConfiguration.json new file mode 100644 index 0000000..e213445 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramConfiguration.json @@ -0,0 +1,64 @@ +{ + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "type": "object", + "javaType" : "org.apache.streams.instagram.config.InstagramConfiguration", + "javaInterfaces": ["java.io.Serializable"], + "properties": { + "protocol": { + "type": "string", + "description": "The protocol", + "default": "https" + }, + "host": { + "type": "string", + "description": "The host", + "default": "api.instagram.com" + }, + "port": { + "type": "integer", + "description": "The port", + "default": 443 + }, + "version": { + "type": "string", + "description": "The version", + "default": "v1" + }, + "oauth": { + "type": "object", + "dynamic": "true", + "javaType" : "org.apache.streams.instagram.config.InstagramOAuthConfiguration", + "javaInterfaces": ["java.io.Serializable"], + "properties": { + "clientId": { + "type": "string" + }, + "clientSecret": { + "type": "string" + }, + "accessToken": { + "type": "string" + } + } + }, + "threadsPerProvider": { + "type": "integer", + "description": "number of threads per provider", + "default": 10 + }, + "retrySleepMs": { + "type": "integer", + "description": "ms to sleep when hitting a rate limit", + "default": 100000 + }, + "retryMax": { + "type": "integer", + "description": "max times to retry", + "default": 10 + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramRecentMediaProviderConfiguration.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramRecentMediaProviderConfiguration.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramRecentMediaProviderConfiguration.json new file mode 100644 index 0000000..8c1dc07 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramRecentMediaProviderConfiguration.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "type": "object", + "javaType" : "org.apache.streams.instagram.config.InstagramRecentMediaProviderConfiguration", + "extends": {"$ref":"InstagramConfiguration.json"}, + "javaInterfaces": ["java.io.Serializable"], + "properties": { + "info": { + "type": "array", + "description": "A list of user IDs, indicating the users whose posts should be delivered on the stream", + "items": { + "type": "string" + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramUserInfoProviderConfiguration.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramUserInfoProviderConfiguration.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramUserInfoProviderConfiguration.json new file mode 100644 index 0000000..9906c34 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/config/InstagramUserInfoProviderConfiguration.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "type": "object", + "javaType" : "org.apache.streams.instagram.config.InstagramUserInfoProviderConfiguration", + "extends": {"$ref":"InstagramConfiguration.json"}, + "javaInterfaces": ["java.io.Serializable"], + "properties": { + "info": { + "type": "array", + "description": "A list of user IDs, indicating the users whose posts should be delivered on the stream", + "items": { + "type": "string" + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/Comment.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/Comment.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/Comment.json new file mode 100644 index 0000000..5e7d60e --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/Comment.json @@ -0,0 +1,26 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.pojo.Comment", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "id": { + "type": "string" + }, + "created_time": { + "type": "string" + }, + "text": { + "type": "string" + }, + "from": { + "$ref": "UserInfo.json" + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/Media.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/Media.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/Media.json new file mode 100644 index 0000000..5256e3a --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/Media.json @@ -0,0 +1,164 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.pojo.Media", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "caption": { + "type": "object", + "javaType": "org.apache.streams.instagram.pojo.Caption", + "properties": { + "created_time": { + "type": "string" + }, + "from": { + "$ref": "UserInfo.json" + }, + "id": { + "type": "string" + }, + "text": { + "type": "string" + } + } + }, + "comments": { + "type": "object", + "javaType": "org.apache.streams.instagram.pojo.Comments", + "properties": { + "count": { + "type": "integer" + }, + "data": { + "type": "array", + "items": { + "$ref": "Comment.json" + } + } + } + }, + "created_time": { + "type": "string" + }, + "filter": { + "type": "string" + }, + "id": { + "type": "string" + }, + "images": { + "type": "object", + "properties": { + "low_resolution": { + "description": "this should be org.apache.streams.pojo.json.MediaLink, ../../../../../../../../../../streams-schemas/streams-schema-activitystreams/src/main/jsonschema/media_link.json", + "type": "object", + "javaType": "org.apache.streams.pojo.json.ImageParent" + }, + "standard_resolution": { + "description": "this should be org.apache.streams.pojo.json.MediaLink, ../../../../../../../../../../streams-schemas/streams-schema-activitystreams/src/main/jsonschema/media_link.json", + "type": "object", + "javaType": "org.apache.streams.pojo.json.ImageParent" + }, + "thumbnail": { + "description": "this should be org.apache.streams.pojo.json.MediaLink, ../../../../../../../../../../streams-schemas/streams-schema-activitystreams/src/main/jsonschema/media_link.json", + "type": "object", + "javaType": "org.apache.streams.pojo.json.ImageParent" + } + } + }, + "likes": { + "type": "object", + "javaType": "org.apache.streams.instagram.pojo.LikeCounts", + "properties": { + "count": { + "type": "integer" + } + } + }, + "link": { + "type": "string" + }, + "location": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "latitude": { + "type": "number" + }, + "longitude": { + "type": "number" + }, + "name": { + "type": "string" + } + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "type": { + "type": "string", + "enum": [ + "image", + "video" + ] + }, + "user": { + "$ref": "UserInfo.json" + }, + "videos": { + "type": "object", + "properties": { + "low_resolution": { + "description": "this should be org.apache.streams.pojo.json.MediaLink, ../../../../../../../../../../streams-schemas/streams-schema-activitystreams/src/main/jsonschema/media_link.json", + "type": "object", + "javaType": "org.apache.streams.pojo.json.ImageParent" + }, + "standard_resolution": { + "description": "this should be org.apache.streams.pojo.json.MediaLink, ../../../../../../../../../../streams-schemas/streams-schema-activitystreams/src/main/jsonschema/media_link.json", + "type": "object", + "javaType": "org.apache.streams.pojo.json.ImageParent" + }, + "thumbnail": { + "description": "this should be org.apache.streams.pojo.json.MediaLink, ../../../../../../../../../../streams-schemas/streams-schema-activitystreams/src/main/jsonschema/media_link.json", + "type": "object", + "javaType": "org.apache.streams.pojo.json.ImageParent" + } + } + }, + "users_in_photo": { + "type": "array", + "items": { + "type": "object", + "properties": { + "user": { + "$ref": "UserInfo.json" + }, + "position": { + "type": "object", + "properties": { + "x": { + "type": "number" + }, + "y": { + "type": "number" + } + } + } + } + } + } + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/UserInfo.json ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/UserInfo.json b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/UserInfo.json new file mode 100644 index 0000000..b8af857 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/jsonschema/org/apache/streams/instagram/pojo/UserInfo.json @@ -0,0 +1,47 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.instagram.pojo.UserInfo", + "javaInterfaces": [ + "java.io.Serializable" + ], + "properties": { + "id": { + "type": "string" + }, + "username": { + "type": "string" + }, + "full_name": { + "type": "string" + }, + "profile_picture": { + "type": "string" + }, + "bio": { + "type": "string" + }, + "website": { + "type": "string" + }, + "counts": { + "type": "object", + "javaType": "org.apache.streams.instagram.pojo.UserInfoCounts", + "properties": { + "media": { + "type": "integer" + }, + "follows": { + "type": "integer" + }, + "followed_by": { + "type": "integer" + } + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/main/resources/reference.conf ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/main/resources/reference.conf b/streams-contrib/streams-provider-instagram/src/main/resources/reference.conf index fe95199..5fa90d0 100644 --- a/streams-contrib/streams-provider-instagram/src/main/resources/reference.conf +++ b/streams-contrib/streams-provider-instagram/src/main/resources/reference.conf @@ -1,5 +1,8 @@ # Apache Streams (incubating) # Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 instagram { - version = "v1" + protocol = "https" + host = "api.instagram.com" + port = 443 + version = "v1" } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/api/InstagramOAuthRequestSignerTest.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/api/InstagramOAuthRequestSignerTest.java b/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/api/InstagramOAuthRequestSignerTest.java new file mode 100644 index 0000000..211dc25 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/api/InstagramOAuthRequestSignerTest.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.streams.instagram.test.api; + +import org.apache.streams.instagram.api.InstagramOAuthRequestSigner; +import org.apache.streams.instagram.config.InstagramOAuthConfiguration; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +/** + * Created by sblackmon on 3/26/17. + */ +public class InstagramOAuthRequestSignerTest { + + private static final Logger LOGGER = LoggerFactory.getLogger(InstagramOAuthRequestSignerTest.class); + + private static final InstagramOAuthConfiguration testOauthConfig = new InstagramOAuthConfiguration() + .withClientSecret("6dc1787668c64c939929c17683d7cb74") + .withAccessToken("fb2e77d.47a0479900504cb3ab4a1f626d174d2d"); + + private static final InstagramOAuthRequestSigner signer = + new InstagramOAuthRequestSigner(testOauthConfig); + + @Test + public void testExample1() throws Exception { + String endpoint = "/users/self"; + Map<String,String> testParamMap = new HashMap<>(); + testParamMap.put("access_token", "fb2e77d.47a0479900504cb3ab4a1f626d174d2d"); + String signature_parameter_string = signer.generateSignatureBaseString(endpoint, testParamMap); + String expected_parameter_string = endpoint + "|access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d"; + assertEquals(expected_parameter_string, signature_parameter_string); + String signature = signer.computeSignature(signature_parameter_string, testOauthConfig.getClientSecret()); + String expected_signature = "cbf5a1f41db44412506cb6563a3218b50f45a710c7a8a65a3e9b18315bb338bf"; + assertEquals(expected_signature, signature); + } + + @Test + public void testExample2() throws Exception { + String endpoint = "/media/657988443280050001_25025320"; + Map<String,String> testParamMap = new HashMap<>(); + testParamMap.put("access_token", "fb2e77d.47a0479900504cb3ab4a1f626d174d2d"); + testParamMap.put("count", "10"); + String signature_parameter_string = signer.generateSignatureBaseString(endpoint, testParamMap); + String expected_parameter_string = endpoint + "|access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d|count=10"; + assertEquals(expected_parameter_string, signature_parameter_string); + String signature = signer.computeSignature(signature_parameter_string, testOauthConfig.getClientSecret()); + String expected_signature = "260634b241a6cfef5e4644c205fb30246ff637591142781b86e2075faf1b163a"; + assertEquals(expected_signature, signature); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/data/InstagramMediaFeedDataConverterIT.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/data/InstagramMediaFeedDataConverterIT.java b/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/data/InstagramMediaFeedDataConverterIT.java index e92aa7e..9c4a7da 100644 --- a/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/data/InstagramMediaFeedDataConverterIT.java +++ b/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/data/InstagramMediaFeedDataConverterIT.java @@ -19,15 +19,13 @@ package org.apache.streams.instagram.test.data; import org.apache.streams.data.ActivityConverter; +import org.apache.streams.instagram.pojo.Media; import org.apache.streams.instagram.serializer.InstagramMediaFeedDataConverter; import org.apache.streams.jackson.StreamsJacksonMapper; import org.apache.streams.pojo.json.Activity; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; import org.apache.commons.lang.StringUtils; -import org.jinstagram.entity.users.feed.MediaFeedData; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -48,26 +46,21 @@ import static org.junit.Assert.assertThat; /** * Tests conversion of instagram inputs to Activity. */ - public class InstagramMediaFeedDataConverterIT { private static final Logger LOGGER = LoggerFactory.getLogger(InstagramMediaFeedDataConverterIT.class); - // use gson because jInstagram's pojos do - private Gson gson = new Gson(); - - // use jackson to write to file output private ObjectMapper mapper = StreamsJacksonMapper.getInstance(); - @Test - public void InstagramMediaFeedDataConverterITCase() throws Exception { - InputStream is = InstagramMediaFeedDataConverterIT.class.getResourceAsStream("/testMediaFeedObjects.txt"); + @Test(dependsOnGroups = "providers") + public void InstagramMediaFeedDataConverterIT() throws Exception { + InputStream is = InstagramMediaFeedDataConverterIT.class.getResourceAsStream("/InstagramRecentMediaProviderIT.stdout.txt"); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); PrintStream outStream = new PrintStream( new BufferedOutputStream( - new FileOutputStream("target/test-classes/InstagramMediaFeedDataConverterITCase.txt"))); + new FileOutputStream("target/test-classes/InstagramMediaFeedDataConverterIT.txt"))); try { while (br.ready()) { @@ -75,9 +68,9 @@ public class InstagramMediaFeedDataConverterIT { if (!StringUtils.isEmpty(line)) { LOGGER.info("raw: {}", line); - MediaFeedData mediaFeedData = gson.fromJson(line, MediaFeedData.class); + Media mediaFeedData = mapper.readValue(line, Media.class); - ActivityConverter<MediaFeedData> converter = new InstagramMediaFeedDataConverter(); + ActivityConverter<Media> converter = new InstagramMediaFeedDataConverter(); Activity activity = converter.toActivityList(mediaFeedData).get(0); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/data/InstagramUserInfoDataConverterIT.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/data/InstagramUserInfoDataConverterIT.java b/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/data/InstagramUserInfoDataConverterIT.java index b46e2f9..91d4647 100644 --- a/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/data/InstagramUserInfoDataConverterIT.java +++ b/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/data/InstagramUserInfoDataConverterIT.java @@ -19,6 +19,7 @@ package org.apache.streams.instagram.test.data; import org.apache.streams.data.ActivityObjectConverter; +import org.apache.streams.instagram.pojo.UserInfo; import org.apache.streams.instagram.serializer.InstagramUserInfoDataConverter; import org.apache.streams.jackson.StreamsJacksonMapper; import org.apache.streams.pojo.json.ActivityObject; @@ -26,7 +27,6 @@ import org.apache.streams.pojo.json.ActivityObject; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import org.apache.commons.lang.StringUtils; -import org.jinstagram.entity.users.basicinfo.UserInfoData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,15 +53,11 @@ public class InstagramUserInfoDataConverterIT { private static final Logger LOGGER = LoggerFactory.getLogger(InstagramUserInfoDataConverterIT.class); - // use gson because jInstagram's pojos do - private Gson gson = new Gson(); - - // use jackson to write to file output private ObjectMapper mapper = StreamsJacksonMapper.getInstance(); - @Test + @Test(dependsOnGroups = "providers") public void InstagramUserInfoDataConverterIT() throws Exception { - InputStream is = InstagramUserInfoDataConverterIT.class.getResourceAsStream("/testUserInfoData.txt"); + InputStream is = InstagramUserInfoDataConverterIT.class.getResourceAsStream("/InstagramUserInfoProviderIT.stdout.txt"); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); @@ -76,9 +72,9 @@ public class InstagramUserInfoDataConverterIT { LOGGER.info("raw: {}", line); - UserInfoData userInfoData = gson.fromJson(line, UserInfoData.class); + UserInfo userInfoData = mapper.readValue(line, UserInfo.class); - ActivityObjectConverter<UserInfoData> converter = new InstagramUserInfoDataConverter(); + ActivityObjectConverter<UserInfo> converter = new InstagramUserInfoDataConverter(); ActivityObject activityObject = converter.toActivityObject(userInfoData); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/providers/InstagramRecentMediaProviderIT.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/providers/InstagramRecentMediaProviderIT.java b/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/providers/InstagramRecentMediaProviderIT.java index 8507db5..f5c55ed 100644 --- a/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/providers/InstagramRecentMediaProviderIT.java +++ b/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/providers/InstagramRecentMediaProviderIT.java @@ -20,6 +20,7 @@ package org.apache.streams.instagram.test.providers; import org.apache.streams.instagram.provider.recentmedia.InstagramRecentMediaProvider; +import org.hamcrest.Matchers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -29,6 +30,8 @@ import java.io.File; import java.io.FileReader; import java.io.LineNumberReader; +import static org.hamcrest.MatcherAssert.assertThat; + /** * Integration Test for InstagramRecentMediaProvider. */ @@ -36,7 +39,7 @@ public class InstagramRecentMediaProviderIT { private static final Logger LOGGER = LoggerFactory.getLogger(InstagramRecentMediaProviderIT.class); - @Test + @Test(groups = "providers") public void testInstagramRecentMediaProvider() throws Exception { String configfile = "./target/test-classes/InstagramRecentMediaProviderIT.conf"; @@ -57,16 +60,16 @@ public class InstagramRecentMediaProviderIT { testThread.join(60000); File out = new File(outfile); - Assert.assertTrue (out.exists()); - Assert.assertTrue (out.canRead()); - Assert.assertTrue (out.isFile()); + Assert.assertTrue(out.exists()); + Assert.assertTrue(out.canRead()); + Assert.assertTrue(out.isFile()); FileReader outReader = new FileReader(out); LineNumberReader outCounter = new LineNumberReader(outReader); - while (outCounter.readLine() != null) { - } + while (outCounter.readLine() != null) {} + + assertThat(outCounter.getLineNumber(), Matchers.greaterThanOrEqualTo(1)); - Assert.assertTrue (outCounter.getLineNumber() >= 1); } } http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/providers/InstagramUserInfoProviderIT.java ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/providers/InstagramUserInfoProviderIT.java b/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/providers/InstagramUserInfoProviderIT.java index ba125e7..8e00084 100644 --- a/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/providers/InstagramUserInfoProviderIT.java +++ b/streams-contrib/streams-provider-instagram/src/test/java/org/apache/streams/instagram/test/providers/InstagramUserInfoProviderIT.java @@ -20,6 +20,7 @@ package org.apache.streams.instagram.test.providers; import org.apache.streams.instagram.provider.userinfo.InstagramUserInfoProvider; +import org.hamcrest.Matchers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -29,11 +30,13 @@ import java.io.File; import java.io.FileReader; import java.io.LineNumberReader; +import static org.hamcrest.MatcherAssert.assertThat; + public class InstagramUserInfoProviderIT { private static final Logger LOGGER = LoggerFactory.getLogger(InstagramUserInfoProviderIT.class); - @Test + @Test(groups = "providers") public void testInstagramUserInfoProvider() throws Exception { String configfile = "./target/test-classes/InstagramUserInfoProviderIT.conf"; @@ -54,16 +57,16 @@ public class InstagramUserInfoProviderIT { testThread.join(60000); File out = new File(outfile); - Assert.assertTrue (out.exists()); - Assert.assertTrue (out.canRead()); - Assert.assertTrue (out.isFile()); + Assert.assertTrue(out.exists()); + Assert.assertTrue(out.canRead()); + Assert.assertTrue(out.isFile()); FileReader outReader = new FileReader(out); LineNumberReader outCounter = new LineNumberReader(outReader); while (outCounter.readLine() != null) {} - Assert.assertTrue (outCounter.getLineNumber() >= 1); + assertThat(outCounter.getLineNumber(), Matchers.greaterThanOrEqualTo(1)); } } http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/test/resources/InstagramRecentMediaProviderIT.conf ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/test/resources/InstagramRecentMediaProviderIT.conf b/streams-contrib/streams-provider-instagram/src/test/resources/InstagramRecentMediaProviderIT.conf index 5acfbd0..3bfb7c0 100644 --- a/streams-contrib/streams-provider-instagram/src/test/resources/InstagramRecentMediaProviderIT.conf +++ b/streams-contrib/streams-provider-instagram/src/test/resources/InstagramRecentMediaProviderIT.conf @@ -14,12 +14,10 @@ # specific language governing permissions and limitations # under the License. instagram { - usersInfo = { - users = [ - { - #userId = "blackmonsteve" - userId = "1646021441" - } - ] - } + info = [ + #blackmonsteve + "1646021441" + ] + retryMax = 1 + retrySleepMs = 1000 } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/2c83c574/streams-contrib/streams-provider-instagram/src/test/resources/InstagramUserInfoProviderIT.conf ---------------------------------------------------------------------- diff --git a/streams-contrib/streams-provider-instagram/src/test/resources/InstagramUserInfoProviderIT.conf b/streams-contrib/streams-provider-instagram/src/test/resources/InstagramUserInfoProviderIT.conf index 5acfbd0..3bfb7c0 100644 --- a/streams-contrib/streams-provider-instagram/src/test/resources/InstagramUserInfoProviderIT.conf +++ b/streams-contrib/streams-provider-instagram/src/test/resources/InstagramUserInfoProviderIT.conf @@ -14,12 +14,10 @@ # specific language governing permissions and limitations # under the License. instagram { - usersInfo = { - users = [ - { - #userId = "blackmonsteve" - userId = "1646021441" - } - ] - } + info = [ + #blackmonsteve + "1646021441" + ] + retryMax = 1 + retrySleepMs = 1000 } \ No newline at end of file