17944: Adds vocabulary checking support to links.
[arvados.git] / lib / controller / federation / conn.go
index 586ac23013a531dbcacdab9c705f307886abc158..d477303527c7b71e827607a24af1ba838ee23464 100644 (file)
@@ -192,6 +192,10 @@ func (conn *Conn) ConfigGet(ctx context.Context) (json.RawMessage, error) {
        return json.RawMessage(buf.Bytes()), err
 }
 
+func (conn *Conn) VocabularyGet(ctx context.Context) (arvados.Vocabulary, error) {
+       return conn.chooseBackend(conn.cluster.ClusterID).VocabularyGet(ctx)
+}
+
 func (conn *Conn) Login(ctx context.Context, options arvados.LoginOptions) (arvados.LoginResponse, error) {
        if id := conn.cluster.Login.LoginCluster; id != "" && id != conn.cluster.ClusterID {
                // defer entire login procedure to designated cluster
@@ -262,13 +266,26 @@ func (conn *Conn) CollectionGet(ctx context.Context, options arvados.GetOptions)
                if err != nil {
                        return err
                }
-               // options.UUID is either hash+size or
-               // hash+size+hints; only hash+size need to
-               // match the computed PDH.
-               if pdh := arvados.PortableDataHash(c.ManifestText); pdh != options.UUID && !strings.HasPrefix(options.UUID, pdh+"+") {
-                       err = httpErrorf(http.StatusBadGateway, "bad portable data hash %q received from remote %q (expected %q)", pdh, remoteID, options.UUID)
-                       ctxlog.FromContext(ctx).Warn(err)
-                       return err
+               haveManifest := true
+               if options.Select != nil {
+                       haveManifest = false
+                       for _, s := range options.Select {
+                               if s == "manifest_text" {
+                                       haveManifest = true
+                                       break
+                               }
+                       }
+               }
+               if haveManifest {
+                       pdh := arvados.PortableDataHash(c.ManifestText)
+                       // options.UUID is either hash+size or
+                       // hash+size+hints; only hash+size need to
+                       // match the computed PDH.
+                       if pdh != options.UUID && !strings.HasPrefix(options.UUID, pdh+"+") {
+                               err = httpErrorf(http.StatusBadGateway, "bad portable data hash %q received from remote %q (expected %q)", pdh, remoteID, options.UUID)
+                               ctxlog.FromContext(ctx).Warn(err)
+                               return err
+                       }
                }
                if remoteID != "" {
                        c.ManifestText = rewriteManifest(c.ManifestText, remoteID)
@@ -452,6 +469,26 @@ func (conn *Conn) GroupUntrash(ctx context.Context, options arvados.UntrashOptio
        return conn.chooseBackend(options.UUID).GroupUntrash(ctx, options)
 }
 
+func (conn *Conn) LinkCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Link, error) {
+       return conn.chooseBackend(options.ClusterID).LinkCreate(ctx, options)
+}
+
+func (conn *Conn) LinkUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Link, error) {
+       return conn.chooseBackend(options.UUID).LinkUpdate(ctx, options)
+}
+
+func (conn *Conn) LinkGet(ctx context.Context, options arvados.GetOptions) (arvados.Link, error) {
+       return conn.chooseBackend(options.UUID).LinkGet(ctx, options)
+}
+
+func (conn *Conn) LinkList(ctx context.Context, options arvados.ListOptions) (arvados.LinkList, error) {
+       return conn.generated_LinkList(ctx, options)
+}
+
+func (conn *Conn) LinkDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Link, error) {
+       return conn.chooseBackend(options.UUID).LinkDelete(ctx, options)
+}
+
 func (conn *Conn) SpecimenList(ctx context.Context, options arvados.ListOptions) (arvados.SpecimenList, error) {
        return conn.generated_SpecimenList(ctx, options)
 }