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
diff --git a/apps/app-blank.png b/core/common/src/main/resources/app-blank.png
similarity index 100%
rename from apps/app-blank.png
rename to core/common/src/main/resources/app-blank.png
Binary files differ
diff --git a/apps/app.png b/core/common/src/main/resources/app.png
similarity index 100%
rename from apps/app.png
rename to core/common/src/main/resources/app.png
Binary files differ
diff --git a/tools/test/bin/onos-stage-apps b/tools/test/bin/onos-stage-apps
index d7dafda..883fe4d 100755
--- a/tools/test/bin/onos-stage-apps
+++ b/tools/test/bin/onos-stage-apps
@@ -28,5 +28,3 @@
cp -rf $AUX/m2/* $KARAF_M2
rm -fr $AUX
done
-
-cp $ONOS_ROOT/apps/app.png $APPS/app.png