Package com.bradmcevoy.http.exceptions

Examples of com.bradmcevoy.http.exceptions.BadRequestException


      file.setParent(getKey(((FolderResource) toCollection).getFolder()));
      ofy.put(file);
      return;
    }
   
    throw new BadRequestException(this, "Cannot be copied to " + toCollection.toString());
  }
View Full Code Here


    log.info("get some fields to update/remove" + fields);
  }
 
  @Override
  public String processForm(Map<String, String> parameters, Map<String, FileItem> files) throws BadRequestException, NotAuthorizedException, ConflictException {
    throw new BadRequestException(this, "not implemented yet");
  }
View Full Code Here

    throw new NotAuthorizedException(rDest);
  }

  @Override
  public void copyTo(CollectionResource toCollection, String name) throws NotAuthorizedException, BadRequestException, ConflictException {
    throw new BadRequestException(this, "recursive copy is not supported yet");
  }
View Full Code Here

            org.jdom.Document doc = builder.build(request.getInputStream());
            String reportName = doc.getRootElement().getName();
            Report r = reports.get( reportName);
            if( r == null ) {
                log.error( "report not known: " + reportName );
                throw new BadRequestException( resource );
            } else {
                String xml = r.process( request.getHostHeader(), resource, doc );
                response.setStatus( Response.Status.SC_MULTI_STATUS );
                response.getOutputStream().write( xml.getBytes());
                response.getOutputStream().flush();
View Full Code Here

                } else {
                    if( target instanceof MakeCollectionableResource ) {
                        MakeCollectionableResource mk = (MakeCollectionableResource) target;
                        CollectionResource f = mk.createCollection( newFolderName );
                    } else {
                        throw new BadRequestException( target, "Folder does not allow creating subfolders" );
                    }
                    log.debug( "add new child ok" );
                    errNumber = 0;
                }
            } catch( Throwable e ) {
View Full Code Here

    }

    private void processFileUpload( FileItem f, Map<String, String> params ) throws BadRequestException {
        CollectionResource target = null;
        if( wrappedResource == null ) {
            throw new BadRequestException(this, "collection not found" );
        }
        target = (CollectionResource) wrappedResource.child( "uploads" );
        if( target == null ) {
            try {
                if( wrappedResource instanceof MakeCollectionableResource ) {
                    MakeCollectionableResource mk = (MakeCollectionableResource) wrappedResource;
                    target = mk.createCollection( "uploads" );
                } else {
                    throw new BadRequestException( target, "Cant create subfolder" );
                }
            } catch( ConflictException ex ) {
                throw new RuntimeException( ex );
            } catch( NotAuthorizedException ex ) {
                throw new RuntimeException( ex );
            } catch( BadRequestException ex ) {
                throw new RuntimeException( ex );
            }
        }

        String name = FileUtils.sanitiseName(f.getName() );
        log.debug( "processFileUpload: " + name );
        boolean isFirst = true;
        String newName = null;
        while( target.child( name ) != null ) {
            name = FileUtils.incrementFileName( name, isFirst );
            newName = name;
            isFirst = false;
        }

        long size = f.getSize();
        try {
            if( target instanceof PutableResource ) {
                PutableResource putable = (PutableResource) target;
                Resource newRes = putable.createNew( name, f.getInputStream(), size, null );
                if( newRes != null ) {
                    log.trace( "created: " + newRes.getName() + " of type: " + newRes.getClass() );
                } else {
                    log.trace( "createNew returned null" );
                }
            } else {
                throw new BadRequestException(target, "Does not implement PutableResource");
            }
        } catch( ConflictException ex ) {
            throw new RuntimeException( ex );
        } catch( NotAuthorizedException ex ) {
            throw new RuntimeException( ex );
View Full Code Here

                propertyBuilder.processResource(resps, cr, parseResult, href, 0, 0, href);
               
                respProps.addAll(resps);
            }
        } else {
            throw new BadRequestException(resource, "Resource is not a " + CalendarResource.class.getCanonicalName() + " is a: " + resource.getClass() );
        }

        String xml = xmlGenerator.generate(respProps);
        return xml;
    }
View Full Code Here

    public String processForm(Map<String, String> parameters, Map<String, FileItem> files) throws BadRequestException, NotAuthorizedException, ConflictException {
      System.out.println("processForm: parameters: " + parameters + " files: " + files);

      if (files.isEmpty()) {
        log.warn("No meta file provided");
        throw new BadRequestException(r);
      } else {
        try {
          FileItem item = files.values().iterator().next();

          File metaFile = metaStore.storeMetaData(r, item.getInputStream());
View Full Code Here

    public void replaceContent(InputStream in, Long length) throws BadRequestException, ConflictException, NotAuthorizedException {
      log.trace("replaceContent: bytes: " + length);
      try {
        File metaFile = metaStore.getMetaData(r);
        if (metaFile == null) {
          throw new BadRequestException(r, "No previous metadata was found for this version of this file");
        }

        // save new data to a temp file
        File tempNewData = File.createTempFile("milton-zsync", "newdata");
        FileOutputStream fout = new FileOutputStream(tempNewData);
View Full Code Here

            if( eventManager != null ) {
                eventManager.fireEvent( new NewFolderEvent( col ) );
            }
            return null;
        } catch( ConflictException ex ) {
            throw new BadRequestException( wrapped, "A conflict occured. The folder might already exist" );
        }
    }
View Full Code Here

TOP

Related Classes of com.bradmcevoy.http.exceptions.BadRequestException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.