private String findAcceptableName(String baseName, String ext, int i) throws ConflictException, NotAuthorizedException, BadRequestException { String candidateName = baseName + "_" + i; if (ext != null && ext.length() > 0) { candidateName += "." + ext; } if (wrapped.child(candidateName) == null) { return candidateName; } else { if (i < 100) { return findAcceptableName(baseName, ext, i + 1); } else { log.warn("Too many files with similar names: " + candidateName); throw new ConflictException(this); } } }
} catch (ConflictException e) { log.warn("ConflictException", e); errorMessage = "Conflict: " + e.getMessage();
} catch (ConflictException ex) { log.warn("conflictException: ", ex); manager.getResponseHandler().respondConflict(ex.getResource(), response, request, INTERNAL_SERVER_ERROR_HTML); } catch (NotAuthorizedException ex) { log.warn("NotAuthorizedException", ex);
public String processForm( Map<String, String> parameters, Map<String, FileItem> files ) throws BadRequestException, NotAuthorizedException { String destHeader = parameters.get( "destination"); String dest = Utils.decodePath(destHeader); Path pDest = Path.path( dest ); Resource rDestParent = resourceFactory.getResource( host, pDest.getParent().toString()); if( rDestParent == null ) throw new BadRequestException( wrapped, "The destination parent does not exist"); if(rDestParent instanceof CollectionResource ) { CollectionResource colDestParent = (CollectionResource) rDestParent; if( colDestParent.child( pDest.getName()) == null ) { try { wrapped.copyTo( colDestParent, pDest.getName() ); } catch( ConflictException ex ) { log.warn( "Exception copying to: " + pDest.getName(), ex); throw new BadRequestException( rDestParent, "conflict: " + ex.getMessage()); } return null; } else { log.warn( "destination already exists: " + pDest.getName()); throw new BadRequestException( rDestParent, "File already exists"); } } else { throw new BadRequestException( wrapped, "The destination parent is not a collection resource"); } }
if (!autoname) { log.warn("Conflict: Can't create resource with name " + initialName + " because it already exists. To rename automatically use request parameter: " + PARAM_AUTONAME + ", or to overwrite use " + PARAM_OVERWRITE); throw new ConflictException(this); } else { log.trace("file exists and autoname is set, so will find acceptable name");
} catch( ConflictException ex ) { log.warn( "Exception copying to: " + pDest.getName(), ex); throw new BadRequestException( rDestParent, "conflict: " + ex.getMessage());
void process() throws ConflictException, NotAuthorizedException, BadRequestException { String relFolder = sFolder.substring( 1 ); Path p = Path.path( relFolder ); Resource r = find( wrappedResource, p ); if( r instanceof CollectionResource ) { target = (CollectionResource) r; } else { log.warn("not found or not CollectionResource: " + r); } if( target == null ) { log.warn( "No PutableResource with that path: " + sFolder ); throw new BadRequestException( "Path not found: " + sFolder ); } try { if( command.equals( "GetFolders" ) ) { processGetFoldersCommand( false ); } else if( command.equals( "GetFoldersAndFiles" ) ) { processGetFoldersCommand( true ); } else if( command.equals( "CreateFolder" ) ) { processCreateFolderCommand(); } else if( command.equals( "FileUpload" ) ) { processUploadFolderCommand(); } else { log.warn( "Unknown command: " + command ); throw new ConflictException( target ); } } finally { writer.flush(); } }
throw new ConflictException( target ); } else { log.warn("The collection is not putable: " + r.getName() + " - " + r.getClass().getCanonicalName()); throw new ConflictException( r );
} else { log.warn("Couldnt delete child resource: " + rChild.getName() + " of type; " + rChild.getClass().getName() + " because it does not implement: " + DeletableResource.class.getCanonicalName()); throw new ConflictException(rChild);
throw new MethodNotAllowedException(result, href); case 409: throw new ConflictException(href); default: throw new GenericHttpException(result, href);