Ejemplo n.º 1
0
 private void writeHttpData(InterfaceHttpData data) {
   if (data.getHttpDataType() == HttpDataType.Attribute) {
     Attribute attribute = (Attribute) data;
     String value;
     try {
       value = attribute.getValue();
     } catch (IOException e1) {
       // Error while reading data from File, only print name and error
       e1.printStackTrace();
       responseContent.append(
           "\r\nBODY Attribute: "
               + attribute.getHttpDataType().name()
               + ": "
               + attribute.getName()
               + " Error while reading value: "
               + e1.getMessage()
               + "\r\n");
       return;
     }
     if (value.length() > 100) {
       responseContent.append(
           "\r\nBODY Attribute: "
               + attribute.getHttpDataType().name()
               + ": "
               + attribute.getName()
               + " data too long\r\n");
     } else {
       responseContent.append(
           "\r\nBODY Attribute: "
               + attribute.getHttpDataType().name()
               + ": "
               + attribute
               + "\r\n");
     }
   } else {
     responseContent.append(
         "\r\nBODY FileUpload: " + data.getHttpDataType().name() + ": " + data + "\r\n");
     if (data.getHttpDataType() == HttpDataType.FileUpload) {
       FileUpload fileUpload = (FileUpload) data;
       if (fileUpload.isCompleted()) {
         if (fileUpload.length() < 10000) {
           responseContent.append("\tContent of file\r\n");
           try {
             responseContent.append(fileUpload.getString(fileUpload.getCharset()));
           } catch (IOException e1) {
             // do nothing for the example
             e1.printStackTrace();
           }
           responseContent.append("\r\n");
         } else {
           responseContent.append(
               "\tFile too long to be printed out:" + fileUpload.length() + "\r\n");
         }
         // fileUpload.isInMemory();// tells if the file is in Memory
         // or on File
         // fileUpload.renameTo(dest); // enable to move into another
         // File dest
         // decoder.removeFileUploadFromClean(fileUpload); //remove
         // the File of to delete file
       } else {
         responseContent.append("\tFile to be continued but should not!\r\n");
       }
     }
   }
 }