Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated dependencies to the latest versions. #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = crlf
indent_size = 2
indent_style = space
insert_final_newline = false
max_line_length = 120
tab_width = 4
trim_trailing_whitespace = true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ target
*/.classpath
*/.project
*/.settings
*.iml
.idea
116 changes: 58 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ Maven:
Use Maven to build.

- mvn compile
- mvn install
- mvn install
- mvn -f assembly assembly:assembly

```xml
<dependency>
<groupId>com.ibm.common</groupId>
<artifactId>activitystreams</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
</dependency>
```

Dependencies:

- gson 2.2.4
- guava 16.0.1
- joda-time 2.3
- gson 2.8.6
- guava 30.1.1-jre
- joda-time 2.10.10

## Creating an Activity statement

Expand All @@ -34,30 +34,30 @@ public class Example {

public static void main(String... args) {

Activity activity =
Activity activity =
activity()
.actor(object("person").id("acct:[email protected]"))
.object(object("note").content("my note"))
.verb("post")
.get();

}

}
```

The library uses a consistent fluent generator pattern to construct all
The library uses a consistent fluent generator pattern to construct all
object types. Once created, objects are immutable.

## Serializing and Parsing objects

The library has one job: to make it easy to create and parse Activity
Stream objects that are conformant to the Activity Streams 2.0
The library has one job: to make it easy to create and parse Activity
Stream objects that are conformant to the Activity Streams 2.0
specification.

The IO object is used to serialize and parse Activity Stream objects.
IO objects are threadsafe and immutable so they can be safely created
once and stored as a static final constant.
The IO object is used to serialize and parse Activity Stream objects.
IO objects are threadsafe and immutable so they can be safely created
once and stored as a static final constant.

```java
package com.ibm.common.activitystreams;
Expand All @@ -72,25 +72,25 @@ import java.io.ByteArrayOutputStream;
public class Test {

private static final IO io = makeDefaultPrettyPrint();

public static void main(String... args) {

Activity activity =
Activity activity =
activity()
.actor(object("person").id("acct:[email protected]"))
.object(object("note").content("my note"))
.verb("post")
.get();
ByteArrayOutputStream out =

ByteArrayOutputStream out =
new ByteArrayOutputStream();

// Write it out
activity.writeTo(out, io);
ByteArrayInputStream in =

ByteArrayInputStream in =
new ByteArrayInputStream(out.toByteArray());

// Read it in
activity = io.readAsActivity(in);

Expand All @@ -103,13 +103,13 @@ public class Test {

for (ASObject object : activity.object())
System.out.println(object.objectType().id()) // "note"

// iterate all properties
for (String key : activity)
System.out.println(activity.get(key));

}

}

```
Expand All @@ -118,26 +118,26 @@ All Activity Stream objects support a variety of writeTo methods. These
serialize those objects as JSON to either an OutputStream, Writer or a
String. You can choose to use the default IO instance or pass in an IO.
Alternatively, you can use the write methods on the IO object itself to
serialize.
serialize.

## Makers and Builders

All objects use a fluent generator pattern. That is, you use a builder
object to construct immutable instances of an object. You use Makers
All objects use a fluent generator pattern. That is, you use a builder
object to construct immutable instances of an object. You use Makers
classes to create instances of the builders.

```java
import com.ibm.common.activitystreams.Makers;
import com.ibm.common.activitystreams.ASObject;

//... the long way...

ASObject.Builder builder = Makers.object();

builder.id("urn:example:1")
.displayName("foo")
.objectType("thing");

ASObject obj = builder.get();
```

Expand All @@ -146,8 +146,8 @@ By leveraging the fluent API pattern, the example above can be written as:
```java
import static com.ibm.common.activitystreams.Makers.object;
import com.ibm.common.activitystreams.ASObject;
ASObject obj =

ASObject obj =
object("thing")
.id("urn:example:1")
.displayName("foo")
Expand All @@ -161,7 +161,7 @@ Here's a slightly more complex example:
import static com.ibm.common.activitystreams.Makers.object;
import static com.ibm.common.activitystreams.Activity;

Activity activity =
Activity activity =
activity()
.verb("post")
.actor(
Expand All @@ -176,18 +176,18 @@ Here's a slightly more complex example:
.get();
```

Here, we first create an Activity.Builder object (using "activity()"). We
Here, we first create an Activity.Builder object (using "activity()"). We
then set the verb to "post" and set a new "person" object as the actor.
Following that, we create a new "note" object and set it as the object
of the activity. Finally, we call get() to create the finished Activity object.

## Using Modules

A Module is a package collection of extensions to the Activity Streams 2.0
data model. The reference implementation currently provides modules for
data model. The reference implementation currently provides modules for
Action Handlers, GeoJSON and Legacy Activity Streams 1.0 objectTypes.

Modules are registered when the IO object is created. For example, to
Modules are registered when the IO object is created. For example, to
use the Actions module:

```java
Expand All @@ -198,20 +198,20 @@ use the Actions module:

//...

public static final IO io =
public static final IO io =
IO.makeDefaultPrettyPrint(ActionsModule.instance);

//... create an extension object
ASObject httpAction =

ASObject httpAction =
httpAction("http://example.org", METHOD_POST)
.auth(
"oauth2",
"oauth2",
object()
.set("scopes",
.set("scopes",
object()
.set(
"scope.key.1",
"scope.key.1",
object().set("description", "foo"))))
.expects(
htmlForm()
Expand All @@ -229,20 +229,20 @@ use the Actions module:
"urn:example:some:optional-feature")
.target(TARGET_DIALOG)
.get();

//... write the extension object out using the created IO object

java.io.ByteArrayOutputStream out =
java.io.ByteArrayOutputStream out =
new java.io.ByteArrayOutputStream();

// write using the IO object
httpAction.writeTo(out, io);
java.io.ByteArrayInputStream in =

java.io.ByteArrayInputStream in =
new java.io.ByteArrayInputStream(out.toByteArray());

httpAction = io.read(in);

```

The GeoJSON module provides an implementation of the GeoJSON format.
Expand All @@ -260,7 +260,7 @@ objectTypes (see https://github.com/activitystreams/activity-schema/blob/master/
```java
import com.ibm.common.activitystreams.legacy.LegacyModule;
import com.ibm.common.activitystreams.IO;

IO io = IO.makeDefault(LegacyModule.instance);
```

Expand All @@ -270,7 +270,7 @@ You can register multiple modules when the IO object is created:
import com.ibm.common.activitystreams.legacy.LegacyModule;
import com.ibm.common.geojson.as2.GeoModule;
import com.ibm.common.activitystreams.IO;

IO io = IO.makeDefault(LegacyModule.instance, GeoModule.instance);
```

Expand All @@ -280,18 +280,18 @@ Each of the modules is provided as separate Maven artifacts.:
<dependency>
<groupId>com.ibm.common</groupId>
<artifactId>activitystreams-actions</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.ibm.common</groupId>
<artifactId>activitystreams-geo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.ibm.common</groupId>
<artifactId>activitystreams-legacy</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
</dependency>
```
Loading