Changeset 1480

Show
Ignore:
Timestamp:
11/19/08 13:09:56 (7 weeks ago)
Author:
marcelo
Message:

Issue 15: UserStory: Create generic FeedSync Server

Location:
branches/dev-instedd
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • branches/dev-instedd/org.javarosa.demo/src/org/javarosa/demo/midlet/Mesh4xDemoMidlet.java

    r1275 r1480  
    9898                // MESH4x properties 
    9999                initProperty(Mesh4jPropertyRules.HTTP_SYNC_BASE_URL, "http://sync.instedd.org/Service.svc/feeds/", true); 
    100                 initProperty(Mesh4jPropertyRules.HTTP_DISCOVERY_XFORMS_URL, "http://sync.instedd.org/Service.svc/feeds/XForms", true); 
    101100                initProperty(Mesh4jPropertyRules.SMS_DEFAULT_TARGET, "+541136544867", true); 
    102101                initProperty(Mesh4jPropertyRules.SMS_PORT, "3333", true); 
  • branches/dev-instedd/org.javarosa.demo/src/org/javarosa/demo/shell/JavaRosaDemoShell.java

    r1453 r1480  
    126126                         
    127127                } else if (returningActivity instanceof SplashScreenModule) { 
     128                         
    128129                        LoggedUserIdentityProvider.INSTANCE.setLoggedUser("admin"); 
    129130                        launchActivity(new FormListActivity(this, "Forms List"), context); 
     
    352353                initProperty(Mesh4jPropertyRules.SMS_BLOCK_DIFF_SIZE, "100"); 
    353354                initProperty(Mesh4jPropertyRules.SMS_MAX_MESSAGE_LENGHT, "140", true); 
    354                 initProperty(Mesh4jPropertyRules.SMS_DEFAULT_TARGET, "+5550001", true); 
     355                initProperty(Mesh4jPropertyRules.SMS_DEFAULT_TARGET, "+5550001"); 
    355356                initProperty(Mesh4jPropertyRules.SMS_PORT, "3333", true); 
    356357                initProperty(Mesh4jPropertyRules.USE_TEMPLATES, Mesh4jPropertyRules.USE_TEMPLATES_NO); 
    357                 initProperty(Mesh4jPropertyRules.HTTP_SYNC_BASE_URL, "http://vcc-pc:8080/mesh4x/feeds/", true); 
    358                 initProperty(Mesh4jPropertyRules.HTTP_DISCOVERY_XFORMS_URL, "http://vcc-pc:8080/mesh4x/feeds/XForms", true); 
    359 //              initProperty(Mesh4jPropertyRules.HTTP_SYNC_BASE_URL, "http://sync.instedd.org/Service.svc/feeds/"); 
    360 //              initProperty(Mesh4jPropertyRules.HTTP_DISCOVERY_XFORMS_URL, "http://sync.instedd.org/Service.svc/feeds/XForms"); 
     358                initProperty(Mesh4jPropertyRules.HTTP_SYNC_BASE_URL, "http://localhost:9090/mesh4x/feeds/XForms", true); 
    361359        } 
    362360 
  • branches/dev-instedd/org.javarosa.mesh4j.sync.extensions/src/org/javarosa/core/services/mesh4j/extensions/SyncEngineService.java

    r1453 r1480  
    1717import org.javarosa.xform.mesh4j.extensions.FormDefUtils; 
    1818import org.javarosa.xform.util.XFormUtils; 
     19import org.kxml2.kdom.Element; 
    1920import org.mesh4j.sync.SyncEngine; 
    2021import org.mesh4j.sync.adapters.feed.atom.AtomSyndicationFormat; 
     
    5354import org.mesh4j.sync.message.protocol.NoChangesMessageProcessor; 
    5455import org.mesh4j.sync.model.Item; 
     56import org.mesh4j.sync.utils.XmlHelper; 
    5557 
    5658public class SyncEngineService implements IService, IMessageSyncAdapterFactory, IMessageSyncAware, ISmsConnectionInboundOutboundNotification, ISmsRetiesNotification { 
     
    104106        // SYnc METHODS 
    105107        public static Vector<Item> synchronizeItemsSynchronousHttpMethod(String formName) { 
    106                 String url = getBaseURL()+ formName + "?format=atom10"; 
     108                String url = getBaseURL()+ "/" + formName + "?format=atom10"; 
    107109                SplitAdapter splitAdapter = makeXFormSplitAdapter(formName); 
    108110                HttpSyncAdapter httpAdapter = new HttpSyncAdapter(url, AtomSyndicationFormat.INSTANCE, LoggedUserIdentityProvider.INSTANCE, IdGenerator.INSTANCE); 
     
    151153 
    152154        public static void importFormDefFromURL() { 
    153                 String url = JavaRosaServiceProvider.instance().getPropertyManager().getSingularProperty(Mesh4jPropertyRules.HTTP_DISCOVERY_XFORMS_URL) + "?format=atom10"; 
    154                 HttpSyncAdapter httpAdapter = new HttpSyncAdapter(url, AtomSyndicationFormat.INSTANCE, LoggedUserIdentityProvider.INSTANCE, IdGenerator.INSTANCE); 
     155                String url = getBaseURL(); 
     156                HttpSyncAdapter httpAdapter = new HttpSyncAdapter(url+"?format=atom10", AtomSyndicationFormat.INSTANCE, LoggedUserIdentityProvider.INSTANCE, IdGenerator.INSTANCE); 
    155157                Vector<Item> items = httpAdapter.getAll(); 
    156158                         
    157159                for (Item item : items) { 
    158160                        if(!item.isDeleted()){ 
    159                                 String xml = item.getContent().getPayload(); 
    160                                 FormDefUtils.importFormDefFromXml(xml); 
     161                                String payload = item.getContent().getPayload(); 
     162                                System.out.println(payload); 
     163                                if(payload.startsWith("<schema>") && payload.endsWith("</schema>")){ 
     164                                        payload = payload.substring(8, payload.length()-9); 
     165                                        //schemaXML.replaceAll("&lt;", "<"); 
     166                                        //schemaXML.replaceAll("&gt;", ">"); 
     167                                        FormDefUtils.importFormDefFromXml(payload); 
     168                                } 
    161169                        }                                
    162170                } 
  • branches/dev-instedd/org.javarosa.mesh4j.sync.extensions/src/org/javarosa/core/services/properties/mesh4j/extensions/Mesh4jPropertyRules.java

    r1286 r1480  
    1313        // CONSTANTS 
    1414        public static final String HTTP_SYNC_BASE_URL = "Mesh4xBaseUrl"; 
    15         public static final String HTTP_DISCOVERY_XFORMS_URL = "Mesh4xDiscoveryUrl"; 
    1615        public static final String SMS_DEFAULT_TARGET = "Mesh4xDefaultSmsTarget"; 
    1716        public static final String SMS_PORT = "Mesh4xDefaultSmsPort"; 
     
    4645 
    4746        this.rules.put(HTTP_SYNC_BASE_URL, new Vector()); 
    48         this.rules.put(HTTP_DISCOVERY_XFORMS_URL, new Vector()); 
    4947        this.rules.put(SMS_DEFAULT_TARGET, new Vector()); 
    5048        this.rules.put(SMS_PORT, new Vector()); 
  • branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/FeedReader.java

    r1464 r1480  
    8282                String title = ""; 
    8383                String description = ""; 
     84                String link = ""; 
    8485                 
    8586                Sync sync = null; 
     
    9293                                if(ISyndicationFormat.SX_ELEMENT_SYNC.equals(element.getName())){ 
    9394                                        sync = readSync(element); 
    94                                 } else if(ISyndicationFormat.SX_ELEMENT_ITEM_TITLE.equals(element.getName())){ 
     95                                } else if(ISyndicationFormat.SX_ELEMENT_ITEM_TITLE.equals(element.getName()) || "subtitle".equals(element.getName())){ 
    9596                                        title = element.getText(0); 
    9697                                } else if(ISyndicationFormat.SX_ELEMENT_ITEM_DESCRIPTION.equals(element.getName())){ 
    9798                                        description = element.getText(0); 
     99                                } else if(ISyndicationFormat.SX_ELEMENT_ITEM_LINK.equals(element.getName())){ 
     100                                        link = element.getText(0); 
    98101                                } else if(!ISyndicationFormat.SX_ELEMENT_AUTHOR.equals(element.getName())){ 
    99102                                        payload.append(this.elementToXML(element)); 
  • branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/adapters/feed/ISyndicationFormat.java

    r994 r1480  
    6666        public static final String SX_ELEMENT_ITEM_TITLE = "title"; 
    6767        public static final String SX_ELEMENT_ITEM_DESCRIPTION = "description"; 
     68        public static final String SX_ELEMENT_ITEM_LINK = "link"; 
    6869                 
    6970} 
  • branches/dev-instedd/org.mesh4j.sync/src/org/mesh4j/sync/adapters/rms/storage/RmsStorageSyncRepository.java

    r1289 r1480  
    44 
    55import org.mesh4j.sync.adapters.SyncInfo; 
    6 import org.mesh4j.sync.adapters.feed.rss.RssSyndicationFormat; 
     6import org.mesh4j.sync.adapters.feed.atom.AtomSyndicationFormat; 
    77import org.mesh4j.sync.adapters.split.ISyncRepository; 
    88import org.mesh4j.sync.id.generator.IIdGenerator; 
     
    2828                Guard.argumentNotNull(idGenerator, "idGenerator"); 
    2929                 
    30                 this.parser = new SyncInfoObjectParser(RssSyndicationFormat.INSTANCE, identityProvider, idGenerator); 
     30                this.parser = new SyncInfoObjectParser(AtomSyndicationFormat.INSTANCE, identityProvider, idGenerator); 
    3131                this.storage = new RmsStorage(parser, storageName); 
    3232                this.idGenerator = idGenerator;