Skip to main content

Mixing SharePoint and Java

The primary development environment where I work is Java on Unix. However, we've started to move to SharePoint for collaborative development. If you've ever worked with SharePoint from the client side, typically you'll see something like this in your C# code:

someSharePointServiceWebReference.PreAuthenticate = true;
someSharePointServiceWebReference.Credentials = CredentialCache.DefaultCredentials;

Those two lines encompass a lot of activity behind the scenes. Essentially you're asking the .NET framework to authenticate you with an NTLM hash.

All is not lost if you want to do the same thing in Java. Version 3.0 of the Jakarta HttpClient can manage NTLMv1 authentication. Create an instance of org.apache.commons.httpclient.NTCredentials and you're set.

Storing files in a document library is pretty easy. Just use the HTTP "PUT" verb. About the only tricky part is determining the URL to pass to the PutMethod constructor. The URL has to be the URL of the document library plus the desired remote file name.

So, if you access a document library like this:
http://someserver/sites/somesite/Shared%20Documents/Forms/AllItems.aspx
and you want to put a Word doc called "Polices.doc" into it, the PUT URL is this:
http://someserver/sites/somesite/Shared%20Documents/Policies.doc

Next time I'll go over how to use Apache Axis to call a SharePoint webservice.

Comments

Popular posts from this blog

Initial Speech Recognition App

I'm pretty impressed with Microsoft's System.Speech API.  It took less than 3 days to throw together a proof-of-concept application.  The hardest part was probably coming up with the grammar -- documentation for that is pretty thin on the ground.

Anyways, here's the application source code on GitHub if anyone wants a look:
ObserverLengthSampler project

If nothing else, I'd recommend it as a starting point for someone needing a number recognition SRGS grammar in an XML format.

I guess Python isn't so bad after all...

Not wanting to hassle with learning OpenCV and fighting with an edit-compile-execute environment, I decided to use my OpenCV project as an excuse to play around with Python.

I'm still a serious beginner, but I'm beginning to understand why it gets the use it does.

Anyhow, it only took a couple of days to integrate Tesseract OCR, PIL, and OpenCV such that I could open multi-frame TIFF images, perform some basic feature detection, and then use the output of feature detection to focus on a specific region for OCR.

I will admit to having a few false starts.  The first was that I used an older (C++) tutorial that was using some deprecated features of OpenCV and ignoring some other features.  For example, the tutorial was using Hough Line detection to find squares on a printed page.  In order to get to that point there was thresholding, dilating, eroding, inversion, flood filling and so on.  Even then I wasn't getting the correct results.

When I started over, I was using the old…

Python and libpuzzle

As much as I've dogged on Python in the past (significant whitespace, really?), I've got to admit that it's
got some cool features too.

For example, I'm playing with libpuzzle (a library for visually comparing images).  It has a command line utility and a C and PHP API.  Unfortunately, the CLI utility doesn't allow one to dump the raw comparison vector, and it's a PITA to write C just to play with a library.

Python's native "ctypes" to the rescue!

from ctypes import * class PuzzleCvec(Structure): _fields_ = [("sizeof_vec", c_size_t), ("vec", c_char_p)] class PuzzleCompressedCvec(Structure): _fields_ = [("sizeof_compressed_vec", c_size_t), ("vec", c_char_p)] class PuzzleContext(Structure): _fields_ = [("puzzle_max_width", c_uint), ("puzzle_max_height", c_uint), ("puzzle_lambdas", c_uint), ("…