Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
I used to think that a Camel was something to smoke or ride in the desert, but that was before I opened my mouth at work one day and said, "Sure I can automatically save these documents up to SharePoint." SharePoint has been around for a long time, so I assumed that there must be a Java API or possibly some exposed web services that I could consume. Well, as it turns out I did get the job done, and as with many things it ended better than it started. But there were quite a few hurdles along the way, which I'd like to help other JavaWorld readers avoid.
In this Java tip I'll show you how to perform basic CRUD operations on a SharePoint document folder from a Java client. The demonstration
will focus on some of the more popular methods that any SharePoint web service consumer is likely to invoke, which are found
in Microsoft's Copy and Lists services. For the CRUD operations we'll use CAML (Collaborative Application Markup Language), an XML-based language utilized in many of the methods exposed by
Lists. You'll learn how to construct valid CAML structures that are passed as method parameters or assigned to object properties,
which are in turn passed as parameters to these services.
Hopefully, this tip will convince you that there are CAMLs that you can use to get business documents from point A to point B, without relying on four legs and a hump.
My demonstration code is very simple: I've used no open source code other than for logging and my implementation has no dependencies on Java EE technology, so you can run the source code directly from Eclipse in a standard Java application.
I work in a group that performs information management for large volumes of data that eventually is housed in various data-marts (service, export, report, and so on). Consumers, both internal and external to the company, consume the data in order to make business and personal decisions. Various kinds of monitoring take place in this environment, including automated audits and reports that are run against the data housed in data-marts. Audits ensure that data is in a consistent state, both across marts and within the mart where it resides. Audit reports are emailed to various people and then manually saved on SharePoint.
Because the engines used for monitoring have a pluggable output writer concept, it was natural to consider setting up a writer for SharePoint. We already were writing to the database, SMTP servers, and a file system, so this seemed like a logical next step and a way to avoid the manual process.
The trick, of course, was making it all work.
The sample application for this article demonstrates how to communicate with SharePoint from a Java client. I wrote the application using Eclipse 3.6.2 and Java 1.6.0_32. Figure 1 shows the two main packages contained within the sample application.
The first package,
com.jw.sharepoint.examples, contains all the custom code for the solution. It uses the code contained in the
com.microsoft.sharepoint.webservices package, which was code-generated.
cacertsfile is updated with the site's trusted certificate.