services/application: some fixes to errors returned when there are no envelopes

This CL fixes two distinct problems:

1. When we run Match against a name for which there are no
envelopes, it should return ErrNoExist instead of ErrInvalidSuffix.
This matters for the device publish tool, which treats ErrNoExist to
mean that there are no envelopes yet uploaded for the given
application (whereas if it sees ErrInvalidSuffix, it complains and
exits)

2. When we run Glob or TidyNow against the root of the application
server and there are no applications on the server, it is failing with
the confusing:
applicationd:"".[__Glob|TidyNow]: Does not exist: applications
The reason has to do with what
i.store.BindObject("/applications").Children() returns when there are no
actual app objects under /applications in the server's internal
store. The fix is to properly handle this case.

Unrelated to the above, updating the documentation for application
remove to mention the option of using '*' for all profiles.

Change-Id: I8e52e6452f40bdcf7c5dba89a37f1098c3ecfde7
diff --git a/services/application/application/doc.go b/services/application/application/doc.go
index dc803a7..e90bb42 100644
--- a/services/application/application/doc.go
+++ b/services/application/application/doc.go
@@ -106,7 +106,8 @@
 Usage:
    application remove <application> <profile>
 
-<application> is the full name of the application. <profile> is a profile.
+<application> is the full name of the application. <profile> is a profile.  If
+specified as '*', all profiles are removed.
 
 Application edit
 
diff --git a/services/application/application/impl.go b/services/application/application/impl.go
index a3768a4..406a91a 100644
--- a/services/application/application/impl.go
+++ b/services/application/application/impl.go
@@ -214,7 +214,7 @@
 	ArgsName: "<application> <profile>",
 	ArgsLong: `
 <application> is the full name of the application.
-<profile> is a profile.`,
+<profile> is a profile.  If specified as '*', all profiles are removed.`,
 }
 
 func runRemove(ctx *context.T, env *cmdline.Env, args []string) error {
diff --git a/services/application/applicationd/service.go b/services/application/applicationd/service.go
index 7ca66b8..ea012ff 100644
--- a/services/application/applicationd/service.go
+++ b/services/application/applicationd/service.go
@@ -114,7 +114,7 @@
 			return empty, err
 		}
 		if len(versions) < 1 {
-			return empty, verror.New(ErrInvalidSuffix, ctx)
+			return empty, verror.New(verror.ErrNoExist, ctx)
 		}
 		sort.Strings(versions)
 		version = versions[len(versions)-1]
@@ -226,6 +226,12 @@
 
 func (i *appRepoService) allApplications() ([]string, error) {
 	apps, err := i.store.BindObject("/applications").Children()
+	// There is no actual object corresponding to "/applications" in the
+	// store, so Children() returns ErrNoExist when there are no actual app
+	// objects under /applications.
+	if verror.ErrorID(err) == verror.ErrNoExist.ID {
+		return nil, nil
+	}
 	if err != nil {
 		return nil, err
 	}