nodeRefs = searchService.selectNodes(storeRootNodeRef, rootPath, null, namespaceService, false);
if (nodeRefs.size() > 1)
{
throw new RuntimeException("Multiple possible children for : \n" + " path: " + rootPath + "\n" + " results: " + nodeRefs);
}
else if (nodeRefs.size() == 0)
{
throw new RuntimeException("Node is not found for : \n" + " root path: " + rootPath);
}
defaultRootNode = nodeRefs.get(0);
// Commit the transaction
if (tx != null)
tx.commit();
}
catch (Exception ex)
{
logger.error(ex);
}
finally
{
// Clear the current system user
authComponent.clearCurrentSecurityContext();
}
}
/**
*
* @return root node for WebDAV
*/
public static NodeRef getWebdavRootNode()
{
return getRootNodeRef();
}
/**
* Bean to hold injected initialization parameters.
*
* @author Derek Hulley
* @since V3.5 Team
*/
public static class WebDAVInitParameters
{
private boolean enabled = false;
private String storeName;
private String rootPath;
private String urlPathPrefix;
public boolean getEnabled()
{
return enabled;
}
public void setEnabled(boolean enabled)
{
this.enabled = enabled;
}
/**
* @return Returns the name of the store
* @throws ServletException if the store name was not set
*/
public String getStoreName() throws ServletException
{
if (!PropertyCheck.isValidPropertyString(storeName))
{
throw new ServletException("WebDAV missing 'storeName' value.");
}
return storeName;
}
public void setStoreName(String storeName)
{
this.storeName = storeName;
}
/**
* @return Returns the WebDAV root path within the store
* @throws ServletException if the root path was not set
*/
public String getRootPath() throws ServletException
{
if (!PropertyCheck.isValidPropertyString(rootPath))
{
throw new ServletException("WebDAV missing 'rootPath' value.");
}
return rootPath;
}
public void setRootPath(String rootPath)
{
this.rootPath = rootPath;
}
/**
* Get the path prefix that generated URLs should exhibit, e.g.
*
* http://server.name<prefix>/path/to/file.txt
*
* In the default set up this would be of the form /context-path/servlet-name e.g. /alfresco/webdav:
*
* http://server.name/alfresco/webdav/path/to/file.txt
*
* however if using URL rewriting rules or a reverse proxy in front of the webdav server
* you may choose to use, for example / for shorter URLs.
*
* http://server.name/path/to/file.txt
*
*
* Leaving this property blank will cause the prefix used to be /context-path/servlet-name
*
* @return the urlPathPrefix
*/
public String getUrlPathPrefix()
{
return urlPathPrefix;
}
/**
* See {@link #getUrlPathPrefix()}
*
* @param urlPathPrefix String
*/
public void setUrlPathPrefix(String urlPathPrefix)
{
this.urlPathPrefix = urlPathPrefix;
}
}
}