Author: mfranklin
Date: Thu May 2 14:07:15 2013
New Revision: 1478375
URL: http://svn.apache.org/r1478375
Log:
Fixed issues with MongoDB activity streams
Added:
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsEntry.java
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsMediaLink.java
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsObject.java
Modified:
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/conversion/impl/MongoDbActivityStreamsEntryConverter.java
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/repository/impl/MongoDbActivityStreamsRepository.java
rave/branches/0.21.1/rave-components/rave-mongodb/src/test/java/org/apache/rave/portal/repository/impl/MongoDbActivityStreamsRepositoryTest.java
Added:
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsEntry.java
URL:
http://svn.apache.org/viewvc/rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsEntry.java?rev=1478375&view=auto
==============================================================================
---
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsEntry.java
(added)
+++
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsEntry.java
Thu May 2 14:07:15 2013
@@ -0,0 +1,63 @@
+/*
+ * 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.rave.portal.model;
+
+
+import com.google.common.collect.Maps;
+import org.apache.rave.portal.model.impl.ActivityStreamsEntryImpl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MongoDbActivityStreamsEntry extends ActivityStreamsEntryImpl {
+
+ private HashMap openSocial;
+ private HashMap extensions;
+
+ @Override
+ public HashMap getOpenSocial() {
+ return openSocial;
+ }
+
+ @Override
+ public HashMap getExtensions() {
+ return extensions;
+ }
+
+ @Override
+ public void setOpenSocial(Map openSocial) {
+ this.openSocial = convertToHashMap(openSocial);
+ }
+
+ @Override
+ public void setExtensions(Map extensions) {
+ this.extensions = convertToHashMap(extensions);
+ }
+
+
+ private HashMap convertToHashMap(Map extensions) {
+ HashMap converted = null;
+ if(extensions != null) {
+ converted= Maps.newHashMap();
+ converted.putAll(extensions);
+ }
+ return converted;
+ }
+}
Added:
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsMediaLink.java
URL:
http://svn.apache.org/viewvc/rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsMediaLink.java?rev=1478375&view=auto
==============================================================================
---
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsMediaLink.java
(added)
+++
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsMediaLink.java
Thu May 2 14:07:15 2013
@@ -0,0 +1,52 @@
+/*
+ * 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.rave.portal.model;
+
+
+import com.google.common.collect.Maps;
+import org.apache.rave.portal.model.impl.ActivityStreamsMediaLinkImpl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MongoDbActivityStreamsMediaLink extends
ActivityStreamsMediaLinkImpl {
+
+ private HashMap openSocial;
+
+ @Override
+ public HashMap getOpenSocial() {
+ return openSocial;
+ }
+
+ @Override
+ public void setOpenSocial(Map openSocial) {
+ this.openSocial = convertToHashMap(openSocial);
+ }
+
+
+ private HashMap convertToHashMap(Map extensions) {
+ HashMap converted = null;
+ if(extensions != null) {
+ converted= Maps.newHashMap();
+ converted.putAll(extensions);
+ }
+ return converted;
+ }
+}
Added:
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsObject.java
URL:
http://svn.apache.org/viewvc/rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsObject.java?rev=1478375&view=auto
==============================================================================
---
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsObject.java
(added)
+++
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/MongoDbActivityStreamsObject.java
Thu May 2 14:07:15 2013
@@ -0,0 +1,62 @@
+/*
+ * 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.rave.portal.model;
+
+
+import com.google.common.collect.Maps;
+import org.apache.rave.portal.model.impl.ActivityStreamsObjectImpl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MongoDbActivityStreamsObject extends ActivityStreamsObjectImpl {
+
+ private HashMap openSocial;
+ private HashMap extensions;
+
+ @Override
+ public HashMap getOpenSocial() {
+ return openSocial;
+ }
+
+ @Override
+ public HashMap getExtensions() {
+ return extensions;
+ }
+
+ @Override
+ public void setOpenSocial(Map openSocial) {
+ this.openSocial = convertToHashMap(openSocial);
+ }
+
+ @Override
+ public void setExtensions(Map extensions) {
+ this.extensions = convertToHashMap(extensions);
+ }
+
+ private HashMap convertToHashMap(Map extensions) {
+ HashMap converted = null;
+ if(extensions != null) {
+ converted= Maps.newHashMap();
+ converted.putAll(extensions);
+ }
+ return converted;
+ }
+}
Modified:
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/conversion/impl/MongoDbActivityStreamsEntryConverter.java
URL:
http://svn.apache.org/viewvc/rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/conversion/impl/MongoDbActivityStreamsEntryConverter.java?rev=1478375&r1=1478374&r2=1478375&view=diff
==============================================================================
---
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/conversion/impl/MongoDbActivityStreamsEntryConverter.java
(original)
+++
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/model/conversion/impl/MongoDbActivityStreamsEntryConverter.java
Thu May 2 14:07:15 2013
@@ -20,26 +20,25 @@
package org.apache.rave.portal.model.conversion.impl;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import org.apache.rave.model.ActivityStreamsEntry;
import org.apache.rave.model.ActivityStreamsMediaLink;
import org.apache.rave.model.ActivityStreamsObject;
+import org.apache.rave.portal.model.MongoDbActivityStreamsEntry;
+import org.apache.rave.portal.model.MongoDbActivityStreamsMediaLink;
+import org.apache.rave.portal.model.MongoDbActivityStreamsObject;
import org.apache.rave.portal.model.conversion.HydratingModelConverter;
-import org.apache.rave.portal.model.impl.ActivityStreamsEntryImpl;
-import org.apache.rave.portal.model.impl.ActivityStreamsMediaLinkImpl;
import org.apache.rave.portal.model.impl.ActivityStreamsObjectImpl;
import org.springframework.stereotype.Component;
import java.util.List;
-import java.util.Map;
import static org.apache.rave.portal.model.util.MongoDbModelUtil.generateId;
@Component
-public class MongoDbActivityStreamsEntryConverter implements
HydratingModelConverter<ActivityStreamsEntry, ActivityStreamsEntryImpl> {
+public class MongoDbActivityStreamsEntryConverter implements
HydratingModelConverter<ActivityStreamsEntry, MongoDbActivityStreamsEntry> {
@Override
- public void hydrate(ActivityStreamsEntryImpl dehydrated) {
+ public void hydrate(MongoDbActivityStreamsEntry dehydrated) {
}
@Override
@@ -48,9 +47,9 @@ public class MongoDbActivityStreamsEntry
}
@Override
- public ActivityStreamsEntryImpl convert(ActivityStreamsEntry source) {
+ public MongoDbActivityStreamsEntry convert(ActivityStreamsEntry source) {
if (source != null) {
- ActivityStreamsEntryImpl converted = new
ActivityStreamsEntryImpl();
+ MongoDbActivityStreamsEntry converted = new
MongoDbActivityStreamsEntry();
converted.setActor(convert(source.getActor()));
converted.setObject(convert(source.getObject()));
converted.setGenerator(convert(source.getGenerator()));
@@ -67,13 +66,13 @@ public class MongoDbActivityStreamsEntry
private ActivityStreamsMediaLink convert(ActivityStreamsMediaLink source) {
if (source != null) {
- ActivityStreamsMediaLink converted = new
ActivityStreamsMediaLinkImpl();
+ MongoDbActivityStreamsMediaLink converted = new
MongoDbActivityStreamsMediaLink();
converted.setId(source.getId() == null ? generateId() :
source.getId());
converted.setDuration(source.getDuration());
converted.setHeight(source.getHeight());
converted.setWidth(source.getWidth());
converted.setUrl(source.getUrl());
- converted.setOpenSocial(getConvertedMap(source.getOpenSocial()));
+ converted.setOpenSocial(source.getOpenSocial());
return converted;
}
return null;
@@ -81,7 +80,7 @@ public class MongoDbActivityStreamsEntry
public ActivityStreamsObject convert(ActivityStreamsObject source) {
if (source != null) {
- ActivityStreamsObjectImpl converted = new
ActivityStreamsObjectImpl();
+ MongoDbActivityStreamsObject converted = new
MongoDbActivityStreamsObject();
converted.setAuthor(convert(source.getAuthor()));
converted.setAttachments(convert(source.getAttachments()));
converted.setImage(convert(source.getImage()));
@@ -103,9 +102,9 @@ public class MongoDbActivityStreamsEntry
private void updateSimpleProperties(ActivityStreamsObject source,
ActivityStreamsObjectImpl converted) {
converted.setId(source.getId() == null ? generateId() :
source.getId());
- converted.setOpenSocial(getConvertedMap(source.getOpenSocial()));
+ converted.setOpenSocial(source.getOpenSocial());
converted.setObjectType(source.getObjectType());
- converted.setExtensions(getConvertedMap(source.getExtensions()));
+ converted.setExtensions(source.getExtensions());
converted.setDisplayName(source.getDisplayName());
converted.setAlias(source.getAlias());
converted.setAttendedBy(source.getAttendedBy());
@@ -145,9 +144,9 @@ public class MongoDbActivityStreamsEntry
private void updateSimpleProperties(ActivityStreamsEntry source,
ActivityStreamsEntry converted) {
converted.setId(source.getId() == null ? generateId() :
source.getId());
- converted.setOpenSocial(getConvertedMap(source.getOpenSocial()));
+ converted.setOpenSocial(source.getOpenSocial());
converted.setObjectType(source.getObjectType());
- converted.setExtensions(getConvertedMap(source.getExtensions()));
+ converted.setExtensions(source.getExtensions());
converted.setUrl(source.getUrl());
converted.setAppId(source.getAppId());
converted.setBcc(source.getBcc());
@@ -181,14 +180,4 @@ public class MongoDbActivityStreamsEntry
converted.setVerb(source.getVerb());
converted.setUrl(source.getUrl());
}
-
- @SuppressWarnings("unchecked")
- private Map getConvertedMap(Map toConvert) {
- Map converted = null;
- if(toConvert != null) {
- converted= Maps.newHashMap();
- converted.putAll(toConvert);
- }
- return converted;
- }
}
Modified:
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/repository/impl/MongoDbActivityStreamsRepository.java
URL:
http://svn.apache.org/viewvc/rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/repository/impl/MongoDbActivityStreamsRepository.java?rev=1478375&r1=1478374&r2=1478375&view=diff
==============================================================================
---
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/repository/impl/MongoDbActivityStreamsRepository.java
(original)
+++
rave/branches/0.21.1/rave-components/rave-mongodb/src/main/java/org/apache/rave/portal/repository/impl/MongoDbActivityStreamsRepository.java
Thu May 2 14:07:15 2013
@@ -20,6 +20,7 @@
package org.apache.rave.portal.repository.impl;
import org.apache.rave.model.ActivityStreamsEntry;
+import org.apache.rave.portal.model.MongoDbActivityStreamsEntry;
import org.apache.rave.portal.model.conversion.HydratingConverterFactory;
import org.apache.rave.portal.model.impl.ActivityStreamsEntryImpl;
import org.apache.rave.portal.repository.ActivityStreamsRepository;
@@ -39,7 +40,7 @@ import static org.springframework.data.m
*/
@Repository
public class MongoDbActivityStreamsRepository implements
ActivityStreamsRepository {
- private static final Class<? extends ActivityStreamsEntry> CLASS =
ActivityStreamsEntryImpl.class;
+ private static final Class<? extends ActivityStreamsEntry> CLASS =
MongoDbActivityStreamsEntry.class;
private final MongoOperations template;
private final HydratingConverterFactory converter;
Modified:
rave/branches/0.21.1/rave-components/rave-mongodb/src/test/java/org/apache/rave/portal/repository/impl/MongoDbActivityStreamsRepositoryTest.java
URL:
http://svn.apache.org/viewvc/rave/branches/0.21.1/rave-components/rave-mongodb/src/test/java/org/apache/rave/portal/repository/impl/MongoDbActivityStreamsRepositoryTest.java?rev=1478375&r1=1478374&r2=1478375&view=diff
==============================================================================
---
rave/branches/0.21.1/rave-components/rave-mongodb/src/test/java/org/apache/rave/portal/repository/impl/MongoDbActivityStreamsRepositoryTest.java
(original)
+++
rave/branches/0.21.1/rave-components/rave-mongodb/src/test/java/org/apache/rave/portal/repository/impl/MongoDbActivityStreamsRepositoryTest.java
Thu May 2 14:07:15 2013
@@ -22,6 +22,7 @@ package org.apache.rave.portal.repositor
import com.google.common.collect.Lists;
import org.apache.rave.model.ActivityStreamsEntry;
+import org.apache.rave.portal.model.MongoDbActivityStreamsEntry;
import org.apache.rave.portal.model.conversion.HydratingConverterFactory;
import org.apache.rave.portal.model.impl.ActivityStreamsEntryImpl;
import org.apache.rave.portal.repository.ActivityStreamsRepository;
@@ -41,6 +42,7 @@ import static org.junit.Assert.assertTha
public class MongoDbActivityStreamsRepositoryTest {
public static final String ID = "1";
+ public static final Class<MongoDbActivityStreamsEntry> ENTITY_CLASS =
MongoDbActivityStreamsEntry.class;
private MongoOperations template;
private HydratingConverterFactory factory;
private ActivityStreamsRepository repository;
@@ -54,8 +56,8 @@ public class MongoDbActivityStreamsRepos
@Test
public void getAll() {
- List<ActivityStreamsEntryImpl> result = Lists.newArrayList();
- expect(template.findAll(eq(ActivityStreamsEntryImpl.class),
eq(ACTIVITIES))).andReturn(result);
+ List<MongoDbActivityStreamsEntry> result = Lists.newArrayList();
+ expect(template.findAll(eq(ENTITY_CLASS),
eq(ACTIVITIES))).andReturn(result);
replay(template);
List<ActivityStreamsEntry> entries = repository.getAll();
@@ -64,8 +66,8 @@ public class MongoDbActivityStreamsRepos
@Test
public void getByUserId() {
- List<ActivityStreamsEntryImpl> result = Lists.newArrayList();
- expect(template.find(Query.query(Criteria.where("actor._id").is(ID)),
ActivityStreamsEntryImpl.class, ACTIVITIES)).andReturn(result);
+ List<MongoDbActivityStreamsEntry> result = Lists.newArrayList();
+ expect(template.find(Query.query(Criteria.where("actor._id").is(ID)),
ENTITY_CLASS, ACTIVITIES)).andReturn(result);
replay(template);
List<ActivityStreamsEntry> entries = repository.getByUserId(ID);
@@ -102,9 +104,9 @@ public class MongoDbActivityStreamsRepos
@Test
public void getById() {
- ActivityStreamsEntryImpl entry = new ActivityStreamsEntryImpl();
+ MongoDbActivityStreamsEntry entry = new MongoDbActivityStreamsEntry();
entry.setId(ID);
- expect(template.findById(ID, ActivityStreamsEntryImpl.class,
ACTIVITIES)).andReturn(entry);
+ expect(template.findById(ID, ENTITY_CLASS,
ACTIVITIES)).andReturn(entry);
replay(template);
ActivityStreamsEntry result = repository.get(ID);