mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Implemented Delete Document API for remote AVM store (repo-tier) and remote store client (web-tier).
Fixed and added APIs to bind and unbind components in web-tier object model - mirrored API methods for "sitedata" JS API. - this completes the working APIs needed to add/remove pages and add/remove/modify component bindings to facilitate user dashboard configuration and site page configuration. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9716 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
<webscript>
|
||||||
|
<shortname>Remote AVM Store</shortname>
|
||||||
|
<description>Remote service mirroring the Store interface - to an AVM store</description>
|
||||||
|
<url>/remotestore/{method}/{path}</url>
|
||||||
|
<authentication>admin</authentication>
|
||||||
|
<format default="">argument</format>
|
||||||
|
</webscript>
|
@@ -210,13 +210,18 @@
|
|||||||
<property name="rootPath"><value>alfresco</value></property>
|
<property name="rootPath"><value>alfresco</value></property>
|
||||||
<property name="store"><value>sitestore</value></property>
|
<property name="store"><value>sitestore</value></property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="webscript.org.alfresco.repository.store.remoteavm.post" class="org.alfresco.repo.web.scripts.bean.AVMRemoteStore" parent="webscript">
|
<bean id="webscript.org.alfresco.repository.store.remoteavm.post" class="org.alfresco.repo.web.scripts.bean.AVMRemoteStore" parent="webscript">
|
||||||
<property name="mimetypeService" ref="MimetypeService" />
|
<property name="mimetypeService" ref="MimetypeService" />
|
||||||
<property name="avmService" ref="AVMService" />
|
<property name="avmService" ref="AVMService" />
|
||||||
<property name="rootPath"><value>alfresco</value></property>
|
<property name="rootPath"><value>alfresco</value></property>
|
||||||
<property name="store"><value>sitestore</value></property>
|
<property name="store"><value>sitestore</value></property>
|
||||||
</bean>
|
</bean>
|
||||||
|
<bean id="webscript.org.alfresco.repository.store.remoteavm.delete" class="org.alfresco.repo.web.scripts.bean.AVMRemoteStore" parent="webscript">
|
||||||
|
<property name="mimetypeService" ref="MimetypeService" />
|
||||||
|
<property name="avmService" ref="AVMService" />
|
||||||
|
<property name="rootPath"><value>alfresco</value></property>
|
||||||
|
<property name="store"><value>sitestore</value></property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- Activity Feed Web Scripts -->
|
<!-- Activity Feed Web Scripts -->
|
||||||
|
@@ -252,6 +252,30 @@ public class AVMRemoteStore extends BaseRemoteStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.web.scripts.bean.BaseRemoteStore#deleteDocument(org.alfresco.web.scripts.WebScriptResponse, java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void deleteDocument(WebScriptResponse res, String path)
|
||||||
|
{
|
||||||
|
String avmPath = buildAVMPath(path);
|
||||||
|
AVMNodeDescriptor desc = this.avmService.lookup(-1, avmPath);
|
||||||
|
if (desc == null)
|
||||||
|
{
|
||||||
|
res.setStatus(Status.STATUS_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.avmService.removeNode(avmPath);
|
||||||
|
}
|
||||||
|
catch (AccessDeniedException ae)
|
||||||
|
{
|
||||||
|
res.setStatus(Status.STATUS_UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.web.scripts.bean.BaseRemoteStore#listDocuments(org.alfresco.web.scripts.WebScriptResponse, java.lang.String, boolean)
|
* @see org.alfresco.repo.web.scripts.bean.BaseRemoteStore#listDocuments(org.alfresco.web.scripts.WebScriptResponse, java.lang.String, boolean)
|
||||||
*/
|
*/
|
||||||
|
@@ -63,7 +63,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
* For content create and update the request should be POSTed and the content sent as the
|
* For content create and update the request should be POSTed and the content sent as the
|
||||||
* payload of the request content.
|
* payload of the request content.
|
||||||
*
|
*
|
||||||
* Supported method API:
|
* Supported API methods:
|
||||||
* GET lastmodified -> return long timestamp of a document
|
* GET lastmodified -> return long timestamp of a document
|
||||||
* GET has -> return true/false of existence for a document
|
* GET has -> return true/false of existence for a document
|
||||||
* GET get -> return document content - in addition the usual HTTP headers for the
|
* GET get -> return document content - in addition the usual HTTP headers for the
|
||||||
@@ -72,6 +72,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
* GET listall -> return the list of available document paths (recursively) under a given path
|
* GET listall -> return the list of available document paths (recursively) under a given path
|
||||||
* POST create -> create a new document with request content payload
|
* POST create -> create a new document with request content payload
|
||||||
* POST update -> update an existing document with request content payload
|
* POST update -> update an existing document with request content payload
|
||||||
|
* DELETE delete -> delete an existing document
|
||||||
*
|
*
|
||||||
* @author Kevin Roast
|
* @author Kevin Roast
|
||||||
*/
|
*/
|
||||||
@@ -148,26 +149,17 @@ public abstract class BaseRemoteStore extends AbstractWebScript
|
|||||||
switch (method)
|
switch (method)
|
||||||
{
|
{
|
||||||
case LASTMODIFIED:
|
case LASTMODIFIED:
|
||||||
if (path == null)
|
validatePath(path);
|
||||||
{
|
|
||||||
throw new WebScriptException("Remote Store expecting document path.");
|
|
||||||
}
|
|
||||||
lastModified(res, path);
|
lastModified(res, path);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HAS:
|
case HAS:
|
||||||
if (path == null)
|
validatePath(path);
|
||||||
{
|
|
||||||
throw new WebScriptException("Remote Store expecting document path.");
|
|
||||||
}
|
|
||||||
hasDocument(res, path);
|
hasDocument(res, path);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GET:
|
case GET:
|
||||||
if (path == null)
|
validatePath(path);
|
||||||
{
|
|
||||||
throw new WebScriptException("Remote Store expecting document path.");
|
|
||||||
}
|
|
||||||
getDocument(res, path);
|
getDocument(res, path);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -179,20 +171,19 @@ public abstract class BaseRemoteStore extends AbstractWebScript
|
|||||||
listDocuments(res, path, true);
|
listDocuments(res, path, true);
|
||||||
|
|
||||||
case CREATE:
|
case CREATE:
|
||||||
if (path == null)
|
validatePath(path);
|
||||||
{
|
|
||||||
throw new WebScriptException("Remote Store expecting document path.");
|
|
||||||
}
|
|
||||||
createDocument(res, path, httpReq.getInputStream());
|
createDocument(res, path, httpReq.getInputStream());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPDATE:
|
case UPDATE:
|
||||||
if (path == null)
|
validatePath(path);
|
||||||
{
|
|
||||||
throw new WebScriptException("Remote Store expecting document path.");
|
|
||||||
}
|
|
||||||
updateDocument(res, path, httpReq.getInputStream());
|
updateDocument(res, path, httpReq.getInputStream());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DELETE:
|
||||||
|
validatePath(path);
|
||||||
|
deleteDocument(res, path);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException enumErr)
|
catch (IllegalArgumentException enumErr)
|
||||||
@@ -204,6 +195,17 @@ public abstract class BaseRemoteStore extends AbstractWebScript
|
|||||||
throw new WebScriptException("Error during remote store API: " + ioErr.getMessage());
|
throw new WebScriptException("Error during remote store API: " + ioErr.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate we have a path argument.
|
||||||
|
*/
|
||||||
|
private static void validatePath(String path)
|
||||||
|
{
|
||||||
|
if (path == null)
|
||||||
|
{
|
||||||
|
throw new WebScriptException("Remote Store expecting document path elements.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to break down webscript extension path into path component elements
|
* Helper to break down webscript extension path into path component elements
|
||||||
@@ -246,7 +248,7 @@ public abstract class BaseRemoteStore extends AbstractWebScript
|
|||||||
* @param path document path
|
* @param path document path
|
||||||
* @return
|
* @return
|
||||||
*
|
*
|
||||||
* @throws IOException if the document does not exist in the store
|
* @throws IOException if an error occurs retrieving the document
|
||||||
*/
|
*/
|
||||||
protected abstract void getDocument(WebScriptResponse res, String path)
|
protected abstract void getDocument(WebScriptResponse res, String path)
|
||||||
throws IOException;
|
throws IOException;
|
||||||
@@ -260,7 +262,7 @@ public abstract class BaseRemoteStore extends AbstractWebScript
|
|||||||
* @param path document path
|
* @param path document path
|
||||||
* @param recurse true to peform a recursive list, false for direct children only.
|
* @param recurse true to peform a recursive list, false for direct children only.
|
||||||
*
|
*
|
||||||
* @throws IOException if the path does not exist in the store
|
* @throws IOException if an error occurs listing the documents
|
||||||
*/
|
*/
|
||||||
protected abstract void listDocuments(WebScriptResponse res, String path, boolean recurse)
|
protected abstract void listDocuments(WebScriptResponse res, String path, boolean recurse)
|
||||||
throws IOException;
|
throws IOException;
|
||||||
@@ -271,7 +273,7 @@ public abstract class BaseRemoteStore extends AbstractWebScript
|
|||||||
* @param path document path
|
* @param path document path
|
||||||
* @param content content of the document to write
|
* @param content content of the document to write
|
||||||
*
|
*
|
||||||
* @throws IOException if the document already exists or the create fails
|
* @throws IOException if the create fails
|
||||||
*/
|
*/
|
||||||
protected abstract void createDocument(WebScriptResponse res, String path, InputStream content);
|
protected abstract void createDocument(WebScriptResponse res, String path, InputStream content);
|
||||||
|
|
||||||
@@ -281,13 +283,22 @@ public abstract class BaseRemoteStore extends AbstractWebScript
|
|||||||
* @param path document path
|
* @param path document path
|
||||||
* @param content content to update the document with
|
* @param content content to update the document with
|
||||||
*
|
*
|
||||||
* @throws IOException if the document does not exist or the update fails
|
* @throws IOException if the update fails
|
||||||
*/
|
*/
|
||||||
protected abstract void updateDocument(WebScriptResponse res, String path, InputStream content);
|
protected abstract void updateDocument(WebScriptResponse res, String path, InputStream content);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes an existing document.
|
||||||
|
*
|
||||||
|
* @param path document path
|
||||||
|
*
|
||||||
|
* @throws IOException if the delete fails
|
||||||
|
*/
|
||||||
|
protected abstract void deleteDocument(WebScriptResponse res, String path);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum representing the API method on the Store.
|
* Enum representing the available API methods on the Store.
|
||||||
*/
|
*/
|
||||||
private enum APIMethod
|
private enum APIMethod
|
||||||
{
|
{
|
||||||
@@ -297,6 +308,7 @@ public abstract class BaseRemoteStore extends AbstractWebScript
|
|||||||
LIST,
|
LIST,
|
||||||
LISTALL,
|
LISTALL,
|
||||||
CREATE,
|
CREATE,
|
||||||
UPDATE
|
UPDATE,
|
||||||
|
DELETE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user