private void processUpdate(IFile selectedFile) {
IResponse response = null;
try {
GuvnorMetadataProps props = GuvnorMetadataUtils.getGuvnorMetadata(selectedFile);
IWebDavClient client = WebDavServerCache.getWebDavClient(props.getRepository());
if (client == null) {
client = WebDavClientFactory.createClient(new URL(props.getRepository()));
WebDavServerCache.cacheWebDavClient(props.getRepository(), client);
}
InputStream ins = null;
try {
response = client.getResourceInputStream(props.getFullpath());
ins = response.getInputStream();
} catch (WebDavException wde) {
if (wde.getErrorCode() != IResponse.SC_UNAUTHORIZED) {
// If not an authentication failure, we don't know what to do with it
throw wde;
}
boolean retry = PlatformUtils.getInstance().
authenticateForServer(props.getRepository(), client);
if (retry) {
response = client.getResourceInputStream(props.getFullpath());
ins = response.getInputStream();
}
}
if (ins != null) {
selectedFile.setContents(ins, true, true, null);
GuvnorMetadataUtils.markCurrentGuvnorResource(selectedFile);
ResourceProperties resProps = client.queryProperties(props.getFullpath());
GuvnorMetadataProps mdProps = GuvnorMetadataUtils.getGuvnorMetadata(selectedFile);
mdProps.setVersion(resProps.getLastModifiedDate());
mdProps.setRevision(resProps.getRevision());
GuvnorMetadataUtils.setGuvnorMetadataProps(selectedFile.getFullPath(), mdProps);
}