|By Anthony Krinsky||
|November 29, 1999 12:00 AM EST||
Managing and displaying content stored in the Spectra object store will be a major feature of any Spectra project. Content will come from a variety of places: self-service applications, system-generated messages and objects, and externally provided articles and data from a variety of content providers. The latter is called "syndicated content." This article demonstrates how one might automate the insertion of syndicated content from an outside news service.
There are two methods of getting syndicated content in Allaire Spectra: the hard way...and the easy way. The easy way is to transfer content over HTTP from one Spectra machine to another using the Syndication features of the COAPI (Content Object API) (see Figure 1, Scenario 3). This content syndication process gets a terrific write-up in chapter 14, "Syndication and Remote Access," of the Programming with Allaire Spectra manual.
Alternatively, content vendors wouldn't need their own Spectra servers, but would simply package the data in an XML format, WDDX, that Spectra understands (Figure 1, Scenario 2). Allaire will soon begin to promote WDDX, as implemented by the COAPI, for this purpose. Spectra users and content providers can also use XSL transformation engines to normalize XML data before or after syndication. Allaire may soon bundle Granularity Information Architecture's GIAXT XSL transformation engine (www.granularity.com) to provide such translation services.
In the meantime we'll need to process newsfeeds ourselves and programmatically funnel them into the object store through the COAPI (Figure 1, Scenario 1). It's not elegant, but it's easy to implement and works quite well.p> If you want real-time news from a variety of sources and you want it fast, one of the best places to start is Screaming Media (www.screamingmedia.net). Screaming Media is a nice solution because they aggregate content from hundreds of traditional and nontraditional sources, provide data in a consistent format, allow you to pay only for what you use and don't require impression-based royalties. For $2,500 up-front and $500/month (and up), Screaming Media will send piping-hot, filtered news to a proprietary Java component, Siteware, that sits on your server. Reuters, Wavo and iSyndicate provide a similar service and each has its own proprietary or third-party syndication components.
Installing the Siteware component first requires installing the Java 1.1.8 Run-time Environment (JRE) from http://java.sun.com. You then unzip some files and add a "siteware.bat" shortcut (on NT) to the start-up (C:\WINNT\Profiles\All Users\Start Menu\Programs\Startup) directory. This file includes the JDBC:OBDC driver that Siteware uses to communicate with MS SQL Server. Make sure you install this in the default directory.
When you order news from Screaming Media, you specify filters describing the type of news you want, industry segments, keywords and so forth. Each filter becomes a feed that has its own configuration files specifying field delimiter characters, escape character policies, headers and footers. Siteware "wakes up" every 15 minutes and pulls your feeds off the Screaming Media servers. It then processes the feeds in one of four ways as Hclient, DBClient, fClient or pClient.
If you're running MS SQL server or have access to a JDBC driver for your favorite database, using the DBClient database insertion method is a no-brainer (tell Screaming Media this is how you want Siteware set up). The Hclient method is quite interesting since it will write content into templates using variable substitution. Once we build our Screaming Media News object type, we could create a sample object and use it as a prototype template for use with this method. Since databases are more flexible than flat files, I've chosen to use DBClient for my own installation. fClient and pClient can also write out delimited text files but you need to parse them and process them yourself - no fun.
To store Screaming Media content temporarily, you'll need to create a table in your SQL database with the columns listed in Table 1.
I've set up a DSN in the ODBC administrator called "SyndicatedContent" that points to my "SyndicatedContent" database and defaults to the "ScreamingContent" table.
If you're getting sports scores from Screaming Media, you'll need to add additional fields to your ScreamingContent table or create a new table ("ScreamingSportsContent," perhaps!). For more information on sports scores, contact Screaming Media directly.
Screaming Media's technical staff will edit Siteware's configuration files to match the DSN and table names you've created. Extract the *.zip file they send you and run siteware.bat (located in the IMDSJServer/bin directory) from the command prompt. When you see two "SUCCESS" prompts and a blinking cursor beneath, Siteware has initialized successfully and has begun dumping content into your database. Look into your database table and you'll see the stories that meet your filter criteria.
The next step is moving the content from the syndication table into Spectra. The first thing we need to do is create a ScreamingNews object type that defines how the data will be stored in the Spectra database. This requires some "data modeling" in the Webtop. After logging in under the admin account, go to System Design > Site Object Designer > Property Definitions and create the properties in Table 2.
I've added the bCleaned property to those in the database as a flag to denote whether the default text has been reviewed to clean up any formatting inconsistencies from the feed. I also added properties that allow me to bind photographs to ScreamingNews objects. You can license photos from several places on the Internet including Reuters and the Associated Press. Spectra ships with a "core" system object type IMAGE (70E7DFB6-A67E-11D2-B3AC00C04FA35A23) that you can define as an embedded property in any object type. We'll embed an IMAGE property into the news article as well as provide a vertical alignment control variable and useimage flag.
Once the properties are created, you can actually create the object type itself (you must follow this sequence). Go to the Type Designer, create a new object type called "ScreamingNews" and map in the property definitions as indicated. Then add the method handlers given in Table 3.
Note that we didn't include "create", "edit" and "delete" methods as they are implicit and use the default handlers. If you write any of them yourself, write the edit handler - the default is quite ugly. There's no special "create" or "delete" functionality required, so there's no need to declare these methods and write your own handlers. Beware of the embedded image object - implementing embedded objects in handlers is an "advanced" skill.
This is public news, so there aren't any permissions on this object type. Applying permissions in Spectra slow down the application considerably - less so for object types than for objects themselves. Caching permissions in the CF administrator is virtually essential.
The last step in getting the data into the object store is to build the handler, syndicate_import.cfm, that manages the process (see Listing 1). This handler is nothing more than a simple query against your syndicated content database, and a loop that copies the data into the Spectra object store and then updates the foreign key in the syndicated content database. It then calls a cleanup routine to mark articles older than 30 days as "inactive" and "archived" since it's illegal for you to keep them around. Note that we've created but not coded syndicate_push and syndicate_pull. These method handlers are used at a later time to manage syndication directly between Spectra servers in the organization or with partners (you'll need to discuss licensing with Screaming Media, of course).
You can test the handler in Listing 1 by calling it from a dummy page with the following code:
objectid="Put a test object ID in here"
The syndication stream invoker (which we'll call next) doesn't care that syndicate_import doesn't require an ObjectID; however, CFA_ContentObject does care so we need to provide a dummy ObjectID in our testing code.
Once you see that this handler is working properly, you need to set up a schedule in Webtop to call it every few minutes. In System Design > Programming Objects > Syndication Streams you can easily add an event to run the syndicate_import method every 15 minutes or at whatever polling interval you've established in Siteware (see Figure 2).
While Screaming Media does channel its content providers' various feed formats into the fields listed above, providers format their stories differently so it's strongly suggested that you edit each article within Spectra prior to posting it on your site. You can see the results of your hard work in the Webtop object finder (see Figure 3).
Sample handler code and the content object types I created above are available in their entirety on the CFDJ Web site and may be installed all at once using the Spectra object type package install function. You'll also want to check the Allaire Tag Gallery and/or the Screaming Media Web site for the latest code as Screaming Media, along with other content providers, has become increasingly interested in the Spectra platform as a turnkey content subscriber and publishing solution.
Conclusion and Next Steps
In this article I've described some of the "heavy lifting" you'll need to perform to get syndicated content into your Spectra object store. Since object type definitions and properly coded handlers are reusable, you won't need to start from scratch; use and modify the source code provided here at your discretion.
It won't be long before syndicated content providers are cognizant of the huge installed base of Spectra servers. When that occurs, they may give you the ability to pull content directly into your Spectra servers by providing it over HTTP in the appropriate format. When this happens, you'll download and install an object type definition file from the content provider and set up a syndication stream handler that polls their database every so often for your content. Alternatively, they could push content directly to Spectra through the remote method invoker interface after you provide them with the appropriate username and password, your IP address and any other default values you care about (e.g., don't publish this article until I see it first!). In these scenarios you may use a syndicate_pull or syndicate_push method handler rather than the kludgy but functional syndicate_import routine provided here.
As a premium service, content providers may also map their metadata keywords to ones you provide, actually marking up the content with metadata before sending it over. They might even write Spectra news-viewer applications that use the content object types they provide. What better way to get you started with their content fast!
Syndicating graphics is going to be a bit more difficult, but easier with ColdFusion 4.5's new facilities for Base 64 encoding. For now, write or use default handlers that bind your downloaded graphics separately to articles you've syndicated and are ready to publish.
In the next article we'll explore how the Spectra syndication API allows transparent syndication of content and applications between Spectra servers.
- Where Are RIA Technologies Headed in 2008?
- The Next Programming Models, RIAs and Composite Applications
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Constructing an Application with Flash Forms from the Ground Up
- Building a Zip Code Proximity Search with ColdFusion
- Personal Branding Checklist
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Has the Technology Bounceback Begun?
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- Adobe Flex 2: Advanced DataGrid
- Cloud People: A Who's Who of Cloud Computing
- Web Services Using ColdFusion and Apache CXF