Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSData


    /********** Constructors **********/
    public static MSiteConfig getSiteConfigFromHostAndPort(String configHostName, int aPort) throws MonitorException {
        if (NSLog.debugLoggingAllowedForLevelAndGroups(NSLog. DebugLevelInformational, NSLog.DebugGroupDeployment))
            NSLog.debug.appendln("!@#$!@#$ getSiteConfigFromHostAndPort creates a WOHTTPConnection");
        NSDictionary monitorRequest = new NSDictionary<String, String>("SITE", "queryWotaskd");
        NSData content = new NSData( (new _JavaMonitorCoder()).encodeRootObjectForKey(monitorRequest, "monitorRequest") );

        WORequest aRequest = new ERXRequest(MObject._POST, MObject.directActionString, MObject._HTTP1, NSDictionary.EmptyDictionary, content, null);
        WOResponse aResponse = null;

        try {
View Full Code Here


    return super.invokeAction(request, context);
  }

  @Override
  public void takeValuesFromRequest(WORequest request, WOContext context) {
    NSData data = (NSData) request.formValueForKey(dropTargetID());
    if(data != null) {
      String mimetype = (String) request.formValueForKey(dropTargetID() + ".mimetype");
      if(!accept().isEmpty() && !acceptMimetype(mimetype)) {
        // reject mime types that don't match
        invokeAction = true;
        willAccept = false;
      } else {
        String filename = (String) request.formValueForKey(dropTargetID() + ".filename");
        FileOutputStream os = null;
        try {
          File uploadedFile = File.createTempFile("DragAndDropUpload-", ".tmp");
          os = new FileOutputStream(uploadedFile);
          data.writeToStream(os);
          ERAttachment upload = ERAttachmentProcessor.processorForType(storageType()).process(editingContext(), uploadedFile, filename, mimetype, configurationName(), null);
          setValueForBinding(upload, "attachment");
          invokeAction = true;
          FileUtils.deleteQuietly(uploadedFile);
        } catch (IOException e) {
View Full Code Here

    if (delegate() != null) {
      delegate().attachmentCreated(this, attachment);
    }
    try {
      attachment.setWebPath(ERAttachmentProcessor._parsePathTemplate(attachment, webPath, recommendedFileName));
      NSData data = new NSData(uploadedFile.toURI().toURL());
      if (smallData) {
        attachment.setSmallData(data);
      }
      else {
        ERAttachmentData attachmentData = ERAttachmentData.createERAttachmentData(editingContext);
View Full Code Here

    return attachment;
  }

  @Override
  public InputStream attachmentInputStream(ERDatabaseAttachment attachment) throws FileNotFoundException {
    NSData data = attachment.smallData();
    if (data == null) {
      ERAttachmentData attachmentData = attachment.attachmentData();
      if (attachmentData != null) {
        data = attachmentData.data();
      }
    }
    InputStream attachmentInputStream;
    if (data != null) {
      attachmentInputStream = data.stream();
    }
    else {
      throw new FileNotFoundException("There was no data available for this attachment.");
    }
    return attachmentInputStream;
View Full Code Here

    try {
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      workbook().write(out);
      out.close();
     
      return new NSData(out.toByteArray());
    } catch (IOException e) {
      log.error(e,e);
    }
    return null;
  }
View Full Code Here

            }
            InputStream stream = new ByteArrayInputStream(bytes);

            EGSimpleTableParser parser = new EGSimpleTableParser(stream, fonts(), styles());
            try {
              NSData data = parser.data();
              if((hasBinding("data") && canSetValueForBinding("data")) ||
                 (hasBinding("stream") && canSetValueForBinding("stream"))
                 ) {
                  if(hasBinding("data")) {
                      setValueForBinding(data, "data");
                  }
                  if(hasBinding("stream")) {
                      setValueForBinding(data.stream(), "stream");
                  }
                  response.appendContentString(contentString);
              } else {
                  String fileName = fileName();
                  if(fileName == null) {
                      fileName = "results.xls";
                  }
                 
                  response.disableClientCaching();
                  response.appendHeader(String.valueOf( data.length()), "Content-Length" );
                  response.setContent(data); // Changed by ishimoto because it was sooooo buggy and didn't work in Japanese
 
                  response.setHeader("inline; filename=\"" + fileName + "\"", "content-disposition");
                  response.setHeader("application/vnd.ms-excel", "content-type");
              }
View Full Code Here

    public void addToBothSidesOfAttachments(ERCMessageAttachment attachement) {
      addObjectToBothSidesOfRelationshipWithKey(attachement, Key.ATTACHMENTS);
    }
   
    public String storedGzippedValueForKey(String key) {
        NSData data = (NSData)storedValueForKey(key);
        String value = null;
        if (data != null && data.bytes().length > 0) {
            value = ERXCompressionUtilities.gunzipByteArrayAsString(data.bytes());
        }
        return value;
    }
View Full Code Here

        }
        return value;
    }

    public void takeStoredGzippedValueForKey(String aValue, String key) {
        NSData valueToSet = null;
       
        if ( aValue != null ) {
            byte bytes[] = ERXCompressionUtilities.gzipStringAsByteArray(aValue);
           
            if (bytes.length > 0) {
                valueToSet = new NSData(bytes);
            }
        }
       
        takeStoredValueForKey(valueToSet, key);
    }
View Full Code Here

    else if (key instanceof Long) {
      dos.writeByte(ERXRemoteSynchronizer.LONG_TYPE);
      dos.writeLong(((Long) key).longValue());
    }
    else if (key instanceof NSData) {
      NSData data = (NSData) key;
      dos.writeByte(ERXRemoteSynchronizer.DATA_TYPE);
      dos.writeByte(data.length());
      data.writeToStream(dos);
    }
    else if (key instanceof String) {
      String str = (String)key;
      dos.writeByte(ERXRemoteSynchronizer.STRING_TYPE);
      dos.writeUTF(str);
View Full Code Here

    }
    else if (keyType == ERXRemoteSynchronizer.DATA_TYPE) {
      int size = dis.readByte();
      byte[] data = new byte[size];
      dis.readFully(data);
      obj = new NSData(data);
    }
    else if (keyType == ERXRemoteSynchronizer.STRING_TYPE) {
      obj = dis.readUTF();
    }
    else {
View Full Code Here

TOP

Related Classes of com.webobjects.foundation.NSData

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.