Changeset 1481
- Timestamp:
- 11/20/08 08:17:53 (7 weeks ago)
- Location:
- branches/dev-instedd
- Files:
-
- 11 modified
-
org.javarosa.demo/build.properties (modified) (1 diff)
-
org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/FeedReader.java (modified) (1 diff)
-
org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/FeedWriter.java (modified) (2 diffs)
-
org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/ISyndicationFormat.java (modified) (4 diffs)
-
org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/XMLContent.java (modified) (2 diffs)
-
org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/atom/AtomSyndicationFormat.java (modified) (3 diffs)
-
org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/rss/RssSyndicationFormat.java (modified) (3 diffs)
-
org.mesh4j.sync/src/org/mesh4j/sync/adapters/rms/storage/EntityContent.java (modified) (2 diffs)
-
org.mesh4j.sync/src/org/mesh4j/sync/adapters/rms/storage/RmsRecordContent.java (modified) (2 diffs)
-
org.mesh4j.sync/src/org/mesh4j/sync/model/IContent.java (modified) (2 diffs)
-
org.mesh4j.sync/src/org/mesh4j/sync/model/NullContent.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/dev-instedd/org.javarosa.demo/build.properties
r1231 r1481 25 25 #device.identifier=Palm/TungstenC 26 26 device.identifier=Generic/DefaultColorPhone 27 #device.identifier=Sony-Ericsson/P1i 27 28 #device.identifier=Generic/MppPhone 28 29 #device.identifier=Palm/Treo650 -
branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/FeedReader.java
r1480 r1481 93 93 if(ISyndicationFormat.SX_ELEMENT_SYNC.equals(element.getName())){ 94 94 sync = readSync(element); 95 } else if( ISyndicationFormat.SX_ELEMENT_ITEM_TITLE.equals(element.getName()) || "subtitle".equals(element.getName())){95 } else if(this.syndicationFormat.isFeedItemTitle(element)){ 96 96 title = element.getText(0); 97 } else if( ISyndicationFormat.SX_ELEMENT_ITEM_DESCRIPTION.equals(element.getName())){97 } else if(this.syndicationFormat.isFeedItemDescription(element)){ 98 98 description = element.getText(0); 99 } else if( ISyndicationFormat.SX_ELEMENT_ITEM_LINK.equals(element.getName())){99 } else if(this.syndicationFormat.isFeedItemLink(element)){ 100 100 link = element.getText(0); 101 101 } else if(!ISyndicationFormat.SX_ELEMENT_AUTHOR.equals(element.getName())){ -
branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/FeedWriter.java
r1291 r1481 51 51 this.syndicationFormat.writeStartItem(writer); 52 52 53 this.writeContent(writer, item.get Content());53 this.writeContent(writer, item.getSync(), item.getContent(), this.syndicationFormat); 54 54 55 55 String by = this.identityProvider.getAuthenticatedUser(); … … 70 70 } 71 71 72 private void writeContent(Writer writer, IContent content) throws Exception { 73 String xmlContent = XMLContent.normalizeContent(content); 74 if(xmlContent != null && xmlContent.trim().length() > 0){ 75 writer.write(xmlContent); 76 } 77 78 if(content instanceof XMLContent){ 79 XMLContent contentAsXMLContent = (XMLContent) content; 80 if(contentAsXMLContent.getTitle() != null && contentAsXMLContent.getTitle().trim().length() > 0){ 81 writer.write("<title>"); 82 writer.write(contentAsXMLContent.getTitle()); 83 writer.write("</title>"); 84 } 85 86 if(contentAsXMLContent.getDescription() != null && contentAsXMLContent.getDescription().trim().length() > 0){ 87 writer.write("<description>"); 88 writer.write(contentAsXMLContent.getDescription()); 89 writer.write("</description>"); 90 } 91 } 72 private void writeContent(Writer writer, Sync sync, IContent content, ISyndicationFormat format) throws Exception { 73 content.addToFeedPayload(writer, sync, format); 92 74 } 93 75 -
branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/ISyndicationFormat.java
r1480 r1481 1 1 package org.mesh4j.sync.adapters.feed; 2 2 3 import java.io.IOException; 3 4 import java.io.Writer; 4 5 import java.util.Date; … … 14 15 Element getBaseElement(Document document); 15 16 17 boolean isFeedItemTitle(Element element); 18 boolean isFeedItemDescription(Element element); 19 boolean isFeedItemLink(Element element); 20 16 21 Date parseDate(String dateAsString); 17 22 String formatDate(Date date); … … 22 27 void writeEndDocument(Writer writer) throws Exception; 23 28 29 void writeStartFeedItemTitle(Writer writer) throws IOException; 30 void writeEndFeedItemTitle(Writer writer) throws IOException; 31 32 void writeStartFeedItemDescription(Writer writer) throws IOException; 33 void writeEndFeedItemDescription(Writer writer) throws IOException; 34 35 void writeStartFeedItemLink(Writer writer) throws IOException; 36 void writeEndFeedItemLink(Writer writer) throws IOException; 24 37 25 38 // / <summary> … … 62 75 public static final String SX_ATTRIBUTE_HISTORY_WHEN = "when"; 63 76 public static final String SX_ATTRIBUTE_HISTORY_BY = "by"; 64 65 // sx:item 66 public static final String SX_ELEMENT_ITEM_TITLE = "title"; 67 public static final String SX_ELEMENT_ITEM_DESCRIPTION = "description"; 68 public static final String SX_ELEMENT_ITEM_LINK = "link"; 69 77 70 78 } -
branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/XMLContent.java
r1064 r1481 1 1 package org.mesh4j.sync.adapters.feed; 2 2 3 import java.io.Writer; 4 3 5 import org.mesh4j.sync.model.Content; 4 import org.mesh4j.sync.model. IContent;6 import org.mesh4j.sync.model.Sync; 5 7 6 8 … … 59 61 } 60 62 61 public static String normalizeContent(IContent content) { 62 return content.getPayloadForFeed(); 63 } 64 65 public String getPayloadForFeed(){ 66 return this.getPayload(); 63 public void addToFeedPayload(Writer writer, Sync sync, ISyndicationFormat format) throws Exception{ 64 format.writeStartFeedItemTitle(writer); 65 writer.write(this.getTitle()); 66 format.writeEndFeedItemTitle(writer); 67 68 format.writeStartFeedItemDescription(writer); 69 writer.write(this.getDescription()); 70 format.writeEndFeedItemDescription(writer); 71 72 writer.write(this.getPayload()); 67 73 } 68 74 } -
branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/atom/AtomSyndicationFormat.java
r994 r1481 1 1 package org.mesh4j.sync.adapters.feed.atom; 2 2 3 import java.io.IOException; 3 4 import java.io.Writer; 4 5 import java.util.Date; … … 13 14 private static final String ATOM_ELEMENT_FEED = "feed"; 14 15 private static final String ATOM_ELEMENT_ENTRY = "entry"; 16 public static final String FEED_ITEM_ELEMENT_TITLE = "title"; 17 public static final String FEED_ITEM_ELEMENT_DESCRIPTION = "content"; 18 public static final String FEED_ITEM_ELEMENT_LINK = "link"; 15 19 public static final AtomSyndicationFormat INSTANCE = new AtomSyndicationFormat(); 16 20 … … 55 59 return "ATOM"; 56 60 } 61 62 public boolean isFeedItemDescription(Element element) { 63 return FEED_ITEM_ELEMENT_DESCRIPTION.equals(element.getName()); 64 } 65 66 public boolean isFeedItemLink(Element element) { 67 return FEED_ITEM_ELEMENT_LINK.equals(element.getName()); 68 } 69 70 71 public boolean isFeedItemTitle(Element element) { 72 return FEED_ITEM_ELEMENT_TITLE.equals(element.getName()); 73 } 74 75 public void writeStartFeedItemDescription(Writer writer) throws IOException { 76 writer.write("<content>"); 77 } 78 79 public void writeEndFeedItemDescription(Writer writer) throws IOException { 80 writer.write("</content>"); 81 } 82 83 public void writeStartFeedItemLink(Writer writer) throws IOException { 84 writer.write("<link>"); 85 } 86 87 public void writeEndFeedItemLink(Writer writer) throws IOException { 88 writer.write("</link>"); 89 } 90 91 public void writeStartFeedItemTitle(Writer writer) throws IOException { 92 writer.write("<title>"); 93 } 94 95 public void writeEndFeedItemTitle(Writer writer) throws IOException { 96 writer.write("</title>"); 97 } 57 98 } -
branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/rss/RssSyndicationFormat.java
r994 r1481 1 1 package org.mesh4j.sync.adapters.feed.rss; 2 2 3 import java.io.IOException; 3 4 import java.io.Writer; 4 5 import java.util.Date; … … 14 15 public static final String RSS_ELEMENT_ITEM = "item"; 15 16 public static final String RSS_ELEMENT_CHANNEL = "channel"; 17 public static final String FEED_ITEM_ELEMENT_TITLE = "title"; 18 public static final String FEED_ITEM_ELEMENT_DESCRIPTION = "description"; 19 public static final String FEED_ITEM_ELEMENT_LINK = "link"; 16 20 public static final RssSyndicationFormat INSTANCE = new RssSyndicationFormat(); 17 21 … … 76 80 } 77 81 82 public boolean isFeedItemDescription(Element element) { 83 return FEED_ITEM_ELEMENT_DESCRIPTION.equals(element.getName()); 84 } 85 86 public boolean isFeedItemLink(Element element) { 87 return FEED_ITEM_ELEMENT_LINK.equals(element.getName()); 88 } 89 90 91 public boolean isFeedItemTitle(Element element) { 92 return FEED_ITEM_ELEMENT_TITLE.equals(element.getName()); 93 } 94 95 public void writeStartFeedItemDescription(Writer writer) throws IOException { 96 writer.write("<description>"); 97 } 98 99 public void writeEndFeedItemDescription(Writer writer) throws IOException { 100 writer.write("</description>"); 101 } 102 103 public void writeStartFeedItemLink(Writer writer) throws IOException { 104 writer.write("<link>"); 105 } 106 107 public void writeEndFeedItemLink(Writer writer) throws IOException { 108 writer.write("</link>"); 109 } 110 111 public void writeStartFeedItemTitle(Writer writer) throws IOException { 112 writer.write("<title>"); 113 } 114 115 public void writeEndFeedItemTitle(Writer writer) throws IOException { 116 writer.write("</title>"); 117 } 78 118 } -
branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/adapters/rms/storage/EntityContent.java
r1064 r1481 1 1 package org.mesh4j.sync.adapters.rms.storage; 2 2 3 import java.io.Writer; 4 3 5 import org.kxml2.kdom.Element; 6 import org.mesh4j.sync.adapters.feed.ISyndicationFormat; 4 7 import org.mesh4j.sync.model.Content; 5 8 import org.mesh4j.sync.model.IContent; 9 import org.mesh4j.sync.model.Sync; 6 10 import org.mesh4j.sync.utils.XmlHelper; 7 11 … … 77 81 } 78 82 79 public String getPayloadForFeed() { 80 StringBuffer sb = new StringBuffer(); 81 sb.append("<title>"); 82 sb.append(this.entityName); 83 sb.append("</title>"); 83 public void addToFeedPayload(Writer writer, Sync sync, ISyndicationFormat format) throws Exception{ 84 format.writeStartFeedItemTitle(writer); 85 writer.write(this.entityName); 86 format.writeEndFeedItemTitle(writer); 84 87 85 sb.append("<description>"); 86 sb.append("Sync id: " + this.getId()); 87 sb.append(" version: " + this.getVersion()); 88 sb.append("</description>"); 89 90 sb.append(this.getPayload()); 91 return sb.toString(); 88 format.writeStartFeedItemDescription(writer); 89 writer.write("Sync id: " + this.getId() ); 90 writer.write(" version: " + this.getVersion()); 91 format.writeEndFeedItemDescription(writer); 92 93 writer.write(this.getPayload()); 92 94 } 93 95 } -
branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/adapters/rms/storage/RmsRecordContent.java
r1064 r1481 1 1 package org.mesh4j.sync.adapters.rms.storage; 2 2 3 import java.io.Writer; 4 5 import org.mesh4j.sync.adapters.feed.ISyndicationFormat; 3 6 import org.mesh4j.sync.model.IContent; 7 import org.mesh4j.sync.model.Sync; 4 8 import org.mesh4j.sync.validations.Guard; 5 9 … … 90 94 } 91 95 92 public String getPayloadForFeed() { 93 StringBuffer sb = new StringBuffer(); 94 sb.append("<title>"); 95 sb.append(this.entityName); 96 sb.append("</title>"); 96 public void addToFeedPayload(Writer writer, Sync sync, ISyndicationFormat format) throws Exception{ 97 format.writeStartFeedItemTitle(writer); 98 writer.write(this.entityName); 99 format.writeEndFeedItemTitle(writer); 97 100 98 sb.append("<description>"); 99 sb.append("Sync id: " + this.syncId); 100 sb.append(" version: " + this.getVersion()); 101 sb.append("</description>"); 102 103 sb.append(this.payload); 104 return sb.toString(); 101 format.writeStartFeedItemDescription(writer); 102 writer.write("Sync id: " + this.syncId ); 103 writer.write(" version: " + this.getVersion()); 104 format.writeEndFeedItemDescription(writer); 105 106 writer.write(this.payload); 105 107 } 106 108 } -
branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/model/IContent.java
r1064 r1481 1 1 package org.mesh4j.sync.model; 2 3 import java.io.Writer; 4 5 import org.mesh4j.sync.adapters.feed.ISyndicationFormat; 2 6 3 7 public interface IContent{ … … 11 15 int getVersion(); 12 16 13 String getPayloadForFeed(); 14 17 void addToFeedPayload(Writer writer, Sync sync, ISyndicationFormat format) throws Exception; 15 18 } -
branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/model/NullContent.java
r1064 r1481 1 1 package org.mesh4j.sync.model; 2 2 3 import java.io.Writer; 4 5 import org.mesh4j.sync.adapters.feed.ISyndicationFormat; 3 6 import org.mesh4j.sync.validations.Guard; 4 7 … … 52 55 } 53 56 54 public String getPayloadForFeed() { 55 StringBuffer sb = new StringBuffer(); 56 sb.append("<title>deleted</title>"); 57 sb.append("<description>deleted</description>"); 58 return sb.toString(); 57 public void addToFeedPayload(Writer writer, Sync sync, ISyndicationFormat format) throws Exception{ 58 format.writeStartFeedItemTitle(writer); 59 if(sync.isDeleted()){ 60 writer.write("--DELETED--"); 61 } else { 62 writer.write("--UNKNOWN--"); 63 } 64 format.writeEndFeedItemTitle(writer); 65 66 format.writeStartFeedItemDescription(writer); 67 writer.write("Id: " + this.getId() + " version: " + this.getVersion()); 68 format.writeEndFeedItemDescription(writer); 59 69 } 60 70 }
