Moving default app.png to common/resources, so that it is included in the bundle
Change-Id: I4ad225eb0e73bceb31f9a2a4edc29180cd0db500
diff --git a/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java b/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java
index 6fdbeca..a8b5e0e 100644
--- a/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java
+++ b/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java
@@ -38,9 +38,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.imageio.ImageIO;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -456,25 +454,20 @@
// Returns the byte stream from icon.png file in oar application archive.
private byte[] getApplicationIcon(String appName) {
-
- byte[] icon = new byte[0];
File iconFile = iconFile(appName, APP_PNG);
-
- if (!iconFile.exists()) {
- // assume that we can always fallback to default icon
- iconFile = new File(appsDir, APP_PNG);
- }
-
try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ImageIO.write(ImageIO.read(iconFile), PNG, bos);
- icon = bos.toByteArray();
- bos.close();
+ final InputStream iconStream;
+ if (iconFile.exists()) {
+ iconStream = new FileInputStream(iconFile);
+ } else {
+ // assume that we can always fallback to default icon
+ iconStream = ApplicationArchive.class.getResourceAsStream("/" + APP_PNG);
+ }
+ return ByteStreams.toByteArray(iconStream);
} catch (IOException e) {
- e.printStackTrace();
+ log.warn("Unable to read app icon for app {}", appName, e);
}
-
- return icon;
+ return new byte[0];
}
// Returns application role type