SPResourceNode theNode = getNodeFromServer(aFile);
if (theNode == null) { //try to create a new node in Server
if (! inCache(aFile.getParentFile()) ) {
throw new HttpException("Bad File Path: "+aFile.getParent());
}
SPWebFolder parentDir = (SPWebFolder)
getNodeFromCache((SPFile) aFile.getParentFile());
String parentUrlPath = parentDir.getResourceUrlPath();
if (parentDir.hasWriteAccess()) {
SPWebFile newNode = new SPWebFile(client,
parentUrlPath+aFile.getName());
int statusCode = newNode.putFileContent("");
if ( statusCode == HttpStatus.SC_OK) {
parentDir.addWebFile(newNode);
this.fileCache.put(aFile, newNode);
theNode = (SPResourceNode) newNode;
}
} else {
throw new HttpException("Write Access Denied in "
+parentUrlPath+" ("+HttpStatus.SC_FORBIDDEN+")");
}
}
return theNode;