Moving default app.png to common/resources, so that it is included in the bundle
Change-Id: I4ad225eb0e73bceb31f9a2a4edc29180cd0db500
Showing
4 changed files
with
10 additions
and
19 deletions
| ... | @@ -38,9 +38,7 @@ import org.onosproject.store.AbstractStore; | ... | @@ -38,9 +38,7 @@ import org.onosproject.store.AbstractStore; |
| 38 | import org.slf4j.Logger; | 38 | import org.slf4j.Logger; |
| 39 | import org.slf4j.LoggerFactory; | 39 | import org.slf4j.LoggerFactory; |
| 40 | 40 | ||
| 41 | -import javax.imageio.ImageIO; | ||
| 42 | import java.io.ByteArrayInputStream; | 41 | import java.io.ByteArrayInputStream; |
| 43 | -import java.io.ByteArrayOutputStream; | ||
| 44 | import java.io.File; | 42 | import java.io.File; |
| 45 | import java.io.FileInputStream; | 43 | import java.io.FileInputStream; |
| 46 | import java.io.FileNotFoundException; | 44 | import java.io.FileNotFoundException; |
| ... | @@ -456,25 +454,20 @@ public class ApplicationArchive | ... | @@ -456,25 +454,20 @@ public class ApplicationArchive |
| 456 | 454 | ||
| 457 | // Returns the byte stream from icon.png file in oar application archive. | 455 | // Returns the byte stream from icon.png file in oar application archive. |
| 458 | private byte[] getApplicationIcon(String appName) { | 456 | private byte[] getApplicationIcon(String appName) { |
| 459 | - | ||
| 460 | - byte[] icon = new byte[0]; | ||
| 461 | File iconFile = iconFile(appName, APP_PNG); | 457 | File iconFile = iconFile(appName, APP_PNG); |
| 462 | - | ||
| 463 | - if (!iconFile.exists()) { | ||
| 464 | - // assume that we can always fallback to default icon | ||
| 465 | - iconFile = new File(appsDir, APP_PNG); | ||
| 466 | - } | ||
| 467 | - | ||
| 468 | try { | 458 | try { |
| 469 | - ByteArrayOutputStream bos = new ByteArrayOutputStream(); | 459 | + final InputStream iconStream; |
| 470 | - ImageIO.write(ImageIO.read(iconFile), PNG, bos); | 460 | + if (iconFile.exists()) { |
| 471 | - icon = bos.toByteArray(); | 461 | + iconStream = new FileInputStream(iconFile); |
| 472 | - bos.close(); | 462 | + } else { |
| 463 | + // assume that we can always fallback to default icon | ||
| 464 | + iconStream = ApplicationArchive.class.getResourceAsStream("/" + APP_PNG); | ||
| 465 | + } | ||
| 466 | + return ByteStreams.toByteArray(iconStream); | ||
| 473 | } catch (IOException e) { | 467 | } catch (IOException e) { |
| 474 | - e.printStackTrace(); | 468 | + log.warn("Unable to read app icon for app {}", appName, e); |
| 475 | } | 469 | } |
| 476 | - | 470 | + return new byte[0]; |
| 477 | - return icon; | ||
| 478 | } | 471 | } |
| 479 | 472 | ||
| 480 | // Returns application role type | 473 | // Returns application role type | ... | ... |
| ... | @@ -28,5 +28,3 @@ find $M2_REPO/org/onosproject/ -name "*.oar" -path "*/${ONOS_POM_VERSION}/*" | w | ... | @@ -28,5 +28,3 @@ find $M2_REPO/org/onosproject/ -name "*.oar" -path "*/${ONOS_POM_VERSION}/*" | w |
| 28 | cp -rf $AUX/m2/* $KARAF_M2 | 28 | cp -rf $AUX/m2/* $KARAF_M2 |
| 29 | rm -fr $AUX | 29 | rm -fr $AUX |
| 30 | done | 30 | done |
| 31 | - | ||
| 32 | -cp $ONOS_ROOT/apps/app.png $APPS/app.png | ... | ... |
-
Please register or login to post a comment