Skip to content

Commit

Permalink
closing IO streams
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed May 6, 2016
1 parent fb20c33 commit 63e3f02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Expand Up @@ -28,6 +28,7 @@
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -223,13 +224,15 @@ public void onClick(AjaxRequestTarget target) {
public File getObject() {
String home = getPageBase().getMidpointConfiguration().getMidpointHome();
File f = new File(home, "result");
DataOutputStream dos;
DataOutputStream dos = null;
try {
dos = new DataOutputStream(new FileOutputStream(f));

dos.writeBytes(OperationResultPanel.this.getModel().getObject().getXml());
} catch (IOException e) {
LOGGER.error("Could not download result: {}", e.getMessage(), e);
} finally {
IOUtils.closeQuietly(dos);
}

return f;
Expand Down
Expand Up @@ -49,6 +49,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ScriptingExpressionType;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.Validate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
Expand Down Expand Up @@ -1531,12 +1532,13 @@ public void importFromResource(String shadowOid, Task task, OperationResult pare
@Override
public void importObjectsFromFile(File input, ImportOptionsType options, Task task,
OperationResult parentResult) throws FileNotFoundException {
OperationResult result = parentResult.createSubresult(IMPORT_OBJECTS_FROM_FILE);
FileInputStream fis;
try {
OperationResult result = parentResult.createSubresult(IMPORT_OBJECTS_FROM_FILE);
FileInputStream fis = null;
try {
fis = new FileInputStream(input);
} catch (FileNotFoundException e) {
String msg = "Error reading from file "+input+": "+e.getMessage();
IOUtils.closeQuietly(fis);
String msg = "Error reading from file " + input + ": " + e.getMessage();
result.recordFatalError(msg, e);
throw e;
}
Expand All @@ -1549,7 +1551,7 @@ public void importObjectsFromFile(File input, ImportOptionsType options, Task ta
try {
fis.close();
} catch (IOException e) {
LOGGER.error("Error closing file "+input+": "+e.getMessage(), e);
LOGGER.error("Error closing file " + input + ": " + e.getMessage(), e);
}
}
result.computeStatus();
Expand Down

0 comments on commit 63e3f02

Please sign in to comment.