From 5ace6fc1cee998ff1e7e9566eff863fb2bc6e27d Mon Sep 17 00:00:00 2001 From: toddn Date: Fri, 23 Jul 2021 13:28:55 -0500 Subject: [PATCH 1/2] adding indexing for new collections created by the api route --- app/api/Collections.scala | 49 ++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/app/api/Collections.scala b/app/api/Collections.scala index 09d399014..3f8f47bfe 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"))) @@ -572,6 +575,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) => { From 8c343c422d3e050d5d6a4353db500eee794f817a Mon Sep 17 00:00:00 2001 From: toddn Date: Sat, 24 Jul 2021 13:17:37 -0500 Subject: [PATCH 2/2] updating CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e734fe22..66a7cb930 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## unreleased + +### Fixed +- Collections created using api route are now indexed upon creation. [#257](https://github.com/clowder-framework/clowder/issues/257) + ## 1.18.0 - 2021-07-08 ### Added