Skip to content

Commit

Permalink
BUG su DataSource
Browse files Browse the repository at this point in the history
  • Loading branch information
mspasiano committed Sep 27, 2016
1 parent ab85e72 commit 0231824
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -938,12 +938,14 @@ public UploadedFileDataSourceStream(InputStream inputStream, String contentType)

@Override
public OutputStream getOutputStream() throws IOException {
throw new NotImplementedException("datasource file non implementato Stream");
ByteArrayOutputStream output = new ByteArrayOutputStream();
IOUtils.copy(inputStream, output);
return output;
}

@Override
public String getName() {
throw new NotImplementedException("Nome non implementato Stream");
return "DATASOURCE";
}

@Override
Expand Down Expand Up @@ -971,17 +973,17 @@ public OutputStream getOutputStream() throws IOException {

@Override
public String getName() {
throw new NotImplementedException("Nome non implementato Output Stream");
return "DATASOURCE";
}

@Override
public InputStream getInputStream() throws IOException {
throw new NotImplementedException("Nome non implementato Output Stream");
throw new NotImplementedException("getInputStream non implementato Output Stream");
}

@Override
public String getContentType() {
throw new NotImplementedException("Nome non implementato Output Stream");
return "www/unknow";
}
}
class UploadedFileDataSource implements DataSource {
Expand All @@ -994,16 +996,21 @@ public UploadedFileDataSource(BodyPart bodypart) {

@Override
public OutputStream getOutputStream() throws IOException {
throw new NotImplementedException("datasource file non implementato" + bodypart.toString());
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
IOUtils.copy(bodypart.getInputStream(), output);
} catch (MessagingException e) {
logger.error("UploadedFileDataSource::getOutputStream", e);
}
return output;
}

@Override
public String getName() {
try {
return bodypart.getFileName();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.error("UploadedFileDataSource::getName", e);
}
return null;
}
Expand All @@ -1013,8 +1020,7 @@ public InputStream getInputStream() throws IOException {
try {
return bodypart.getInputStream();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.error("UploadedFileDataSource::getInputStream", e);
}
return null;
}
Expand All @@ -1024,8 +1030,7 @@ public String getContentType() {
try {
return bodypart.getContentType();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.error("UploadedFileDataSource::getContentType", e);
}
return null;
}
Expand Down

0 comments on commit 0231824

Please sign in to comment.