Browse Source

metadata service won't create a catalog uid

Mark deVilliers 2 years ago
parent
commit
5cc132b2be
2 changed files with 6 additions and 19 deletions
  1. 3 16
      metadata/api/catalog.go
  2. 3 3
      metadata/api/catalog_store.go

+ 3 - 16
metadata/api/catalog.go

@@ -1,12 +1,8 @@
1 1
 package api
2 2
 
3 3
 import (
4
-	"crypto/md5"
5
-	"encoding/base64"
6
-	"fmt"
7 4
 	"log"
8 5
 	"net/http"
9
-	"strings"
10 6
 
11 7
 	validator "gopkg.in/validator.v2"
12 8
 
@@ -29,15 +25,14 @@ type ErrorResponse struct {
29 25
 // The Tags property should contain enough information to enable a search index
30 26
 // The Sample property should contain enough detail to interact with the data
31 27
 type CatalogRequest struct {
32
-	Key    string   `json:"key" description:"path of the data item" validate:"nonzero"`
33
-	Tags   []string `json:"tags" description:"a collection of tags probably belonging to an ontology" validate:"nonzero"`
34
-	Sample string   `json:"sample" description:"sample value e.g. a json object `
28
+	Subject string   `json:"subject" description:"path of the data item" validate:"nonzero"`
29
+	Tags    []string `json:"tags" description:"a collection of tags probably belonging to an ontology" validate:"nonzero"`
30
+	Sample  string   `json:"sample" description:"sample value e.g. a json object `
35 31
 }
36 32
 
37 33
 // CatalogItem contains the original request
38 34
 type CatalogItem struct {
39 35
 	CatalogRequest
40
-	UID         string `json:"uid" description:"unique identifier for the catalogued piece of data" validate:"nonzero"`
41 36
 	LocationUID string `json:"-"`
42 37
 }
43 38
 
@@ -213,16 +208,8 @@ func (e catalogResource) catalogItem(request *restful.Request, response *restful
213 208
 		return
214 209
 	}
215 210
 
216
-	// generate a consistent uid
217
-	key := []byte(fmt.Sprintf("%s:%s", locationUID, req.Key))
218
-	hash := md5.Sum(key)
219
-	encoded := base64.StdEncoding.EncodeToString(hash[:])
220
-	// urlencode the url as used in URL for deletes
221
-	encoded = strings.Replace(encoded, "/", "_", -1)
222
-
223 211
 	item := CatalogItem{
224 212
 		CatalogRequest: req,
225
-		UID:            encoded,
226 213
 		LocationUID:    locationUID,
227 214
 	}
228 215
 	e.store.Items.Add(item)

+ 3 - 3
metadata/api/catalog_store.go

@@ -49,15 +49,15 @@ func (e itemMap) Add(i CatalogItem) {
49 49
 	e.lock.Lock()
50 50
 	defer e.lock.Unlock()
51 51
 
52
-	e.store[i.UID] = i
52
+	e.store[i.Subject] = i
53 53
 
54 54
 }
55 55
 
56
-func (e itemMap) Delete(uid string) {
56
+func (e itemMap) Delete(subject string) {
57 57
 	e.lock.Lock()
58 58
 	defer e.lock.Unlock()
59 59
 
60
-	delete(e.store, uid)
60
+	delete(e.store, subject)
61 61
 }
62 62
 
63 63
 func (e itemMap) All() []CatalogItem {