Examples of FormFile


Examples of de.metalcon.utils.FormFile

              this.commandQueue.add(createStatusUpdateCommand);

              commandStacked = true;
            } catch (final StatusUpdateInstantiationFailedException e) {
              // remove the files
              FormFile fileItem;
              File file;
              for (String fileIdentifier : formItemList
                  .getFileIdentifiers()) {
                fileItem = formItemList.getFile(fileIdentifier);
                file = fileItem.getFile();

                if (file != null) {
                  file.delete();
                }
              }
View Full Code Here

Examples of org.apache.clerezza.jaxrs.utils.form.FormFile

   * resource already exists.
   */
  @POST
  @Consumes("multipart/form")
  public Response postContent(MultiPartBody form) {
    FormFile formFile = form.getFormFileParameterValues("content")[0];
    String uri = form.getTextParameterValues("uri")[0];
    byte[] content = formFile.getContent();
    if (content == null || uri == null) {
      return Response.status(400).entity("Required form field is missing").
          type(MediaType.TEXT_PLAIN_TYPE).build();
    }
    LockableMGraph contentGraph = cgProvider.getContentGraph();
    Lock readLock = contentGraph.getLock().readLock();
    readLock.lock();
    try {
      if (contentGraph.filter(new UriRef(uri), RDF.type, null).hasNext()) {
        return Response.status(Response.Status.CONFLICT).
            entity("A resource with the specified URI already exists").
            type(MediaType.TEXT_PLAIN_TYPE).build();
      }
    } finally {
      readLock.unlock();
    }
    handler.put(new UriRef(uri), formFile.getMediaType(), content);
    return Response.created(URI.create(uri)).build();
 
View Full Code Here

Examples of org.apache.clerezza.jaxrs.utils.form.FormFile

    String scriptName = "unnamed";

    byte[] scriptFileBytes = new byte[0];

    if(fileChoice.equals("file")) {
      FormFile formFile =
          form.getFormFileParameterValues("scriptFile")[0];
      scriptFileBytes = formFile.getContent();

      if (scriptFileBytes == null || (scriptFileBytes.length == 0)) {
        String message = "no script uploaded";
        logger.warn(message);
        throw new WebApplicationException(Response.status(
            Status.BAD_REQUEST).entity(message).build());
      }

      scriptName = formFile.getFileName();

      if(mediaType.trim().equals("")) {
        mediaType = formFile.getMediaType().toString();
      }
    } else if(fileChoice.equals("text")) {
      if(form.getTextParameterValues("scriptCode").length > 0) {
        scriptFileBytes = form.getTextParameterValues("scriptCode")[0].
            getBytes();
View Full Code Here

Examples of org.apache.clerezza.jaxrs.utils.form.FormFile

    String scriptCode = form.getTextParameterValues("scriptCode")[0];

    ScriptLanguageDescription sld =
        extractLanguageAndVersion(scriptLanguageAndVersion);

    FormFile formFile =
        form.getFormFileParameterValues("scriptFile")[0];
   
    byte[] scriptFileBytes = formFile.getContent();



    if (scriptFileBytes == null || (scriptFileBytes.length == 0)) {
      scriptFileBytes = scriptCode.getBytes();
      if(mediaType.trim().equals("")) {
        mediaType = "text/plain";
      }
    } else {
      if(mediaType.trim().equals("")) {
        mediaType = formFile.getMediaType().toString();
      }
      scriptName = formFile.getFileName();
    }
    saveScript(scriptUri, scriptFileBytes, scriptName, sld.getLanguage(),
        sld.getVersion(), mediaType, producedType);

    return RedirectUtil.createSeeOtherResponse(
View Full Code Here

Examples of org.apache.clerezza.jaxrs.utils.form.FormFile

    AccessController.checkPermission(new WebAccessPermission());
    FormFile[] formFiles = form.getFormFileParameterValues("graph");
    if (formFiles.length == 0) {
      responseWithBadRequest("form file parameter 'graph' is missing");
    }
    FormFile formFile = formFiles[0];
    byte[] graph = formFile.getContent();
    if (graph == null || (graph.length == 0)) {
      responseWithBadRequest("no triples uploaded");
    }
    MediaType mediaType = formFile.getMediaType();
    if (mediaType == null) {
      responseWithBadRequest("mime-type not specified");
    }
    if (mediaType.equals(MediaType.APPLICATION_OCTET_STREAM_TYPE)) {
      MediaType guessedType = MediaTypeGuesser.getInstance().guessTypeForName(formFile.getFileName());
      if (guessedType != null) {
        mediaType = guessedType;
      }
    }
    String graphName = getFirstTextParameterValue(form, "name", true);
View Full Code Here

Examples of org.apache.clerezza.jaxrs.utils.form.FormFile

    AccessController.checkPermission(new RestorePermission());
    FormFile[] files = body.getFormFileParameterValues("file");
    if (files.length != 1) {
      throw new RuntimeException("Must submit exactly one file");
    }
    final FormFile file = files[0];
    try {
      return AccessController.doPrivileged(new PrivilegedExceptionAction<Response>() {

        @Override
        public Response run() throws IOException {
          restore(new ByteArrayInputStream(file.getContent()));
          return RedirectUtil.createSeeOtherResponse("/admin/backup", uriInfo);
        }
      });
    } catch (PrivilegedActionException ex) {
      throw ex.getCause();
View Full Code Here

Examples of org.apache.clerezza.jaxrs.utils.form.FormFile

     */
    @POST
    public RdfViewable enhanceFile(MultiPartBody body) throws IOException, EnhancementException {
        final String[] chainValues = body.getTextParameterValues("chain");
        final String chainName = chainValues.length > 0 ? chainValues[0] : null;
        final FormFile file = body.getFormFileParameterValues("file")[0];
        final ContentSource contentSource = new ByteArraySource(
                file.getContent(),
                file.getMediaType().toString(),
                file.getFileName());
        final ContentItem contentItem = contentItemFactory.createContentItem(contentSource);
        if ((chainName == null) || chainName.trim().equals("")) {
            enhancementJobManager.enhanceContent(contentItem);
        } else {
            final Chain chain = chainManager.getChain(chainName);
View Full Code Here

Examples of org.apache.clerezza.jaxrs.utils.form.FormFile

        AccessController.checkPermission(new WebAccessPermission());
        FormFile[] formFiles = form.getFormFileParameterValues("graph");
        if (formFiles.length == 0) {
            responseWithBadRequest("form file parameter 'graph' is missing");
        }
        FormFile formFile = formFiles[0];
        byte[] graph = formFile.getContent();
        if (graph == null || (graph.length == 0)) {
            responseWithBadRequest("no triples uploaded");
        }
        MediaType mediaType = formFile.getMediaType();
        if (mediaType == null) {
            responseWithBadRequest("mime-type not specified");
        }
        if (mediaType.equals(MediaType.APPLICATION_OCTET_STREAM_TYPE)) {
            MediaType guessedType = MediaTypeGuesser.getInstance().guessTypeForName(formFile.getFileName());
            if (guessedType != null) {
                mediaType = guessedType;
            }
        }
        String graphName = getFirstTextParameterValue(form, "name", true);
View Full Code Here

Examples of org.apache.struts.upload.FormFile

           fileVO.setTo(getTimestamp(endDay,endMonth,endYear,timeZone));
        }
      }

      // get file
      FormFile fileUpload = ((FileForm)form).getFile();
      // set file vo
      fileVO.setName(fileUpload.getFileName());
      fileVO.setFileSize(fileUpload.getFileSize());
      fileVO.setPhysicalFolder(Integer.parseInt(((FileForm)form).getUploadfolderid()));
      fileVO.setTitle(((FileForm)form).getTitle());
      fileVO.setDescription(((FileForm)form).getDescription());

      if(((FileForm)form).getAuthorid() != null && ((FileForm)form).getAuthorid().length() > 0)
        fileVO.setAuthorId(Integer.parseInt(((FileForm)form).getAuthorid()));

      if(((FileForm)form).getEntityid() != null && ((FileForm)form).getEntityid().length() > 0)
        fileVO.setRelateEntity(Integer.parseInt(((FileForm)form).getEntityid()));

      if(((FileForm)form).getIndividualid() != null && ((FileForm)form).getIndividualid().length() > 0)
        fileVO.setRelateIndividual(Integer.parseInt(((FileForm)form).getIndividualid()));

      fileVO.setRelatedFieldID(((FileForm)form).getRelatedFieldID());
      fileVO.setRelatedFieldValue(((FileForm)form).getRelatedFieldValue());
      fileVO.setRelatedTypeID(((FileForm)form).getRelatedTypeID());
      fileVO.setRelatedTypeValue(((FileForm)form).getRelatedTypeValue());
      fileVO.setVisibility(((FileForm)form).getAccess());
      fileVO.setCustomerView(((FileForm)form).getCustomerview());
      fileVO.setCompanyNews(((FileForm)form).getCompanynews());

      int userId = ((UserObject)session.getAttribute("userobject")).getIndividualID();
      fileVO.setCreatedBy(userId);
      fileVO.setOwner(userId);
      // call to file facade
      CvFileFacade fileFacade = new CvFileFacade();

      // set request back to jsp
        request.setAttribute(FileConstantKeys.TYPEOFFILE, FileConstantKeys.FILE);
        request.setAttribute(FileConstantKeys.CURRENTTAB, FileConstantKeys.DETAIL);
        request.setAttribute(FileConstantKeys.TYPEOFOPERATION, FileConstantKeys.ADD);
        request.setAttribute(FileConstantKeys.WINDOWID, "1");

      if (request.getParameter("closeornew").equals("close"))
      {
        request.setAttribute("closeWindow","true");
      }
      else
      {
        request.setAttribute("closeWindow","false");
      }

        FORWARD_final = FORWARD_savefile;

      try
      {
       int recordID=fileFacade.addFile(userId, fileVO.getPhysicalFolder(), fileVO, fileUpload.getInputStream(), dataSource);
       rowID=recordID;
      }
      catch(CvFileException e)
      {
        System.out.println("[Exception][SaveNewFileHandler.execute] Exception Thrown: "+e);
View Full Code Here

Examples of org.apache.struts.upload.FormFile

      int userId = userobjectd.getIndividualID();
      fileVO.setModifiedBy(userId);
      // call to file facade
      CvFileFacade fileFacade = new CvFileFacade();
      FormFile fileUpload = ((FileForm)form).getFile();

      if (fileUpload != null && !(fileUpload.equals("")))
      {
        fileVO.setName(fileUpload.getFileName());
        fileVO.setFileSize(fileUpload.getFileSize());
      }

      request.setAttribute(FileConstantKeys.TYPEOFFILE, FileConstantKeys.FILE);
      request.setAttribute(FileConstantKeys.CURRENTTAB, FileConstantKeys.DETAIL);
      request.setAttribute(FileConstantKeys.TYPEOFOPERATION, FileConstantKeys.EDIT);
      request.setAttribute(FileConstantKeys.WINDOWID, "1");
      request.setAttribute(FileConstantKeys.FFID, ""+fileVO.getFileId());

      if (request.getParameter("saveType").equals("save"))
        {
          request.setAttribute("bodycontent", "editdetailfile");
          FORWARD_final = FORWARD_editsavefile;
        }
        else // if (request.getParameter("saveType").equals("saveclose"))
        {
          request.setAttribute("bodycontent", null);
          FORWARD_final = FORWARD_editsaveclosefile;
        }
      try
      {
        fileFacade.updateFile(userId, otherFolderId, fileVO,fileUpload.getInputStream(), dataSource);

        if(fileUpload!=null && fileUpload.getFileName()!=null && (!fileUpload.getFileName().trim().equals("")) )  //CW: update the filename field to the new file name
        {

          ((FileForm)form).setFileInfo(fileUpload.getFileName());
        }
      }
      catch(CvFileException e)
      {
        System.out.println("[Exception][SaveEditFileHandler.execute] Exception Thrown: "+e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.