diff --git a/CHANGELOG.md b/CHANGELOG.md index eff74f999..95e3c0075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ If any files are returned, you should check to see if these files affected and a - Updated swagger documentation - Return 404 not found when calling file/dataset/space api endpoints with an invalid ID [#251](https://github.com/clowder-framework/clowder/issues/251) - Line breaks in welcome message breaks swagger build [#187](https://github.com/clowder-framework/clowder/issues/187) +- Collections created using api route are now indexed upon creation. [#257](https://github.com/clowder-framework/clowder/issues/257) ### Changed - Added more information when writing files to make sure files are written correctly diff --git a/app/api/Collections.scala b/app/api/Collections.scala index ebff20038..1960b373b 100644 --- a/app/api/Collections.scala +++ b/app/api/Collections.scala @@ -1,32 +1,28 @@ package api -import java.io.{ByteArrayInputStream, InputStream, ByteArrayOutputStream} -import java.security.{DigestInputStream, MessageDigest} -import java.text.SimpleDateFormat -import java.util.zip.{ZipEntry, ZipOutputStream, Deflater} - import Iterators.RootCollectionIterator -import _root_.util.JSONLD +import util.SearchUtils import api.Permission.Permission -import org.apache.commons.codec.binary.Hex +import controllers.Utils +import models._ import play.api.Logger import play.api.Play.current -import models._ +import play.api.libs.concurrent.Execution.Implicits._ import play.api.libs.iteratee.Enumerator -import services._ -import play.api.libs.json._ -import play.api.libs.json.{JsObject, JsValue} import play.api.libs.json.Json.toJson -import javax.inject.{ Singleton, Inject} -import scala.collection.mutable.ListBuffer -import scala.concurrent.{Future, ExecutionContext} -import play.api.libs.concurrent.Execution.Implicits._ -import scala.util.parsing.json.JSONArray -import scala.util.{Try, Success, Failure} -import java.util.{Calendar, Date} -import controllers.Utils +import play.api.libs.json.{JsObject, JsValue, _} +import services._ + +import java.io.ByteArrayOutputStream +import java.security.MessageDigest +import java.util.zip.{Deflater, ZipOutputStream} +import java.util.{Calendar, Date} +import javax.inject.{Inject, Singleton} import scala.collection.immutable.List +import scala.collection.mutable.ListBuffer +import scala.concurrent.{ExecutionContext, Future} +import scala.util.{Failure, Success, Try} /** @@ -72,6 +68,13 @@ class Collections @Inject() (datasets: DatasetService, collections.addToRootSpaces(c.id, s.id) events.addSourceEvent(request.user, c.id, c.name, s.id, s.name, EventType.ADD_COLLECTION_SPACE.toString) }) + // index collection + current.plugin[ElasticsearchPlugin].foreach{ + _.index(SearchUtils.getElasticsearchObject(c)) + } + //Add to Events Table + val option_user = userService.findByIdentity(identity) + events.addObjectEvent(option_user, c.id, c.name, EventType.CREATE_COLLECTION.toString) Ok(toJson(Map("id" -> id))) } case None => Ok(toJson(Map("status" -> "error"))) @@ -598,6 +601,14 @@ class Collections @Inject() (datasets: DatasetService, events.addSourceEvent(request.user, c.id, c.name, s.id, s.name, EventType.ADD_COLLECTION_SPACE.toString) } + // index collection + current.plugin[ElasticsearchPlugin].foreach{ + _.index(SearchUtils.getElasticsearchObject(c)) + } + //Add to Events Table + val option_user = userService.findByIdentity(identity) + events.addObjectEvent(option_user, c.id, c.name, EventType.CREATE_COLLECTION.toString) + //do stuff with parent here (request.body \"parentId").asOpt[String] match { case Some(parentId) => {