Author: rbaxter85
Date: Fri May 10 14:27:34 2013
New Revision: 1481024
URL: http://svn.apache.org/r1481024
Log:
shindig atom API enhancements
Committed for Zhi Hong Yang
SHINDIG-1906
Added:
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummary.java
(with props)
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummaryConverter.java
(with props)
Modified:
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomAuthor.java
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomEntry.java
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomFeed.java
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/xstream/XStream081Configuration.java
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomId.xml
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomIds.xml
Modified:
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomAuthor.java
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomAuthor.java?rev=1481024&r1=1481023&r2=1481024&view=diff
==============================================================================
---
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomAuthor.java
(original)
+++
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomAuthor.java
Fri May 10 14:27:34 2013
@@ -48,7 +48,10 @@ public class AtomAuthor {
* @param activityEntry
*/
public AtomAuthor(ActivityEntry activityEntry) {
- uri = activityEntry.getActor().getId();
+ uri = activityEntry.getActor().getUrl();
name = activityEntry.getActor().getDisplayName();
+ if (name == null) {
+ name = activityEntry.getActor().getId();
+ }
}
}
Modified:
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomEntry.java
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomEntry.java?rev=1481024&r1=1481023&r2=1481024&view=diff
==============================================================================
---
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomEntry.java
(original)
+++
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomEntry.java
Fri May 10 14:27:34 2013
@@ -38,7 +38,7 @@ public class AtomEntry {
@SuppressWarnings("unused")
private String title;
@SuppressWarnings("unused")
- private String summary;
+ private AtomSummary summary;
@SuppressWarnings("unused")
private String icon;
@SuppressWarnings("unused")
@@ -79,7 +79,7 @@ public class AtomEntry {
Activity activity = (Activity) o;
content = new AtomContent(activity);
title = activity.getTitle();
- summary = activity.getBody();
+ summary = new AtomSummary(activity.getBody());
link = new AtomLink("self", activity.getUrl());
icon = activity.getStreamFaviconUrl();
source = new AtomSource(activity);
@@ -90,7 +90,8 @@ public class AtomEntry {
ActivityEntry activity = (ActivityEntry)o;
id = activity.getId();
title = activity.getTitle();
- summary = activity.getObject().getSummary();
+ summary = new AtomSummary(activity.getObject().getSummary());
+ link = new AtomLink("alternate", activity.getObject().getUrl());
author = new AtomAuthor(activity);
content = new AtomContent(activity);
try {
Modified:
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomFeed.java
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomFeed.java?rev=1481024&r1=1481023&r2=1481024&view=diff
==============================================================================
---
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomFeed.java
(original)
+++
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomFeed.java
Fri May 10 14:27:34 2013
@@ -46,8 +46,20 @@ public class AtomFeed {
@SuppressWarnings("unused")
private String author;
@SuppressWarnings("unused")
+ private String title;
+ @SuppressWarnings("unused")
+ private String updated;
+ @SuppressWarnings("unused")
+ private String id;
+ @SuppressWarnings("unused")
private AtomLink link;
+ public static final String AUTHOR = "author";
+ public static final String TITLE = "title";
+ public static final String UPDATED = "updated";
+ public static final String ID = "id";
+ public static final String URL = "url";
+
/**
* @param obj
*/
@@ -64,8 +76,15 @@ public class AtomFeed {
startIndex = r.getStartIndex();
totalResults = r.getTotalResults();
itemsPerPage = r.getItemsPerPage();
- author = "?";
- link = new AtomLink("rel", "???");
+ author = (r.get(AUTHOR)==null) ? "?" : r.get(AUTHOR).toString();
+ title = (r.get(TITLE)==null) ? "?" : r.get(TITLE).toString();
+ id = (r.get(ID)==null) ? "?" : r.get(ID).toString();
+ updated = (r.get(UPDATED)==null) ? "" : r.get(UPDATED).toString();
+
+ if (r.get(URL)!=null) {
+ link = new AtomLink("self", r.get(URL).toString());
+ }
+
} else if (obj instanceof Map) {
Map<?, ?> m = (Map<?, ?>) obj;
entry = Lists.newArrayList();
Added:
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummary.java
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummary.java?rev=1481024&view=auto
==============================================================================
---
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummary.java
(added)
+++
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummary.java
Fri May 10 14:27:34 2013
@@ -0,0 +1,42 @@
+/*
+ * 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.shindig.social.core.util.atom;
+
+
+/**
+ * Represents an atom:summary element, and exists only so we can add a type
+ */
+public class AtomSummary {
+
+ @SuppressWarnings("unused")
+ private String type = "html";
+ @SuppressWarnings("unused")
+ private String value;
+
+ /**
+ * @param string value
+ */
+ public AtomSummary(String value) {
+ this.value=value;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+}
\ No newline at end of file
Propchange:
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummary.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummaryConverter.java
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummaryConverter.java?rev=1481024&view=auto
==============================================================================
---
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummaryConverter.java
(added)
+++
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummaryConverter.java
Fri May 10 14:27:34 2013
@@ -0,0 +1,72 @@
+/*
+ * 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.shindig.social.core.util.atom;
+
+import com.thoughtworks.xstream.converters.Converter;
+import com.thoughtworks.xstream.converters.MarshallingContext;
+import com.thoughtworks.xstream.converters.UnmarshallingContext;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
+import com.google.common.base.Preconditions;
+
+/**
+ * Serializes summary for atom, taking account of attributes.
+ */
+public class AtomSummaryConverter implements Converter {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
com.thoughtworks.xstream.converters.Converter#marshal(java.lang.Object,
+ * com.thoughtworks.xstream.io.HierarchicalStreamWriter,
+ * com.thoughtworks.xstream.converters.MarshallingContext)
+ */
+ public void marshal(Object object, HierarchicalStreamWriter writer,
MarshallingContext context) {
+ AtomSummary link = (AtomSummary) object;
+ if (link.getType() != null) {
+ writer.addAttribute("type", link.getType());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader,
+ * com.thoughtworks.xstream.converters.UnmarshallingContext)
+ */
+ public Object unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context) {
+ Preconditions.checkNotNull(reader);
+
+ reader.moveDown();
+ AtomSummary al = new AtomSummary(reader.getValue());
+ reader.moveUp();
+ return al;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
com.thoughtworks.xstream.converters.ConverterMatcher#canConvert(java.lang.Class)
+ */
+ // Base API is inherently unchecked
+ @SuppressWarnings("unchecked")
+ public boolean canConvert(Class clazz) {
+ return AtomSummary.class.equals(clazz);
+ }
+
+}
Propchange:
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomSummaryConverter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/xstream/XStream081Configuration.java
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/xstream/XStream081Configuration.java?rev=1481024&r1=1481023&r2=1481024&view=diff
==============================================================================
---
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/xstream/XStream081Configuration.java
(original)
+++
shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/xstream/XStream081Configuration.java
Fri May 10 14:27:34 2013
@@ -52,6 +52,7 @@ import org.apache.shindig.social.core.ut
import org.apache.shindig.social.core.util.atom.AtomFeed;
import org.apache.shindig.social.core.util.atom.AtomKeyValue;
import org.apache.shindig.social.core.util.atom.AtomLinkConverter;
+import org.apache.shindig.social.core.util.atom.AtomSummaryConverter;
import org.apache.shindig.social.opensocial.model.Account;
import org.apache.shindig.social.opensocial.model.Activity;
import org.apache.shindig.social.opensocial.model.ActivityEntry;
@@ -152,7 +153,6 @@ public class XStream081Configuration imp
.put("bodyType", os)
.put("message", os)
.put("mediaItem", os)
- .put("name", os)
.put("url", os)
.put("response", os)
.put("appdata", os)
@@ -352,6 +352,7 @@ public class XStream081Configuration imp
xstream.registerConverter(new RestfullCollectionConverter(fmapper));
xstream.registerConverter(new DataCollectionConverter(fmapper));
xstream.registerConverter(new AtomLinkConverter());
+ xstream.registerConverter(new AtomSummaryConverter());
xstream.registerConverter(new ISO8601DateConverter());
xstream.registerConverter(new ISO8601GregorianCalendarConverter());
Modified:
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomId.xml
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomId.xml?rev=1481024&r1=1481023&r2=1481024&view=diff
==============================================================================
---
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomId.xml
(original)
+++
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomId.xml
Fri May 10 14:27:34 2013
@@ -2,11 +2,12 @@
<entry>
<id>activity2</id>
<title>John posted a new photo album.</title>
- <summary>Photo posted</summary>
+ <summary type="html" />
<author>
- <uri>john.doe</uri>
- <name xmlns="http://ns.opensocial.org/2008/opensocial">John Doe</name>
+ <uri>http://example.org/john</uri>
+ <name>John Doe</name>
</author>
+ <link rel="alternate">http://example.org/album/my_fluffy_cat.jpg</link>
<content type="application/xml">
<activityEntry xmlns="http://ns.opensocial.org/2008/opensocial">
<actor>
Modified:
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomIds.xml
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomIds.xml?rev=1481024&r1=1481023&r2=1481024&view=diff
==============================================================================
---
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomIds.xml
(original)
+++
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomIds.xml
Fri May 10 14:27:34 2013
@@ -2,11 +2,12 @@
<entry>
<id>activity2</id>
<title>John posted a new photo album.</title>
- <summary>Photo posted</summary>
+ <summary type="html" />
<author>
- <uri>john.doe</uri>
- <name xmlns="http://ns.opensocial.org/2008/opensocial">John Doe</name>
+ <uri>http://example.org/john</uri>
+ <name>John Doe</name>
</author>
+ <link rel="alternate">http://example.org/album/my_fluffy_cat.jpg</link>
<content type="application/xml">
<activityEntry xmlns="http://ns.opensocial.org/2008/opensocial">
<actor>
@@ -89,10 +90,12 @@
<entry>
<id>activity1</id>
<title>John shared new photos with you</title>
+ <summary type="html" />
<author>
- <uri>john.doe</uri>
- <name xmlns="http://ns.opensocial.org/2008/opensocial">John Doe</name>
+ <uri>http://example.org/john</uri>
+ <name>John Doe</name>
</author>
+ <link rel="alternate">http://example.org/blog/2011/02/entry</link>
<content type="application/xml">
<activityEntry xmlns="http://ns.opensocial.org/2008/opensocial">
<actor>
@@ -145,5 +148,7 @@
<osearch:totalResults>2</osearch:totalResults>
<osearch:itemsPerPage>2</osearch:itemsPerPage>
<author>?</author>
- <link rel="rel">???</link>
+ <title>?</title>
+ <updated></updated>
+ <id>?</id>
</feed>