Apps-- added onos.app.title property to applications.
Change-Id: Id845390ee0bee5b871c0ce9f47b2ce98fbcf26b9
diff --git a/core/api/src/main/java/org/onosproject/app/ApplicationDescription.java b/core/api/src/main/java/org/onosproject/app/ApplicationDescription.java
index 1528f35..8732732 100644
--- a/core/api/src/main/java/org/onosproject/app/ApplicationDescription.java
+++ b/core/api/src/main/java/org/onosproject/app/ApplicationDescription.java
@@ -51,6 +51,13 @@
String origin();
/**
+ * Returns title of the application.
+ *
+ * @return application title text
+ */
+ String title();
+
+ /**
* Returns description of the application.
*
* @return application description text
diff --git a/core/api/src/main/java/org/onosproject/app/DefaultApplicationDescription.java b/core/api/src/main/java/org/onosproject/app/DefaultApplicationDescription.java
index 3aaca4c..1d371c4 100644
--- a/core/api/src/main/java/org/onosproject/app/DefaultApplicationDescription.java
+++ b/core/api/src/main/java/org/onosproject/app/DefaultApplicationDescription.java
@@ -35,6 +35,7 @@
private final String name;
private final Version version;
+ private final String title;
private final String description;
private final String origin;
private final String category;
@@ -52,6 +53,7 @@
*
* @param name application name
* @param version application version
+ * @param title application title
* @param description application description
* @param origin origin company
* @param category application category
@@ -64,7 +66,7 @@
* @param features application features
* @param requiredApps list of required application names
*/
- public DefaultApplicationDescription(String name, Version version,
+ public DefaultApplicationDescription(String name, Version version, String title,
String description, String origin, String category,
String url, String readme, byte[] icon,
ApplicationRole role, Set<Permission> permissions,
@@ -72,6 +74,7 @@
List<String> requiredApps) {
this.name = checkNotNull(name, "Name cannot be null");
this.version = checkNotNull(version, "Version cannot be null");
+ this.title = checkNotNull(title, "Title cannot be null");
this.description = checkNotNull(description, "Description cannot be null");
this.origin = checkNotNull(origin, "Origin cannot be null");
this.category = checkNotNull(category, "Category cannot be null");
@@ -97,6 +100,11 @@
}
@Override
+ public String title() {
+ return title;
+ }
+
+ @Override
public String description() {
return description;
}
@@ -157,6 +165,7 @@
.add("name", name)
.add("version", version)
.add("description", description)
+ .add("title", title)
.add("origin", origin)
.add("category", category)
.add("url", url)
diff --git a/core/api/src/main/java/org/onosproject/core/Application.java b/core/api/src/main/java/org/onosproject/core/Application.java
index 8700cad..04a1e09 100644
--- a/core/api/src/main/java/org/onosproject/core/Application.java
+++ b/core/api/src/main/java/org/onosproject/core/Application.java
@@ -42,6 +42,15 @@
Version version();
/**
+ * Returns the title of the application.
+ * This should be a short, human-readable string, as opposed
+ * to the unique identifier returned by {@link #id()}.
+ *
+ * @return application title text
+ */
+ String title();
+
+ /**
* Returns description of the application.
*
* @return application description text
diff --git a/core/api/src/main/java/org/onosproject/core/DefaultApplication.java b/core/api/src/main/java/org/onosproject/core/DefaultApplication.java
index 7737ef8..487e709 100644
--- a/core/api/src/main/java/org/onosproject/core/DefaultApplication.java
+++ b/core/api/src/main/java/org/onosproject/core/DefaultApplication.java
@@ -36,6 +36,7 @@
private final ApplicationId appId;
private final Version version;
+ private final String title;
private final String description;
private final String category;
private final String url;
@@ -53,6 +54,7 @@
*
* @param appId application identifier
* @param version application version
+ * @param title application title
* @param description application description
* @param origin origin company
* @param category application category
@@ -65,7 +67,7 @@
* @param features application features
* @param requiredApps list of required application names
*/
- public DefaultApplication(ApplicationId appId, Version version,
+ public DefaultApplication(ApplicationId appId, Version version, String title,
String description, String origin, String category,
String url, String readme, byte[] icon,
ApplicationRole role, Set<Permission> permissions,
@@ -73,6 +75,7 @@
List<String> requiredApps) {
this.appId = checkNotNull(appId, "ID cannot be null");
this.version = checkNotNull(version, "Version cannot be null");
+ this.title = checkNotNull(title, "Title cannot be null");
this.description = checkNotNull(description, "Description cannot be null");
this.origin = checkNotNull(origin, "Origin cannot be null");
this.category = checkNotNull(category, "Category cannot be null");
@@ -104,6 +107,11 @@
}
@Override
+ public String title() {
+ return title;
+ }
+
+ @Override
public String description() {
return description;
}
@@ -160,7 +168,7 @@
@Override
public int hashCode() {
- return Objects.hash(appId, version, description, origin, category, url,
+ return Objects.hash(appId, version, title, description, origin, category, url,
readme, role, permissions, featuresRepo, features, requiredApps);
}
@@ -173,8 +181,12 @@
return false;
}
final DefaultApplication other = (DefaultApplication) obj;
+ // TODO: review -- do ALL the fields need to be included?
+ // It is debatable whether fields like description, url, and readme,
+ // need to be included in the notion of equivalence.
return Objects.equals(this.appId, other.appId) &&
Objects.equals(this.version, other.version) &&
+ Objects.equals(this.title, other.title) &&
Objects.equals(this.description, other.description) &&
Objects.equals(this.origin, other.origin) &&
Objects.equals(this.category, other.category) &&
@@ -192,6 +204,7 @@
return toStringHelper(this)
.add("appId", appId)
.add("version", version)
+ .add("title", title)
.add("description", description)
.add("origin", origin)
.add("category", category)
diff --git a/core/api/src/test/java/org/onosproject/app/ApplicationEventTest.java b/core/api/src/test/java/org/onosproject/app/ApplicationEventTest.java
index 0d4ae4c..2edd1f0 100644
--- a/core/api/src/test/java/org/onosproject/app/ApplicationEventTest.java
+++ b/core/api/src/test/java/org/onosproject/app/ApplicationEventTest.java
@@ -32,7 +32,7 @@
public class ApplicationEventTest extends AbstractEventTest {
private Application createApp() {
- return new DefaultApplication(APP_ID, VER, DESC, ORIGIN, CATEGORY,
+ return new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN, CATEGORY,
URL, README, ICON, ROLE, PERMS,
Optional.of(FURL), FEATURES, APPS);
}
diff --git a/core/api/src/test/java/org/onosproject/app/DefaultApplicationDescriptionTest.java b/core/api/src/test/java/org/onosproject/app/DefaultApplicationDescriptionTest.java
index e01d4d8..7e8b6ea 100644
--- a/core/api/src/test/java/org/onosproject/app/DefaultApplicationDescriptionTest.java
+++ b/core/api/src/test/java/org/onosproject/app/DefaultApplicationDescriptionTest.java
@@ -38,6 +38,7 @@
public static final String APP_NAME = "org.foo.app";
public static final Version VER = Version.version(1, 2, "a", null);
+ public static final String TITLE = "Awesome App";
public static final String DESC = "Awesome application from Circus, Inc.";
public static final String ORIGIN = "Circus";
public static final String CATEGORY = "other";
@@ -55,11 +56,12 @@
@Test
public void basics() {
ApplicationDescription app =
- new DefaultApplicationDescription(APP_NAME, VER, DESC, ORIGIN,
+ new DefaultApplicationDescription(APP_NAME, VER, TITLE, DESC, ORIGIN,
CATEGORY, URL, README, ICON,
ROLE, PERMS, FURL, FEATURES, APPS);
assertEquals("incorrect id", APP_NAME, app.name());
assertEquals("incorrect version", VER, app.version());
+ assertEquals("incorrect title", TITLE, app.title());
assertEquals("incorrect description", DESC, app.description());
assertEquals("incorrect origin", ORIGIN, app.origin());
assertEquals("incorrect category", CATEGORY, app.category());
diff --git a/core/api/src/test/java/org/onosproject/core/DefaultApplicationTest.java b/core/api/src/test/java/org/onosproject/core/DefaultApplicationTest.java
index c0fbf9c..8e141ce 100644
--- a/core/api/src/test/java/org/onosproject/core/DefaultApplicationTest.java
+++ b/core/api/src/test/java/org/onosproject/core/DefaultApplicationTest.java
@@ -43,7 +43,7 @@
@Test
public void basics() {
- Application app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
+ Application app = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN,
CATEGORY, URL, README, ICON, ROLE,
PERMS, Optional.of(FURL), FEATURES, APPS);
assertEquals("incorrect id", APP_ID, app.id());
@@ -64,16 +64,16 @@
@Test
public void testEquality() {
- Application a1 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
+ Application a1 = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN,
CATEGORY, URL, README, ICON, ROLE,
PERMS, Optional.of(FURL), FEATURES, APPS);
- Application a2 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
+ Application a2 = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN,
CATEGORY, URL, README, ICON, ROLE,
PERMS, Optional.of(FURL), FEATURES, APPS);
- Application a3 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
+ Application a3 = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN,
CATEGORY, URL, README, ICON, ROLE,
PERMS, Optional.empty(), FEATURES, APPS);
- Application a4 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN + "asd",
+ Application a4 = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN + "asd",
CATEGORY, URL, README, ICON, ROLE,
PERMS, Optional.of(FURL), FEATURES, APPS);
new EqualsTester().addEqualityGroup(a1, a2)
@@ -87,7 +87,7 @@
public void immutableIcon() {
byte[] iconSourceData = ICON_ORIG.clone();
- Application app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
+ Application app = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN,
CATEGORY, URL, README, iconSourceData, ROLE,
PERMS, Optional.of(FURL), FEATURES, APPS);
@@ -128,7 +128,7 @@
// Set<Permission> p = PERMS_ORIG;
Set<Permission> p = PERMS_UNSAFE;
- Application app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
+ Application app = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN,
CATEGORY, URL, README, ICON, ROLE,
p, Optional.of(FURL), FEATURES, APPS);
@@ -170,7 +170,7 @@
// List<String> f = FEATURES_ORIG;
List<String> f = FEATURES_UNSAFE;
- Application app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
+ Application app = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN,
CATEGORY, URL, README, ICON, ROLE,
PERMS, Optional.of(FURL), f, APPS);
@@ -190,7 +190,7 @@
// List<String> ra = REQ_APPS_ORIG;
List<String> ra = REQ_APPS_UNSAFE;
- Application app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
+ Application app = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN,
CATEGORY, URL, README, ICON, ROLE,
PERMS, Optional.of(FURL), FEATURES, ra);
@@ -206,7 +206,7 @@
@Test
public void nullIcon() {
- Application app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
+ Application app = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN,
CATEGORY, URL, README, null, ROLE,
PERMS, Optional.of(FURL), FEATURES, APPS);
byte[] icon = app.icon();
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 1e3f49c..3699b5d 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
@@ -88,6 +88,7 @@
private static final String CATEGORY = "[@category]";
private static final String URL = "[@url]";
+ private static final String TITLE = "[@title]";
private static final String ROLE = "security.role";
private static final String APP_PERMISSIONS = "security.permissions.app-perm";
@@ -294,6 +295,11 @@
String name = cfg.getString(NAME);
Version version = Version.version(cfg.getString(VERSION));
String origin = cfg.getString(ORIGIN);
+
+ String title = cfg.getString(TITLE);
+ // FIXME: title should be set as attribute to APP, but fallback for now...
+ title = title == null ? name : title;
+
String category = cfg.getString(CATEGORY, UTILITY);
String url = cfg.getString(URL);
byte[] icon = getApplicationIcon(name);
@@ -313,7 +319,7 @@
// put short description to description field
String desc = compactDescription(readme);
- return new DefaultApplicationDescription(name, version, desc, origin,
+ return new DefaultApplicationDescription(name, version, title, desc, origin,
category, url, readme, icon,
role, perms, featuresRepo,
features, requiredApps);
diff --git a/core/common/src/test/java/org/onosproject/common/app/ApplicationArchiveTest.java b/core/common/src/test/java/org/onosproject/common/app/ApplicationArchiveTest.java
index 87c6363..f7258c3 100644
--- a/core/common/src/test/java/org/onosproject/common/app/ApplicationArchiveTest.java
+++ b/core/common/src/test/java/org/onosproject/common/app/ApplicationArchiveTest.java
@@ -65,6 +65,7 @@
assertEquals("incorrect url", URL, app.url());
assertEquals("incorrect readme", README, app.readme());
+ assertEquals("incorrect title", TITLE, app.title());
assertEquals("incorrect description", DESC, app.description());
assertEquals("incorrect features URI", FURL, app.featuresRepo().get());
assertEquals("incorrect permissions", PERMS, app.permissions());
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java
index 98c18b4..5047987 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java
@@ -49,14 +49,18 @@
*/
@Component(immediate = true)
@Service
-public class SimpleApplicationStore extends ApplicationArchive implements ApplicationStore {
+public class SimpleApplicationStore extends ApplicationArchive
+ implements ApplicationStore {
private final Logger log = getLogger(getClass());
// App inventory & states
- private final ConcurrentMap<ApplicationId, DefaultApplication> apps = new ConcurrentHashMap<>();
- private final ConcurrentMap<ApplicationId, ApplicationState> states = new ConcurrentHashMap<>();
- private final ConcurrentMap<ApplicationId, Set<Permission>> permissions = new ConcurrentHashMap<>();
+ private final ConcurrentMap<ApplicationId, DefaultApplication> apps =
+ new ConcurrentHashMap<>();
+ private final ConcurrentMap<ApplicationId, ApplicationState> states =
+ new ConcurrentHashMap<>();
+ private final ConcurrentMap<ApplicationId, Set<Permission>> permissions =
+ new ConcurrentHashMap<>();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ApplicationIdStore idStore;
@@ -72,13 +76,20 @@
ApplicationId appId = idStore.registerApplication(name);
ApplicationDescription appDesc = getApplicationDescription(name);
DefaultApplication app =
- new DefaultApplication(appId, appDesc.version(),
- appDesc.description(), appDesc.origin(),
- appDesc.category(), appDesc.url(),
- appDesc.readme(), appDesc.icon(),
- appDesc.role(), appDesc.permissions(),
- appDesc.featuresRepo(), appDesc.features(),
- appDesc.requiredApps());
+ new DefaultApplication(appId,
+ appDesc.version(),
+ appDesc.title(),
+ appDesc.description(),
+ appDesc.origin(),
+ appDesc.category(),
+ appDesc.url(),
+ appDesc.readme(),
+ appDesc.icon(),
+ appDesc.role(),
+ appDesc.permissions(),
+ appDesc.featuresRepo(),
+ appDesc.features(),
+ appDesc.requiredApps());
apps.put(appId, app);
states.put(appId, isActive(name) ? INSTALLED : ACTIVE);
// load app permissions
@@ -118,12 +129,20 @@
ApplicationDescription appDesc = saveApplication(appDescStream);
ApplicationId appId = idStore.registerApplication(appDesc.name());
DefaultApplication app =
- new DefaultApplication(appId, appDesc.version(), appDesc.description(),
- appDesc.origin(), appDesc.category(), appDesc.url(),
- appDesc.readme(), appDesc.icon(),
- appDesc.role(), appDesc.permissions(),
- appDesc.featuresRepo(), appDesc.features(),
- appDesc.requiredApps());
+ new DefaultApplication(appId,
+ appDesc.version(),
+ appDesc.title(),
+ appDesc.description(),
+ appDesc.origin(),
+ appDesc.category(),
+ appDesc.url(),
+ appDesc.readme(),
+ appDesc.icon(),
+ appDesc.role(),
+ appDesc.permissions(),
+ appDesc.featuresRepo(),
+ appDesc.features(),
+ appDesc.requiredApps());
apps.put(appId, app);
states.put(appId, INSTALLED);
delegate.notify(new ApplicationEvent(APP_INSTALLED, app));
diff --git a/core/common/src/test/resources/org/onosproject/common/app/app.xml b/core/common/src/test/resources/org/onosproject/common/app/app.xml
index f623722..0f84e61 100644
--- a/core/common/src/test/resources/org/onosproject/common/app/app.xml
+++ b/core/common/src/test/resources/org/onosproject/common/app/app.xml
@@ -13,8 +13,10 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<app name="org.foo.app" origin="Circus" version="1.2.a" category="other"
- url="http://www.onosproject.org" featuresRepo="mvn:org.foo-features/1.2a/xml/features"
+<app name="org.foo.app" origin="Circus" version="1.2.a"
+ title="Awesome App" category="other"
+ url="http://www.onosproject.org"
+ featuresRepo="mvn:org.foo-features/1.2a/xml/features"
features="foo,bar">
<description>Awesome application from Circus, Inc.</description>
<security>
diff --git a/core/common/src/test/resources/org/onosproject/common/app/app.zip b/core/common/src/test/resources/org/onosproject/common/app/app.zip
index 6ee64c0..137f9df 100644
--- a/core/common/src/test/resources/org/onosproject/common/app/app.zip
+++ b/core/common/src/test/resources/org/onosproject/common/app/app.zip
Binary files differ
diff --git a/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java b/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java
index f66fb4d..13a3c4a 100644
--- a/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java
@@ -138,7 +138,7 @@
@Override
public Application create(InputStream appDescStream) {
- app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, CATEGORY,
+ app = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN, CATEGORY,
URL, README, ICON, ROLE, PERMS,
Optional.of(FURL), FEATURES, ImmutableList.of());
state = INSTALLED;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/app/GossipApplicationStore.java b/core/store/dist/src/main/java/org/onosproject/store/app/GossipApplicationStore.java
index 50063b2..51f759a 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/app/GossipApplicationStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/app/GossipApplicationStore.java
@@ -507,10 +507,19 @@
*/
private Application registerApp(ApplicationDescription appDesc) {
ApplicationId appId = idStore.registerApplication(appDesc.name());
- return new DefaultApplication(appId, appDesc.version(), appDesc.description(),
- appDesc.origin(), appDesc.category(), appDesc.url(),
- appDesc.readme(), appDesc.icon(), appDesc.role(),
- appDesc.permissions(), appDesc.featuresRepo(),
- appDesc.features(), appDesc.requiredApps());
+ return new DefaultApplication(appId,
+ appDesc.version(),
+ appDesc.title(),
+ appDesc.description(),
+ appDesc.origin(),
+ appDesc.category(),
+ appDesc.url(),
+ appDesc.readme(),
+ appDesc.icon(),
+ appDesc.role(),
+ appDesc.permissions(),
+ appDesc.featuresRepo(),
+ appDesc.features(),
+ appDesc.requiredApps());
}
}