You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2014/01/08 16:25:59 UTC
[43/51] [abbrv] [partial] MARMOTTA-397: Reorganized and renamed
Marmotta Sesame Tools
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndLink.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndLink.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndLink.java
new file mode 100644
index 0000000..f16a3d4
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndLink.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ * Copyright 2011 ROME Team
+ *
+ * Licensed 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 com.sun.syndication.feed.synd;
+
+/**
+ * Represents a link or enclosure associated with entry.
+ * @author Dave Johnson
+ */
+public interface SyndLink {
+ /**
+ * Creates a deep 'bean' clone of the object.
+ * <p>
+ * @return a clone of the object.
+ * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
+ *
+ */
+ public abstract Object clone() throws CloneNotSupportedException;
+
+ /**
+ * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
+ * <p>
+ * @param other he reference object with which to compare.
+ * @return <b>true</b> if 'this' object is equal to the 'other' object.
+ *
+ */
+ @Override
+ public abstract boolean equals(Object other);
+
+ /**
+ * Returns a hashcode value for the object.
+ * <p>
+ * It follows the contract defined by the Object hashCode() method.
+ * <p>
+ * @return the hashcode of the bean object.
+ *
+ */
+ @Override
+ public abstract int hashCode();
+
+ /**
+ * Returns the String representation for the object.
+ * <p>
+ * @return String representation for the object.
+ *
+ */
+ @Override
+ public abstract String toString();
+
+ /**
+ * Returns the link rel.
+ * <p>
+ * @return the link rel, <b>null</b> if none.
+ *
+ */
+ public abstract String getRel();
+
+ /**
+ * Sets the link rel.
+ * <p>
+ * @param rel the link rel,, <b>null</b> if none.
+ *
+ */
+ public abstract void setRel(String rel);
+
+ /**
+ * Returns the link type.
+ * <p>
+ * @return the link type, <b>null</b> if none.
+ *
+ */
+ public abstract String getType();
+
+ /**
+ * Sets the link type.
+ * <p>
+ * @param type the link type, <b>null</b> if none.
+ *
+ */
+ public abstract void setType(String type);
+
+ /**
+ * Returns the link href.
+ * <p>
+ * @return the link href, <b>null</b> if none.
+ *
+ */
+ public abstract String getHref();
+
+ /**
+ * Sets the link href.
+ * <p>
+ * @param href the link href, <b>null</b> if none.
+ *
+ */
+ public abstract void setHref(String href);
+
+ /**
+ * Returns the link title.
+ * <p>
+ * @return the link title, <b>null</b> if none.
+ *
+ */
+ public abstract String getTitle();
+
+ /**
+ * Sets the link title.
+ * <p>
+ * @param title the link title, <b>null</b> if none.
+ *
+ */
+ public abstract void setTitle(String title);
+
+ /**
+ * Returns the hreflang
+ * <p>
+ * @return Returns the hreflang.
+ */
+ public abstract String getHreflang();
+
+ /**
+ * Set the hreflang
+ * <p>
+ * @param hreflang The hreflang to set.
+ */
+ public abstract void setHreflang(String hreflang);
+
+ /**
+ * Returns the length
+ * <p>
+ * @return Returns the length.
+ */
+ public abstract long getLength();
+
+ /**
+ * Set the length
+ * <p>
+ * @param length The length to set.
+ */
+ public abstract void setLength(long length);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndLinkImpl.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndLinkImpl.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndLinkImpl.java
new file mode 100644
index 0000000..8ab5e0e
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndLinkImpl.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ * Copyright 2011 ROME Team
+ *
+ * Licensed 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 com.sun.syndication.feed.synd;
+
+import com.sun.syndication.feed.impl.ObjectBean;
+
+import java.io.Serializable;
+
+/**
+ * Represents a link or an enclosure.
+ * <p>
+ * @author Alejandro Abdelnur
+ * @author Dave Johnson (updated for Atom 1.0)
+ */
+public class SyndLinkImpl implements Cloneable,Serializable, SyndLink {
+
+ private ObjectBean _objBean;
+
+ private String _href;
+ private String _rel;
+ private String _type;
+ private String _hreflang;
+ private String _title;
+ private long _length;
+
+ /**
+ * Default constructor. All properties are set to <b>null</b>.
+ * <p>
+ *
+ */
+ public SyndLinkImpl() {
+ _objBean = new ObjectBean(this.getClass(),this);
+ }
+
+ /**
+ * Creates a deep 'bean' clone of the object.
+ * <p>
+ * @return a clone of the object.
+ * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
+ *
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return _objBean.clone();
+ }
+
+ /**
+ * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
+ * <p>
+ * @param other he reference object with which to compare.
+ * @return <b>true</b> if 'this' object is equal to the 'other' object.
+ *
+ */
+ @Override
+ public boolean equals(Object other) {
+ if(!(other instanceof SyndLinkImpl)){
+ return false;
+ }
+ return _objBean.equals(other);
+ }
+
+ /**
+ * Returns a hashcode value for the object.
+ * <p>
+ * It follows the contract defined by the Object hashCode() method.
+ * <p>
+ * @return the hashcode of the bean object.
+ *
+ */
+ @Override
+ public int hashCode() {
+ return _objBean.hashCode();
+ }
+
+ /**
+ * Returns the String representation for the object.
+ * <p>
+ * @return String representation for the object.
+ *
+ */
+ @Override
+ public String toString() {
+ return _objBean.toString();
+ }
+
+ /**
+ * Returns the link rel.
+ * <p>
+ * @return the link rel, <b>null</b> if none.
+ *
+ */
+ public String getRel() {
+ return _rel;
+ }
+
+ /**
+ * Sets the link rel.
+ * <p>
+ * @param rel the link rel,, <b>null</b> if none.
+ *
+ */
+ public void setRel(String rel) {
+ //TODO add check, ask P@ about the check
+ _rel = rel;
+ }
+
+ /**
+ * Returns the link type.
+ * <p>
+ * @return the link type, <b>null</b> if none.
+ *
+ */
+ public String getType() {
+ return _type;
+ }
+
+ /**
+ * Sets the link type.
+ * <p>
+ * @param type the link type, <b>null</b> if none.
+ *
+ */
+ public void setType(String type) {
+ _type = type;
+ }
+
+ /**
+ * Returns the link href.
+ * <p>
+ * @return the link href, <b>null</b> if none.
+ *
+ */
+ public String getHref() {
+ return _href;
+ }
+
+ /**
+ * Sets the link href.
+ * <p>
+ * @param href the link href, <b>null</b> if none.
+ *
+ */
+ public void setHref(String href) {
+ _href = href;
+ }
+
+ /**
+ * Returns the link title.
+ * <p>
+ * @return the link title, <b>null</b> if none.
+ *
+ */
+ public String getTitle() {
+ return _title;
+ }
+
+ /**
+ * Sets the link title.
+ * <p>
+ * @param title the link title, <b>null</b> if none.
+ *
+ */
+ public void setTitle(String title) {
+ _title = title;
+ }
+
+ /**
+ * Returns the hreflang
+ * <p>
+ * @return Returns the hreflang.
+ */
+ public String getHreflang() {
+ return _hreflang;
+ }
+
+ /**
+ * Set the hreflang
+ * <p>
+ * @param hreflang The hreflang to set.
+ */
+ public void setHreflang(String hreflang) {
+ _hreflang = hreflang;
+ }
+
+ /**
+ * Returns the length
+ * <p>
+ * @return Returns the length.
+ */
+ public long getLength() {
+ return _length;
+ }
+
+ /**
+ * Set the length
+ * <p>
+ * @param length The length to set.
+ */
+ public void setLength(long length) {
+ _length = length;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndPerson.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndPerson.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndPerson.java
new file mode 100644
index 0000000..8b22b79
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndPerson.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ * Copyright 2011 The ROME Team
+ *
+ * Licensed 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 com.sun.syndication.feed.synd;
+
+import com.sun.syndication.feed.module.Extendable;
+
+/**
+ * Bean interface for authors and contributors of SyndFeedImpl feeds and entries.
+ * <p>
+ * @author Dave Johnson
+ *
+ */
+public interface SyndPerson extends Cloneable, Extendable
+{
+
+ /**
+ * Returns name of person
+ */
+ public String getName();
+
+ /**
+ * Sets name of person.
+ */
+ public void setName(String name);
+
+ /**
+ * Returns URI of person.
+ */
+ public String getUri();
+
+ /**
+ * Sets URI of person.
+ */
+ public void setUri(String uri);
+
+ /**
+ * Returns email of person.
+ */
+ public String getEmail();
+
+ /**
+ * Sets email of person.
+ */
+ public void setEmail(String email);
+
+
+ /**
+ * Creates a deep clone of the object.
+ * <p>
+ * @return a clone of the object.
+ * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
+ *
+ */
+ public Object clone() throws CloneNotSupportedException;
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndPersonImpl.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndPersonImpl.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndPersonImpl.java
new file mode 100644
index 0000000..c6c7989
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/SyndPersonImpl.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ * Copyright 2011 The ROME Team
+ *
+ * Licensed 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 com.sun.syndication.feed.synd;
+
+import com.sun.syndication.feed.impl.ObjectBean;
+import com.sun.syndication.feed.module.Module;
+import com.sun.syndication.feed.module.impl.ModuleUtils;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.io.Serializable;
+
+/**
+ * Bean for authors and contributors of SyndFeedImpl feeds and entries.
+ * <p>
+ * @author Dave Johnson
+ *
+ */
+public class SyndPersonImpl implements Serializable, SyndPerson {
+ private ObjectBean _objBean;
+ private String _name;
+ private String _uri;
+ private String _email;
+ private List _modules;
+
+ /**
+ * For implementations extending SyndContentImpl to be able to use the ObjectBean functionality
+ * with extended interfaces.
+ */
+ public SyndPersonImpl() {
+ _objBean = new ObjectBean(SyndPerson.class,this);
+ }
+
+ /**
+ * Creates a deep 'bean' clone of the object.
+ * <p>
+ * @return a clone of the object.
+ * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
+ *
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return _objBean.clone();
+ }
+
+ /**
+ * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
+ * <p>
+ * @param other he reference object with which to compare.
+ * @return <b>true</b> if 'this' object is equal to the 'other' object.
+ *
+ */
+ @Override
+ public boolean equals(Object other) {
+ if(!(other instanceof SyndPersonImpl)){
+ return false;
+ }
+ return _objBean.equals(other);
+ }
+
+ /**
+ * Returns a hashcode value for the object.
+ * <p>
+ * It follows the contract defined by the Object hashCode() method.
+ * <p>
+ * @return the hashcode of the bean object.
+ *
+ */
+ @Override
+ public int hashCode() {
+ return _objBean.hashCode();
+ }
+
+ /**
+ * Returns the String representation for the object.
+ * <p>
+ * @return String representation for the object.
+ *
+ */
+ @Override
+ public String toString() {
+ return _objBean.toString();
+ }
+
+ /**
+ * Returns the person name.
+ * <p>
+ * @return the person name, <b>null</b> if none.
+ *
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * Sets the category name.
+ * <p>
+ * @param name the category name to set, <b>null</b> if none.
+ *
+ */
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /**
+ * Returns the person's e-mail address.
+ * <p>
+ * @return the person's e-mail address, <b>null</b> if none.
+ *
+ */
+ public String getEmail() {
+ return _email;
+ }
+
+ /**
+ * Sets the person's e-mail address.
+ * <p>
+ * @param email The person's e-mail address to set, <b>null</b> if none.
+ *
+ */
+ public void setEmail(String email) {
+ _email = email;
+ }
+
+ /**
+ * Returns the person's URI.
+ * <p>
+ * @return the person's URI, <b>null</b> if none.
+ *
+ */
+ public String getUri() {
+ return _uri;
+ }
+
+ /**
+ * Sets the person's URI.
+ * <p>
+ * @param uri the peron's URI to set, <b>null</b> if none.
+ *
+ */
+ public void setUri(String uri) {
+ _uri = uri;
+ }
+
+ /**
+ * Returns the person modules.
+ * <p>
+ * @return a list of ModuleImpl elements with the person modules,
+ * an empty list if none.
+ */
+ public List getModules()
+ {
+ if (_modules==null) {
+ _modules=new ArrayList();
+ }
+ return _modules;
+ }
+
+ /**
+ * Sets the person modules.
+ * <p>
+ * @param modules the list of ModuleImpl elements with the person modules to set,
+ * an empty list or <b>null</b> if none.
+ *
+ */
+ public void setModules(List modules) {
+ _modules = modules;
+ }
+
+ /**
+ * Returns the module identified by a given URI.
+ * <p>
+ * @param uri the URI of the ModuleImpl.
+ * @return The module with the given URI, <b>null</b> if none.
+ */
+ public Module getModule(String uri) {
+ return ModuleUtils.getModule(getModules(),uri);
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java
new file mode 100644
index 0000000..74dd500
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForAtom03.java
@@ -0,0 +1,502 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ * Copyright 2011 The ROME Team
+ *
+ * Licensed 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 com.sun.syndication.feed.synd.impl;
+
+import com.sun.syndication.feed.WireFeed;
+import com.sun.syndication.feed.atom.Content;
+import com.sun.syndication.feed.atom.Entry;
+import com.sun.syndication.feed.atom.Feed;
+import com.sun.syndication.feed.atom.Link;
+import com.sun.syndication.feed.atom.Person;
+import com.sun.syndication.feed.module.impl.ModuleUtils;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.Converter;
+import com.sun.syndication.feed.synd.SyndEnclosure;
+import com.sun.syndication.feed.synd.SyndEnclosureImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndContentImpl;
+import com.sun.syndication.feed.synd.SyndEntryImpl;
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndLink;
+import com.sun.syndication.feed.synd.SyndLinkImpl;
+import com.sun.syndication.feed.synd.SyndPerson;
+import com.sun.syndication.feed.synd.SyndPersonImpl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Date;
+import java.util.Iterator;
+
+/**
+ */
+public class ConverterForAtom03 implements Converter {
+ private String _type;
+
+ public ConverterForAtom03() {
+ this("atom_0.3");
+ }
+
+ protected ConverterForAtom03(String type) {
+ _type = type;
+ }
+
+ public String getType() {
+ return _type;
+ }
+
+ public void copyInto(WireFeed feed,SyndFeed syndFeed) {
+ Feed aFeed = (Feed) feed;
+
+ syndFeed.setModules(ModuleUtils.cloneModules(aFeed.getModules()));
+
+ if (((List)feed.getForeignMarkup()).size() > 0) {
+ syndFeed.setForeignMarkup(feed.getForeignMarkup());
+ }
+
+ syndFeed.setEncoding(aFeed.getEncoding());
+
+ syndFeed.setUri(aFeed.getId());
+
+ syndFeed.setTitle(aFeed.getTitle());
+
+ // use first alternate links as THE link
+ if (aFeed.getAlternateLinks() != null
+ && aFeed.getAlternateLinks().size() > 0) {
+ Link theLink = (Link)aFeed.getAlternateLinks().get(0);
+ syndFeed.setLink(theLink.getHrefResolved());
+ }
+ // lump alternate and other links together
+ List syndLinks = new ArrayList();
+ if (aFeed.getAlternateLinks() != null
+ && aFeed.getAlternateLinks().size() > 0) {
+ syndLinks.addAll(createSyndLinks(aFeed.getAlternateLinks()));
+ }
+ if (aFeed.getOtherLinks() != null
+ && aFeed.getOtherLinks().size() > 0) {
+ syndLinks.addAll(createSyndLinks(aFeed.getOtherLinks()));
+ }
+ syndFeed.setLinks(syndLinks);
+
+ Content tagline = aFeed.getTagline();
+ if (tagline!=null) {
+ syndFeed.setDescription(tagline.getValue());
+ }
+
+
+ List aEntries = aFeed.getEntries();
+ if (aEntries!=null) {
+ syndFeed.setEntries(createSyndEntries(aEntries, syndFeed.isPreservingWireFeed()));
+ }
+
+ // Core Atom language/author/copyright/modified elements have precedence
+ // over DC equivalent info.
+
+ String language = aFeed.getLanguage();
+ if (language!=null) {
+ syndFeed.setLanguage(language);
+ }
+
+ List authors = aFeed.getAuthors();
+ if (authors!=null && authors.size() > 0) {
+ syndFeed.setAuthors(createSyndPersons(authors));
+ }
+
+ String copyright = aFeed.getCopyright();
+ if (copyright!=null) {
+ syndFeed.setCopyright(copyright);
+ }
+
+ Date date = aFeed.getModified();
+ if (date!=null) {
+ syndFeed.setPublishedDate(date);
+ }
+
+ }
+
+ protected List createSyndLinks(List aLinks) {
+ ArrayList sLinks = new ArrayList();
+ for (Iterator iter = aLinks.iterator(); iter.hasNext();) {
+ Link link = (Link)iter.next();
+ if (!link.getRel().equals("enclosure")) {
+ SyndLink sLink = createSyndLink(link);
+ sLinks.add(sLink);
+ }
+ }
+ return sLinks;
+ }
+
+ public SyndLink createSyndLink(Link link) {
+ SyndLink syndLink = new SyndLinkImpl();
+ syndLink.setRel( link.getRel());
+ syndLink.setType( link.getType());
+ syndLink.setHref( link.getHrefResolved());
+ syndLink.setTitle( link.getTitle());
+ return syndLink;
+ }
+
+ protected List createSyndEntries(List atomEntries, boolean preserveWireItems) {
+ List syndEntries = new ArrayList();
+ for (int i=0;i<atomEntries.size();i++) {
+ syndEntries.add(createSyndEntry((Entry) atomEntries.get(i), preserveWireItems));
+ }
+ return syndEntries;
+ }
+
+ protected SyndEntry createSyndEntry(Entry entry, boolean preserveWireItem) {
+ SyndEntryImpl syndEntry = new SyndEntryImpl();
+ if (preserveWireItem) {
+ syndEntry.setWireEntry(entry);
+ }
+
+ syndEntry.setModules(ModuleUtils.cloneModules(entry.getModules()));
+
+ if (((List)entry.getForeignMarkup()).size() > 0) {
+ syndEntry.setForeignMarkup((List)entry.getForeignMarkup());
+ }
+
+ syndEntry.setTitle(entry.getTitle());
+
+ // if there is exactly one alternate link, use that as THE link
+ if (entry.getAlternateLinks() != null
+ && entry.getAlternateLinks().size() == 1) {
+ Link theLink = (Link)entry.getAlternateLinks().get(0);
+ syndEntry.setLink(theLink.getHrefResolved());
+ }
+
+ // Create synd enclosures from enclosure links
+ List syndEnclosures = new ArrayList();
+ if (entry.getOtherLinks() != null && entry.getOtherLinks().size() > 0) {
+ List oLinks = entry.getOtherLinks();
+ for (Iterator iter = oLinks.iterator(); iter.hasNext(); ) {
+ Link thisLink = (Link)iter.next();
+ if ("enclosure".equals(thisLink.getRel()))
+ syndEnclosures.add(createSyndEnclosure(entry, thisLink));
+ }
+ }
+ syndEntry.setEnclosures(syndEnclosures);
+
+ // lump alternate and other links together
+ List syndLinks = new ArrayList();
+ if (entry.getAlternateLinks() != null
+ && entry.getAlternateLinks().size() > 0) {
+ syndLinks.addAll(createSyndLinks(entry.getAlternateLinks()));
+ }
+ if (entry.getOtherLinks() != null
+ && entry.getOtherLinks().size() > 0) {
+ syndLinks.addAll(createSyndLinks(entry.getOtherLinks()));
+ }
+ syndEntry.setLinks(syndLinks);
+
+
+ String id = entry.getId();
+ if (id!=null) {
+ syndEntry.setUri(entry.getId());
+ }
+ else {
+ syndEntry.setUri(syndEntry.getLink());
+ }
+
+ Content content = entry.getSummary();
+ if (content==null) {
+ List contents = entry.getContents();
+ if (contents!=null && contents.size()>0) {
+ content = (Content) contents.get(0);
+ }
+ }
+ if (content!=null) {
+ SyndContent sContent = new SyndContentImpl();
+ sContent.setType(content.getType());
+ sContent.setValue(content.getValue());
+ syndEntry.setDescription(sContent);
+ }
+
+ List contents = entry.getContents();
+ if (contents.size()>0) {
+ List sContents = new ArrayList();
+ for (int i=0;i<contents.size();i++) {
+ content = (Content) contents.get(i);
+ SyndContent sContent = new SyndContentImpl();
+ sContent.setType(content.getType());
+ sContent.setValue(content.getValue());
+ sContent.setMode(content.getMode());
+ sContents.add(sContent);
+ }
+ syndEntry.setContents(sContents);
+ }
+
+ List authors = entry.getAuthors();
+ if (authors!=null && authors.size() > 0) {
+ syndEntry.setAuthors(createSyndPersons(authors));
+ SyndPerson person0 = (SyndPerson)syndEntry.getAuthors().get(0);
+ syndEntry.setAuthor(person0.getName());
+ }
+
+ Date date = entry.getModified();
+ if (date==null) {
+ date = entry.getIssued();
+ if (date==null) {
+ date = entry.getCreated();
+ }
+ }
+ if (date!=null) {
+ syndEntry.setPublishedDate(date);
+ }
+
+ return syndEntry;
+ }
+
+ public SyndEnclosure createSyndEnclosure(Entry entry, Link link) {
+ SyndEnclosure syndEncl = new SyndEnclosureImpl();
+ syndEncl.setUrl(link.getHrefResolved());
+ syndEncl.setType(link.getType());
+ syndEncl.setLength(link.getLength());
+ return syndEncl;
+ }
+
+ public WireFeed createRealFeed(SyndFeed syndFeed) {
+ Feed aFeed = new Feed(getType());
+ aFeed.setModules(ModuleUtils.cloneModules(syndFeed.getModules()));
+
+ aFeed.setEncoding(syndFeed.getEncoding());
+
+ aFeed.setId(syndFeed.getUri());
+
+ SyndContent sTitle = syndFeed.getTitleEx();
+ if (sTitle != null) {
+ Content title = new Content();
+ if (sTitle.getType() != null) {
+ title.setType(sTitle.getType());
+ }
+
+ if (sTitle.getMode() != null) {
+ title.setMode(sTitle.getMode());
+ }
+
+ title.setValue(sTitle.getValue());
+ aFeed.setTitleEx(title);
+ }
+
+ // separate SyndEntry's links collection into alternate and other links
+ List alternateLinks = new ArrayList();
+ List otherLinks = new ArrayList();
+ List slinks = syndFeed.getLinks();
+ if (slinks != null) {
+ for (Iterator iter=slinks.iterator(); iter.hasNext();) {
+ SyndLink syndLink = (SyndLink)iter.next();
+ Link link = createAtomLink(syndLink);
+ if (link.getRel() == null ||
+ "".equals(link.getRel().trim()) ||
+ "alternate".equals(link.getRel())) {
+ alternateLinks.add(link);
+ } else {
+ otherLinks.add(link);
+ }
+ }
+ }
+ // no alternate link? then use THE link if there is one
+ if (alternateLinks.isEmpty() && syndFeed.getLink() != null) {
+ Link link = new Link();
+ link.setRel("alternate");
+ link.setHref(syndFeed.getLink());
+ alternateLinks.add(link);
+ }
+
+ if (alternateLinks.size() > 0) aFeed.setAlternateLinks(alternateLinks);
+ if (otherLinks.size() > 0) aFeed.setOtherLinks(otherLinks);
+
+ String sDesc = syndFeed.getDescription();
+ if (sDesc!=null) {
+ Content tagline = new Content();
+ tagline.setValue(sDesc);
+ aFeed.setTagline(tagline);
+ }
+
+ aFeed.setLanguage(syndFeed.getLanguage());
+
+ List authors = syndFeed.getAuthors();
+ if (authors!=null && authors.size() > 0) {
+ aFeed.setAuthors(createAtomPersons(authors));
+ }
+
+ aFeed.setCopyright(syndFeed.getCopyright());
+
+ aFeed.setModified(syndFeed.getPublishedDate());
+
+ List sEntries = syndFeed.getEntries();
+ if (sEntries!=null) {
+ aFeed.setEntries(createAtomEntries(sEntries));
+ }
+
+ return aFeed;
+ }
+
+ protected static List createAtomPersons(List sPersons) {
+ List persons = new ArrayList();
+ for (Iterator iter = sPersons.iterator(); iter.hasNext(); ) {
+ SyndPerson sPerson = (SyndPerson)iter.next();
+ Person person = new Person();
+ person.setName(sPerson.getName());
+ person.setUri(sPerson.getUri());
+ person.setEmail(sPerson.getEmail());
+ person.setModules(sPerson.getModules());
+ persons.add(person);
+ }
+ return persons;
+ }
+
+ protected static List createSyndPersons(List aPersons) {
+ List persons = new ArrayList();
+ for (Iterator iter = aPersons.iterator(); iter.hasNext(); ) {
+ Person aPerson = (Person)iter.next();
+ SyndPerson person = new SyndPersonImpl();
+ person.setName(aPerson.getName());
+ person.setUri(aPerson.getUri());
+ person.setEmail(aPerson.getEmail());
+ person.setModules(aPerson.getModules());
+ persons.add(person);
+ }
+ return persons;
+ }
+
+ protected List createAtomEntries(List syndEntries) {
+ List atomEntries = new ArrayList();
+ for (int i=0;i<syndEntries.size();i++) {
+ atomEntries.add(createAtomEntry((SyndEntry)syndEntries.get(i)));
+ }
+ return atomEntries;
+ }
+
+ protected Entry createAtomEntry(SyndEntry sEntry) {
+ Entry aEntry = new Entry();
+ aEntry.setModules(ModuleUtils.cloneModules(sEntry.getModules()));
+
+ aEntry.setId(sEntry.getUri());
+
+ SyndContent sTitle = sEntry.getTitleEx();
+ if (sTitle!=null) {
+ Content title = new Content();
+ if (sTitle.getType() != null) {
+ title.setType(sTitle.getType());
+ }
+
+ if (sTitle.getMode() != null) {
+ title.setMode(sTitle.getMode());
+ }
+
+ title.setValue(sTitle.getValue());
+ aEntry.setTitleEx(title);
+ }
+
+ // separate SyndEntry's links collection into alternate and other links
+ List alternateLinks = new ArrayList();
+ List otherLinks = new ArrayList();
+ List slinks = sEntry.getLinks();
+ if (slinks != null) {
+ for (Iterator iter=slinks.iterator(); iter.hasNext();) {
+ SyndLink syndLink = (SyndLink)iter.next();
+ Link link = createAtomLink(syndLink);
+ if (link.getRel() == null ||
+ "".equals(link.getRel().trim()) ||
+ "alternate".equals(link.getRel())) {
+ alternateLinks.add(link);
+ } else {
+ otherLinks.add(link);
+ }
+ }
+ }
+ // no alternate link? then use THE link if there is one
+ if (alternateLinks.isEmpty() && sEntry.getLink() != null) {
+ Link link = new Link();
+ link.setRel("alternate");
+ link.setHref(sEntry.getLink());
+ alternateLinks.add(link);
+ }
+
+ List sEnclosures = sEntry.getEnclosures();
+ if (sEnclosures != null) {
+ for (Iterator iter=sEnclosures.iterator(); iter.hasNext();) {
+ SyndEnclosure syndEnclosure = (SyndEnclosure) iter.next();
+ Link link = createAtomEnclosure(syndEnclosure);
+ otherLinks.add(link);
+ }
+ }
+
+ if (alternateLinks.size() > 0) aEntry.setAlternateLinks(alternateLinks);
+ if (otherLinks.size() > 0) aEntry.setOtherLinks(otherLinks);
+
+
+ SyndContent sContent = sEntry.getDescription();
+ if (sContent!=null) {
+ Content content = new Content();
+ content.setType(sContent.getType());
+ content.setValue(sContent.getValue());
+ content.setMode(Content.ESCAPED);
+ aEntry.setSummary(content);
+ }
+
+ List contents = sEntry.getContents();
+ if (contents.size()>0) {
+ List aContents = new ArrayList();
+ for (int i=0;i<contents.size();i++) {
+ sContent = (SyndContentImpl) contents.get(i);
+ Content content = new Content();
+ content.setType(sContent.getType());
+ content.setValue(sContent.getValue());
+ content.setMode(sContent.getMode());
+ aContents.add(content);
+
+ }
+ aEntry.setContents(aContents);
+ }
+
+ List sAuthors = sEntry.getAuthors();
+ if (sAuthors!=null && sAuthors.size() > 0) {
+ aEntry.setAuthors(createAtomPersons(sAuthors));
+ } else if (sEntry.getAuthor() != null) {
+ Person person = new Person();
+ person.setName(sEntry.getAuthor());
+ List authors = new ArrayList();
+ authors.add(person);
+ aEntry.setAuthors(authors);
+ }
+
+ aEntry.setModified(sEntry.getPublishedDate());
+ aEntry.setIssued(sEntry.getPublishedDate());
+
+ return aEntry;
+ }
+
+ public Link createAtomLink(SyndLink syndLink) {
+ Link link = new Link();
+ link.setRel( syndLink.getRel());
+ link.setType( syndLink.getType());
+ link.setHref( syndLink.getHref());
+ link.setTitle( syndLink.getTitle());
+ return link;
+ }
+
+ public Link createAtomEnclosure(SyndEnclosure syndEnclosure) {
+ Link link = new Link();
+ link.setRel( "enclosure");
+ link.setType( syndEnclosure.getType());
+ link.setHref( syndEnclosure.getUrl());
+ link.setLength( syndEnclosure.getLength());
+ return link;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForAtom10.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForAtom10.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForAtom10.java
new file mode 100644
index 0000000..8f9a6b3
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForAtom10.java
@@ -0,0 +1,562 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * Licensed 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 com.sun.syndication.feed.synd.impl;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import com.sun.syndication.feed.WireFeed;
+import com.sun.syndication.feed.atom.Category;
+import com.sun.syndication.feed.atom.Content;
+import com.sun.syndication.feed.atom.Entry;
+import com.sun.syndication.feed.atom.Feed;
+import com.sun.syndication.feed.atom.Link;
+import com.sun.syndication.feed.atom.Person;
+import com.sun.syndication.feed.module.impl.ModuleUtils;
+import com.sun.syndication.feed.synd.Converter;
+import com.sun.syndication.feed.synd.SyndCategory;
+import com.sun.syndication.feed.synd.SyndCategoryImpl;
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndContentImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndEntryImpl;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.feed.synd.SyndLink;
+import com.sun.syndication.feed.synd.SyndLinkImpl;
+import com.sun.syndication.feed.synd.SyndPerson;
+import com.sun.syndication.feed.synd.SyndEnclosure;
+import com.sun.syndication.feed.synd.SyndEnclosureImpl;
+
+
+/**
+ */
+public class ConverterForAtom10 implements Converter {
+ private String _type;
+
+ public ConverterForAtom10() {
+ this("atom_1.0");
+ }
+
+ protected ConverterForAtom10(String type) {
+ _type = type;
+ }
+
+ public String getType() {
+ return _type;
+ }
+
+ public void copyInto(WireFeed feed, SyndFeed syndFeed) {
+ Feed aFeed = (Feed) feed;
+
+ syndFeed.setModules(ModuleUtils.cloneModules(aFeed.getModules()));
+
+ if (((List)feed.getForeignMarkup()).size() > 0) {
+ syndFeed.setForeignMarkup((List)feed.getForeignMarkup());
+ }
+
+ syndFeed.setEncoding(aFeed.getEncoding());
+
+ syndFeed.setUri(aFeed.getId());
+
+ Content aTitle = aFeed.getTitleEx();
+ if (aTitle != null) {
+ SyndContent c = new SyndContentImpl();
+ c.setType(aTitle.getType());
+ c.setValue(aTitle.getValue());
+ syndFeed.setTitleEx(c);
+ }
+
+ Content aSubtitle = aFeed.getSubtitle();
+ if (aSubtitle!=null) {
+ SyndContent c = new SyndContentImpl();
+ c.setType(aSubtitle.getType());
+ c.setValue(aSubtitle.getValue());
+ syndFeed.setDescriptionEx(c);
+ }
+
+ // use first alternate links as THE link
+ if (aFeed.getAlternateLinks() != null
+ && aFeed.getAlternateLinks().size() > 0) {
+ Link theLink = (Link)aFeed.getAlternateLinks().get(0);
+ syndFeed.setLink(theLink.getHrefResolved());
+ }
+ // lump alternate and other links together
+ List syndLinks = new ArrayList();
+ if (aFeed.getAlternateLinks() != null
+ && aFeed.getAlternateLinks().size() > 0) {
+ syndLinks.addAll(createSyndLinks(aFeed.getAlternateLinks()));
+ }
+ if (aFeed.getOtherLinks() != null
+ && aFeed.getOtherLinks().size() > 0) {
+ syndLinks.addAll(createSyndLinks(aFeed.getOtherLinks()));
+ }
+ syndFeed.setLinks(syndLinks);
+
+ List aEntries = aFeed.getEntries();
+ if (aEntries!=null) {
+ syndFeed.setEntries(createSyndEntries(aFeed, aEntries, syndFeed.isPreservingWireFeed()));
+ }
+
+ // Core Atom language/author/copyright/modified elements have precedence
+ // over DC equivalent info.
+
+ List authors = aFeed.getAuthors();
+ if (authors!=null && authors.size() > 0) {
+ syndFeed.setAuthors(ConverterForAtom03.createSyndPersons(authors));
+ }
+
+ List contributors = aFeed.getContributors();
+ if (contributors!=null && contributors.size() > 0) {
+ syndFeed.setContributors(ConverterForAtom03.createSyndPersons(contributors));
+ }
+
+ String rights = aFeed.getRights();
+ if (rights!=null) {
+ syndFeed.setCopyright(rights);
+ }
+
+ Date date = aFeed.getUpdated();
+ if (date!=null) {
+ syndFeed.setPublishedDate(date);
+ }
+
+ }
+
+ protected List createSyndLinks(List aLinks) {
+ ArrayList sLinks = new ArrayList();
+ for (Iterator iter = aLinks.iterator(); iter.hasNext();) {
+ Link link = (Link)iter.next();
+ SyndLink sLink = createSyndLink(link);
+ sLinks.add(sLink);
+ }
+ return sLinks;
+ }
+
+ protected List createSyndEntries(Feed feed, List atomEntries, boolean preserveWireItems) {
+ List syndEntries = new ArrayList();
+ for (int i=0;i<atomEntries.size();i++) {
+ syndEntries.add(createSyndEntry(feed, (Entry) atomEntries.get(i), preserveWireItems));
+ }
+ return syndEntries;
+ }
+
+ protected SyndEntry createSyndEntry(Feed feed, Entry entry, boolean preserveWireItem) {
+ SyndEntryImpl syndEntry = new SyndEntryImpl();
+ if (preserveWireItem) {
+ syndEntry.setWireEntry(entry);
+ }
+ syndEntry.setModules(ModuleUtils.cloneModules(entry.getModules()));
+
+ if (((List)entry.getForeignMarkup()).size() > 0) {
+ syndEntry.setForeignMarkup((List)entry.getForeignMarkup());
+ }
+
+ Content eTitle = entry.getTitleEx();
+ if (eTitle != null) {
+ syndEntry.setTitleEx(createSyndContent(eTitle));
+ }
+
+ Content summary = entry.getSummary();
+ if (summary!=null) {
+ syndEntry.setDescription(createSyndContent(summary));
+ }
+
+ List contents = entry.getContents();
+ if (contents != null && contents.size() > 0) {
+ List sContents = new ArrayList();
+ for (Iterator iter=contents.iterator(); iter.hasNext();) {
+ Content content = (Content)iter.next();
+ sContents.add(createSyndContent(content));
+ }
+ syndEntry.setContents(sContents);
+ }
+
+ List authors = entry.getAuthors();
+ if (authors!=null && authors.size() > 0) {
+ syndEntry.setAuthors(ConverterForAtom03.createSyndPersons(authors));
+ SyndPerson person0 = (SyndPerson)syndEntry.getAuthors().get(0);
+ syndEntry.setAuthor(person0.getName());
+ }
+
+ List contributors = entry.getContributors();
+ if (contributors!=null && contributors.size() > 0) {
+ syndEntry.setContributors(ConverterForAtom03.createSyndPersons(contributors));
+ }
+
+ Date date = entry.getPublished();
+ if (date!=null) {
+ syndEntry.setPublishedDate(date);
+ }
+
+ date = entry.getUpdated();
+ if (date!=null) {
+ syndEntry.setUpdatedDate(date);
+ }
+
+ List categories = entry.getCategories();
+ if (categories!=null) {
+ List syndCategories = new ArrayList();
+ for (Iterator iter=categories.iterator(); iter.hasNext();) {
+ Category c = (Category)iter.next();
+ SyndCategory syndCategory = new SyndCategoryImpl();
+ syndCategory.setName(c.getTerm());
+ syndCategory.setTaxonomyUri(c.getSchemeResolved());
+ // TODO: categories MAY have labels
+ // syndCategory.setLabel(c.getLabel());
+ syndCategories.add(syndCategory);
+ }
+ syndEntry.setCategories(syndCategories);
+ }
+
+ // use first alternate link as THE link
+ if (entry.getAlternateLinks() != null
+ && entry.getAlternateLinks().size() > 0) {
+ Link theLink = (Link)entry.getAlternateLinks().get(0);
+ syndEntry.setLink(theLink.getHrefResolved());
+ }
+
+ // Create synd enclosures from enclosure links
+ List syndEnclosures = new ArrayList();
+ if (entry.getOtherLinks() != null && entry.getOtherLinks().size() > 0) {
+ List oLinks = entry.getOtherLinks();
+ for (Iterator iter = oLinks.iterator(); iter.hasNext(); ) {
+ Link thisLink = (Link)iter.next();
+ if ("enclosure".equals(thisLink.getRel()))
+ syndEnclosures.add(
+ createSyndEnclosure(feed, entry, thisLink));
+ }
+ }
+ syndEntry.setEnclosures(syndEnclosures);
+
+ // lump alternate and other links together
+ List syndLinks = new ArrayList();
+ if (entry.getAlternateLinks() != null
+ && entry.getAlternateLinks().size() > 0) {
+ syndLinks.addAll(createSyndLinks(entry.getAlternateLinks()));
+ }
+ if (entry.getOtherLinks() != null
+ && entry.getOtherLinks().size() > 0) {
+ syndLinks.addAll(createSyndLinks(entry.getOtherLinks()));
+ }
+ syndEntry.setLinks(syndLinks);
+
+ String id = entry.getId();
+ if (id!=null) {
+ syndEntry.setUri(entry.getId());
+ }
+ else {
+ syndEntry.setUri(syndEntry.getLink());
+ }
+
+ // Convert source element Feed into SyndFeed and assign as SyndEntry
+ // source
+ Feed source = entry.getSource();
+ if (source != null) {
+ SyndFeed syndSource = new SyndFeedImpl(source);
+ syndEntry.setSource(syndSource);
+ }
+
+ return syndEntry;
+ }
+
+ public SyndEnclosure createSyndEnclosure(Feed feed, Entry entry,
+ Link link) {
+ SyndEnclosure syndEncl = new SyndEnclosureImpl();
+ syndEncl.setUrl(link.getHrefResolved());
+ syndEncl.setType(link.getType());
+ syndEncl.setLength(link.getLength());
+ return syndEncl;
+ }
+
+ public Link createAtomEnclosure(SyndEnclosure syndEnclosure) {
+ Link link = new Link();
+ link.setRel( "enclosure");
+ link.setType( syndEnclosure.getType());
+ link.setHref( syndEnclosure.getUrl());
+ link.setLength( syndEnclosure.getLength());
+ return link;
+ }
+
+ public SyndLink createSyndLink(Link link) {
+ SyndLink syndLink = new SyndLinkImpl();
+ syndLink.setRel( link.getRel());
+ syndLink.setType( link.getType());
+ syndLink.setHref( link.getHrefResolved());
+ syndLink.setHreflang(link.getHreflang());
+ syndLink.setLength( link.getLength());
+ syndLink.setTitle( link.getTitle());
+ return syndLink;
+ }
+
+ public Link createAtomLink(SyndLink syndLink) {
+ Link link = new Link();
+ link.setRel( syndLink.getRel());
+ link.setType( syndLink.getType());
+ link.setHref( syndLink.getHref());
+ link.setHreflang(syndLink.getHreflang());
+ link.setLength( syndLink.getLength());
+ link.setTitle( syndLink.getTitle());
+ return link;
+ }
+
+ public WireFeed createRealFeed(SyndFeed syndFeed) {
+ Feed aFeed = new Feed(getType());
+ aFeed.setModules(ModuleUtils.cloneModules(syndFeed.getModules()));
+
+ aFeed.setEncoding(syndFeed.getEncoding());
+
+ aFeed.setId(syndFeed.getUri());
+
+ SyndContent sTitle = syndFeed.getTitleEx();
+ if (sTitle != null) {
+ Content title = new Content();
+ title.setType(sTitle.getType());
+ title.setValue(sTitle.getValue());
+ aFeed.setTitleEx(title);
+ }
+
+ SyndContent sDesc = syndFeed.getDescriptionEx();
+ if (sDesc != null) {
+ Content subtitle = new Content();
+ subtitle.setType(sDesc.getType());
+ subtitle.setValue(sDesc.getValue());
+ aFeed.setSubtitle(subtitle);
+ }
+
+ // separate SyndEntry's links collection into alternate and other links
+ List alternateLinks = new ArrayList();
+ List otherLinks = new ArrayList();
+ List slinks = syndFeed.getLinks();
+ if (slinks != null) {
+ for (Iterator iter=slinks.iterator(); iter.hasNext();) {
+ SyndLink syndLink = (SyndLink)iter.next();
+ Link link = createAtomLink(syndLink);
+ if (link.getRel() == null ||
+ "".equals(link.getRel().trim()) ||
+ "alternate".equals(link.getRel())) {
+ alternateLinks.add(link);
+ } else {
+ otherLinks.add(link);
+ }
+ }
+ }
+ // no alternate link? then use THE link if there is one
+ if (alternateLinks.isEmpty() && syndFeed.getLink() != null) {
+ Link link = new Link();
+ link.setRel("alternate");
+ link.setHref(syndFeed.getLink());
+ alternateLinks.add(link);
+ }
+ if (alternateLinks.size() > 0) aFeed.setAlternateLinks(alternateLinks);
+ if (otherLinks.size() > 0) aFeed.setOtherLinks(otherLinks);
+
+ List sCats = syndFeed.getCategories();
+ List aCats = new ArrayList();
+ if (sCats != null) {
+ for (Iterator iter=sCats.iterator(); iter.hasNext();) {
+ SyndCategory sCat = (SyndCategory)iter.next();
+ Category aCat = new Category();
+ aCat.setTerm(sCat.getName());
+ // TODO: aCat.setLabel(sCat.getLabel());
+ aCat.setScheme(sCat.getTaxonomyUri());
+ aCats.add(aCat);
+ }
+ }
+ if (aCats.size() > 0) aFeed.setCategories(aCats);
+
+ List authors = syndFeed.getAuthors();
+ if (authors!=null && authors.size() > 0) {
+ aFeed.setAuthors(ConverterForAtom03.createAtomPersons(authors));
+ }
+
+ List contributors = syndFeed.getContributors();
+ if (contributors!=null && contributors.size() > 0) {
+ aFeed.setContributors(ConverterForAtom03.createAtomPersons(contributors));
+ }
+
+ aFeed.setRights(syndFeed.getCopyright());
+
+ aFeed.setUpdated(syndFeed.getPublishedDate());
+
+ List sEntries = syndFeed.getEntries();
+ if (sEntries!=null) {
+ aFeed.setEntries(createAtomEntries(sEntries));
+ }
+
+ if (((List)syndFeed.getForeignMarkup()).size() > 0) {
+ aFeed.setForeignMarkup(syndFeed.getForeignMarkup());
+ }
+ return aFeed;
+ }
+
+ protected SyndContent createSyndContent(Content content) {
+ SyndContent sContent = new SyndContentImpl();
+ sContent.setType(content.getType());
+ sContent.setValue(content.getValue());
+ return sContent;
+ }
+
+ protected List createAtomEntries(List syndEntries) {
+ List atomEntries = new ArrayList();
+ for (int i=0;i<syndEntries.size();i++) {
+ atomEntries.add(createAtomEntry((SyndEntry)syndEntries.get(i)));
+ }
+ return atomEntries;
+ }
+
+ protected Content createAtomContent(SyndContent sContent) {
+ Content content = new Content();
+ content.setType(sContent.getType());
+ content.setValue(sContent.getValue());
+ return content;
+ }
+
+ protected List createAtomContents(List syndContents) {
+ List atomContents = new ArrayList();
+ for (int i=0;i<syndContents.size();i++) {
+ atomContents.add(createAtomContent((SyndContent)syndContents.get(i)));
+ }
+ return atomContents;
+ }
+
+ protected Entry createAtomEntry(SyndEntry sEntry) {
+ Entry aEntry = new Entry();
+ aEntry.setModules(ModuleUtils.cloneModules(sEntry.getModules()));
+
+ aEntry.setId(sEntry.getUri());
+
+ SyndContent sTitle = sEntry.getTitleEx();
+ if (sTitle!=null) {
+ Content title = new Content();
+ title.setType(sTitle.getType());
+ title.setValue(sTitle.getValue());
+ aEntry.setTitleEx(title);
+ }
+
+ SyndContent sDescription = sEntry.getDescription();
+ if (sDescription!=null) {
+ Content summary = new Content();
+ summary.setType(sDescription.getType());
+ summary.setValue(sDescription.getValue());
+ aEntry.setSummary(summary);
+ }
+
+ // separate SyndEntry's links collection into alternate and other links
+ List alternateLinks = new ArrayList();
+ List otherLinks = new ArrayList();
+ List slinks = sEntry.getLinks();
+ List enclosures = sEntry.getEnclosures();
+ boolean linkRelEnclosureExists = false;
+ if (slinks != null) {
+ for (Iterator iter=slinks.iterator(); iter.hasNext();) {
+ SyndLink syndLink = (SyndLink)iter.next();
+ Link link = createAtomLink(syndLink);
+ // Set this flag if there's a link of rel = enclosure so that
+ // enclosures won't be duplicated when pulled from
+ // SyndEntry.getEnclosures()
+ if (syndLink.getRel() != null &&
+ "enclosure".equals(syndLink.getRel())) {
+ linkRelEnclosureExists = true;
+ }
+ if (link.getRel() == null ||
+ "".equals(link.getRel().trim()) ||
+ "alternate".equals(syndLink.getRel())) {
+ alternateLinks.add(link);
+ } else {
+ otherLinks.add(link);
+ }
+ }
+ }
+ // no alternate link? then use THE link if there is one
+ if (alternateLinks.isEmpty() && sEntry.getLink() != null) {
+ Link link = new Link();
+ link.setRel("alternate");
+ link.setHref(sEntry.getLink());
+ alternateLinks.add(link);
+ }
+ // add SyndEnclosures as links with rel="enclosure" ONLY if
+ // there are no SyndEntry.getLinks() with rel="enclosure"
+ if (enclosures != null && linkRelEnclosureExists == false) {
+ for (Iterator iter=enclosures.iterator(); iter.hasNext();) {
+ SyndEnclosure syndEncl = (SyndEnclosure)iter.next();
+ Link link = createAtomEnclosure(syndEncl);
+ otherLinks.add(link);
+ }
+ }
+ if (alternateLinks.size() > 0) aEntry.setAlternateLinks(alternateLinks);
+ if (otherLinks.size() > 0) aEntry.setOtherLinks(otherLinks);
+
+ List sCats = sEntry.getCategories();
+ List aCats = new ArrayList();
+ if (sCats != null) {
+ for (Iterator iter=sCats.iterator(); iter.hasNext();) {
+ SyndCategory sCat = (SyndCategory)iter.next();
+ Category aCat = new Category();
+ aCat.setTerm(sCat.getName());
+ // TODO: aCat.setLabel(sCat.getLabel());
+ aCat.setScheme(sCat.getTaxonomyUri());
+ aCats.add(aCat);
+ }
+ }
+ if (aCats.size() > 0) aEntry.setCategories(aCats);
+
+ List syndContents = sEntry.getContents();
+ aEntry.setContents(createAtomContents(syndContents));
+
+ List authors = sEntry.getAuthors();
+ if (authors!=null && authors.size() > 0) {
+ aEntry.setAuthors(ConverterForAtom03.createAtomPersons(authors));
+ } else if (sEntry.getAuthor() != null) {
+ Person person = new Person();
+ person.setName(sEntry.getAuthor());
+ authors = new ArrayList();
+ authors.add(person);
+ aEntry.setAuthors(authors);
+ }
+
+ List contributors = sEntry.getContributors();
+ if (contributors!=null && contributors.size() > 0) {
+ aEntry.setContributors(ConverterForAtom03.createAtomPersons(contributors));
+ }
+
+ aEntry.setPublished(sEntry.getPublishedDate());
+
+ // Fix for issue #41 "Use updated instead of published"
+ // And issue #42 "Atom 1.0 Date (Updated or Published) Not Set"
+ // Atom requires an updated date, if it's missing use the published date
+ if (sEntry.getUpdatedDate() != null) {
+ aEntry.setUpdated(sEntry.getUpdatedDate());
+ } else {
+ aEntry.setUpdated(sEntry.getPublishedDate());
+ }
+
+ if (((List)sEntry.getForeignMarkup()).size() > 0) {
+ aEntry.setForeignMarkup((List)sEntry.getForeignMarkup());
+ }
+
+ SyndFeed sSource = sEntry.getSource();
+ if (sSource != null) {
+ Feed aSource = (Feed) sSource.createWireFeed(getType());
+ aEntry.setSource(aSource);
+ }
+ return aEntry;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS090.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS090.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS090.java
new file mode 100644
index 0000000..1e4246d
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS090.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * Licensed 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 com.sun.syndication.feed.synd.impl;
+
+import com.sun.syndication.feed.WireFeed;
+import com.sun.syndication.feed.module.impl.ModuleUtils;
+import com.sun.syndication.feed.rss.Channel;
+import com.sun.syndication.feed.rss.Image;
+import com.sun.syndication.feed.rss.Item;
+import com.sun.syndication.feed.synd.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ */
+public class ConverterForRSS090 implements Converter {
+ private String _type;
+
+ public ConverterForRSS090() {
+ this("rss_0.9");
+ }
+
+ protected ConverterForRSS090(String type) {
+ _type = type;
+ }
+
+ public String getType() {
+ return _type;
+ }
+
+ public void copyInto(WireFeed feed,SyndFeed syndFeed) {
+ syndFeed.setModules(ModuleUtils.cloneModules(feed.getModules()));
+ if (((List)feed.getForeignMarkup()).size() > 0) {
+ syndFeed.setForeignMarkup(feed.getForeignMarkup());
+ }
+ syndFeed.setEncoding(feed.getEncoding());
+ Channel channel = (Channel) feed;
+ syndFeed.setTitle(channel.getTitle());
+ syndFeed.setLink(channel.getLink());
+ syndFeed.setDescription(channel.getDescription());
+
+ Image image = channel.getImage();
+ if (image!=null) {
+ syndFeed.setImage(createSyndImage(image));
+ }
+
+ List items = channel.getItems();
+ if (items!=null) {
+ syndFeed.setEntries(createSyndEntries(items, syndFeed.isPreservingWireFeed()));
+ }
+ }
+
+ protected SyndImage createSyndImage(Image rssImage) {
+ SyndImage syndImage = new SyndImageImpl();
+ syndImage.setTitle(rssImage.getTitle());
+ syndImage.setUrl(rssImage.getUrl());
+ syndImage.setLink(rssImage.getLink());
+ return syndImage;
+ }
+
+ protected List createSyndEntries(List rssItems, boolean preserveWireItems) {
+ List syndEntries = new ArrayList();
+ for (int i=0;i<rssItems.size();i++) {
+ syndEntries.add(createSyndEntry((Item) rssItems.get(i), preserveWireItems));
+ }
+ return syndEntries;
+ }
+
+ protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
+ SyndEntryImpl syndEntry = new SyndEntryImpl();
+ if (preserveWireItem) {
+ syndEntry.setWireEntry(item);
+ }
+
+ syndEntry.setModules(ModuleUtils.cloneModules(item.getModules()));
+
+ if (((List)item.getForeignMarkup()).size() > 0) {
+ syndEntry.setForeignMarkup(item.getForeignMarkup());
+ }
+
+ syndEntry.setUri(item.getUri());
+ syndEntry.setLink(item.getLink());
+ syndEntry.setTitle(item.getTitle());
+ syndEntry.setLink(item.getLink());
+ return syndEntry;
+ }
+
+ public WireFeed createRealFeed(SyndFeed syndFeed) {
+ return createRealFeed(getType(),syndFeed);
+ }
+
+ protected WireFeed createRealFeed(String type,SyndFeed syndFeed) {
+ Channel channel = new Channel(type);
+ channel.setModules(ModuleUtils.cloneModules(syndFeed.getModules()));
+
+ channel.setEncoding(syndFeed.getEncoding());
+
+ channel.setTitle(syndFeed.getTitle());
+ if (syndFeed.getLink() != null) {
+ channel.setLink(syndFeed.getLink());
+ }
+ else
+ if (syndFeed.getLinks().size() > 0) {
+ channel.setLink(((SyndLink)syndFeed.getLinks().get(0)).getHref());
+ }
+ channel.setDescription(syndFeed.getDescription());
+ SyndImage sImage = syndFeed.getImage();
+ if (sImage!=null) {
+ channel.setImage(createRSSImage(sImage));
+ }
+
+ List sEntries = syndFeed.getEntries();
+ if (sEntries!=null) {
+ channel.setItems(createRSSItems(sEntries));
+ }
+
+ if (((List)syndFeed.getForeignMarkup()).size() > 0) {
+ channel.setForeignMarkup(syndFeed.getForeignMarkup());
+ }
+ return channel;
+ }
+
+ protected Image createRSSImage(SyndImage sImage) {
+ Image image = new Image();
+ image.setTitle(sImage.getTitle());
+ image.setUrl(sImage.getUrl());
+ image.setLink(sImage.getLink());
+ return image;
+ }
+
+ protected List createRSSItems(List sEntries) {
+ List list = new ArrayList();
+ for (int i=0;i<sEntries.size();i++) {
+ list.add(createRSSItem((SyndEntry)sEntries.get(i)));
+ }
+ return list;
+ }
+
+ protected Item createRSSItem(SyndEntry sEntry) {
+ Item item = new Item();
+ item.setModules(ModuleUtils.cloneModules(sEntry.getModules()));
+ item.setTitle(sEntry.getTitle());
+ item.setLink(sEntry.getLink());
+ if (((List)sEntry.getForeignMarkup()).size() > 0) {
+ item.setForeignMarkup(sEntry.getForeignMarkup());
+ }
+
+ String uri = sEntry.getUri();
+ if (uri != null) {
+ item.setUri(uri);
+ }
+
+
+ return item;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Netscape.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Netscape.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Netscape.java
new file mode 100644
index 0000000..fe5ce26
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Netscape.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * Licensed 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 com.sun.syndication.feed.synd.impl;
+
+
+
+/**
+ */
+public class ConverterForRSS091Netscape extends ConverterForRSS091Userland {
+
+ public ConverterForRSS091Netscape() {
+ this("rss_0.91N");
+ }
+
+ protected ConverterForRSS091Netscape(String type) {
+ super(type);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Userland.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Userland.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Userland.java
new file mode 100644
index 0000000..bcc035f
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Userland.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * Licensed 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 com.sun.syndication.feed.synd.impl;
+
+import com.sun.syndication.feed.WireFeed;
+import com.sun.syndication.feed.module.DCModule;
+import com.sun.syndication.feed.rss.Channel;
+import com.sun.syndication.feed.rss.Content;
+import com.sun.syndication.feed.rss.Description;
+import com.sun.syndication.feed.rss.Image;
+import com.sun.syndication.feed.rss.Item;
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndContentImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndImage;
+import com.sun.syndication.feed.synd.SyndPerson;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ */
+public class ConverterForRSS091Userland extends ConverterForRSS090 {
+ public ConverterForRSS091Userland() {
+ this("rss_0.91U");
+ }
+
+ protected ConverterForRSS091Userland(String type) {
+ super(type);
+ }
+
+ @Override
+ public void copyInto(WireFeed feed, SyndFeed syndFeed) {
+ Channel channel = (Channel) feed;
+ super.copyInto(channel, syndFeed);
+ syndFeed.setLanguage(channel.getLanguage()); //c
+ syndFeed.setCopyright(channel.getCopyright()); //c
+
+ Date pubDate = channel.getPubDate();
+
+ if (pubDate != null) {
+ syndFeed.setPublishedDate(pubDate); //c
+ } else if (channel.getLastBuildDate() != null) {
+ syndFeed.setPublishedDate(channel.getLastBuildDate()); //c
+ }
+
+ String author = channel.getManagingEditor();
+
+ if (author != null) {
+ List creators = ((DCModule) syndFeed.getModule(DCModule.URI)).getCreators();
+
+ if (!creators.contains(author)) {
+ Set s = new HashSet(); // using a set to remove duplicates
+ s.addAll(creators); // DC creators
+ s.add(author); // feed native author
+ creators.clear();
+ creators.addAll(s);
+ }
+ }
+ }
+
+ protected Description createItemDescription(SyndContent sContent) {
+ Description desc = new Description();
+ desc.setValue(sContent.getValue());
+ desc.setType(sContent.getType());
+
+ return desc;
+ }
+
+ @Override
+ protected Image createRSSImage(SyndImage sImage) {
+ Image image = super.createRSSImage(sImage);
+ image.setDescription(sImage.getDescription());
+
+ return image;
+ }
+
+ // for synd -> rss
+ // synd.content -> rss.content
+ // synd.description -> rss.description
+ @Override
+ protected Item createRSSItem(SyndEntry sEntry) {
+ Item item = super.createRSSItem(sEntry);
+
+ SyndContent sContent = sEntry.getDescription();
+
+ if (sContent != null) {
+ item.setDescription(createItemDescription(sContent));
+ }
+
+ List contents = sEntry.getContents();
+
+ if ((contents != null) && (contents.size() > 0)) {
+ SyndContent syndContent = (SyndContent) contents.get(0);
+ Content cont = new Content();
+ cont.setValue(syndContent.getValue());
+ cont.setType(syndContent.getType());
+ item.setContent(cont);
+ }
+
+ return item;
+ }
+
+ @Override
+ protected WireFeed createRealFeed(String type, SyndFeed syndFeed) {
+ Channel channel = (Channel) super.createRealFeed(type, syndFeed);
+ channel.setLanguage(syndFeed.getLanguage()); //c
+ channel.setCopyright(syndFeed.getCopyright()); //c
+ channel.setPubDate(syndFeed.getPublishedDate()); //c
+
+ if ((syndFeed.getAuthors() != null) && (syndFeed.getAuthors()
+ .size() > 0)) {
+ SyndPerson author = (SyndPerson) syndFeed.getAuthors()
+ .get(0);
+ channel.setManagingEditor(author.getName());
+ }
+
+ return channel;
+ }
+
+ // for rss -> synd
+ // rss.content -> synd.content
+ // rss.description -> synd.description
+ @Override
+ protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
+ SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
+ Description desc = item.getDescription();
+
+ if (desc != null) {
+ SyndContent descContent = new SyndContentImpl();
+ descContent.setType(desc.getType());
+ descContent.setValue(desc.getValue());
+ syndEntry.setDescription(descContent);
+ }
+
+ Content cont = item.getContent();
+
+ if (cont != null) {
+ SyndContent content = new SyndContentImpl();
+ content.setType(cont.getType());
+ content.setValue(cont.getValue());
+
+ List syndContents = new ArrayList();
+ syndContents.add(content);
+ syndEntry.setContents(syndContents);
+ }
+
+ return syndEntry;
+ }
+
+ @Override
+ protected SyndImage createSyndImage(Image rssImage) {
+ SyndImage syndImage = super.createSyndImage(rssImage);
+ syndImage.setDescription(rssImage.getDescription());
+
+ return syndImage;
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS092.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS092.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS092.java
new file mode 100644
index 0000000..f47462d
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS092.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * Licensed 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 com.sun.syndication.feed.synd.impl;
+
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import com.sun.syndication.feed.rss.Category;
+import com.sun.syndication.feed.rss.Enclosure;
+import com.sun.syndication.feed.rss.Item;
+import com.sun.syndication.feed.synd.SyndCategory;
+import com.sun.syndication.feed.synd.SyndCategoryImpl;
+import com.sun.syndication.feed.synd.SyndEnclosure;
+import com.sun.syndication.feed.synd.SyndEnclosureImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+
+/**
+ */
+public class ConverterForRSS092 extends ConverterForRSS091Userland {
+
+ public ConverterForRSS092() {
+ this("rss_0.92");
+ }
+
+ protected ConverterForRSS092(String type) {
+ super(type);
+ }
+
+ @Override
+ protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
+ SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
+ List cats = item.getCategories();
+ if (cats.size()>0) {
+ Set s = new LinkedHashSet(); // using a set to remove duplicates and use a LinkedHashSet to try to retain the document order
+ s.addAll(createSyndCategories(cats)); // feed native categories (as syndcat)
+ s.addAll(syndEntry.getCategories()); // DC subjects (as syndcat)
+ syndEntry.setCategories(new ArrayList(s)); //c
+ }
+ List enclosures = item.getEnclosures();
+ if (enclosures.size()>0) {
+ syndEntry.setEnclosures(createSyndEnclosures(enclosures));
+ }
+ return syndEntry;
+ }
+
+ protected List createSyndCategories(List rssCats) {
+ List syndCats = new ArrayList();
+ for (int i=0;i<rssCats.size();i++) {
+ Category rssCat = (Category) rssCats.get(i);
+ SyndCategory sCat = new SyndCategoryImpl();
+ sCat.setTaxonomyUri(rssCat.getDomain());
+ sCat.setName(rssCat.getValue());
+ syndCats.add(sCat);
+ }
+ return syndCats;
+ }
+
+ protected List createSyndEnclosures(List enclosures) {
+ List sEnclosures = new ArrayList();
+ for (int i=0;i<enclosures.size();i++) {
+ Enclosure enc = (Enclosure) enclosures.get(i);
+ SyndEnclosure sEnc = new SyndEnclosureImpl();
+ sEnc.setUrl(enc.getUrl());
+ sEnc.setType(enc.getType());
+ sEnc.setLength(enc.getLength());
+ sEnclosures.add(sEnc);
+ }
+ return sEnclosures;
+ }
+
+ @Override
+ protected Item createRSSItem(SyndEntry sEntry) {
+ Item item = super.createRSSItem(sEntry);
+
+ List sCats = sEntry.getCategories(); //c
+ if (sCats.size()>0) {
+ item.setCategories(createRSSCategories(sCats));
+ }
+ List sEnclosures = sEntry.getEnclosures();
+ if (sEnclosures.size()>0) {
+ item.setEnclosures(createEnclosures(sEnclosures));
+ }
+ return item;
+ }
+
+ protected List createRSSCategories(List sCats) {
+ List cats = new ArrayList();
+ for (int i=0;i<sCats.size();i++) {
+ SyndCategory sCat = (SyndCategory) sCats.get(i);
+ Category cat = new Category();
+ cat.setDomain(sCat.getTaxonomyUri());
+ cat.setValue(sCat.getName());
+ cats.add(cat);
+ }
+ return cats;
+ }
+
+ protected List createEnclosures(List sEnclosures) {
+ List enclosures = new ArrayList();
+ for (int i=0;i<sEnclosures.size();i++) {
+ SyndEnclosure sEnc = (SyndEnclosure) sEnclosures.get(i);
+ Enclosure enc = new Enclosure();
+ enc.setUrl(sEnc.getUrl());
+ enc.setType(sEnc.getType());
+ enc.setLength(sEnc.getLength());
+ enclosures.add(enc);
+ }
+ return enclosures;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS093.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS093.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS093.java
new file mode 100644
index 0000000..79839af
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS093.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * Licensed 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 com.sun.syndication.feed.synd.impl;
+
+import com.sun.syndication.feed.rss.Item;
+import com.sun.syndication.feed.synd.SyndEntry;
+
+import java.util.Date;
+
+/**
+ */
+public class ConverterForRSS093 extends ConverterForRSS092 {
+
+ public ConverterForRSS093() {
+ this("rss_0.93");
+ }
+
+ protected ConverterForRSS093(String type) {
+ super(type);
+ }
+
+ @Override
+ protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
+ SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
+ Date pubDate = item.getPubDate();
+ if (pubDate!=null) {
+ syndEntry.setPublishedDate(pubDate); //c
+ }
+ return syndEntry;
+ }
+
+ @Override
+ protected Item createRSSItem(SyndEntry sEntry) {
+ Item item = super.createRSSItem(sEntry);
+ item.setPubDate(sEntry.getPublishedDate()); //c
+ return item;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/00c22e7c/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java
new file mode 100644
index 0000000..9c36934
--- /dev/null
+++ b/commons/marmotta-sesame-tools/marmotta-rio-rss/src/ext/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2004 Sun Microsystems, Inc.
+ *
+ * Licensed 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 com.sun.syndication.feed.synd.impl;
+
+import com.sun.syndication.feed.WireFeed;
+import com.sun.syndication.feed.module.DCModule;
+import com.sun.syndication.feed.rss.Channel;
+import com.sun.syndication.feed.rss.Guid;
+import com.sun.syndication.feed.rss.Item;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndLink;
+import com.sun.syndication.feed.synd.SyndLinkImpl;
+import com.sun.syndication.feed.synd.SyndPerson;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ */
+public class ConverterForRSS094 extends ConverterForRSS093 {
+
+ public ConverterForRSS094() {
+ this("rss_0.94");
+ }
+
+ protected ConverterForRSS094(String type) {
+ super(type);
+ }
+
+ @Override
+ public void copyInto(WireFeed feed,SyndFeed syndFeed) {
+ Channel channel = (Channel) feed;
+ super.copyInto(channel,syndFeed);
+ List cats = channel.getCategories(); //c
+ if (cats.size()>0) {
+ Set s = new HashSet(); // using a set to remove duplicates
+ s.addAll(createSyndCategories(cats)); // feed native categories (as syndcat)
+ s.addAll(syndFeed.getCategories()); // DC subjects (as syndcat)
+ syndFeed.setCategories(new ArrayList(s));
+ }
+ }
+
+ @Override
+ protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
+ SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
+
+ // adding native feed author to DC creators list
+ String author = item.getAuthor();
+ if (author!=null) {
+ List creators = ((DCModule)syndEntry.getModule(DCModule.URI)).getCreators();
+ if (!creators.contains(author)) {
+ Set s = new HashSet(); // using a set to remove duplicates
+ s.addAll(creators); // DC creators
+ s.add(author); // feed native author
+ creators.clear();
+ creators.addAll(s);
+ }
+ }
+
+ Guid guid = item.getGuid();
+ if (guid!=null) {
+ syndEntry.setUri(guid.getValue());
+ if (item.getLink()==null && guid.isPermaLink()) {
+ syndEntry.setLink(guid.getValue());
+ }
+ }
+ else {
+ syndEntry.setUri(item.getLink());
+ }
+ if(item.getComments() != null){
+ SyndLinkImpl comments = new SyndLinkImpl();
+ comments.setRel("comments");
+ comments.setHref(item.getComments());
+ comments.setType("text/html");
+ }
+ return syndEntry;
+ }
+
+
+ @Override
+ protected WireFeed createRealFeed(String type,SyndFeed syndFeed) {
+ Channel channel = (Channel) super.createRealFeed(type,syndFeed);
+ List cats = syndFeed.getCategories(); //c
+ if (cats.size()>0) {
+ channel.setCategories(createRSSCategories(cats));
+ }
+ return channel;
+ }
+
+ @Override
+ protected Item createRSSItem(SyndEntry sEntry) {
+ Item item = super.createRSSItem(sEntry);
+ if (sEntry.getAuthors()!=null && sEntry.getAuthors().size() > 0) {
+ SyndPerson author = (SyndPerson)sEntry.getAuthors().get(0);
+ item.setAuthor(author.getEmail());
+ }
+
+ Guid guid = null;
+ String uri = sEntry.getUri();
+ if (uri!=null) {
+ guid = new Guid();
+ guid.setPermaLink(false);
+ guid.setValue(uri);
+ }
+ else {
+ String link = sEntry.getLink();
+ if (link!=null) {
+ guid = new Guid();
+ guid.setPermaLink(true);
+ guid.setValue(link);
+ }
+ }
+ item.setGuid(guid);
+ SyndLink comments = sEntry.findRelatedLink("comments");
+ if(comments != null && (comments.getType() == null || comments.getType().endsWith("html"))){
+ item.setComments(comments.getHref());
+ }
+ return item;
+ }
+
+}