本文整理汇总了Java中org.apache.jackrabbit.webdav.DavServletResponse类的典型用法代码示例。如果您正苦于以下问题:Java DavServletResponse类的具体用法?Java DavServletResponse怎么用?Java DavServletResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DavServletResponse类属于org.apache.jackrabbit.webdav包,在下文中一共展示了DavServletResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshLock
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
@Override
public ActiveLock refreshLock( LockInfo lockInfo, String lockToken )
throws DavException
{
if ( !exists() )
{
throw new DavException( DavServletResponse.SC_NOT_FOUND );
}
ActiveLock lock = getLock( lockInfo.getType(), lockInfo.getScope() );
if ( lock == null )
{
throw new DavException( DavServletResponse.SC_PRECONDITION_FAILED,
"No lock with the given type/scope present on resource " + getResourcePath() );
}
lock = lockManager.refreshLock( lockInfo, lockToken, this );
return lock;
}
示例2: unlock
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
@Override
public void unlock( String lockToken )
throws DavException
{
ActiveLock lock = getLock( Type.WRITE, Scope.EXCLUSIVE );
if ( lock == null )
{
throw new DavException( HttpServletResponse.SC_PRECONDITION_FAILED );
}
else if ( lock.isLockedByToken( lockToken ) )
{
lockManager.releaseLock( lockToken, this );
}
else
{
throw new DavException( DavServletResponse.SC_LOCKED );
}
}
示例3: testDeleteNonExistantResourceShould404
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
@Test
public void testDeleteNonExistantResourceShould404()
throws Exception
{
File dir = new File( baseDir, "testdir" );
try
{
DavResource directoryResource = getDavResource( "/testdir", dir );
directoryResource.getCollection().removeMember( directoryResource );
fail( "Did not throw DavException" );
}
catch ( DavException e )
{
assertEquals( DavServletResponse.SC_NOT_FOUND, e.getErrorCode() );
}
}
示例4: testRefreshLockThrowsExceptionIfNoLockIsPresent
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
@Test
public void testRefreshLockThrowsExceptionIfNoLockIsPresent()
throws Exception
{
LockInfo info = new LockInfo( Scope.EXCLUSIVE, Type.WRITE, "/", 0, false );
assertEquals( 0, resource.getLocks().length );
try
{
lockManager.refreshLock( info, "notoken", resource );
fail( "Did not throw dav exception" );
}
catch ( DavException e )
{
assertEquals( DavServletResponse.SC_PRECONDITION_FAILED, e.getErrorCode() );
}
assertEquals( 0, resource.getLocks().length );
}
示例5: testUnlockThrowsDavExceptionIfNotLocked
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
@Test
public void testUnlockThrowsDavExceptionIfNotLocked()
throws Exception
{
LockInfo info = new LockInfo( Scope.EXCLUSIVE, Type.WRITE, "/", 0, false );
assertEquals( 0, resource.getLocks().length );
lockManager.createLock( info, resource );
assertEquals( 1, resource.getLocks().length );
try
{
lockManager.releaseLock( "BLAH", resource );
fail( "Did not throw DavException" );
}
catch ( DavException e )
{
assertEquals( DavServletResponse.SC_LOCKED, e.getErrorCode() );
}
assertEquals( 1, resource.getLocks().length );
}
示例6: testUnlockThrowsDavExceptionIfResourceNotLocked
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
@Test
public void testUnlockThrowsDavExceptionIfResourceNotLocked()
throws Exception
{
assertEquals( 0, resource.getLocks().length );
try
{
lockManager.releaseLock( "BLAH", resource );
fail( "Did not throw DavException" );
}
catch ( DavException e )
{
assertEquals( DavServletResponse.SC_PRECONDITION_FAILED, e.getErrorCode() );
}
assertEquals( 0, resource.getLocks().length );
}
示例7: processResponseBody
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
/**
* Overridden to process the sync-token. Adapted from DavMethodBase.
*
* @see DavMethodBase#processResponseBody(HttpState, HttpConnection)
*/
@Override
protected void processResponseBody(HttpState httpState, HttpConnection httpConnection) {
if (getStatusCode() == DavServletResponse.SC_MULTI_STATUS) {
try {
Document document = getResponseBodyAsDocument();
if (document != null) {
synctoken = DomUtil.getChildText(document.getDocumentElement(), SyncReportInfo.XML_SYNC_TOKEN, DavConstants.NAMESPACE);
log.info("Sync-Token for REPORT: " + synctoken);
multiStatus = MultiStatus.createFromXml(document.getDocumentElement());
processMultiStatusBody(multiStatus, httpState, httpConnection);
}
} catch (IOException e) {
log.error("Error while parsing sync-token.", e);
setSuccess(false);
}
}
}
示例8: move
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
@Override
public void move( @Nullable DavResource destination ) throws DavException {
// todo check on path
// if( !( file instanceof Renameable ) ) {
// throw new DavException( DavServletResponse.SC_FORBIDDEN );
// }
if( !exists() ) {
throw new DavException( DavServletResponse.SC_NOT_FOUND );
}
try {
Files.move( file, ( checkPath( destination ) ).file );
} catch( IOException e ) {
throw new DavException( DavServletResponse.SC_FORBIDDEN );
}
}
示例9: copy
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
@Override
public void copy( @Nullable DavResource destination, boolean shallow ) throws DavException {
// todo folders ?
// todo shallow
if( !exists() ) {
throw new DavException( DavServletResponse.SC_NOT_FOUND );
}
// if( !( destination instanceof DavPath ) ) {
// throw new UnsupportedOperationException( "can't copy to resource outside: " + destination );
// }
try {
Files.copy( file, checkPath( destination ).file );
} catch( IOException e ) {
throw new DavException( DavServletResponse.SC_FORBIDDEN );
}
}
示例10: removeMember
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
@Override
public void removeMember( @Nullable DavResource member ) throws DavException {
if( isDirectory ) {
if( !exists() ) {
throw new DavException( DavServletResponse.SC_NOT_FOUND );
}
DavPath davPath = checkPath( member );
try {
Pathss.deleteRecursive( davPath.file );
} catch( Exception e ) {
throw new DavException( DavServletResponse.SC_FORBIDDEN, e );
}
} else {
throw new UnsupportedOperationException( "Not implemented" );
}
}
示例11: removeMember
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
@Override
public void removeMember(DavResource resource) throws DavException {
final AbstractDavResource cassandraResource = (AbstractDavResource) resource;
final String path = cassandraResource.getPath();
if (path.equals("/")) {
return;
}
if (cassandraResource.isCollection()) {
final List<String> siblings = getCassandraService().getSiblings(path);
if (!siblings.isEmpty()) {
throw new DavException(DavServletResponse.SC_CONFLICT, "You cannot delete collection with content");
}
getCassandraService().deleteDirectory(path);
} else {
getFileStorageService().deleteFile(path);
}
}
示例12: createFile
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
public void createFile(final String fullFilePath, final InputContext inputContext) throws DavException {
if (cassandraDao.getFile(fullFilePath) != null) {
throw new DavException(DavServletResponse.SC_CONFLICT);
}
final String parentDirectory = getParentDirectory(fullFilePath);
final String fileName = PathUtils.getFileName(fullFilePath);
final UUID parentId = cassandraDao.getFile(parentDirectory);
try {
final UUID fileUUID = cassandraFileDao.createFile(parentId, fileName);
if (inputContext.hasStream() && inputContext.getContentLength() >= 0) {
final CountingInputStream countingInputStream = new CountingInputStream(inputContext.getInputStream());
cassandraFileDao.writeFile(fileUUID, countingInputStream);
cassandraFileDao.updateFileInfo(fileUUID, countingInputStream.getCount());
}
} catch (ConnectionException e) {
throw new RuntimeException(e);
}
}
示例13: RegistryResource
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
public RegistryResource(RegistryWebDavContext webdavContext,
DavResourceLocator locator) throws DavException {
this.registry = webdavContext.getRegistry();
if(registry == null){
throw new DavException(DavServletResponse.SC_FORBIDDEN, "Registry Not Found");
}
this.locator = locator;
this.resourceCache = webdavContext;
String path = locator.getResourcePath();
if(path.startsWith("/registry/resourcewebdav")){
path = path.substring("/registry/resourcewebdav".length());
}
if(path.trim().length() == 0){
path = "/";
}
this.path = path.trim();
//this.session = session;
}
示例14: refreshLock
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
public ActiveLock refreshLock(LockInfo lockInfo, String lockToken) throws DavException{
if(lockable){
if (!exists()) {
throw new DavException(DavServletResponse.SC_NOT_FOUND);
}
ActiveLock lock = getLock(lockInfo.getType(), lockInfo.getScope());
if (lock == null) {
throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No lock with the given type/scope present on resource " + getResourcePath());
}
lock = lockManager.refreshLock(lockInfo, lockToken, this);
/* since lock has infinite lock (simple) or undefined timeout (jcr)
return the lock as retrieved from getLock. */
return lock;
}else{
throw new UnsupportedOperationException();
}
}
示例15: alterProperties
import org.apache.jackrabbit.webdav.DavServletResponse; //导入依赖的package包/类
public MultiStatusResponse alterProperties(List changeList)
throws DavException {
if (!exists()) {
throw new DavException(DavServletResponse.SC_NOT_FOUND);
}
MultiStatusResponse msr = new MultiStatusResponse(getHref(), null);
Iterator it = changeList.iterator();
while(it.hasNext()){
DavProperty property = (DavProperty)it.next();
try{
getUnderlineResource().setProperty(property.getName().getName(), (String)property.getValue());
msr.add(property, DavServletResponse.SC_OK);
}catch (Exception e) {
e.printStackTrace();
msr.add(property, DavServletResponse.SC_BAD_REQUEST);
}
}
return msr;
}