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();