Skip to content

Commit

Permalink
Created more meaningful bucket names
Browse files Browse the repository at this point in the history
  • Loading branch information
bradtaylor committed Jun 26, 2015
1 parent 959a971 commit b6e6251
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Expand Up @@ -30,18 +30,22 @@ object GcsAuthorizationProvider extends AuthorizationProvider with LazyLogging {

private case class GoogleResponse(entity: AgoraEntity, response: HttpResponse)

def namespaceToBucketName(namespace: String): String = "agoraNamespace_" + namespace

def entityToObjectName(entity: AgoraEntity): String = "agoraEntity_" + entity.entityType.get + "_" + entity.name.get + "_" + entity.snapshotId.get

def getGcsObjectRoleRequestUrl(agoraEntity: AgoraEntity, userEmail: String): String = {
val agoraBusiness = new AgoraBusiness
agoraBusiness.hasNamespaceNameId(agoraEntity) match {
case true =>
"https://www.googleapis.com/storage/v1/b/" + agoraEntity.namespace.get + "/o/" + agoraEntity.name.get + agoraEntity.snapshotId.get + "/acl/user-" + userEmail
"https://www.googleapis.com/storage/v1/b/" + namespaceToBucketName(agoraEntity.namespace.get) + "/o/" + entityToObjectName(agoraEntity) + "/acl/user-" + userEmail
case false =>
throw new Exception("Trying to get Google ACLs for AgoraEntity with missing namespace, name, or snapshotId")
}
}

def getGcsBucketRoleRequestUrl(namespace: String, userEmail: String): String = {
"https://www.googleapis.com/storage/v1/b/" + namespace + "/acl/user-" + userEmail
"https://www.googleapis.com/storage/v1/b/" + namespaceToBucketName(namespace) + "/acl/user-" + userEmail
}

def insertGoogleBucketUrl(): String = {
Expand Down
Expand Up @@ -3,6 +3,7 @@ package org.broadinstitute.dsde.agora.server.webservice.validation
import org.broadinstitute.dsde.agora.server.model.{AgoraEntityType, AgoraProjectionDefaults, AgoraEntity}

object AgoraValidation {
// TODO for DSDEEPB-457: validate that namespace meets DNS requirements shown here: https://cloud.google.com/storage/docs/bucket-naming#requirements
def validateMetadata(entity: AgoraEntity): AgoraValidation = {
var validation = AgoraValidation()
if (!entity.namespace.exists(_.trim.nonEmpty)) {
Expand Down

0 comments on commit b6e6251

Please sign in to comment.