From dc13227068002fab29b63d0a70213dfd239c6865 Mon Sep 17 00:00:00 2001 From: Tim Yardley Date: Wed, 18 Dec 2019 16:18:49 -0600 Subject: [PATCH 1/9] random things --- app/views/JSConsole.scala.html | 4 +++- app/views/ss/provider.scala.html | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/JSConsole.scala.html b/app/views/JSConsole.scala.html index 0835269f7..2ba480af1 100644 --- a/app/views/JSConsole.scala.html +++ b/app/views/JSConsole.scala.html @@ -1,9 +1,11 @@ @play.api.Play.maybeApplication.map(_.mode) match { case Some(play.api.Mode.Prod) => { } case _ => {} diff --git a/app/views/ss/provider.scala.html b/app/views/ss/provider.scala.html index 303a046a8..475121e6f 100644 --- a/app/views/ss/provider.scala.html +++ b/app/views/ss/provider.scala.html @@ -29,7 +29,7 @@ } @if( provider.authMethod == UserPassword ) { -
@if( UsernamePasswordProvider.withUserNameSupport ) { From 00d1fa7b615b860c360d4ac6c7301b8f9faa2a8b Mon Sep 17 00:00:00 2001 From: Tim Yardley Date: Wed, 18 Dec 2019 19:12:00 -0600 Subject: [PATCH 2/9] random cleanup --- app/Global.scala | 223 +++-------- app/Iterators/BagItIterator.scala | 2 +- app/Iterators/DatasetIterator.scala | 2 +- app/api/ApiHelp.scala | 22 +- app/api/Comments.scala | 234 +++++------ app/api/Geometry.scala | 2 +- app/api/Geostreams.scala | 46 +-- app/api/Indexes.scala | 14 +- app/api/Permissions.scala | 18 +- app/api/Sections.scala | 34 +- app/api/Selected.scala | 26 +- app/api/Sensors.scala | 77 ++-- app/api/ThreeDTexture.scala | 2 +- app/api/ZoomIt.scala | 2 +- app/controllers/Admin.scala | 6 +- app/controllers/Application.scala | 2 +- app/controllers/Collections.scala | 4 +- app/controllers/Datasets.scala | 2 +- app/controllers/Error.scala | 2 +- app/controllers/ExtractionInfo.scala | 2 +- app/controllers/Extractors.scala | 2 +- app/controllers/Files.scala | 162 ++++---- app/controllers/Geostreams.scala | 2 +- app/controllers/Login.scala | 2 +- app/controllers/Search.scala | 36 +- app/controllers/Selected.scala | 6 +- app/controllers/ToolManager.scala | 2 +- app/controllers/Utils.scala | 2 +- app/filters/CORSFilter.scala | 2 +- app/models/CurationObject.scala | 2 +- app/models/DBCounts.scala | 2 +- app/models/Dataset.scala | 2 +- app/models/Event.scala | 24 +- app/models/ExtractionInfoSetUp.scala | 2 +- app/models/ExtractorsForInstance.scala | 3 +- app/models/FileOP.scala | 4 +- app/models/IncrementCounter.scala | 2 +- app/models/Metadata.scala | 20 +- app/models/RequestResource.scala | 2 +- app/models/Role.scala | 2 +- app/models/Section.scala | 2 +- app/models/SectionIndexInfo.scala | 2 +- app/models/ServerStartTime.scala | 2 +- app/models/StandardVocab.scala | 2 +- app/models/TempFile.scala | 2 +- app/models/User.scala | 6 +- app/models/UserSpaceAndRole.scala | 2 +- app/models/VersusExtraction.scala | 8 +- app/models/VersusIndex.scala | 48 +-- app/models/VersusIndexTypeName.scala | 2 +- app/models/WebPageResource.scala | 2 +- app/services/AdminsNotifierPlugin.scala | 2 +- app/services/ContextLDService.scala | 3 +- app/services/CrowdProvider.scala | 2 +- app/services/DatasetsAutodumpService.scala | 11 +- .../DatasetsMetadataAutodumpService.scala | 9 +- app/services/ElasticsearchPlugin.scala | 2 +- app/services/EventService.scala | 166 ++++---- app/services/ExtractionRequestsService.scala | 2 +- app/services/ExtractorService.scala | 2 +- app/services/FileDumpService.scala | 32 +- .../FileMetadataAutodumpService.scala | 11 +- app/services/LdapProvider.scala | 2 +- app/services/MailerPlugin.scala | 20 +- app/services/MultimediaQueryService.scala | 2 +- app/services/PolyglotPlugin.scala | 8 +- app/services/PostgresPlugin.scala | 30 +- app/services/RDFExportService.scala | 224 +++++------ app/services/RDFUpdateService.scala | 378 +++++++++--------- app/services/RabbitmqPlugin.scala | 2 +- app/services/RdfSPARQLService.scala | 2 +- app/services/SchedulerService.scala | 68 ++-- app/services/SectionIndexInfoService.scala | 82 ++-- app/services/SectionService.scala | 2 +- .../SecureSocialTemplatesPlugin.scala | 2 +- app/services/SpaceService.scala | 24 +- .../fourstore/FourStoreRdfSPARQLService.scala | 189 +++++---- app/services/irods/IRODSPlugin.scala | 66 +-- .../mongodb/MongoDBAuthenticatorStore.scala | 3 +- .../mongodb/MongoDBCollectionService.scala | 20 +- .../mongodb/MongoDBContextLDService.scala | 2 +- .../mongodb/MongoDBCurationService.scala | 2 +- .../mongodb/MongoDBDatasetService.scala | 276 ++++++------- .../mongodb/MongoDBExtractionService.scala | 16 +- app/services/mongodb/MongoDBFileService.scala | 166 ++++---- .../mongodb/MongoDBFolderService.scala | 2 +- .../MongoDBMultimediaQueryService.scala | 4 +- .../mongodb/MongoDBPreviewService.scala | 2 +- .../mongodb/MongoDBSchedulerService.scala | 2 +- .../MongoDBSectionIndexInfoService.scala | 14 +- .../mongodb/MongoDBSectionService.scala | 2 +- .../mongodb/MongoDBSpaceService.scala | 22 +- .../MongoDBStandardVocabularyService.scala | 2 +- app/services/mongodb/MongoDBUserService.scala | 2 +- app/util/DistancePriorityQueue.scala | 20 +- app/util/FileUtils.scala | 6 +- app/util/Publications.scala | 2 +- app/util/RequiredFieldsConfig.scala | 2 +- app/util/SearchUtils.scala | 2 +- app/util/SpaceConfig.scala | 2 +- 100 files changed, 1437 insertions(+), 1558 deletions(-) diff --git a/app/Global.scala b/app/Global.scala index 24adc32b8..3f5c264b9 100644 --- a/app/Global.scala +++ b/app/Global.scala @@ -1,178 +1,71 @@ -import java.io.{PrintWriter, StringWriter} -import java.time.Duration -import java.time.ZonedDateTime -import java.time.temporal.ChronoUnit - -import play.api.{Application, GlobalSettings} -import play.api.Logger -import play.filters.gzip.GzipFilter -import play.libs.Akka -import securesocial.core.SecureSocial -import services.{AppConfiguration, AppConfigurationService, CollectionService, DI, DatasetService, FileService, SpaceService, UserService} - -import scala.concurrent.Future -import scala.concurrent.duration._ -import play.api.libs.concurrent.Execution.Implicits._ -import models._ -import java.util.{Calendar, Date} - -import play.api.mvc.{RequestHeader, WithFilters} -import play.api.mvc.Results._ -import akka.actor.Cancellable -import filters.CORSFilter -import julienrf.play.jsonp.Jsonp -import play.Play -import play.api.Play.configuration -import play.api.libs.json.Json._ - -/** - * Configure application. Ensure mongo indexes if mongo plugin is enabled. - * - * @author Luigi Marini - */ -object Global extends WithFilters(new GzipFilter(), new Jsonp(), CORSFilter()) with GlobalSettings { - var extractorTimer: Cancellable = null - var jobTimer: Cancellable = null - var archivalTimer: Cancellable = null - - - override def onStart(app: Application) { - val appConfig: AppConfigurationService = DI.injector.getInstance(classOf[AppConfigurationService]) - val files: FileService = DI.injector.getInstance(classOf[FileService]) - - ServerStartTime.startTime = Calendar.getInstance().getTime - Logger.debug("\n----Server Start Time----" + ServerStartTime.startTime + "\n \n") - - val users: UserService = DI.injector.getInstance(classOf[UserService]) - - // set the default ToS version - AppConfiguration.setDefaultTermsOfServicesVersion() - - // add all new admins - users.updateAdmins() - - // create default roles - if (users.listRoles().isEmpty) { - Logger.debug("Ensuring roles exist") - users.updateRole(Role.Admin) - users.updateRole(Role.Editor) - users.updateRole(Role.Viewer) - } - - // set default metadata definitions - MetadataDefinition.registerDefaultDefinitions() - - val archiveEnabled = Play.application.configuration.getBoolean("archiveEnabled", false) - if (archiveEnabled && archivalTimer == null) { - val archiveDebug = Play.application.configuration.getBoolean("archiveDebug", false) - val interval = if (archiveDebug) { 5 minutes } else { 1 day } - - // Determine time until next midnight - val now = ZonedDateTime.now - val midnight = now.truncatedTo(ChronoUnit.DAYS) - val sinceLastMidnight = Duration.between(midnight, now).getSeconds - val delay = if (archiveDebug) { 10 seconds } else { - (Duration.ofDays(1).getSeconds - sinceLastMidnight) seconds - } - - Logger.info("Starting archival loop - first iteration in " + delay + ", next iteration after " + interval) - archivalTimer = Akka.system.scheduler.schedule(delay, interval) { - Logger.info("Starting auto archive process...") - files.autoArchiveCandidateFiles() - } +import models.UUID +import play.api.mvc._ +import com.mongodb.casbah.Imports._ +import org.bson.types.ObjectId +import play.api.libs.json._ +import play.api.data.validation.ValidationError + +object Binders { + + type ObjectId = org.bson.types.ObjectId + + /** + * QueryString binder for ObjectId + */ + implicit def objectIdQueryStringBindable = new QueryStringBindable[ObjectId] { + def bind(key: String, params: Map[String, Seq[String]]) = params.get(key).flatMap(_.headOption).map { value => + if (ObjectId.isValid(value)) + Right(new ObjectId(value)) + else + Left("Cannot parse parameter " + key + " as ObjectId") } - - if (extractorTimer == null) { - extractorTimer = Akka.system().scheduler.schedule(0 minutes, 5 minutes) { - ExtractionInfoSetUp.updateExtractorsInfo() - } - } - - if (jobTimer == null) { - jobTimer = Akka.system().scheduler.schedule(0 minutes, 1 minutes) { - JobsScheduler.runScheduledJobs() - } - } - - // Get database counts from appConfig; generate them if unavailable or user count = 0 - appConfig.getProperty[Long]("countof.bytes") match { - case Some(filesBytes) => - Logger.info("Byte count found in appConfig; skipping database counting") - case None => { - // Reset byte count to zero before incrementing - appConfig.resetCount('bytes) - - Logger.info("Byte count not found in appConfig; scheduling database counting in 10s...") - Akka.system().scheduler.scheduleOnce(10 seconds) { - Logger.debug("Initializing appConfig byte count...") - val files: FileService = DI.injector.getInstance(classOf[FileService]) - - // Store the byte count in appConfig so it can be fetched quickly later - appConfig.incrementCount('bytes, files.bytes()) - Logger.info("Initialized appConfig byte count") - } - } - } - - Logger.info("Application has started") - } - - override def onStop(app: Application) { - extractorTimer.cancel() - jobTimer.cancel() - Logger.info("Application shutdown") + def unbind(key: String, value: ObjectId) = key + "=" + value.toString } - private lazy val injector = services.DI.injector - private lazy val users: UserService = DI.injector.getInstance(classOf[UserService]) - - /** Used for dynamic controller dispatcher **/ - override def getControllerInstance[A](clazz: Class[A]) = { - injector.getInstance(clazz) + /** + * Path binder for ObjectId. + */ + implicit def objectIdPathBindable = new PathBindable[ObjectId] { + def bind(key: String, value: String) = { + if (ObjectId.isValid(value)) + Right(new ObjectId(value)) + else + Left("Cannot parse parameter " + key + " as ObjectId") + } + def unbind(key: String, value: ObjectId) = value.toString } - override def onError(request: RequestHeader, ex: Throwable) = { - val sw = new StringWriter() - val pw = new PrintWriter(sw) - ex.printStackTrace(pw) - - if (request.path.contains("/api/")) { - Future(InternalServerError(toJson(Map("status" -> "error", - "request" -> request.toString(), - "exception" -> sw.toString.replace("\n", "\\n"))))) - } else { - implicit val user = SecureSocial.currentUser(request) match{ - case Some(identity) => users.findByIdentity(identity) - case None => None - } - Future(InternalServerError(views.html.errorPage(request, sw.toString)(user))) - } + /** + * Convert a ObjectId to a Javascript String + */ + implicit def objectIdJavascriptLitteral = new JavascriptLitteral[ObjectId] { + def to(value: ObjectId) = value.toString } - override def onHandlerNotFound(request: RequestHeader) = { - if (request.path.contains("/api/")) { - Future(NotFound(toJson(Map("status" -> "not found", - "request" -> request.toString())))) - } else { - implicit val user = SecureSocial.currentUser(request) match { - case Some(identity) => users.findByIdentity(identity) - case None => None - } - Future(NotFound(views.html.errorPage(request, "Not found")(user))) + /** + * UUID path binder + */ + implicit def uuidPathBinder(implicit stringBinder: PathBindable[String]) = new PathBindable[UUID] { + override def bind(key: String, value: String): Either[String, UUID] = { + if (UUID.isValid(value)) + Right(UUID(value)) + else + Left(s"Cannot parse parameter $key") } + override def unbind(key: String, uuid: UUID): String = uuid.stringify } - override def onBadRequest(request: RequestHeader, error: String) = { - if (request.path.contains("/api/")) { - Future(BadRequest(toJson(Map("status" -> ("bad request"), - "message" -> error, - "request" -> request.toString())))) - } else { - implicit val user = SecureSocial.currentUser(request) match { - case Some(identity) => users.findByIdentity(identity) - case None => None - } - Future(BadRequest(views.html.errorPage(request, error)(user))) + /** + * UUID query binder + */ + implicit def uuidQueryBinder(implicit stringBinder: QueryStringBindable[String]) = new QueryStringBindable[UUID] { + override def bind(key: String, params: Map[String, Seq[String]]): Option[Either[String, UUID]] = { + val value = params(key)(0) + if (UUID.isValid(value)) + Some(Right(UUID(value))) + else + Some(Left(s"Cannot parse parameter $key")) } + override def unbind(key: String, uuid: UUID): String = uuid.stringify } } diff --git a/app/Iterators/BagItIterator.scala b/app/Iterators/BagItIterator.scala index c87fafd25..d8cb0924f 100644 --- a/app/Iterators/BagItIterator.scala +++ b/app/Iterators/BagItIterator.scala @@ -149,4 +149,4 @@ class BagItIterator(pathToFolder : String, collection : Option[models.Collection } } } -} \ No newline at end of file +} diff --git a/app/Iterators/DatasetIterator.scala b/app/Iterators/DatasetIterator.scala index ac56bd496..2068f3218 100644 --- a/app/Iterators/DatasetIterator.scala +++ b/app/Iterators/DatasetIterator.scala @@ -172,4 +172,4 @@ class DatasetIterator(pathToFolder : String, dataset : models.Dataset, zip: ZipO } } } -} \ No newline at end of file +} diff --git a/app/api/ApiHelp.scala b/app/api/ApiHelp.scala index 6321247d8..0bb8f292a 100644 --- a/app/api/ApiHelp.scala +++ b/app/api/ApiHelp.scala @@ -20,15 +20,15 @@ object ApiHelp extends Controller { */ def getResources() = Action { Ok(toJson(""" - { - apiVersion: "0.1", - swaggerVersion: "1.1", - basePath: "http://localhost:9000/api", - apis: [ - { - path: "/datasets.json", - description: "Datasets are basic containers of data" - }, + { + apiVersion: "0.1", + swaggerVersion: "1.1", + basePath: "http://localhost:9000/api", + apis: [ + { + path: "/datasets.json", + description: "Datasets are basic containers of data" + }, { path: "/files.json", description: "Files include raw bytes and metadata" @@ -37,8 +37,8 @@ object ApiHelp extends Controller { path: "/collections.json", description: "Collections are groupings of datasets" } - ] - } + ] + } """)) } diff --git a/app/api/Comments.scala b/app/api/Comments.scala index adfc5db02..ae7bda6e8 100644 --- a/app/api/Comments.scala +++ b/app/api/Comments.scala @@ -20,7 +20,7 @@ class Comments @Inject()(datasets: DatasetService, comments: CommentService, eve def comment(id: UUID) = PermissionAction(Permission.AddComment, Some(ResourceRef(ResourceRef.comment, id)))(parse.json) { implicit request => Logger.trace("Adding comment") - comments.get(id) match { + comments.get(id) match { case Some(parent) => { request.user match { case Some(identity) => { @@ -58,150 +58,150 @@ class Comments @Inject()(datasets: DatasetService, comments: CommentService, eve case None => BadRequest } } - + //Remove comment code starts /** * REST endpoint: DELETE: remove a comment associated with a specific file - * + * * The method takes a single arg: - * + * * id: A UUID that identifies the comment to be removed. - * + * * The request body needs no data, so it should be empty. - * + * * Only the owner of a comment will be allowed to delete it. Any other request will fail. - * + * */ def removeComment(id: UUID) = PermissionAction(Permission.DeleteComment, Some(ResourceRef(ResourceRef.comment, id)))(parse.json) { implicit request => - request.user match { - case Some(identity) => { - var commentId: UUID = id - if (UUID.isValid(commentId.stringify)) { - - Logger.debug(s"removeComment from file with id $commentId.") - //Check to make sure user email matches the comment email - comments.get(commentId) match { - case Some(theComment) => { - //Check to make sure the user is the same as the author, otherwise, they - //shouldn't be able to delete the comment. - if (identity.email == theComment.author.email) { - comments.removeComment(commentId) - Ok(Json.obj("status" -> "success")) - } - else { - Logger.error(s"Only the ${Messages("owner").toLowerCase()} can delete the comment.") - BadRequest(toJson(s"Only ${Messages("owner").toLowerCase()} can delete the comment.")) - } - } - case None => { - //Really shouldn't happen - BadRequest(toJson("Error getting the comment.")) - } - } - } - else { - Logger.error(s"The given id $commentId is not a valid ObjectId.") - BadRequest(toJson(s"The given id $commentId is not a valid ObjectId.")) - } - } - case None => { - //This case shouldn't happen, as there are checks to prevent this API from being - //called without an Identity - BadRequest - } - } + request.user match { + case Some(identity) => { + var commentId: UUID = id + if (UUID.isValid(commentId.stringify)) { + + Logger.debug(s"removeComment from file with id $commentId.") + //Check to make sure user email matches the comment email + comments.get(commentId) match { + case Some(theComment) => { + //Check to make sure the user is the same as the author, otherwise, they + //shouldn't be able to delete the comment. + if (identity.email == theComment.author.email) { + comments.removeComment(commentId) + Ok(Json.obj("status" -> "success")) + } + else { + Logger.error(s"Only the ${Messages("owner").toLowerCase()} can delete the comment.") + BadRequest(toJson(s"Only ${Messages("owner").toLowerCase()} can delete the comment.")) + } + } + case None => { + //Really shouldn't happen + BadRequest(toJson("Error getting the comment.")) + } + } + } + else { + Logger.error(s"The given id $commentId is not a valid ObjectId.") + BadRequest(toJson(s"The given id $commentId is not a valid ObjectId.")) + } + } + case None => { + //This case shouldn't happen, as there are checks to prevent this API from being + //called without an Identity + BadRequest + } + } } //End, remove comment code - + //Edit comment code starts /** * REST endpoint: POST: edit a comment associated with a specific file - * + * * The method takes a single arg: - * + * * id: A UUID that identifies the comment to be edited. - * + * * The data contained in the request body will contain data for the edit, stored in the following key-value pairs: - * + * * "commentText" -> The updated text to be used for the comment. - * + * * Only the owner of the comment will be allowed to edit it. Other requests will fail. - * + * */ def editComment(id: UUID) = PermissionAction(Permission.EditComment, Some(ResourceRef(ResourceRef.comment, id)))(parse.json) { implicit request => - request.user match { - case Some(identity) => { - var commentId: UUID = id - if (UUID.isValid(commentId.stringify)) { - Logger.debug(s"editComment from file with id $commentId.") - - comments.get(commentId) match { - case Some(theComment) => { - //Make sure that the author of the comment is the one editing it - if (identity.email == theComment.author.email) { - //Set up the vars we are looking for - var commentText: String = null; + request.user match { + case Some(identity) => { + var commentId: UUID = id + if (UUID.isValid(commentId.stringify)) { + Logger.debug(s"editComment from file with id $commentId.") + + comments.get(commentId) match { + case Some(theComment) => { + //Make sure that the author of the comment is the one editing it + if (identity.email == theComment.author.email) { + //Set up the vars we are looking for + var commentText: String = null; - var aResult: JsResult[String] = (request.body \ "commentText").validate[String] + var aResult: JsResult[String] = (request.body \ "commentText").validate[String] - // Pattern matching - aResult match { - case s: JsSuccess[String] => { - commentText = s.get - } - case e: JsError => { - Logger.error("Errors: " + JsError.toFlatJson(e).toString()) - BadRequest(toJson(s"description data is missing.")) - } - } + // Pattern matching + aResult match { + case s: JsSuccess[String] => { + commentText = s.get + } + case e: JsError => { + Logger.error("Errors: " + JsError.toFlatJson(e).toString()) + BadRequest(toJson(s"description data is missing.")) + } + } - Logger.debug(s"editComment from file with id $commentId.") + Logger.debug(s"editComment from file with id $commentId.") - comments.editComment(commentId, commentText) - events.addObjectEvent(request.user, commentId, commentText, EventType.EDIT_COMMENT.toString) - Ok(Json.obj("status" -> "success")) - } - else { - Logger.error(s"Only the ${Messages("owner").toLowerCase()} can edit the comment.") - BadRequest(toJson(s"Only ${Messages("owner").toLowerCase()} can edit the comment.")) - } - } - case None => { - //Shouldn't happen - BadRequest(toJson("Error getting the comment")) - } - } - } - else { - Logger.error(s"The given id $commentId is not a valid ObjectId.") - BadRequest(toJson(s"The given id $commentId is not a valid ObjectId.")) - } - } - case None => { - //This case shouldn't happen, as there are checks to prevent this API from being - //called without an Identity - BadRequest - } - } + comments.editComment(commentId, commentText) + events.addObjectEvent(request.user, commentId, commentText, EventType.EDIT_COMMENT.toString) + Ok(Json.obj("status" -> "success")) + } + else { + Logger.error(s"Only the ${Messages("owner").toLowerCase()} can edit the comment.") + BadRequest(toJson(s"Only ${Messages("owner").toLowerCase()} can edit the comment.")) + } + } + case None => { + //Shouldn't happen + BadRequest(toJson("Error getting the comment")) + } + } + } + else { + Logger.error(s"The given id $commentId is not a valid ObjectId.") + BadRequest(toJson(s"The given id $commentId is not a valid ObjectId.")) + } + } + case None => { + //This case shouldn't happen, as there are checks to prevent this API from being + //called without an Identity + BadRequest + } + } } //End, remove comment code - /** - * This will create an event in the specified user's feed indicating they were mentioned in a comment - * on the specified resource. + /** + * This will create an event in the specified user's feed indicating they were mentioned in a comment + * on the specified resource. */ - def mentionInComment(userid: UUID, resourceID: UUID, resourceName: String, resourceType: String, commenterId: UUID) = - PermissionAction(Permission.AddComment, Some(ResourceRef(Symbol(resourceType), resourceID))) { - users.get(commenterId) match { - case Some(u) => { - events.addRequestEvent(users.get(userid), u, resourceID, resourceName, "mention_"+resourceType+"_comment") - Ok(s"Mention event added to user id $userid's feed") - } - case None => { - events.addObjectEvent(users.get(userid), resourceID, resourceName, "mention_"+resourceType+"_comment") - Ok(s"Mention event added to user id $userid's feed") - } - } + def mentionInComment(userid: UUID, resourceID: UUID, resourceName: String, resourceType: String, commenterId: UUID) = + PermissionAction(Permission.AddComment, Some(ResourceRef(Symbol(resourceType), resourceID))) { + users.get(commenterId) match { + case Some(u) => { + events.addRequestEvent(users.get(userid), u, resourceID, resourceName, "mention_"+resourceType+"_comment") + Ok(s"Mention event added to user id $userid's feed") + } + case None => { + events.addObjectEvent(users.get(userid), resourceID, resourceName, "mention_"+resourceType+"_comment") + Ok(s"Mention event added to user id $userid's feed") + } + } - } + } } diff --git a/app/api/Geometry.scala b/app/api/Geometry.scala index 5cdd54bf1..ab2f7672e 100644 --- a/app/api/Geometry.scala +++ b/app/api/Geometry.scala @@ -27,4 +27,4 @@ class Geometry @Inject()(threeD: ThreeDService) extends Controller with ApiContr BadRequest(toJson("File not attached.")) } } -} \ No newline at end of file +} diff --git a/app/api/Geostreams.scala b/app/api/Geostreams.scala index 75d66898c..5877625e7 100644 --- a/app/api/Geostreams.scala +++ b/app/api/Geostreams.scala @@ -229,34 +229,34 @@ object Geostreams extends ApiController { def updateStatisticsSensor(id: String) = PermissionAction(Permission.AddGeoStream) { implicit request => Logger.debug("update sensor statistics for " + id) current.plugin[PostgresPlugin] match { - case Some(plugin) if plugin.isEnabled => { - plugin.updateSensorStats(Some(id)) - jsonp("""{"status":"updated"}""", request) - } + case Some(plugin) if plugin.isEnabled => { + plugin.updateSensorStats(Some(id)) + jsonp("""{"status":"updated"}""", request) + } case _ => pluginNotEnabled - } + } } def updateStatisticsStream(id: String) = PermissionAction(Permission.AddGeoStream) { implicit request => Logger.debug("update stream statistics for " + id) - current.plugin[PostgresPlugin] match { - case Some(plugin) if plugin.isEnabled => { - plugin.updateStreamStats(Some(id)) - jsonp("""{"status":"updated"}""", request) - } + current.plugin[PostgresPlugin] match { + case Some(plugin) if plugin.isEnabled => { + plugin.updateStreamStats(Some(id)) + jsonp("""{"status":"updated"}""", request) + } case _ => pluginNotEnabled - } + } } def updateStatisticsStreamSensor() = PermissionAction(Permission.AddGeoStream) { implicit request => Logger.debug("update all sensor/stream statistics") - current.plugin[PostgresPlugin] match { - case Some(plugin) if plugin.isEnabled => { - plugin.updateSensorStats(None) - jsonp("""{"status":"updated"}""", request) - } + current.plugin[PostgresPlugin] match { + case Some(plugin) if plugin.isEnabled => { + plugin.updateSensorStats(None) + jsonp("""{"status":"updated"}""", request) + } case _ => pluginNotEnabled - } + } } def getSensorStatistics(id: String) = PermissionAction(Permission.ViewGeoStream) { implicit request => @@ -402,8 +402,8 @@ object Geostreams extends ApiController { current.plugin[PostgresPlugin] match { case Some(plugin) if plugin.isEnabled => { plugin.counts() match { - case (sensors, streams, datapoints) => jsonp(Json.obj("sensors"->sensors,"streams"->streams,"datapoints"->datapoints), request) - case _ => jsonp("""{"status":"error"}""", request) + case (sensors, streams, datapoints) => jsonp(Json.obj("sensors"->sensors,"streams"->streams,"datapoints"->datapoints), request) + case _ => jsonp("""{"status":"error"}""", request) } } case _ => pluginNotEnabled @@ -676,7 +676,7 @@ object Geostreams extends ApiController { var counter = new DateTime((startTime.getYear / 10) * 10, 1, 1, 0, 0, 0) while (counter.isBefore(endTime) || counter.isEqual(endTime)) { val year = counter.getYear - val date = new DateTime(year+5,7,1,12,0,0) + val date = new DateTime(year + 5,7,1,12,0,0) result.put(year.toString, Json.obj("year" -> year, "date" -> iso.print(date))) counter = counter.plusYears(10) } @@ -685,7 +685,7 @@ object Geostreams extends ApiController { var counter = new DateTime((startTime.getYear / 5) * 5, 1, 1, 0, 0, 0) while (counter.isBefore(endTime) || counter.isEqual(endTime)) { val year = counter.getYear - val date = new DateTime(year+2,7,1,12,0,0) + val date = new DateTime(year + 2,7,1,12,0,0) result.put(year.toString, Json.obj("year" -> year, "date" -> iso.print(date))) counter = counter.plusYears(5) } @@ -731,9 +731,9 @@ object Geostreams extends ApiController { result.put(year + " fall", Json.obj("year" -> year, "date" -> iso.print(new DateTime(year, 11, 1, 12, 0, 0)))) } else { - result.put(year + " winter", Json.obj("year" -> year, + result.put(year + " winter", Json.obj("year" -> year, "date" -> iso.print(new DateTime(year, 2, 1, 12, 0, 0)))) - } + } counter = counter.plusMonths(3) } } diff --git a/app/api/Indexes.scala b/app/api/Indexes.scala index 86158328a..81567fc94 100644 --- a/app/api/Indexes.scala +++ b/app/api/Indexes.scala @@ -21,9 +21,9 @@ class Indexes @Inject() (multimediaSearch: MultimediaQueryService, previews: Pre */ def index() = PermissionAction(Permission.MultimediaIndexDocument)(parse.json) { implicit request => (request.body \ "section_id").asOpt[String].map { section_id => - (request.body \ "preview_id").asOpt[String].map { preview_id => + (request.body \ "preview_id").asOpt[String].map { preview_id => previews.get(UUID(preview_id)) match { - case Some(p) => + case Some(p) => current.plugin[RabbitmqPlugin].foreach{ _.submitSectionPreviewManually(p, new UUID(section_id), Utils.baseUrl(request), request.apiKey) } @@ -32,12 +32,12 @@ class Indexes @Inject() (multimediaSearch: MultimediaQueryService, previews: Pre _.indexPreview(p.id,fileType) } Ok(toJson("success")) - case None => + case None => BadRequest(toJson("Missing parameter [preview_id]")) } - }.getOrElse { - BadRequest(toJson("Missing parameter [preview_id]")) - } + }.getOrElse { + BadRequest(toJson("Missing parameter [preview_id]")) + } }.getOrElse { BadRequest(toJson("Missing parameter [section_id]")) } @@ -59,7 +59,7 @@ class Indexes @Inject() (multimediaSearch: MultimediaQueryService, previews: Pre case None => { val jsFeatures = (request.body \ "features").as[List[JsObject]] val features = jsFeatures.map {f => - Feature((f \ "representation").as[String], (f \ "descriptor").as[List[Double]]) + Feature((f \ "representation").as[String], (f \ "descriptor").as[List[Double]]) } val doc = MultimediaFeatures(section_id = Some(sectionUUID), features = features) multimediaSearch.insert(doc) diff --git a/app/api/Permissions.scala b/app/api/Permissions.scala index c60d96dd7..813035c1f 100644 --- a/app/api/Permissions.scala +++ b/app/api/Permissions.scala @@ -13,8 +13,8 @@ import services._ object Permission extends Enumeration { type Permission = Value - // spaces - val ViewSpace, + // spaces + val ViewSpace, CreateSpace, DeleteSpace, EditSpace, @@ -77,10 +77,10 @@ object Permission extends Enumeration { CreateSensor, ViewSensor, DeleteSensor, - AddGeoStream, - ViewGeoStream, - DeleteGeoStream, - AddDatapoints, + AddGeoStream, + ViewGeoStream, + DeleteGeoStream, + AddDatapoints, // relations CreateRelation, @@ -139,9 +139,9 @@ object Permission extends Enumeration { lazy val vocabularyterms: VocabularyTermService = DI.injector.getInstance(classOf[VocabularyTermService]) /** Returns true if the user is listed as a server admin */ - def checkServerAdmin(user: Option[User]): Boolean = { - user.exists(u => u.status==UserStatus.Admin) - } + def checkServerAdmin(user: Option[User]): Boolean = { + user.exists(u => u.status==UserStatus.Admin) + } /** Returns true if the user is the owner of the resource, this function is used in the code for checkPermission as well. */ def checkOwner(user: Option[User], resourceRef: ResourceRef): Boolean = { diff --git a/app/api/Sections.scala b/app/api/Sections.scala index 192de0d8e..077f10713 100644 --- a/app/api/Sections.scala +++ b/app/api/Sections.scala @@ -172,23 +172,23 @@ class Sections @Inject()( } def description(id: UUID) = PermissionAction(Permission.EditSection, Some(ResourceRef(ResourceRef.section, id)))(parse.json) { implicit request => - request.user match { - case Some(identity) => { - request.body.\("description").asOpt[String] match { - case Some(descr) => { - sections.setDescription(id, descr) - Ok(toJson(Map("status"->"success"))) - } - case None => { - Logger.error("no section description specified.") - BadRequest(toJson("no section description specified.")) - } - } - } - case None => - Logger.error(("No user identity found in the request, request body: " + request.body)) - BadRequest(toJson("No user identity found in the request, request body: " + request.body)) - } + request.user match { + case Some(identity) => { + request.body.\("description").asOpt[String] match { + case Some(descr) => { + sections.setDescription(id, descr) + Ok(toJson(Map("status"->"success"))) + } + case None => { + Logger.error("no section description specified.") + BadRequest(toJson("no section description specified.")) + } + } + } + case None => + Logger.error(("No user identity found in the request, request body: " + request.body)) + BadRequest(toJson("No user identity found in the request, request body: " + request.body)) + } } /** diff --git a/app/api/Selected.scala b/app/api/Selected.scala index 3f5b3996e..a65ab2166 100644 --- a/app/api/Selected.scala +++ b/app/api/Selected.scala @@ -44,7 +44,7 @@ class Selected @Inject()(selections: SelectionService, def add() = AuthenticatedAction(parse.json) { implicit request => Logger.debug("Requesting Selected.add" + request.body) request.body.\("dataset").asOpt[String] match { - case Some(dataset) => { + case Some(dataset) => { request.user match { case Some(user) => { selections.add(UUID(dataset), user.email.get) @@ -52,18 +52,18 @@ class Selected @Inject()(selections: SelectionService, } case None => Ok(toJson(Map("success"->"false", "msg"->"User not logged in"))) } - } - case None => { - Logger.error("no dataset specified") - BadRequest - } + } + case None => { + Logger.error("no dataset specified") + BadRequest + } } } def remove() = AuthenticatedAction(parse.json) { implicit request => Logger.debug("Requesting Selected.remove" + request.body) request.body.\("dataset").asOpt[String] match { - case Some(dataset) => { + case Some(dataset) => { request.user match { case Some(user) => { selections.remove(UUID(dataset), user.email.get) @@ -71,11 +71,11 @@ class Selected @Inject()(selections: SelectionService, } case None => Ok(toJson(Map("success"->"false", "msg"->"User not logged in"))) } - } - case None => { - Logger.error("no dataset specified") - BadRequest - } + } + case None => { + Logger.error("no dataset specified") + BadRequest + } } } @@ -193,4 +193,4 @@ class Selected @Inject()(selections: SelectionService, } } } -} \ No newline at end of file +} diff --git a/app/api/Sensors.scala b/app/api/Sensors.scala index 6a5b49eee..f020dadee 100644 --- a/app/api/Sensors.scala +++ b/app/api/Sensors.scala @@ -5,64 +5,63 @@ import play.api.Play.current import services.PostgresPlugin /** - * Metadata about sensors registered with the system. Datastreams can be associalted with sensors. + * Metadata about sensors registered with the system. Datastreams can be associated with sensors. */ object Sensors extends Controller with ApiController { def add() = PermissionAction(Permission.AddGeoStream)(parse.json) { implicit request => - current.plugin[PostgresPlugin] match { - case Some(plugin) => { - Ok("") - } - case None => { - Ok("") - } + current.plugin[PostgresPlugin] match { + case Some(plugin) => { + Ok("") } + case None => { + Ok("") + } + } } def get(id: String) = PermissionAction(Permission.ViewGeoStream)(parse.json) { implicit request => - current.plugin[PostgresPlugin] match { - case Some(plugin) => { - Ok("") - } - case None => { - Ok("") - } + current.plugin[PostgresPlugin] match { + case Some(plugin) => { + Ok("") + } + case None => { + Ok("") } + } } def list() = PermissionAction(Permission.ViewGeoStream)(parse.json) { implicit request => - current.plugin[PostgresPlugin] match { - case Some(plugin) => { - val sensors = plugin.listSensors() - Ok("") - } - case None => { - Ok("") - } + current.plugin[PostgresPlugin] match { + case Some(plugin) => { + val sensors = plugin.listSensors() + Ok("") + } + case None => { + Ok("") } + } } def search() = PermissionAction(Permission.ViewGeoStream)(parse.json) { implicit request => - current.plugin[PostgresPlugin] match { - case Some(plugin) => { - Ok("") - } - case None => { - Ok("") - } + current.plugin[PostgresPlugin] match { + case Some(plugin) => { + Ok("") } + case None => { + Ok("") + } + } } def delete(id: String) = PermissionAction(Permission.DeleteGeoStream)(parse.json) { implicit request => - current.plugin[PostgresPlugin] match { - case Some(plugin) => { - Ok("") - } - case None => { - Ok("") - } + current.plugin[PostgresPlugin] match { + case Some(plugin) => { + Ok("") + } + case None => { + Ok("") } + } } - -} \ No newline at end of file +} diff --git a/app/api/ThreeDTexture.scala b/app/api/ThreeDTexture.scala index 6cd4f1150..bc8f56db3 100644 --- a/app/api/ThreeDTexture.scala +++ b/app/api/ThreeDTexture.scala @@ -28,4 +28,4 @@ class ThreeDTexture @Inject()(threeD: ThreeDService) extends Controller with Api BadRequest(toJson("File not attached.")) } } -} \ No newline at end of file +} diff --git a/app/api/ZoomIt.scala b/app/api/ZoomIt.scala index 8835b9476..9c2250316 100644 --- a/app/api/ZoomIt.scala +++ b/app/api/ZoomIt.scala @@ -29,4 +29,4 @@ class ZoomIt @Inject()(tiles: TileService) extends Controller with ApiController BadRequest(toJson("File not attached.")) } } -} \ No newline at end of file +} diff --git a/app/controllers/Admin.scala b/app/controllers/Admin.scala index cb91e0c2d..b80766a0a 100644 --- a/app/controllers/Admin.scala +++ b/app/controllers/Admin.scala @@ -275,7 +275,7 @@ class Admin @Inject() (sectionIndexInfo: SectionIndexInfoService, userService: U case None => { Future(Ok("No Versus Service")) } - } + } } /** @@ -340,8 +340,8 @@ class Admin @Inject() (sectionIndexInfo: SectionIndexInfoService, userService: U } def viewDumpers() = ServerAdminAction { implicit request => - implicit val user = request.user - Ok(views.html.viewDumpers()) + implicit val user = request.user + Ok(views.html.viewDumpers()) } def submitCreateRole() = ServerAdminAction { implicit request => diff --git a/app/controllers/Application.scala b/app/controllers/Application.scala index ab2e0aba5..0208a8663 100644 --- a/app/controllers/Application.scala +++ b/app/controllers/Application.scala @@ -98,7 +98,7 @@ class Application @Inject() (files: FileService, collections: CollectionService, def index = UserAction(needActive = false) { implicit request => val appConfig: AppConfigurationService = DI.injector.getInstance(classOf[AppConfigurationService]) - implicit val user = request.user + implicit val user = request.user var newsfeedEvents = List.empty[Event] if (!play.Play.application().configuration().getBoolean("clowder.disable.events", false)) { diff --git a/app/controllers/Collections.scala b/app/controllers/Collections.scala index 788148837..059417e36 100644 --- a/app/controllers/Collections.scala +++ b/app/controllers/Collections.scala @@ -479,8 +479,8 @@ class Collections @Inject() (datasets: DatasetService, collections: CollectionSe } else { Redirect(routes.Collections.collection(collection.id)) } - } - case None => Redirect(routes.Collections.list()).flashing("error" -> "You are not authorized to create new collections.") + } + case None => Redirect(routes.Collections.list()).flashing("error" -> "You are not authorized to create new collections.") } } diff --git a/app/controllers/Datasets.scala b/app/controllers/Datasets.scala index 2e8fa162e..d9c9fa7d0 100644 --- a/app/controllers/Datasets.scala +++ b/app/controllers/Datasets.scala @@ -835,4 +835,4 @@ class Datasets @Inject() ( implicit val user = request.user Ok(views.html.generalMetadataSearch()) } -} \ No newline at end of file +} diff --git a/app/controllers/Error.scala b/app/controllers/Error.scala index 7d55100bd..04686737f 100644 --- a/app/controllers/Error.scala +++ b/app/controllers/Error.scala @@ -93,4 +93,4 @@ class Error extends SecuredController { implicit val user = request.user Forbidden(views.html.notAuthorized(message, id, resourceType)) } -} \ No newline at end of file +} diff --git a/app/controllers/ExtractionInfo.scala b/app/controllers/ExtractionInfo.scala index 2107f2939..ce9fa2a66 100644 --- a/app/controllers/ExtractionInfo.scala +++ b/app/controllers/ExtractionInfo.scala @@ -98,4 +98,4 @@ class ExtractionInfo @Inject() (extractors: ExtractorService, dtsrequests: Extra val extensionHostUrl = configuration.getString("dts.extension.host").getOrElse("") Ok(views.html.dtsExtension(Utils.baseUrl(request), hostname, extensionHostUrl)) } -} \ No newline at end of file +} diff --git a/app/controllers/Extractors.scala b/app/controllers/Extractors.scala index 96617186c..a10664d88 100644 --- a/app/controllers/Extractors.scala +++ b/app/controllers/Extractors.scala @@ -133,4 +133,4 @@ class Extractors @Inject() (extractions: ExtractionService, case None => InternalServerError("Dataset not found") } } -} \ No newline at end of file +} diff --git a/app/controllers/Files.scala b/app/controllers/Files.scala index 7fc5b644f..c58f5486d 100644 --- a/app/controllers/Files.scala +++ b/app/controllers/Files.scala @@ -347,8 +347,8 @@ class Files @Inject() ( }.toMap //Code to read the cookie data. On default calls, without a specific value for the mode, the cookie value is used. - //Note that this cookie will, in the long run, pertain to all the major high-level views that have the similar - //modal behavior for viewing data. Currently the options are tile and list views. MMF - 12/14 + //Note that this cookie will, in the long run, pertain to all the major high-level views that have the similar + //modal behavior for viewing data. Currently the options are tile and list views. MMF - 12/14 val viewMode: Option[String] = if (mode == null || mode == "") { request.cookies.get("view-mode") match { @@ -488,7 +488,7 @@ class Files @Inject() ( } } /*def extraction(id: String) = SecuredAction(authorization = WithPermission(Permission.ShowFile)) { implicit request => - + }*/ @@ -504,27 +504,27 @@ class Files @Inject() ( Logger.debug("--------- in upload ------------ ") user match { case Some(identity) => { - request.body.file("files[]").map { f => - var nameOfFile = f.filename - var flags = "" - if(nameOfFile.toLowerCase().endsWith(".ptm")){ - val thirdSeparatorIndex = nameOfFile.indexOf("__") - if(thirdSeparatorIndex >= 0){ - val firstSeparatorIndex = nameOfFile.indexOf("_") - val secondSeparatorIndex = nameOfFile.indexOf("_", firstSeparatorIndex+1) - flags = flags + "+numberofIterations_" + nameOfFile.substring(0,firstSeparatorIndex) + "+heightFactor_" + nameOfFile.substring(firstSeparatorIndex+1,secondSeparatorIndex)+ "+ptm3dDetail_" + nameOfFile.substring(secondSeparatorIndex+1,thirdSeparatorIndex) - nameOfFile = nameOfFile.substring(thirdSeparatorIndex+2) - } - } - Logger.debug("Uploading file " + nameOfFile) - - val showPreviews = request.body.asFormUrlEncoded.get("datasetLevel").get(0) - - // store file - val file = files.save(new FileInputStream(f.ref.file), nameOfFile, f.contentType, identity, showPreviews) - val uploadedFile = f - file match { - case Some(f) => { + request.body.file("files[]").map { f => + var nameOfFile = f.filename + var flags = "" + if(nameOfFile.toLowerCase().endsWith(".ptm")){ + val thirdSeparatorIndex = nameOfFile.indexOf("__") + if(thirdSeparatorIndex >= 0){ + val firstSeparatorIndex = nameOfFile.indexOf("_") + val secondSeparatorIndex = nameOfFile.indexOf("_", firstSeparatorIndex+1) + flags = flags + "+numberofIterations_" + nameOfFile.substring(0,firstSeparatorIndex) + "+heightFactor_" + nameOfFile.substring(firstSeparatorIndex+1,secondSeparatorIndex)+ "+ptm3dDetail_" + nameOfFile.substring(secondSeparatorIndex+1,thirdSeparatorIndex) + nameOfFile = nameOfFile.substring(thirdSeparatorIndex+2) + } + } + Logger.debug("Uploading file " + nameOfFile) + + val showPreviews = request.body.asFormUrlEncoded.get("datasetLevel").get(0) + + // store file + val file = files.save(new FileInputStream(f.ref.file), nameOfFile, f.contentType, identity, showPreviews) + val uploadedFile = f + file match { + case Some(f) => { // Add new file & byte count to appConfig appConfig.incrementCount('files, 1) appConfig.incrementCount('bytes, f.length) @@ -577,25 +577,25 @@ class Files @Inject() ( val extra = Map("filename" -> f.filename) dtsrequests.insertRequest(serverIP, clientIP, f.filename, f.id, fileType, f.length, f.uploadDate) /****************************/ - current.plugin[RabbitmqPlugin].foreach{ + current.plugin[RabbitmqPlugin].foreach{ // FIXME dataset not available? _.fileCreated(f, None, Utils.baseUrl(request), request.apiKey) } - - //for metadata files - if(fileType.equals("application/xml") || fileType.equals("text/xml")){ - val xmlToJSON = FilesUtils.readXMLgetJSON(uploadedFile.ref.file) - files.addXMLMetadata(f.id, xmlToJSON) - - current.plugin[ElasticsearchPlugin].foreach{ - _.index(SearchUtils.getElasticsearchObject(f)) + + //for metadata files + if(fileType.equals("application/xml") || fileType.equals("text/xml")){ + val xmlToJSON = FilesUtils.readXMLgetJSON(uploadedFile.ref.file) + files.addXMLMetadata(f.id, xmlToJSON) + + current.plugin[ElasticsearchPlugin].foreach{ + _.index(SearchUtils.getElasticsearchObject(f)) } - } - else{ - current.plugin[ElasticsearchPlugin].foreach{ - _.index(SearchUtils.getElasticsearchObject(f)) + } + else{ + current.plugin[ElasticsearchPlugin].foreach{ + _.index(SearchUtils.getElasticsearchObject(f)) } - } + } current.plugin[VersusPlugin].foreach { _.indexFile(f.id, fileType) } @@ -610,7 +610,7 @@ class Files @Inject() ( current.plugin[AdminsNotifierPlugin].foreach { _.sendAdminsNotification(Utils.baseUrl(request), "File","added",f.id.stringify, nameOfFile)} - //Correctly set the updated URLs and data that is needed for the interface to correctly + //Correctly set the updated URLs and data that is needed for the interface to correctly //update the display after a successful upload. val https = controllers.Utils.https(request) val retMap = Map("files" -> @@ -621,11 +621,11 @@ class Files @Inject() ( "size" -> toJson(uploadedFile.ref.file.length()), "url" -> toJson(routes.Files.file(f.id).absoluteURL(https)), "deleteUrl" -> toJson(api.routes.Files.removeFile(f.id).absoluteURL(https)), - "deleteType" -> toJson("POST") - ) - ) - ) - ) + "deleteType" -> toJson("POST") + ) + ) + ) + ) Ok(toJson(retMap)) } case None => { @@ -675,7 +675,7 @@ class Files @Inject() ( implicit val user = request.user if (UUID.isValid(id.stringify)) { - //Check the license type before doing anything. + //Check the license type before doing anything. files.get(id) match { case Some(file) => { if (file.licenseData.isDownloadAllowed(request.user)) { @@ -777,7 +777,7 @@ class Files @Inject() ( //prepare encoded file name for converted file val lastSeparatorIndex = file.filename.replace("_", ".").lastIndexOf(".") val outputFileName = file.filename.substring(0, lastSeparatorIndex) + "." + outputFormat - + //create local temp file to save polyglot output val tempFileName = "temp_converted_file." + outputFormat val tempFile: java.io.File = new java.io.File(tempFileName) @@ -851,7 +851,7 @@ class Files @Inject() ( case x if x.length == 1 => (x.head.toLong, contentLength - 1) case x => (x(0).toLong, x(1).toLong) } - range match { case (start,end) => + range match { case (start,end) => inputStream.skip(start) @@ -863,11 +863,11 @@ class Files @Inject() ( ACCEPT_RANGES -> "bytes", CONTENT_RANGE -> "bytes %d-%d/%d".format(start, end, contentLength), CONTENT_LENGTH -> (end - start + 1).toString, - CONTENT_TYPE -> contentType - ) - ), - body = Enumerator.fromStream(inputStream) - ) + CONTENT_TYPE -> contentType + ) + ), + body = Enumerator.fromStream(inputStream) + ) } } case None => { @@ -904,7 +904,7 @@ class Files @Inject() ( if (typeToSearch.equals("sectionsSome") && dataParts.contains("sections")) { sections = dataParts("sections").toList } - //END OF: processing searching within files or sections of files or both + //END OF: processing searching within files or sections of files or both request.body.file("File").map { f => try { var nameOfFile = f.filename @@ -921,7 +921,7 @@ class Files @Inject() ( } } Logger.debug("Controllers/Files Uploading file " + nameOfFile) - + // store file val file = queries.save(new FileInputStream(f.ref.file), nameOfFile, f.contentType) val uploadedFile = f @@ -1269,11 +1269,11 @@ class Files @Inject() ( // Logger.debug("Part: " + partName + " filename: " + filename + " contentType: " + contentType); // // TODO RK handle exception for instance if we switch to other DB // Logger.debug("myPartHandler") - // val files = current.plugin[MongoSalatPlugin] match { - // case None => throw new RuntimeException("No MongoSalatPlugin"); - // case Some(x) => x.gridFS("uploads") - // } - // + // val files = current.plugin[MongoSalatPlugin] match { + // case None => throw new RuntimeException("No MongoSalatPlugin"); + // case Some(x) => x.gridFS("uploads") + // } + // // //Set up the PipedOutputStream here, give the input stream to a worker thread // val pos:PipedOutputStream = new PipedOutputStream(); // val pis:PipedInputStream = new PipedInputStream(pos); @@ -1289,8 +1289,8 @@ class Files @Inject() ( //// mongoFile.save //// val id = mongoFile.getAs[ObjectId]("_id").get.toString //// Ok(views.html.file(mongoFile.asDBObject, id)) - // - // + // + // // //Read content to the POS // Iteratee.fold[Array[Byte], PipedOutputStream](pos) { (os, data) => // os.write(data) @@ -1301,26 +1301,26 @@ class Files @Inject() ( // } // } // } - // + // // /** // * Ajax upload. How do we pass in the file name?(parse.temporaryFile) // */ - // - // + // + // // def uploadAjax = Action(parse.temporaryFile) { implicit request => // // val f = request.body.file // val filename=f.getName() - // + // // // store file // // TODO is this still used? if so replace null with user. // Logger.debug("uploadAjax") // val file = files.save(new FileInputStream(f.getAbsoluteFile()), filename, None, null) - // + // // file match { // case Some(f) => { // var fileType = f.contentType - // + // // // TODO RK need to replace unknown with the server name // val key = "unknown." + "file."+ f.contentType.replace(".", "_").replace("/", ".") // // TODO RK : need figure out if we can use https @@ -1331,7 +1331,7 @@ class Files @Inject() ( // _.index("files", "file", id, List(("filename",f.filename), ("contentType", f.contentType))) // } // // redirect to file page - // Redirect(routes.Files.file(f.id.toString)) + // Redirect(routes.Files.file(f.id.toString)) // } // case None => { // Logger.error("Could not retrieve file that was just saved.") @@ -1352,14 +1352,14 @@ class Files @Inject() ( * * TODO Finish implementing. Right now it doesn't write to anything. */ - // case class SomeIteratee(state: Symbol = 'Cont, input: Input[Array[Byte]] = Empty, + // case class SomeIteratee(state: Symbol = 'Cont, input: Input[Array[Byte]] = Empty, // received: Int = 0) extends Iteratee[Array[Byte], Either[Result, Int]] { // Logger.debug(state + " " + input + " " + received) // //// val files = current.plugin[MongoSalatPlugin] match { - //// case None => throw new RuntimeException("No MongoSalatPlugin"); - //// case Some(x) => x.gridFS("uploads") - //// } + //// case None => throw new RuntimeException("No MongoSalatPlugin"); + //// case Some(x) => x.gridFS("uploads") + //// } //// //// val pos:PipedOutputStream = new PipedOutputStream(); //// val pis:PipedInputStream = new PipedInputStream(pos); @@ -1367,27 +1367,27 @@ class Files @Inject() ( //// fh.filename = "test-file.txt" //// fh.contentType = "text/plain" //// } - // - // + // + // // def fold[B]( // done: (Either[Result, Int], Input[Array[Byte]]) => Promise[B], // cont: (Input[Array[Byte]] => Iteratee[Array[Byte], Either[Result, Int]]) => Promise[B], // error: (String, Input[Array[Byte]]) => Promise[B] // ): Promise[B] = state match { - // case 'Done => { + // case 'Done => { // Logger.debug("Done with upload") //// pos.close() - // done(Right(received), Input.Empty) + // done(Right(received), Input.Empty) // } // case 'Cont => cont(in => in match { // case in: El[Array[Byte]] => { // Logger.debug("Getting ready to write " + in.e.length) - // try { + // try { //// pos.write(in.e) - // } catch { - // case error => Logger.error("Error writing to gridfs" + error.toString()) - // } - // Logger.debug("Calling recursive function") + // } catch { + // case error => Logger.error("Error writing to gridfs" + error.toString()) + // } + // Logger.debug("Calling recursive function") // copy(input = in, received = received + in.e.length) // } // case Empty => { diff --git a/app/controllers/Geostreams.scala b/app/controllers/Geostreams.scala index f6d0ecc6d..41fa85bf1 100644 --- a/app/controllers/Geostreams.scala +++ b/app/controllers/Geostreams.scala @@ -96,4 +96,4 @@ class Geostreams @Inject() ( } } -} \ No newline at end of file +} diff --git a/app/controllers/Login.scala b/app/controllers/Login.scala index b9c7d0388..53c3fba8c 100644 --- a/app/controllers/Login.scala +++ b/app/controllers/Login.scala @@ -96,4 +96,4 @@ class Login extends SecuredController { ldapConnection.close() } } -} \ No newline at end of file +} diff --git a/app/controllers/Search.scala b/app/controllers/Search.scala index cd9435b86..309a4f494 100644 --- a/app/controllers/Search.scala +++ b/app/controllers/Search.scala @@ -71,7 +71,7 @@ class Search @Inject() ( } /* - * GET the query file from a URL and compare within the database and show the result + * GET the query file from a URL and compare within the database and show the result * */ def searchbyURL(queryURL: String) = PermissionAction(Permission.ViewDataset).async { implicit request => implicit val user = request.user @@ -89,7 +89,7 @@ class Search @Inject() ( } //convert list of futures into a Future[list] scala.concurrent.Future.sequence(resultListOfFutures) - } //End yield- outer for + } //End yield- outer for for { futureListResults <- futureFutureListResults listOfResults <- futureListResults @@ -133,7 +133,7 @@ class Search @Inject() ( //convert list of futures into a Future[list] scala.concurrent.Future.sequence(resultListOfFutures) - } //End yield + } //End yield for { futureListResults <- futureFutureListResults @@ -144,12 +144,12 @@ class Search @Inject() ( val thumb_id: String = queries.getFile(fileID).flatMap(_.thumbnail_id).map(_.stringify).getOrElse("") Ok(views.html.multimediaSearchResults(filename, Some(fileID), Some(thumb_id), listOfResults)) } - } //end of case Some(plugin) + } //end of case Some(plugin) case None => { Future(Ok("No Versus Service")) } - } //current.plugin[VersusPlugin] match + } //current.plugin[VersusPlugin] match } //case Some((inputStream... case None => { @@ -181,7 +181,7 @@ class Search @Inject() ( } //convert list of futures into a Future[list] scala.concurrent.Future.sequence(resultListOfFutures) - } //End yield- outer for + } //End yield- outer for for { futureListResults <- futureFutureListResults @@ -191,12 +191,12 @@ class Search @Inject() ( val thumb_id = files.get(inputFileId).flatMap(_.thumbnail_id).getOrElse("") Ok(views.html.multimediaSearchResults(filename, Some(inputFileId), Some(thumb_id), listOfResults)) } - } //end of case Some(plugin) + } //end of case Some(plugin) case None => { Future(Ok("No Versus Service")) } - } //current.plugin[VersusPlugin] match + } //current.plugin[VersusPlugin] match } //case Some((inputStream... case None => { @@ -211,7 +211,7 @@ class Search @Inject() ( * Returns * boolean: true if errors are present * String: error message - * List[Double] : weights + * List[Double]: weights */ def validateInput(input: Map[String, Seq[String]]): (Boolean, String, List[Double]) = { var inputErrors = false @@ -221,7 +221,7 @@ class Search @Inject() ( inputErrors = true return (inputErrors, "Not all fields are present", List(0.0)) } - //now deal with weights + //now deal with weights try { weightsList = input("Weight").map(w => w.toDouble).toList } catch { @@ -235,7 +235,7 @@ class Search @Inject() ( } if (sum != 1) return (true, "sum of weights must be 1", List(0.0)) - //no errors, return list of weights + //no errors, return list of weights (false, "", weightsList) } @@ -258,7 +258,7 @@ class Search @Inject() ( val nonzeroWeights = nonzeroWeightsBuf.toList val nonzeroMaps = nonzeroMapsBuf.toList - //If after removing zero-weight maps we have just one map left - nothing to merge, return the map. + //If after removing zero-weight maps we have just one map left - nothing to merge, return the map. //Otherwise, merge maps. if (nonzeroMaps.length == 1) { nonzeroMaps(0) @@ -274,7 +274,7 @@ class Search @Inject() ( } /** * For two maps and two corresponding weights, will find linear combinations of corresponding values, - * using the weights provided + * using the weights provided */ def mergeTwoMaps(mapOne: collection.immutable.HashMap[String, Double], mapTwo: collection.immutable.HashMap[String, Double], @@ -305,7 +305,7 @@ class Search @Inject() ( val filename = fileInfo._2 current.plugin[VersusPlugin] match { case Some(plugin) => { - //get file and a list of indexes from request, query this file against each of these indexes + //get file and a list of indexes from request, query this file against each of these indexes val queryResults = indexIDs.map(indId => plugin.queryIndexSorted(fileId.stringify, indId.stringify)) //change a list of futures into a future list val futureListResults = scala.concurrent.Future.sequence(queryResults) @@ -334,19 +334,19 @@ class Search @Inject() ( //get an option of thumbnail id for this image and pass on to view val thumb_id = queries.getFile(fileId).flatMap(_.thumbnail_id) Ok(views.html.multimediaSearchResultsCombined(filename, thumb_id, sortedMergedResults)) - } //end of yield - } //end of case Some(plugin) + } //end of yield + } //end of case Some(plugin) case None => { Future(Ok("No Versus Service")) } - } //current.plugin[VersusPlugin] match + } //current.plugin[VersusPlugin] match } //case Some((inputStream... case None => { Logger.debug("File with id " + fileId + " not found") Future(Ok("File with id " + fileId + " not found")) } - } //end of queries.get(imageID) match + } //end of queries.get(imageID) match } //end of if no validation errors else { Future(Ok("Form validation errors: " + errorMessage)) } } diff --git a/app/controllers/Selected.scala b/app/controllers/Selected.scala index c494b568a..6c1014fca 100644 --- a/app/controllers/Selected.scala +++ b/app/controllers/Selected.scala @@ -15,10 +15,10 @@ class Selected @Inject()(selections: SelectionService, files: FileService) exten request.user match { case Some(identity) => { implicit val user = request.user - val datasets = selections.get(request.user.get.email.get) // TODO handle edge cases - Ok(views.html.selected(datasets.to[scala.collection.mutable.ListBuffer])) + val datasets = selections.get(request.user.get.email.get) // TODO handle edge cases + Ok(views.html.selected(datasets.to[scala.collection.mutable.ListBuffer])) } case None => Logger.error("Error get user from request"); InternalServerError } } -} \ No newline at end of file +} diff --git a/app/controllers/ToolManager.scala b/app/controllers/ToolManager.scala index 3dcd5586a..7bb022527 100644 --- a/app/controllers/ToolManager.scala +++ b/app/controllers/ToolManager.scala @@ -147,4 +147,4 @@ class ToolManager extends SecuredController { case None => BadRequest("No ToolManagerPlugin found.") } } -} \ No newline at end of file +} diff --git a/app/controllers/Utils.scala b/app/controllers/Utils.scala index f759e97d0..982836ceb 100644 --- a/app/controllers/Utils.scala +++ b/app/controllers/Utils.scala @@ -167,4 +167,4 @@ object Utils { decodedReplies.toList } } -} \ No newline at end of file +} diff --git a/app/filters/CORSFilter.scala b/app/filters/CORSFilter.scala index cddbaa4bd..e6a77eec4 100644 --- a/app/filters/CORSFilter.scala +++ b/app/filters/CORSFilter.scala @@ -41,4 +41,4 @@ case class CORSFilter() extends Filter{ )} } } -} \ No newline at end of file +} diff --git a/app/models/CurationObject.scala b/app/models/CurationObject.scala index a2851ae1d..cb36970ac 100644 --- a/app/models/CurationObject.scala +++ b/app/models/CurationObject.scala @@ -164,4 +164,4 @@ case class CurationFolder( folders: List[UUID] = List.empty, parentId: UUID, parentType: String, - parentCurationObjectId: UUID) \ No newline at end of file + parentCurationObjectId: UUID) diff --git a/app/models/DBCounts.scala b/app/models/DBCounts.scala index 22a7d98f3..a6f2d730e 100644 --- a/app/models/DBCounts.scala +++ b/app/models/DBCounts.scala @@ -14,4 +14,4 @@ case class DBCounts(numDatasets: Long=0, numFiles: Long=0, numBytes: Long=0, num "users"->numUsers ) } -} \ No newline at end of file +} diff --git a/app/models/Dataset.scala b/app/models/Dataset.scala index 11953197c..25b36ae5a 100644 --- a/app/models/Dataset.scala +++ b/app/models/Dataset.scala @@ -72,4 +72,4 @@ case class DatasetAccess( showAccess: Boolean = false, access: String = "N/A", accessOptions: List[String] = List.empty -) \ No newline at end of file +) diff --git a/app/models/Event.scala b/app/models/Event.scala index 65dfd479b..83641c5aa 100644 --- a/app/models/Event.scala +++ b/app/models/Event.scala @@ -15,14 +15,14 @@ import services.DI */ case class Event( - user: MiniUser, + user: MiniUser, targetuser : Option[MiniUser] = None, - object_id: Option[UUID] = None, - object_name: Option[String] = None, - source_id: Option[UUID] = None, - source_name: Option[String] = None, - event_type: String, - created: Date = new Date() + object_id: Option[UUID] = None, + object_name: Option[String] = None, + source_id: Option[UUID] = None, + source_name: Option[String] = None, + event_type: String, + created: Date = new Date() ) @@ -52,7 +52,7 @@ import services.DI * addMetadata_dataset => "user added metadata to dataset: object_name" * addMetadata_file => "user added metadata to file: object_name" * - * update_dataset_information => "user updated dataset infomration for object_name" + * update_dataset_information => "user updated dataset information for object_name" * * (when working with comments object_name holds comment text, object_id has UUID of comment) * comment_file => "user commented object_name on file: source_name" @@ -61,7 +61,7 @@ import services.DI * * set_note_file => "user set the note on object_name" * - * download_file => "user downladed object_name" (not working) + * download_file => "user downloaded object_name" (not working) * * tos_update => "Terms of Service were updated" * @@ -76,8 +76,8 @@ import services.DI */ object Events { - val scheduler: SchedulerService = DI.injector.getInstance(classOf[SchedulerService]) - val users: UserService = DI.injector.getInstance(classOf[UserService]) + val scheduler: SchedulerService = DI.injector.getInstance(classOf[SchedulerService]) + val users: UserService = DI.injector.getInstance(classOf[UserService]) val events: EventService = DI.injector.getInstance(classOf[EventService]) /** @@ -164,4 +164,4 @@ object EventType extends Enumeration { val SET_NOTE_FILE = Value("set_note_file") val DOWNLOAD_FILE = Value("download_file") val TOS_UPDATE = Value("tos_update") -} \ No newline at end of file +} diff --git a/app/models/ExtractionInfoSetUp.scala b/app/models/ExtractionInfoSetUp.scala index 13b648a96..3d20176d5 100644 --- a/app/models/ExtractionInfoSetUp.scala +++ b/app/models/ExtractionInfoSetUp.scala @@ -208,7 +208,7 @@ def updateDTSRequests(file_id:UUID,extractor_id:String)={ var exlist = List[String]() exjsonlist.map { ex => - Logger.trace("internal: " +(ex \"internal")+" name:"+(ex \"name").as[String]) + Logger.trace("internal: " + (ex \"internal") + " name:" + (ex \"name").as[String]) if ((ex \ "internal").as[Boolean] == false) { var name = (ex \ "name").as[String] exlist = name :: exlist diff --git a/app/models/ExtractorsForInstance.scala b/app/models/ExtractorsForInstance.scala index 2eff31725..bda98a80a 100644 --- a/app/models/ExtractorsForInstance.scala +++ b/app/models/ExtractorsForInstance.scala @@ -5,5 +5,4 @@ package models */ case class ExtractorsForInstance( extractors: List[String] - ) - \ No newline at end of file +) diff --git a/app/models/FileOP.scala b/app/models/FileOP.scala index 5e4ec2f17..488b935cb 100644 --- a/app/models/FileOP.scala +++ b/app/models/FileOP.scala @@ -54,7 +54,7 @@ object FileOP { // where "values" are the preview properties, such as "preview_id", "url", and "contentType". var previewRes = Map[String, MutableList[JsValue]]() previews1.filter(_.extractor_id.isDefined).foreach(p => { - + val ename = p.extractor_id.get val jitem = Json.obj("preview_id" -> p.id.stringify, "contentType" -> p.contentType, "url" -> api.routes.Previews.download(p.id).toString) @@ -68,4 +68,4 @@ object FileOP { jpreviews } - } \ No newline at end of file + } diff --git a/app/models/IncrementCounter.scala b/app/models/IncrementCounter.scala index cfd5f2cde..8bdb581cb 100644 --- a/app/models/IncrementCounter.scala +++ b/app/models/IncrementCounter.scala @@ -2,4 +2,4 @@ package models class IncrementCounter { var count = 0 -} \ No newline at end of file +} diff --git a/app/models/Metadata.scala b/app/models/Metadata.scala index 6ce0a393b..bc09c5423 100644 --- a/app/models/Metadata.scala +++ b/app/models/Metadata.scala @@ -138,16 +138,16 @@ object Metadata { "user_id" -> user_id_string) } } - + implicit object MetadataWrites extends Writes[Metadata] { - def writes(metadata: Metadata) = Json.obj( - "created_at" -> metadata.createdAt.toString, - //if (i == 1) x else y - //switch based on type of creator/agent and call appropriate class' implicit writes - "agent"-> (if (metadata.creator.isInstanceOf[UserAgent]) metadata.creator.asInstanceOf[UserAgent] else metadata.creator.asInstanceOf[ExtractorAgent]) , - "content" -> metadata.content - ) - } + def writes(metadata: Metadata) = Json.obj( + "created_at" -> metadata.createdAt.toString, + //if (i == 1) x else y + //switch based on type of creator/agent and call appropriate class' implicit writes + "agent"-> (if (metadata.creator.isInstanceOf[UserAgent]) metadata.creator.asInstanceOf[UserAgent] else metadata.creator.asInstanceOf[ExtractorAgent]) , + "content" -> metadata.content + ) + } } @@ -177,4 +177,4 @@ object RDFModel { } } -} \ No newline at end of file +} diff --git a/app/models/RequestResource.scala b/app/models/RequestResource.scala index c5950247c..a13bce4a4 100644 --- a/app/models/RequestResource.scala +++ b/app/models/RequestResource.scala @@ -13,4 +13,4 @@ comment: String = "N/A"){ case that: RequestResource => that.id.equals(this.id) case _ => false } -} \ No newline at end of file +} diff --git a/app/models/Role.scala b/app/models/Role.scala index 52df9136d..93c4b83b6 100644 --- a/app/models/Role.scala +++ b/app/models/Role.scala @@ -24,4 +24,4 @@ object Role { // viewer role val viewerPerm = Permission.READONLY val Viewer = new Role(name="Viewer", description="Viewer Role", permissions = viewerPerm.map(_.toString)) -} \ No newline at end of file +} diff --git a/app/models/Section.scala b/app/models/Section.scala index c1793a1ed..141eb5c68 100644 --- a/app/models/Section.scala +++ b/app/models/Section.scala @@ -25,4 +25,4 @@ case class Rectangle( w: Double, h: Double) { override def toString() = f"x: $x%.2f, y: $y%.2f, width: $w%.2f, height: $h%.2f" -} \ No newline at end of file +} diff --git a/app/models/SectionIndexInfo.scala b/app/models/SectionIndexInfo.scala index 3829d781e..2ac944673 100644 --- a/app/models/SectionIndexInfo.scala +++ b/app/models/SectionIndexInfo.scala @@ -9,4 +9,4 @@ case class SectionIndexInfo( indexId:String, indexName:Option[String] = None, indexType: Option[String] = None - ) \ No newline at end of file + ) diff --git a/app/models/ServerStartTime.scala b/app/models/ServerStartTime.scala index 15d02a0d9..cd6e3fb76 100644 --- a/app/models/ServerStartTime.scala +++ b/app/models/ServerStartTime.scala @@ -10,4 +10,4 @@ import java.util.Date object ServerStartTime { var startTime: Date=null -} \ No newline at end of file +} diff --git a/app/models/StandardVocab.scala b/app/models/StandardVocab.scala index cad582197..c9d9b1a6b 100644 --- a/app/models/StandardVocab.scala +++ b/app/models/StandardVocab.scala @@ -22,4 +22,4 @@ object StandardVocab{ "terms" -> vocabulary.terms.toList) } } -} \ No newline at end of file +} diff --git a/app/models/TempFile.scala b/app/models/TempFile.scala index b8a7b8c4c..867efbf10 100644 --- a/app/models/TempFile.scala +++ b/app/models/TempFile.scala @@ -17,4 +17,4 @@ case class TempFile( contentType: String, length: Long = 0, thumbnail_id: Option[UUID] = None - ) \ No newline at end of file + ) diff --git a/app/models/User.scala b/app/models/User.scala index 3564e5253..cfeeb7885 100644 --- a/app/models/User.scala +++ b/app/models/User.scala @@ -10,9 +10,9 @@ import securesocial.core._ import services.AppConfiguration object UserStatus extends Enumeration { - type UserStatus = Value - val Inactive, Active, Admin = Value - } + type UserStatus = Value + val Inactive, Active, Admin = Value + } /** * Simple class to capture basic User Information. This is similar to Identity in securesocial diff --git a/app/models/UserSpaceAndRole.scala b/app/models/UserSpaceAndRole.scala index 76d254c59..abd3ba863 100644 --- a/app/models/UserSpaceAndRole.scala +++ b/app/models/UserSpaceAndRole.scala @@ -7,4 +7,4 @@ package models case class UserSpaceAndRole ( spaceId: UUID = null, role: Role = null // TODO replace with UUID -) \ No newline at end of file +) diff --git a/app/models/VersusExtraction.scala b/app/models/VersusExtraction.scala index 60f198246..574c2b3b0 100644 --- a/app/models/VersusExtraction.scala +++ b/app/models/VersusExtraction.scala @@ -24,9 +24,5 @@ object VersusExtraction { JsSuccess(VersusExtraction(ex_id,a_name,ex_name,des)) } - - } - - - -} \ No newline at end of file + } +} diff --git a/app/models/VersusIndex.scala b/app/models/VersusIndex.scala index ae92b2518..30982c181 100644 --- a/app/models/VersusIndex.scala +++ b/app/models/VersusIndex.scala @@ -19,28 +19,28 @@ case class VersusIndex( object VersusIndex { /** * Serializer for VersusIndex type. - */ - implicit object VersusIndexWrites extends Writes[VersusIndex] { - def writes(index: VersusIndex) = Json.obj( - "id" -> index.id, - "mimetype" -> index.MIMEtype, - "extr"->index.extractorID, - "measure"->index.measureID, - "typeOfIndexer"->index.indexerType - ) - } + */ + implicit object VersusIndexWrites extends Writes[VersusIndex] { + def writes(index: VersusIndex) = Json.obj( + "id" -> index.id, + "mimetype" -> index.MIMEtype, + "extr"->index.extractorID, + "measure"->index.measureID, + "typeOfIndexer"->index.indexerType + ) + } - /** - * Deserializer for VersusIndex type. - */ - implicit object VersusIndexReads extends Reads[VersusIndex] { - def reads(json: JsValue) ={ - val maybeID:String = (json \"indexID").as[String] - val maybeMimeType:String=(json\"MIMEtype").as[String] - val exType:String=(json\"Extractor").as[String] - val meType:String=(json\"Measure").as[String] - val indxrType:String=(json\"Indexer").as[String] - JsSuccess(VersusIndex(maybeID,maybeMimeType,exType,meType,indxrType)) - } - } -} \ No newline at end of file + /** + * Deserializer for VersusIndex type. + */ + implicit object VersusIndexReads extends Reads[VersusIndex] { + def reads(json: JsValue) ={ + val maybeID:String = (json \"indexID").as[String] + val maybeMimeType:String=(json\"MIMEtype").as[String] + val exType:String=(json\"Extractor").as[String] + val meType:String=(json\"Measure").as[String] + val indxrType:String=(json\"Indexer").as[String] + JsSuccess(VersusIndex(maybeID,maybeMimeType,exType,meType,indxrType)) + } + } +} diff --git a/app/models/VersusIndexTypeName.scala b/app/models/VersusIndexTypeName.scala index af753d39d..9e4de7c27 100644 --- a/app/models/VersusIndexTypeName.scala +++ b/app/models/VersusIndexTypeName.scala @@ -32,4 +32,4 @@ object VersusIndexTypeName { def addTypeAndName(index: VersusIndexTypeName, indType:String, indName:String): VersusIndexTypeName = { index.copy(indexType = Some(indType), indexName = Some(indName)) } -} \ No newline at end of file +} diff --git a/app/models/WebPageResource.scala b/app/models/WebPageResource.scala index f28b1d332..0e71a1cad 100644 --- a/app/models/WebPageResource.scala +++ b/app/models/WebPageResource.scala @@ -10,4 +10,4 @@ case class WebPageResource( id: UUID, webPageURL:String, URLs: Map[String,String] -) \ No newline at end of file +) diff --git a/app/services/AdminsNotifierPlugin.scala b/app/services/AdminsNotifierPlugin.scala index 223aa9a7d..edc97c415 100644 --- a/app/services/AdminsNotifierPlugin.scala +++ b/app/services/AdminsNotifierPlugin.scala @@ -45,7 +45,7 @@ class AdminsNotifierPlugin @Inject()(userService: UserService) (application:Appl mailHTML match { case "" => { - Logger.error("Unknown event type.") + Logger.error("Unknown event type.") } case _=> { Mail.sendEmailAdmins(mailSubject, None, Html(mailHTML)) diff --git a/app/services/ContextLDService.scala b/app/services/ContextLDService.scala index ca6e8dabb..d56005b0f 100644 --- a/app/services/ContextLDService.scala +++ b/app/services/ContextLDService.scala @@ -26,5 +26,4 @@ trait ContextLDService { /** Update context **/ def updateContext(context: ContextLD) - -} \ No newline at end of file +} diff --git a/app/services/CrowdProvider.scala b/app/services/CrowdProvider.scala index a1797d965..3be0deedd 100644 --- a/app/services/CrowdProvider.scala +++ b/app/services/CrowdProvider.scala @@ -79,4 +79,4 @@ object CrowdProvider { private val CrowdServerURL = "securesocial.crowd.url" // time token is alive for private val CrowdServerTimeOut = "securesocial.crowd.timeout" -} \ No newline at end of file +} diff --git a/app/services/DatasetsAutodumpService.scala b/app/services/DatasetsAutodumpService.scala index 66fb1efb5..7f0230243 100644 --- a/app/services/DatasetsAutodumpService.scala +++ b/app/services/DatasetsAutodumpService.scala @@ -16,9 +16,9 @@ class DatasetsAutodumpService (application: Application) extends Plugin { Logger.debug("Starting dataset file groupings autodumper Plugin") //Dump dataset file groupings periodically val timeInterval = play.Play.application().configuration().getInt("datasetdump.dumpEvery") - Akka.system().scheduler.schedule(0.days, timeInterval.intValue().days){ - dumpDatasetGroupings - } + Akka.system().scheduler.schedule(0.days, timeInterval.intValue().days){ + dumpDatasetGroupings + } } override def onStop() { @@ -42,6 +42,5 @@ class DatasetsAutodumpService (application: Application) extends Plugin { unsuccessfulMessage = unsuccessfulMessage.substring(0, unsuccessfulMessage.length()-2) + "." Logger.debug(unsuccessfulMessage) } - } - -} \ No newline at end of file + } +} diff --git a/app/services/DatasetsMetadataAutodumpService.scala b/app/services/DatasetsMetadataAutodumpService.scala index 26d9052ab..4521c07eb 100644 --- a/app/services/DatasetsMetadataAutodumpService.scala +++ b/app/services/DatasetsMetadataAutodumpService.scala @@ -17,9 +17,9 @@ class DatasetsMetadataAutodumpService (application: Application) extends Plugin Logger.debug("Starting dataset metadata autodumper Plugin") //Dump metadata of all datasets periodically val timeInterval = play.Play.application().configuration().getInt("datasetmetadatadump.dumpEvery") - Akka.system().scheduler.schedule(0.days, timeInterval.intValue().days){ - dumpAllDatasetMetadata - } + Akka.system().scheduler.schedule(0.days, timeInterval.intValue().days){ + dumpAllDatasetMetadata + } } override def onStop() { @@ -44,5 +44,4 @@ class DatasetsMetadataAutodumpService (application: Application) extends Plugin } } - -} \ No newline at end of file +} diff --git a/app/services/ElasticsearchPlugin.scala b/app/services/ElasticsearchPlugin.scala index 62358d9fb..1925ba01f 100644 --- a/app/services/ElasticsearchPlugin.scala +++ b/app/services/ElasticsearchPlugin.scala @@ -958,4 +958,4 @@ class ElasticsearchPlugin(application: Application) extends Plugin { Logger.info("ElasticsearchPlugin has stopped") } -} \ No newline at end of file +} diff --git a/app/services/EventService.scala b/app/services/EventService.scala index bd4d474ff..e0f4e8240 100644 --- a/app/services/EventService.scala +++ b/app/services/EventService.scala @@ -12,90 +12,90 @@ import com.novus.salat.dao.SalatMongoCursor */ trait EventService { - - /** - * Lists all the events - */ - - def listEvents(): List[Event] - - /** - * Adds a general event - */ - - def addEvent(event: Event) - - /** - * Event where only the user is involved - */ - def addUserEvent(user: Option[User], action_type: String) - - /** - * Event where user interacts with one object - */ - def addObjectEvent(user: Option[User], object_id: UUID, object_name: String, action_type: String) - - /** - * Event where the user interacts with 2 objects, etc moving a dataset to a collection - */ - def addSourceEvent(user: Option[User], object_id: UUID, object_name: String, source_id: UUID, source_name: String, action_type: String) - - /** - * Event where 2 user interacts with 1 object, etc request event - */ - def addRequestEvent(user: Option[User], targetuser: User, object_id: UUID, object_name: String, action_type: String) - - /** - * Gets limit number of events from users, collections, datasets, and files and compliles them into 1 list - */ - def getEvents(followedEntities:List[TypedID], limit: Option[Integer]): List[Event] - - /** - * Gets all users for a specific list and specific type: object or source - */ - - def getEventsOfType(following: List[UUID], id_type: String, limit: Option[Integer]): List[Event] - - /** - * Gets all events for one UUID - */ - def getEvents(id: String, id_type: String, limit: Option[Integer]): SalatMongoCursor[Event] - - /** - * Get limit number of events which come after a specificied time - */ - - def getEventsByTime(followedEntities:List[TypedID], time: Date, limit: Option[Integer]): List[Event] - - /** - * Get the latest N events - */ - def getLatestNEventsOfType(n: Int, event_type: Option[String]): List[Event] - - /** - * Get the request event and loginuser is targetuser - */ - def getRequestEvents( targetuser: Option[User], limit: Option[Integer]): List[Event] - - /** - * Get the events by creator - */ - def getEventsByUser( user: User, limit: Option[Integer]): List[Event] - - /** - * Get the comment events - */ - def getCommentEvent( user: User, limit: Option[Integer]): List[Event] - - /** - * Update the object name - */ - def updateObjectName(id:UUID, name:String) - - /** - * Update user fullname + + /** + * Lists all the events + */ + + def listEvents(): List[Event] + + /** + * Adds a general event + */ + + def addEvent(event: Event) + + /** + * Event where only the user is involved + */ + def addUserEvent(user: Option[User], action_type: String) + + /** + * Event where user interacts with one object + */ + def addObjectEvent(user: Option[User], object_id: UUID, object_name: String, action_type: String) + + /** + * Event where the user interacts with 2 objects, etc moving a dataset to a collection + */ + def addSourceEvent(user: Option[User], object_id: UUID, object_name: String, source_id: UUID, source_name: String, action_type: String) + + /** + * Event where 2 user interacts with 1 object, etc request event + */ + def addRequestEvent(user: Option[User], targetuser: User, object_id: UUID, object_name: String, action_type: String) + + /** + * Gets limit number of events from users, collections, datasets, and files and compliles them into 1 list + */ + def getEvents(followedEntities:List[TypedID], limit: Option[Integer]): List[Event] + + /** + * Gets all users for a specific list and specific type: object or source */ - def updateAuthorFullName(userId: UUID, fullName: String) + + def getEventsOfType(following: List[UUID], id_type: String, limit: Option[Integer]): List[Event] + + /** + * Gets all events for one UUID + */ + def getEvents(id: String, id_type: String, limit: Option[Integer]): SalatMongoCursor[Event] + + /** + * Get limit number of events which come after a specificied time + */ + + def getEventsByTime(followedEntities:List[TypedID], time: Date, limit: Option[Integer]): List[Event] + + /** + * Get the latest N events + */ + def getLatestNEventsOfType(n: Int, event_type: Option[String]): List[Event] + + /** + * Get the request event and loginuser is targetuser + */ + def getRequestEvents( targetuser: Option[User], limit: Option[Integer]): List[Event] + + /** + * Get the events by creator + */ + def getEventsByUser( user: User, limit: Option[Integer]): List[Event] + + /** + * Get the comment events + */ + def getCommentEvent( user: User, limit: Option[Integer]): List[Event] + + /** + * Update the object name + */ + def updateObjectName(id:UUID, name:String) + + /** + * Update user fullname + */ + def updateAuthorFullName(userId: UUID, fullName: String) } diff --git a/app/services/ExtractionRequestsService.scala b/app/services/ExtractionRequestsService.scala index 880eb1dd3..74587a4f3 100644 --- a/app/services/ExtractionRequestsService.scala +++ b/app/services/ExtractionRequestsService.scala @@ -12,4 +12,4 @@ trait ExtractionRequestsService { def updateRequest(file_id:UUID,extractor_id:String) def getDTSRequests():List[ExtractionRequests] -} \ No newline at end of file +} diff --git a/app/services/ExtractorService.scala b/app/services/ExtractorService.scala index 7bc1a0436..094fe9327 100644 --- a/app/services/ExtractorService.scala +++ b/app/services/ExtractorService.scala @@ -40,4 +40,4 @@ trait ExtractorService { def getExtractorInfo(extractorName: String): Option[ExtractorInfo] def updateExtractorInfo(e: ExtractorInfo): Option[ExtractorInfo] -} \ No newline at end of file +} diff --git a/app/services/FileDumpService.scala b/app/services/FileDumpService.scala index 81a028136..209f07738 100644 --- a/app/services/FileDumpService.scala +++ b/app/services/FileDumpService.scala @@ -18,18 +18,18 @@ class FileDumpService(application: Application) extends Plugin { Logger.debug("Starting file dumper Plugin") val fileSep = System.getProperty("file.separator") var fileDumpDir = play.api.Play.configuration.getString("filedump.dir").getOrElse("") - if(!fileDumpDir.equals("")){ - if (!fileDumpDir.endsWith(fileSep)) - fileDumpDir = fileDumpDir + fileSep - this.fileDumpDir = Some(fileDumpDir) - - var fileDumpMoveDir = play.api.Play.configuration.getString("filedumpmove.dir").getOrElse("") - if(!fileDumpMoveDir.equals("")){ - if(!fileDumpMoveDir.endsWith(fileSep)) - fileDumpMoveDir = fileDumpMoveDir + fileSep - this.fileDumpMoveDir = Some(fileDumpMoveDir) - } - } + if(!fileDumpDir.equals("")){ + if (!fileDumpDir.endsWith(fileSep)) + fileDumpDir = fileDumpDir + fileSep + this.fileDumpDir = Some(fileDumpDir) + + var fileDumpMoveDir = play.api.Play.configuration.getString("filedumpmove.dir").getOrElse("") + if(!fileDumpMoveDir.equals("")){ + if(!fileDumpMoveDir.endsWith(fileSep)) + fileDumpMoveDir = fileDumpMoveDir + fileSep + this.fileDumpMoveDir = Some(fileDumpMoveDir) + } + } } override def onStop() { @@ -57,10 +57,10 @@ class FileDumpService(application: Application) extends Plugin { movedFile.getParentFile().mkdirs() if(copiedFile.renameTo(movedFile)){ - Logger.debug("File dumped and moved to staging directory successfully.") + Logger.debug("File dumped and moved to staging directory successfully.") }else{ - Logger.warn("Could not move dumped file to staging directory.") - } + Logger.warn("Could not move dumped file to staging directory.") + } } case None => Logger.warn("Could not move dumped file to staging directory. No staging directory set.") } @@ -75,4 +75,4 @@ case class DumpOfFile( fileToDump: File, fileId: String, fileName: String -) \ No newline at end of file +) diff --git a/app/services/FileMetadataAutodumpService.scala b/app/services/FileMetadataAutodumpService.scala index 4f7c6f515..8cfee1df6 100644 --- a/app/services/FileMetadataAutodumpService.scala +++ b/app/services/FileMetadataAutodumpService.scala @@ -17,9 +17,9 @@ class FileMetadataAutodumpService (application: Application) extends Plugin { Logger.debug("Starting file metadata autodumper Plugin") //Dump metadata of all files periodically val timeInterval = play.Play.application().configuration().getInt("filemetadatadump.dumpEvery") - Akka.system().scheduler.schedule(0.days, timeInterval.intValue().days){ - dumpAllFileMetadata - } + Akka.system().scheduler.schedule(0.days, timeInterval.intValue().days){ + dumpAllFileMetadata + } } override def onStop() { @@ -43,6 +43,5 @@ class FileMetadataAutodumpService (application: Application) extends Plugin { Logger.debug(unsuccessfulMessage) } - } - -} \ No newline at end of file + } +} diff --git a/app/services/LdapProvider.scala b/app/services/LdapProvider.scala index 2e5b87fca..dbacfce98 100644 --- a/app/services/LdapProvider.scala +++ b/app/services/LdapProvider.scala @@ -83,4 +83,4 @@ object LdapProvider { lazy val objectClass = conf.getString("securesocial.ldap.objectClass").getOrElse("inetorgperson") lazy val ldapServerURL = conf.getString("securesocial.ldap.url").getOrElse("http://localhost/ldap") lazy val ldapServerTimeOut = conf.getInt("securesocial.ldap.timeout").getOrElse(5) -} \ No newline at end of file +} diff --git a/app/services/MailerPlugin.scala b/app/services/MailerPlugin.scala index 787499d53..f520c847d 100644 --- a/app/services/MailerPlugin.scala +++ b/app/services/MailerPlugin.scala @@ -48,18 +48,18 @@ class MailerPlugin (application: Application) extends Plugin { } def sendMail(subscriberMail : String, html: String, subject: String): Boolean = { - - Logger.debug("Sending mail to " + subscriberMail) + + Logger.debug("Sending mail to " + subscriberMail) //Authenticate if needed var session = Session.getDefaultInstance(properties) if(!user.equals("")){ session = Session.getInstance(properties, - new javax.mail.Authenticator() { - override def getPasswordAuthentication(): PasswordAuthentication = { - return new PasswordAuthentication(user, play.api.Play.configuration.getString("smtp.password").getOrElse("")) - } - }) + new javax.mail.Authenticator() { + override def getPasswordAuthentication(): PasswordAuthentication = { + return new PasswordAuthentication(user, play.api.Play.configuration.getString("smtp.password").getOrElse("")) + } + }) } try{ @@ -74,12 +74,12 @@ class MailerPlugin (application: Application) extends Plugin { Logger.debug("Sent message successfully.") }catch { case msgex: MessagingException =>{ - Logger.error(msgex.toString()) - return false + Logger.error(msgex.toString()) + return false } } return true } -} \ No newline at end of file +} diff --git a/app/services/MultimediaQueryService.scala b/app/services/MultimediaQueryService.scala index 49c2bda18..1428be443 100644 --- a/app/services/MultimediaQueryService.scala +++ b/app/services/MultimediaQueryService.scala @@ -61,4 +61,4 @@ abstract class MultimediaQueryService { def recomputeAllDistances() def computeDistances(source: MultimediaFeatures) -} \ No newline at end of file +} diff --git a/app/services/PolyglotPlugin.scala b/app/services/PolyglotPlugin.scala index 110c0c27e..5cff7f9a7 100644 --- a/app/services/PolyglotPlugin.scala +++ b/app/services/PolyglotPlugin.scala @@ -59,7 +59,7 @@ class PolyglotPlugin(application: Application) extends Plugin { */ def checkForFileAndDownload(triesLeft: Int, url: String, outputStream: OutputStream): Future[Unit] = { - //check that credentials are set in config file + //check that credentials are set in config file if ( !polyglotUser.isDefined || !polyglotPassword.isDefined) { throw new RuntimeException("Polyglot credentials not defined.") } @@ -75,7 +75,7 @@ class PolyglotPlugin(application: Application) extends Plugin { val result = WS.url(url) .withAuth(polyglotUser.get, polyglotPassword.get, AuthScheme.BASIC) .get { xx => fromStream(outputStream) } - .flatMap(_.run) + .flatMap(_.run) //Returning result. When it is mapped in the controller, the successful future is AFTER file has been downloaded on the Clowder server. result } else { @@ -156,7 +156,7 @@ class PolyglotPlugin(application: Application) extends Plugin { .get .map { case response => - //If reponse was successful, get a list of output formats. Otherwise return None. + //If response was successful, get a list of output formats. Otherwise return None. val outputFormats = { if (response.status == 200) { Logger.debug("success getting response from Polyglot") @@ -176,4 +176,4 @@ class PolyglotPlugin(application: Application) extends Plugin { Future(None) } } -} \ No newline at end of file +} diff --git a/app/services/PostgresPlugin.scala b/app/services/PostgresPlugin.scala index f3ff6d18a..e54722600 100644 --- a/app/services/PostgresPlugin.scala +++ b/app/services/PostgresPlugin.scala @@ -479,11 +479,11 @@ class PostgresPlugin(application: Application) extends Plugin { def getSensorStats(id: String): Option[String] = { val query = "WITH stream_info AS (" + - "SELECT sensor_id, start_time, end_time, unnest(params) AS param FROM streams WHERE sensor_id=?" + - ") " + - "SELECT row_to_json(t, true) AS my_sensor FROM (" + - "SELECT to_char(min(start_time) AT TIME ZONE 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SSZ') As min_start_time, to_char(max(end_time) AT TIME ZONE 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SSZ') As max_end_time, array_agg(distinct param) AS parameters FROM stream_info" + - ") As t;" + "SELECT sensor_id, start_time, end_time, unnest(params) AS param FROM streams WHERE sensor_id=?" + + ") " + + "SELECT row_to_json(t, true) AS my_sensor FROM (" + + "SELECT to_char(min(start_time) AT TIME ZONE 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SSZ') As min_start_time, to_char(max(end_time) AT TIME ZONE 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SSZ') As max_end_time, array_agg(distinct param) AS parameters FROM stream_info" + + ") As t;" val st = conn.prepareStatement(query) st.setInt(1, id.toInt) Logger.debug("Get streams by sensor statement: " + st) @@ -665,7 +665,7 @@ class PostgresPlugin(application: Application) extends Plugin { } def deleteStream(id: Integer): Boolean = { - val deleteStream = "DELETE from streams where gid = ?" + val deleteStream = "DELETE from streams where gid = ?" val st = conn.prepareStatement(deleteStream) st.setInt(1, id) st.execute() @@ -990,15 +990,15 @@ class PostgresPlugin(application: Application) extends Plugin { def filterProperties(obj: JsObject, attributes: List[String]) = { var props = JsObject(Seq.empty) (obj \ "properties").asOpt[JsObject] match { - case Some(x) => { - for (f <- x.fieldSet) { - if (("source" == f._1) || attributes.contains(f._1)) { - props = props + f - } - } - (obj - ("properties") + ("properties", props)) - } - case None => obj + case Some(x) => { + for (f <- x.fieldSet) { + if (("source" == f._1) || attributes.contains(f._1)) { + props = props + f + } + } + (obj - ("properties") + ("properties", props)) + } + case None => obj } } diff --git a/app/services/RDFExportService.scala b/app/services/RDFExportService.scala index a938ef3c0..e0faa31ea 100644 --- a/app/services/RDFExportService.scala +++ b/app/services/RDFExportService.scala @@ -38,7 +38,7 @@ class RDFExportService (application: Application) extends Plugin { //Clean temporary RDF files var timeInterval = play.Play.application().configuration().getInt("rdfTempCleanup.checkEvery") Akka.system().scheduler.schedule(0.minutes, timeInterval.intValue().minutes){ - files.removeTemporaries() + files.removeTemporaries() } } @@ -54,131 +54,131 @@ class RDFExportService (application: Application) extends Plugin { val uuId = UUID(id) files.get(uuId) match { - case Some(file) => { - val theJSON = files.getUserMetadataJSON(uuId) - val fileSep = System.getProperty("file.separator") - - //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion - var extraChar = "" - val OS = System.getProperty("os.name").toLowerCase() - if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) - extraChar = "\\" - - var resultDir = resultsDir + new ObjectId().toString - new java.io.File(resultDir).mkdirs() - - if(!theJSON.replaceAll(" ","").equals("{}")){ - val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) - xmlFile.delete() - } - else{ - new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() - } - val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") - Some(resultFile) - } - case None => None - } + case Some(file) => { + val theJSON = files.getUserMetadataJSON(uuId) + val fileSep = System.getProperty("file.separator") + + //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion + var extraChar = "" + val OS = System.getProperty("os.name").toLowerCase() + if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) + extraChar = "\\" + + var resultDir = resultsDir + new ObjectId().toString + new java.io.File(resultDir).mkdirs() + + if(!theJSON.replaceAll(" ","").equals("{}")){ + val xmlFile = jsonToXML(theJSON) + new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + xmlFile.delete() + } + else{ + new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() + } + val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") + Some(resultFile) + } + case None => None + } } def getRDFURLsForFile(id: String): Option[JsValue] = { val uuId = UUID(id) files.get(uuId) match { - case Some(file) => { - - //RDF from XML of the file itself (for XML metadata-only files) - val previewsList = previews.findByFileId(uuId) - var rdfPreviewList = List.empty[models.Preview] - for(currPreview <- previewsList){ - if(currPreview.contentType.equals("application/rdf+xml")){ - rdfPreviewList = rdfPreviewList :+ currPreview - } - } - var list = for (currPreview <- rdfPreviewList) yield Json.toJson(hostUrl + api.routes.Previews.download(currPreview.id)) - - //RDF from export of file community-generated metadata to RDF - for(i <- 1 to filesMappingsQuantity){ - var currHostString = hostUrl + api.routes.Files.getRDFUserMetadata(uuId,i.toString) - list = list :+ Json.toJson(currHostString) - } - - val listJson = Json.toJson(list.toList) - Some(listJson) - } - case None => None - } + case Some(file) => { + + //RDF from XML of the file itself (for XML metadata-only files) + val previewsList = previews.findByFileId(uuId) + var rdfPreviewList = List.empty[models.Preview] + for(currPreview <- previewsList){ + if(currPreview.contentType.equals("application/rdf+xml")){ + rdfPreviewList = rdfPreviewList :+ currPreview + } + } + var list = for (currPreview <- rdfPreviewList) yield Json.toJson(hostUrl + api.routes.Previews.download(currPreview.id)) + + //RDF from export of file community-generated metadata to RDF + for(i <- 1 to filesMappingsQuantity){ + var currHostString = hostUrl + api.routes.Files.getRDFUserMetadata(uuId,i.toString) + list = list :+ Json.toJson(currHostString) + } + + val listJson = Json.toJson(list.toList) + Some(listJson) + } + case None => None + } } def getRDFUserMetadataDataset(id: String, mappingNumber: String="1"): Option[java.io.File] = { val uuId = UUID(id) datasets.get(uuId) match { - case Some(dataset) => { - val theJSON = datasets.getUserMetadataJSON(uuId) - val fileSep = System.getProperty("file.separator") - - //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion - var extraChar = "" - val OS = System.getProperty("os.name").toLowerCase() - if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) - extraChar = "\\" - - var resultDir = resultsDir + new ObjectId().toString - new java.io.File(resultDir).mkdirs() - - if(!theJSON.replaceAll(" ","").equals("{}")){ - val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) - xmlFile.delete() - } - else{ - new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() - } - val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") - Some(resultFile) - } - case None => None - } + case Some(dataset) => { + val theJSON = datasets.getUserMetadataJSON(uuId) + val fileSep = System.getProperty("file.separator") + + //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion + var extraChar = "" + val OS = System.getProperty("os.name").toLowerCase() + if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) + extraChar = "\\" + + var resultDir = resultsDir + new ObjectId().toString + new java.io.File(resultDir).mkdirs() + + if(!theJSON.replaceAll(" ","").equals("{}")){ + val xmlFile = jsonToXML(theJSON) + new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + xmlFile.delete() + } + else{ + new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() + } + val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") + Some(resultFile) + } + case None => None + } } def getRDFURLsForDataset(id: String): Option[JsValue] = { val uuId = UUID(id) datasets.get(uuId) match { - case Some(dataset) => { - - //RDF from XML files in the dataset itself (for XML metadata-only files) - val previewsList = previews.findByDatasetId(uuId) - var rdfPreviewList = List.empty[models.Preview] - for(currPreview <- previewsList){ - if(currPreview.contentType.equals("application/rdf+xml")){ - rdfPreviewList = rdfPreviewList :+ currPreview - } - } - var list = for (currPreview <- rdfPreviewList) yield Json.toJson(hostUrl + api.routes.Previews.download(currPreview.id)) - - for(file <- dataset.files){ - val filePreviewsList = previews.findByFileId(file) - var fileRdfPreviewList = List.empty[models.Preview] - for(currPreview <- filePreviewsList){ - if(currPreview.contentType.equals("application/rdf+xml")){ - fileRdfPreviewList = fileRdfPreviewList :+ currPreview - } - } - val filesList = for (currPreview <- fileRdfPreviewList) yield Json.toJson(hostUrl + api.routes.Previews.download(currPreview.id)) - list = list ++ filesList - } - - //RDF from export of file community-generated metadata to RDF - for(i <- 1 to filesMappingsQuantity){ - var currHostString = hostUrl + api.routes.Datasets.getRDFUserMetadata(uuId,i.toString) - list = list :+ Json.toJson(currHostString) - } - - val listJson = Json.toJson(list.toList) - Some(listJson) - } - case None => None - } + case Some(dataset) => { + + //RDF from XML files in the dataset itself (for XML metadata-only files) + val previewsList = previews.findByDatasetId(uuId) + var rdfPreviewList = List.empty[models.Preview] + for(currPreview <- previewsList){ + if(currPreview.contentType.equals("application/rdf+xml")){ + rdfPreviewList = rdfPreviewList :+ currPreview + } + } + var list = for (currPreview <- rdfPreviewList) yield Json.toJson(hostUrl + api.routes.Previews.download(currPreview.id)) + + for(file <- dataset.files){ + val filePreviewsList = previews.findByFileId(file) + var fileRdfPreviewList = List.empty[models.Preview] + for(currPreview <- filePreviewsList){ + if(currPreview.contentType.equals("application/rdf+xml")){ + fileRdfPreviewList = fileRdfPreviewList :+ currPreview + } + } + val filesList = for (currPreview <- fileRdfPreviewList) yield Json.toJson(hostUrl + api.routes.Previews.download(currPreview.id)) + list = list ++ filesList + } + + //RDF from export of file community-generated metadata to RDF + for(i <- 1 to filesMappingsQuantity){ + var currHostString = hostUrl + api.routes.Datasets.getRDFUserMetadata(uuId,i.toString) + list = list :+ Json.toJson(currHostString) + } + + val listJson = Json.toJson(list.toList) + Some(listJson) + } + case None => None + } } def jsonToXML(theJSON: String): java.io.File = { @@ -207,4 +207,4 @@ class RDFExportService (application: Application) extends Plugin { } -} \ No newline at end of file +} diff --git a/app/services/RDFUpdateService.scala b/app/services/RDFUpdateService.scala index c2a2384db..16ad41e13 100644 --- a/app/services/RDFUpdateService.scala +++ b/app/services/RDFUpdateService.scala @@ -67,198 +67,198 @@ class RDFUpdateService(application: Application) extends Plugin { def modifyRDFUserMetadataFiles(id: UUID, mappingNumber: String="1") = { sparql.removeFileFromGraphs(id, "rdfCommunityGraphName") files.get(id) match { - case Some(file) => { - val theJSON = files.getUserMetadataJSON(id) - val fileSep = System.getProperty("file.separator") - - //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion - var extraChar = "" - val OS = System.getProperty("os.name").toLowerCase() - if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) - extraChar = "\\" - - val tmpDir = System.getProperty("java.io.tmpdir") - var resultDir = tmpDir + fileSep + "clowder__rdfuploadtemporaryfiles" + fileSep + new ObjectId().toString - val resultDirFile = new java.io.File(resultDir) - resultDirFile.mkdirs() - - if(!theJSON.replaceAll(" ","").equals("{}")){ - val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) - xmlFile.delete() - } - else{ - new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() - } - val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") - - //Connecting RDF metadata with the entity describing the original file - val rootNodes = new ArrayList[String]() - val rootNodesFile = play.api.Play.configuration.getString("rootNodesFile").getOrElse("") - Logger.debug(rootNodesFile) - if(!rootNodesFile.equals("*")){ - val rootNodesReader = new BufferedReader(new FileReader(new java.io.File(rootNodesFile))) - var line = rootNodesReader.readLine() - while (line != null){ - Logger.debug((line == null).toString() ) - rootNodes.add(line.trim()) - line = rootNodesReader.readLine() - } - rootNodesReader.close() - } - - val resultFileConnected = java.io.File.createTempFile("ResultsConnected", ".rdf") - - val fileWriter = new BufferedWriter(new FileWriter(resultFileConnected)) - val fis = new FileInputStream(resultFile) - val data = new Array[Byte] (resultFile.length().asInstanceOf[Int]) - fis.read(data) - fis.close() - resultFile.delete() - FileUtils.deleteDirectory(resultDirFile) - // - val s = new String(data, "UTF-8") - val rdfDescriptions = s.split(" } - } - - if(isInRootNodes){ - val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"")+1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"")+1)) - val theHost = "http://" + play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") - var connection = "" - fileWriter.write(connection) - } - } - } - fileWriter.close() - - sparql.addFromFile(id, resultFileConnected, "file") - resultFileConnected.delete() - - sparql.addFileToGraph(id, "rdfCommunityGraphName") - - files.setUserMetadataWasModified(id, false) - } - case None => {} - } + case Some(file) => { + val theJSON = files.getUserMetadataJSON(id) + val fileSep = System.getProperty("file.separator") + + //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion + var extraChar = "" + val OS = System.getProperty("os.name").toLowerCase() + if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) + extraChar = "\\" + + val tmpDir = System.getProperty("java.io.tmpdir") + var resultDir = tmpDir + fileSep + "clowder__rdfuploadtemporaryfiles" + fileSep + new ObjectId().toString + val resultDirFile = new java.io.File(resultDir) + resultDirFile.mkdirs() + + if(!theJSON.replaceAll(" ","").equals("{}")){ + val xmlFile = jsonToXML(theJSON) + new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + xmlFile.delete() + } + else{ + new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() + } + val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") + + //Connecting RDF metadata with the entity describing the original file + val rootNodes = new ArrayList[String]() + val rootNodesFile = play.api.Play.configuration.getString("rootNodesFile").getOrElse("") + Logger.debug(rootNodesFile) + if(!rootNodesFile.equals("*")){ + val rootNodesReader = new BufferedReader(new FileReader(new java.io.File(rootNodesFile))) + var line = rootNodesReader.readLine() + while (line != null){ + Logger.debug((line == null).toString() ) + rootNodes.add(line.trim()) + line = rootNodesReader.readLine() + } + rootNodesReader.close() + } + + val resultFileConnected = java.io.File.createTempFile("ResultsConnected", ".rdf") + + val fileWriter = new BufferedWriter(new FileWriter(resultFileConnected)) + val fis = new FileInputStream(resultFile) + val data = new Array[Byte] (resultFile.length().asInstanceOf[Int]) + fis.read(data) + fis.close() + resultFile.delete() + FileUtils.deleteDirectory(resultDirFile) + // + val s = new String(data, "UTF-8") + val rdfDescriptions = s.split(" } + } + + if(isInRootNodes){ + val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"")+1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"")+1)) + val theHost = "http://" + play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") + var connection = "" + fileWriter.write(connection) + } + } + } + fileWriter.close() + + sparql.addFromFile(id, resultFileConnected, "file") + resultFileConnected.delete() + + sparql.addFileToGraph(id, "rdfCommunityGraphName") + + files.setUserMetadataWasModified(id, false) + } + case None => {} + } } - def modifyRDFUserMetadataDatasets(id: UUID, mappingNumber: String="1") = { - sparql.removeDatasetFromUserGraphs(id) - datasets.get(id) match { - case Some(dataset) => { - val theJSON = datasets.getUserMetadataJSON(id) - val fileSep = System.getProperty("file.separator") - - //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion - var extraChar = "" - val OS = System.getProperty("os.name").toLowerCase() - if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) - extraChar = "\\" - - val tmpDir = System.getProperty("java.io.tmpdir") - var resultDir = tmpDir + fileSep + "clowder__rdfuploadtemporaryfiles" + fileSep + new ObjectId().toString - val resultDirFile = new java.io.File(resultDir) - resultDirFile.mkdirs() - - if(!theJSON.replaceAll(" ","").equals("{}")){ - val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) - xmlFile.delete() - } - else{ - new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() - } - val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") - - //Connecting RDF metadata with the entity describing the original file - val rootNodes = new ArrayList[String]() - val rootNodesFile = play.api.Play.configuration.getString("datasetRootNodesFile").getOrElse("") - Logger.debug(rootNodesFile) - if(!rootNodesFile.equals("*")){ - val rootNodesReader = new BufferedReader(new FileReader(new java.io.File(rootNodesFile))) - var line = rootNodesReader.readLine() - while (line != null){ - Logger.debug((line == null).toString() ) - rootNodes.add(line.trim()) - line = rootNodesReader.readLine() - } - rootNodesReader.close() - } - - val resultFileConnected = java.io.File.createTempFile("ResultsConnected", ".rdf") - - val fileWriter = new BufferedWriter(new FileWriter(resultFileConnected)) - val fis = new FileInputStream(resultFile) - val data = new Array[Byte] (resultFile.length().asInstanceOf[Int]) - fis.read(data) - fis.close() - resultFile.delete() - FileUtils.deleteDirectory(resultDirFile) - // - val s = new String(data, "UTF-8") - val rdfDescriptions = s.split(" } - } - - if(isInRootNodes){ - val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"")+1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"")+1)) - val theHost = "http://" + play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") - var connection = "" - fileWriter.write(connection) - } - } - } - fileWriter.close() - - sparql.addFromFile(id, resultFileConnected, "dataset") - resultFileConnected.delete() - - sparql.addDatasetToGraph(id, "rdfCommunityGraphName") - - datasets.setUserMetadataWasModified(id, false) - } - case None => {} - } + def modifyRDFUserMetadataDatasets(id: UUID, mappingNumber: String="1") = { + sparql.removeDatasetFromUserGraphs(id) + datasets.get(id) match { + case Some(dataset) => { + val theJSON = datasets.getUserMetadataJSON(id) + val fileSep = System.getProperty("file.separator") + + //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion + var extraChar = "" + val OS = System.getProperty("os.name").toLowerCase() + if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) + extraChar = "\\" + + val tmpDir = System.getProperty("java.io.tmpdir") + var resultDir = tmpDir + fileSep + "clowder__rdfuploadtemporaryfiles" + fileSep + new ObjectId().toString + val resultDirFile = new java.io.File(resultDir) + resultDirFile.mkdirs() + + if(!theJSON.replaceAll(" ","").equals("{}")){ + val xmlFile = jsonToXML(theJSON) + new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + xmlFile.delete() + } + else{ + new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() + } + val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") + + //Connecting RDF metadata with the entity describing the original file + val rootNodes = new ArrayList[String]() + val rootNodesFile = play.api.Play.configuration.getString("datasetRootNodesFile").getOrElse("") + Logger.debug(rootNodesFile) + if(!rootNodesFile.equals("*")){ + val rootNodesReader = new BufferedReader(new FileReader(new java.io.File(rootNodesFile))) + var line = rootNodesReader.readLine() + while (line != null){ + Logger.debug((line == null).toString() ) + rootNodes.add(line.trim()) + line = rootNodesReader.readLine() + } + rootNodesReader.close() + } + + val resultFileConnected = java.io.File.createTempFile("ResultsConnected", ".rdf") + + val fileWriter = new BufferedWriter(new FileWriter(resultFileConnected)) + val fis = new FileInputStream(resultFile) + val data = new Array[Byte] (resultFile.length().asInstanceOf[Int]) + fis.read(data) + fis.close() + resultFile.delete() + FileUtils.deleteDirectory(resultDirFile) + // + val s = new String(data, "UTF-8") + val rdfDescriptions = s.split(" } + } + + if(isInRootNodes){ + val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"")+1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"")+1)) + val theHost = "http://" + play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") + var connection = "" + fileWriter.write(connection) + } + } + } + fileWriter.close() + + sparql.addFromFile(id, resultFileConnected, "dataset") + resultFileConnected.delete() + + sparql.addDatasetToGraph(id, "rdfCommunityGraphName") + + datasets.setUserMetadataWasModified(id, false) + } + case None => {} + } } diff --git a/app/services/RabbitmqPlugin.scala b/app/services/RabbitmqPlugin.scala index d31e29055..fe25e0b52 100644 --- a/app/services/RabbitmqPlugin.scala +++ b/app/services/RabbitmqPlugin.scala @@ -1239,4 +1239,4 @@ class ExtractorsHeartbeats(channel: Channel, queue: String) extends Actor { /** RabbitMQ Bindings retrieve from management API **/ case class Binding(source: String, vhost: String, destination: String, destination_type: String, routing_key: String, - arguments: JsObject, properties_key: String) \ No newline at end of file + arguments: JsObject, properties_key: String) diff --git a/app/services/RdfSPARQLService.scala b/app/services/RdfSPARQLService.scala index 0f4a30798..dd81523a3 100644 --- a/app/services/RdfSPARQLService.scala +++ b/app/services/RdfSPARQLService.scala @@ -22,4 +22,4 @@ trait RdfSPARQLService { def addFromFile(id: UUID, tempFile: java.io.File, fileOrDataset: String, selectedGraph:String = "rdfCommunityGraphName") : Null -} \ No newline at end of file +} diff --git a/app/services/SchedulerService.scala b/app/services/SchedulerService.scala index c9599366b..dff77f72c 100644 --- a/app/services/SchedulerService.scala +++ b/app/services/SchedulerService.scala @@ -10,51 +10,51 @@ import com.novus.salat.dao.SalatMongoCursor */ trait SchedulerService { - - /** - * Lists all the scheduled jobs - */ + + /** + * Lists all the scheduled jobs + */ - def listJobs(): List[TimerJob] + def listJobs(): List[TimerJob] - /** - * schedule jobs - */ + /** + * schedule jobs + */ - def scheduleJob(job: TimerJob) + def scheduleJob(job: TimerJob) - /** - * find job by name - */ + /** + * find job by name + */ - def getJob(name: String): SalatMongoCursor[TimerJob] + def getJob(name: String): SalatMongoCursor[TimerJob] - /** - * Remove Job from Jobs Collection - */ + /** + * Remove Job from Jobs Collection + */ - def deleteJob(name: String) + def deleteJob(name: String) - /** - * Add an email digest job - */ + /** + * Add an email digest job + */ - def updateEmailJob(id : UUID, name: String, setting: String) + def updateEmailJob(id : UUID, name: String, setting: String) - /* - * Check if job exists in collection - */ - def jobExists(name: String): Boolean + /* + * Check if job exists in collection + */ + def jobExists(name: String): Boolean - /* - * Update the time last job was ran - */ + /* + * Update the time last job was ran + */ - def updateLastRun(name: String) + def updateLastRun(name: String) - /** - * Get Job by the current time - */ - def getJobByTime(minute: Integer, hour: Integer, day_of_week: Integer): List[TimerJob] + /** + * Get Job by the current time + */ + def getJobByTime(minute: Integer, hour: Integer, day_of_week: Integer): List[TimerJob] -} \ No newline at end of file +} diff --git a/app/services/SectionIndexInfoService.scala b/app/services/SectionIndexInfoService.scala index a26f019f4..fe9f4a05b 100644 --- a/app/services/SectionIndexInfoService.scala +++ b/app/services/SectionIndexInfoService.scala @@ -13,45 +13,45 @@ import scala.util.Try */ trait SectionIndexInfoService { - /** - * Add a new document to the collection, with index Id and type given. - */ - def insertType(indexId: UUID, indexType:String) - - /** - * Add a new document to the collection, with index Id and name given. - */ - def insertName(indexId:UUID, indexName:String) - - /** - * Check if given index is in the collection - */ - def isFound(indexId: UUID): Boolean - - /** - * Return type of the sections for the id given - */ - def getType(indexId:UUID):Option[String] - - /** - * Returns an array of all distinct values of the field indexType - */ - def getDistinctTypes:List[String] - - /** - * Return name of the sections for the id given - */ - def getName(indexId:UUID):Option[String] - - /** - * Delete all documents from collection - */ - def deleteAll() - - /** - * Deletes index with the given id. Returns true is index was found and deleted. Returns false if index was not found. - * In any case, after completion of the method, index will not be in the collection. - */ - def delete(id:UUID):Boolean - + /** + * Add a new document to the collection, with index Id and type given. + */ + def insertType(indexId: UUID, indexType:String) + + /** + * Add a new document to the collection, with index Id and name given. + */ + def insertName(indexId:UUID, indexName:String) + + /** + * Check if given index is in the collection + */ + def isFound(indexId: UUID): Boolean + + /** + * Return type of the sections for the id given + */ + def getType(indexId:UUID):Option[String] + + /** + * Returns an array of all distinct values of the field indexType + */ + def getDistinctTypes:List[String] + + /** + * Return name of the sections for the id given + */ + def getName(indexId:UUID):Option[String] + + /** + * Delete all documents from collection + */ + def deleteAll() + + /** + * Deletes index with the given id. Returns true is index was found and deleted. Returns false if index was not found. + * In any case, after completion of the method, index will not be in the collection. + */ + def delete(id:UUID):Boolean + } diff --git a/app/services/SectionService.scala b/app/services/SectionService.scala index 5f746b602..2b67ef272 100644 --- a/app/services/SectionService.scala +++ b/app/services/SectionService.scala @@ -48,4 +48,4 @@ trait SectionService { * Get the list of spaces that the section (section --> file --> dataset(s) --> [collection(s)] --> space(s)) belongs to */ def getParentSpaces(querySectionId: UUID): ArrayBuffer[UUID] -} \ No newline at end of file +} diff --git a/app/services/SecureSocialTemplatesPlugin.scala b/app/services/SecureSocialTemplatesPlugin.scala index 5b78f9c74..11bb0f3c7 100644 --- a/app/services/SecureSocialTemplatesPlugin.scala +++ b/app/services/SecureSocialTemplatesPlugin.scala @@ -145,4 +145,4 @@ class SecureSocialTemplatesPlugin(application: play.Application) extends Templat def getPasswordChangePage[A](implicit request: SecuredRequest[A], form: Form[ChangeInfo]):Html = { securesocial.views.html.passwordChange(form) } -} \ No newline at end of file +} diff --git a/app/services/SpaceService.scala b/app/services/SpaceService.scala index cb5220f8d..c84497166 100644 --- a/app/services/SpaceService.scala +++ b/app/services/SpaceService.scala @@ -272,18 +272,18 @@ trait SpaceService { def removeCurationObject(spaceId: UUID, curationObjectId: UUID) /** - * If entry for spaceId already exists, will update list of extractors. - * Otherwise will create and add a new document to the collection, with spaceId and extractor given. - */ - def addExtractor(spaceId: UUID, extractor:String) - - /** - * Get all extractors for this space id. - */ + * If entry for spaceId already exists, will update list of extractors. + * Otherwise will create and add a new document to the collection, with spaceId and extractor given. + */ + def addExtractor(spaceId: UUID, extractor:String) + + /** + * Get all extractors for this space id. + */ def getAllExtractors(spaceId: UUID): List[String] /** - * Delete an entire entry with extractors for this space id. - */ - def deleteAllExtractors(spaceId: UUID): Boolean -} \ No newline at end of file + * Delete an entire entry with extractors for this space id. + */ + def deleteAllExtractors(spaceId: UUID): Boolean +} diff --git a/app/services/fourstore/FourStoreRdfSPARQLService.scala b/app/services/fourstore/FourStoreRdfSPARQLService.scala index 607ece43a..9bc9ff8e4 100644 --- a/app/services/fourstore/FourStoreRdfSPARQLService.scala +++ b/app/services/fourstore/FourStoreRdfSPARQLService.scala @@ -19,133 +19,133 @@ import models.UUID class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: FileService) extends RdfSPARQLService { def addFileToGraph(fileId: UUID, selectedGraph:String = "rdfXMLGraphName"): Null = { - - val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/data/" - val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") + + val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/data/" + val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") val httpclient = new DefaultHttpClient() val httpPost = new HttpPost(queryUrl) - + val urlParameters = new ArrayList[NameValuePair]() var updateQuery = " <" + graphName + "_file" + "> ." - + updateQuery = updateQuery + "> <" + graphName + "_file" + "> ." + Logger.debug("the query: "+updateQuery) - urlParameters.add(new BasicNameValuePair("data", updateQuery)) - urlParameters.add(new BasicNameValuePair("graph", graphName + "_file_" + fileId)) - urlParameters.add(new BasicNameValuePair("mime-type", "application/x-turtle")) - + urlParameters.add(new BasicNameValuePair("data", updateQuery)) + urlParameters.add(new BasicNameValuePair("graph", graphName + "_file_" + fileId)) + urlParameters.add(new BasicNameValuePair("mime-type", "application/x-turtle")) + httpPost.setEntity(new UrlEncodedFormEntity(urlParameters)) val queryResponse = httpclient.execute(httpPost) Logger.debug(queryResponse.getStatusLine().toString()) - + val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - + Logger.debug("the results: "+resultsString) - - return null + + return null } def addDatasetToGraph(datasetId: UUID, selectedGraph: String = "rdfXMLGraphName"): Null = { - - val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/data/" - val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") + + val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/data/" + val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") val httpclient = new DefaultHttpClient() val httpPost = new HttpPost(queryUrl) - + val urlParameters = new ArrayList[NameValuePair]() var updateQuery = " <" + graphName + "_dataset" + "> ." - + Logger.debug("the query: "+updateQuery) - urlParameters.add(new BasicNameValuePair("data", updateQuery)) - urlParameters.add(new BasicNameValuePair("graph", graphName + "_dataset_" + datasetId)) - urlParameters.add(new BasicNameValuePair("mime-type", "application/x-turtle")) - + urlParameters.add(new BasicNameValuePair("data", updateQuery)) + urlParameters.add(new BasicNameValuePair("graph", graphName + "_dataset_" + datasetId)) + urlParameters.add(new BasicNameValuePair("mime-type", "application/x-turtle")) + httpPost.setEntity(new UrlEncodedFormEntity(urlParameters)) val queryResponse = httpclient.execute(httpPost) Logger.debug(queryResponse.getStatusLine().toString()) - + val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - + Logger.debug("the results: "+resultsString) - return null + return null } - + def linkFileToDataset(fileId: UUID, datasetId: UUID, selectedGraph: String = "rdfXMLGraphName"): Null = { - - val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/data/" - val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") + + val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/data/" + val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") val httpclient = new DefaultHttpClient() val httpPost = new HttpPost(queryUrl) - + val urlParameters = new ArrayList[NameValuePair]() val hostIp = play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") var updateQuery = " ." - + Logger.debug("the query: "+updateQuery) - urlParameters.add(new BasicNameValuePair("data", updateQuery)) - urlParameters.add(new BasicNameValuePair("graph", graphName + "_file_" + fileId)) - urlParameters.add(new BasicNameValuePair("mime-type", "application/x-turtle")) - + urlParameters.add(new BasicNameValuePair("data", updateQuery)) + urlParameters.add(new BasicNameValuePair("graph", graphName + "_file_" + fileId)) + urlParameters.add(new BasicNameValuePair("mime-type", "application/x-turtle")) + httpPost.setEntity(new UrlEncodedFormEntity(urlParameters)) val queryResponse = httpclient.execute(httpPost) Logger.debug(queryResponse.getStatusLine().toString()) - + val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - + Logger.debug("the results: "+resultsString) - return null + return null } - + def removeFileFromGraphs(fileId: UUID, selectedGraph:String = "rdfXMLGraphName"): Null = { - - val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") - val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/data/" + graphName + "_file_" + fileId + + val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") + val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/data/" + graphName + "_file_" + fileId val httpclient = new DefaultHttpClient() - + val httpDelete = new HttpDelete(queryUrl) - + val queryResponse = httpclient.execute(httpDelete) Logger.debug(queryResponse.getStatusLine().toString()) val resultsEntity = queryResponse.getEntity() - val resultsString = EntityUtils.toString(resultsEntity) + val resultsString = EntityUtils.toString(resultsEntity) Logger.debug("the results: "+resultsString) - return null - + return null + } - + def removeDatasetFromUserGraphs(datasetId: UUID): Null = { - - val graphName = play.api.Play.configuration.getString("rdfCommunityGraphName").getOrElse("") - val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/data/" + graphName + "_dataset_" + datasetId + + val graphName = play.api.Play.configuration.getString("rdfCommunityGraphName").getOrElse("") + val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/data/" + graphName + "_dataset_" + datasetId val httpclient = new DefaultHttpClient() - + val httpDelete = new HttpDelete(queryUrl) - + val queryResponse = httpclient.execute(httpDelete) Logger.debug(queryResponse.getStatusLine().toString()) val resultsEntity = queryResponse.getEntity() - val resultsString = EntityUtils.toString(resultsEntity) + val resultsString = EntityUtils.toString(resultsEntity) Logger.debug("the results: "+resultsString) - return null - + return null + } - + def detachFileFromDataset(fileId: UUID, datasetId: UUID, selectedGraph:String = "rdfXMLGraphName"): Null = { - - val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/update/" - val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") + + val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/update/" + val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") val httpclient = new DefaultHttpClient() val httpPost = new HttpPost(queryUrl) - + val urlParameters = new ArrayList[NameValuePair]() val hostIp = play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") var updateQuery = "DELETE { " + updateQuery } Logger.debug("the query: "+updateQuery) - urlParameters.add(new BasicNameValuePair("update", updateQuery)) - + urlParameters.add(new BasicNameValuePair("update", updateQuery)) + httpPost.setEntity(new UrlEncodedFormEntity(urlParameters)) val queryResponse = httpclient.execute(httpPost) Logger.debug(queryResponse.getStatusLine().toString()) - + val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - + Logger.debug("the results: "+resultsString) - return null - + return null + } - + def removeDatasetFromGraphs(datasetId: UUID): Null = { //First, delete all RDF links having to do with files belonging only to the dataset to be deleted, as those files will be deleted together with the dataset datasets.get(datasetId) match { @@ -195,60 +195,57 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File } } return null - + } - + def sparqlQuery(queryText: String): String = { - - val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/sparql/" + + val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/sparql/" val httpclient = new DefaultHttpClient() - Logger.debug("query text: "+ queryText) + Logger.debug("query text: "+ queryText) val httpPost = new HttpPost(queryUrl) - + val urlParameters = new ArrayList[NameValuePair]() - urlParameters.add(new BasicNameValuePair("query", queryText)) - + urlParameters.add(new BasicNameValuePair("query", queryText)) + httpPost.setEntity(new UrlEncodedFormEntity(urlParameters)) val queryResponse = httpclient.execute(httpPost) Logger.debug(queryResponse.getStatusLine().toString()) - + val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - + return resultsString } - + def addFromFile(id: UUID, tempFile: java.io.File, fileOrDataset: String, selectedGraph:String = "rdfCommunityGraphName") : Null = { - + val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/data/" - val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") + val graphName = play.api.Play.configuration.getString(selectedGraph).getOrElse("") val httpclient = new DefaultHttpClient() val httpPost = new HttpPost(queryUrl) - + val urlParameters = new ArrayList[NameValuePair]() - + val fis = new FileInputStream(tempFile) val data = new Array[Byte] (tempFile.length().asInstanceOf[Int]) fis.read(data) fis.close() - - var updateQuery = new String(data, "UTF-8") - - urlParameters.add(new BasicNameValuePair("data", updateQuery)) - urlParameters.add(new BasicNameValuePair("graph", graphName + "_"+ fileOrDataset + "_" + id)) - + + var updateQuery = new String(data, "UTF-8") + + urlParameters.add(new BasicNameValuePair("data", updateQuery)) + urlParameters.add(new BasicNameValuePair("graph", graphName + "_"+ fileOrDataset + "_" + id)) + httpPost.setEntity(new UrlEncodedFormEntity(urlParameters)) val queryResponse = httpclient.execute(httpPost) Logger.debug(queryResponse.getStatusLine().toString()) - + val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - + Logger.debug("the results: "+resultsString) return null } - - - -} \ No newline at end of file +} diff --git a/app/services/irods/IRODSPlugin.scala b/app/services/irods/IRODSPlugin.scala index 4a4921009..697b73def 100644 --- a/app/services/irods/IRODSPlugin.scala +++ b/app/services/irods/IRODSPlugin.scala @@ -31,11 +31,11 @@ class IRODSPlugin(app: Application) extends Plugin { openIRODSConnection() Logger.info("irods: Connected. " + conn) } - + override def onStop() { - // close connection - closeIRODSConnection() - Logger.info("iRODSPlugin has stopped.") + // close connection + closeIRODSConnection() + Logger.info("iRODSPlugin has stopped.") } //Is the plugin enabled? @@ -44,45 +44,45 @@ class IRODSPlugin(app: Application) extends Plugin { def openIRODSConnection() = { lazy val configuration = Play.current.configuration - // you can now access the application.conf settings - - // seven required fields (similar to .irodsEnv file used in icommands client) - val host = configuration.getString("irods.host").getOrElse("") - val port = configuration.getInt("irods.port").getOrElse(0) - val username = configuration.getString("irods.username").getOrElse("") - val password = configuration.getString("irods.password").getOrElse("") - val zone = configuration.getString("irods.zone").getOrElse("") - val defaultStorageResource = configuration.getString("irods.defaultStorageResource").getOrElse("") - userhome = configuration.getString("irods.userhome").getOrElse("") - - val usercurrent = configuration.getString("irods.usercurrent").getOrElse("") + // you can now access the application.conf settings + + // seven required fields (similar to .irodsEnv file used in icommands client) + val host = configuration.getString("irods.host").getOrElse("") + val port = configuration.getInt("irods.port").getOrElse(0) + val username = configuration.getString("irods.username").getOrElse("") + val password = configuration.getString("irods.password").getOrElse("") + val zone = configuration.getString("irods.zone").getOrElse("") + val defaultStorageResource = configuration.getString("irods.defaultStorageResource").getOrElse("") + userhome = configuration.getString("irods.userhome").getOrElse("") + + val usercurrent = configuration.getString("irods.usercurrent").getOrElse("") - try { - account = IRODSAccount.instance(host, port, username, password, userhome, zone, defaultStorageResource) - irodsFileSystem = IRODSFileSystem.instance() // RODSFileSystem shared object, initialized - Logger.debug("irods: Connecting to " + account.toString()) + try { + account = IRODSAccount.instance(host, port, username, password, userhome, zone, defaultStorageResource) + irodsFileSystem = IRODSFileSystem.instance() // RODSFileSystem shared object, initialized + Logger.debug("irods: Connecting to " + account.toString()) - // the actual connection, For a given account creates an IRODSFileFactory that can return iRODS file objects for this particular connection. + // the actual connection, For a given account creates an IRODSFileFactory that can return iRODS file objects for this particular connection. irodsFileFactory = irodsFileSystem.getIRODSFileFactory(account) - _conn = true - } catch { - case je: org.irods.jargon.core.exception.JargonException => Logger.error("irods: Error connecting to iRODS server. " + je.toString); _conn = false - case t: Throwable => Logger.error("irods: Unknown error connecting to iRODS server: " + t.toString); _conn = false - } + _conn = true + } catch { + case je: org.irods.jargon.core.exception.JargonException => Logger.error("irods: Error connecting to iRODS server. " + je.toString); _conn = false + case t: Throwable => Logger.error("irods: Unknown error connecting to iRODS server: " + t.toString); _conn = false + } } def closeIRODSConnection() = { - Logger.info("irods: Closing connection.") - irodsFileSystem.closeAndEatExceptions() - _conn = false + Logger.info("irods: Closing connection.") + irodsFileSystem.closeAndEatExceptions() + _conn = false } // Close the session that is connected to the particular iRODS server with the given account. def closeIRODSAccountConnection() = { - Logger.info("irods: Closing account connection.") - irodsFileSystem.closeAndEatExceptions(account) - _conn = false + Logger.info("irods: Closing account connection.") + irodsFileSystem.closeAndEatExceptions(account) + _conn = false } //getters @@ -90,4 +90,4 @@ class IRODSPlugin(app: Application) extends Plugin { def conn = _conn // setter def conn_= (value:Boolean):Unit = _conn = value -} \ No newline at end of file +} diff --git a/app/services/mongodb/MongoDBAuthenticatorStore.scala b/app/services/mongodb/MongoDBAuthenticatorStore.scala index 2ade4aa56..d963547ee 100644 --- a/app/services/mongodb/MongoDBAuthenticatorStore.scala +++ b/app/services/mongodb/MongoDBAuthenticatorStore.scala @@ -78,5 +78,4 @@ class MongoDBAuthenticatorStore(app: Application) extends AuthenticatorStore(app AuthenticatorDAO.delete(id) Right(()) } - -} \ No newline at end of file +} diff --git a/app/services/mongodb/MongoDBCollectionService.scala b/app/services/mongodb/MongoDBCollectionService.scala index 191bad68f..5ade48c19 100644 --- a/app/services/mongodb/MongoDBCollectionService.scala +++ b/app/services/mongodb/MongoDBCollectionService.scala @@ -452,7 +452,7 @@ class MongoDBCollectionService @Inject() ( case None => MongoDBObject() } if (date == "") { - Collection.find(filter).sort(order).limit(limit).toList + Collection.find(filter).sort(order).limit(limit).toList } else { val sinceDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse(date) Logger.debug("After " + sinceDate) @@ -470,7 +470,7 @@ class MongoDBCollectionService @Inject() ( case None => MongoDBObject() } if (date == "") { - Collection.find(filter).sort(order).limit(limit).toList + Collection.find(filter).sort(order).limit(limit).toList } else { order = MongoDBObject("created" -> 1) val sinceDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse(date) @@ -771,7 +771,7 @@ class MongoDBCollectionService @Inject() ( def removeDataset(collectionId: UUID, datasetId: UUID, ignoreNotFound: Boolean = true) = Try { Logger.debug(s"Removing dataset $datasetId from collection $collectionId") - Collection.findOneById(new ObjectId(collectionId.stringify)) match{ + Collection.findOneById(new ObjectId(collectionId.stringify)) match{ case Some(collection) => { datasets.get(datasetId) match { case Some(dataset) => { @@ -784,10 +784,10 @@ class MongoDBCollectionService @Inject() ( index(collection.id) if(!collection.thumbnail_id.isEmpty && !dataset.thumbnail_id.isEmpty){ - if(collection.thumbnail_id.get == dataset.thumbnail_id.get){ - createThumbnail(collection.id) - } - } + if(collection.thumbnail_id.get == dataset.thumbnail_id.get){ + createThumbnail(collection.id) + } + } Logger.debug("Removing dataset from collection completed") } @@ -811,7 +811,7 @@ class MongoDBCollectionService @Inject() ( } def delete(collectionId: UUID) = Try { - Collection.findOneById(new ObjectId(collectionId.stringify)) match { + Collection.findOneById(new ObjectId(collectionId.stringify)) match { case Some(collection) => { for(dataset <- datasets.listCollection(collectionId.stringify)) { //remove collection from dataset @@ -875,7 +875,7 @@ class MongoDBCollectionService @Inject() ( def createThumbnail(collectionId:UUID){ get(collectionId) match{ - case Some(collection) => { + case Some(collection) => { val selecteddatasets = datasets.listCollection(collectionId.stringify) for(dataset <- selecteddatasets){ if(dataset.isInstanceOf[models.Dataset]){ @@ -888,7 +888,7 @@ class MongoDBCollectionService @Inject() ( } Collection.update(MongoDBObject("_id" -> new ObjectId(collectionId.stringify)), $set("thumbnail_id" -> None), false, false, WriteConcern.Safe) } - case None => + case None => } } diff --git a/app/services/mongodb/MongoDBContextLDService.scala b/app/services/mongodb/MongoDBContextLDService.scala index 975bd9db1..30b7a8d02 100644 --- a/app/services/mongodb/MongoDBContextLDService.scala +++ b/app/services/mongodb/MongoDBContextLDService.scala @@ -60,4 +60,4 @@ object ContextLDDAO extends ModelCompanion[ContextLD, ObjectId] { case None => throw new RuntimeException("No MongoSalatPlugin") case Some(x) => new SalatDAO[ContextLD, ObjectId](collection = x.collection("contextld")) {} } -} \ No newline at end of file +} diff --git a/app/services/mongodb/MongoDBCurationService.scala b/app/services/mongodb/MongoDBCurationService.scala index 62ef01428..ba3ff706e 100644 --- a/app/services/mongodb/MongoDBCurationService.scala +++ b/app/services/mongodb/MongoDBCurationService.scala @@ -345,4 +345,4 @@ object CurationFolderDAO extends ModelCompanion[CurationFolder, ObjectId] { case None => throw new RuntimeException("No MongoSalatPlugin"); case Some(x) => new SalatDAO[CurationFolder, ObjectId](collection = x.collection("curationFolders")) {} } -} \ No newline at end of file +} diff --git a/app/services/mongodb/MongoDBDatasetService.scala b/app/services/mongodb/MongoDBDatasetService.scala index 52267f4c2..b9569e9a6 100644 --- a/app/services/mongodb/MongoDBDatasetService.scala +++ b/app/services/mongodb/MongoDBDatasetService.scala @@ -1187,32 +1187,32 @@ class MongoDBDatasetService @Inject() ( val currValue = reqValue.asInstanceOf[String] if (keyTrimmed.endsWith("__not")) { if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ - var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); - if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; - } - if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; - } - objectForEach += MongoDBObject(tempActualKey -> MongoDBObject("$not" -> realValue.r)) + var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); + if(!currValue.contains(" ANYWHERE")){ + realValue = "^"+realValue+"$"; + } + if(currValue.contains(" IGNORE CASE")){ + realValue = "(?i)"+realValue; + } + objectForEach += MongoDBObject(tempActualKey -> MongoDBObject("$not" -> realValue.r)) } else{ - objectForEach += MongoDBObject(tempActualKey -> MongoDBObject("$ne" -> currValue)) + objectForEach += MongoDBObject(tempActualKey -> MongoDBObject("$ne" -> currValue)) } } else { if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ - var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); - if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; - } - if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; - } - objectForEach += MongoDBObject(tempActualKey -> realValue.r) + var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); + if(!currValue.contains(" ANYWHERE")){ + realValue = "^"+realValue+"$"; + } + if(currValue.contains(" IGNORE CASE")){ + realValue = "(?i)"+realValue; + } + objectForEach += MongoDBObject(tempActualKey -> realValue.r) } else{ - objectForEach += MongoDBObject(tempActualKey -> currValue) + objectForEach += MongoDBObject(tempActualKey -> currValue) } } } else { @@ -1455,132 +1455,132 @@ class MongoDBDatasetService @Inject() ( def dumpAllDatasetMetadata(): List[String] = { - Logger.debug("Dumping metadata of all datasets.") - - val fileSep = System.getProperty("file.separator") - val lineSep = System.getProperty("line.separator") - var dsMdDumpDir = play.api.Play.configuration.getString("datasetdump.dir").getOrElse("") - if(!dsMdDumpDir.endsWith(fileSep)) - dsMdDumpDir = dsMdDumpDir + fileSep - var dsMdDumpMoveDir = play.api.Play.configuration.getString("datasetdumpmove.dir").getOrElse("") - if(dsMdDumpMoveDir.equals("")){ - Logger.warn("Will not move dumped datasets metadata to staging directory. No staging directory set.") - } - else{ - if(!dsMdDumpMoveDir.endsWith(fileSep)) - dsMdDumpMoveDir = dsMdDumpMoveDir + fileSep - } - - var unsuccessfulDumps: ListBuffer[String] = ListBuffer.empty - - for(dataset <- Dataset.findAll){ - try{ - val dsId = dataset.id.toString - - val dsTechnicalMetadata = getTechnicalMetadataJSON(dataset.id) - val dsUserMetadata = getUserMetadataJSON(dataset.id) - val dsXMLMetadata = getXMLMetadataJSON(dataset.id) - if(dsTechnicalMetadata != "{}" || dsUserMetadata != "{}" || dsXMLMetadata != "{}"){ - - val datasetnameNoSpaces = dataset.name.replaceAll("\\s+","_") - val filePathInDirs = dsId.charAt(dsId.length()-3)+ fileSep + dsId.charAt(dsId.length()-2)+dsId.charAt(dsId.length()-1)+ fileSep + dsId + fileSep + datasetnameNoSpaces + "__metadata.txt" - val mdFile = new java.io.File(dsMdDumpDir + filePathInDirs) - mdFile.getParentFile().mkdirs() - - val fileWriter = new BufferedWriter(new FileWriter(mdFile)) - fileWriter.write(dsTechnicalMetadata + lineSep + lineSep + dsUserMetadata + lineSep + lineSep + dsXMLMetadata) - fileWriter.close() - - if(!dsMdDumpMoveDir.equals("")){ - try{ - val mdMoveFile = new java.io.File(dsMdDumpMoveDir + filePathInDirs) - mdMoveFile.getParentFile().mkdirs() - - if(mdFile.renameTo(mdMoveFile)){ - Logger.debug("Dataset metadata dumped and moved to staging directory successfully.") - }else{ - Logger.warn("Could not move dumped dataset metadata to staging directory.") - throw new Exception("Could not move dumped dataset metadata to staging directory.") - } - }catch {case ex:Exception =>{ - val badDatasetId = dataset.id.toString - Logger.error("Unable to stage dumped metadata of dataset with id "+badDatasetId+": "+ex.printStackTrace()) - unsuccessfulDumps += badDatasetId - }} - } - - } - }catch {case ex:Exception =>{ - val badDatasetId = dataset.id.toString - Logger.error("Unable to dump metadata of dataset with id "+badDatasetId+": "+ex.printStackTrace()) - unsuccessfulDumps += badDatasetId - }} - } - - return unsuccessfulDumps.toList - } + Logger.debug("Dumping metadata of all datasets.") + + val fileSep = System.getProperty("file.separator") + val lineSep = System.getProperty("line.separator") + var dsMdDumpDir = play.api.Play.configuration.getString("datasetdump.dir").getOrElse("") + if(!dsMdDumpDir.endsWith(fileSep)) + dsMdDumpDir = dsMdDumpDir + fileSep + var dsMdDumpMoveDir = play.api.Play.configuration.getString("datasetdumpmove.dir").getOrElse("") + if(dsMdDumpMoveDir.equals("")){ + Logger.warn("Will not move dumped datasets metadata to staging directory. No staging directory set.") + } + else{ + if(!dsMdDumpMoveDir.endsWith(fileSep)) + dsMdDumpMoveDir = dsMdDumpMoveDir + fileSep + } + + var unsuccessfulDumps: ListBuffer[String] = ListBuffer.empty + + for(dataset <- Dataset.findAll){ + try{ + val dsId = dataset.id.toString + + val dsTechnicalMetadata = getTechnicalMetadataJSON(dataset.id) + val dsUserMetadata = getUserMetadataJSON(dataset.id) + val dsXMLMetadata = getXMLMetadataJSON(dataset.id) + if(dsTechnicalMetadata != "{}" || dsUserMetadata != "{}" || dsXMLMetadata != "{}"){ + + val datasetnameNoSpaces = dataset.name.replaceAll("\\s+","_") + val filePathInDirs = dsId.charAt(dsId.length()-3)+ fileSep + dsId.charAt(dsId.length()-2)+dsId.charAt(dsId.length()-1)+ fileSep + dsId + fileSep + datasetnameNoSpaces + "__metadata.txt" + val mdFile = new java.io.File(dsMdDumpDir + filePathInDirs) + mdFile.getParentFile().mkdirs() + + val fileWriter = new BufferedWriter(new FileWriter(mdFile)) + fileWriter.write(dsTechnicalMetadata + lineSep + lineSep + dsUserMetadata + lineSep + lineSep + dsXMLMetadata) + fileWriter.close() + + if(!dsMdDumpMoveDir.equals("")){ + try{ + val mdMoveFile = new java.io.File(dsMdDumpMoveDir + filePathInDirs) + mdMoveFile.getParentFile().mkdirs() + + if(mdFile.renameTo(mdMoveFile)){ + Logger.debug("Dataset metadata dumped and moved to staging directory successfully.") + }else{ + Logger.warn("Could not move dumped dataset metadata to staging directory.") + throw new Exception("Could not move dumped dataset metadata to staging directory.") + } + }catch {case ex:Exception =>{ + val badDatasetId = dataset.id.toString + Logger.error("Unable to stage dumped metadata of dataset with id "+badDatasetId+": "+ex.printStackTrace()) + unsuccessfulDumps += badDatasetId + }} + } + + } + }catch {case ex:Exception =>{ + val badDatasetId = dataset.id.toString + Logger.error("Unable to dump metadata of dataset with id "+badDatasetId+": "+ex.printStackTrace()) + unsuccessfulDumps += badDatasetId + }} + } + + return unsuccessfulDumps.toList + } def dumpAllDatasetGroupings(): List[String] = { - Logger.debug("Dumping dataset groupings of all datasets.") - - val fileSep = System.getProperty("file.separator") - val lineSep = System.getProperty("line.separator") - var datasetsDumpDir = play.api.Play.configuration.getString("datasetdump.dir").getOrElse("") - if(!datasetsDumpDir.endsWith(fileSep)) - datasetsDumpDir = datasetsDumpDir + fileSep - var dsDumpMoveDir = play.api.Play.configuration.getString("datasetdumpmove.dir").getOrElse("") - if(dsDumpMoveDir.equals("")){ - Logger.warn("Will not move dumped dataset groupings to staging directory. No staging directory set.") - } - else{ - if(!dsDumpMoveDir.endsWith(fileSep)) - dsDumpMoveDir = dsDumpMoveDir + fileSep - } - - var unsuccessfulDumps: ListBuffer[String] = ListBuffer.empty - - for(dataset <- Dataset.findAll){ - try{ - val dsId = dataset.id.toString - val datasetnameNoSpaces = dataset.name.replaceAll("\\s+","_") - val filePathInDirs = dsId.charAt(dsId.length()-3)+ fileSep + dsId.charAt(dsId.length()-2)+dsId.charAt(dsId.length()-1)+ fileSep + dsId + fileSep + datasetnameNoSpaces + ".txt" - - val groupingFile = new java.io.File(datasetsDumpDir + filePathInDirs) - groupingFile.getParentFile().mkdirs() - - val filePrintStream = new PrintStream(groupingFile) + Logger.debug("Dumping dataset groupings of all datasets.") + + val fileSep = System.getProperty("file.separator") + val lineSep = System.getProperty("line.separator") + var datasetsDumpDir = play.api.Play.configuration.getString("datasetdump.dir").getOrElse("") + if(!datasetsDumpDir.endsWith(fileSep)) + datasetsDumpDir = datasetsDumpDir + fileSep + var dsDumpMoveDir = play.api.Play.configuration.getString("datasetdumpmove.dir").getOrElse("") + if(dsDumpMoveDir.equals("")){ + Logger.warn("Will not move dumped dataset groupings to staging directory. No staging directory set.") + } + else{ + if(!dsDumpMoveDir.endsWith(fileSep)) + dsDumpMoveDir = dsDumpMoveDir + fileSep + } + + var unsuccessfulDumps: ListBuffer[String] = ListBuffer.empty + + for(dataset <- Dataset.findAll){ + try{ + val dsId = dataset.id.toString + val datasetnameNoSpaces = dataset.name.replaceAll("\\s+","_") + val filePathInDirs = dsId.charAt(dsId.length()-3)+ fileSep + dsId.charAt(dsId.length()-2)+dsId.charAt(dsId.length()-1)+ fileSep + dsId + fileSep + datasetnameNoSpaces + ".txt" + + val groupingFile = new java.io.File(datasetsDumpDir + filePathInDirs) + groupingFile.getParentFile().mkdirs() + + val filePrintStream = new PrintStream(groupingFile) files.get(dataset.files).found.foreach(file => { filePrintStream.println("id:"+file.id.toString+" "+"filename:"+file.filename) }) - filePrintStream.close() - - if(!dsDumpMoveDir.equals("")){ - try{ - val groupingMoveFile = new java.io.File(dsDumpMoveDir + filePathInDirs) - groupingMoveFile.getParentFile().mkdirs() - - if(groupingFile.renameTo(groupingMoveFile)){ - Logger.debug("Dataset file grouping dumped and moved to staging directory successfully.") - }else{ - Logger.warn("Could not move dumped dataset file grouping to staging directory.") - throw new Exception("Could not move dumped dataset file grouping to staging directory.") - } - }catch {case ex:Exception =>{ - val badDatasetId = dataset.id.toString - Logger.error("Unable to stage file grouping of dataset with id "+badDatasetId+": "+ex.printStackTrace()) - unsuccessfulDumps += badDatasetId - }} - } - }catch {case ex:Exception =>{ - val badDatasetId = dataset.id.toString - Logger.error("Unable to dump file grouping of dataset with id "+badDatasetId+": "+ex.printStackTrace()) - unsuccessfulDumps += badDatasetId - }} - } - - return unsuccessfulDumps.toList - } + filePrintStream.close() + + if(!dsDumpMoveDir.equals("")){ + try{ + val groupingMoveFile = new java.io.File(dsDumpMoveDir + filePathInDirs) + groupingMoveFile.getParentFile().mkdirs() + + if(groupingFile.renameTo(groupingMoveFile)){ + Logger.debug("Dataset file grouping dumped and moved to staging directory successfully.") + }else{ + Logger.warn("Could not move dumped dataset file grouping to staging directory.") + throw new Exception("Could not move dumped dataset file grouping to staging directory.") + } + }catch {case ex:Exception =>{ + val badDatasetId = dataset.id.toString + Logger.error("Unable to stage file grouping of dataset with id "+badDatasetId+": "+ex.printStackTrace()) + unsuccessfulDumps += badDatasetId + }} + } + }catch {case ex:Exception =>{ + val badDatasetId = dataset.id.toString + Logger.error("Unable to dump file grouping of dataset with id "+badDatasetId+": "+ex.printStackTrace()) + unsuccessfulDumps += badDatasetId + }} + } + + return unsuccessfulDumps.toList + } def addFollower(id: UUID, userId: UUID) { Dataset.dao.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), diff --git a/app/services/mongodb/MongoDBExtractionService.scala b/app/services/mongodb/MongoDBExtractionService.scala index b8b9506ef..d26a76948 100644 --- a/app/services/mongodb/MongoDBExtractionService.scala +++ b/app/services/mongodb/MongoDBExtractionService.scala @@ -45,19 +45,19 @@ class MongoDBExtractionService extends ExtractionService { def getExtractorList(fileId:UUID):collection.mutable.Map[String,String] = { val allOfFile = Extraction.find(MongoDBObject("file_id" -> new ObjectId(fileId.stringify))).toList - var extractorsArray:collection.mutable.Map[String,String] = collection.mutable.Map() - for(currentExtraction <- allOfFile){ - extractorsArray(currentExtraction.extractor_id) = currentExtraction.status - } + var extractorsArray:collection.mutable.Map[String,String] = collection.mutable.Map() + for(currentExtraction <- allOfFile){ + extractorsArray(currentExtraction.extractor_id) = currentExtraction.status + } return extractorsArray } def getExtractionTime(fileId:UUID):List[Date] ={ val allOfFile = Extraction.find(MongoDBObject("file_id" -> new ObjectId(fileId.stringify))).toList - var extractorsTimeArray=List[Date]() - for(currentExtraction <- allOfFile){ - extractorsTimeArray = currentExtraction.start.get :: extractorsTimeArray - } + var extractorsTimeArray=List[Date]() + for(currentExtraction <- allOfFile){ + extractorsTimeArray = currentExtraction.start.get :: extractorsTimeArray + } return extractorsTimeArray } diff --git a/app/services/mongodb/MongoDBFileService.scala b/app/services/mongodb/MongoDBFileService.scala index 0788bb54c..23f0ca6c0 100644 --- a/app/services/mongodb/MongoDBFileService.scala +++ b/app/services/mongodb/MongoDBFileService.scala @@ -827,7 +827,7 @@ class MongoDBFileService @Inject() ( } } }) - } + } } } @@ -1001,32 +1001,32 @@ class MongoDBFileService @Inject() ( val currValue = reqValue.asInstanceOf[String] if(keyTrimmed.endsWith("__not")){ if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ - var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); - if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; - } - if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; - } - objectForEach += MongoDBObject(tempActualKey -> MongoDBObject("$not" -> realValue.r)) + var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); + if(!currValue.contains(" ANYWHERE")){ + realValue = "^"+realValue+"$"; + } + if(currValue.contains(" IGNORE CASE")){ + realValue = "(?i)"+realValue; + } + objectForEach += MongoDBObject(tempActualKey -> MongoDBObject("$not" -> realValue.r)) } else{ - objectForEach += MongoDBObject(tempActualKey -> MongoDBObject("$ne" -> currValue)) + objectForEach += MongoDBObject(tempActualKey -> MongoDBObject("$ne" -> currValue)) } } else{ if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ - var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); - if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; - } - if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; - } - objectForEach += MongoDBObject(tempActualKey -> realValue.r) + var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); + if(!currValue.contains(" ANYWHERE")){ + realValue = "^"+realValue+"$"; + } + if(currValue.contains(" IGNORE CASE")){ + realValue = "(?i)"+realValue; + } + objectForEach += MongoDBObject(tempActualKey -> realValue.r) } else{ - objectForEach += MongoDBObject(tempActualKey -> currValue) + objectForEach += MongoDBObject(tempActualKey -> currValue) } } }else{ @@ -1083,70 +1083,70 @@ class MongoDBFileService @Inject() ( } def dumpAllFileMetadata(): List[String] = { - Logger.debug("Dumping metadata of all files.") - - val fileSep = System.getProperty("file.separator") - val lineSep = System.getProperty("line.separator") - var fileMdDumpDir = play.api.Play.configuration.getString("filedump.dir").getOrElse("") - if(!fileMdDumpDir.endsWith(fileSep)) - fileMdDumpDir = fileMdDumpDir + fileSep - var fileMdDumpMoveDir = play.api.Play.configuration.getString("filedumpmove.dir").getOrElse("") - if(fileMdDumpMoveDir.equals("")){ - Logger.warn("Will not move dumped files metadata to staging directory. No staging directory set.") - } - else{ - if(!fileMdDumpMoveDir.endsWith(fileSep)) - fileMdDumpMoveDir = fileMdDumpMoveDir + fileSep - } - - var unsuccessfulDumps: ListBuffer[String] = ListBuffer.empty - - for(file <- FileDAO.findAll){ - try{ - val fileId = file.id.toString - - val fileTechnicalMetadata = getTechnicalMetadataJSON(file.id) - val fileUserMetadata = getUserMetadataJSON(file.id) - if(fileTechnicalMetadata != "{}" || fileUserMetadata != "{}"){ - - val filenameNoExtension = file.filename.substring(0, file.filename.lastIndexOf(".")) - val filePathInDirs = fileId.charAt(fileId.length()-3)+ fileSep + fileId.charAt(fileId.length()-2)+fileId.charAt(fileId.length()-1)+ fileSep + fileId + fileSep + filenameNoExtension + "__metadata.txt" - val mdFile = new java.io.File(fileMdDumpDir + filePathInDirs) - mdFile.getParentFile().mkdirs() - - val fileWriter = new BufferedWriter(new FileWriter(mdFile)) - fileWriter.write(fileTechnicalMetadata + lineSep + lineSep + fileUserMetadata) - fileWriter.close() - - if(!fileMdDumpMoveDir.equals("")){ - try{ - val mdMoveFile = new java.io.File(fileMdDumpMoveDir + filePathInDirs) - mdMoveFile.getParentFile().mkdirs() - - if(mdFile.renameTo(mdMoveFile)){ - Logger.debug("File metadata dumped and moved to staging directory successfully.") - }else{ - Logger.warn("Could not move dumped file metadata to staging directory.") - throw new Exception("Could not move dumped file metadata to staging directory.") - } - }catch {case ex:Exception =>{ - val badFileId = file.id.toString - Logger.error("Unable to stage dumped metadata of file with id "+badFileId+": "+ex.printStackTrace()) - unsuccessfulDumps += badFileId - }} - } - } - - }catch {case ex:Exception =>{ - val badFileId = file.id.toString - Logger.error("Unable to dump metadata of file with id "+badFileId+": "+ex.printStackTrace()) - unsuccessfulDumps += badFileId - }} - } - - return unsuccessfulDumps.toList - - } + Logger.debug("Dumping metadata of all files.") + + val fileSep = System.getProperty("file.separator") + val lineSep = System.getProperty("line.separator") + var fileMdDumpDir = play.api.Play.configuration.getString("filedump.dir").getOrElse("") + if(!fileMdDumpDir.endsWith(fileSep)) + fileMdDumpDir = fileMdDumpDir + fileSep + var fileMdDumpMoveDir = play.api.Play.configuration.getString("filedumpmove.dir").getOrElse("") + if(fileMdDumpMoveDir.equals("")){ + Logger.warn("Will not move dumped files metadata to staging directory. No staging directory set.") + } + else{ + if(!fileMdDumpMoveDir.endsWith(fileSep)) + fileMdDumpMoveDir = fileMdDumpMoveDir + fileSep + } + + var unsuccessfulDumps: ListBuffer[String] = ListBuffer.empty + + for(file <- FileDAO.findAll){ + try{ + val fileId = file.id.toString + + val fileTechnicalMetadata = getTechnicalMetadataJSON(file.id) + val fileUserMetadata = getUserMetadataJSON(file.id) + if(fileTechnicalMetadata != "{}" || fileUserMetadata != "{}"){ + + val filenameNoExtension = file.filename.substring(0, file.filename.lastIndexOf(".")) + val filePathInDirs = fileId.charAt(fileId.length()-3)+ fileSep + fileId.charAt(fileId.length()-2)+fileId.charAt(fileId.length()-1)+ fileSep + fileId + fileSep + filenameNoExtension + "__metadata.txt" + val mdFile = new java.io.File(fileMdDumpDir + filePathInDirs) + mdFile.getParentFile().mkdirs() + + val fileWriter = new BufferedWriter(new FileWriter(mdFile)) + fileWriter.write(fileTechnicalMetadata + lineSep + lineSep + fileUserMetadata) + fileWriter.close() + + if(!fileMdDumpMoveDir.equals("")){ + try{ + val mdMoveFile = new java.io.File(fileMdDumpMoveDir + filePathInDirs) + mdMoveFile.getParentFile().mkdirs() + + if(mdFile.renameTo(mdMoveFile)){ + Logger.debug("File metadata dumped and moved to staging directory successfully.") + }else{ + Logger.warn("Could not move dumped file metadata to staging directory.") + throw new Exception("Could not move dumped file metadata to staging directory.") + } + }catch {case ex:Exception =>{ + val badFileId = file.id.toString + Logger.error("Unable to stage dumped metadata of file with id "+badFileId+": "+ex.printStackTrace()) + unsuccessfulDumps += badFileId + }} + } + } + + }catch {case ex:Exception =>{ + val badFileId = file.id.toString + Logger.error("Unable to dump metadata of file with id "+badFileId+": "+ex.printStackTrace()) + unsuccessfulDumps += badFileId + }} + } + + return unsuccessfulDumps.toList + + } def addFollower(id: UUID, userId: UUID) { FileDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), diff --git a/app/services/mongodb/MongoDBFolderService.scala b/app/services/mongodb/MongoDBFolderService.scala index 5f1bf53ab..6be5fbff7 100644 --- a/app/services/mongodb/MongoDBFolderService.scala +++ b/app/services/mongodb/MongoDBFolderService.scala @@ -157,4 +157,4 @@ object FolderDAO extends ModelCompanion[Folder, ObjectId] { case None =>throw new RuntimeException("No MongoSalatPlugin"); case Some(x) => new SalatDAO[Folder, ObjectId](collection = x.collection("folders")){} } -} \ No newline at end of file +} diff --git a/app/services/mongodb/MongoDBMultimediaQueryService.scala b/app/services/mongodb/MongoDBMultimediaQueryService.scala index 44a55f95d..489ca8ce1 100644 --- a/app/services/mongodb/MongoDBMultimediaQueryService.scala +++ b/app/services/mongodb/MongoDBMultimediaQueryService.scala @@ -25,8 +25,8 @@ class MongoDBMultimediaQueryService @Inject() (sections: SectionService, spaces: */ def updateThumbnail(queryId: UUID, thumbnailId: UUID) { TempFileDAO.update(MongoDBObject("_id" -> new ObjectId(queryId.stringify)), - //because of a bug in Salat have to explicitely cast to ObjectId - $set("thumbnail_id" -> new ObjectId(thumbnailId.stringify)), false, false, WriteConcern.Safe) + //because of a bug in Salat have to explicitely cast to ObjectId + $set("thumbnail_id" -> new ObjectId(thumbnailId.stringify)), false, false, WriteConcern.Safe) } diff --git a/app/services/mongodb/MongoDBPreviewService.scala b/app/services/mongodb/MongoDBPreviewService.scala index 5a8cafac5..fd782c792 100644 --- a/app/services/mongodb/MongoDBPreviewService.scala +++ b/app/services/mongodb/MongoDBPreviewService.scala @@ -277,7 +277,7 @@ class MongoDBPreviewService @Inject()(files: FileService, tiles: TileService, st $set("file_id" -> new ObjectId(file_id)), false, false, WriteConcern.Safe) } - Logger.debug("Updating previews.files " + previewId + " with " + metadata) + Logger.debug("Updating previews.files " + previewId + " with " + metadata) } case _ => Logger.error("Expected a JSObject") } diff --git a/app/services/mongodb/MongoDBSchedulerService.scala b/app/services/mongodb/MongoDBSchedulerService.scala index cb34edcaf..7aa1fbb7b 100644 --- a/app/services/mongodb/MongoDBSchedulerService.scala +++ b/app/services/mongodb/MongoDBSchedulerService.scala @@ -117,4 +117,4 @@ object Jobs extends ModelCompanion[TimerJob, ObjectId] { case None => throw new RuntimeException("No MongoSalatPlugin"); case Some(x) => new SalatDAO[TimerJob, ObjectId](collection = x.collection("jobs")) {} } -} \ No newline at end of file +} diff --git a/app/services/mongodb/MongoDBSectionIndexInfoService.scala b/app/services/mongodb/MongoDBSectionIndexInfoService.scala index 8631e473b..7a8bd74c2 100644 --- a/app/services/mongodb/MongoDBSectionIndexInfoService.scala +++ b/app/services/mongodb/MongoDBSectionIndexInfoService.scala @@ -13,14 +13,14 @@ import models.{SectionIndexInfo, UUID} */ class MongoDBSectionIndexInfoService extends SectionIndexInfoService { - /** + /** * Check if index with this id is already in mongo collection. If it is - update type. If it is not - * add a new entry with index id and index type. */ def insertType (indexId: UUID, indexType: String) { - val query = MongoDBObject("indexId" -> indexId.stringify) - //set "true" for upsert - SectionIndexInfoDAO.update(query, $set("indexType" -> indexType), true, false, WriteConcern.Safe) + val query = MongoDBObject("indexId" -> indexId.stringify) + //set "true" for upsert + SectionIndexInfoDAO.update(query, $set("indexType" -> indexType), true, false, WriteConcern.Safe) } /** @@ -35,7 +35,7 @@ class MongoDBSectionIndexInfoService extends SectionIndexInfoService { def insertName (indexId: UUID, indexName: String) { val query = MongoDBObject("indexId" -> indexId.stringify) //set boolean parameter to "true" for upsert, i.e. update/insert - SectionIndexInfoDAO.update(query, $set("indexName" -> indexName), true, false, WriteConcern.Safe) + SectionIndexInfoDAO.update(query, $set("indexName" -> indexName), true, false, WriteConcern.Safe) } /** @@ -58,7 +58,7 @@ class MongoDBSectionIndexInfoService extends SectionIndexInfoService { */ def getDistinctTypes(): List[String] = { SectionIndexInfoDAO.find(MongoDBObject()).flatMap(_.indexType).toList.distinct - } + } /** * Returns true is entry with this indexId is found. @@ -93,4 +93,4 @@ object SectionIndexInfoDAO extends ModelCompanion[SectionIndexInfo, ObjectId] { case None => throw new RuntimeException("No MongoSalatPlugin"); case Some(x) => new SalatDAO[SectionIndexInfo, ObjectId](collection = x.collection("sectionIndexInfo")) {} } -} \ No newline at end of file +} diff --git a/app/services/mongodb/MongoDBSectionService.scala b/app/services/mongodb/MongoDBSectionService.scala index 19edda073..b7f9e01d3 100644 --- a/app/services/mongodb/MongoDBSectionService.scala +++ b/app/services/mongodb/MongoDBSectionService.scala @@ -116,7 +116,7 @@ class MongoDBSectionService @Inject() (comments: CommentService, previews: Previ } def setDescription(id: UUID, descr: String) { - SectionDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), $set("description" -> Some(descr)), false, false, WriteConcern.Safe) + SectionDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), $set("description" -> Some(descr)), false, false, WriteConcern.Safe) } /** diff --git a/app/services/mongodb/MongoDBSpaceService.scala b/app/services/mongodb/MongoDBSpaceService.scala index 0a207e849..f05d0b89c 100644 --- a/app/services/mongodb/MongoDBSpaceService.scala +++ b/app/services/mongodb/MongoDBSpaceService.scala @@ -422,7 +422,7 @@ class MongoDBSpaceService @Inject() ( case None => { //Should this do something else other than log an error? log.error("Problem retrieving the space by ID in isTimeToLiveENabled") - return false + return false } } } @@ -441,7 +441,7 @@ class MongoDBSpaceService @Inject() ( case None => { //Should this do something else other than log and return -1? log.error("Problem retrieving the space by ID in getTimeToLive") - return -1 + return -1 } } } @@ -461,12 +461,12 @@ class MongoDBSpaceService @Inject() ( val currentTime = System.currentTimeMillis() for (aDataset <- datasetsList) { - val datasetTime = aDataset.lastModifiedDate.getTime() - val difference = currentTime - datasetTime - if (difference > timeToLive) { - //It was last modified longer than the time to live, so remove it. - datasets.removeDataset(aDataset.id, host, apiKey, user) - } + val datasetTime = aDataset.lastModifiedDate.getTime() + val difference = currentTime - datasetTime + if (difference > timeToLive) { + //It was last modified longer than the time to live, so remove it. + datasets.removeDataset(aDataset.id, host, apiKey, user) + } } for (aCollection <- collectionsList) { @@ -676,9 +676,9 @@ class MongoDBSpaceService @Inject() ( * Otherwise, creates a new entry with spaceId and extractor. */ def addExtractor (spaceId: UUID, extractor: String) { - //will add extractor to the list of extractors for this space, only if it's not there. - val query = MongoDBObject("spaceId" -> spaceId.stringify) - ExtractorsForSpaceDAO.update(query, $addToSet("extractors" -> extractor), true, false, WriteConcern.Safe) + //will add extractor to the list of extractors for this space, only if it's not there. + val query = MongoDBObject("spaceId" -> spaceId.stringify) + ExtractorsForSpaceDAO.update(query, $addToSet("extractors" -> extractor), true, false, WriteConcern.Safe) } /** diff --git a/app/services/mongodb/MongoDBStandardVocabularyService.scala b/app/services/mongodb/MongoDBStandardVocabularyService.scala index 77eafa476..e1181928e 100644 --- a/app/services/mongodb/MongoDBStandardVocabularyService.scala +++ b/app/services/mongodb/MongoDBStandardVocabularyService.scala @@ -51,4 +51,4 @@ object StandardVocabulary extends ModelCompanion[StandardVocab, ObjectId] { case None => throw new RuntimeException("No MongoSalatPlugin"); case Some(x) => new SalatDAO[StandardVocab, ObjectId](collection = x.collection("metadata.vocabularies")) {} } -} \ No newline at end of file +} diff --git a/app/services/mongodb/MongoDBUserService.scala b/app/services/mongodb/MongoDBUserService.scala index cf990b379..fe8ad4e1b 100644 --- a/app/services/mongodb/MongoDBUserService.scala +++ b/app/services/mongodb/MongoDBUserService.scala @@ -295,7 +295,7 @@ class MongoDBUserService @Inject() ( def removeUserFromSpace(userId: UUID, spaceId: UUID): Unit = { Logger.debug("remove user from space") UserDAO.dao.update(MongoDBObject("_id" -> new ObjectId(userId.stringify)), - $pull("spaceandrole" -> MongoDBObject( "spaceId" -> new ObjectId(spaceId.stringify))), false, false, WriteConcern.Safe) + $pull("spaceandrole" -> MongoDBObject( "spaceId" -> new ObjectId(spaceId.stringify))), false, false, WriteConcern.Safe) } /** diff --git a/app/util/DistancePriorityQueue.scala b/app/util/DistancePriorityQueue.scala index c8ba30cca..042cbdd1d 100644 --- a/app/util/DistancePriorityQueue.scala +++ b/app/util/DistancePriorityQueue.scala @@ -14,16 +14,16 @@ import play.api.libs.json._ case class SearchResult(section_id: String, distance: Double, preview_id: Option[String] = None) object SearchResult { - implicit val SearchResultFormat = Json.format[SearchResult] + implicit val SearchResultFormat = Json.format[SearchResult] } class DistancePriorityQueue(maxSize: Int) extends PriorityQueue[SearchResult](maxSize: Int) { - - override def lessThan(a: SearchResult, b: SearchResult): Boolean = { - if (a.distance > b.distance) { - return true; - } else { - return false; - } - } -} \ No newline at end of file + + override def lessThan(a: SearchResult, b: SearchResult): Boolean = { + if (a.distance > b.distance) { + return true; + } else { + return false; + } + } +} diff --git a/app/util/FileUtils.scala b/app/util/FileUtils.scala index d16e5454a..6c07f358f 100644 --- a/app/util/FileUtils.scala +++ b/app/util/FileUtils.scala @@ -401,7 +401,7 @@ object FileUtils { // craete the file object val path = url.getPath - val filename = path.slice(path.lastIndexOfSlice("/")+1, path.length) + val filename = path.slice(path.lastIndexOfSlice("/") + 1, path.length) val file = File(UUID.generate(), path, filename, filename, user, new Date(), FileUtils.getContentType(filename, None), -1, "", isIntermediate=intermediateUpload, showPreviews=showPreviews, @@ -459,7 +459,7 @@ object FileUtils { Logger.debug(path + " is whitelisted for upload") // craete the file object - val filename = path.slice(path.lastIndexOfSlice("/")+1, path.length) + val filename = path.slice(path.lastIndexOfSlice("/") + 1, path.length) val length = new java.io.File(path).length() val loader = classOf[services.filesystem.DiskByteStorageService].getName val file = File(UUID.generate(), path, filename, filename, user, new Date(), @@ -497,7 +497,7 @@ object FileUtils { Some(file) } else { - Logger.debug(path +" is not a whitelisted upload location") + Logger.debug(path + " is not a whitelisted upload location") None } } diff --git a/app/util/Publications.scala b/app/util/Publications.scala index 38b43a7a1..92ec0ca14 100644 --- a/app/util/Publications.scala +++ b/app/util/Publications.scala @@ -63,4 +63,4 @@ object Publications { } -} \ No newline at end of file +} diff --git a/app/util/RequiredFieldsConfig.scala b/app/util/RequiredFieldsConfig.scala index bdc6947fd..7bedb3270 100644 --- a/app/util/RequiredFieldsConfig.scala +++ b/app/util/RequiredFieldsConfig.scala @@ -28,4 +28,4 @@ object RequiredFieldsConfig { } -} \ No newline at end of file +} diff --git a/app/util/SearchUtils.scala b/app/util/SearchUtils.scala index 9d8d03d53..c47927545 100644 --- a/app/util/SearchUtils.scala +++ b/app/util/SearchUtils.scala @@ -250,7 +250,7 @@ object SearchUtils { Some(new ElasticsearchObject( ResourceRef(ResourceRef.section, id), - "section-"+id.toString, + "section-" + id.toString, "", new Date, "", diff --git a/app/util/SpaceConfig.scala b/app/util/SpaceConfig.scala index 7bd73b9f5..735071b47 100644 --- a/app/util/SpaceConfig.scala +++ b/app/util/SpaceConfig.scala @@ -27,4 +27,4 @@ object SpaceConfig { val timeString = configuration.getInt("clowder.space.timeToLive").getOrElse(720) (timeString * 60 * 60 * 1000L) } -} \ No newline at end of file +} From e99d472a52718842942d6b5c4bd24916bd8315bf Mon Sep 17 00:00:00 2001 From: Tim Yardley Date: Wed, 18 Dec 2019 19:47:37 -0600 Subject: [PATCH 3/9] whitespace cleanup --- app/api/ApiHelp.scala | 3 +- app/api/CurationObjects.scala | 2 +- app/api/Datasets.scala | 14 +-- app/api/Extractions.scala | 8 +- app/api/Geometry.scala | 2 +- app/api/Indexes.scala | 2 +- app/api/Search.scala | 4 +- app/api/Sections.scala | 6 +- app/api/Selected.scala | 2 +- app/api/Sensors.scala | 8 +- app/api/ThreeDTexture.scala | 5 +- app/controllers/Application.scala | 2 +- app/controllers/CurationObjects.scala | 2 +- app/controllers/Datasets.scala | 8 +- app/controllers/Error.scala | 34 +++---- app/controllers/ExtractionInfo.scala | 8 +- app/controllers/Spaces.scala | 2 +- app/controllers/Users.scala | 4 +- app/controllers/Utils.scala | 6 +- app/models/ContextLD.scala | 8 +- app/models/Event.scala | 4 +- app/models/ExtractionInfoSetUp.scala | 18 ++-- app/models/ExtractionRequests.scala | 4 +- app/models/FileOP.scala | 17 ++-- app/models/JobsScheduler.scala | 4 +- app/models/LicenseData.scala | 12 +-- app/models/Metadata.scala | 12 +-- app/models/PreviewFilesSearchResult.scala | 9 +- app/models/SectionIndexInfo.scala | 2 +- app/models/Selected.scala | 3 +- app/models/Space.scala | 2 +- app/models/User.scala | 5 +- app/models/UserSpaceAndRole.scala | 2 +- app/models/VersusExtraction.scala | 6 -- app/models/VersusIndex.scala | 23 +++-- app/models/VersusIndexTypeName.scala | 18 ++-- app/models/WebPageResource.scala | 2 +- app/services/AdminsNotifierPlugin.scala | 6 +- app/services/CollectionService.scala | 4 +- app/services/CommentService.scala | 10 +- app/services/DatasetService.scala | 8 +- app/services/DatasetsAutodumpService.scala | 14 +-- .../DatasetsMetadataAutodumpService.scala | 12 +-- app/services/EventService.scala | 4 +- app/services/ExtractionRequestsService.scala | 8 +- app/services/ExtractionService.scala | 8 +- app/services/ExtractorService.scala | 16 +-- app/services/FileDumpService.scala | 10 +- .../FileMetadataAutodumpService.scala | 16 +-- app/services/FileService.scala | 22 ++--- app/services/MailerPlugin.scala | 34 +++---- app/services/MetadataService.scala | 8 +- app/services/MultimediaQueryService.scala | 16 +-- app/services/PolyglotPlugin.scala | 28 +++--- app/services/PostgresPlugin.scala | 14 +-- app/services/PreviewService.scala | 4 +- app/services/RDFExportService.scala | 98 +++++++++---------- app/services/RDFUpdateService.scala | 82 ++++++++-------- app/services/RdfSPARQLService.scala | 14 +-- app/services/SchedulerService.scala | 4 +- app/services/SectionIndexInfoService.scala | 20 ++-- app/services/SectionService.scala | 2 +- .../SecureSocialTemplatesPlugin.scala | 6 +- app/services/SpaceService.scala | 2 +- app/services/TempFileService.scala | 2 +- app/services/UserService.scala | 34 +++---- app/services/VersusPlugin.scala | 70 ++++++------- app/services/irods/IRODSPlugin.scala | 28 +++--- .../mongodb/MongoDBAuthenticatorStore.scala | 6 +- .../mongodb/MongoDBCollectionService.scala | 2 +- .../mongodb/MongoDBCommentService.scala | 16 +-- .../mongodb/MongoDBContextLDService.scala | 2 +- .../mongodb/MongoDBCurationService.scala | 2 +- .../mongodb/MongoDBEventService.scala | 4 +- .../MongoDBExtractionRequestsService.scala | 16 +-- .../mongodb/MongoDBExtractionService.scala | 8 +- .../mongodb/MongoDBExtractorService.scala | 8 +- app/services/mongodb/MongoDBFileService.scala | 36 +++---- .../mongodb/MongoDBPreviewService.scala | 14 +-- .../mongodb/MongoDBSchedulerService.scala | 4 +- .../MongoDBSectionIndexInfoService.scala | 42 ++++---- .../mongodb/MongoDBSectionService.scala | 6 +- .../mongodb/MongoDBTempFileService.scala | 6 +- app/services/mongodb/MongoSalatPlugin.scala | 10 +- app/services/mongodb/MongoUserService.scala | 6 +- app/util/DistancePriorityQueue.scala | 2 +- app/util/Publications.scala | 6 +- app/util/RequiredFieldsConfig.scala | 13 +-- app/util/SpaceConfig.scala | 10 +- 89 files changed, 536 insertions(+), 560 deletions(-) diff --git a/app/api/ApiHelp.scala b/app/api/ApiHelp.scala index 0bb8f292a..1ac4c615a 100644 --- a/app/api/ApiHelp.scala +++ b/app/api/ApiHelp.scala @@ -11,7 +11,7 @@ import play.api.Logger */ object ApiHelp extends Controller { - def options(path:String) = Action { + def options(path:String) = Action { Logger.debug("ApiHelp: preflight request") Ok("") } @@ -41,5 +41,4 @@ object ApiHelp extends Controller { } """)) } - } diff --git a/app/api/CurationObjects.scala b/app/api/CurationObjects.scala index 1b1032fba..5a35d766d 100644 --- a/app/api/CurationObjects.scala +++ b/app/api/CurationObjects.scala @@ -48,7 +48,7 @@ class CurationObjects @Inject()(datasets: DatasetService, case Some(f) => f.length case None => 0 } - + var tempMap = Map( "Identifier" -> Json.toJson("urn:uuid:"+file.id), "@id" -> Json.toJson("urn:uuid:"+file.id), diff --git a/app/api/Datasets.scala b/app/api/Datasets.scala index ec29d2813..dee4c39e3 100644 --- a/app/api/Datasets.scala +++ b/app/api/Datasets.scala @@ -1110,8 +1110,8 @@ class Datasets @Inject()( BadRequest(toJson(s"The given id $id is not a valid ObjectId.")) } } - //End, Update Dataset Information code - + //End, Update Dataset Information code + def removeCreator(id: UUID, creator: String) = PermissionAction(Permission.EditDataset, Some(ResourceRef(ResourceRef.dataset, id))) { implicit request => implicit val user = request.user if (UUID.isValid(id.stringify)) { @@ -1132,12 +1132,12 @@ class Datasets @Inject()( BadRequest(toJson(s"The given id $id is not a valid ObjectId.")) } } - //End, removeCreator - + //End, removeCreator + def moveCreator(id: UUID, creator: String, newPos: Int) = PermissionAction(Permission.EditDataset, Some(ResourceRef(ResourceRef.dataset, id))) { implicit request => implicit val user = request.user if (UUID.isValid(id.stringify)) { - + Logger.debug(s"Move Creator for dataset with id $id. : $creator to $newPos") datasets.moveCreator(id, creator, newPos) datasets.get(id) match { @@ -1154,8 +1154,8 @@ class Datasets @Inject()( } } //End, move Creator - - + + //Update License code /** * REST endpoint: POST: update the license data associated with a specific Dataset diff --git a/app/api/Extractions.scala b/app/api/Extractions.scala index bb417f4c4..2d03810b4 100644 --- a/app/api/Extractions.scala +++ b/app/api/Extractions.scala @@ -155,11 +155,11 @@ class Extractions @Inject()( else { BadRequest("Not valid id") } - } //case plugin + } //case plugin case None => { BadRequest("No Service") } - } //plugin match + } //plugin match } /** @@ -174,7 +174,7 @@ class Extractions @Inject()( case Some(plugin) => { files.get(id) match { case Some(file) => { - //Get the list of extractors processing the file + //Get the list of extractors processing the file val l = extractions.getExtractorList(file.id) map { elist => (elist._1, elist._2) @@ -387,7 +387,7 @@ class Extractions @Inject()( val listNamesJson = toJson(listNames) Ok(toJson(Map("Extractors" -> listNamesJson))) } - + /** * Temporary fix for BD-289: Get Details of Extractors' Servers IP, Names and Count */ diff --git a/app/api/Geometry.scala b/app/api/Geometry.scala index ab2f7672e..8ebf5b6b0 100644 --- a/app/api/Geometry.scala +++ b/app/api/Geometry.scala @@ -12,7 +12,7 @@ class Geometry @Inject()(threeD: ThreeDService) extends Controller with ApiContr /** * Upload a 3D binary geometry file. - */ + */ def uploadGeometry() = PermissionAction(Permission.AddFile)(parse.multipartFormData) { implicit request => request.body.file("File").map { f => Logger.debug("Uploading binary geometry file " + f.filename) diff --git a/app/api/Indexes.scala b/app/api/Indexes.scala index 81567fc94..9ca97a7be 100644 --- a/app/api/Indexes.scala +++ b/app/api/Indexes.scala @@ -42,7 +42,7 @@ class Indexes @Inject() (multimediaSearch: MultimediaQueryService, previews: Pre BadRequest(toJson("Missing parameter [section_id]")) } } - + /** * Add feature to index. */ diff --git a/app/api/Search.scala b/app/api/Search.scala index 7cfc86c6b..0c865b27e 100644 --- a/app/api/Search.scala +++ b/app/api/Search.scala @@ -127,7 +127,7 @@ class Search @Inject() ( queues map { case (key, queue) => val list = new ListBuffer[SearchResult] - for (element <- queue) { + for (element <- queue) { val previewsBySection = previews.findBySectionId(element.target_section) if (previewsBySection.size == 1) { Logger.trace("Appended search result " + key + " " + element.target_section + " " + element.distance + " " + previewsBySection(0).id.toString) @@ -141,7 +141,7 @@ class Search @Inject() ( val jsonResults = toJson(items.toMap) Ok(jsonResults) - + } case None => InternalServerError("feature not found") } diff --git a/app/api/Sections.scala b/app/api/Sections.scala index 077f10713..a2ffb0a37 100644 --- a/app/api/Sections.scala +++ b/app/api/Sections.scala @@ -170,7 +170,7 @@ class Sections @Inject()( case None => BadRequest } } - + def description(id: UUID) = PermissionAction(Permission.EditSection, Some(ResourceRef(ResourceRef.section, id)))(parse.json) { implicit request => request.user match { case Some(identity) => { @@ -199,7 +199,7 @@ class Sections @Inject()( case Some(section) => { thumbnails.get(thumbnail_id) match { case Some(thumbnail) => { - sections.updateThumbnail(section_id, thumbnail_id) + sections.updateThumbnail(section_id, thumbnail_id) Ok(toJson(Map("status" -> "success"))) } case None => BadRequest(toJson("Thumbnail not found")) @@ -208,5 +208,5 @@ class Sections @Inject()( case None => BadRequest(toJson("Section not found " + section_id)) } } - + } diff --git a/app/api/Selected.scala b/app/api/Selected.scala index a65ab2166..3b7951e5e 100644 --- a/app/api/Selected.scala +++ b/app/api/Selected.scala @@ -59,7 +59,7 @@ class Selected @Inject()(selections: SelectionService, } } } - + def remove() = AuthenticatedAction(parse.json) { implicit request => Logger.debug("Requesting Selected.remove" + request.body) request.body.\("dataset").asOpt[String] match { diff --git a/app/api/Sensors.scala b/app/api/Sensors.scala index f020dadee..1970b5736 100644 --- a/app/api/Sensors.scala +++ b/app/api/Sensors.scala @@ -19,7 +19,7 @@ object Sensors extends Controller with ApiController { } } } - + def get(id: String) = PermissionAction(Permission.ViewGeoStream)(parse.json) { implicit request => current.plugin[PostgresPlugin] match { case Some(plugin) => { @@ -30,7 +30,7 @@ object Sensors extends Controller with ApiController { } } } - + def list() = PermissionAction(Permission.ViewGeoStream)(parse.json) { implicit request => current.plugin[PostgresPlugin] match { case Some(plugin) => { @@ -42,7 +42,7 @@ object Sensors extends Controller with ApiController { } } } - + def search() = PermissionAction(Permission.ViewGeoStream)(parse.json) { implicit request => current.plugin[PostgresPlugin] match { case Some(plugin) => { @@ -53,7 +53,7 @@ object Sensors extends Controller with ApiController { } } } - + def delete(id: String) = PermissionAction(Permission.DeleteGeoStream)(parse.json) { implicit request => current.plugin[PostgresPlugin] match { case Some(plugin) => { diff --git a/app/api/ThreeDTexture.scala b/app/api/ThreeDTexture.scala index bc8f56db3..1874521bb 100644 --- a/app/api/ThreeDTexture.scala +++ b/app/api/ThreeDTexture.scala @@ -9,13 +9,12 @@ import play.api.mvc.Controller import services.ThreeDService class ThreeDTexture @Inject()(threeD: ThreeDService) extends Controller with ApiController { - /** * Upload a 3D texture file. - */ + */ def uploadTexture() = PermissionAction(Permission.CreatePreview)(parse.multipartFormData) { implicit request => - request.body.file("File").map { f => + request.body.file("File").map { f => Logger.debug("Uploading 3D texture file " + f.filename) // store file try { diff --git a/app/controllers/Application.scala b/app/controllers/Application.scala index 0208a8663..9be847b9d 100644 --- a/app/controllers/Application.scala +++ b/app/controllers/Application.scala @@ -528,7 +528,7 @@ class Application @Inject() (files: FileService, collections: CollectionService, controllers.routes.javascript.FileLinks.createLink, controllers.routes.javascript.Search.search ) - ).as(JSON) + ).as(JSON) } } diff --git a/app/controllers/CurationObjects.scala b/app/controllers/CurationObjects.scala index d4c628fca..4f5a5e04c 100644 --- a/app/controllers/CurationObjects.scala +++ b/app/controllers/CurationObjects.scala @@ -914,6 +914,6 @@ class CurationObjects @Inject() ( } - + } diff --git a/app/controllers/Datasets.scala b/app/controllers/Datasets.scala index d9c9fa7d0..933038032 100644 --- a/app/controllers/Datasets.scala +++ b/app/controllers/Datasets.scala @@ -399,9 +399,9 @@ class Datasets @Inject() ( /** * Sorted List of datasets within a space - * Since this only works within a space right now, it just checks to see if the user has permission to view the space - * (which takes into account the public settings) and, if so, calls the method to list all datasets in the space, regardless - * of status/public view flags, etc. To generalize for sorting of other lists, the permission checks will need to be in + * Since this only works within a space right now, it just checks to see if the user has permission to view the space + * (which takes into account the public settings) and, if so, calls the method to list all datasets in the space, regardless + * of status/public view flags, etc. To generalize for sorting of other lists, the permission checks will need to be in * the dataset query (as in the list method). */ def sortedListInSpace(space: String, offset: Int, size: Int, showPublic: Boolean) = UserAction(needActive = false) { implicit request => @@ -415,7 +415,7 @@ class Datasets @Inject() ( val spaceName = datasetSpace match { case Some(s) => Some(s.name) case None => None - } + } var title: Option[String] = Some(Messages("resource.in.title", Messages("datasets.title"), spaceTitle, routes.Spaces.getSpace(datasetSpace.get.id), datasetSpace.get.name)) diff --git a/app/controllers/Error.scala b/app/controllers/Error.scala index 04686737f..127b10b88 100644 --- a/app/controllers/Error.scala +++ b/app/controllers/Error.scala @@ -9,27 +9,27 @@ import securesocial.core.providers.utils.RoutesHelper /** * Utility controller to be called, typically as a redirect, from the client side when an AJAX error is received, * or when there are errors with authentication or permissions within the normal controller flow. - * + * */ class Error extends SecuredController { /** * Default method when the failure is due to not being logged in. - * + * * Requires no args, provides the generic message "You must be logged in to perform that action.". - * + * */ def authenticationRequired() = UserAction(needActive = false) { implicit request => Results.Redirect(RoutesHelper.login.absoluteURL(IdentityProvider.sslEnabled)).flashing("error" -> "You must be logged in to perform that action.") } - + /** - * Message specific method when the failure is due to not being logged in. Ideally, the original url + * Message specific method when the failure is due to not being logged in. Ideally, the original url * will be set as a cookie so that securesocial can redirect back to the user's original page. - * + * * Client should pass in their own message to be displayed. If the message is null or empty, it will default to * the generic message "You must be logged in to perform that action.". - * + * * @param msg A String that will be the specific error message passed to the login panel * @param url The originating window href for the failed authentication */ @@ -40,14 +40,14 @@ class Error extends SecuredController { if (msg != null && !msg.trim().equals("")) { errMsg = msg } - + Logger.trace("The specified url to redirect to is " + url) - + //If the url is present, set the session key if (url != null && !url.trim().equals("")) { origUrlPresent = true } - + if (origUrlPresent) { Results.Redirect(RoutesHelper.login.absoluteURL(IdentityProvider.sslEnabled)).flashing("error" -> errMsg).withSession("original-url" -> url) } @@ -55,13 +55,13 @@ class Error extends SecuredController { Results.Redirect(RoutesHelper.login.absoluteURL(IdentityProvider.sslEnabled)).flashing("error" -> errMsg) } } - + /** * Redirect request that comes in when a user is logged in but does not have the appropriate permissions for accessing a specific location. - * - * Client may pass in their own message to be displayed. If the message is null or empty, it will default to + * + * Client may pass in their own message to be displayed. If the message is null or empty, it will default to * the generic message "You do not have the permissions required to view that location." - * + * * @param msg A String that will be the specific error message passed to the view to display */ def incorrectPermissions(msg: String) = UserAction(needActive = false) { implicit request => @@ -69,9 +69,9 @@ class Error extends SecuredController { var errMsg = "You do not have the permissions required to view that location." if (msg != null && !msg.trim().equals("")) { errMsg = msg - } - - //Implicit user val necessary to the view in order to make sure that the system knows if there is a user logged in or + } + + //Implicit user val necessary to the view in order to make sure that the system knows if there is a user logged in or //not, for appropriate visual cues. implicit val user = request.user Results.Ok(views.html.noPermissions(errMsg)) diff --git a/app/controllers/ExtractionInfo.scala b/app/controllers/ExtractionInfo.scala index ce9fa2a66..32b559c2c 100644 --- a/app/controllers/ExtractionInfo.scala +++ b/app/controllers/ExtractionInfo.scala @@ -39,7 +39,7 @@ class ExtractionInfo @Inject() (extractors: ExtractorService, dtsrequests: Extra } /** - * Directs currently running extractors information to the webpage + * Directs currently running extractors information to the webpage */ def getExtractorNames() = AuthenticatedAction { implicit request => @@ -47,7 +47,7 @@ class ExtractionInfo @Inject() (extractors: ExtractorService, dtsrequests: Extra Ok(views.html.extractors(list_names, list_names.size)) } - + /** * Directs input type supported by currently running extractors information to the webpage */ @@ -67,7 +67,7 @@ class ExtractionInfo @Inject() (extractors: ExtractorService, dtsrequests: Extra Ok(views.html.extractorsInputTypes(list_inputtypes1,list_inputtypes1.size)) } - + /** * Directs DTS extractions requests information to the webpage */ @@ -78,7 +78,7 @@ class ExtractionInfo @Inject() (extractors: ExtractorService, dtsrequests: Extra var currentTime = Calendar.getInstance().getTime() Ok(views.html.extractionRequests(list_requests, list_requests.size, startTime, currentTime)) } - + /** * DTS Bookmarklet page */ diff --git a/app/controllers/Spaces.scala b/app/controllers/Spaces.scala index ca4cd1832..11876441a 100644 --- a/app/controllers/Spaces.scala +++ b/app/controllers/Spaces.scala @@ -194,7 +194,7 @@ class Spaces @Inject() (spaces: SpaceService, users: UserService, events: EventS if (user.isDefined) selections.get(user.get.identityId.userId).map(_.id.stringify) else List.empty[String] Logger.debug("User selection " + userSelections) - + val rs = play.api.Play.current.plugin[services.StagingAreaPlugin] match { case Some(plugin) => Publications.getPublications(s.id.toString, spaces) case None => List.empty diff --git a/app/controllers/Users.scala b/app/controllers/Users.scala index acd0a2cf1..948826be3 100644 --- a/app/controllers/Users.scala +++ b/app/controllers/Users.scala @@ -38,9 +38,9 @@ class Users @Inject() (users: UserService, appConfig: AppConfigurationService) e val onHandleStartSignUpGoTo = securesocial.controllers.Registration.onHandleStartSignUpGoTo val Success = securesocial.controllers.Registration.Success val ThankYouCheckEmail = securesocial.core.providers.utils.Mailer.SignUpEmailSubject - + val SignUpEmailSubject = "mails.sendSignUpEmail.subject" - + val Email = "email" val startForm = Form ( Email -> email.verifying(Constraint[String] { diff --git a/app/controllers/Utils.scala b/app/controllers/Utils.scala index 982836ceb..df8ae85d8 100644 --- a/app/controllers/Utils.scala +++ b/app/controllers/Utils.scala @@ -106,12 +106,12 @@ object Utils { /** * Utility method to modify the elements in a collection that are encoded when submitted and stored. These elements * are decoded when a view requests the objects, so that they can be human readable. - * + * * Currently, the following collection elements are encoded: - * + * * name * description - * + * */ def decodeCollectionElements(collection: Collection) : Collection = { val updatedName = updateEncodedTextNewlines(collection.name) diff --git a/app/models/ContextLD.scala b/app/models/ContextLD.scala index de4ceda25..042586a1b 100644 --- a/app/models/ContextLD.scala +++ b/app/models/ContextLD.scala @@ -12,9 +12,5 @@ import play.api.libs.json.JsString case class ContextLD( id: UUID = UUID.generate, contextName: JsString, //e.g. ncsa.cv.face.jsonld or some user id .jsonld - context: JsValue) - - - - - + context: JsValue +) diff --git a/app/models/Event.scala b/app/models/Event.scala index 83641c5aa..e8807023c 100644 --- a/app/models/Event.scala +++ b/app/models/Event.scala @@ -51,9 +51,9 @@ import services.DI * * addMetadata_dataset => "user added metadata to dataset: object_name" * addMetadata_file => "user added metadata to file: object_name" - * + * * update_dataset_information => "user updated dataset information for object_name" - * + * * (when working with comments object_name holds comment text, object_id has UUID of comment) * comment_file => "user commented object_name on file: source_name" * add_comment_dataset => "user commented object_name on dataset: source_name" diff --git a/app/models/ExtractionInfoSetUp.scala b/app/models/ExtractionInfoSetUp.scala index 3d20176d5..46c48a53c 100644 --- a/app/models/ExtractionInfoSetUp.scala +++ b/app/models/ExtractionInfoSetUp.scala @@ -22,10 +22,10 @@ val dtsrequests:ExtractionRequestsService=DI.injector.getInstance(classOf[Extrac /* * Updates DTS extraction request - * + * */ def updateDTSRequests(file_id:UUID,extractor_id:String)={ - + dtsrequests.updateRequest(file_id,extractor_id) } @@ -91,10 +91,10 @@ def updateDTSRequests(file_id:UUID,extractor_id:String)={ } //end of outer yield qDetails Future status }//end of updateAndGetStatus method - + /** * Obtains the queues' names attached to an exchange where source is the exchange and destination is the queue - */ + */ def getQDetailsFutures(plugin: services.RabbitmqPlugin, exchange: String) = { for { qNamesResponse <- plugin.getQueuesNamesForAnExchange(exchange) @@ -119,9 +119,9 @@ def updateDTSRequests(file_id:UUID,extractor_id:String)={ qdetailsFutureList } //end of yield qNamesResponse } - + /** - * updates : extractors details + * updates : extractors details * currently running extractors list * servers IPs where extractors are running */ @@ -170,7 +170,7 @@ def updateDTSRequests(file_id:UUID,extractor_id:String)={ else { "" } - } //end of for + } //end of for extractors.insertServerIPs(ipsList) extractors.insertExtractorDetail(exDetails) qlistResult @@ -195,9 +195,9 @@ def updateDTSRequests(file_id:UUID,extractor_id:String)={ routingKeysList } } - + /** - * Get all exchanges for a given virtual host + * Get all exchanges for a given virtual host * TODO : It will be used for multiple exchanges attached to a virtual host in Future */ def getExchangesFutureList(plugin: services.RabbitmqPlugin): Future[List[String]] = { diff --git a/app/models/ExtractionRequests.scala b/app/models/ExtractionRequests.scala index 3f729c27f..70090428f 100644 --- a/app/models/ExtractionRequests.scala +++ b/app/models/ExtractionRequests.scala @@ -17,6 +17,4 @@ case class ExtractionRequests( extractors:Option[List[String]], startTime:Option[Date], endTime:Option[Date] - ) - - +) diff --git a/app/models/FileOP.scala b/app/models/FileOP.scala index 488b935cb..20ccf70be 100644 --- a/app/models/FileOP.scala +++ b/app/models/FileOP.scala @@ -9,12 +9,12 @@ import play.api.Logger object FileOP { /** * Returns extracted lists of tags for a file - * + * */ - + val previews: PreviewService=DI.injector.getInstance(classOf[PreviewService]) val files:FileService=DI.injector.getInstance(classOf[FileService]) - + def extractTags(file: models.File) = { val tags = file.tags // Transform the tag list into a list of ["extractor_id" or "userId", "values"] items, @@ -42,11 +42,11 @@ object FileOP { val jtags = jtagsE ++ jtagsU jtags } - - + + /** * Returns Previews extracted so far for a file - * + * */ def extractPreviews(id: UUID) = { val previews1 =previews.findByFileId(id); @@ -54,7 +54,7 @@ object FileOP { // where "values" are the preview properties, such as "preview_id", "url", and "contentType". var previewRes = Map[String, MutableList[JsValue]]() previews1.filter(_.extractor_id.isDefined).foreach(p => { - + val ename = p.extractor_id.get val jitem = Json.obj("preview_id" -> p.id.stringify, "contentType" -> p.contentType, "url" -> api.routes.Previews.download(p.id).toString) @@ -67,5 +67,4 @@ object FileOP { val jpreviews = previewRes.map { case (k, v) => Json.obj("extractor_id" -> k, "values" -> Json.toJson(v)) } jpreviews } - - } +} diff --git a/app/models/JobsScheduler.scala b/app/models/JobsScheduler.scala index 8f7bd4eae..bdd0c64a9 100644 --- a/app/models/JobsScheduler.scala +++ b/app/models/JobsScheduler.scala @@ -6,8 +6,8 @@ import services.SchedulerService import services.DI /** - * Schedules Jobs - * + * Schedules Jobs + * */ /** diff --git a/app/models/LicenseData.scala b/app/models/LicenseData.scala index 6434b868c..b96de46e9 100644 --- a/app/models/LicenseData.scala +++ b/app/models/LicenseData.scala @@ -3,7 +3,7 @@ package models import api.Permission /** - * case class to handle specific license information. Currently attached to individual Datasets and Files. + * case class to handle specific license information. Currently attached to individual Datasets and Files. */ case class LicenseData ( id: UUID = UUID.generate(), @@ -19,9 +19,9 @@ case class LicenseData ( /** * Utility method to check if the license allows the file to be downloaded. Currently, if the license type is NOT * "license1", or if it is "license1" and the "allowDownload" flag is set, the file can be downloaded. - * + * * @return A boolean, true if the license type allows the file to be downloaded, false otherwise. - * + * */ def isDownloadAllowed(user: Option[User]) = { (m_licenseType != "license1") || m_allowDownload || Permission.checkPermission(user, Permission.DownloadFiles) || (user match { @@ -32,11 +32,11 @@ case class LicenseData ( /** * Utility method to check if a name matches the rights holder of the license. - * + * * @param aName A String that represents the name of a user to compare to the current rights holder. - * + * * @return A boolean, true if the parameter matches the owner, false otherwise. - * + * */ def isRightsOwner(aName: String) = { m_rightsHolder == aName diff --git a/app/models/Metadata.scala b/app/models/Metadata.scala index bc09c5423..f774d192b 100644 --- a/app/models/Metadata.scala +++ b/app/models/Metadata.scala @@ -71,9 +71,9 @@ object Agent { val userService: UserService = DI.injector.getInstance(classOf[UserService]) def reads(json: JsValue) = { - //creator(agent) may be User or Extractor depending on the json + //creator(agent) may be User or Extractor depending on the json var creator: Option[models.Agent] = None - + //parse json input for type of agent val typeOfAgent = (json \ "agent" \ "@type").as[String] @@ -128,7 +128,7 @@ object Metadata { "extractor_id" -> extractor_id_string) } } - + implicit object UserAgentWrites extends Writes[UserAgent] { def writes(user: UserAgent): JsObject = { val user_id_string = user.userId.map(_.toString).getOrElse("") @@ -138,7 +138,7 @@ object Metadata { "user_id" -> user_id_string) } } - + implicit object MetadataWrites extends Writes[Metadata] { def writes(metadata: Metadata) = Json.obj( "created_at" -> metadata.createdAt.toString, @@ -158,7 +158,7 @@ object RDFModel { def reads(json: JsValue) = { var model: Option[models.RDFModel] = None var in: java.io.InputStream = new java.io.ByteArrayInputStream( Json.stringify(json).getBytes ) - + // Parse JSON-LD var m: Model = ModelFactory.createDefaultModel() var error: String = null @@ -175,6 +175,6 @@ object RDFModel { case None => JsError(ValidationError("Parse succeeded, but JSON-LD RDF model was empty. Try setting a default @vocab in your @context node.")) } } - + } } diff --git a/app/models/PreviewFilesSearchResult.scala b/app/models/PreviewFilesSearchResult.scala index 649749810..eb1e7f646 100644 --- a/app/models/PreviewFilesSearchResult.scala +++ b/app/models/PreviewFilesSearchResult.scala @@ -2,9 +2,9 @@ * Previewers and Files Search Resutls. * Used by multimedia search to pass information * between controller and viewer. - * + * * Specifically, used by VersusPlugin, Search, ContentBasedSearchResultsVideo3 - * + * * Searching through files (born as still images) and video previews * (first shot of each frame of the video) * @@ -14,8 +14,7 @@ package models case class PreviewFilesSearchResult( - fileOrPreview:String, + fileOrPreview:String, searchResultFile: SearchResultFile, - searchResultPreview: SearchResultPreview + searchResultPreview: SearchResultPreview ) - diff --git a/app/models/SectionIndexInfo.scala b/app/models/SectionIndexInfo.scala index 2ac944673..4e7bdb54e 100644 --- a/app/models/SectionIndexInfo.scala +++ b/app/models/SectionIndexInfo.scala @@ -6,7 +6,7 @@ package models * */ case class SectionIndexInfo( - indexId:String, + indexId:String, indexName:Option[String] = None, indexType: Option[String] = None ) diff --git a/app/models/Selected.scala b/app/models/Selected.scala index 59d5560ac..e5d143125 100644 --- a/app/models/Selected.scala +++ b/app/models/Selected.scala @@ -18,5 +18,4 @@ case class Selected ( id: ObjectId = new ObjectId, user: String, datasets: List[String] = List.empty - ) - +) diff --git a/app/models/Space.scala b/app/models/Space.scala index 0e0df7079..fe71807a9 100644 --- a/app/models/Space.scala +++ b/app/models/Space.scala @@ -62,7 +62,7 @@ case class SpaceInvite( role: String, creationTime: java.util.Date, expirationTime: java.util.Date) - + // New way to manage metadata. Will eventually be merged with space metadata. case class SpaceMetadata ( created: Date, diff --git a/app/models/User.scala b/app/models/User.scala index cfeeb7885..e31c3cd73 100644 --- a/app/models/User.scala +++ b/app/models/User.scala @@ -13,7 +13,6 @@ object UserStatus extends Enumeration { type UserStatus = Value val Inactive, Active, Admin = Value } - /** * Simple class to capture basic User Information. This is similar to Identity in securesocial * @@ -127,7 +126,7 @@ case class ClowderUser( // should user be active status: UserStatus.Value = UserStatus.Inactive, - + // has the user escalated privileges, this is never saved to the database @transient superAdminMode: Boolean = false, @@ -152,7 +151,7 @@ case class ClowderUser( termsOfServices: Option[UserTermsOfServices] = None, lastLogin: Option[Date] = None - + ) extends User case class Profile( diff --git a/app/models/UserSpaceAndRole.scala b/app/models/UserSpaceAndRole.scala index abd3ba863..edc5249ca 100644 --- a/app/models/UserSpaceAndRole.scala +++ b/app/models/UserSpaceAndRole.scala @@ -1,7 +1,7 @@ package models /** - * Elements here are initialized to null since they should always be defined, and if they are not, + * Elements here are initialized to null since they should always be defined, and if they are not, * then it is an exception case. */ case class UserSpaceAndRole ( diff --git a/app/models/VersusExtraction.scala b/app/models/VersusExtraction.scala index 574c2b3b0..0bd2dadab 100644 --- a/app/models/VersusExtraction.scala +++ b/app/models/VersusExtraction.scala @@ -9,20 +9,14 @@ import play.api.libs.json.JsResult * */ object VersusExtraction { - case class VersusExtraction(val extraction_id: String, val adapter_name:String, val extractor_name:String, val descriptor:String ) - - implicit object VersusExtraction extends Reads[VersusExtraction] { def reads(json: JsValue) ={ - val ex_id:String = (json \"extractor_id").as[String] val a_name:String=(json \"adapter_name").as[String] val ex_name:String=(json \"extractor_name").as[String] val des:String=(json \"descriptor").as[String] - JsSuccess(VersusExtraction(ex_id,a_name,ex_name,des)) - } } } diff --git a/app/models/VersusIndex.scala b/app/models/VersusIndex.scala index 30982c181..2fba4f043 100644 --- a/app/models/VersusIndex.scala +++ b/app/models/VersusIndex.scala @@ -8,15 +8,14 @@ import play.api.libs.json.Reads import play.api.libs.json.JsSuccess import play.api.libs.json.JsResult -case class VersusIndex( - val id :String, - val MIMEtype :String, - val extractorID:String, - val measureID:String, +case class VersusIndex( + val id :String, + val MIMEtype :String, + val extractorID:String, + val measureID:String, val indexerType:String - ) - -object VersusIndex { +) +object VersusIndex { /** * Serializer for VersusIndex type. */ @@ -29,18 +28,18 @@ object VersusIndex { "typeOfIndexer"->index.indexerType ) } - + /** * Deserializer for VersusIndex type. */ - implicit object VersusIndexReads extends Reads[VersusIndex] { - def reads(json: JsValue) ={ + implicit object VersusIndexReads extends Reads[VersusIndex] { + def reads(json: JsValue) ={ val maybeID:String = (json \"indexID").as[String] val maybeMimeType:String=(json\"MIMEtype").as[String] val exType:String=(json\"Extractor").as[String] val meType:String=(json\"Measure").as[String] val indxrType:String=(json\"Indexer").as[String] - JsSuccess(VersusIndex(maybeID,maybeMimeType,exType,meType,indxrType)) + JsSuccess(VersusIndex(maybeID,maybeMimeType,exType,meType,indxrType)) } } } diff --git a/app/models/VersusIndexTypeName.scala b/app/models/VersusIndexTypeName.scala index 9e4de7c27..9ccff6cb5 100644 --- a/app/models/VersusIndexTypeName.scala +++ b/app/models/VersusIndexTypeName.scala @@ -9,14 +9,14 @@ import play.api.libs.json.Json //names of the variables here MUST be the same as in versus IndexResource.listJSON, where the Json is created. case class VersusIndexTypeName( - indexID: String, - MIMEtype:String, - Extractor: String, - Measure:String, - Indexer:String, - indexName: Option[String], + indexID: String, + MIMEtype:String, + Extractor: String, + Measure:String, + Indexer:String, + indexName: Option[String], indexType:Option[String] - ) +) object VersusIndexTypeName { implicit val format: Format[VersusIndexTypeName] = Json.format[VersusIndexTypeName] @@ -24,11 +24,11 @@ object VersusIndexTypeName { def addName(index: VersusIndexTypeName, indName:String): VersusIndexTypeName = { index.copy(indexName = Some(indName)) } - + def addType(index: VersusIndexTypeName, indType:String): VersusIndexTypeName = { index.copy(indexType = Some(indType)) } - + def addTypeAndName(index: VersusIndexTypeName, indType:String, indName:String): VersusIndexTypeName = { index.copy(indexType = Some(indType), indexName = Some(indName)) } diff --git a/app/models/WebPageResource.scala b/app/models/WebPageResource.scala index 0e71a1cad..2e4cf6ee4 100644 --- a/app/models/WebPageResource.scala +++ b/app/models/WebPageResource.scala @@ -4,7 +4,7 @@ package models * Web page URL and (file URLs in that specific web page, UUIDs for those file saved in database) * This is used for DTS service * - * + * */ case class WebPageResource( id: UUID, diff --git a/app/services/AdminsNotifierPlugin.scala b/app/services/AdminsNotifierPlugin.scala index edc97c415..0014b4738 100644 --- a/app/services/AdminsNotifierPlugin.scala +++ b/app/services/AdminsNotifierPlugin.scala @@ -19,7 +19,7 @@ class AdminsNotifierPlugin @Inject()(userService: UserService) (application:Appl override lazy val enabled = { !application.configuration.getString("adminnotifierservice").filter(_ == "disabled").isDefined } - + def sendAdminsNotification(baseURL: String, resourceType: String = "Dataset", eventType: String = "added", resourceId: String, resourceName: String) = { @@ -31,7 +31,7 @@ class AdminsNotifierPlugin @Inject()(userService: UserService) (application:Appl } else if(resourceType.equals("Collection")){ baseURL + controllers.routes.Collections.collection(UUID(resourceId)) } - + resourceUrl match{ case "" => { Logger.error("Unknown resource type.") @@ -50,7 +50,7 @@ class AdminsNotifierPlugin @Inject()(userService: UserService) (application:Appl case _=> { Mail.sendEmailAdmins(mailSubject, None, Html(mailHTML)) } - } + } } } } diff --git a/app/services/CollectionService.scala b/app/services/CollectionService.scala index 8eef9991e..d3b79b391 100644 --- a/app/services/CollectionService.scala +++ b/app/services/CollectionService.scala @@ -104,12 +104,12 @@ trait CollectionService { */ def listUser(date: String, nextPage: Boolean, limit: Integer, title: String, user: Option[User], showAll: Boolean, owner: User, exact: Boolean): List[Collection] - + /** * Return a list of collections the user has access to starting at a specific date with matching title. */ def listSpaceAccess(limit: Integer, space: String, permissions: Set[Permission], user: Option[User], showAll: Boolean, showPublic: Boolean): List[Collection] - + /** * List All Collections (Including childs) a user can view. */ diff --git a/app/services/CommentService.scala b/app/services/CommentService.scala index 67cbbdcb7..3cec8f806 100644 --- a/app/services/CommentService.scala +++ b/app/services/CommentService.scala @@ -22,23 +22,23 @@ trait CommentService { def findCommentsBySectionId(id: UUID): List[Comment] def removeComment(c: Comment) - + /** * Service provided to actually edit a specific comment by id. - * + * * id: The identifier of the comment to edit, as a UUID. * commentText: The data to replace the comment text with, as a String. */ def editComment(id: UUID, commentText: String) - + /** * Remove a comment by its identifier. - * + * * id: The identifier of the comment to remove, as a UUID. */ def removeComment(id: UUID) def updateAuthorFullName(userId: UUID, fullName: String) - + } diff --git a/app/services/DatasetService.scala b/app/services/DatasetService.scala index ac7498ff4..0ba31a68f 100644 --- a/app/services/DatasetService.scala +++ b/app/services/DatasetService.scala @@ -203,7 +203,7 @@ trait DatasetService { def modifyRDFOfMetadataChangedDatasets() def dumpAllDatasetGroupings(): List[String] - + def dumpAllDatasetMetadata(): List[String] def modifyRDFUserMetadata(id: UUID, mappingNumber: String="1") @@ -365,17 +365,17 @@ trait DatasetService { * Remove follower from a dataset. */ def removeFollower(id: UUID, userId: UUID) - + /** * Add a creator to the end of the dataset's list of creators */ def addCreator(id: UUID, creator: String) - + /** * Remove a creator from the dataset's list of creators */ def removeCreator(id: UUID, creator: String) - + /** * Move a creator to a new position in the dataset's list of creators */ diff --git a/app/services/DatasetsAutodumpService.scala b/app/services/DatasetsAutodumpService.scala index 7f0230243..d9f6c71a3 100644 --- a/app/services/DatasetsAutodumpService.scala +++ b/app/services/DatasetsAutodumpService.scala @@ -11,16 +11,16 @@ import play.api.libs.concurrent.Execution.Implicits._ class DatasetsAutodumpService (application: Application) extends Plugin { val datasets: DatasetService = DI.injector.getInstance(classOf[DatasetService]) - + override def onStart() { Logger.debug("Starting dataset file groupings autodumper Plugin") //Dump dataset file groupings periodically - val timeInterval = play.Play.application().configuration().getInt("datasetdump.dumpEvery") + val timeInterval = play.Play.application().configuration().getInt("datasetdump.dumpEvery") Akka.system().scheduler.schedule(0.days, timeInterval.intValue().days){ dumpDatasetGroupings } } - + override def onStop() { Logger.debug("Shutting down dataset file groupings autodumper Plugin") } @@ -28,9 +28,9 @@ class DatasetsAutodumpService (application: Application) extends Plugin { override lazy val enabled = { !application.configuration.getString("datasetsdumpservice").filter(_ == "disabled").isDefined } - + def dumpDatasetGroupings() = { - + val unsuccessfulDumps = datasets.dumpAllDatasetGroupings if(unsuccessfulDumps.size == 0) Logger.debug("Dumping of dataset file groupings was successful for all datasets.") @@ -41,6 +41,6 @@ class DatasetsAutodumpService (application: Application) extends Plugin { } unsuccessfulMessage = unsuccessfulMessage.substring(0, unsuccessfulMessage.length()-2) + "." Logger.debug(unsuccessfulMessage) - } - } + } + } } diff --git a/app/services/DatasetsMetadataAutodumpService.scala b/app/services/DatasetsMetadataAutodumpService.scala index 4521c07eb..9cb2654b4 100644 --- a/app/services/DatasetsMetadataAutodumpService.scala +++ b/app/services/DatasetsMetadataAutodumpService.scala @@ -12,16 +12,16 @@ import play.api.libs.concurrent.Execution.Implicits._ class DatasetsMetadataAutodumpService (application: Application) extends Plugin { val datasets: DatasetService = DI.injector.getInstance(classOf[DatasetService]) - + override def onStart() { Logger.debug("Starting dataset metadata autodumper Plugin") //Dump metadata of all datasets periodically - val timeInterval = play.Play.application().configuration().getInt("datasetmetadatadump.dumpEvery") + val timeInterval = play.Play.application().configuration().getInt("datasetmetadatadump.dumpEvery") Akka.system().scheduler.schedule(0.days, timeInterval.intValue().days){ dumpAllDatasetMetadata } } - + override def onStop() { Logger.debug("Shutting down dataset metadata autodumper Plugin") } @@ -29,7 +29,7 @@ class DatasetsMetadataAutodumpService (application: Application) extends Plugin override lazy val enabled = { !application.configuration.getString("datasetmetadatadumpservice").filter(_ == "disabled").isDefined } - + def dumpAllDatasetMetadata() = { val unsuccessfulDumps = datasets.dumpAllDatasetMetadata if(unsuccessfulDumps.size == 0) @@ -41,7 +41,7 @@ class DatasetsMetadataAutodumpService (application: Application) extends Plugin } unsuccessfulMessage = unsuccessfulMessage.substring(0, unsuccessfulMessage.length()-2) + "." Logger.debug(unsuccessfulMessage) - } - + } + } } diff --git a/app/services/EventService.scala b/app/services/EventService.scala index e0f4e8240..aae1f39c6 100644 --- a/app/services/EventService.scala +++ b/app/services/EventService.scala @@ -10,9 +10,9 @@ import com.novus.salat.dao.SalatMongoCursor * Service definition to interact with Events database. * */ - + trait EventService { - + /** * Lists all the events */ diff --git a/app/services/ExtractionRequestsService.scala b/app/services/ExtractionRequestsService.scala index 74587a4f3..740e2975d 100644 --- a/app/services/ExtractionRequestsService.scala +++ b/app/services/ExtractionRequestsService.scala @@ -6,10 +6,10 @@ import models._ * */ trait ExtractionRequestsService { - - def insertRequest(serverIP:String,clientIP:String,filename:String,fileid:UUID,fileType:String,filesize:Long, uploadDate:Date) - + + def insertRequest(serverIP:String,clientIP:String,filename:String,fileid:UUID,fileType:String,filesize:Long, uploadDate:Date) + def updateRequest(file_id:UUID,extractor_id:String) - + def getDTSRequests():List[ExtractionRequests] } diff --git a/app/services/ExtractionService.scala b/app/services/ExtractionService.scala index 03a2b6ec9..f10151d9e 100644 --- a/app/services/ExtractionService.scala +++ b/app/services/ExtractionService.scala @@ -19,13 +19,13 @@ trait ExtractionService { def findById(resource: ResourceRef): List[Extraction] def insert(extraction: Extraction): Option[ObjectId] - + def getExtractorList(fileId:UUID): collection.mutable.Map[String,String] - + def getExtractionTime(fileId:UUID): List[Date] - + def save(webpr: WebPageResource): UUID - + def getWebPageResource(id: UUID): Map[String,String] def groupByType(extraction_list: List[Extraction]): Map[String, ExtractionGroup] diff --git a/app/services/ExtractorService.scala b/app/services/ExtractorService.scala index 094fe9327..c511c74f1 100644 --- a/app/services/ExtractorService.scala +++ b/app/services/ExtractorService.scala @@ -8,7 +8,7 @@ import play.api.libs.json.JsValue */ trait ExtractorService { - + def getExtractorServerIPList(): List[String] def disableAllExtractors(): Boolean @@ -18,21 +18,21 @@ trait ExtractorService { def enableExtractor(extractor: String) def getExtractorNames(categories: List[String]): List[String] - + def getExtractorInputTypes(): List[String] - + def insertServerIPs(l: List[String]) - + def insertExtractorNames(names: List[String]) - + def insertInputTypes(inputTypes: List[String]) - + //---Temporary fix for BD-289 def insertExtractorDetail(extractorTuple: List[ExtractorDetail]) - + def getExtractorDetail(): Option[JsValue] //--End of Temporary fix BD-289 - + def dropAllExtractorStatusCollection() def listExtractorsInfo(categories: List[String]): List[ExtractorInfo] diff --git a/app/services/FileDumpService.scala b/app/services/FileDumpService.scala index 209f07738..fa8c881e8 100644 --- a/app/services/FileDumpService.scala +++ b/app/services/FileDumpService.scala @@ -22,14 +22,14 @@ class FileDumpService(application: Application) extends Plugin { if (!fileDumpDir.endsWith(fileSep)) fileDumpDir = fileDumpDir + fileSep this.fileDumpDir = Some(fileDumpDir) - + var fileDumpMoveDir = play.api.Play.configuration.getString("filedumpmove.dir").getOrElse("") if(!fileDumpMoveDir.equals("")){ if(!fileDumpMoveDir.endsWith(fileSep)) fileDumpMoveDir = fileDumpMoveDir + fileSep this.fileDumpMoveDir = Some(fileDumpMoveDir) } - } + } } override def onStop() { @@ -49,13 +49,13 @@ class FileDumpService(application: Application) extends Plugin { val fileDumpingDir = dumpDir + filePathInDirs val copiedFile = new File(fileDumpingDir) FileUtils.copyFile(fileDump.fileToDump, copiedFile) - + fileDumpMoveDir match { case Some(dumpMoveDir) => { val fileDumpingMoveDir = dumpMoveDir + filePathInDirs val movedFile = new File(fileDumpingMoveDir) movedFile.getParentFile().mkdirs() - + if(copiedFile.renameTo(movedFile)){ Logger.debug("File dumped and moved to staging directory successfully.") }else{ @@ -63,7 +63,7 @@ class FileDumpService(application: Application) extends Plugin { } } case None => Logger.warn("Could not move dumped file to staging directory. No staging directory set.") - } + } } case None => Logger.warn("Could not dump file. No file dumping directory set.") } diff --git a/app/services/FileMetadataAutodumpService.scala b/app/services/FileMetadataAutodumpService.scala index 8cfee1df6..d9da81c8d 100644 --- a/app/services/FileMetadataAutodumpService.scala +++ b/app/services/FileMetadataAutodumpService.scala @@ -12,16 +12,16 @@ import play.api.libs.concurrent.Execution.Implicits._ class FileMetadataAutodumpService (application: Application) extends Plugin { val files: FileService = DI.injector.getInstance(classOf[FileService]) - + override def onStart() { Logger.debug("Starting file metadata autodumper Plugin") //Dump metadata of all files periodically - val timeInterval = play.Play.application().configuration().getInt("filemetadatadump.dumpEvery") + val timeInterval = play.Play.application().configuration().getInt("filemetadatadump.dumpEvery") Akka.system().scheduler.schedule(0.days, timeInterval.intValue().days){ dumpAllFileMetadata - } } - + } + override def onStop() { Logger.debug("Shutting down file metadata autodumper Plugin") } @@ -29,7 +29,7 @@ class FileMetadataAutodumpService (application: Application) extends Plugin { override lazy val enabled = { !application.configuration.getString("filemetadatadumpservice").filter(_ == "disabled").isDefined } - + def dumpAllFileMetadata() = { val unsuccessfulDumps = files.dumpAllFileMetadata if(unsuccessfulDumps.size == 0) @@ -41,7 +41,7 @@ class FileMetadataAutodumpService (application: Application) extends Plugin { } unsuccessfulMessage = unsuccessfulMessage.substring(0, unsuccessfulMessage.length()-2) + "." Logger.debug(unsuccessfulMessage) - } - - } + } + + } } diff --git a/app/services/FileService.scala b/app/services/FileService.scala index 2bd852fa6..28e66222e 100644 --- a/app/services/FileService.scala +++ b/app/services/FileService.scala @@ -60,27 +60,27 @@ trait FileService { * List all files in the system. */ def listFiles(): List[File] - + /** * List all files in the system that are not intermediate result files generated by the extractors. */ def listFilesNotIntermediate(): List[File] - + /** * List files after a specified date. */ def listFilesAfter(date: String, limit: Int): List[File] - + /** * List files before a specified date. */ def listFilesBefore(date: String, limit: Int): List[File] - + /** * List files for a specific user after a specified date. */ def listUserFilesAfter(date: String, limit: Int, email: String): List[File] - + /** * List files for a specific user before a specified date. */ @@ -124,7 +124,7 @@ trait FileService { def first(): Option[File] def indexAll() - + def index(id: UUID) /** @@ -144,9 +144,9 @@ trait FileService { // TODO return JsValue def getXMLMetadataJSON(id: UUID): String - + def modifyRDFOfMetadataChangedFiles() - + def modifyRDFUserMetadata(id: UUID, mappingNumber: String="1") def dumpAllFileMetadata(): List[String] @@ -177,7 +177,7 @@ trait FileService { def addUserMetadata(id: UUID, json: String) - def addXMLMetadata(id: UUID, json: String) + def addXMLMetadata(id: UUID, json: String) def findByTag(tag: String, user: Option[User]): List[File] @@ -210,10 +210,10 @@ trait FileService { def searchMetadataFormulateQuery(requestedMap: java.util.LinkedHashMap[String, Any], root: String): MongoDBObject def removeOldIntermediates(apiKey: Option[String], user: Option[User]) - + /** * Update the license data that is currently associated with the file. - * + * * id: The id of the file * licenseType: A String representing the type of license * rightsHolder: A String that is the free-text describing the owner of the license. Only required for certain license types diff --git a/app/services/MailerPlugin.scala b/app/services/MailerPlugin.scala index f520c847d..8e9b50b9a 100644 --- a/app/services/MailerPlugin.scala +++ b/app/services/MailerPlugin.scala @@ -8,33 +8,33 @@ import javax.activation._ class MailerPlugin (application: Application) extends Plugin { - val from = play.Play.application().configuration().getString("smtp.from") + val from = play.Play.application().configuration().getString("smtp.from") val host = play.Play.application().configuration().getString("smtp.host") val properties = System.getProperties() properties.setProperty("mail.smtp.host", host) - + //SSL or regular SMTP var port = play.api.Play.configuration.getInt("smtp.port").getOrElse(0) if(play.api.Play.configuration.getBoolean("smtp.ssl").getOrElse(false)){ if(port == 0) port = 465 - + properties.setProperty("mail.smtp.socketFactory.port", port.toString) - properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory") + properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory") } else{ if(port == 0) port = 25 } properties.setProperty("mail.smtp.port", port.toString) - - val user = play.api.Play.configuration.getString("smtp.user").getOrElse("") - + + val user = play.api.Play.configuration.getString("smtp.user").getOrElse("") + if(!user.equals("")){ properties.setProperty("mail.smtp.auth", "true") } - - + + override def onStart() { Logger.debug("Starting Mailer Plugin") @@ -46,13 +46,13 @@ class MailerPlugin (application: Application) extends Plugin { override lazy val enabled = { !application.configuration.getString("mailservice").filter(_ == "disabled").isDefined } - + def sendMail(subscriberMail : String, html: String, subject: String): Boolean = { - + Logger.debug("Sending mail to " + subscriberMail) - + //Authenticate if needed - var session = Session.getDefaultInstance(properties) + var session = Session.getDefaultInstance(properties) if(!user.equals("")){ session = Session.getInstance(properties, new javax.mail.Authenticator() { @@ -61,7 +61,7 @@ class MailerPlugin (application: Application) extends Plugin { } }) } - + try{ val message = new MimeMessage(session) message.setFrom(new InternetAddress(from)) @@ -70,16 +70,16 @@ class MailerPlugin (application: Application) extends Plugin { message.setSubject(subject) message.setContent(html, "text/html") Transport.send(message) - + Logger.debug("Sent message successfully.") }catch { case msgex: MessagingException =>{ Logger.error(msgex.toString()) return false - } + } } return true } - + } diff --git a/app/services/MetadataService.scala b/app/services/MetadataService.scala index fa80a0abe..0ccb50ad6 100644 --- a/app/services/MetadataService.scala +++ b/app/services/MetadataService.scala @@ -10,13 +10,13 @@ import play.api.mvc.MultipartFormData * MetadataService for add and query metadata */ trait MetadataService { - + /** Add metadata to the metadata collection and attach to a section /file/dataset/collection */ def addMetadata(metadata: Metadata) : UUID - + /** Get Metadata By Id*/ def getMetadataById(id : UUID) : Option[Metadata] - + /** Get Metadata based on Id of an element (section/file/dataset/collection) */ def getMetadataByAttachTo(resourceRef: ResourceRef): List[Metadata] @@ -35,7 +35,7 @@ trait MetadataService { /** Remove metadata by attachTo from a specific extractor */ def removeMetadataByAttachToAndExtractor(resourceRef: ResourceRef, extractorName: String, host: String, apiKey: Option[String], user: Option[User]): List[UUID] - + /** Get metadata context if available */ def getMetadataContext(metadataId: UUID): Option[JsValue] diff --git a/app/services/MultimediaQueryService.scala b/app/services/MultimediaQueryService.scala index 1428be443..e1df62c8c 100644 --- a/app/services/MultimediaQueryService.scala +++ b/app/services/MultimediaQueryService.scala @@ -13,34 +13,34 @@ import play.api.libs.json.JsObject * Generic file service to store blobs of files and metadata about them. */ abstract class MultimediaQueryService { - + /** * Update thumbnail used to represent this query. */ - def updateThumbnail(queryId: UUID, thumbnailId: UUID) - + def updateThumbnail(queryId: UUID, thumbnailId: UUID) + /** * Save a file from an input stream. */ def save(inputStream: InputStream, filename: String, contentType: Option[String]): Option[TempFile] - + /** * Get the input stream of a file given a file id. * Returns input stream, file name, content type, content length. */ def get(id: UUID): Option[(InputStream, String, String, Long)] - + /** * List all files in the system. */ def listFiles(): List[TempFile] - - + + /** * Get file metadata. */ def getFile(id: UUID): Option[TempFile] - + /** * Store file metadata. */ diff --git a/app/services/PolyglotPlugin.scala b/app/services/PolyglotPlugin.scala index 5cff7f9a7..a9612ece1 100644 --- a/app/services/PolyglotPlugin.scala +++ b/app/services/PolyglotPlugin.scala @@ -63,15 +63,15 @@ class PolyglotPlugin(application: Application) extends Plugin { if ( !polyglotUser.isDefined || !polyglotPassword.isDefined) { throw new RuntimeException("Polyglot credentials not defined.") } - + if (triesLeft == 0) Future.failed(throw new RuntimeException("Converted file not found.")) - + else WS.url(url).withAuth(polyglotUser.get, polyglotPassword.get, AuthScheme.BASIC).get flatMap { res => if (res.status == 200) { //this is the callback, runs after file exists is TRUE Logger.debug("File exists on polyglot. Will download now.") //file exists on Polyglot, begin download using iteratee - //following example in https://www.playframework.com/documentation/2.2.x/ScalaWS Processing large responses + //following example in https://www.playframework.com/documentation/2.2.x/ScalaWS Processing large responses val result = WS.url(url) .withAuth(polyglotUser.get, polyglotPassword.get, AuthScheme.BASIC) .get { xx => fromStream(outputStream) } @@ -85,7 +85,7 @@ class PolyglotPlugin(application: Application) extends Plugin { } } - /** + /** * Uploads to Polyglot the file to be converted. Returns url of the converted file. */ def getConvertedFileURL(filename: String, inputStream: java.io.InputStream, outputFormat: String): Future[String] = { @@ -96,8 +96,8 @@ class PolyglotPlugin(application: Application) extends Plugin { //post a multipart form data to Polyglot. //based on the code from https://github.com/playframework/playframework/issues/902 - //comment dated Dec 5, 2014 - // Build up the Multiparts - consists of just one file part + //comment dated Dec 5, 2014 + // Build up the Multiparts - consists of just one file part val filePart: FilePart = new FilePart(filename, new ByteArrayPartSource(filename, IOUtils.toByteArray(inputStream))) val parts = Array[Part](filePart) val reqEntity = new MultipartRequestEntity(parts, new FluentCaseInsensitiveStringsMap) @@ -106,19 +106,19 @@ class PolyglotPlugin(application: Application) extends Plugin { val bytes = baos.toByteArray val reqContentType = reqEntity.getContentType - // Now just send the data to the WS API + // Now just send the data to the WS API val response = WS.url(polyglotConvertURL.get + outputFormat) .withAuth(polyglotUser.get, polyglotPassword.get, AuthScheme.BASIC) .post(bytes)(Writeable.wBytes, ContentTypeOf(Some(reqContentType))) - //get the url for the converted file on Polyglot + //get the url for the converted file on Polyglot val fileURLFut = response.map { res => if (res.status != 200) { Logger.debug("Could not get url of converted file - status = " + res.status + " " + res.statusText) throw new RuntimeException("Could not connect to Polyglot. " + res.statusText) } - //TODO: Find an easier way to get rid of html markup + //TODO: Find an easier way to get rid of html markup //result is an html link //http://the_url_string val fileURL = res.body.substring(res.body.indexOf("http"), res.body.indexOf(">")) @@ -127,9 +127,9 @@ class PolyglotPlugin(application: Application) extends Plugin { fileURLFut.map { url => Logger.debug("Converted file url = " + url) } fileURLFut } - + /** - * Gets all output formats for the given input format. + * Gets all output formats for the given input format. * If outputs are stored in memory, returns them. Otherwise, calls another method to fetch outputs from Polyglot. */ def getOutputFormats(inputType: String): Future[Option[List[String]]] = { @@ -143,14 +143,14 @@ class PolyglotPlugin(application: Application) extends Plugin { getOutputFormatsPolyglot(inputType) } } - + /** * Goes to Polyglot and fetches all output formats for the input format given. */ - def getOutputFormatsPolyglot(inputType: String): Future[Option[List[String]]] = { + def getOutputFormatsPolyglot(inputType: String): Future[Option[List[String]]] = { //proceed only if received all the config params if (polyglotInputsURL.isDefined && polyglotUser.isDefined && polyglotPassword.isDefined) { - //call polyglot server with authentication + //call polyglot server with authentication WS.url(polyglotInputsURL.get + inputType) .withAuth(polyglotUser.get, polyglotPassword.get, AuthScheme.BASIC) .get diff --git a/app/services/PostgresPlugin.scala b/app/services/PostgresPlugin.scala index e54722600..571212f89 100644 --- a/app/services/PostgresPlugin.scala +++ b/app/services/PostgresPlugin.scala @@ -455,7 +455,7 @@ class PostgresPlugin(application: Application) extends Plugin { (name, base + "#detail/location/" + name + "/") } } - + def getSensorStreams(id: String): Option[String] = { var data = "" val query = "SELECT array_to_json(array_agg(t),true) As my_places FROM " + @@ -476,7 +476,7 @@ class PostgresPlugin(application: Application) extends Plugin { None } else Some(data) } - + def getSensorStats(id: String): Option[String] = { val query = "WITH stream_info AS (" + "SELECT sensor_id, start_time, end_time, unnest(params) AS param FROM streams WHERE sensor_id=?" + @@ -702,8 +702,8 @@ class PostgresPlugin(application: Application) extends Plugin { st.execute() st.close true - } - + } + def dropAll(): Boolean = { val deleteSensors = "DELETE from sensors" val st = conn.prepareStatement(deleteSensors) @@ -719,7 +719,7 @@ class PostgresPlugin(application: Application) extends Plugin { st3.close() true } - + def counts(): (Int, Int, Int) = { var counts = (0, 0, 0) val countQuery = "SELECT (SELECT COUNT(DISTINCT gid) FROM sensors) AS sensors,(SELECT COUNT(DISTINCT gid) FROM streams) AS streams,(SELECT COUNT(DISTINCT gid) FROM datapoints) AS datapoints" @@ -986,7 +986,7 @@ class PostgresPlugin(application: Application) extends Plugin { } } } - + def filterProperties(obj: JsObject, attributes: List[String]) = { var props = JsObject(Seq.empty) (obj \ "properties").asOpt[JsObject] match { @@ -1001,7 +1001,7 @@ class PostgresPlugin(application: Application) extends Plugin { case None => obj } } - + def getDatapoint(id: String): Option[String] = { var data = "" val query = "SELECT row_to_json(t,true) As my_datapoint FROM " + diff --git a/app/services/PreviewService.scala b/app/services/PreviewService.scala index d29cd17b2..eab35cf34 100644 --- a/app/services/PreviewService.scala +++ b/app/services/PreviewService.scala @@ -71,7 +71,7 @@ trait PreviewService { def setTitle(previewId: UUID, title: String) def getMetadata(id: UUID): scala.collection.immutable.Map[String,Any] - + def getExtractorId(id: UUID): String - + } diff --git a/app/services/RDFExportService.scala b/app/services/RDFExportService.scala index e0faa31ea..1b1e8232f 100644 --- a/app/services/RDFExportService.scala +++ b/app/services/RDFExportService.scala @@ -22,15 +22,15 @@ import models.UUID * */ class RDFExportService (application: Application) extends Plugin { - + val files: FileService = DI.injector.getInstance(classOf[FileService]) val datasets: DatasetService = DI.injector.getInstance(classOf[DatasetService]) val previews: PreviewService = DI.injector.getInstance(classOf[PreviewService]) - + val resultsDir = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "clowder__rdfdumptemporaryfiles" + System.getProperty("file.separator") val filesMappingsQuantity = Integer.parseInt(play.api.Play.configuration.getString("filesxmltordfmapping.dircount").getOrElse("1")) val datasetsMappingsQuantity = Integer.parseInt(play.api.Play.configuration.getString("datasetsxmltordfmapping.dircount").getOrElse("1")) - + val hostUrl = "http://" + play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") override def onStart() { @@ -41,7 +41,7 @@ class RDFExportService (application: Application) extends Plugin { files.removeTemporaries() } } - + override def onStop() { Logger.debug("Shutting down RDF exporter Plugin") } @@ -49,44 +49,44 @@ class RDFExportService (application: Application) extends Plugin { override lazy val enabled = { !application.configuration.getString("rdfexportservice").filter(_ == "disabled").isDefined } - + def getRDFUserMetadataFile(id: String, mappingNumber: String="1"): Option[java.io.File] = { - - val uuId = UUID(id) - files.get(uuId) match { + + val uuId = UUID(id) + files.get(uuId) match { case Some(file) => { val theJSON = files.getUserMetadataJSON(uuId) val fileSep = System.getProperty("file.separator") - - //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion + + //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion var extraChar = "" val OS = System.getProperty("os.name").toLowerCase() if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) extraChar = "\\" - + var resultDir = resultsDir + new ObjectId().toString new java.io.File(resultDir).mkdirs() - + if(!theJSON.replaceAll(" ","").equals("{}")){ val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) xmlFile.delete() } else{ new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() } val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") - Some(resultFile) + Some(resultFile) } case None => None - } + } } - + def getRDFURLsForFile(id: String): Option[JsValue] = { - val uuId = UUID(id) + val uuId = UUID(id) files.get(uuId) match { case Some(file) => { - + //RDF from XML of the file itself (for XML metadata-only files) val previewsList = previews.findByFileId(uuId) var rdfPreviewList = List.empty[models.Preview] @@ -94,58 +94,58 @@ class RDFExportService (application: Application) extends Plugin { if(currPreview.contentType.equals("application/rdf+xml")){ rdfPreviewList = rdfPreviewList :+ currPreview } - } + } var list = for (currPreview <- rdfPreviewList) yield Json.toJson(hostUrl + api.routes.Previews.download(currPreview.id)) - - //RDF from export of file community-generated metadata to RDF + + //RDF from export of file community-generated metadata to RDF for(i <- 1 to filesMappingsQuantity){ var currHostString = hostUrl + api.routes.Files.getRDFUserMetadata(uuId,i.toString) list = list :+ Json.toJson(currHostString) } - + val listJson = Json.toJson(list.toList) Some(listJson) } case None => None } } - + def getRDFUserMetadataDataset(id: String, mappingNumber: String="1"): Option[java.io.File] = { - val uuId = UUID(id) - datasets.get(uuId) match { + val uuId = UUID(id) + datasets.get(uuId) match { case Some(dataset) => { val theJSON = datasets.getUserMetadataJSON(uuId) val fileSep = System.getProperty("file.separator") - - //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion + + //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion var extraChar = "" val OS = System.getProperty("os.name").toLowerCase() if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) extraChar = "\\" - + var resultDir = resultsDir + new ObjectId().toString new java.io.File(resultDir).mkdirs() - + if(!theJSON.replaceAll(" ","").equals("{}")){ val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) xmlFile.delete() } else{ new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() } val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") - Some(resultFile) + Some(resultFile) } case None => None - } + } } - + def getRDFURLsForDataset(id: String): Option[JsValue] = { - val uuId = UUID(id) + val uuId = UUID(id) datasets.get(uuId) match { case Some(dataset) => { - + //RDF from XML files in the dataset itself (for XML metadata-only files) val previewsList = previews.findByDatasetId(uuId) var rdfPreviewList = List.empty[models.Preview] @@ -153,9 +153,9 @@ class RDFExportService (application: Application) extends Plugin { if(currPreview.contentType.equals("application/rdf+xml")){ rdfPreviewList = rdfPreviewList :+ currPreview } - } + } var list = for (currPreview <- rdfPreviewList) yield Json.toJson(hostUrl + api.routes.Previews.download(currPreview.id)) - + for(file <- dataset.files){ val filePreviewsList = previews.findByFileId(file) var fileRdfPreviewList = List.empty[models.Preview] @@ -167,25 +167,25 @@ class RDFExportService (application: Application) extends Plugin { val filesList = for (currPreview <- fileRdfPreviewList) yield Json.toJson(hostUrl + api.routes.Previews.download(currPreview.id)) list = list ++ filesList } - - //RDF from export of file community-generated metadata to RDF + + //RDF from export of file community-generated metadata to RDF for(i <- 1 to filesMappingsQuantity){ var currHostString = hostUrl + api.routes.Datasets.getRDFUserMetadata(uuId,i.toString) list = list :+ Json.toJson(currHostString) } - + val listJson = Json.toJson(list.toList) Some(listJson) } case None => None } } - + def jsonToXML(theJSON: String): java.io.File = { - - val jsonObject = new JSONObject(theJSON) + + val jsonObject = new JSONObject(theJSON) var xml = org.json.XML.toString(jsonObject) - + //Remove spaces from XML tags var currStart = xml.indexOf("<") var currEnd = -1 @@ -197,14 +197,14 @@ class RDFExportService (application: Application) extends Plugin { currStart = xml.indexOf("<", currEnd+1) } xmlNoSpaces = xmlNoSpaces + xml.substring(currEnd+1) - + val xmlFile = java.io.File.createTempFile("xml",".xml") val fileWriter = new BufferedWriter(new FileWriter(xmlFile)) fileWriter.write(xmlNoSpaces) fileWriter.close() - - return xmlFile + + return xmlFile } - - + + } diff --git a/app/services/RDFUpdateService.scala b/app/services/RDFUpdateService.scala index 16ad41e13..57cf7d55b 100644 --- a/app/services/RDFUpdateService.scala +++ b/app/services/RDFUpdateService.scala @@ -66,50 +66,50 @@ class RDFUpdateService(application: Application) extends Plugin { def modifyRDFUserMetadataFiles(id: UUID, mappingNumber: String="1") = { sparql.removeFileFromGraphs(id, "rdfCommunityGraphName") - files.get(id) match { + files.get(id) match { case Some(file) => { val theJSON = files.getUserMetadataJSON(id) val fileSep = System.getProperty("file.separator") - - //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion + + //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion var extraChar = "" val OS = System.getProperty("os.name").toLowerCase() if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) extraChar = "\\" - + val tmpDir = System.getProperty("java.io.tmpdir") var resultDir = tmpDir + fileSep + "clowder__rdfuploadtemporaryfiles" + fileSep + new ObjectId().toString val resultDirFile = new java.io.File(resultDir) resultDirFile.mkdirs() - + if(!theJSON.replaceAll(" ","").equals("{}")){ val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) xmlFile.delete() } else{ new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() } val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") - + //Connecting RDF metadata with the entity describing the original file val rootNodes = new ArrayList[String]() val rootNodesFile = play.api.Play.configuration.getString("rootNodesFile").getOrElse("") Logger.debug(rootNodesFile) if(!rootNodesFile.equals("*")){ - val rootNodesReader = new BufferedReader(new FileReader(new java.io.File(rootNodesFile))) - var line = rootNodesReader.readLine() + val rootNodesReader = new BufferedReader(new FileReader(new java.io.File(rootNodesFile))) + var line = rootNodesReader.readLine() while (line != null){ - Logger.debug((line == null).toString() ) + Logger.debug((line == null).toString() ) rootNodes.add(line.trim()) - line = rootNodesReader.readLine() + line = rootNodesReader.readLine() } rootNodesReader.close() } - + val resultFileConnected = java.io.File.createTempFile("ResultsConnected", ".rdf") - - val fileWriter = new BufferedWriter(new FileWriter(resultFileConnected)) + + val fileWriter = new BufferedWriter(new FileWriter(resultFileConnected)) val fis = new FileInputStream(resultFile) val data = new Array[Byte] (resultFile.length().asInstanceOf[Int]) fis.read(data) @@ -138,7 +138,7 @@ class RDFUpdateService(application: Application) extends Plugin { } }catch {case MustBreak => } } - + if(isInRootNodes){ val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"")+1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"")+1)) val theHost = "http://" + play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") @@ -146,17 +146,17 @@ class RDFUpdateService(application: Application) extends Plugin { connection = connection + "\">" fileWriter.write(connection) - } + } } } fileWriter.close() - - sparql.addFromFile(id, resultFileConnected, "file") + + sparql.addFromFile(id, resultFileConnected, "file") resultFileConnected.delete() - - sparql.addFileToGraph(id, "rdfCommunityGraphName") - - files.setUserMetadataWasModified(id, false) + + sparql.addFileToGraph(id, "rdfCommunityGraphName") + + files.setUserMetadataWasModified(id, false) } case None => {} } @@ -165,50 +165,50 @@ class RDFUpdateService(application: Application) extends Plugin { def modifyRDFUserMetadataDatasets(id: UUID, mappingNumber: String="1") = { sparql.removeDatasetFromUserGraphs(id) - datasets.get(id) match { + datasets.get(id) match { case Some(dataset) => { val theJSON = datasets.getUserMetadataJSON(id) val fileSep = System.getProperty("file.separator") - - //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion + + //for Unix we need an extra \ in the directory path of the LidoToCidocConvertion output file due to Windows-based behavior of LidoToCidocConvertion var extraChar = "" val OS = System.getProperty("os.name").toLowerCase() if(OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0) extraChar = "\\" - + val tmpDir = System.getProperty("java.io.tmpdir") var resultDir = tmpDir + fileSep + "clowder__rdfuploadtemporaryfiles" + fileSep + new ObjectId().toString val resultDirFile = new java.io.File(resultDir) resultDirFile.mkdirs() - + if(!theJSON.replaceAll(" ","").equals("{}")){ val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) xmlFile.delete() } else{ new java.io.File(resultDir + fileSep + extraChar + "Results.rdf").createNewFile() } val resultFile = new java.io.File(resultDir + fileSep + extraChar + "Results.rdf") - + //Connecting RDF metadata with the entity describing the original file val rootNodes = new ArrayList[String]() val rootNodesFile = play.api.Play.configuration.getString("datasetRootNodesFile").getOrElse("") Logger.debug(rootNodesFile) if(!rootNodesFile.equals("*")){ - val rootNodesReader = new BufferedReader(new FileReader(new java.io.File(rootNodesFile))) - var line = rootNodesReader.readLine() + val rootNodesReader = new BufferedReader(new FileReader(new java.io.File(rootNodesFile))) + var line = rootNodesReader.readLine() while (line != null){ - Logger.debug((line == null).toString() ) + Logger.debug((line == null).toString() ) rootNodes.add(line.trim()) - line = rootNodesReader.readLine() + line = rootNodesReader.readLine() } rootNodesReader.close() } - + val resultFileConnected = java.io.File.createTempFile("ResultsConnected", ".rdf") - - val fileWriter = new BufferedWriter(new FileWriter(resultFileConnected)) + + val fileWriter = new BufferedWriter(new FileWriter(resultFileConnected)) val fis = new FileInputStream(resultFile) val data = new Array[Byte] (resultFile.length().asInstanceOf[Int]) fis.read(data) @@ -237,7 +237,7 @@ class RDFUpdateService(application: Application) extends Plugin { } }catch {case MustBreak => } } - + if(isInRootNodes){ val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"")+1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"")+1)) val theHost = "http://" + play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") @@ -245,16 +245,16 @@ class RDFUpdateService(application: Application) extends Plugin { connection = connection + "\">" fileWriter.write(connection) - } + } } } fileWriter.close() - + sparql.addFromFile(id, resultFileConnected, "dataset") resultFileConnected.delete() - + sparql.addDatasetToGraph(id, "rdfCommunityGraphName") - + datasets.setUserMetadataWasModified(id, false) } case None => {} diff --git a/app/services/RdfSPARQLService.scala b/app/services/RdfSPARQLService.scala index dd81523a3..8700080f2 100644 --- a/app/services/RdfSPARQLService.scala +++ b/app/services/RdfSPARQLService.scala @@ -7,19 +7,19 @@ trait RdfSPARQLService { def addFileToGraph(fileId: UUID, selectedGraph: String = "rdfXMLGraphName"): Null def addDatasetToGraph(datasetId: UUID, selectedGraph:String = "rdfXMLGraphName"): Null - + def removeFileFromGraphs(fileId: UUID, selectedGraph:String = "rdfXMLGraphName"): Null def removeDatasetFromGraphs(datasetId: UUID): Null - + def linkFileToDataset(fileId: UUID, datasetId: UUID, selectedGraph:String = "rdfXMLGraphName"): Null - + def sparqlQuery(queryText: String): String - + def detachFileFromDataset(fileId: UUID, datasetId: UUID, selectedGraph:String = "rdfXMLGraphName"): Null - + def removeDatasetFromUserGraphs(fileId: UUID): Null - + def addFromFile(id: UUID, tempFile: java.io.File, fileOrDataset: String, selectedGraph:String = "rdfCommunityGraphName") : Null - + } diff --git a/app/services/SchedulerService.scala b/app/services/SchedulerService.scala index dff77f72c..342f9bc2e 100644 --- a/app/services/SchedulerService.scala +++ b/app/services/SchedulerService.scala @@ -8,9 +8,9 @@ import com.novus.salat.dao.SalatMongoCursor * Service to add a job to scheduler * */ - + trait SchedulerService { - + /** * Lists all the scheduled jobs */ diff --git a/app/services/SectionIndexInfoService.scala b/app/services/SectionIndexInfoService.scala index fe9f4a05b..a2d8ffaf6 100644 --- a/app/services/SectionIndexInfoService.scala +++ b/app/services/SectionIndexInfoService.scala @@ -5,7 +5,7 @@ import scala.util.Try /** * Census service. - * + * * Helper to store information about Census INdexes. Census index should be indexed separately and searched separately. * Census Index's id will be stored in CensusIndex db table. * @@ -17,41 +17,41 @@ trait SectionIndexInfoService { * Add a new document to the collection, with index Id and type given. */ def insertType(indexId: UUID, indexType:String) - + /** * Add a new document to the collection, with index Id and name given. */ def insertName(indexId:UUID, indexName:String) - + /** * Check if given index is in the collection */ - def isFound(indexId: UUID): Boolean - + def isFound(indexId: UUID): Boolean + /** * Return type of the sections for the id given */ def getType(indexId:UUID):Option[String] - + /** * Returns an array of all distinct values of the field indexType */ def getDistinctTypes:List[String] - + /** * Return name of the sections for the id given */ def getName(indexId:UUID):Option[String] - + /** * Delete all documents from collection */ def deleteAll() - + /** * Deletes index with the given id. Returns true is index was found and deleted. Returns false if index was not found. * In any case, after completion of the method, index will not be in the collection. */ def delete(id:UUID):Boolean - + } diff --git a/app/services/SectionService.scala b/app/services/SectionService.scala index 2b67ef272..8f580b63c 100644 --- a/app/services/SectionService.scala +++ b/app/services/SectionService.scala @@ -11,7 +11,7 @@ import models.User trait SectionService { def listSections(): List[Section] - + def get(id: UUID): Option[Section] def get(ids: List[UUID]): DBResult[Section] diff --git a/app/services/SecureSocialTemplatesPlugin.scala b/app/services/SecureSocialTemplatesPlugin.scala index 11bb0f3c7..240e703c4 100644 --- a/app/services/SecureSocialTemplatesPlugin.scala +++ b/app/services/SecureSocialTemplatesPlugin.scala @@ -77,7 +77,7 @@ class SecureSocialTemplatesPlugin(application: play.Application) extends Templat def getSignUpEmail(token: String)(implicit request: RequestHeader): (Option[Txt], Option[Html]) = { (None, Some(views.html.ss.mails.signUpEmail(token))) } - + /** * Returns the email sent when the user is already registered * @@ -137,11 +137,11 @@ class SecureSocialTemplatesPlugin(application: play.Application) extends Templat def getPasswordChangedNoticeEmail(user: Identity)(implicit request: RequestHeader): (Option[Txt], Option[Html]) = { (None, Some(views.html.ss.mails.passwordChangedNotice(user))) } - + def getNotAuthorizedPage[A](implicit request: Request[A]): Html = { securesocial.views.html.notAuthorized() } - + def getPasswordChangePage[A](implicit request: SecuredRequest[A], form: Form[ChangeInfo]):Html = { securesocial.views.html.passwordChange(form) } diff --git a/app/services/SpaceService.scala b/app/services/SpaceService.scala index c84497166..72752491d 100644 --- a/app/services/SpaceService.scala +++ b/app/services/SpaceService.scala @@ -276,7 +276,7 @@ trait SpaceService { * Otherwise will create and add a new document to the collection, with spaceId and extractor given. */ def addExtractor(spaceId: UUID, extractor:String) - + /** * Get all extractors for this space id. */ diff --git a/app/services/TempFileService.scala b/app/services/TempFileService.scala index d7c61dd11..8c58afe8a 100644 --- a/app/services/TempFileService.scala +++ b/app/services/TempFileService.scala @@ -8,7 +8,7 @@ import models.{UUID, TempFile} trait TempFileService { def get(query_id: UUID): Option[TempFile] - + /** * Update thumbnail used to represent this query file. */ diff --git a/app/services/UserService.scala b/app/services/UserService.scala index fffa4b86e..922097b37 100644 --- a/app/services/UserService.scala +++ b/app/services/UserService.scala @@ -135,51 +135,51 @@ trait UserService { * TODO: use UUID instead of email */ def createNewListInUser(email: String, field: String, fieldList: List[Any]) - + /** * Add a space to a specific user. - * + * * @param userId The identifier of the user that is being modified by this service * @param spaceId The identifier of the space that is being associated with the user - * + * */ def addUserToSpace(userId: UUID, role: Role, spaceId: UUID) - + /** * Remove a space from a specific user. - * + * * @param userId The identifier of the user that is being modified by this service * @param spaceId The space to be disassociated from the user - * + * */ def removeUserFromSpace(userId: UUID, spaceId: UUID) - + /** * Update the role that a user has for a specific space. - * + * * @param userId The identifier of the user to be modified * @param role The new role to be associated with the user - * @param spaceId The identifier of the space - * + * @param spaceId The identifier of the space + * */ def changeUserRoleInSpace(userId: UUID, role: Role, spaceId: UUID) - + /** * Retrieve the role that a user has for a specific space. - * + * * @param userId The identifier of the user to retrieve * @param spaceId The identifier of the space to get the role for - * + * * @return The role that the user has associated with the space specified - * + * */ def getUserRoleInSpace(userId: UUID, spaceId: UUID): Option[Role] - + /** * List the users that are associated with a specific space. - * + * * @param spaceId The identifier of the space to build a list of users for - * + * * @return A list of users that are associated with a space */ def listUsersInSpace(spaceId: UUID): List[User] diff --git a/app/services/VersusPlugin.scala b/app/services/VersusPlugin.scala index f83f16105..1dde33059 100644 --- a/app/services/VersusPlugin.scala +++ b/app/services/VersusPlugin.scala @@ -105,7 +105,7 @@ class VersusPlugin(application: Application) extends Plugin { /* * Gets the list of indexers available in Versus web server - * + * */ def getIndexers(): Future[Response] = { Logger.trace("VersusPlugin.getIndexers") @@ -117,9 +117,9 @@ class VersusPlugin(application: Application) extends Plugin { indexerList } - /* + /* * Get all indexes from Versus web server - * + * */ def getIndexes(): Future[Response] = { Logger.trace("VersusPlugin.getIndexes") @@ -138,9 +138,9 @@ class VersusPlugin(application: Application) extends Plugin { indexList } - /* - * Get all indexes from Versus web server as a future list - * + /* + * Get all indexes from Versus web server as a future list + * */ def getIndexesAsFutureList(): Future[List[models.VersusIndex]] = { Logger.trace("VersusPlugin: Getting indexes as a future list") @@ -228,10 +228,10 @@ class VersusPlugin(application: Application) extends Plugin { } indexesBuf.toList - } // futureResponse.map { + } // futureResponse.map { } - /* + /* * Get all indexes from Versus web server THAT MATCH THE FILE CONTENT TYPE as a future list */ def getIndexesForContentTypeAsFutureList(contentType: String): Future[List[models.VersusIndex]] = { @@ -315,7 +315,7 @@ class VersusPlugin(application: Application) extends Plugin { */ def indexPreview(previewId: UUID, fileType: String)(implicit request: Request[Any]) { //called from /app/api/Indexes.scala->index() which is called from extractors, - //(e.g. cinemetrics extractor ->uploadShot, or from face extractor, etc) + //(e.g. cinemetrics extractor ->uploadShot, or from face extractor, etc) val configuration = play.api.Play.configuration val key = "?key=" + configuration.getString("commKey").get val https = controllers.Utils.https(request) @@ -330,7 +330,7 @@ class VersusPlugin(application: Application) extends Plugin { for (indexList <- getIndexesAsFutureList()) { for (index <- indexList) { val sectionType = sectionIndexInfo.getType(UUID(index.id)) - //if section type is defined AND is a substring of extractor id - add this preview to this index + //if section type is defined AND is a substring of extractor id - add this preview to this index if (sectionType.isDefined && extractorId.contains(sectionType.get)) WS.url(host + "/indexes/" + index.id + "/add").post(Map("infile" -> Seq(prevURL))) } @@ -391,10 +391,10 @@ class VersusPlugin(application: Application) extends Plugin { /* * Removes video or image file from indexes on Versus side. - * Goes through the list of all indexes and calls Versus REST endpoint to remove the file from each index. + * Goes through the list of all indexes and calls Versus REST endpoint to remove the file from each index. * If input file is a still image - removes the file itself from the indexes. * If input file is a video - finds all its previews and removes each preview from the indexes. - * + * */ def removeFromIndexes(fileId: UUID) { // @@ -408,7 +408,7 @@ class VersusPlugin(application: Application) extends Plugin { files.get(fileId) match { case Some(file) => { // - //if file is a video, then it might have several still image previews + //if file is a video, then it might have several still image previews //(Previews are the first frame of each shot of the video file). //These previews were indexed and are now part of Versus indexes. //Have to remove these previews from the Versus indexes. @@ -424,7 +424,7 @@ class VersusPlugin(application: Application) extends Plugin { } } } - } // end of for(preview <- previews.findByFileId(file.id)){ + } // end of for(preview <- previews.findByFileId(file.id)){ } if (!file.contentType.contains("video/")) { @@ -435,7 +435,7 @@ class VersusPlugin(application: Application) extends Plugin { } } } - } //end case Some(file) + } //end case Some(file) case None => { Logger.debug(" Could not remove file - not found.") } @@ -464,7 +464,7 @@ class VersusPlugin(application: Application) extends Plugin { * Searches for entries similar to the input file, which is already in the db. */ def queryIndexForExistingFile(inputFileId: UUID, indexId: String)(implicit request: Request[Any]): Future[List[PreviewFilesSearchResult]] = { - //called when multimedia search -> find similar is clicked + //called when multimedia search -> find similar is clicked Logger.trace("VersusPlugin - queryIndexForExistingFile - file id = " + inputFileId) val configuration = play.api.Play.configuration @@ -502,14 +502,14 @@ class VersusPlugin(application: Application) extends Plugin { val isPreview = url.contains("previews") var id: String = "" if (isPreview) { - //url = http://localhost:9000/api/previews/52fd1970e4b02ac3e30280a5?key=r1ek3rs + //url = http://localhost:9000/api/previews/52fd1970e4b02ac3e30280a5?key=r1ek3rs val lastSlash = url.lastIndexOf("/") val questionMark = url.lastIndexOf("?") id = url.substring(lastSlash + 1, questionMark) } if (isFile) { - //url contains 'blob' + //url contains 'blob' //http://localhost:9000/api/files/52fd26fbe4b02ac3e30280db/blob?key=r1ek3rs val lastSlash = url.lastIndexOf("/") //Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index. @@ -519,7 +519,7 @@ class VersusPlugin(application: Application) extends Plugin { id } - + /** * Sends a search query to an index in Versus * input: @@ -547,12 +547,12 @@ class VersusPlugin(application: Application) extends Plugin { //will call IndexResource.queryindex on Versus side val responseFuture: Future[Response] = WS.url(queryIndexUrl).post(Map("infile" -> Seq(inputFileURL))) - //mapping Future[Response] to Future[List[PreviewFilesSearchResult]] - + //mapping Future[Response] to Future[List[PreviewFilesSearchResult]] + responseFuture.map{ response => val similarityResults = Json.parse(response.body).as[Seq[models.VersusSimilarityResult.VersusSimilarityResult]] - var resultList = new ListBuffer[PreviewFilesSearchResult] + var resultList = new ListBuffer[PreviewFilesSearchResult] similarityResults.map { result => //example: result.docID = http://localhost:9000/api/files/52fd26fbe4b02ac3e30280db/blob?key=r1ek3rs @@ -566,26 +566,26 @@ class VersusPlugin(application: Application) extends Plugin { val resultId = UUID(getIdFromVersusURL(result.docID)) //when searching for videos - might get previews search results, no 'blob' in preview doc id if (isPreview) { - //result.docID = http://localhost:9000/api/previews/52fd1970e4b02ac3e30280a5?key=r1ek3rs + //result.docID = http://localhost:9000/api/previews/52fd1970e4b02ac3e30280a5?key=r1ek3rs for (blob <- previews.getBlob(resultId)) { val previewName = blob._2 for (previewResult <- getPrevSearchResult(resultId, previewName, result)) { resultList += new PreviewFilesSearchResult("preview", null, previewResult) } } - } //end of if (isPreview) + } //end of if (isPreview) //in case of still images AND non-image file formats - if (isFile) { + if (isFile) { files.get(resultId) map { file => //use helper method to get the results val oneFileResult = getFileSeachResult(resultId, file, result) resultList += new PreviewFilesSearchResult("file", oneFileResult, null) } - } //end of if (isFile) - } // End of similarity map - + } //end of if (isFile) + } // End of similarity map + resultList.toList } } @@ -612,14 +612,14 @@ class VersusPlugin(application: Application) extends Plugin { //example: queryIndexUrl = http://localhost:8080/api/v1/indexes/a885bad2-f463-496f-a881-c01ebd4c31f1/query //will call IndexResource.queryindex on Versus side - //mapping Future[Response] to Future[HashMap[index URL as String, proximity]] + //mapping Future[Response] to Future[HashMap[index URL as String, proximity]] responseFuture.map { response => val similarityResults = Json.parse(response.body).as[Seq[models.VersusSimilarityResult.VersusSimilarityResult]] - //max prox is the same for every result + //max prox is the same for every result //a list of touples (id, normalized proximity) val toupleList = similarityResults.map { res => - //"if(c) p else q" equivalent to java "c ? p : q" + //"if(c) p else q" equivalent to java "c ? p : q" (res.docID, if (res.maxProximity == 0) res.proximity else (res.proximity / res.maxProximity)) }.toList val resultsHM = new scala.collection.mutable.HashMap[String, Double] @@ -629,11 +629,11 @@ class VersusPlugin(application: Application) extends Plugin { } var result = collection.immutable.HashMap(resultsHM.toSeq: _*) result - } //end of responseFuture.map { + } //end of responseFuture.map { } /* - * Helper method. Called from queryIndex + * Helper method. Called from queryIndex */ def getFileSeachResult(result_id: UUID, file: models.File, result: models.VersusSimilarityResult.VersusSimilarityResult): SearchResultFile = { @@ -669,7 +669,7 @@ class VersusPlugin(application: Application) extends Plugin { var fileIdString = "" var datasetIDs = new ListBuffer[String] - //===Get section and file info, dataset(s) info. Preview is associated with one section, section is associated with one file, file can be associated with 0 or more datasets + //===Get section and file info, dataset(s) info. Preview is associated with one section, section is associated with one file, file can be associated with 0 or more datasets preview.section_id match { case Some(section_id) => { sections.get(section_id) match { @@ -707,7 +707,7 @@ class VersusPlugin(application: Application) extends Plugin { //No preview found case None => { return None } - } //END OF : previews.get(preview_id) match + } //END OF : previews.get(preview_id) match } override def onStop() { diff --git a/app/services/irods/IRODSPlugin.scala b/app/services/irods/IRODSPlugin.scala index 697b73def..7565fae02 100644 --- a/app/services/irods/IRODSPlugin.scala +++ b/app/services/irods/IRODSPlugin.scala @@ -10,42 +10,42 @@ import org.irods.jargon.core.exception.JargonException * A concrete storage based on the iRODS file storage system. There are 7 * required parameters to establish a connection to iRODS including a * host, port, username, password, user home, zone, and default storage resource - * name. - * + * name. + * * Setup iRODS connection using Jargon. * * @date 2014-08-18 - * + * */ class IRODSPlugin(app: Application) extends Plugin { var userhome: String = _ - + var account: IRODSAccount = _ var irodsFileSystem: IRODSFileSystem = _ var irodsFileFactory: IRODSFileFactory = _ - private var _conn: Boolean = false + private var _conn: Boolean = false override def onStart() { Logger.info("Starting iRODS Plugin.") openIRODSConnection() Logger.info("irods: Connected. " + conn) } - + override def onStop() { // close connection closeIRODSConnection() Logger.info("iRODSPlugin has stopped.") } - //Is the plugin enabled? + //Is the plugin enabled? override def enabled = true - - + + def openIRODSConnection() = { lazy val configuration = Play.current.configuration // you can now access the application.conf settings - + // seven required fields (similar to .irodsEnv file used in icommands client) val host = configuration.getString("irods.host").getOrElse("") val port = configuration.getInt("irods.port").getOrElse(0) @@ -54,7 +54,7 @@ class IRODSPlugin(app: Application) extends Plugin { val zone = configuration.getString("irods.zone").getOrElse("") val defaultStorageResource = configuration.getString("irods.defaultStorageResource").getOrElse("") userhome = configuration.getString("irods.userhome").getOrElse("") - + val usercurrent = configuration.getString("irods.usercurrent").getOrElse("") try { @@ -64,7 +64,7 @@ class IRODSPlugin(app: Application) extends Plugin { // the actual connection, For a given account creates an IRODSFileFactory that can return iRODS file objects for this particular connection. irodsFileFactory = irodsFileSystem.getIRODSFileFactory(account) - + _conn = true } catch { case je: org.irods.jargon.core.exception.JargonException => Logger.error("irods: Error connecting to iRODS server. " + je.toString); _conn = false @@ -84,10 +84,10 @@ class IRODSPlugin(app: Application) extends Plugin { irodsFileSystem.closeAndEatExceptions(account) _conn = false } - + //getters def getFileFactory(): IRODSFileFactory = { return irodsFileFactory } def conn = _conn // setter - def conn_= (value:Boolean):Unit = _conn = value + def conn_= (value:Boolean):Unit = _conn = value } diff --git a/app/services/mongodb/MongoDBAuthenticatorStore.scala b/app/services/mongodb/MongoDBAuthenticatorStore.scala index d963547ee..1303841ce 100644 --- a/app/services/mongodb/MongoDBAuthenticatorStore.scala +++ b/app/services/mongodb/MongoDBAuthenticatorStore.scala @@ -61,18 +61,18 @@ object AuthenticatorDAO extends ModelCompanion[LocalAuthenticator, ObjectId] { } class MongoDBAuthenticatorStore(app: Application) extends AuthenticatorStore(app) { - + def save(authenticator: Authenticator): Either[Error, Unit] = { Logger.trace("Saving Authenticator " + authenticator) AuthenticatorDAO.save(authenticator) Right(()) } - + def find(id: String): Either[Error, Option[Authenticator]] = { Logger.trace("Searching Authenticator " + id) Right(AuthenticatorDAO.find(id)) } - + def delete(id: String): Either[Error, Unit] = { Logger.trace("Deleting id from Authenticator" + id) AuthenticatorDAO.delete(id) diff --git a/app/services/mongodb/MongoDBCollectionService.scala b/app/services/mongodb/MongoDBCollectionService.scala index 5ade48c19..4aea881b1 100644 --- a/app/services/mongodb/MongoDBCollectionService.scala +++ b/app/services/mongodb/MongoDBCollectionService.scala @@ -190,7 +190,7 @@ class MongoDBCollectionService @Inject() ( def listUser(date: String, nextPage: Boolean, limit: Integer, title: String, user: Option[User], showAll: Boolean, owner: User, exact: Boolean): List[Collection] = { list(Some(date), nextPage, limit, Some(title), None, Set[Permission](Permission.ViewCollection), user, showAll, Some(owner), exactMatch=exact) } - + def listSpaceAccess(limit: Integer, space: String, permissions: Set[Permission], user: Option[User], showAll: Boolean, showPublic: Boolean) = { list(None, false, 0, None, Option(space), permissions, user, showAll, None, showPublic) } diff --git a/app/services/mongodb/MongoDBCommentService.scala b/app/services/mongodb/MongoDBCommentService.scala index bf9d0d0c9..84d37ab3c 100644 --- a/app/services/mongodb/MongoDBCommentService.scala +++ b/app/services/mongodb/MongoDBCommentService.scala @@ -72,21 +72,21 @@ class MongoDBCommentService extends CommentService { /** * Implementation of the editComment method defined in the services/CommentService.scala trait. - * + * * This implementation edits the comment by updating the "text" field in for the identified comment. */ - def editComment(id: UUID, commentText: String) { - val result = Comment.dao.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), - $set("text" -> commentText), - false, false, WriteConcern.Safe); + def editComment(id: UUID, commentText: String) { + val result = Comment.dao.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), + $set("text" -> commentText), + false, false, WriteConcern.Safe); } - + /** * Implementation of the removeComment method defined in the services/CommentService.scala trait. - * + * * This implementation removes the file by getting it by its identifier originally. */ - def removeComment(id: UUID) { + def removeComment(id: UUID) { val theComment = get(id) removeComment(theComment.get) } diff --git a/app/services/mongodb/MongoDBContextLDService.scala b/app/services/mongodb/MongoDBContextLDService.scala index 30b7a8d02..67d1c32c9 100644 --- a/app/services/mongodb/MongoDBContextLDService.scala +++ b/app/services/mongodb/MongoDBContextLDService.scala @@ -20,7 +20,7 @@ import services.MetadataService import play.api.libs.json.JsString /** * MongoDB implementation of ContextLD service - * + * */ @Singleton diff --git a/app/services/mongodb/MongoDBCurationService.scala b/app/services/mongodb/MongoDBCurationService.scala index ba3ff706e..38b7d1b32 100644 --- a/app/services/mongodb/MongoDBCurationService.scala +++ b/app/services/mongodb/MongoDBCurationService.scala @@ -267,7 +267,7 @@ class MongoDBCurationService @Inject() (metadatas: MetadataService, spaces: Spa case Some(c) if name != c.name => { events.updateObjectName(id, name) } - case _ => + case _ => } CurationDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), $set("description" -> description, "name" -> name, "space" -> new ObjectId(newSpace.stringify), "creators" -> creators), diff --git a/app/services/mongodb/MongoDBEventService.scala b/app/services/mongodb/MongoDBEventService.scala index e4ca3576f..604974ac5 100644 --- a/app/services/mongodb/MongoDBEventService.scala +++ b/app/services/mongodb/MongoDBEventService.scala @@ -47,7 +47,7 @@ class MongoDBEventService @Inject() ( if (object_name.toString() != "undefined"){ user match { case Some(modeluser) => { - Event.insert(new Event(modeluser.getMiniUser, None, Option(object_id), Option(object_name), None, None, action_type, new Date())) + Event.insert(new Event(modeluser.getMiniUser, None, Option(object_id), Option(object_name), None, None, action_type, new Date())) } case None => Logger.error("No user provided") } @@ -57,7 +57,7 @@ class MongoDBEventService @Inject() ( def addSourceEvent(user: Option[User], object_id: UUID, object_name: String, source_id: UUID, source_name: String, action_type: String) = { user match { case Some(modeluser) => { - Event.insert(new Event(modeluser.getMiniUser, None, Option(object_id), Option(object_name), Option(source_id), Option(source_name), action_type, new Date())) + Event.insert(new Event(modeluser.getMiniUser, None, Option(object_id), Option(object_name), Option(source_id), Option(source_name), action_type, new Date())) } case None => Logger.error("No user provided") } diff --git a/app/services/mongodb/MongoDBExtractionRequestsService.scala b/app/services/mongodb/MongoDBExtractionRequestsService.scala index 693b89015..05417ae1e 100644 --- a/app/services/mongodb/MongoDBExtractionRequestsService.scala +++ b/app/services/mongodb/MongoDBExtractionRequestsService.scala @@ -25,7 +25,7 @@ import javax.inject.{Singleton, Inject} /** * MongoDB implementation for ExtractionRequestsService to keep track of extraction requests - * + * */ class MongoDBExtractionRequestsService @Inject()(extractions: ExtractionService)extends ExtractionRequestsService { @@ -48,7 +48,7 @@ class MongoDBExtractionRequestsService @Inject()(extractions: ExtractionService) } - + def updateRequest(file_id:UUID,extractor_id:String) = { val requests = getRequests(file_id) Logger.debug("-----Updating Extraction Request----------") @@ -63,24 +63,24 @@ class MongoDBExtractionRequestsService @Inject()(extractions: ExtractionService) Logger.debug("File Id for UPDATE MongoDB Extraction requests: " + fileid) var extime=extractions.getExtractionTime(file_id) - + var sortedTime = extime.sortBy(_.getTime()) var len = sortedTime.size var ex = extractions.getExtractorList(file_id) - + val elist = ex.keySet.toList Logger.debug("----extractorlist:----"+ elist); if (len != 0) { var update = $set("extractors" -> elist, "startTime" -> sortedTime(0), "endTime" -> sortedTime(len - 1)) var result = ExtractionRequests.dao.collection.update(r, update) - + } } } - + def getRequests(file_id:UUID) = { Logger.debug("GET Requests---- fileID"+ file_id.toString) //val query = MongoDBObject("endTime" -> None) @@ -88,7 +88,7 @@ class MongoDBExtractionRequestsService @Inject()(extractions: ExtractionService) val query = MongoDBObject("fileid"->new ObjectId(file_id.stringify)) var requests1=ExtractionRequests.find(query) Logger.debug("REQUEST Length: "+ requests1.length) - + var requests = ExtractionRequests.dao.collection.find(query) requests } @@ -102,4 +102,4 @@ object ExtractionRequests extends ModelCompanion[ExtractionRequests, ObjectId] { case Some(x) => new SalatDAO[ExtractionRequests, ObjectId](collection = x.collection("dtsrequests")) {} } -} +} diff --git a/app/services/mongodb/MongoDBExtractionService.scala b/app/services/mongodb/MongoDBExtractionService.scala index d26a76948..be1bd5ae3 100644 --- a/app/services/mongodb/MongoDBExtractionService.scala +++ b/app/services/mongodb/MongoDBExtractionService.scala @@ -38,11 +38,11 @@ class MongoDBExtractionService extends ExtractionService { def insert(extraction: Extraction): Option[ObjectId] = { Extraction.insert(extraction) } - + /** * Returns list of extractors and their corresponding status for a specified file */ - + def getExtractorList(fileId:UUID):collection.mutable.Map[String,String] = { val allOfFile = Extraction.find(MongoDBObject("file_id" -> new ObjectId(fileId.stringify))).toList var extractorsArray:collection.mutable.Map[String,String] = collection.mutable.Map() @@ -65,14 +65,14 @@ class MongoDBExtractionService extends ExtractionService { WebPageResource.insert(webpr,WriteConcern.Safe) webpr.id } - + def getWebPageResource(id: UUID): Map[String,String]={ val wpr=WebPageResource.findOne(MongoDBObject("_id"->new ObjectId(id.stringify))) var wprlist= wpr.map{ e=>Logger.debug("resource id:" + id.toString) e.URLs }.getOrElse(Map.empty) - wprlist + wprlist } // Return a mapping of ExtractorName -> (FirstMsgTime, LatestMsgTime, LatestMsg, ListOfAllMessages) diff --git a/app/services/mongodb/MongoDBExtractorService.scala b/app/services/mongodb/MongoDBExtractorService.scala index 61453fadb..b1342737a 100644 --- a/app/services/mongodb/MongoDBExtractorService.scala +++ b/app/services/mongodb/MongoDBExtractorService.scala @@ -116,10 +116,10 @@ class MongoDBExtractorService extends ExtractorService { //------------------------Temporary fix-------------------------------- /** * - * This is a temporary fix for keeping track of extractor servers IPs, names and the extractors' counts - * This will be omitted in future version + * This is a temporary fix for keeping track of extractor servers IPs, names and the extractors' counts + * This will be omitted in future version * - * * + * * */ def insertExtractorDetail(exDetails: List[ExtractorDetail]) = { for (qn <- exDetails) { @@ -140,7 +140,7 @@ class MongoDBExtractorService extends ExtractorService { Some(edArray) } - //------------------------------------------End of Temporary fix------------- + //------------------------------------------End of Temporary fix------------- def getExtractorInputTypes() = { var list_inputs = List[String]() diff --git a/app/services/mongodb/MongoDBFileService.scala b/app/services/mongodb/MongoDBFileService.scala index 23f0ca6c0..b349d4e7a 100644 --- a/app/services/mongodb/MongoDBFileService.scala +++ b/app/services/mongodb/MongoDBFileService.scala @@ -656,7 +656,7 @@ class MongoDBFileService @Inject() ( def incrementMetadataCount(id: UUID, count: Long) = { FileDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), $inc("metadataCount" -> count), false, false, WriteConcern.Safe) } - + /** * Add versus descriptors to the Versus.descriptors collection associated to a file * @@ -667,7 +667,7 @@ class MongoDBFileService @Inject() ( VersusDAO.insert(new Versus(id,doc),WriteConcern.Safe) Logger.debug("--Added versus descriptors in json format received from versus to the metadata field --") } - + /** * Get Versus descriptors as Json Array for a file */ @@ -680,7 +680,7 @@ class MongoDBFileService @Inject() ( Logger.debug("array=" + vdArray.toString) } Some(vdArray) - } + } /*convert list of JsObject to JsArray*/ def getJsonArray(list: List[JsObject]): JsArray = { list.foldLeft(JsArray())((acc, x) => acc ++ Json.arr(x)) @@ -727,7 +727,7 @@ class MongoDBFileService @Inject() ( def findIntermediates(): List[File] = { FileDAO.find(MongoDBObject("isIntermediate" -> true)).toList } - + /** * Implementation of updateLicenseing defined in services/FileService.scala. */ @@ -735,9 +735,9 @@ class MongoDBFileService @Inject() ( allowDownload: String) { val licenseData = models.LicenseData(m_licenseType = licenseType, m_rightsHolder = rightsHolder, m_licenseText = licenseText, m_licenseUrl = licenseUrl, m_allowDownload = allowDownload.toBoolean) - val result = FileDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), - $set("licenseData" -> LicenseData.toDBObject(licenseData)), - false, false, WriteConcern.Safe); + val result = FileDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), + $set("licenseData" -> LicenseData.toDBObject(licenseData)), + false, false, WriteConcern.Safe); } // ---------- Tags related code starts ------------------ @@ -773,7 +773,7 @@ class MongoDBFileService @Inject() ( FileDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), $addToSet("comments" -> Comment.toDBObject(comment)), false, false, WriteConcern.Safe) } - + def setIntermediate(id: UUID){ FileDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), $set("isIntermediate" -> Some(true)), false, false, WriteConcern.Safe) @@ -784,13 +784,13 @@ class MongoDBFileService @Inject() ( get(id) match{ case Some(file) => { if(file.originalname.length >0) { - + FileDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), $set("filename" -> newName), false, false, WriteConcern.Safe) } else { FileDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), $set("filename" -> newName, "originalname" -> file.filename ), false, false, WriteConcern.Safe) - + } } } @@ -817,8 +817,8 @@ class MongoDBFileService @Inject() ( datasets.index(fileDataset.id) } - if(!file.thumbnail_id.isEmpty && !fileDataset.thumbnail_id.isEmpty){ - if(file.thumbnail_id.get.equals(fileDataset.thumbnail_id.get)){ + if(!file.thumbnail_id.isEmpty && !fileDataset.thumbnail_id.isEmpty){ + if(file.thumbnail_id.get.equals(fileDataset.thumbnail_id.get)){ datasets.newThumbnail(fileDataset.id) collections.get(fileDataset.collections).found.foreach(collection => { if(!collection.thumbnail_id.isEmpty){ @@ -829,7 +829,7 @@ class MongoDBFileService @Inject() ( }) } } - + } val fileFolders = folders.findByFileId(file.id) @@ -948,10 +948,10 @@ class MongoDBFileService @Inject() ( if(reqValue.isInstanceOf[String]){ val currValue = reqValue.asInstanceOf[String] - + if(keyTrimmed.endsWith("__not")){ if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ - var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); + var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ realValue = "^"+realValue+"$"; } @@ -966,7 +966,7 @@ class MongoDBFileService @Inject() ( } else{ if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ - var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); + var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ realValue = "^"+realValue+"$"; } @@ -1001,7 +1001,7 @@ class MongoDBFileService @Inject() ( val currValue = reqValue.asInstanceOf[String] if(keyTrimmed.endsWith("__not")){ if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ - var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); + var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ realValue = "^"+realValue+"$"; } @@ -1016,7 +1016,7 @@ class MongoDBFileService @Inject() ( } else{ if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ - var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); + var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ realValue = "^"+realValue+"$"; } diff --git a/app/services/mongodb/MongoDBPreviewService.scala b/app/services/mongodb/MongoDBPreviewService.scala index fd782c792..b723a0fac 100644 --- a/app/services/mongodb/MongoDBPreviewService.scala +++ b/app/services/mongodb/MongoDBPreviewService.scala @@ -289,10 +289,10 @@ class MongoDBPreviewService @Inject()(files: FileService, tiles: TileService, st $set("title" -> title), upsert=false, multi=false, WriteConcern.Safe) } - + /** - * Get metadata from the mongo db as a map. - * + * Get metadata from the mongo db as a map. + * */ def getMetadata(id: UUID): scala.collection.immutable.Map[String,Any] = { PreviewDAO.dao.collection.findOneByID(new ObjectId(id.stringify)) match { @@ -303,12 +303,12 @@ class MongoDBPreviewService @Inject()(files: FileService, tiles: TileService, st } } } - - def getExtractorId(id: UUID):String = { - val extractor_id = getMetadata(id)("extractor_id").toString + + def getExtractorId(id: UUID):String = { + val extractor_id = getMetadata(id)("extractor_id").toString extractor_id } - + } object PreviewDAO extends ModelCompanion[Preview, ObjectId] { diff --git a/app/services/mongodb/MongoDBSchedulerService.scala b/app/services/mongodb/MongoDBSchedulerService.scala index 7aa1fbb7b..b2a371d92 100644 --- a/app/services/mongodb/MongoDBSchedulerService.scala +++ b/app/services/mongodb/MongoDBSchedulerService.scala @@ -32,7 +32,7 @@ class MongoDBSchedulerService extends SchedulerService { var checkJob = false var jobList = getJob(name) for (job <- jobList){ - checkJob = true + checkJob = true } return checkJob } @@ -69,7 +69,7 @@ class MongoDBSchedulerService extends SchedulerService { Jobs.dao.update(MongoDBObject("name" -> name), $set("frequency" -> freq)) } - + def updateEmailJob(id: UUID, name: String, setting: String) = { if (jobExists(name) == false) { diff --git a/app/services/mongodb/MongoDBSectionIndexInfoService.scala b/app/services/mongodb/MongoDBSectionIndexInfoService.scala index 7a8bd74c2..720a42bd5 100644 --- a/app/services/mongodb/MongoDBSectionIndexInfoService.scala +++ b/app/services/mongodb/MongoDBSectionIndexInfoService.scala @@ -11,8 +11,8 @@ import models.{SectionIndexInfo, UUID} /** * USe Mongodb to store section index information */ -class MongoDBSectionIndexInfoService extends SectionIndexInfoService { - +class MongoDBSectionIndexInfoService extends SectionIndexInfoService { + /** * Check if index with this id is already in mongo collection. If it is - update type. If it is not - * add a new entry with index id and index type. @@ -20,24 +20,24 @@ class MongoDBSectionIndexInfoService extends SectionIndexInfoService { def insertType (indexId: UUID, indexType: String) { val query = MongoDBObject("indexId" -> indexId.stringify) //set "true" for upsert - SectionIndexInfoDAO.update(query, $set("indexType" -> indexType), true, false, WriteConcern.Safe) + SectionIndexInfoDAO.update(query, $set("indexType" -> indexType), true, false, WriteConcern.Safe) } - + /** *Insert name of an index into mongo db. *Check if index with this id is already in mongo collection. If it is - update name. If not - * add a new entry with index id and index name. * Input: * @param indexId - id of the index - * @param indexName - name of the index - * - */ + * @param indexName - name of the index + * + */ def insertName (indexId: UUID, indexName: String) { val query = MongoDBObject("indexId" -> indexId.stringify) //set boolean parameter to "true" for upsert, i.e. update/insert - SectionIndexInfoDAO.update(query, $set("indexName" -> indexName), true, false, WriteConcern.Safe) + SectionIndexInfoDAO.update(query, $set("indexName" -> indexName), true, false, WriteConcern.Safe) } - + /** * Returns name of this index if found, otherwise returns none. */ @@ -45,45 +45,45 @@ class MongoDBSectionIndexInfoService extends SectionIndexInfoService { val query = MongoDBObject("indexId" -> indexId.stringify) SectionIndexInfoDAO.findOne(query).flatMap(_.indexName) } - + /** * Returns type string if found, otherwise returns none. */ - def getType(indexId: UUID): Option[String] = { - SectionIndexInfoDAO.findOne(MongoDBObject("indexId" -> indexId.stringify)).flatMap(_.indexType) + def getType(indexId: UUID): Option[String] = { + SectionIndexInfoDAO.findOne(MongoDBObject("indexId" -> indexId.stringify)).flatMap(_.indexType) } - + /** * Returns an array of all distinct values of the field indexType */ def getDistinctTypes(): List[String] = { SectionIndexInfoDAO.find(MongoDBObject()).flatMap(_.indexType).toList.distinct } - + /** * Returns true is entry with this indexId is found. */ - def isFound(indexId: UUID): Boolean = { - SectionIndexInfoDAO.findOne(MongoDBObject("indexId" -> indexId)).isDefined + def isFound(indexId: UUID): Boolean = { + SectionIndexInfoDAO.findOne(MongoDBObject("indexId" -> indexId)).isDefined } - + /** * Removes collection from mongo db */ def deleteAll() { SectionIndexInfoDAO.remove(MongoDBObject()) - } - + } + /** * Removes one index from collection */ - def delete(indexId: UUID): Boolean = { + def delete(indexId: UUID): Boolean = { Logger.debug("MongoDBSectionIndexInfoService - top of delete for indexId = " + indexId) val query = MongoDBObject("indexId" -> indexId.stringify) val result = SectionIndexInfoDAO.remove( query ) Logger.debug("MongoDBSectionIndexInfoService - delete: Number removed: = result.getN = " + result.getN) //if one or more deleted - return true - val wasDeleted = result.getN >0 + val wasDeleted = result.getN >0 wasDeleted } } diff --git a/app/services/mongodb/MongoDBSectionService.scala b/app/services/mongodb/MongoDBSectionService.scala index b7f9e01d3..d42daa217 100644 --- a/app/services/mongodb/MongoDBSectionService.scala +++ b/app/services/mongodb/MongoDBSectionService.scala @@ -21,7 +21,7 @@ import scala.collection.mutable.ArrayBuffer */ @Singleton class MongoDBSectionService @Inject() (comments: CommentService, previews: PreviewService, files: FileService, datasets: DatasetService, folders: FolderService) extends SectionService { - + def listSections(): List[Section] = { SectionDAO.findAll.toList } @@ -191,9 +191,9 @@ class MongoDBSectionService @Inject() (comments: CommentService, previews: Previ return ArrayBuffer.empty } } - + } - + } object SectionDAO extends ModelCompanion[Section, ObjectId] { diff --git a/app/services/mongodb/MongoDBTempFileService.scala b/app/services/mongodb/MongoDBTempFileService.scala index 4f7c28188..6693b69e9 100644 --- a/app/services/mongodb/MongoDBTempFileService.scala +++ b/app/services/mongodb/MongoDBTempFileService.scala @@ -21,7 +21,7 @@ class MongoDBTempFileService extends TempFileService { def get(query_id: UUID): Option[TempFile] = { TempFileDAO.findOneById(new ObjectId(query_id.stringify)) } - + /** * Update thumbnail used to represent this query. */ @@ -29,8 +29,8 @@ class MongoDBTempFileService extends TempFileService { TempFileDAO.update(MongoDBObject("_id" -> new ObjectId(queryId.stringify)), $set("thumbnail_id" -> thumbnailId.stringify), false, false, WriteConcern.Safe) } - - + + } object TempFileDAO extends ModelCompanion[TempFile, ObjectId] { diff --git a/app/services/mongodb/MongoSalatPlugin.scala b/app/services/mongodb/MongoSalatPlugin.scala index a5f8fc06e..9b3a8c6e0 100644 --- a/app/services/mongodb/MongoSalatPlugin.scala +++ b/app/services/mongodb/MongoSalatPlugin.scala @@ -422,13 +422,13 @@ class MongoSalatPlugin(app: Application) extends Plugin { // Change repository in extractors.info collection into a list updateMongo("update-repository-type-in-extractors-info", updateRepositoryType) - // Change existing 'In Curation' curation objects/pub requests to 'In Prepaparation' + // Change existing 'In Curation' curation objects/pub requests to 'In Prepaparation' updateMongo("change-in-curation-status-to-in-preparation", updateInCurationStatus) - // Change from User active and serverAdmin flags to single status + // Change from User active and serverAdmin flags to single status updateMongo("change-to-user-status", updateToUserStatus) - - // Capture original filename from FRBR metadata supplied by SEAD Migrator + + // Capture original filename from FRBR metadata supplied by SEAD Migrator updateMongo("populate-original-filename", updateOriginalFilename) // Removes the private key from extraction logs @@ -1614,7 +1614,7 @@ class MongoSalatPlugin(app: Application) extends Plugin { collection("uploads").update(MongoDBObject("_id" -> new ObjectId(ref.get("_id").toString())), MongoDBObject("$set" -> MongoDBObject( "originalname" -> path.substring(path.lastIndexOf("/")+1))), false, false, WriteConcern.Safe) - + } case _ => Logger.info("Nope") } diff --git a/app/services/mongodb/MongoUserService.scala b/app/services/mongodb/MongoUserService.scala index f31f1a83e..14669d345 100644 --- a/app/services/mongodb/MongoUserService.scala +++ b/app/services/mongodb/MongoUserService.scala @@ -39,7 +39,7 @@ object TokenDAO extends ModelCompanion[MongoToken, ObjectId] { def findByUUID(uuid: String): Option[MongoToken] = { dao.findOne(MongoDBObject("uuid" -> uuid)) } - + def removeByUUID(uuid: String) { dao.remove(MongoDBObject("uuid" -> uuid), WriteConcern.Normal) } @@ -66,7 +66,7 @@ class MongoUserService(application: Application) extends UserServicePlugin(appli * @param email - the user email * @param providerId - the provider id * @return - */ + */ def findByEmailAndProvider(email: String, providerId: String): Option[Identity] = { Logger.trace("Searching for user " + email + " " + providerId) SocialUserDAO.findOne(MongoDBObject("email"->email, "identityId.providerId"->providerId)) @@ -141,5 +141,5 @@ class MongoUserService(application: Application) extends UserServicePlugin(appli def deleteExpiredTokens() { Logger.debug("----Deleting expired tokens") for (token <- TokenDAO.findAll) if (token.isExpired) TokenDAO.remove(token) - } + } } diff --git a/app/util/DistancePriorityQueue.scala b/app/util/DistancePriorityQueue.scala index 042cbdd1d..f9c212418 100644 --- a/app/util/DistancePriorityQueue.scala +++ b/app/util/DistancePriorityQueue.scala @@ -18,7 +18,7 @@ object SearchResult { } class DistancePriorityQueue(maxSize: Int) extends PriorityQueue[SearchResult](maxSize: Int) { - + override def lessThan(a: SearchResult, b: SearchResult): Boolean = { if (a.distance > b.distance) { return true; diff --git a/app/util/Publications.scala b/app/util/Publications.scala index 92ec0ca14..051de8c97 100644 --- a/app/util/Publications.scala +++ b/app/util/Publications.scala @@ -16,8 +16,6 @@ import services.SpaceService * */ object Publications { - - def getPublications(space: String, spaces: SpaceService) = { implicit val context = scala.concurrent.ExecutionContext.Implicits.global val endpoint = play.Play.application().configuration().getString("publishData.list.uri").replaceAll("/$", "") @@ -28,10 +26,10 @@ object Publications { val spaceSet: Set[String] = space match { case s: String if (s.isEmpty) => Set() case sp: String => spaces.get(UUID(sp)) match { - case Some(s) => ( s.name :: s.affiliatedSpaces).toSet + case Some(s) => ( s.name :: s.affiliatedSpaces).toSet case None => Set() } - + } val result = futureResponse.map { case response => diff --git a/app/util/RequiredFieldsConfig.scala b/app/util/RequiredFieldsConfig.scala index 7bedb3270..b24729865 100644 --- a/app/util/RequiredFieldsConfig.scala +++ b/app/util/RequiredFieldsConfig.scala @@ -7,25 +7,22 @@ import play.api.Play._ * */ object RequiredFieldsConfig { - /** * Value for if name fields should be required or not. - * + * * @return A boolean, true if name should be required. False otherwise. Default is true. */ def isNameRequired(): Boolean = { configuration.getBoolean("clowder.requiredfields.isNameRequired").getOrElse(true) } - + /** * Value for if description fields should be required or not. - * + * * @return A boolean, true if description should be required. False otherwise. Default is false. - * + * */ def isDescriptionRequired(): Boolean = { - configuration.getBoolean("clowder.requiredfields.isDescriptionRequired").getOrElse(false) + configuration.getBoolean("clowder.requiredfields.isDescriptionRequired").getOrElse(false) } - - } diff --git a/app/util/SpaceConfig.scala b/app/util/SpaceConfig.scala index 735071b47..7136396e7 100644 --- a/app/util/SpaceConfig.scala +++ b/app/util/SpaceConfig.scala @@ -7,21 +7,21 @@ import play.api.Play._ * */ object SpaceConfig { - + /** * Value for if purging should be enabled or not. - * + * * @return A boolean, true if resources should expire. False otherwise. */ def getIsTimeToLiveEnabled(): Boolean = { configuration.getBoolean("clowder.space.isTimeToLiveEnabled").getOrElse(false) } - + /** * The amount of time before resources should expire. - * + * * @return The value of the amount, in milliseconds. - * + * */ def getTimeToLive(): Long = { val timeString = configuration.getInt("clowder.space.timeToLive").getOrElse(720) From a6b3cca762d9221d7895d8f732a5f087be3287ff Mon Sep 17 00:00:00 2001 From: Tim Yardley Date: Wed, 18 Dec 2019 21:30:02 -0600 Subject: [PATCH 4/9] update for consistency and style --- app/Iterators/BagItIterator.scala | 52 ++++----- app/Iterators/CollectionIterator.scala | 40 +++---- app/Iterators/DatasetIterator.scala | 18 ++-- .../DatasetsInCollectionIterator.scala | 12 +-- app/Iterators/FileIterator.scala | 22 ++-- app/Iterators/RootCollectionIterator.scala | 44 ++++---- app/Iterators/SelectedIterator.scala | 17 ++- app/api/Collections.scala | 2 +- app/api/Comments.scala | 4 +- app/api/CurationObjects.scala | 14 +-- app/api/Datasets.scala | 56 +++++----- app/api/Events.scala | 8 +- app/api/Extractions.scala | 2 +- app/api/Folders.scala | 2 +- app/api/Geostreams.scala | 2 +- app/api/Reporting.scala | 100 +++++++++--------- app/controllers/Collections.scala | 14 +-- app/controllers/Datasets.scala | 10 +- app/controllers/Files.scala | 6 +- app/controllers/Users.scala | 14 +-- app/services/ElasticsearchPlugin.scala | 46 ++++---- app/services/FileDumpService.scala | 2 +- app/services/PostgresPlugin.scala | 18 ++-- app/services/RDFExportService.scala | 16 +-- app/services/RDFUpdateService.scala | 12 +-- app/services/RabbitmqPlugin.scala | 20 ++-- app/services/SecureSocialEventListener.scala | 4 +- app/services/ToolManagerPlugin.scala | 36 +++---- .../fourstore/FourStoreRdfSPARQLService.scala | 32 +++--- .../mongodb/MongoDBCollectionService.scala | 4 +- .../mongodb/MongoDBContextLDService.scala | 2 +- .../mongodb/MongoDBCurationService.scala | 2 +- .../mongodb/MongoDBDatasetService.scala | 64 +++++------ .../MongoDBExtractionRequestsService.scala | 8 +- .../mongodb/MongoDBExtractionService.scala | 2 +- app/services/mongodb/MongoDBFileService.scala | 40 +++---- .../mongodb/MongoDBMetadataService.scala | 6 +- .../MongoDBMultimediaQueryService.scala | 4 +- .../mongodb/MongoDBSpaceService.scala | 4 +- app/services/mongodb/MongoSalatPlugin.scala | 4 +- 40 files changed, 382 insertions(+), 383 deletions(-) diff --git a/app/Iterators/BagItIterator.scala b/app/Iterators/BagItIterator.scala index d8cb0924f..8092f9b2d 100644 --- a/app/Iterators/BagItIterator.scala +++ b/app/Iterators/BagItIterator.scala @@ -19,20 +19,20 @@ class BagItIterator(pathToFolder : String, collection : Option[models.Collection var bytes : Long = 0L private def addBagItTextToZip(pathToFolder : String, totalbytes: Long, totalFiles: Long, zip: ZipOutputStream, collection: models.Collection, user: Option[models.User]) = { - zip.putNextEntry(new ZipEntry(pathToFolder+"/bagit.txt")) + zip.putNextEntry(new ZipEntry(pathToFolder + "/bagit.txt")) val softwareLine = "Bag-Software-Agent: clowder.ncsa.illinois.edu\n" - val baggingDate = "Bagging-Date: "+(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(Calendar.getInstance.getTime)+"\n" + val baggingDate = "Bagging-Date: " + (new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(Calendar.getInstance.getTime) + "\n" val baggingSize = "Bag-Size: " + totalbytes + "\n" - val payLoadOxum = "Payload-Oxum: "+ totalbytes + "." + totalFiles +"\n" - val senderIdentifier="Internal-Sender-Identifier: "+collection.id+"\n" - val senderDescription = "Internal-Sender-Description: "+collection.description+"\n" + val payLoadOxum = "Payload-Oxum: " + totalbytes + "." + totalFiles + "\n" + val senderIdentifier = "Internal-Sender-Identifier: " + collection.id + "\n" + val senderDescription = "Internal-Sender-Description: " + collection.description + "\n" var s:String = "" if (user.isDefined) { val contactName = "Contact-Name: " + user.get.fullName + "\n" val contactEmail = "Contact-Email: " + user.get.email.getOrElse("") + "\n" - s = softwareLine+baggingDate+baggingSize+payLoadOxum+contactName+contactEmail+senderIdentifier+senderDescription + s = softwareLine + baggingDate + baggingSize + payLoadOxum + contactName + contactEmail + senderIdentifier + senderDescription } else { - s = softwareLine+baggingDate+baggingSize+payLoadOxum+senderIdentifier+senderDescription + s = softwareLine + baggingDate + baggingSize + payLoadOxum + senderIdentifier + senderDescription } Some(new ByteArrayInputStream(s.getBytes("UTF-8"))) @@ -40,39 +40,39 @@ class BagItIterator(pathToFolder : String, collection : Option[models.Collection // If no collection provided, assume this is for Selected download private def addBagItTextToZip(pathToFolder : String, totalbytes: Long, totalFiles: Long, zip: ZipOutputStream, user: Option[models.User]) = { - zip.putNextEntry(new ZipEntry(pathToFolder+"/bagit.txt")) + zip.putNextEntry(new ZipEntry(pathToFolder + "/bagit.txt")) val softwareLine = "Bag-Software-Agent: clowder.ncsa.illinois.edu\n" - val baggingDate = "Bagging-Date: "+(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(Calendar.getInstance.getTime)+"\n" + val baggingDate = "Bagging-Date: " + (new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(Calendar.getInstance.getTime) + "\n" val baggingSize = "Bag-Size: " + totalbytes + "\n" - val payLoadOxum = "Payload-Oxum: "+ totalbytes + "." + totalFiles +"\n" + val payLoadOxum = "Payload-Oxum: " + totalbytes + "." + totalFiles + "\n" val s:String = if (user.isDefined) { - val senderIdentifier="Internal-Sender-Identifier: user "+user.get.id+"\n" + val senderIdentifier = "Internal-Sender-Identifier: user " + user.get.id + "\n" val senderDescription = "Internal-Sender-Description: User Dataset Selections\n" val contactName = "Contact-Name: " + user.get.fullName + "\n" val contactEmail = "Contact-Email: " + user.get.email.getOrElse("") + "\n" - softwareLine+baggingDate+baggingSize+payLoadOxum+contactName+contactEmail+senderIdentifier+senderDescription + softwareLine + baggingDate + baggingSize + payLoadOxum + contactName + contactEmail + senderIdentifier + senderDescription } else { - val senderIdentifier="Internal-Sender-Identifier: unknown user\n" + val senderIdentifier = "Internal-Sender-Identifier: unknown user\n" val senderDescription = "Internal-Sender-Description: User Dataset Selections\n" - softwareLine+baggingDate+baggingSize+payLoadOxum+senderIdentifier+senderDescription + softwareLine + baggingDate + baggingSize + payLoadOxum + senderIdentifier + senderDescription } Some(new ByteArrayInputStream(s.getBytes("UTF-8"))) } private def addBagInfoToZip(pathToFolder : String ,zip : ZipOutputStream) : Option[InputStream] = { - zip.putNextEntry(new ZipEntry(pathToFolder+"/bag-info.txt")) - val s : String = "BagIt-Version: 0.97\n"+"Tag-File-Character-Encoding: UTF-8\n" + zip.putNextEntry(new ZipEntry(pathToFolder + "/bag-info.txt")) + val s : String = "BagIt-Version: 0.97\n" + "Tag-File-Character-Encoding: UTF-8\n" Some(new ByteArrayInputStream(s.getBytes("UTF-8"))) } private def addManifestMD5ToZip(pathToFolder : String, md5map : Map[String,MessageDigest] ,zip : ZipOutputStream) : Option[InputStream] = { - zip.putNextEntry(new ZipEntry(pathToFolder+"/manifest-md5.txt")) + zip.putNextEntry(new ZipEntry(pathToFolder + "/manifest-md5.txt")) var s : String = "" md5map.foreach{ case (filePath,md) => { - val current = Hex.encodeHexString(md.digest())+" "+filePath+"\n" + val current = Hex.encodeHexString(md.digest()) + " " + filePath + "\n" s = s + current } } @@ -80,11 +80,11 @@ class BagItIterator(pathToFolder : String, collection : Option[models.Collection } private def addTagManifestMD5ToZip(pathToFolder : String, md5map : Map[String,MessageDigest],zip : ZipOutputStream) : Option[InputStream] = { - zip.putNextEntry(new ZipEntry(pathToFolder+"/tagmanifest-md5.txt")) + zip.putNextEntry(new ZipEntry(pathToFolder + "/tagmanifest-md5.txt")) var s : String = "" md5map.foreach{ case (filePath,md) => { - val current = Hex.encodeHexString(md.digest())+" "+filePath+"\n" + val current = Hex.encodeHexString(md.digest()) + " " + filePath + "\n" s = s + current } } @@ -109,15 +109,15 @@ class BagItIterator(pathToFolder : String, collection : Option[models.Collection case 1 => { is = collection match { case Some(coll) => { - addBagItTextToZip(pathToFolder,bytes,0,zip,coll,user) + addBagItTextToZip(pathToFolder, bytes, 0, zip, coll, user) } case None => { - addBagItTextToZip(pathToFolder,bytes,0,zip,user) + addBagItTextToZip(pathToFolder, bytes, 0, zip, user) } } val md5 = MessageDigest.getInstance("MD5") - md5Bag.put("bagit.txt",md5) + md5Bag.put("bagit.txt", md5) file_type = 2 Some(new DigestInputStream(is.get, md5)) @@ -125,7 +125,7 @@ class BagItIterator(pathToFolder : String, collection : Option[models.Collection case 0 => { is = addBagInfoToZip(pathToFolder,zip) val md5 = MessageDigest.getInstance("MD5") - md5Bag.put("bag-info.txt",md5) + md5Bag.put("bag-info.txt", md5) file_type = 1 Some(new DigestInputStream(is.get, md5)) @@ -133,14 +133,14 @@ class BagItIterator(pathToFolder : String, collection : Option[models.Collection case 2 => { is = addManifestMD5ToZip(pathToFolder,md5Files.toMap[String,MessageDigest],zip) val md5 = MessageDigest.getInstance("MD5") - md5Bag.put("manifest-md5.txt",md5) + md5Bag.put("manifest-md5.txt", md5) file_type = 3 Some(new DigestInputStream(is.get, md5)) } case 3 => { is = addTagManifestMD5ToZip(pathToFolder,md5Bag.toMap[String,MessageDigest],zip) val md5 = MessageDigest.getInstance("MD5") - md5Bag.put("tagmanifest-md5.txt",md5) + md5Bag.put("tagmanifest-md5.txt", md5) file_type = 4 Some(new DigestInputStream(is.get, md5)) } diff --git a/app/Iterators/CollectionIterator.scala b/app/Iterators/CollectionIterator.scala index cbe326122..21bd27996 100644 --- a/app/Iterators/CollectionIterator.scala +++ b/app/Iterators/CollectionIterator.scala @@ -56,15 +56,15 @@ class CollectionIterator(pathToFolder : String, parent_collection : models.Colle } private def addCollectionInfoToZip(folderName: String, collection: models.Collection, zip: ZipOutputStream): Option[InputStream] = { - val path = folderName + "/"+collection.name+"_info.json" - zip.putNextEntry(new ZipEntry(folderName + "/"+collection.name+"_info.json")) + val path = folderName + "/" + collection.name + "_info.json" + zip.putNextEntry(new ZipEntry(folderName + "/" + collection.name + "_info.json")) val infoListMap = Json.prettyPrint(jsonCollection(collection)) Some(new ByteArrayInputStream(infoListMap.getBytes("UTF-8"))) } private def addCollectionMetadataToZip(folderName : String , collection : models.Collection, zip : ZipOutputStream) : Option[InputStream] = { - val path = folderName+"/"+collection.name+"_metadata.json" - zip.putNextEntry(new ZipEntry(folderName+"/"+collection.name+"_metadata.json")) + val path = folderName + "/" + collection.name + "_metadata.json" + zip.putNextEntry(new ZipEntry(folderName + "/" + collection.name + "_metadata.json")) val collectionMetadata = getCollectionInfoAsJson(collection) val metadataMap = Json.prettyPrint(collectionMetadata) Some(new ByteArrayInputStream(metadataMap.getBytes("UTF-8"))) @@ -74,14 +74,14 @@ class CollectionIterator(pathToFolder : String, parent_collection : models.Colle if (file_type < 2){ true } - else if (file_type ==2){ + else if (file_type == 2){ if (datasetIterator.hasNext()){ true } else if (numChildCollections > 0){ - currentCollectionIterator = Some(new CollectionIterator(pathToFolder+"/"+child_collections(childCollectionCount).name, child_collections(childCollectionCount),zip,md5Files,user,collections,datasets,files, - folders,metadataService,spaces)) - file_type +=1 + currentCollectionIterator = Some(new CollectionIterator(pathToFolder + "/" + child_collections(childCollectionCount).name, child_collections(childCollectionCount), zip, md5Files, user, collections, datasets, files, + folders, metadataService, spaces)) + file_type += 1 true } else { false @@ -91,14 +91,14 @@ class CollectionIterator(pathToFolder : String, parent_collection : models.Colle case Some(collectionIterator) => { if (collectionIterator.hasNext()){ true - } else if (childCollectionCount < numChildCollections -2){ - childCollectionCount+=1 - currentCollectionIterator = Some(new CollectionIterator(pathToFolder+"/"+child_collections(childCollectionCount).name, child_collections(childCollectionCount),zip,md5Files,user, - collections,datasets,files, - folders,metadataService,spaces)) + } else if (childCollectionCount < numChildCollections - 2){ + childCollectionCount += 1 + currentCollectionIterator = Some(new CollectionIterator(pathToFolder + "/" + child_collections(childCollectionCount).name, child_collections(childCollectionCount), zip, md5Files, user, + collections, datasets, files, + folders, metadataService, spaces)) true } else { - file_type+=1 + file_type += 1 false } } @@ -114,17 +114,17 @@ class CollectionIterator(pathToFolder : String, parent_collection : models.Colle //collection info case 0 => { val md5 = MessageDigest.getInstance("MD5") - md5Files.put(pathToFolder+"_info.json",md5) - val is = addCollectionInfoToZip(pathToFolder, parent_collection,zip) - file_type+=1 + md5Files.put(pathToFolder + "_info.json", md5) + val is = addCollectionInfoToZip(pathToFolder, parent_collection, zip) + file_type += 1 Some(new DigestInputStream(is.get, md5)) } //collection metadata case 1 => { val md5 = MessageDigest.getInstance("MD5") - md5Files.put(pathToFolder+"_metadata.json",md5) - val is = addCollectionMetadataToZip(pathToFolder, parent_collection,zip) - file_type+=1 + md5Files.put(pathToFolder + "_metadata.json", md5) + val is = addCollectionMetadataToZip(pathToFolder, parent_collection, zip) + file_type += 1 Some(new DigestInputStream(is.get, md5)) } //datasets in this collection diff --git a/app/Iterators/DatasetIterator.scala b/app/Iterators/DatasetIterator.scala index 2068f3218..5dac4603b 100644 --- a/app/Iterators/DatasetIterator.scala +++ b/app/Iterators/DatasetIterator.scala @@ -44,15 +44,15 @@ class DatasetIterator(pathToFolder : String, dataset : models.Dataset, zip: ZipO } def addDatasetInfoToZip(folderName: String, dataset: models.Dataset, zip: ZipOutputStream): Option[InputStream] = { - val path = folderName + "/"+dataset.name+"_info.json" - zip.putNextEntry(new ZipEntry(folderName + "/"+dataset.name+"_info.json")) + val path = folderName + "/" + dataset.name + "_info.json" + zip.putNextEntry(new ZipEntry(folderName + "/" + dataset.name + "_info.json")) val infoListMap = Json.prettyPrint(getDatasetInfoAsJson(dataset)) Some(new ByteArrayInputStream(infoListMap.getBytes("UTF-8"))) } def addDatasetMetadataToZip(folderName: String, dataset : models.Dataset, zip: ZipOutputStream): Option[InputStream] = { - val path = folderName + "/"+dataset.name+"_dataset_metadata.json" - zip.putNextEntry(new ZipEntry(folderName + "/"+dataset.name+"_metadata.json")) + val path = folderName + "/" + dataset.name + "_dataset_metadata.json" + zip.putNextEntry(new ZipEntry(folderName + "/" + dataset.name + "_metadata.json")) val datasetMetadata = metadataService.getMetadataByAttachTo(ResourceRef(ResourceRef.dataset, dataset.id)) .map(JSONLD.jsonMetadataWithContext(_)) val s : String = Json.prettyPrint(Json.toJson(datasetMetadata)) @@ -85,7 +85,7 @@ class DatasetIterator(pathToFolder : String, dataset : models.Dataset, zip: ZipO while(f1.parentType == "folder") { folders.get(f1.parentId) match { case Some(fparent) => { - name = fparent.displayName + "/"+ name + name = fparent.displayName + "/" + name f1 = fparent } case None => @@ -125,7 +125,7 @@ class DatasetIterator(pathToFolder : String, dataset : models.Dataset, zip: ZipO if (fileIterator.hasNext()){ true } else if (fileCounter < numFiles -1){ - fileCounter +=1 + fileCounter += 1 currentFileIterator = Some(new FileIterator(folderNameMap(inputFiles(fileCounter).id),inputFiles(fileCounter),zip,md5Files,files,folders,metadataService)) true } else { @@ -146,7 +146,7 @@ class DatasetIterator(pathToFolder : String, dataset : models.Dataset, zip: ZipO is = addDatasetInfoToZip(pathToFolder,dataset,zip) val md5 = MessageDigest.getInstance("MD5") md5Files.put("_info.json",md5) - file_type+=1 + file_type += 1 Some(new DigestInputStream(is.get, md5)) } case 1 => { @@ -154,10 +154,10 @@ class DatasetIterator(pathToFolder : String, dataset : models.Dataset, zip: ZipO val md5 = MessageDigest.getInstance("MD5") md5Files.put("_metadata.json",md5) if (numFiles > 0){ - file_type+=1 + file_type += 1 currentFileIterator = Some(new FileIterator(folderNameMap(inputFiles(fileCounter).id),inputFiles(fileCounter),zip,md5Files,files,folders,metadataService)) } else { - file_type+=2 + file_type += 2 } Some(new DigestInputStream(is.get, md5)) diff --git a/app/Iterators/DatasetsInCollectionIterator.scala b/app/Iterators/DatasetsInCollectionIterator.scala index 24f6b11ba..f2515084c 100644 --- a/app/Iterators/DatasetsInCollectionIterator.scala +++ b/app/Iterators/DatasetsInCollectionIterator.scala @@ -37,8 +37,8 @@ class DatasetsInCollectionIterator(pathToFolder : String, collection : models.Co var currentDatasetIterator : Option[DatasetIterator] = if (numDatasets > 0){ - Some(new DatasetIterator(pathToFolder+"/"+currentDataset.get.name,currentDataset.get, zip, md5Files, - folders, files,metadataService,datasets,spaces)) + Some(new DatasetIterator(pathToFolder + "/" + currentDataset.get.name, currentDataset.get, zip, md5Files, + folders, files, metadataService, datasets, spaces)) } else { None } @@ -51,13 +51,13 @@ class DatasetsInCollectionIterator(pathToFolder : String, collection : models.Co if (datasetIterator.hasNext()){ true } else { - if (datasetCount < numDatasets -1){ - datasetCount +=1 + if (datasetCount < numDatasets - 1){ + datasetCount += 1 currentDataset = Some(datasetsInCollection(datasetCount)) currentDataset match { case Some(cd) => { - currentDatasetIterator = Some(new DatasetIterator(pathToFolder+"/"+cd.name,cd, zip, md5Files, - folders, files,metadataService,datasets,spaces)) + currentDatasetIterator = Some(new DatasetIterator(pathToFolder + "/" + cd.name, cd, zip, md5Files, + folders, files, metadataService, datasets, spaces)) true } case None => false diff --git a/app/Iterators/FileIterator.scala b/app/Iterators/FileIterator.scala index 315d1bdb9..1edac2d96 100644 --- a/app/Iterators/FileIterator.scala +++ b/app/Iterators/FileIterator.scala @@ -10,7 +10,7 @@ import services.{FolderService, MetadataService, FileService} import util.JSONLD //this is used for file downloads -//called by the dataset interator +//called by the dataset iterator class FileIterator (pathToFile : String, file : models.File,zip : ZipOutputStream, md5Files :scala.collection.mutable.HashMap[String, MessageDigest], files : FileService, folders : FolderService , metadataService : MetadataService) extends Iterator[Option[InputStream]] { def getFileInfoAsJson(file : models.File) : JsValue = { @@ -31,7 +31,7 @@ class FileIterator (pathToFile : String, file : models.File,zip : ZipOutputStrea Json.obj("id" -> file.id, "filename" -> file.filename, "author" -> file.author.email, "uploadDate" -> file.uploadDate.toString,"contentType"->file.contentType,"description"->file.description,"license"->licenseInfo) } def addFileInfoToZip(folderName: String, file: models.File, zip: ZipOutputStream): Option[InputStream] = { - zip.putNextEntry(new ZipEntry(folderName + "/"+file.filename+"_info.json")) + zip.putNextEntry(new ZipEntry(folderName + "/" + file.filename + "_info.json")) val fileInfo = getFileInfoAsJson(file) val s : String = Json.prettyPrint(fileInfo) Some(new ByteArrayInputStream(s.getBytes("UTF-8"))) @@ -48,7 +48,7 @@ class FileIterator (pathToFile : String, file : models.File,zip : ZipOutputStrea } def addFileMetadataToZip(folderName: String, file: models.File, zip: ZipOutputStream): Option[InputStream] = { - zip.putNextEntry(new ZipEntry(folderName + "/"+file.filename+"_metadata.json")) + zip.putNextEntry(new ZipEntry(folderName + "/" + file.filename + "_metadata.json")) val fileMetadata = metadataService.getMetadataByAttachTo(ResourceRef(ResourceRef.file, file.id)).map(JSONLD.jsonMetadataWithContext(_)) val s : String = Json.prettyPrint(Json.toJson(fileMetadata)) Some(new ByteArrayInputStream(s.getBytes("UTF-8"))) @@ -66,24 +66,24 @@ class FileIterator (pathToFile : String, file : models.File,zip : ZipOutputStrea def next() = { file_type match { case 0 => { - file_type +=1 + file_type += 1 is = addFileInfoToZip(pathToFile, file, zip) val md5 = MessageDigest.getInstance("MD5") - md5Files.put(file.filename+"_info.json",md5) + md5Files.put(file.filename + "_info.json", md5) Some(new DigestInputStream(is.get,md5)) } case 1 => { - file_type+=1 - is = addFileMetadataToZip(pathToFile,file,zip) + file_type += 1 + is = addFileMetadataToZip(pathToFile, file, zip) val md5 = MessageDigest.getInstance("MD5") - md5Files.put(file.filename+"_metadata.json",md5) + md5Files.put(file.filename + "_metadata.json", md5) Some(new DigestInputStream(is.get,md5)) } case 2 => { - file_type+=1 - is = addFileToZip(pathToFile,file,zip) + file_type += 1 + is = addFileToZip(pathToFile, file, zip) val md5 = MessageDigest.getInstance("MD5") - md5Files.put(file.filename,md5) + md5Files.put(file.filename, md5) Some(new DigestInputStream(is.get,md5)) } case _ => None diff --git a/app/Iterators/RootCollectionIterator.scala b/app/Iterators/RootCollectionIterator.scala index b112dfd86..b571c69c0 100644 --- a/app/Iterators/RootCollectionIterator.scala +++ b/app/Iterators/RootCollectionIterator.scala @@ -17,7 +17,7 @@ import scala.collection.mutable.ListBuffer class RootCollectionIterator(pathToFolder : String, root_collection : models.Collection,zip : ZipOutputStream, md5Files : scala.collection.mutable.HashMap[String, MessageDigest], md5Bag : scala.collection.mutable.HashMap[String, MessageDigest], - user : Option[User],totalBytes : Long,bagit : Boolean, + user : Option[User], totalBytes : Long, bagit : Boolean, collections: CollectionService, datasets : DatasetService, files : FileService, folders : FolderService, metadataService : MetadataService, spaces : SpaceService) extends Iterator[Option[InputStream]] { @@ -38,8 +38,8 @@ class RootCollectionIterator(pathToFolder : String, root_collection : models.Col private def addCollectionInfoToZip(folderName: String, collection: models.Collection, zip: ZipOutputStream): Option[InputStream] = { - val path = folderName + "/"+collection.name+"_info.json" - zip.putNextEntry(new ZipEntry(folderName + "/"+collection.name+"_info.json")) + val path = folderName + "/" + collection.name + "_info.json" + zip.putNextEntry(new ZipEntry(folderName + "/" + collection.name + "_info.json")) val infoListMap = Json.prettyPrint(jsonCollection(collection)) Some(new ByteArrayInputStream(infoListMap.getBytes("UTF-8"))) } @@ -54,8 +54,8 @@ class RootCollectionIterator(pathToFolder : String, root_collection : models.Col private def addCollectionMetadataToZip(folderName : String , collection : models.Collection, zip : ZipOutputStream) : Option[InputStream] = { - val path = folderName+"/"+collection.name+"_metadata.json" - zip.putNextEntry(new ZipEntry(folderName+"/"+collection.name+"_metadata.json")) + val path = folderName + "/" + collection.name + "_metadata.json" + zip.putNextEntry(new ZipEntry(folderName + "/" + collection.name + "_metadata.json")) val collectionMetadata = getCollectionInfoAsJson(collection) val metadataMap = Json.prettyPrint(collectionMetadata) Some(new ByteArrayInputStream(metadataMap.getBytes("UTF-8"))) @@ -102,18 +102,18 @@ class RootCollectionIterator(pathToFolder : String, root_collection : models.Col if (file_type < 2){ true } - else if (file_type ==2){ + else if (file_type == 2){ if (datasetIterator.hasNext()){ true } else if (numCollections > 0){ - currentCollectionIterator = Some(new CollectionIterator(pathToFolder+"/"+child_collections(collectionCount).name, child_collections(collectionCount),zip,md5Files,user, - collections,datasets,files, - folders,metadataService,spaces)) - file_type +=1 + currentCollectionIterator = Some(new CollectionIterator(pathToFolder + "/" + child_collections(collectionCount).name, child_collections(collectionCount), zip, md5Files, user, + collections, datasets, files, + folders, metadataService, spaces)) + file_type += 1 true } else if (bagit){ - bagItIterator = Some(new BagItIterator(pathToFolder,Some(root_collection) ,zip,md5Bag,md5Files,bytesSoFar ,user)) + bagItIterator = Some(new BagItIterator(pathToFolder,Some(root_collection), zip, md5Bag, md5Files, bytesSoFar, user)) file_type = 4 true } else { @@ -124,16 +124,16 @@ class RootCollectionIterator(pathToFolder : String, root_collection : models.Col case Some(collectionIterator) => { if (collectionIterator.hasNext()){ true - } else if (collectionCount < numCollections -2){ - collectionCount+=1 - currentCollectionIterator = Some(new CollectionIterator(pathToFolder+"/"+child_collections(collectionCount).name, child_collections(collectionCount),zip,md5Files,user, - collections,datasets,files, - folders,metadataService,spaces)) + } else if (collectionCount < numCollections - 2){ + collectionCount += 1 + currentCollectionIterator = Some(new CollectionIterator(pathToFolder + "/" + child_collections(collectionCount).name, child_collections(collectionCount), zip, md5Files, user, + collections, datasets, files, + folders, metadataService, spaces)) true } else { if (bagit){ - bagItIterator = Some(new BagItIterator(pathToFolder,Some(root_collection) ,zip,md5Bag,md5Files,bytesSoFar ,user)) - file_type+=1 + bagItIterator = Some(new BagItIterator(pathToFolder,Some(root_collection), zip, md5Bag, md5Files, bytesSoFar, user)) + file_type += 1 true } else { false @@ -149,7 +149,7 @@ class RootCollectionIterator(pathToFolder : String, root_collection : models.Col if (bagIterator.hasNext()){ true } else { - file_type +=1 + file_type += 1 false } } @@ -165,15 +165,15 @@ class RootCollectionIterator(pathToFolder : String, root_collection : models.Col //collection info case 0 => { val md5 = MessageDigest.getInstance("MD5") - md5Files.put(pathToFolder+"_info.json",md5) + md5Files.put(pathToFolder + "_info.json", md5) val is = addCollectionInfoToZip(pathToFolder, root_collection,zip) - file_type+=1 + file_type += 1 Some(new DigestInputStream(is.get, md5)) } //collection metadata case 1 => { val md5 = MessageDigest.getInstance("MD5") - md5Files.put(pathToFolder+"_metadata.json",md5) + md5Files.put(pathToFolder + "_metadata.json", md5) val is = addCollectionMetadataToZip(pathToFolder, root_collection,zip) file_type+=1 Some(new DigestInputStream(is.get, md5)) diff --git a/app/Iterators/SelectedIterator.scala b/app/Iterators/SelectedIterator.scala index 4885473d2..cc554fdfa 100644 --- a/app/Iterators/SelectedIterator.scala +++ b/app/Iterators/SelectedIterator.scala @@ -21,8 +21,8 @@ class SelectedIterator(pathToFolder : String, selected : List[Dataset], zip : Zi var datasetCount = 0 var currDs = selected(datasetCount) - var datasetIterator = new DatasetIterator(pathToFolder+"/"+currDs.name, currDs, zip, md5Files, folders, files, - metadataService,datasets,spaces) + var datasetIterator = new DatasetIterator(pathToFolder + "/" + currDs.name, currDs, zip, md5Files, folders, files, + metadataService, datasets, spaces) var file_type = 0 @@ -48,17 +48,17 @@ class SelectedIterator(pathToFolder : String, selected : List[Dataset], zip : Zi } def hasNext() = { - if (file_type ==0){ + if (file_type == 0){ if (datasetIterator.hasNext()){ true - } else if (selected.length > datasetCount+1){ + } else if (selected.length > datasetCount + 1){ datasetCount += 1 currDs = selected(datasetCount) - datasetIterator = new DatasetIterator(pathToFolder+"/"+currDs.name,currDs,zip,md5Files,folders,files, - metadataService,datasets,spaces) + datasetIterator = new DatasetIterator(pathToFolder + "/" + currDs.name, currDs, zip, md5Files, folders, files, + metadataService, datasets, spaces) true } else if (bagit) { - bagItIterator = Some(new BagItIterator(pathToFolder,None ,zip,md5Bag,md5Files,bytesSoFar ,user)) + bagItIterator = Some(new BagItIterator(pathToFolder, None, zip, md5Bag, md5Files, bytesSoFar, user)) file_type = 1 true } else { @@ -70,7 +70,7 @@ class SelectedIterator(pathToFolder : String, selected : List[Dataset], zip : Zi if (bagIterator.hasNext()){ true } else { - file_type +=1 + file_type += 1 false } } @@ -101,6 +101,5 @@ class SelectedIterator(pathToFolder : String, selected : List[Dataset], zip : Zi None } } - } } diff --git a/app/api/Collections.scala b/app/api/Collections.scala index 09d399014..22e0dfd67 100644 --- a/app/api/Collections.scala +++ b/app/api/Collections.scala @@ -773,7 +773,7 @@ class Collections @Inject() (datasets: DatasetService, // Use a 1MB in memory byte array Ok.chunked(enumeratorFromCollection(collection,1024*1024, compression,bagit,user)).withHeaders( "Content-Type" -> "application/zip", - "Content-Disposition" -> ("attachment; filename=\"" + collection.name+ ".zip\"") + "Content-Disposition" -> ("attachment; filename=\"" + collection.name + ".zip\"") ) } // If the dataset wasn't found by ID diff --git a/app/api/Comments.scala b/app/api/Comments.scala index ae7bda6e8..6a2964529 100644 --- a/app/api/Comments.scala +++ b/app/api/Comments.scala @@ -194,11 +194,11 @@ class Comments @Inject()(datasets: DatasetService, comments: CommentService, eve PermissionAction(Permission.AddComment, Some(ResourceRef(Symbol(resourceType), resourceID))) { users.get(commenterId) match { case Some(u) => { - events.addRequestEvent(users.get(userid), u, resourceID, resourceName, "mention_"+resourceType+"_comment") + events.addRequestEvent(users.get(userid), u, resourceID, resourceName, "mention_" + resourceType + "_comment") Ok(s"Mention event added to user id $userid's feed") } case None => { - events.addObjectEvent(users.get(userid), resourceID, resourceName, "mention_"+resourceType+"_comment") + events.addObjectEvent(users.get(userid), resourceID, resourceName, "mention_" + resourceType + "_comment") Ok(s"Mention event added to user id $userid's feed") } } diff --git a/app/api/CurationObjects.scala b/app/api/CurationObjects.scala index 5a35d766d..323d4068e 100644 --- a/app/api/CurationObjects.scala +++ b/app/api/CurationObjects.scala @@ -50,8 +50,8 @@ class CurationObjects @Inject()(datasets: DatasetService, } var tempMap = Map( - "Identifier" -> Json.toJson("urn:uuid:"+file.id), - "@id" -> Json.toJson("urn:uuid:"+file.id), + "Identifier" -> Json.toJson("urn:uuid:" + file.id), + "@id" -> Json.toJson("urn:uuid:" + file.id), "Creation Date" -> Json.toJson(format.format(file.uploadDate)), "Label" -> Json.toJson(file.filename), "Title" -> Json.toJson(file.filename), @@ -75,16 +75,16 @@ class CurationObjects @Inject()(datasets: DatasetService, } val foldersJson = curations.getCurationFolders(curations.getAllCurationFolderIds(c.id)).map { folder => - val hasPart = folder.files.map(file=>"urn:uuid:"+file) ++ folder.folders.map(fd => "urn:uuid:"+fd) + val hasPart = folder.files.map(file=>"urn:uuid:" + file) ++ folder.folders.map(fd => "urn:uuid:" + fd) val tempMap = Map( "Creation Date" -> Json.toJson(format.format(folder.created)), "Rights" -> Json.toJson(c.datasets(0).licenseData.m_licenseText), - "Identifier" -> Json.toJson("urn:uuid:"+folder.id), + "Identifier" -> Json.toJson("urn:uuid:" + folder.id), "License" -> Json.toJson(c.datasets(0).licenseData.m_licenseText), "Label" -> Json.toJson(folder.name), "Title" -> Json.toJson(folder.displayName), "Uploaded By" -> Json.toJson(folder.author.fullName + ": " + api.routes.Users.findById(folder.author.id).absoluteURL(https)), - "@id" -> Json.toJson("urn:uuid:"+folder.id), + "@id" -> Json.toJson("urn:uuid:" + folder.id), "@type" -> Json.toJson(Seq("AggregatedResource", "http://cet.ncsa.uiuc.edu/2016/Folder")), "Is Version Of" -> Json.toJson(controllers.routes.Datasets.dataset(c.datasets(0).id).absoluteURL(https) +"#folderId=" +folder.folderId), "Has Part" -> Json.toJson(hasPart) @@ -92,7 +92,7 @@ class CurationObjects @Inject()(datasets: DatasetService, tempMap } - val hasPart = c.files.map(file => "urn:uuid:"+file) ++ c.folders.map(folder => "urn:uuid:"+folder) + val hasPart = c.files.map(file => "urn:uuid:" + file) ++ c.folders.map(folder => "urn:uuid:" + folder) var commentsByDataset = comments.findCommentsByDatasetId(c.datasets(0).id) curations.getCurationFiles(curations.getAllCurationFileIds(c.id)).map { file => @@ -106,7 +106,7 @@ class CurationObjects @Inject()(datasets: DatasetService, Json.toJson(Map( "comment_body" -> Json.toJson(comm.text), "comment_date" -> Json.toJson(format.format(comm.posted)), - "Identifier" -> Json.toJson("urn:uuid:"+comm.id), + "Identifier" -> Json.toJson("urn:uuid:" + comm.id), "comment_author" -> Json.toJson(userService.findById(comm.author.id).map ( usr => Json.toJson(usr.fullName + ": " + api.routes.Users.findById(usr.id).absoluteURL(https)))) )) } diff --git a/app/api/Datasets.scala b/app/api/Datasets.scala index dee4c39e3..ba9b737c2 100644 --- a/app/api/Datasets.scala +++ b/app/api/Datasets.scala @@ -2139,8 +2139,8 @@ class Datasets @Inject()( var is: Option[InputStream] = addDatasetInfoToZip(dataFolder,dataset,zip) //digest input stream val md5 = MessageDigest.getInstance("MD5") - md5Files.put(dataFolder+"_info.json",md5) - is = Some(new DigestInputStream(is.get,md5)) + md5Files.put(dataFolder + "_info.json", md5) + is = Some(new DigestInputStream(is.get, md5)) file_type = 1 //next is metadata @@ -2163,7 +2163,7 @@ class Datasets @Inject()( case (0,0) => { is = addDatasetInfoToZip(dataFolder,dataset,zip) val md5 = MessageDigest.getInstance("MD5") - md5Files.put("_info.json",md5) + md5Files.put("_info.json", md5) is = Some(new DigestInputStream(is.get, md5)) file_type = file_type + 1 } @@ -2171,7 +2171,7 @@ class Datasets @Inject()( case (0,1) => { is = addDatasetMetadataToZip(dataFolder,dataset,zip) val md5 = MessageDigest.getInstance("MD5") - md5Files.put("_metadata.json",md5) + md5Files.put("_metadata.json", md5) is = Some(new DigestInputStream(is.get, md5)) level = 1 file_type = 0 @@ -2180,10 +2180,10 @@ class Datasets @Inject()( case (1,0) =>{ is = addFileInfoToZip(filenameMap(inputFiles(count).id), inputFiles(count), zip) val md5 = MessageDigest.getInstance("MD5") - md5Files.put(filenameMap(inputFiles(count).id)+"_info.json",md5) + md5Files.put(filenameMap(inputFiles(count).id) + "_info.json",md5) is = Some(new DigestInputStream(is.get, md5)) - if (count+1 < inputFiles.size ){ - count +=1 + if (count + 1 < inputFiles.size){ + count += 1 } else { count = 0 file_type = 1 @@ -2193,10 +2193,10 @@ class Datasets @Inject()( case (1,1) =>{ is = addFileMetadataToZip(filenameMap(inputFiles(count).id), inputFiles(count), zip) val md5 = MessageDigest.getInstance("MD5") - md5Files.put(filenameMap(inputFiles(count).id)+"_metadata.json",md5) + md5Files.put(filenameMap(inputFiles(count).id) + "_metadata.json",md5) is = Some(new DigestInputStream(is.get, md5)) - if (count+1 < inputFiles.size ){ - count +=1 + if (count + 1 < inputFiles.size){ + count += 1 } else { count = 0 file_type = 2 @@ -2208,8 +2208,8 @@ class Datasets @Inject()( val md5 = MessageDigest.getInstance("MD5") md5Files.put(filenameMap(inputFiles(count).id),md5) is = Some(new DigestInputStream(is.get, md5)) - if (count+1 < inputFiles.size ){ - count +=1 + if (count + 1 < inputFiles.size ){ + count += 1 } else { if (bagit){ count = 0 @@ -2227,7 +2227,7 @@ class Datasets @Inject()( case (2,0) => { is = addBagItTextToZip(totalBytes,filenameMap.size,zip,dataset,user) val md5 = MessageDigest.getInstance("MD5") - md5Bag.put("bagit.txt",md5) + md5Bag.put("bagit.txt", md5) is = Some(new DigestInputStream(is.get, md5)) file_type = 1 } @@ -2235,7 +2235,7 @@ class Datasets @Inject()( case (2,1) => { is = addBagInfoToZip(zip) val md5 = MessageDigest.getInstance("MD5") - md5Bag.put("bag-info.txt",md5) + md5Bag.put("bag-info.txt", md5) is = Some(new DigestInputStream(is.get, md5)) file_type = 2 } @@ -2243,7 +2243,7 @@ class Datasets @Inject()( case (2,2) => { is = addManifestMD5ToZip(md5Files.toMap[String,MessageDigest],zip) val md5 = MessageDigest.getInstance("MD5") - md5Bag.put("manifest-md5.txt",md5) + md5Bag.put("manifest-md5.txt", md5) is = Some(new DigestInputStream(is.get, md5)) file_type = 3 } @@ -2251,7 +2251,7 @@ class Datasets @Inject()( case (2,3) => { is = addTagManifestMD5ToZip(md5Bag.toMap[String,MessageDigest],zip) val md5 = MessageDigest.getInstance("MD5") - md5Bag.put("tagmanifest-md5.txt",md5) + md5Bag.put("tagmanifest-md5.txt", md5) is = Some(new DigestInputStream(is.get, md5)) level = -1 file_type = -1 @@ -2371,18 +2371,18 @@ class Datasets @Inject()( private def addBagItTextToZip(totalbytes: Long, totalFiles: Long, zip: ZipOutputStream, dataset: models.Dataset, user: Option[models.User]) = { zip.putNextEntry(new ZipEntry("bagit.txt")) val softwareLine = "Bag-Software-Agent: clowder.ncsa.illinois.edu\n" - val baggingDate = "Bagging-Date: "+(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(Calendar.getInstance.getTime)+"\n" + val baggingDate = "Bagging-Date: " + (new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(Calendar.getInstance.getTime) + "\n" val baggingSize = "Bag-Size: " + _root_.util.Formatters.humanReadableByteCount(totalbytes) + "\n" - val payLoadOxum = "Payload-Oxum: "+ totalbytes + "." + totalFiles +"\n" - val senderIdentifier="Internal-Sender-Identifier: "+dataset.id+"\n" - val senderDescription = "Internal-Sender-Description: "+dataset.description+"\n" + val payLoadOxum = "Payload-Oxum: " + totalbytes + "." + totalFiles + "\n" + val senderIdentifier="Internal-Sender-Identifier: " + dataset.id + "\n" + val senderDescription = "Internal-Sender-Description: " + dataset.description + "\n" var s:String = "" if (user.isDefined) { val contactName = "Contact-Name: " + user.get.fullName + "\n" val contactEmail = "Contact-Email: " + user.get.email.getOrElse("") + "\n" - s = softwareLine+baggingDate+baggingSize+payLoadOxum+contactName+contactEmail+senderIdentifier+senderDescription + s = softwareLine + baggingDate + baggingSize + payLoadOxum + contactName + contactEmail + senderIdentifier + senderDescription } else { - s = softwareLine+baggingDate+baggingSize+payLoadOxum+senderIdentifier+senderDescription + s = softwareLine + baggingDate + baggingSize + payLoadOxum + senderIdentifier + senderDescription } Some(new ByteArrayInputStream(s.getBytes("UTF-8"))) @@ -2390,7 +2390,7 @@ class Datasets @Inject()( private def addBagInfoToZip(zip : ZipOutputStream) : Option[InputStream] = { zip.putNextEntry(new ZipEntry("bag-info.txt")) - val s : String = "BagIt-Version: 0.97\n"+"Tag-File-Character-Encoding: UTF-8\n" + val s : String = "BagIt-Version: 0.97\n" + "Tag-File-Character-Encoding: UTF-8\n" Some(new ByteArrayInputStream(s.getBytes("UTF-8"))) } @@ -2399,7 +2399,7 @@ class Datasets @Inject()( var s : String = "" md5map.foreach{ case (filePath,md) => { - val current = Hex.encodeHexString(md.digest())+" "+filePath+"\n" + val current = Hex.encodeHexString(md.digest()) + " " + filePath + "\n" s = s + current } } @@ -2411,7 +2411,7 @@ class Datasets @Inject()( var s : String = "" md5map.foreach{ case (filePath,md) => { - val current = Hex.encodeHexString(md.digest())+" "+filePath+"\n" + val current = Hex.encodeHexString(md.digest()) + " " + filePath + "\n" s = s + current } } @@ -2432,7 +2432,7 @@ class Datasets @Inject()( // Use a 1MB in memory byte array Ok.chunked(enumeratorFromDataset(dataset,1024*1024, compression,bagit,user)).withHeaders( CONTENT_TYPE -> "application/zip", - CONTENT_DISPOSITION -> (FileUtils.encodeAttachment(dataset.name+ ".zip", request.headers.get("user-agent").getOrElse(""))) + CONTENT_DISPOSITION -> (FileUtils.encodeAttachment(dataset.name + ".zip", request.headers.get("user-agent").getOrElse(""))) ) } // If the dataset wasn't found by ID @@ -2520,13 +2520,13 @@ class Datasets @Inject()( case None => BadRequest(s"Unable to copy the dataset with id $datasetId to space with id: $spaceId") } } - case None => BadRequest(s"No space found with id: + $spaceId.") + case None => BadRequest(s"No space found with id: $spaceId.") } } else { BadRequest("You don't have permission to copy the dataset.") } } - case None => BadRequest(s"No dataset found with id: $datasetId") + case None => BadRequest(s"No dataset found with id: $datasetId") } } case None => BadRequest("You need to be logged in to copy a dataset to a space.") diff --git a/app/api/Events.scala b/app/api/Events.scala index cbd693ee5..9e420244a 100644 --- a/app/api/Events.scala +++ b/app/api/Events.scala @@ -31,10 +31,10 @@ class Events @Inject() (events: EventService, val ex = (request.body \ "exceptions").asOpt[String].getOrElse("Non-tracked exceptions") val subject: String = "Exception from " + AppConfiguration.getDisplayName val body = Html("

URL: " + Utils.baseUrl(request) + "

\n" + - "

Version: " + sys.props.getOrElse("build.version", default = "0.0.0") + "#"+sys.props.getOrElse("build.bamboo", default = "development") + - " branch:" + sys.props.getOrElse("build.branch", default = "unknown") +" sha1:"+sys.props.getOrElse("build.gitsha1", default = "unknown")+"

\n" + - "

Request: "+re+"

\n" + - "

Error: "+ex+"

") + "

Version: " + sys.props.getOrElse("build.version", default = "0.0.0") + "#" + sys.props.getOrElse("build.bamboo", default = "development") + + " branch:" + sys.props.getOrElse("build.branch", default = "unknown") +" sha1:" + sys.props.getOrElse("build.gitsha1", default = "unknown") + "

\n" + + "

Request: " + re + "

\n" + + "

Error: " + ex + "

") val recipient: String = "opensource+clowder@ncsa.illinois.edu" Mail.sendEmail(subject, request.user, recipient, body) Ok(toJson("Send Email success")) diff --git a/app/api/Extractions.scala b/app/api/Extractions.scala index 2d03810b4..3f133a074 100644 --- a/app/api/Extractions.scala +++ b/app/api/Extractions.scala @@ -646,7 +646,7 @@ class Extractions @Inject()( _.fileSetAddedToDataset(ds, filelist.toList, Utils.baseUrl(request), request.apiKey) } } - case None => BadRequest(toJson("Dataset "+datasetid+" not found")) + case None => BadRequest(toJson("Dataset " + datasetid + " not found")) } Ok(toJson("added new event")) diff --git a/app/api/Folders.scala b/app/api/Folders.scala index 7c0d43e69..3631f38e2 100644 --- a/app/api/Folders.scala +++ b/app/api/Folders.scala @@ -333,7 +333,7 @@ class Folders @Inject() ( } } - case None => BadRequest("Failed to copy the file. The destination folder doesn't exist. New folder Id: "+ newFolderId) + case None => BadRequest("Failed to copy the file. The destination folder doesn't exist. New folder Id: " + newFolderId) } } diff --git a/app/api/Geostreams.scala b/app/api/Geostreams.scala index 5877625e7..3d129d36e 100644 --- a/app/api/Geostreams.scala +++ b/app/api/Geostreams.scala @@ -1336,7 +1336,7 @@ object Geostreams extends ApiController { var index = 0 while (index < points.length - 1) { val lat = Parsers.parseDouble(points(index)) - val lon = Parsers.parseDouble(points(index+1)) + val lon = Parsers.parseDouble(points(index + 1)) if (lat.isDefined && lon.isDefined) { coordinates += Json.toJson(Array(lon.get, lat.get)) } diff --git a/app/api/Reporting.scala b/app/api/Reporting.scala index cbc266806..06601774c 100644 --- a/app/api/Reporting.scala +++ b/app/api/Reporting.scala @@ -160,13 +160,13 @@ class Reporting @Inject()(selections: SelectionService, } contents += "\"space\"," - contents += "\""+sp.id.toString+"\"," - contents += "\""+sp.name.replace("\"", "\"\"")+"\"," - contents += "\""+sp.description.replace("\"", "\"\"")+"\"," - contents += "\""+creator_id+"\"," - contents += dateFormat.format(sp.created)+"," - contents += sp.datasetCount.toString+"," - contents += sp.collectionCount.toString+"," + contents += "\"" + sp.id.toString + "\"," + contents += "\"" + sp.name.replace("\"", "\"\"") + "\"," + contents += "\"" + sp.description.replace("\"", "\"\"") + "\"," + contents += "\"" + creator_id + "\"," + contents += dateFormat.format(sp.created) + "," + contents += sp.datasetCount.toString + "," + contents += sp.collectionCount.toString + "," contents += sp.userCount.toString contents += "\n" }) @@ -197,22 +197,22 @@ class Reporting @Inject()(selections: SelectionService, }) contents += "\"user\"," - contents += "\""+u.id.toString+"\"," - contents += "\""+u.getMiniUser.fullName+"\"," - contents += "\""+u.email.getOrElse("")+"\"," - contents += "\""+u.identityId.providerId+"\"," + contents += "\"" + u.id.toString + "\"," + contents += "\"" + u.getMiniUser.fullName + "\"," + contents += "\"" + u.email.getOrElse("") + "\"," + contents += "\"" + u.identityId.providerId + "\"," u.lastLogin match { case Some(lastdate) => { - contents += dateFormat.format(lastdate)+"," + contents += dateFormat.format(lastdate) + "," val currdate = new Date val difference = (currdate.getTime()-currdate.getTime())/86400000 - contents += Math.abs(difference).toString+"," + contents += Math.abs(difference).toString + "," } case None => contents += ",," } - contents += (if (u.status==UserStatus.Inactive) "false" else "true")+"," - contents += (if (u.status==UserStatus.Admin) "true" else "false")+"," - contents += admin_spaces.toString+"," + contents += (if (u.status==UserStatus.Inactive) "false" else "true") + "," + contents += (if (u.status==UserStatus.Admin) "true" else "false") + "," + contents += admin_spaces.toString + "," contents += member_spaces.toString contents += "\n" }) @@ -268,20 +268,20 @@ class Reporting @Inject()(selections: SelectionService, } contents += "\"file\"," - contents += "\""+f.id.toString+"\"," - contents += "\""+f.filename+"\"," - contents += "\""+f.author.fullName+"\"," - contents += "\""+f.author.id+"\"," - contents += (f.length/1000).toInt.toString+"," - contents += dateFormat.format(f.uploadDate)+"," - contents += vwcount+"," - contents += dlcount+"," - contents += lvstr+"," - contents += ldstr+"," - contents += "\""+f.loader_id+"\"," - contents += "\""+ds_list+"\"," - contents += "\""+coll_list+"\"," - contents += "\""+space_list+"\"" + contents += "\"" + f.id.toString + "\"," + contents += "\"" + f.filename + "\"," + contents += "\"" + f.author.fullName + "\"," + contents += "\"" + f.author.id + "\"," + contents += (f.length/1000).toInt.toString + "," + contents += dateFormat.format(f.uploadDate) + "," + contents += vwcount + "," + contents += dlcount + "," + contents += lvstr + "," + contents += ldstr + "," + contents += "\"" + f.loader_id + "\"," + contents += "\"" + ds_list + "\"," + contents += "\"" + coll_list + "\"," + contents += "\"" + space_list + "\"" contents += "\n" return contents @@ -322,20 +322,20 @@ class Reporting @Inject()(selections: SelectionService, } contents += "\"dataset\"," - contents += "\""+ds.id.toString+"\"," - contents += "\""+ds.name.replace("\"", "\"\"")+"\"," - contents += "\""+ds.author.fullName+"\"," - contents += "\""+ds.author.id+"\"," + contents += "\"" + ds.id.toString + "\"," + contents += "\"" + ds.name.replace("\"", "\"\"") + "\"," + contents += "\"" + ds.author.fullName + "\"," + contents += "\"" + ds.author.id + "\"," if (returnAllColums) contents += "," // datasets do not have size - contents += dateFormat.format(ds.created)+"," - contents += vwcount+"," - contents += dlcount+"," - contents += lvstr+"," - contents += ldstr+"," + contents += dateFormat.format(ds.created) + "," + contents += vwcount + "," + contents += dlcount + "," + contents += lvstr + "," + contents += ldstr + "," if (returnAllColums) contents += "," // datasets do not have location if (returnAllColums) contents += "," // datasets do not have parent_datasets - contents += "\""+coll_list+"\"," - contents += "\""+space_list+"\"" + contents += "\"" + coll_list + "\"," + contents += "\"" + space_list + "\"" contents += "\n" return contents @@ -370,20 +370,20 @@ class Reporting @Inject()(selections: SelectionService, } contents += "\"collection\"," - contents += "\""+coll.id.toString+"\"," - contents += "\""+coll.name.replace("\"", "\"\"")+"\"," - contents += "\""+coll.author.fullName+"\"," - contents += "\""+coll.author.id+"\"," + contents += "\"" + coll.id.toString + "\"," + contents += "\"" + coll.name.replace("\"", "\"\"") + "\"," + contents += "\"" + coll.author.fullName + "\"," + contents += "\"" + coll.author.id + "\"," if (returnAllColums) contents += "," // collections do not have size - contents += dateFormat.format(coll.created)+"," - contents += vwcount+"," + contents += dateFormat.format(coll.created) + "," + contents += vwcount + "," if (returnAllColums) contents += "," // collections do not have downloads - contents += lvstr+"," + contents += lvstr + "," if (returnAllColums) contents += "," // collections do not have last_downloaded if (returnAllColums) contents += "," // collections do not have location if (returnAllColums) contents += "," // collections do not have parent_datasets - contents += "\""+coll_list+"\"," - contents += "\""+space_list+"\"" + contents += "\"" + coll_list + "\"," + contents += "\"" + space_list + "\"" contents += "\n" return contents diff --git a/app/controllers/Collections.scala b/app/controllers/Collections.scala index 059417e36..02f3f45d5 100644 --- a/app/controllers/Collections.scala +++ b/app/controllers/Collections.scala @@ -376,7 +376,7 @@ class Collections @Inject() (datasets: DatasetService, collections: CollectionSe } // view the list of collection in a space that you should not access case Some(s) if !Permission.checkPermission(Permission.ViewSpace, ResourceRef(ResourceRef.space, UUID(s))) => { - BadRequest(views.html.notAuthorized("You are not authorized to access the " + spaceTitle+ ".", s, "space")) + BadRequest(views.html.notAuthorized("You are not authorized to access the " + spaceTitle + ".", s, "space")) } case _ => Ok(views.html.collectionList(decodedCollections.toList, prev, next, limit, viewMode, space, spaceName, title, owner, ownerName, when, date, showTrash)) } @@ -581,7 +581,7 @@ class Collections @Inject() (datasets: DatasetService, collections: CollectionSe case Some(collection) => { val datasetsInside = datasets.listCollection(id.stringify, user) - val datasetIdsToUse = datasetsInside.slice(index*limit, (index+1)*limit) + val datasetIdsToUse = datasetsInside.slice(index*limit, (index + 1) * limit) val decodedDatasetsInside = ListBuffer.empty[models.Dataset] for (aDataset <- datasetIdsToUse) { val dDataset = Utils.decodeDatasetElements(aDataset) @@ -589,7 +589,7 @@ class Collections @Inject() (datasets: DatasetService, collections: CollectionSe } val prev = index-1 - val next = if(datasetsInside.length > (index+1) * limit) { + val next = if(datasetsInside.length > (index + 1) * limit) { index + 1 } else { -1 @@ -604,7 +604,7 @@ class Collections @Inject() (datasets: DatasetService, collections: CollectionSe } - case None => Logger.error("Error getting "+ Messages("collection.title") + " " + id); BadRequest(Messages("collection.title") + " not found") + case None => Logger.error("Error getting " + Messages("collection.title") + " " + id); BadRequest(Messages("collection.title") + " not found") } } @@ -613,12 +613,12 @@ class Collections @Inject() (datasets: DatasetService, collections: CollectionSe collections.get(id) match { case Some(collection) => { val dCollection = Utils.decodeCollectionElements(collection) - val child_ids = dCollection.child_collection_ids.slice(index*limit, (index+1)*limit) + val child_ids = dCollection.child_collection_ids.slice(index * limit, (index + 1) * limit) val decodedChildCollections = collections.get(child_ids).found.map(Utils.decodeCollectionElements(_)) val prev = index-1 - val next = if (dCollection.child_collection_ids.length > (index+1)*limit) - index+1 + val next = if (dCollection.child_collection_ids.length > (index + 1) * limit) + index + 1 else -1 diff --git a/app/controllers/Datasets.scala b/app/controllers/Datasets.scala index 933038032..3b29b561e 100644 --- a/app/controllers/Datasets.scala +++ b/app/controllers/Datasets.scala @@ -645,8 +645,8 @@ class Datasets @Inject() ( (SortingUtils.sortFolders(folder.folders.flatMap(f => folders.get(f)), sortOrder).slice(limit * filepageUpdate, limit * (filepageUpdate + 1)), SortingUtils.sortFiles(files.get(folder.files).found, sortOrder).slice(limit * filepageUpdate - folder.folders.length, limit * (filepageUpdate + 1) - folder.folders.length)) } else { - (folder.folders.reverse.slice(limit * filepageUpdate, limit * (filepageUpdate+1)).flatMap(f => folders.get(f)), - folder.files.reverse.slice(limit * filepageUpdate - folder.folders.length, limit * (filepageUpdate+1) - folder.folders.length).flatMap(f => files.get(f))) + (folder.folders.reverse.slice(limit * filepageUpdate, limit * (filepageUpdate + 1)).flatMap(f => folders.get(f)), + folder.files.reverse.slice(limit * filepageUpdate - folder.folders.length, limit * (filepageUpdate + 1) - folder.folders.length).flatMap(f => files.get(f))) } var folderHierarchy = new ListBuffer[Folder]() folderHierarchy += folder @@ -680,8 +680,8 @@ class Datasets @Inject() ( (SortingUtils.sortFolders(dataset.folders.flatMap(f => folders.get(f)), sortOrder).slice(limit * filepageUpdate, limit * (filepageUpdate + 1)), SortingUtils.sortFiles(files.get(dataset.files).found, sortOrder).slice(limit * filepageUpdate - dataset.folders.length, limit * (filepageUpdate + 1) - dataset.folders.length)) } else { - (dataset.folders.reverse.slice(limit * filepageUpdate, limit * (filepageUpdate+1)).flatMap(f => folders.get(f)), - dataset.files.reverse.slice(limit * filepageUpdate - dataset.folders.length, limit * (filepageUpdate+1) - dataset.folders.length).flatMap(f => files.get(f))) + (dataset.folders.reverse.slice(limit * filepageUpdate, limit * (filepageUpdate + 1)).flatMap(f => folders.get(f)), + dataset.files.reverse.slice(limit * filepageUpdate - dataset.folders.length, limit * (filepageUpdate + 1) - dataset.folders.length).flatMap(f => files.get(f))) } val fileComments = limitFileList.map { file => @@ -765,7 +765,7 @@ class Datasets @Inject() ( Map( "name" -> toJson("Missing " + Messages("dataset.title") + " ID."), "size" -> toJson(0), - "error" -> toJson("No "+ Messages("dataset.title")+"id found. Please try again.") + "error" -> toJson("No " + Messages("dataset.title") + "id found. Please try again.") ) ) ) diff --git a/app/controllers/Files.scala b/app/controllers/Files.scala index c58f5486d..d76c6e43f 100644 --- a/app/controllers/Files.scala +++ b/app/controllers/Files.scala @@ -511,9 +511,9 @@ class Files @Inject() ( val thirdSeparatorIndex = nameOfFile.indexOf("__") if(thirdSeparatorIndex >= 0){ val firstSeparatorIndex = nameOfFile.indexOf("_") - val secondSeparatorIndex = nameOfFile.indexOf("_", firstSeparatorIndex+1) - flags = flags + "+numberofIterations_" + nameOfFile.substring(0,firstSeparatorIndex) + "+heightFactor_" + nameOfFile.substring(firstSeparatorIndex+1,secondSeparatorIndex)+ "+ptm3dDetail_" + nameOfFile.substring(secondSeparatorIndex+1,thirdSeparatorIndex) - nameOfFile = nameOfFile.substring(thirdSeparatorIndex+2) + val secondSeparatorIndex = nameOfFile.indexOf("_", firstSeparatorIndex + 1) + flags = flags + "+numberofIterations_" + nameOfFile.substring(0, firstSeparatorIndex) + "+heightFactor_" + nameOfFile.substring(firstSeparatorIndex + 1, secondSeparatorIndex) + "+ptm3dDetail_" + nameOfFile.substring(secondSeparatorIndex + 1, thirdSeparatorIndex) + nameOfFile = nameOfFile.substring(thirdSeparatorIndex + 2) } } Logger.debug("Uploading file " + nameOfFile) diff --git a/app/controllers/Users.scala b/app/controllers/Users.scala index 948826be3..68f3e743f 100644 --- a/app/controllers/Users.scala +++ b/app/controllers/Users.scala @@ -76,9 +76,9 @@ class Users @Inject() (users: UserService, appConfig: AppConfigurationService) e case Some(clowderUser) => { var followedUsers: List[(models.UUID, String, String, String)] = List.empty val userIds = clowderUser.followedEntities.filter(_.objectType == "user") - val userIdsToUse = userIds.slice(index*limit, (index+1)*limit) - val prev = index -1 - val next = if(userIds.length > (index+1) * limit) { + val userIdsToUse = userIds.slice(index*limit, (index + 1) * limit) + val prev = index - 1 + val next = if(userIds.length > (index + 1) * limit) { index + 1 } else { -1 @@ -152,9 +152,9 @@ class Users @Inject() (users: UserService, appConfig: AppConfigurationService) e user match { case Some(clowderUser) => { var followers: List[(models.UUID, String, String, String)] = List.empty - val followersToUse = clowderUser.followers.slice(index*limit, (index+1)*limit) - val prev = index-1 - val next = if(clowderUser.followers.length > (index+1) * limit) { + val followersToUse = clowderUser.followers.slice(index*limit, (index + 1) * limit) + val prev = index - 1 + val next = if(clowderUser.followers.length > (index + 1) * limit) { index + 1 } else { -1 @@ -190,6 +190,6 @@ class Users @Inject() (users: UserService, appConfig: AppConfigurationService) e def sendEmail(subject: String, from: String, recipient: String, body: String) = AuthenticatedAction { implicit request => util.Mail.sendEmail(subject, from, List(recipient), Html(body)) - Ok("Successfully emailed "+recipient) + Ok("Successfully emailed " + recipient) } } diff --git a/app/services/ElasticsearchPlugin.scala b/app/services/ElasticsearchPlugin.scala index 1925ba01f..582fa08eb 100644 --- a/app/services/ElasticsearchPlugin.scala +++ b/app/services/ElasticsearchPlugin.scala @@ -138,41 +138,41 @@ class ElasticsearchPlugin(application: Application) extends Plugin { // whether to restrict to a particular metadata field, or search all fields (including tags, name, etc.) val mdfield = field match { - case Some(k) => expanded_query = " "+k+":\""+expanded_query+"\"" + case Some(k) => expanded_query = " " + k + ":\"" + expanded_query + "\"" case None => {} } // Restrict to a particular tag - currently requires exact match tag match { - case Some(t) => expanded_query += " tag:"+t + case Some(t) => expanded_query += " tag:" + t case None => {} } // Restrict to particular resource_type if requested resource_type match { - case Some(restype) => expanded_query += " resource_type:"+restype + case Some(restype) => expanded_query += " resource_type:" + restype case None => {} } // Restrict to particular dataset ID (only return files) datasetid match { - case Some(dsid) => expanded_query += " in:"+dsid+" resource_type:file" + case Some(dsid) => expanded_query += " in:" + dsid + " resource_type:file" case None => {} } // Restrict to particular collection ID collectionid match { - case Some(cid) => expanded_query += " in:"+cid + case Some(cid) => expanded_query += " in:" + cid case None => {} } spaceid match { - case Some(spid) => expanded_query += " in:"+spid + case Some(spid) => expanded_query += " in:" + spid case None => {} } folderid match { - case Some(fid) => expanded_query += " in:"+fid + case Some(fid) => expanded_query += " in:" + fid case None => {} } @@ -200,7 +200,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin { Logger.debug(s"Only have ${total_results.length} total results; searching for ${size*2} more from ${new_from}") val (results, total_size) = _search(queryObj, index, Some(new_from), Some(size*2)) Logger.debug(s"Found ${results.length} results with ${total_size} total") - if (results.length == 0 || new_from+results.length == total_size) exhausted = true // No more results to find + if (results.length == 0 || new_from + results.length == total_size) exhausted = true // No more results to find val filtered = checkResultPermissions(results, user) Logger.debug(s"Permission to see ${filtered.length} results") var still_scanning = true @@ -266,7 +266,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin { connect() val response = client match { case Some(x) => { - Logger.info("Searching Elasticsearch: "+queryObj.string()) + Logger.info("Searching Elasticsearch: " + queryObj.string()) var responsePrep = x.prepareSearch(index) .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setQuery(queryObj) @@ -290,7 +290,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin { } - /** Create a new index with preconfigured mappgin */ + /** Create a new index with pre-configured mapping */ def createIndex(index: String = nameOfIndex): Unit = { val indexSettings = Settings.settingsBuilder().loadFromSource(jsonBuilder() .startObject() @@ -310,7 +310,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin { client match { case Some(x) => { - Logger.debug("Index \""+index+"\" does not exist; creating now ---") + Logger.debug("Index \"" + index + "\" does not exist; creating now ---") try { x.admin().indices().prepareCreate(index) .setSettings(indexSettings) @@ -533,7 +533,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin { .setSize(0) // Filter to tags on a particular type of resource if given if (resourceType != "") - searcher.setQuery(prepareElasticJsonQuery("resource_type:"+resourceType+"", List.empty)) + searcher.setQuery(prepareElasticJsonQuery("resource_type:" + resourceType + "", List.empty)) else { // Exclude Section tags to avoid double-counting since those are duplicated in File document searcher.setQuery(prepareElasticJsonQuery("resource_type:file|dataset|collection", List.empty)) @@ -641,7 +641,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin { var longKey = (parentKey match { case Some(pk) => { if (pk contains "metadata") - pk+'.'+k + pk + '.' + k else k } case None => k @@ -649,10 +649,10 @@ class ElasticsearchPlugin(application: Application) extends Plugin { // Remove ignored fields ignoredFields.foreach(ig => { - if (longKey.indexOf("."+ig+".") > -1) - longKey = longKey.replace("."+ig+".", ".") - if (longKey.endsWith("."+ig)) - longKey = longKey.stripSuffix("."+ig) + if (longKey.indexOf("." + ig + ".") > -1) + longKey = longKey.replace("." + ig + ".", ".") + if (longKey.endsWith("." + ig)) + longKey = longKey.stripSuffix("." + ig) } ) @@ -847,7 +847,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin { var currterm = "" matches.foreach(mt => { // Determine if the string was a key or value - if (query.contains(mt+":") || query.contains("\""+mt+"\":")) { + if (query.contains(mt + ":") || query.contains("\"" + mt + "\":")) { // Do some user-friendly replacement if (mt == "tag") currterm += "tags:" @@ -856,15 +856,15 @@ class ElasticsearchPlugin(application: Application) extends Plugin { else if (mt == "contains") currterm += "parent_of:" else if (!official_terms.contains(mt)) - currterm += "metadata."+mt+":" + currterm += "metadata." + mt + ":" else - currterm += mt+":" - } else if (query.contains(":"+mt) || query.contains(":\""+mt+"\"")) { + currterm += mt + ":" + } else if (query.contains(":" + mt) || query.contains(":\"" + mt + "\"")) { currterm += mt.toLowerCase() terms += currterm currterm = "" } else { - terms += "_all:"+mt.toLowerCase() + terms += "_all:" + mt.toLowerCase() } }) @@ -876,7 +876,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin { for (operator <- mustOperators) { if (term.contains(operator)) { val key = term.substring(0, term.indexOf(operator)) - val value = term.substring(term.indexOf(operator)+1, term.length) + val value = term.substring(term.indexOf(operator) + 1, term.length) // Only add a MUST object if we have terms to populate it; empty objects break Elasticsearch if (mustOperators.contains(operator) && !populatedMust) { diff --git a/app/services/FileDumpService.scala b/app/services/FileDumpService.scala index fa8c881e8..58869a62e 100644 --- a/app/services/FileDumpService.scala +++ b/app/services/FileDumpService.scala @@ -45,7 +45,7 @@ class FileDumpService(application: Application) extends Plugin { fileDumpDir match { case Some(dumpDir) => { val fileSep = System.getProperty("file.separator") - val filePathInDirs = fileDump.fileId.charAt(fileDump.fileId.length()-3)+ fileSep + fileDump.fileId.charAt(fileDump.fileId.length()-2)+fileDump.fileId.charAt(fileDump.fileId.length()-1)+ fileSep + fileDump.fileId + fileSep + fileDump.fileName + val filePathInDirs = fileDump.fileId.charAt(fileDump.fileId.length() - 3) + fileSep + fileDump.fileId.charAt(fileDump.fileId.length() - 2) + fileDump.fileId.charAt(fileDump.fileId.length() - 1) + fileSep + fileDump.fileId + fileSep + fileDump.fileName val fileDumpingDir = dumpDir + filePathInDirs val copiedFile = new File(fileDumpingDir) FileUtils.copyFile(fileDump.fileToDump, copiedFile) diff --git a/app/services/PostgresPlugin.scala b/app/services/PostgresPlugin.scala index 571212f89..de00e3805 100644 --- a/app/services/PostgresPlugin.scala +++ b/app/services/PostgresPlugin.scala @@ -160,14 +160,14 @@ class PostgresPlugin(application: Application) extends Plugin { val data = Json.stringify(f._4) val geojson = f._5 - ps.setTimestamp(index+1, new Timestamp(start.getTime)) + ps.setTimestamp(index + 1, new Timestamp(start.getTime)) if (end.isDefined) - ps.setTimestamp(index+2, new Timestamp(end.get.getTime)) + ps.setTimestamp(index + 2, new Timestamp(end.get.getTime)) else - ps.setDate(index+2, null) - ps.setInt(index+3, stream_id.toInt) - ps.setString(index+4, data) - ps.setString(index+5, Json.stringify(geojson)) + ps.setDate(index + 2, null) + ps.setInt(index + 3, stream_id.toInt) + ps.setString(index + 4, data) + ps.setString(index + 5, Json.stringify(geojson)) index += 5 }) @@ -240,7 +240,7 @@ class PostgresPlugin(application: Application) extends Plugin { if (sensor_name.isDefined) st.setString(i + 4, sensor_name.getOrElse("")) } else if ((parts.length >= 6) && (parts.length % 2 == 0)) { while (i < parts.length) { - st.setDouble(i + 1, parts(i+1).toDouble) + st.setDouble(i + 1, parts(i + 1).toDouble) st.setDouble(i + 2, parts(i).toDouble) i += 2 } @@ -567,7 +567,7 @@ class PostgresPlugin(application: Application) extends Plugin { } } else if ((parts.length >= 6) && (parts.length % 2 == 0)) { while (i < parts.length) { - st.setDouble(i + 1, parts(i+1).toDouble) + st.setDouble(i + 1, parts(i + 1).toDouble) st.setDouble(i + 2, parts(i).toDouble) i += 2 } @@ -808,7 +808,7 @@ class PostgresPlugin(application: Application) extends Plugin { } else if ((parts.length >= 6) && (parts.length % 2 == 0)) { var j = 0 while (j < parts.length) { - st.setDouble(i + 1, parts(j+1).toDouble) + st.setDouble(i + 1, parts(j + 1).toDouble) st.setDouble(i + 2, parts(j).toDouble) i += 2 j += 2 diff --git a/app/services/RDFExportService.scala b/app/services/RDFExportService.scala index 1b1e8232f..fba92515f 100644 --- a/app/services/RDFExportService.scala +++ b/app/services/RDFExportService.scala @@ -69,7 +69,7 @@ class RDFExportService (application: Application) extends Plugin { if(!theJSON.replaceAll(" ","").equals("{}")){ val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_" + mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) xmlFile.delete() } else{ @@ -128,7 +128,7 @@ class RDFExportService (application: Application) extends Plugin { if(!theJSON.replaceAll(" ","").equals("{}")){ val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_" + mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) xmlFile.delete() } else{ @@ -191,14 +191,14 @@ class RDFExportService (application: Application) extends Plugin { var currEnd = -1 var xmlNoSpaces = "" while(currStart != -1){ - xmlNoSpaces = xmlNoSpaces + xml.substring(currEnd+1,currStart) - currEnd = xml.indexOf(">", currStart+1) - xmlNoSpaces = xmlNoSpaces + xml.substring(currStart,currEnd+1).replaceAll(" ", "_") - currStart = xml.indexOf("<", currEnd+1) + xmlNoSpaces = xmlNoSpaces + xml.substring(currEnd + 1,currStart) + currEnd = xml.indexOf(">", currStart + 1) + xmlNoSpaces = xmlNoSpaces + xml.substring(currStart,currEnd + 1).replaceAll(" ", "_") + currStart = xml.indexOf("<", currEnd + 1) } - xmlNoSpaces = xmlNoSpaces + xml.substring(currEnd+1) + xmlNoSpaces = xmlNoSpaces + xml.substring(currEnd + 1) - val xmlFile = java.io.File.createTempFile("xml",".xml") + val xmlFile = java.io.File.createTempFile("xml", ".xml") val fileWriter = new BufferedWriter(new FileWriter(xmlFile)) fileWriter.write(xmlNoSpaces) fileWriter.close() diff --git a/app/services/RDFUpdateService.scala b/app/services/RDFUpdateService.scala index 57cf7d55b..9c1d6e91a 100644 --- a/app/services/RDFUpdateService.scala +++ b/app/services/RDFUpdateService.scala @@ -84,7 +84,7 @@ class RDFUpdateService(application: Application) extends Plugin { if(!theJSON.replaceAll(" ","").equals("{}")){ val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + new LidoToCidocConvertion(play.api.Play.configuration.getString("filesxmltordfmapping.dir_" + mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) xmlFile.delete() } else{ @@ -140,9 +140,9 @@ class RDFUpdateService(application: Application) extends Plugin { } if(isInRootNodes){ - val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"")+1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"")+1)) + val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"") + 1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"") + 1)) val theHost = "http://" + play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") - var connection = "" fileWriter.write(connection) @@ -183,7 +183,7 @@ class RDFUpdateService(application: Application) extends Plugin { if(!theJSON.replaceAll(" ","").equals("{}")){ val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_" + mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) xmlFile.delete() } else{ @@ -239,9 +239,9 @@ class RDFUpdateService(application: Application) extends Plugin { } if(isInRootNodes){ - val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"")+1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"")+1)) + val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"") + 1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"") + 1)) val theHost = "http://" + play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") - var connection = "" fileWriter.write(connection) diff --git a/app/services/RabbitmqPlugin.scala b/app/services/RabbitmqPlugin.scala index fe25e0b52..4a95cb24f 100644 --- a/app/services/RabbitmqPlugin.scala +++ b/app/services/RabbitmqPlugin.scala @@ -118,7 +118,7 @@ class RabbitmqPlugin(application: Application) extends Plugin { rabbitmquri = configuration.getString("clowder.rabbitmq.uri").getOrElse("amqp://guest:guest@localhost:5672/%2f") exchange = configuration.getString("clowder.rabbitmq.exchange").getOrElse("clowder") mgmtPort = configuration.getString("clowder.rabbitmq.managmentPort").getOrElse("15672") - Logger.debug("uri= "+ rabbitmquri) + Logger.debug("uri= " + rabbitmquri) try { val uri = new URI(rabbitmquri) @@ -203,7 +203,7 @@ class RabbitmqPlugin(application: Application) extends Plugin { connection = Some(factory.get.newConnection()) channel = Some(connection.get.createChannel()) - Logger.debug("vhost: "+ vhost) + Logger.debug("vhost: " + vhost) // setup exchange if provided if (exchange != "") { @@ -220,7 +220,7 @@ class RabbitmqPlugin(application: Application) extends Plugin { queueBindingsFuture map { x => implicit val bindingsReader = Json.reads[Binding] bindings = x.json.as[List[Binding]] - Logger.debug("Bindings successufully retrieved") + Logger.debug("Bindings successfully retrieved") } Await.result(queueBindingsFuture, 5000 millis) @@ -388,10 +388,10 @@ class RabbitmqPlugin(application: Application) extends Plugin { // While the routing key includes the instance name the rabbitmq bindings has a *. // TODO this code could be improved by having less options in how routes and keys are represented val fragments = routingKey.split('.') - val key1 = "*."+fragments.slice(1,fragments.size).mkString(".") - val key2 = "*."+fragments.slice(1,fragments.size - 1).mkString(".") + ".#" - val key3 = "*."+fragments(1)+".#" - val key4 = "*."+fragments.slice(1,fragments.size).mkString(".") + ".#" + val key1 = "*." + fragments.slice(1,fragments.size).mkString(".") + val key2 = "*." + fragments.slice(1,fragments.size - 1).mkString(".") + ".#" + val key3 = "*." + fragments(1) + ".#" + val key4 = "*." + fragments.slice(1,fragments.size).mkString(".") + ".#" bindings.filter(x => Set(key1, key2, key3, key4).contains(x.routing_key)).map(_.destination) } @@ -771,7 +771,7 @@ class RabbitmqPlugin(application: Application) extends Plugin { * @param host */ def submitSectionPreviewManually(preview: Preview, sectionId: UUID, host: String, requestAPIKey: Option[String]): Unit = { - val routingKey = exchange + ".index."+ contentTypeToRoutingKey(preview.contentType) + val routingKey = exchange + ".index." + contentTypeToRoutingKey(preview.contentType) val apiKey = requestAPIKey.getOrElse(globalAPIKey) val extraInfo = Map("section_id"->sectionId) val source = Entity(ResourceRef(ResourceRef.preview, preview.id), None, JsObject(Seq.empty)) @@ -794,7 +794,7 @@ class RabbitmqPlugin(application: Application) extends Plugin { restURL match { case Some(x) => { val url = x + path - Logger.trace("RESTURL: "+ url) + Logger.trace("RESTURL: " + url) WS.url(url).withHeaders("Accept" -> MimeTypes.JSON).withAuth(username, password, AuthScheme.BASIC).get() } case None => { @@ -817,7 +817,7 @@ class RabbitmqPlugin(application: Application) extends Plugin { */ def getQueuesNamesForAnExchange(exchange: String): Future[Response] = { connect - getRestEndPoint("/api/exchanges/"+ vhost +"/"+ exchange +"/bindings/source") + getRestEndPoint("/api/exchanges/" + vhost + "/" + exchange + "/bindings/source") } /** diff --git a/app/services/SecureSocialEventListener.scala b/app/services/SecureSocialEventListener.scala index ac7ae9ec2..e1a129151 100644 --- a/app/services/SecureSocialEventListener.scala +++ b/app/services/SecureSocialEventListener.scala @@ -24,7 +24,7 @@ class SecureSocialEventListener(app: play.api.Application) extends EventListener util.Mail.sendEmailAdmins(subject, Some(user), body) user.email match { case Some(e) => spaceService.processInvitation(e) - case None => Logger.debug("No email found for user "+user.id.stringify) + case None => Logger.debug("No email found for user " + user.id.stringify) } userService.updateUserField(user.id, "lastLogin", new Date()) } @@ -43,7 +43,7 @@ class SecureSocialEventListener(app: play.api.Application) extends EventListener } user.email match { case Some(e) => spaceService.processInvitation(e) - case None => Logger.debug("No email found for user "+user.id.stringify) + case None => Logger.debug("No email found for user " + user.id.stringify) } userService.updateUserField(user.id, "lastLogin", new Date()) } diff --git a/app/services/ToolManagerPlugin.scala b/app/services/ToolManagerPlugin.scala index 5bc43d15b..4b1c66bc2 100644 --- a/app/services/ToolManagerPlugin.scala +++ b/app/services/ToolManagerPlugin.scala @@ -114,7 +114,7 @@ class ToolManagerPlugin(application: Application) extends Plugin { */ def refreshLaunchableToolsFromServer(): Unit = { val apipath = play.Play.application().configuration().getString("toolmanagerURI") - val statusRequest: Future[Response] = url(apipath+"/tools").get() + val statusRequest: Future[Response] = url(apipath + "/tools").get() statusRequest.map( response => { val jsonObj = Json.parse(response.body) @@ -133,7 +133,7 @@ class ToolManagerPlugin(application: Application) extends Plugin { */ def refreshActiveInstanceListFromServer(): Unit = { val apipath = play.Play.application().configuration().getString("toolmanagerURI") - val statusRequest: Future[Response] = url(apipath+"/instances").get() + val statusRequest: Future[Response] = url(apipath + "/instances").get() statusRequest.map( response => { val jsonObj = Json.parse(response.body) @@ -156,24 +156,24 @@ class ToolManagerPlugin(application: Application) extends Plugin { instance.externalId = externalID // TODO: how to get JsValue without the wrapping quotes? - instance.setName((j \ externalID \ "name").toString.replace("\"","")) - instance.setURL((j \ externalID \ "url").toString.replace("\"","")) + instance.setName((j \ externalID \ "name").toString.replace("\"", "")) + instance.setURL((j \ externalID \ "url").toString.replace("\"", "")) instance.setOwner(new UUID((j \ externalID \ "ownerId").toString.replace("\"",""))) instance.setToolInfo( - (j \ externalID \ "toolPath").toString.replace("\"",""), - (j \ externalID \ "toolName").toString.replace("\"","")) + (j \ externalID \ "toolPath").toString.replace("\"", ""), + (j \ externalID \ "toolName").toString.replace("\"", "")) // TODO: normalize time zone - server time is currently shown as-received - val t = (j \ externalID \ "created").toString.replace("\"","") + val t = (j \ externalID \ "created").toString.replace("\"", "") instance.setTimes(t, t) val histList = (j \ externalID \ "uploadHistory").as[List[JsObject]] for (histEntry <- histList) { - val entryTime = (histEntry \ "time").toString.replace("\"","") - val entryUrl = (histEntry \ "url").toString.replace("\"","") - val entryOwner = (histEntry \ "uploaderId").toString.replace("\"","") - val entryId = (histEntry \ "datasetId").toString.replace("\"","") - val entryName = (histEntry \ "datasetName").toString.replace("\"","") + val entryTime = (histEntry \ "time").toString.replace("\"", "") + val entryUrl = (histEntry \ "url").toString.replace("\"", "") + val entryOwner = (histEntry \ "uploaderId").toString.replace("\"", "") + val entryId = (histEntry \ "datasetId").toString.replace("\"", "") + val entryName = (histEntry \ "datasetName").toString.replace("\"", "") instance.uploadHistory(new UUID(entryId)) = (entryName, entryTime, entryOwner) } @@ -211,10 +211,10 @@ class ToolManagerPlugin(application: Application) extends Plugin { // Send request to API to launch Tool // TODO: Figure out something better than the key here - val dsURL = hostURL+controllers.routes.Datasets.dataset(datasetId).url + val dsURL = hostURL + controllers.routes.Datasets.dataset(datasetId).url val apipath = play.Play.application().configuration().getString("toolmanagerURI") + "/instances/" + toolPath val statusRequest: Future[Response] = url(apipath).post(Json.obj( - "dataset" -> (dsURL.replace("/datasets", "/api/datasets")+"/download"), + "dataset" -> (dsURL.replace("/datasets", "/api/datasets") + "/download"), "key" -> play.Play.application().configuration().getString("commKey"), "name" -> instanceName, "ownerId" -> oId, @@ -240,7 +240,7 @@ class ToolManagerPlugin(application: Application) extends Plugin { case _: JsUndefined => {} case _ => { val matched = instanceMap(instance.id) - matched.setID(externalID.toString.replace("\"","")) + matched.setID(externalID.toString.replace("\"", "")) instanceMap(instance.id) = matched } } @@ -300,7 +300,7 @@ class ToolManagerPlugin(application: Application) extends Plugin { * Upload dataset files to an existing instance. */ def uploadDatasetToInstance(hostURL: String, instanceID: UUID, datasetId: UUID, datasetName: String, userId: Option[UUID]): Unit = { - val dsURL = hostURL+controllers.routes.Datasets.dataset(datasetId).url + val dsURL = hostURL + controllers.routes.Datasets.dataset(datasetId).url var oId = "" userId.map(i => oId = i.toString) @@ -310,7 +310,7 @@ class ToolManagerPlugin(application: Application) extends Plugin { val apipath = play.Play.application().configuration().getString("toolmanagerURI") + "/instances/" + instance.toolPath val statusRequest: Future[Response] = url(apipath).put(Json.obj( - "dataset" -> (dsURL.replace("/datasets", "/api/datasets")+"/download"), + "dataset" -> (dsURL.replace("/datasets", "/api/datasets") + ß"/download"), "key" -> play.Play.application().configuration().getString("commKey"), "id" -> instance.externalId.toString, "uploaderId" -> oId, @@ -333,7 +333,7 @@ class ToolManagerPlugin(application: Application) extends Plugin { instanceMap.get(instanceID).map( ts => { val instanceApiID = ts.externalId // External identifier on NDS api - val statusRequest: Future[Response] = url(apipath+"?id="+instanceApiID.toString()).delete() + val statusRequest: Future[Response] = url(apipath + "?id=" + instanceApiID.toString()).delete() }) instanceMap = instanceMap - instanceID diff --git a/app/services/fourstore/FourStoreRdfSPARQLService.scala b/app/services/fourstore/FourStoreRdfSPARQLService.scala index 9bc9ff8e4..ed42bafe1 100644 --- a/app/services/fourstore/FourStoreRdfSPARQLService.scala +++ b/app/services/fourstore/FourStoreRdfSPARQLService.scala @@ -29,7 +29,7 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File var updateQuery = " <" + graphName + "_file" + "> ." - Logger.debug("the query: "+updateQuery) + Logger.debug("the query: " + updateQuery) urlParameters.add(new BasicNameValuePair("data", updateQuery)) urlParameters.add(new BasicNameValuePair("graph", graphName + "_file_" + fileId)) urlParameters.add(new BasicNameValuePair("mime-type", "application/x-turtle")) @@ -41,7 +41,7 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - Logger.debug("the results: "+resultsString) + Logger.debug("the results: " + resultsString) return null } @@ -57,7 +57,7 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File var updateQuery = " <" + graphName + "_dataset" + "> ." - Logger.debug("the query: "+updateQuery) + Logger.debug("the query: " + updateQuery) urlParameters.add(new BasicNameValuePair("data", updateQuery)) urlParameters.add(new BasicNameValuePair("graph", graphName + "_dataset_" + datasetId)) urlParameters.add(new BasicNameValuePair("mime-type", "application/x-turtle")) @@ -69,7 +69,7 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - Logger.debug("the results: "+resultsString) + Logger.debug("the results: " + resultsString) return null } @@ -84,9 +84,9 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File val urlParameters = new ArrayList[NameValuePair]() val hostIp = play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") var updateQuery = " ." + updateQuery = updateQuery + "> ." - Logger.debug("the query: "+updateQuery) + Logger.debug("the query: " + updateQuery) urlParameters.add(new BasicNameValuePair("data", updateQuery)) urlParameters.add(new BasicNameValuePair("graph", graphName + "_file_" + fileId)) urlParameters.add(new BasicNameValuePair("mime-type", "application/x-turtle")) @@ -98,7 +98,7 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - Logger.debug("the results: "+resultsString) + Logger.debug("the results: " + resultsString) return null } @@ -115,7 +115,7 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File Logger.debug(queryResponse.getStatusLine().toString()) val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - Logger.debug("the results: "+resultsString) + Logger.debug("the results: " + resultsString) return null @@ -133,7 +133,7 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File Logger.debug(queryResponse.getStatusLine().toString()) val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - Logger.debug("the results: "+resultsString) + Logger.debug("the results: " + resultsString) return null @@ -149,13 +149,13 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File val urlParameters = new ArrayList[NameValuePair]() val hostIp = play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") var updateQuery = "DELETE { }" + updateQuery = updateQuery + "> }" updateQuery = updateQuery + "WHERE { }" + updateQuery = updateQuery + "> }" if(!graphName.equals("")){ updateQuery = "WITH <" + graphName + "_file_" + fileId + "> " + updateQuery } - Logger.debug("the query: "+updateQuery) + Logger.debug("the query: " + updateQuery) urlParameters.add(new BasicNameValuePair("update", updateQuery)) httpPost.setEntity(new UrlEncodedFormEntity(urlParameters)) @@ -165,7 +165,7 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - Logger.debug("the results: "+resultsString) + Logger.debug("the results: " + resultsString) return null @@ -202,7 +202,7 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File val queryUrl = play.api.Play.configuration.getString("rdfEndpoint").getOrElse("") + "/sparql/" val httpclient = new DefaultHttpClient() - Logger.debug("query text: "+ queryText) + Logger.debug("query text: " + queryText) val httpPost = new HttpPost(queryUrl) val urlParameters = new ArrayList[NameValuePair]() @@ -235,7 +235,7 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File var updateQuery = new String(data, "UTF-8") urlParameters.add(new BasicNameValuePair("data", updateQuery)) - urlParameters.add(new BasicNameValuePair("graph", graphName + "_"+ fileOrDataset + "_" + id)) + urlParameters.add(new BasicNameValuePair("graph", graphName + "_" + fileOrDataset + "_" + id)) httpPost.setEntity(new UrlEncodedFormEntity(urlParameters)) val queryResponse = httpclient.execute(httpPost) @@ -244,7 +244,7 @@ class FourStoreRdfSPARQLService @Inject() (datasets: DatasetService, files: File val resultsEntity = queryResponse.getEntity() val resultsString = EntityUtils.toString(resultsEntity) - Logger.debug("the results: "+resultsString) + Logger.debug("the results: " + resultsString) return null } diff --git a/app/services/mongodb/MongoDBCollectionService.scala b/app/services/mongodb/MongoDBCollectionService.scala index 4aea881b1..af79349a4 100644 --- a/app/services/mongodb/MongoDBCollectionService.scala +++ b/app/services/mongodb/MongoDBCollectionService.scala @@ -1088,7 +1088,7 @@ class MongoDBCollectionService @Inject() ( } def incrementViews(id: UUID, user: Option[User]): (Int, Date) = { - Logger.debug("updating views for collection "+id.toString) + Logger.debug("updating views for collection " + id.toString) val viewdate = new Date val updated = Collection.dao.collection.findAndModify( @@ -1098,7 +1098,7 @@ class MongoDBCollectionService @Inject() ( user match { case Some(u) => { - Logger.debug("updating views for user "+u.toString) + Logger.debug("updating views for user " + u.toString) CollectionStats.update(MongoDBObject("user_id" -> new ObjectId(u.id.stringify), "resource_id" -> new ObjectId(id.stringify), "resource_type" -> "collection"), $inc("views" -> 1) ++ $set("last_viewed" -> viewdate), true, false, WriteConcern.Safe) } diff --git a/app/services/mongodb/MongoDBContextLDService.scala b/app/services/mongodb/MongoDBContextLDService.scala index 67d1c32c9..9f26392ac 100644 --- a/app/services/mongodb/MongoDBContextLDService.scala +++ b/app/services/mongodb/MongoDBContextLDService.scala @@ -34,7 +34,7 @@ class MongoDBContextLDService extends ContextLDService{ /** Get context **/ def getContextById(id: UUID): Option[JsValue] = { - Logger.debug("mongo context id: "+ id) + Logger.debug("mongo context id: " + id) val contextld = ContextLDDAO.findOne(MongoDBObject("_id" -> new ObjectId(id.stringify))) contextld.map(_.context) } diff --git a/app/services/mongodb/MongoDBCurationService.scala b/app/services/mongodb/MongoDBCurationService.scala index 38b7d1b32..8a9a9d433 100644 --- a/app/services/mongodb/MongoDBCurationService.scala +++ b/app/services/mongodb/MongoDBCurationService.scala @@ -290,7 +290,7 @@ class MongoDBCurationService @Inject() (metadatas: MetadataService, spaces: Spa maxValue = depth } } - return maxValue +1 + return maxValue + 1 } private def maxFolderDepth(folderId: UUID): Int = { diff --git a/app/services/mongodb/MongoDBDatasetService.scala b/app/services/mongodb/MongoDBDatasetService.scala index b9569e9a6..93c40b601 100644 --- a/app/services/mongodb/MongoDBDatasetService.scala +++ b/app/services/mongodb/MongoDBDatasetService.scala @@ -560,7 +560,7 @@ class MongoDBDatasetService @Inject() ( if(!theJSON.replaceAll(" ","").equals("{}")){ val xmlFile = jsonToXML(theJSON) - new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_"+mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) + new LidoToCidocConvertion(play.api.Play.configuration.getString("datasetsxmltordfmapping.dir_" + mappingNumber).getOrElse(""), xmlFile.getAbsolutePath(), resultDir) xmlFile.delete() } else{ @@ -616,9 +616,9 @@ class MongoDBDatasetService @Inject() ( } if(isInRootNodes){ - val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"")+1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"")+1)) + val theResource = rdfDescriptions(i).substring(rdfDescriptions(i).indexOf("\"") + 1, rdfDescriptions(i).indexOf("\"", rdfDescriptions(i).indexOf("\"") + 1)) val theHost = "http://" + play.Play.application().configuration().getString("hostIp").replaceAll("/$", "") + ":" + play.Play.application().configuration().getString("http.port") - var connection = "" fileWriter.write(connection) @@ -650,14 +650,14 @@ class MongoDBDatasetService @Inject() ( var currEnd = -1 var xmlNoSpaces = "" while(currStart != -1){ - xmlNoSpaces = xmlNoSpaces + xml.substring(currEnd+1,currStart) - currEnd = xml.indexOf(">", currStart+1) - xmlNoSpaces = xmlNoSpaces + xml.substring(currStart,currEnd+1).replaceAll(" ", "_") - currStart = xml.indexOf("<", currEnd+1) + xmlNoSpaces = xmlNoSpaces + xml.substring(currEnd + 1, currStart) + currEnd = xml.indexOf(">", currStart + 1) + xmlNoSpaces = xmlNoSpaces + xml.substring(currStart, currEnd + 1).replaceAll(" ", "_") + currStart = xml.indexOf("<", currEnd + 1) } - xmlNoSpaces = xmlNoSpaces + xml.substring(currEnd+1) + xmlNoSpaces = xmlNoSpaces + xml.substring(currEnd + 1) - val xmlFile = java.io.File.createTempFile("xml",".xml") + val xmlFile = java.io.File.createTempFile("xml", ".xml") val fileWriter = new BufferedWriter(new FileWriter(xmlFile)) fileWriter.write(xmlNoSpaces) fileWriter.close() @@ -1138,25 +1138,25 @@ class MongoDBDatasetService @Inject() ( if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; + realValue = "^" + realValue + "$"; } if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; + realValue = "(?i)" + realValue; } - builder += MongoDBObject(actualKey -> MongoDBObject("$not" -> realValue.r)) + builder += MongoDBObject(actualKey -> MongoDBObject("$not" -> realValue.r)) } else{ - builder += MongoDBObject(actualKey -> MongoDBObject("$ne" -> currValue)) + builder += MongoDBObject(actualKey -> MongoDBObject("$ne" -> currValue)) } } else { if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; + realValue = "^" + realValue + "$"; } if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; + realValue = "(?i)" + realValue; } builder += MongoDBObject(actualKey -> realValue.r) } @@ -1189,10 +1189,10 @@ class MongoDBDatasetService @Inject() ( if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; + realValue = "^" + realValue + "$"; } if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; + realValue = "(?i)" + realValue; } objectForEach += MongoDBObject(tempActualKey -> MongoDBObject("$not" -> realValue.r)) } @@ -1204,10 +1204,10 @@ class MongoDBDatasetService @Inject() ( if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; + realValue = "^" + realValue + "$"; } if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; + realValue = "(?i)" + realValue; } objectForEach += MongoDBObject(tempActualKey -> realValue.r) } @@ -1482,8 +1482,8 @@ class MongoDBDatasetService @Inject() ( val dsXMLMetadata = getXMLMetadataJSON(dataset.id) if(dsTechnicalMetadata != "{}" || dsUserMetadata != "{}" || dsXMLMetadata != "{}"){ - val datasetnameNoSpaces = dataset.name.replaceAll("\\s+","_") - val filePathInDirs = dsId.charAt(dsId.length()-3)+ fileSep + dsId.charAt(dsId.length()-2)+dsId.charAt(dsId.length()-1)+ fileSep + dsId + fileSep + datasetnameNoSpaces + "__metadata.txt" + val datasetnameNoSpaces = dataset.name.replaceAll("\\s+", "_") + val filePathInDirs = dsId.charAt(dsId.length() - 3) + fileSep + dsId.charAt(dsId.length() - 2) + dsId.charAt(dsId.length() - 1) + fileSep + dsId + fileSep + datasetnameNoSpaces + "__metadata.txt" val mdFile = new java.io.File(dsMdDumpDir + filePathInDirs) mdFile.getParentFile().mkdirs() @@ -1504,7 +1504,7 @@ class MongoDBDatasetService @Inject() ( } }catch {case ex:Exception =>{ val badDatasetId = dataset.id.toString - Logger.error("Unable to stage dumped metadata of dataset with id "+badDatasetId+": "+ex.printStackTrace()) + Logger.error("Unable to stage dumped metadata of dataset with id " + badDatasetId + ": " + ex.printStackTrace()) unsuccessfulDumps += badDatasetId }} } @@ -1512,7 +1512,7 @@ class MongoDBDatasetService @Inject() ( } }catch {case ex:Exception =>{ val badDatasetId = dataset.id.toString - Logger.error("Unable to dump metadata of dataset with id "+badDatasetId+": "+ex.printStackTrace()) + Logger.error("Unable to dump metadata of dataset with id " + badDatasetId + ": " + ex.printStackTrace()) unsuccessfulDumps += badDatasetId }} } @@ -1543,15 +1543,15 @@ class MongoDBDatasetService @Inject() ( for(dataset <- Dataset.findAll){ try{ val dsId = dataset.id.toString - val datasetnameNoSpaces = dataset.name.replaceAll("\\s+","_") - val filePathInDirs = dsId.charAt(dsId.length()-3)+ fileSep + dsId.charAt(dsId.length()-2)+dsId.charAt(dsId.length()-1)+ fileSep + dsId + fileSep + datasetnameNoSpaces + ".txt" + val datasetnameNoSpaces = dataset.name.replaceAll("\\s+", "_") + val filePathInDirs = dsId.charAt(dsId.length() - 3) + fileSep + dsId.charAt(dsId.length() - 2) + dsId.charAt(dsId.length() - 1) + fileSep + dsId + fileSep + datasetnameNoSpaces + ".txt" val groupingFile = new java.io.File(datasetsDumpDir + filePathInDirs) groupingFile.getParentFile().mkdirs() val filePrintStream = new PrintStream(groupingFile) files.get(dataset.files).found.foreach(file => { - filePrintStream.println("id:"+file.id.toString+" "+"filename:"+file.filename) + filePrintStream.println("id:" + file.id.toString + " " + "filename:" + file.filename) }) filePrintStream.close() @@ -1568,13 +1568,13 @@ class MongoDBDatasetService @Inject() ( } }catch {case ex:Exception =>{ val badDatasetId = dataset.id.toString - Logger.error("Unable to stage file grouping of dataset with id "+badDatasetId+": "+ex.printStackTrace()) + Logger.error("Unable to stage file grouping of dataset with id " + badDatasetId + ": " + ex.printStackTrace()) unsuccessfulDumps += badDatasetId }} } }catch {case ex:Exception =>{ val badDatasetId = dataset.id.toString - Logger.error("Unable to dump file grouping of dataset with id "+badDatasetId+": "+ex.printStackTrace()) + Logger.error("Unable to dump file grouping of dataset with id " + badDatasetId + ": " + ex.printStackTrace()) unsuccessfulDumps += badDatasetId }} } @@ -1593,7 +1593,7 @@ class MongoDBDatasetService @Inject() ( } def incrementViews(id: UUID, user: Option[User]): (Int, Date) = { - Logger.debug("updating views for dataset "+id.toString) + Logger.debug("updating views for dataset " + id.toString) val viewdate = new Date val updated = Dataset.dao.collection.findAndModify( @@ -1603,7 +1603,7 @@ class MongoDBDatasetService @Inject() ( user match { case Some(u) => { - Logger.debug("updating views for user "+u.toString) + Logger.debug("updating views for user " + u.toString) DatasetStats.update(MongoDBObject("user_id" -> new ObjectId(u.id.stringify), "resource_id" -> new ObjectId(id.stringify), "resource_type" -> "dataset"), $inc("views" -> 1) ++ $set("last_viewed" -> viewdate), true, false, WriteConcern.Safe) } @@ -1618,13 +1618,13 @@ class MongoDBDatasetService @Inject() ( } def incrementDownloads(id: UUID, user: Option[User]) = { - Logger.debug("updating downloads for dataset "+id.toString) + Logger.debug("updating downloads for dataset " + id.toString) Dataset.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), $inc("stats.downloads" -> 1) ++ $set("stats.last_downloaded" -> new Date), true, false, WriteConcern.Safe) user match { case Some(u) => { - Logger.debug("updating downloads for user "+u.toString) + Logger.debug("updating downloads for user " + u.toString) DatasetStats.update(MongoDBObject("user_id" -> new ObjectId(u.id.stringify), "resource_id" -> new ObjectId(id.stringify), "resource_type" -> "dataset"), $inc("downloads" -> 1) ++ $set("last_downloaded" -> new Date), true, false, WriteConcern.Safe) } diff --git a/app/services/mongodb/MongoDBExtractionRequestsService.scala b/app/services/mongodb/MongoDBExtractionRequestsService.scala index 05417ae1e..51265472a 100644 --- a/app/services/mongodb/MongoDBExtractionRequestsService.scala +++ b/app/services/mongodb/MongoDBExtractionRequestsService.scala @@ -52,7 +52,7 @@ class MongoDBExtractionRequestsService @Inject()(extractions: ExtractionService) def updateRequest(file_id:UUID,extractor_id:String) = { val requests = getRequests(file_id) Logger.debug("-----Updating Extraction Request----------") - Logger.debug( "Number of Requests to be updated : "+requests.length); + Logger.debug( "Number of Requests to be updated : " + requests.length); for (r <- requests) { var req = Json.parse(com.mongodb.util.JSON.serialize(r)) @@ -70,7 +70,7 @@ class MongoDBExtractionRequestsService @Inject()(extractions: ExtractionService) var ex = extractions.getExtractorList(file_id) val elist = ex.keySet.toList - Logger.debug("----extractorlist:----"+ elist); + Logger.debug("----extractorlist:----" + elist); if (len != 0) { var update = $set("extractors" -> elist, "startTime" -> sortedTime(0), "endTime" -> sortedTime(len - 1)) var result = ExtractionRequests.dao.collection.update(r, update) @@ -82,12 +82,12 @@ class MongoDBExtractionRequestsService @Inject()(extractions: ExtractionService) def getRequests(file_id:UUID) = { - Logger.debug("GET Requests---- fileID"+ file_id.toString) + Logger.debug("GET Requests---- fileID" + file_id.toString) //val query = MongoDBObject("endTime" -> None) val id=file_id.toString val query = MongoDBObject("fileid"->new ObjectId(file_id.stringify)) var requests1=ExtractionRequests.find(query) - Logger.debug("REQUEST Length: "+ requests1.length) + Logger.debug("REQUEST Length: " + requests1.length) var requests = ExtractionRequests.dao.collection.find(query) requests diff --git a/app/services/mongodb/MongoDBExtractionService.scala b/app/services/mongodb/MongoDBExtractionService.scala index be1bd5ae3..544d166ab 100644 --- a/app/services/mongodb/MongoDBExtractionService.scala +++ b/app/services/mongodb/MongoDBExtractionService.scala @@ -107,7 +107,7 @@ class MongoDBExtractionService extends ExtractionService { e.end match { case Some(n) => { if (grp_end == "N/A" || n.after(grp_end)) { - Logger.info("updating latest msg: "+e.status) + Logger.info("updating latest msg: " + e.status) grp_end = n grp_endmsg = e.status } diff --git a/app/services/mongodb/MongoDBFileService.scala b/app/services/mongodb/MongoDBFileService.scala index b349d4e7a..a68ada9b4 100644 --- a/app/services/mongodb/MongoDBFileService.scala +++ b/app/services/mongodb/MongoDBFileService.scala @@ -909,21 +909,21 @@ class MongoDBFileService @Inject() ( } def searchAllMetadataFormulateQuery(requestedMetadataQuery: Any): List[File] = { - Logger.debug("top: "+ requestedMetadataQuery.asInstanceOf[java.util.LinkedHashMap[String,Any]].toString() ) + Logger.debug("top: " + requestedMetadataQuery.asInstanceOf[java.util.LinkedHashMap[String,Any]].toString() ) var theQuery = searchMetadataFormulateQuery(requestedMetadataQuery.asInstanceOf[java.util.LinkedHashMap[String,Any]], "all") - Logger.debug("thequery: "+theQuery.toString) + Logger.debug("thequery: " + theQuery.toString) FileDAO.find(theQuery).toList } def searchUserMetadataFormulateQuery(requestedMetadataQuery: Any): List[File] = { - Logger.debug("top: "+ requestedMetadataQuery.asInstanceOf[java.util.LinkedHashMap[String,Any]].toString() ) + Logger.debug("top: " + requestedMetadataQuery.asInstanceOf[java.util.LinkedHashMap[String,Any]].toString() ) var theQuery = searchMetadataFormulateQuery(requestedMetadataQuery.asInstanceOf[java.util.LinkedHashMap[String,Any]], "userMetadata") - Logger.debug("thequery: "+theQuery.toString) + Logger.debug("thequery: " + ßtheQuery.toString) FileDAO.find(theQuery).toList } def searchMetadataFormulateQuery(requestedMap: java.util.LinkedHashMap[String,Any], root: String): MongoDBObject = { - Logger.debug("req: "+ requestedMap) + Logger.debug("req: " + requestedMap) var queryMap = MongoDBList() var builder = MongoDBList() var orFound = false @@ -953,10 +953,10 @@ class MongoDBFileService @Inject() ( if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; + realValue = "^" + realValue + "$"; } if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; + realValue = "(?i)" + realValue; } builder += MongoDBObject(actualKey -> MongoDBObject("$not" -> realValue.r)) } @@ -968,10 +968,10 @@ class MongoDBFileService @Inject() ( if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; + realValue = "^" + realValue + "$"; } if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; + realValue = "(?i)" + realValue; } builder += MongoDBObject(actualKey -> realValue.r) } @@ -1003,10 +1003,10 @@ class MongoDBFileService @Inject() ( if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; + realValue = "^" + realValue + "$"; } if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; + realValue = "(?i)" + realValue; } objectForEach += MongoDBObject(tempActualKey -> MongoDBObject("$not" -> realValue.r)) } @@ -1018,10 +1018,10 @@ class MongoDBFileService @Inject() ( if(currValue.contains(" IGNORE CASE") || currValue.contains(" ANYWHERE")){ var realValue = currValue.replace(" IGNORE CASE", "").replace(" ANYWHERE", ""); if(!currValue.contains(" ANYWHERE")){ - realValue = "^"+realValue+"$"; + realValue = "^" + realValue + "$"; } if(currValue.contains(" IGNORE CASE")){ - realValue = "(?i)"+realValue; + realValue = "(?i)" + realValue; } objectForEach += MongoDBObject(tempActualKey -> realValue.r) } @@ -1110,7 +1110,7 @@ class MongoDBFileService @Inject() ( if(fileTechnicalMetadata != "{}" || fileUserMetadata != "{}"){ val filenameNoExtension = file.filename.substring(0, file.filename.lastIndexOf(".")) - val filePathInDirs = fileId.charAt(fileId.length()-3)+ fileSep + fileId.charAt(fileId.length()-2)+fileId.charAt(fileId.length()-1)+ fileSep + fileId + fileSep + filenameNoExtension + "__metadata.txt" + val filePathInDirs = fileId.charAt(fileId.length() - 3) + fileSep + fileId.charAt(fileId.length() - 2) + fileId.charAt(fileId.length() - 1) + fileSep + fileId + fileSep + filenameNoExtension + "__metadata.txt" val mdFile = new java.io.File(fileMdDumpDir + filePathInDirs) mdFile.getParentFile().mkdirs() @@ -1131,7 +1131,7 @@ class MongoDBFileService @Inject() ( } }catch {case ex:Exception =>{ val badFileId = file.id.toString - Logger.error("Unable to stage dumped metadata of file with id "+badFileId+": "+ex.printStackTrace()) + Logger.error("Unable to stage dumped metadata of file with id " + badFileId + ": " + ex.printStackTrace()) unsuccessfulDumps += badFileId }} } @@ -1139,7 +1139,7 @@ class MongoDBFileService @Inject() ( }catch {case ex:Exception =>{ val badFileId = file.id.toString - Logger.error("Unable to dump metadata of file with id "+badFileId+": "+ex.printStackTrace()) + Logger.error("Unable to dump metadata of file with id " + badFileId + ": " + ex.printStackTrace()) unsuccessfulDumps += badFileId }} } @@ -1171,7 +1171,7 @@ class MongoDBFileService @Inject() ( } def incrementViews(id: UUID, user: Option[User]): (Int, Date) = { - Logger.debug("updating views for file "+id.toString) + Logger.debug("updating views for file " + id.toString) val viewdate = new Date val updated = FileDAO.dao.collection.findAndModify( @@ -1181,7 +1181,7 @@ class MongoDBFileService @Inject() ( user match { case Some(u) => { - Logger.debug("updating views for user "+u.toString) + Logger.debug("updating views for user " + u.toString) FileStats.update(MongoDBObject("user_id" -> new ObjectId(u.id.stringify), "resource_id" -> new ObjectId(id.stringify), "resource_type" -> "file"), $inc("views" -> 1) ++ $set("last_viewed" -> viewdate), true, false, WriteConcern.Safe) } @@ -1196,13 +1196,13 @@ class MongoDBFileService @Inject() ( } def incrementDownloads(id: UUID, user: Option[User]) = { - Logger.debug("updating downloads for file "+id.toString) + Logger.debug("updating downloads for file " + id.toString) FileDAO.update(MongoDBObject("_id" -> new ObjectId(id.stringify)), $inc("stats.downloads" -> 1) ++ $set("stats.last_downloaded" -> new Date), true, false, WriteConcern.Safe) user match { case Some(u) => { - Logger.debug("updating downloads for user "+u.toString) + Logger.debug("updating downloads for user " + u.toString) FileStats.update(MongoDBObject("user_id" -> new ObjectId(u.id.stringify), "resource_id" -> new ObjectId(id.stringify), "resource_type" -> "file"), $inc("downloads" -> 1) ++ $set("last_downloaded" -> new Date), true, false, WriteConcern.Safe) } diff --git a/app/services/mongodb/MongoDBMetadataService.scala b/app/services/mongodb/MongoDBMetadataService.scala index 23913e4f7..ee5be3bbb 100644 --- a/app/services/mongodb/MongoDBMetadataService.scala +++ b/app/services/mongodb/MongoDBMetadataService.scala @@ -63,7 +63,7 @@ class MongoDBMetadataService @Inject() (contextService: ContextLDService, datase /** Get Extractor metadata by attachTo, from a specific extractor if given */ def getExtractedMetadataByAttachTo(resourceRef: ResourceRef, extractor: String): List[Metadata] = { - val regex = ".*extractors/"+extractor + val regex = ".*extractors/" + extractor val order = MongoDBObject("createdAt" -> -1) MetadataDAO.find(MongoDBObject( @@ -121,7 +121,7 @@ class MongoDBMetadataService @Inject() (contextService: ContextLDService, datase } } } - case None => Logger.debug("No metadata found to remove with UUID "+id.toString) + case None => Logger.debug("No metadata found to remove with UUID " + id.toString) } } @@ -155,7 +155,7 @@ class MongoDBMetadataService @Inject() (contextService: ContextLDService, datase /** Remove metadata by attached ID and extractor name **/ def removeMetadataByAttachToAndExtractor(resourceRef: ResourceRef, extractorName: String, host: String, apiKey: Option[String], user: Option[User]): List[UUID] = { - val regex = ".*extractors/"+(extractorName.trim) + val regex = ".*extractors/" + (extractorName.trim) val metadataDocs = MetadataDAO.find(MongoDBObject("attachedTo.resourceType" -> resourceRef.resourceType.name, "attachedTo._id" -> new ObjectId(resourceRef.id.stringify), "creator.extractorId" -> (regex.r))).toList metadataDocs.foreach(m => MetadataDAO.remove(m)) diff --git a/app/services/mongodb/MongoDBMultimediaQueryService.scala b/app/services/mongodb/MongoDBMultimediaQueryService.scala index 489ca8ce1..d3d9985a9 100644 --- a/app/services/mongodb/MongoDBMultimediaQueryService.scala +++ b/app/services/mongodb/MongoDBMultimediaQueryService.scala @@ -56,7 +56,7 @@ class MongoDBMultimediaQueryService @Inject() (sections: SectionService, spaces: case Some(query) => { //Logger.debug(query.toString()) - Logger.debug("get: file name: "+query.filename +" Query id ="+ query.id.toString()) + Logger.debug("get: file name: " + query.filename + " Query id =" + query.id.toString()) Some(query.inputStream, query.getAs[String]("filename").getOrElse("unknown-name"), query.getAs[String]("contentType").getOrElse("unknown"), @@ -98,7 +98,7 @@ def getFile(id: UUID): Option[TempFile] = { mongoFile.save val oid = mongoFile.getAs[ObjectId]("_id").get ///getting object id //mongoFile._id - Logger.debug("StoreMD id="+ oid) + Logger.debug("StoreMD id=" + oid) Some(TempFile(UUID(oid.toString), None, mongoFile.filename.get, mongoFile.uploadDate, mongoFile.contentType.get, mongoFile.length)) } diff --git a/app/services/mongodb/MongoDBSpaceService.scala b/app/services/mongodb/MongoDBSpaceService.scala index f05d0b89c..76e3999ad 100644 --- a/app/services/mongodb/MongoDBSpaceService.scala +++ b/app/services/mongodb/MongoDBSpaceService.scala @@ -652,10 +652,10 @@ class MongoDBSpaceService @Inject() ( addUser(user.id, role, invite.space) removeInvitationFromSpace(UUID(invite.invite_id), invite.space) } - case None => Logger.error(email+" could not be added to space (missing role "+invite.role+")") + case None => Logger.error(email + " could not be added to space (missing role " + invite.role + ")") } } - case None => Logger.error("No user found with email "+email) + case None => Logger.error("No user found with email " + email) } } } diff --git a/app/services/mongodb/MongoSalatPlugin.scala b/app/services/mongodb/MongoSalatPlugin.scala index 9b3a8c6e0..2e994e691 100644 --- a/app/services/mongodb/MongoSalatPlugin.scala +++ b/app/services/mongodb/MongoSalatPlugin.scala @@ -1608,12 +1608,12 @@ class MongoSalatPlugin(app: Application) extends Plugin { val path = content.getAsOrElse[String]("Upload Path", "") if (path.length > 0) { if (path.lastIndexOf("/") >= 0) { - Logger.info("Assigning name/: " + path.substring(path.lastIndexOf("/")+1) + " from path " + path) + Logger.info("Assigning name/: " + path.substring(path.lastIndexOf("/") + 1) + " from path " + path) md.getAs[DBObject]("attachedTo") match { case Some(ref) => { collection("uploads").update(MongoDBObject("_id" -> new ObjectId(ref.get("_id").toString())), MongoDBObject("$set" -> MongoDBObject( - "originalname" -> path.substring(path.lastIndexOf("/")+1))), false, false, WriteConcern.Safe) + "originalname" -> path.substring(path.lastIndexOf("/") + 1))), false, false, WriteConcern.Safe) } case _ => Logger.info("Nope") From 1eb4cb07be9efb3f5aab98ba7af85a8785b6888b Mon Sep 17 00:00:00 2001 From: Tim Yardley Date: Wed, 18 Dec 2019 21:47:40 -0600 Subject: [PATCH 5/9] fix spelling errors on success and occurred --- app/api/Selected.scala | 6 ++--- app/assets/javascripts/select-bulk.js | 2 +- app/assets/javascripts/select.js | 4 ++-- app/views/admin/customize.scala.html | 2 +- app/views/admin/tos.scala.html | 2 +- app/views/admin/users.scala.html | 2 +- app/views/bookmarklet.scala.html | 20 ++++++++-------- app/views/collectionPreviews.scala.html | 4 ++-- app/views/commentform.scala.html | 2 +- app/views/dataset.scala.html | 2 +- app/views/datasetInfo.scala.html | 2 +- app/views/datasets/create.scala.html | 2 +- app/views/datasets/editInfo.scala.html | 4 ++-- app/views/datasets/tags.scala.html | 4 ++-- app/views/datasetsContainingFile.scala.html | 2 +- app/views/emailAdmin.scala.html | 2 +- app/views/errorPage.scala.html | 2 +- .../extractions/extractionsList.scala.html | 2 +- .../submitDatasetExtraction.scala.html | 2 +- .../submitFileExtraction.scala.html | 2 +- app/views/file.scala.html | 8 +++---- app/views/files/share.scala.html | 2 +- app/views/geostreams/map.scala.html | 4 ++-- app/views/home.scala.html | 2 +- app/views/logoSelect.scala.html | 6 ++--- app/views/main.scala.html | 8 +++---- .../manageMetadataDefinitions.scala.html | 2 +- app/views/metadatald/addMetadata.scala.html | 4 ++-- app/views/metadatald/newCard.scala.html | 4 ++-- app/views/metadatald/newTableRow.scala.html | 4 ++-- app/views/metadatald/search.scala.html | 4 ++-- app/views/metadatald/view.scala.html | 4 ++-- app/views/searchResults.scala.html | 2 +- app/views/selectDataset.scala.html | 2 +- app/views/spaces/spaceAllocation.scala.html | 2 +- app/views/viewDumpers.scala.html | 6 ++--- .../DTSbookmarklet/jquery-1.7.2.js | 2 +- public/javascripts/adminIndex.js | 24 +++++++++---------- .../collectionChildCollectionsList.js | 4 ++-- public/javascripts/collectionDatasetsList.js | 4 ++-- public/javascripts/collectionListProcess.js | 8 +++---- public/javascripts/collectionModify.js | 4 ++-- public/javascripts/comment-delete.js | 4 ++-- public/javascripts/comment-edit.js | 4 ++-- public/javascripts/curationProcess.js | 8 +++---- .../dataset-attach-fileuploader.js | 2 +- public/javascripts/datasetListProcess.js | 8 +++---- public/javascripts/datasets/collections.js | 6 ++--- public/javascripts/deleteUtils.js | 4 ++-- .../jquery.fileupload-clowder-auth.js | 8 +++---- public/javascripts/fileListProcess.js | 4 ++-- public/javascripts/files/datasets.js | 6 ++--- public/javascripts/files/main.js | 2 +- public/javascripts/folderListProcess.js | 2 +- public/javascripts/manageAdmins.js | 2 +- public/javascripts/manageRoles.js | 2 +- public/javascripts/metadata/addMetadata.js | 4 ++-- public/javascripts/people.js | 2 +- .../previewers/sectionRubberband.js | 2 +- .../previewers/x3dom/some-library.js | 4 ++-- public/javascripts/repositories.js | 2 +- public/javascripts/searchUserMetadata.js | 2 +- public/javascripts/sectionsListProcess.js | 2 +- public/javascripts/sensors/assign.js | 4 ++-- public/javascripts/sensors/removeRelation.js | 2 +- public/javascripts/spaceModify.js | 16 ++++++------- public/javascripts/spaceconfiguration.js | 4 ++-- public/javascripts/updateLicenseInfo.js | 4 ++-- public/javascripts/userMetadata.js | 2 +- 69 files changed, 146 insertions(+), 146 deletions(-) diff --git a/app/api/Selected.scala b/app/api/Selected.scala index 3b7951e5e..e51da2eca 100644 --- a/app/api/Selected.scala +++ b/app/api/Selected.scala @@ -87,7 +87,7 @@ class Selected @Inject()(selections: SelectionService, selections.get(user.email.get).map(d => { selections.remove(d.id, user.email.get) }) - Ok(toJson(Map("sucess"->"true"))) + Ok(toJson(Map("success"->"true"))) } } } @@ -100,7 +100,7 @@ class Selected @Inject()(selections: SelectionService, datasets.removeDataset(d.id, Utils.baseUrl(request), request.apiKey, request.user) selections.remove(d.id, user.email.get) }) - Ok(toJson(Map("sucess"->"true"))) + Ok(toJson(Map("success"->"true"))) } } } @@ -189,7 +189,7 @@ class Selected @Inject()(selections: SelectionService, events.addObjectEvent(request.user, d.id, d.name, EventType.ADD_TAGS_DATASET.toString) datasets.index(d.id) }) - Ok(toJson(Map("sucess"->"true"))) + Ok(toJson(Map("success"->"true"))) } } } diff --git a/app/assets/javascripts/select-bulk.js b/app/assets/javascripts/select-bulk.js index b2dd09111..30a4f68f9 100644 --- a/app/assets/javascripts/select-bulk.js +++ b/app/assets/javascripts/select-bulk.js @@ -20,7 +20,7 @@ $(function() { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+ textStatus, errorThrown); + console.error("The following error occurred: "+ textStatus, errorThrown); window.location = "../login"; // FIXME hardcoded }); diff --git a/app/assets/javascripts/select.js b/app/assets/javascripts/select.js index ba387aad7..137bc2be5 100644 --- a/app/assets/javascripts/select.js +++ b/app/assets/javascripts/select.js @@ -19,7 +19,7 @@ $(function() { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+ textStatus, errorThrown); + console.error("The following error occurred: "+ textStatus, errorThrown); window.location = "../login"; // FIXME hardcoded }); @@ -40,7 +40,7 @@ $(function() { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+ textStatus, errorThrown); + console.error("The following error occurred: "+ textStatus, errorThrown); window.location = "../login"; // FIXME hardcoded }); diff --git a/app/views/admin/customize.scala.html b/app/views/admin/customize.scala.html index 2bcd7e047..6012c59b3 100644 --- a/app/views/admin/customize.scala.html +++ b/app/views/admin/customize.scala.html @@ -118,7 +118,7 @@

Customize

}); }); }).fail(function(jqXHR) { - console.error("The following error occured: " + jqXHR.responseText); + console.error("The following error occurred: " + jqXHR.responseText); notify("The application preferences was not updated", "error"); }); diff --git a/app/views/admin/tos.scala.html b/app/views/admin/tos.scala.html index f577f4dc9..7b22bb833 100644 --- a/app/views/admin/tos.scala.html +++ b/app/views/admin/tos.scala.html @@ -54,7 +54,7 @@

Terms of Service

}).done(function() { notify("The terms of service have been updated", "success"); }).fail(function(jqXHR) { - console.error("The following error occured: " + jqXHR.responseText); + console.error("The following error occurred: " + jqXHR.responseText); notify("The terms of service are not updated", "error"); }); diff --git a/app/views/admin/users.scala.html b/app/views/admin/users.scala.html index dc467b1e3..a5b0ed626 100644 --- a/app/views/admin/users.scala.html +++ b/app/views/admin/users.scala.html @@ -212,7 +212,7 @@

users = { active: [], inactive: [], admin: [], unadmin: [] }; notify("Users successfully updated.", "success", false, 5000); }).fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); notify("Could not update users : " + errorThrown, "error"); }); } else { diff --git a/app/views/bookmarklet.scala.html b/app/views/bookmarklet.scala.html index 3a5819985..8cb728b40 100644 --- a/app/views/bookmarklet.scala.html +++ b/app/views/bookmarklet.scala.html @@ -31,7 +31,7 @@ var outstandingExtractions = new Array(); var tags = {}; var failedCountDown; - var sucessfullyDone; + var successfullyDone; var countDone; var status = ''; var imgdocs = {}; @@ -188,7 +188,7 @@ /** - * Check upload promises to see if upload has complite successfully. + * Check upload promises to see if upload has completed successfully. */ function checkUploadStatus(id) { for(var u=0;u 0 && countDone == filesInfo.length) { status = 'Done'; diff --git a/app/views/collectionPreviews.scala.html b/app/views/collectionPreviews.scala.html index 69fca56a2..ddb792f27 100644 --- a/app/views/collectionPreviews.scala.html +++ b/app/views/collectionPreviews.scala.html @@ -62,12 +62,12 @@

Previewers available for this collection

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); }); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); }); diff --git a/app/views/commentform.scala.html b/app/views/commentform.scala.html index d8355d53f..5622f0613 100644 --- a/app/views/commentform.scala.html +++ b/app/views/commentform.scala.html @@ -182,7 +182,7 @@ }); request.fail(function(jqXHR, textStatus, errorThrown) { - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to post a comment."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Error posting comment : " + errorThrown, "error"); diff --git a/app/views/dataset.scala.html b/app/views/dataset.scala.html index bd1fa8614..7fcc49c85 100644 --- a/app/views/dataset.scala.html +++ b/app/views/dataset.scala.html @@ -637,7 +637,7 @@

Statistics

request.fail(function (jqXHR, textStatus, errorThrown){ $('#name').val(""); - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to create a new folder."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Error in creating folder: " + errorThrown, "error"); diff --git a/app/views/datasetInfo.scala.html b/app/views/datasetInfo.scala.html index 1b1d16d9f..df82b6b32 100644 --- a/app/views/datasetInfo.scala.html +++ b/app/views/datasetInfo.scala.html @@ -23,7 +23,7 @@ request.fail(function (jqXHR, textStatus, errorThrown){ console.error( - "The following error occured: "+ + "The following error occurred: "+ textStatus, errorThrown ); diff --git a/app/views/datasets/create.scala.html b/app/views/datasets/create.scala.html index 11bce6e76..44e7b1854 100644 --- a/app/views/datasets/create.scala.html +++ b/app/views/datasets/create.scala.html @@ -233,7 +233,7 @@

@Messages("create.header", Messages("dataset.title"))

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to create a new dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Error in creating dataset. : " + errorThrown, "error"); diff --git a/app/views/datasets/editInfo.scala.html b/app/views/datasets/editInfo.scala.html index 0d6837bc3..472b5863e 100644 --- a/app/views/datasets/editInfo.scala.html +++ b/app/views/datasets/editInfo.scala.html @@ -90,7 +90,7 @@ request.done(function (response, textStatus, jqXHR){ ///console.log("Response " + response); - //Sucessful update of the DB - update the interface + //Successful update of the DB - update the interface $("#aboutdesc").html(encDescription.replace(/\n/g, "
")); $("#datasettitle").html(encName.replace(/\n/g, "
")); @@ -99,7 +99,7 @@ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to update the information about a dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset information was not updated due to : " + errorThrown, "error"); diff --git a/app/views/datasets/tags.scala.html b/app/views/datasets/tags.scala.html index f51aa02fd..38a57a104 100644 --- a/app/views/datasets/tags.scala.html +++ b/app/views/datasets/tags.scala.html @@ -95,7 +95,7 @@

Tags

}); request.fail(function (jqXHR, textStatus, errorThrown) { - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a tag from a dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The tag was not removed from the dataset due to : " + errorThrown, "error"); @@ -150,7 +150,7 @@

Tags

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to add a tag to a dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The tag was not added to the dataset due to : " + errorThrown, "error"); diff --git a/app/views/datasetsContainingFile.scala.html b/app/views/datasetsContainingFile.scala.html index db553bf71..c16ed4c27 100644 --- a/app/views/datasetsContainingFile.scala.html +++ b/app/views/datasetsContainingFile.scala.html @@ -42,7 +42,7 @@ $(event.target.parentNode.parentNode).remove(); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a file from a dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The file was not removed from the dataset due to : " + errorThrown, "error"); diff --git a/app/views/emailAdmin.scala.html b/app/views/emailAdmin.scala.html index a0687adab..d7f158d95 100644 --- a/app/views/emailAdmin.scala.html +++ b/app/views/emailAdmin.scala.html @@ -59,7 +59,7 @@

Email admins

$("#subject").val('') $("#body").val('') }).fail(function (jqXHR, textStatus, errorThrown) { - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); notify("The application preferences was not updated due to : " + errorThrown, "error", false); }); return false; diff --git a/app/views/errorPage.scala.html b/app/views/errorPage.scala.html index b65de45d0..53ad47f8d 100644 --- a/app/views/errorPage.scala.html +++ b/app/views/errorPage.scala.html @@ -32,7 +32,7 @@

@re.toString()

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); }); }); diff --git a/app/views/extractions/extractionsList.scala.html b/app/views/extractions/extractionsList.scala.html index 3367520bf..1c90236ad 100644 --- a/app/views/extractions/extractionsList.scala.html +++ b/app/views/extractions/extractionsList.scala.html @@ -72,7 +72,7 @@ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); }); } diff --git a/app/views/extractions/submitDatasetExtraction.scala.html b/app/views/extractions/submitDatasetExtraction.scala.html index 9168a6800..80051fc6f 100644 --- a/app/views/extractions/submitDatasetExtraction.scala.html +++ b/app/views/extractions/submitDatasetExtraction.scala.html @@ -90,7 +90,7 @@

Submit dataset for extraction

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); }); } diff --git a/app/views/extractions/submitFileExtraction.scala.html b/app/views/extractions/submitFileExtraction.scala.html index bb6182f7e..feeeb5c58 100644 --- a/app/views/extractions/submitFileExtraction.scala.html +++ b/app/views/extractions/submitFileExtraction.scala.html @@ -127,7 +127,7 @@

Submit file for extraction

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); }); } diff --git a/app/views/file.scala.html b/app/views/file.scala.html index 529bd534c..69fea6dfd 100644 --- a/app/views/file.scala.html +++ b/app/views/file.scala.html @@ -867,7 +867,7 @@

License

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); notify("Failed to archive file.", "error"); }); @@ -894,7 +894,7 @@

License

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); notify("Failed to unarchive file.", "error"); }); @@ -1078,7 +1078,7 @@

Tags

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a tag from a file."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The tag was not removed from the file due to : " + errorThrown, "error"); @@ -1142,7 +1142,7 @@

Tags

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to add a tag to a file."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The tag was not added to the file due to : " + errorThrown, "error"); diff --git a/app/views/files/share.scala.html b/app/views/files/share.scala.html index e4dfedadd..5ecb03a66 100644 --- a/app/views/files/share.scala.html +++ b/app/views/files/share.scala.html @@ -50,7 +50,7 @@

< }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a tag from a file."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The tag was not removed from the file due to : " + errorThrown, "error"); diff --git a/app/views/geostreams/map.scala.html b/app/views/geostreams/map.scala.html index 5a30532b5..d58b4f84c 100644 --- a/app/views/geostreams/map.scala.html +++ b/app/views/geostreams/map.scala.html @@ -126,7 +126,7 @@

Datapoints

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); }); } @@ -148,7 +148,7 @@

Datapoints

request.fail(function (jqXHR, textStatus, errorThrown){ console.error( - "The following error occured: "+ + "The following error occurred: "+ textStatus, errorThrown ); }); diff --git a/app/views/home.scala.html b/app/views/home.scala.html index d77196f94..8f907bb7b 100644 --- a/app/views/home.scala.html +++ b/app/views/home.scala.html @@ -583,7 +583,7 @@

@collectionInfo. }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); notify("Could not get moe events: " + errorThrown, "error"); }); } diff --git a/app/views/logoSelect.scala.html b/app/views/logoSelect.scala.html index 5aafeb113..f5515c9c3 100644 --- a/app/views/logoSelect.scala.html +++ b/app/views/logoSelect.scala.html @@ -79,7 +79,7 @@ }).done(function() { nextFunction(); }).fail(function(jqXHR) { - console.error("The following error occured: " + jqXHR.responseText); + console.error("The following error occurred: " + jqXHR.responseText); notify("The logo for @path/@name was not updated", "error"); }); } @@ -101,7 +101,7 @@ }).done(function(response, textStatus, jqXHR) { nextFunction(); }).fail(function(jqXHR) { - console.error("The following error occured: " + jqXHR.responseText); + console.error("The following error occurred: " + jqXHR.responseText); notify("The logo for @path/@name was not updated", "error"); }); break; @@ -125,7 +125,7 @@ }).done(function() { nextFunction(); }).fail(function(jqXHR) { - console.error("The following error occured: " + jqXHR.responseText); + console.error("The following error occurred: " + jqXHR.responseText); notify("The logo for @path/@name was not updated", "error"); }); } else { diff --git a/app/views/main.scala.html b/app/views/main.scala.html index c923fc311..aed1830b5 100644 --- a/app/views/main.scala.html +++ b/app/views/main.scala.html @@ -339,7 +339,7 @@ updateSelectedCount(response.length); }); request.fail(function (jqXHR, textStatus, errorThrown) { - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); if (errorThrown != "Unauthorized") { notify("Could not get selections: " + errorThrown, "error"); } @@ -384,7 +384,7 @@ location.reload() }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); notify("Could not delete selections: " + errorThrown, "error"); }); } @@ -406,7 +406,7 @@ location.reload() }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); notify("Could not clear selections: " + errorThrown, "error"); }); } @@ -457,7 +457,7 @@ notify("Tag(s) successfully added.", "success", false, 2000); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); notify("Could not tag selections: " + errorThrown, "error"); }); diff --git a/app/views/manageMetadataDefinitions.scala.html b/app/views/manageMetadataDefinitions.scala.html index 7bd957af8..4dbb29827 100644 --- a/app/views/manageMetadataDefinitions.scala.html +++ b/app/views/manageMetadataDefinitions.scala.html @@ -190,7 +190,7 @@ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to delete metadata definition"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Metadata definition was not removed due to : " + errorThrown, "error"); diff --git a/app/views/metadatald/addMetadata.scala.html b/app/views/metadatald/addMetadata.scala.html index 5d4a26181..64cbf0b08 100644 --- a/app/views/metadatald/addMetadata.scala.html +++ b/app/views/metadatald/addMetadata.scala.html @@ -216,7 +216,7 @@
Add metadata
}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to add metadata"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Metadata was not added due to : " + errorThrown, "error"); @@ -507,7 +507,7 @@
Add metadata
}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to retrieve metadata definitions"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Metadata was not added due to : " + errorThrown, "error"); diff --git a/app/views/metadatald/newCard.scala.html b/app/views/metadatald/newCard.scala.html index d9de55923..75af6fb6e 100644 --- a/app/views/metadatald/newCard.scala.html +++ b/app/views/metadatald/newCard.scala.html @@ -84,7 +84,7 @@ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to add metadata"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Metadata was not removed due to : " + errorThrown, "error"); @@ -131,7 +131,7 @@ request.fail(function (jqXHR, textStatus, errorThrown){ $("#panel_@m.id > #"+mid).removeClass("popping"); - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to retrieve metadata definitions"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Metadata context was not shown due to : " + errorThrown, "error"); diff --git a/app/views/metadatald/newTableRow.scala.html b/app/views/metadatald/newTableRow.scala.html index cb58b23b3..a903ccf7f 100644 --- a/app/views/metadatald/newTableRow.scala.html +++ b/app/views/metadatald/newTableRow.scala.html @@ -69,7 +69,7 @@ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to add metadata"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Metadata was not removed due to : " + errorThrown, "error"); @@ -116,7 +116,7 @@ request.fail(function (jqXHR, textStatus, errorThrown){ $("#"+mid).removeClass("popping"); - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to retrieve metadata definitions"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Metadata context was not shown due to : " + errorThrown, "error"); diff --git a/app/views/metadatald/search.scala.html b/app/views/metadatald/search.scala.html index 0a105f2a8..266ee25eb 100644 --- a/app/views/metadatald/search.scala.html +++ b/app/views/metadatald/search.scala.html @@ -164,7 +164,7 @@

Search Metadata within Space: "@space.name"

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to retrieve metadata definitions"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Unable to fetch Metadata definitions : " + errorThrown, "error"); @@ -494,7 +494,7 @@

Search Metadata within Space: "@space.name"

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); searching = false; }); } diff --git a/app/views/metadatald/view.scala.html b/app/views/metadatald/view.scala.html index 0b040c391..ce8cc0acc 100644 --- a/app/views/metadatald/view.scala.html +++ b/app/views/metadatald/view.scala.html @@ -223,7 +223,7 @@

Metadata

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to add metadata"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Metadata was not removed due to : " + errorThrown, "error"); @@ -270,7 +270,7 @@

Metadata

request.fail(function (jqXHR, textStatus, errorThrown){ $("#"+mid).removeClass("popping"); - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to retrieve metadata definitions"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Metadata context was not shown due to : " + errorThrown, "error"); diff --git a/app/views/searchResults.scala.html b/app/views/searchResults.scala.html index daf0bf7b8..c2b09e88a 100644 --- a/app/views/searchResults.scala.html +++ b/app/views/searchResults.scala.html @@ -179,7 +179,7 @@

Search

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); }); } diff --git a/app/views/selectDataset.scala.html b/app/views/selectDataset.scala.html index 3d4466c55..a2ec882ec 100644 --- a/app/views/selectDataset.scala.html +++ b/app/views/selectDataset.scala.html @@ -22,7 +22,7 @@ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+ textStatus, errorThrown); + console.error("The following error occurred: "+ textStatus, errorThrown); window.location = "../login"; // FIXME hardcoded }); }); diff --git a/app/views/spaces/spaceAllocation.scala.html b/app/views/spaces/spaceAllocation.scala.html index dbefc12ce..795796d09 100644 --- a/app/views/spaces/spaceAllocation.scala.html +++ b/app/views/spaces/spaceAllocation.scala.html @@ -142,7 +142,7 @@

Copy Collection to Space

}); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "Error message."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Error : " + errorThrown, "error"); diff --git a/app/views/viewDumpers.scala.html b/app/views/viewDumpers.scala.html index 73ba9fa99..9bf56689f 100644 --- a/app/views/viewDumpers.scala.html +++ b/app/views/viewDumpers.scala.html @@ -27,7 +27,7 @@

Data dumps

alert(response); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); alert("The metadata of the files (some or all of them) were not dumped due to : " + errorThrown); }); return false; @@ -43,7 +43,7 @@

Data dumps

alert(response); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); alert("The metadata of the datasets (some or all of them) were not dumped due to : " + errorThrown); }); return false; @@ -59,7 +59,7 @@

Data dumps

alert(response); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); alert("The file groupings of the datasets (some or all of them) were not dumped due to : " + errorThrown); }); return false; diff --git a/public/javascripts/DTSbookmarklet/jquery-1.7.2.js b/public/javascripts/DTSbookmarklet/jquery-1.7.2.js index 3774ff986..75ce26177 100644 --- a/public/javascripts/DTSbookmarklet/jquery-1.7.2.js +++ b/public/javascripts/DTSbookmarklet/jquery-1.7.2.js @@ -8249,7 +8249,7 @@ if ( jQuery.support.ajax ) { xml; // Firefox throws exceptions when accessing properties - // of an xhr when a network error occured + // of an xhr when a network error occurred // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) try { diff --git a/public/javascripts/adminIndex.js b/public/javascripts/adminIndex.js index d92be7a9e..9c510c9fc 100644 --- a/public/javascripts/adminIndex.js +++ b/public/javascripts/adminIndex.js @@ -61,7 +61,7 @@ function getAllAdapters() { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); }); } @@ -79,7 +79,7 @@ function getAllExtractors() { } }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); }); } @@ -95,7 +95,7 @@ function getAllMeasures() { } }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); }); } @@ -114,7 +114,7 @@ function getIndexers() { $("#indexerDropDown").html(''+availableIndexers); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); }); } @@ -135,7 +135,7 @@ function getIndexes() { $("#indexDel").html(''+availableIndexes); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); }); } @@ -369,7 +369,7 @@ var createBtn=document.getElementById('create'); }); request.done(function (data, textStatus, jqXHR){ console.log("data:", data); - console.log("Sucessfully created"); + console.log("Successfully created"); //update list of indexes everywhere on the page getIndexes(); //remove old info messages @@ -378,7 +378,7 @@ var createBtn=document.getElementById('create'); $('#createIndexFeedback').text( data); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); $('#createIndexFeedback').text( "Index could not be created"); }); } @@ -397,7 +397,7 @@ var buildBtn=document.getElementById('build'); $('#buildmsg').text(response); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); $('#buildmsg').text( "Could not build index"); }); } @@ -438,7 +438,7 @@ var listBtn=document.getElementById('list'); } }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); }); } @@ -458,7 +458,7 @@ var listBtn=document.getElementById('list'); $('#deletemsg').text(response); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); $('#deletemsg').text( "Could not delete index"); }); } @@ -480,7 +480,7 @@ var listBtn=document.getElementById('list'); $('#deleteallmsg').text(response); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); $('#deleteallmsg').text( "Could not delete all indexes"); }); } @@ -499,7 +499,7 @@ reindex.onclick=function(evt){ $('#reindexmsg').text(response.status); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); $('#reindexmsg').text( "Could not reindex"); }); } diff --git a/public/javascripts/collectionChildCollectionsList.js b/public/javascripts/collectionChildCollectionsList.js index 9c4f233b6..1c88adf82 100644 --- a/public/javascripts/collectionChildCollectionsList.js +++ b/public/javascripts/collectionChildCollectionsList.js @@ -39,7 +39,7 @@ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to add a child collection to a collection."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not added to the collection due to : " + errorThrown, "error"); @@ -60,7 +60,7 @@ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to remove a child collection from a collection."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The child collection was not removed from the collection due to : " + errorThrown, "error"); diff --git a/public/javascripts/collectionDatasetsList.js b/public/javascripts/collectionDatasetsList.js index 267674387..ce02925ed 100644 --- a/public/javascripts/collectionDatasetsList.js +++ b/public/javascripts/collectionDatasetsList.js @@ -37,7 +37,7 @@ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to add a dataset to a collection."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not added to the collection due to : " + errorThrown, "error"); @@ -58,7 +58,7 @@ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to remove a dataset from a collection."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not removed from the collection due to : " + errorThrown, "error"); diff --git a/public/javascripts/collectionListProcess.js b/public/javascripts/collectionListProcess.js index fe7b26702..191ead481 100644 --- a/public/javascripts/collectionListProcess.js +++ b/public/javascripts/collectionListProcess.js @@ -24,7 +24,7 @@ function removeCollection(id, isreload, newurl, resourceFromType){ } }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to remove a collection from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The collection was not removed due to : " + errorThrown, "error"); @@ -46,7 +46,7 @@ function removeCollectionAndRedirect(collectionId, url){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to delete a collection from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The collection was not deleted from the system due to : " + errorThrown, "error"); @@ -68,7 +68,7 @@ function removeChildCollectionFromParent(parentId, childId, url) { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a subcollection from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The child collection was not removed from the system due to : " + errorThrown, "error"); @@ -86,7 +86,7 @@ function restoreCollection(id,isreload,newurl){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to remove a collection from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The collection was not restored due to : " + errorThrown, "error"); diff --git a/public/javascripts/collectionModify.js b/public/javascripts/collectionModify.js index 43f541d06..a50244ff1 100644 --- a/public/javascripts/collectionModify.js +++ b/public/javascripts/collectionModify.js @@ -42,7 +42,7 @@ function addCollectionToParentCollection(id) { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to add a collection to a space."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The collection was not added to the space due to the following : " + errorThrown, "error"); @@ -86,7 +86,7 @@ function addDatasetToCollection(id) { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to add a dataset to a collection."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not added to the collection due to the following : " + errorThrown, "error"); diff --git a/public/javascripts/comment-delete.js b/public/javascripts/comment-delete.js index 18e48fe16..621e4f13b 100644 --- a/public/javascripts/comment-delete.js +++ b/public/javascripts/comment-delete.js @@ -15,13 +15,13 @@ function deleteComment(commentId, reloadPage){ }); request.done(function (response, textStatus, jqXHR){ - //Sucessful update of the DB - update the interface + //Successful update of the DB - update the interface deleteCommentCallback(commentId); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to delete a comment."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The comment was not deleted due to : " + errorThrown, "error"); diff --git a/public/javascripts/comment-edit.js b/public/javascripts/comment-edit.js index 31457eca7..b1d326f77 100644 --- a/public/javascripts/comment-edit.js +++ b/public/javascripts/comment-edit.js @@ -29,13 +29,13 @@ function editComment(commentId, commentText, senderName, senderEmail, commentLin }) }) }); - //Sucessful update of the DB - update the interface + //Successful update of the DB - update the interface $("#comment-body_" + commentId).html(theText.replace(/\n/g, "
")); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to edit a comment."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The comment was not edited due to : " + errorThrown, "error"); diff --git a/public/javascripts/curationProcess.js b/public/javascripts/curationProcess.js index 5b72a8e24..2797604b1 100644 --- a/public/javascripts/curationProcess.js +++ b/public/javascripts/curationProcess.js @@ -16,7 +16,7 @@ function removeCuration(id, isreload, url){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to delete a publication request from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The publication request was not deleted from the system due to : " + errorThrown, "error"); @@ -56,7 +56,7 @@ function removeCurationFile(id, currentFolder, curationid){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a file from the publication request"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("File was not removed from the request due to : " + jqXHR.textResponse, "error"); @@ -75,7 +75,7 @@ function removeCurationFolder(id, parentCurationObject, parentId){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a folder from the publication request"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Folder was not removed due to : " + errorThrown, "error"); @@ -107,7 +107,7 @@ function getUpdatedFilesAndFolders(curationObject, limit) { $('#files').html(response); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to see files and folders."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Error in getting more files and folders. : " + errorThrown, "error"); diff --git a/public/javascripts/dataset-attach-fileuploader.js b/public/javascripts/dataset-attach-fileuploader.js index ef1fbf4bd..25900ae4f 100644 --- a/public/javascripts/dataset-attach-fileuploader.js +++ b/public/javascripts/dataset-attach-fileuploader.js @@ -32,7 +32,7 @@ $(function () { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to add a dataset to a collection."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The fileset message was not generated due to : " + errorThrown, "error"); diff --git a/public/javascripts/datasetListProcess.js b/public/javascripts/datasetListProcess.js index c87d866b0..8058307c1 100644 --- a/public/javascripts/datasetListProcess.js +++ b/public/javascripts/datasetListProcess.js @@ -19,7 +19,7 @@ function removeDataset(datasetId, isreload, url){ } }); request.fail(function (jqXHR, textStatus, errorThrown) { - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to remove a dataset from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not removed due to : " + errorThrown, "error"); @@ -40,7 +40,7 @@ function restoreDataset(id,isreload,newurl){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to remove a collection from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The collection was not restored due to : " + errorThrown, "error"); @@ -61,7 +61,7 @@ function removeDatasetAndRedirect(datasetId, url){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to delete a dataset from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not deleted from the system due to : " + errorThrown, "error"); @@ -83,7 +83,7 @@ function detachAndRemoveDatasetAndRedirect(datasetId, url){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to detach files and then delete a dataset from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not deleted from the system due to : " + errorThrown, "error"); diff --git a/public/javascripts/datasets/collections.js b/public/javascripts/datasets/collections.js index 1d2df4e17..2fbe48223 100644 --- a/public/javascripts/datasets/collections.js +++ b/public/javascripts/datasets/collections.js @@ -37,7 +37,7 @@ function addToCollection(datasetId) { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to add a dataset to a collection."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not added to the collection due to the following : " + errorThrown, "error"); @@ -57,7 +57,7 @@ function removeFromCollection(collectionId, datasetId, event){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a dataset from a collection."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not removed from the collection due to : " + errorThrown, "error"); @@ -86,7 +86,7 @@ function removeDatasetFromCollectionAndRedirect(collectionId, datasetId, isreloa }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a dataset from a collection."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not removed from the collection due to : " + errorThrown, "error"); diff --git a/public/javascripts/deleteUtils.js b/public/javascripts/deleteUtils.js index 3d3ac61e7..b61d488ec 100644 --- a/public/javascripts/deleteUtils.js +++ b/public/javascripts/deleteUtils.js @@ -236,7 +236,7 @@ function clearTrashCollections(url){ window.location.href=url; }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to remove a collection from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The trash was not removed due to : " + errorThrown, "error"); @@ -252,7 +252,7 @@ function clearTrashDatasets(url){ window.location.href=url; }); request.fail(function (jqXHR, textStatus, errorThrown) { - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to remove a dataset from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset trash was not cleared due to : " + errorThrown, "error"); diff --git a/public/javascripts/file-uploader/jquery.fileupload-clowder-auth.js b/public/javascripts/file-uploader/jquery.fileupload-clowder-auth.js index 672fd5073..7922d1e41 100644 --- a/public/javascripts/file-uploader/jquery.fileupload-clowder-auth.js +++ b/public/javascripts/file-uploader/jquery.fileupload-clowder-auth.js @@ -31,7 +31,7 @@ $(function () { }); request.done(function (response, textStatus, jqXHR){ - //Sucessful call, so authenticated. Need to simply ensure that we have a user. It always should be there in + //Successful call, so authenticated. Need to simply ensure that we have a user. It always should be there in //this case, but log the odd corner case. var responseText = jqXHR.responseText; authInProcess = false; @@ -50,7 +50,7 @@ $(function () { request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("addCallback - fileUploader - The following error occured: " + textStatus, errorThrown); + console.error("addCallback - fileUploader - The following error occurred: " + textStatus, errorThrown); authInProcess = false; var errMsg = "You must be logged in to upload new files."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { @@ -112,7 +112,7 @@ $(function () { }); request.done(function (response, textStatus, jqXHR){ - //Sucessful call, so authenticated. Need to simply ensure that we have a user. It always should be there in + //Successful call, so authenticated. Need to simply ensure that we have a user. It always should be there in //this case, but log the odd corner case. var responseText = jqXHR.responseText; authInProcess = false; @@ -132,7 +132,7 @@ $(function () { request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("submitCallback - fileUploader - The following error occured: " + textStatus, errorThrown); + console.error("submitCallback - fileUploader - The following error occurred: " + textStatus, errorThrown); authInProcess = false; var errMsg = "You must be logged in to upload new files."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { diff --git a/public/javascripts/fileListProcess.js b/public/javascripts/fileListProcess.js index ff3da0aa9..c4cc6a2d3 100644 --- a/public/javascripts/fileListProcess.js +++ b/public/javascripts/fileListProcess.js @@ -21,7 +21,7 @@ function removeFile(fileId, isreload, url){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to delete a file from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The file was not deleted from the system due to : " + errorThrown, "error"); @@ -42,7 +42,7 @@ function removeFileAndRedirect(fileId, url){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to delete a file from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The file was not deleted from the system due to : " + errorThrown, "error"); diff --git a/public/javascripts/files/datasets.js b/public/javascripts/files/datasets.js index ad6ac8059..cf3f2642f 100644 --- a/public/javascripts/files/datasets.js +++ b/public/javascripts/files/datasets.js @@ -20,7 +20,7 @@ function moveFromDatasetToDataset(folderFromId, datasetFromId, fileId) { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to move a file to a dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The file was not moved to the dataset due to the following : " + errorThrown, "error"); @@ -52,7 +52,7 @@ function addToDataset(fileId) { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to add a file to a dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The file was not added to the dataset due to the following : " + errorThrown, "error"); @@ -71,7 +71,7 @@ function removeFromDataset(datasetId, fileId, event){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a file from a dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The file was not removed from the dataset due to : " + errorThrown, "error"); diff --git a/public/javascripts/files/main.js b/public/javascripts/files/main.js index fd256a918..d7dfcf352 100644 --- a/public/javascripts/files/main.js +++ b/public/javascripts/files/main.js @@ -26,7 +26,7 @@ function detachFile(fileId, fileName,event){ $("#fileUserMetadata_"+fileId).remove(); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to remove a file from a dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The file was not removed from the dataset due to : " + errorThrown, "error"); diff --git a/public/javascripts/folderListProcess.js b/public/javascripts/folderListProcess.js index 90155ebb0..5a637c33f 100644 --- a/public/javascripts/folderListProcess.js +++ b/public/javascripts/folderListProcess.js @@ -12,7 +12,7 @@ function removeFolder(folderId, parentDataset) { } }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to remove a folder from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The folder was not removed due to : " + errorThrown, "error"); diff --git a/public/javascripts/manageAdmins.js b/public/javascripts/manageAdmins.js index 8ed5ac170..f296e6729 100644 --- a/public/javascripts/manageAdmins.js +++ b/public/javascripts/manageAdmins.js @@ -19,7 +19,7 @@ function removeAdmin(email){ }); request.fail(function (jqXHR, textStatus, errorThrown){ console.error( - "The following error occured: "+ + "The following error occurred: "+ textStatus, errorThrown ); notify("ERROR: " + errorThrown +". Admin not removed.", error); diff --git a/public/javascripts/manageRoles.js b/public/javascripts/manageRoles.js index 50f7819c1..6b6cf8f1f 100644 --- a/public/javascripts/manageRoles.js +++ b/public/javascripts/manageRoles.js @@ -15,7 +15,7 @@ function removeRole(roleId, url) }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in and be an administrator to remove a role from the system."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The role was not deleted from the system due to : " + errorThrown, "error"); diff --git a/public/javascripts/metadata/addMetadata.js b/public/javascripts/metadata/addMetadata.js index 5a856d48f..9ac91a1cb 100644 --- a/public/javascripts/metadata/addMetadata.js +++ b/public/javascripts/metadata/addMetadata.js @@ -85,7 +85,7 @@ function loadExternalResource(field_label, field_description, field_id, field_ty }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); notify("Could not retrieve external vocabulary: " + errorThrown, "error"); }); @@ -228,7 +228,7 @@ function loadExternalResource(field_label, field_description, field_id, field_ty }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); notify("Could not retrieve external vocabulary: " + errorThrown, "error"); }); } diff --git a/public/javascripts/people.js b/public/javascripts/people.js index 2b8b74c39..9b62f09e2 100644 --- a/public/javascripts/people.js +++ b/public/javascripts/people.js @@ -26,7 +26,7 @@ request.fail(function (jqXHR, textStatus, errorThrown){ if(jqXHR.status != 404) { - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); } }); } diff --git a/public/javascripts/previewers/sectionRubberband.js b/public/javascripts/previewers/sectionRubberband.js index 1edd0706b..ce88d349c 100644 --- a/public/javascripts/previewers/sectionRubberband.js +++ b/public/javascripts/previewers/sectionRubberband.js @@ -314,7 +314,7 @@ function rubberbandAddText(tag, comment, sectionid, prNum) { request.done(function (response, textStatus, jqXHR) { }); request.fail(function (jqXHR, textStatus, errorThrown) { - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); window.jsRoutes.api.Sections.delete(sectionid).ajax({ type: "DELETE", contentType: "application/json" diff --git a/public/javascripts/previewers/x3dom/some-library.js b/public/javascripts/previewers/x3dom/some-library.js index 42bf6b71d..38eefc137 100644 --- a/public/javascripts/previewers/x3dom/some-library.js +++ b/public/javascripts/previewers/x3dom/some-library.js @@ -169,7 +169,7 @@ function clearConfigTabAnnotations(prNum){ request.fail(function (jqXHR, textStatus, errorThrown){ console.error( - "The following error occured: "+ + "The following error occurred: "+ textStatus, errorThrown ); notify("ERROR: " + errorThrown +". Annotation edit not submitted.", "error"); @@ -301,7 +301,7 @@ function clearConfigTabAnnotations(prNum){ request.fail(function (jqXHR, textStatus, errorThrown){ console.error( - "The following error occured: "+ + "The following error occurred: "+ textStatus, errorThrown ); notify("ERROR: " + errorThrown +". Annotation not submitted.", "error"); diff --git a/public/javascripts/repositories.js b/public/javascripts/repositories.js index 3fee59c13..751ec6ef0 100644 --- a/public/javascripts/repositories.js +++ b/public/javascripts/repositories.js @@ -24,7 +24,7 @@ function expandRepositories() { request.fail(function(jqXHR, textStatus, errorThrown) { if (jqXHR.status != 404) { - console.error("The following error occured: " + textStatus, + console.error("The following error occurred: " + textStatus, errorThrown); } }); diff --git a/public/javascripts/searchUserMetadata.js b/public/javascripts/searchUserMetadata.js index f7884bb15..e8ffde016 100644 --- a/public/javascripts/searchUserMetadata.js +++ b/public/javascripts/searchUserMetadata.js @@ -536,7 +536,7 @@ $(function() { request.fail(function (jqXHR, textStatus, errorThrown){ console.error( - "The following error occured: "+ + "The following error occurred: "+ textStatus, errorThrown ); notify("ERROR: " + errorThrown +". Search not executed.", "error"); diff --git a/public/javascripts/sectionsListProcess.js b/public/javascripts/sectionsListProcess.js index 522ef77af..96d252367 100644 --- a/public/javascripts/sectionsListProcess.js +++ b/public/javascripts/sectionsListProcess.js @@ -19,7 +19,7 @@ $('#sectiondescrEdit_'+id).css("display","inline"); }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to submit a section description."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { alert("The section description was not posted due to : " + errorThrown); diff --git a/public/javascripts/sensors/assign.js b/public/javascripts/sensors/assign.js index 44208be0c..3b43f3673 100644 --- a/public/javascripts/sensors/assign.js +++ b/public/javascripts/sensors/assign.js @@ -11,7 +11,7 @@ function associateWithSensor(resource_type, item_id, dashboard_url) { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); }); return false; @@ -64,7 +64,7 @@ function associateItemWithSensor(resource_type, item_id, sensor_id, sensor_name, }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); }); return false; diff --git a/public/javascripts/sensors/removeRelation.js b/public/javascripts/sensors/removeRelation.js index d282d8427..1b1fc0b28 100644 --- a/public/javascripts/sensors/removeRelation.js +++ b/public/javascripts/sensors/removeRelation.js @@ -12,7 +12,7 @@ function removeRelation(relation_id) { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); if (errorThrown == 'Unauthorized') { window.alert("You are not authorized to remove the relationship."); } diff --git a/public/javascripts/spaceModify.js b/public/javascripts/spaceModify.js index 36c02a91f..3cead258a 100644 --- a/public/javascripts/spaceModify.js +++ b/public/javascripts/spaceModify.js @@ -44,7 +44,7 @@ function addCollectionToSpace(id,spaceTitle) { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to add a collection"; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The collection was not added due to the following : " + errorThrown, "error"); @@ -68,7 +68,7 @@ function removeCollectionFromSpace(spaceId, id, event){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a collection."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The collection was not removed due to : " + errorThrown, "error"); @@ -101,7 +101,7 @@ function removeCollectionFromSpaceAndRedirect(spaceId, collectionId, isreload, u }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a collection."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The collection was not removed due to : " + errorThrown, "error"); @@ -149,7 +149,7 @@ function addDatasetToSpace(id, spaceTitle) { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to add a dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not added due to the following : " + errorThrown, "error"); @@ -191,7 +191,7 @@ function removeDatasetFromSpace(spaceId, datasetId, event){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not removed due to : " + errorThrown, "error"); @@ -229,7 +229,7 @@ function removeDatasetFromSpaceAndRedirect(spaceId, datasetId, isreload, url){ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to remove a dataset."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The dataset was not removed due to : " + errorThrown, "error"); @@ -309,7 +309,7 @@ function acceptSpaceRequest(spaceId, userId, userName){ console.log("Successful accept request"); }); request.fail(function(jqXHR, textStatus, errorThrown) { - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to accept request."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Accept request failed due to : " + errorThrown, "error"); @@ -330,7 +330,7 @@ function rejectSpaceRequest(id, user){ console.log("Successful reject request"); }); request.fail(function(jqXHR, textStatus, errorThrown) { - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to reject request."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("Reject request failed due to : " + errorThrown, "error"); diff --git a/public/javascripts/spaceconfiguration.js b/public/javascripts/spaceconfiguration.js index 621b383e8..f1c09258a 100644 --- a/public/javascripts/spaceconfiguration.js +++ b/public/javascripts/spaceconfiguration.js @@ -42,7 +42,7 @@ function updateSpaceConfig(spaceId) { request.done(function (response, textStatus, jqXHR){ console.log("Response " + response); - //Sucessful update of the DB - update the interface + //Successful update of the DB - update the interface $("#spacedescdisplay").text(htmlDecode(encDescription)); $("#spacenamedisplay").text(htmlDecode(encName)); @@ -58,7 +58,7 @@ function updateSpaceConfig(spaceId) { }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+textStatus, errorThrown); + console.error("The following error occurred: "+textStatus, errorThrown); var errMsg = "You must be logged in to update the information about a space."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { alert("The space information was not updated due to : " + errorThrown); diff --git a/public/javascripts/updateLicenseInfo.js b/public/javascripts/updateLicenseInfo.js index b32bfeea8..4bbc4c696 100644 --- a/public/javascripts/updateLicenseInfo.js +++ b/public/javascripts/updateLicenseInfo.js @@ -176,7 +176,7 @@ function updateData(id, imageBase, sourceObject, authorName) { request.done(function (response, textStatus, jqXHR){ //console.log("Response " + response); - //Sucessful update of the DB + //Successful update of the DB updateInterface(licenseType, rightsHolder, licenseText, licenseUrl, allowDownload, imageBase, authorName); $("#editlicense").addClass('collapsed'); @@ -185,7 +185,7 @@ function updateData(id, imageBase, sourceObject, authorName) { request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: " + textStatus, errorThrown); + console.error("The following error occurred: " + textStatus, errorThrown); var errMsg = "You must be logged in to edit license information."; if (!checkErrorAndRedirect(jqXHR, errMsg)) { notify("The license information was not modified due to : " + errorThrown, "error"); diff --git a/public/javascripts/userMetadata.js b/public/javascripts/userMetadata.js index d3b17e9ee..d0a526f8e 100644 --- a/public/javascripts/userMetadata.js +++ b/public/javascripts/userMetadata.js @@ -189,7 +189,7 @@ }); request.fail(function (jqXHR, textStatus, errorThrown){ - console.error("The following error occured: "+ textStatus, errorThrown); + console.error("The following error occurred: "+ textStatus, errorThrown); notify("Encountered error " + errorThrown + ". Metadata not added.", true) }); From 92fdd3db5f93e99d9eecac0660da5140a3228433 Mon Sep 17 00:00:00 2001 From: Tim Yardley Date: Wed, 18 Dec 2019 21:55:40 -0600 Subject: [PATCH 6/9] decouple bagit from clowder.ncsa.illinois.edu to just clowder as an app --- app/Iterators/BagItIterator.scala | 4 ++-- app/api/Datasets.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Iterators/BagItIterator.scala b/app/Iterators/BagItIterator.scala index 8092f9b2d..17d386d9b 100644 --- a/app/Iterators/BagItIterator.scala +++ b/app/Iterators/BagItIterator.scala @@ -20,7 +20,7 @@ class BagItIterator(pathToFolder : String, collection : Option[models.Collection private def addBagItTextToZip(pathToFolder : String, totalbytes: Long, totalFiles: Long, zip: ZipOutputStream, collection: models.Collection, user: Option[models.User]) = { zip.putNextEntry(new ZipEntry(pathToFolder + "/bagit.txt")) - val softwareLine = "Bag-Software-Agent: clowder.ncsa.illinois.edu\n" + val softwareLine = "Bag-Software-Agent: clowder\n" val baggingDate = "Bagging-Date: " + (new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(Calendar.getInstance.getTime) + "\n" val baggingSize = "Bag-Size: " + totalbytes + "\n" val payLoadOxum = "Payload-Oxum: " + totalbytes + "." + totalFiles + "\n" @@ -41,7 +41,7 @@ class BagItIterator(pathToFolder : String, collection : Option[models.Collection // If no collection provided, assume this is for Selected download private def addBagItTextToZip(pathToFolder : String, totalbytes: Long, totalFiles: Long, zip: ZipOutputStream, user: Option[models.User]) = { zip.putNextEntry(new ZipEntry(pathToFolder + "/bagit.txt")) - val softwareLine = "Bag-Software-Agent: clowder.ncsa.illinois.edu\n" + val softwareLine = "Bag-Software-Agent: clowder\n" val baggingDate = "Bagging-Date: " + (new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(Calendar.getInstance.getTime) + "\n" val baggingSize = "Bag-Size: " + totalbytes + "\n" val payLoadOxum = "Payload-Oxum: " + totalbytes + "." + totalFiles + "\n" diff --git a/app/api/Datasets.scala b/app/api/Datasets.scala index ba9b737c2..c020b7fb9 100644 --- a/app/api/Datasets.scala +++ b/app/api/Datasets.scala @@ -2370,7 +2370,7 @@ class Datasets @Inject()( private def addBagItTextToZip(totalbytes: Long, totalFiles: Long, zip: ZipOutputStream, dataset: models.Dataset, user: Option[models.User]) = { zip.putNextEntry(new ZipEntry("bagit.txt")) - val softwareLine = "Bag-Software-Agent: clowder.ncsa.illinois.edu\n" + val softwareLine = "Bag-Software-Agent: clowder\n" val baggingDate = "Bagging-Date: " + (new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(Calendar.getInstance.getTime) + "\n" val baggingSize = "Bag-Size: " + _root_.util.Formatters.humanReadableByteCount(totalbytes) + "\n" val payLoadOxum = "Payload-Oxum: " + totalbytes + "." + totalFiles + "\n" From 615a25e6be0f040c371d551f67925ca61dead14d Mon Sep 17 00:00:00 2001 From: Tim Yardley Date: Wed, 18 Dec 2019 22:07:02 -0600 Subject: [PATCH 7/9] remove some hardcoded clowder.ncsa links, and add fixme for others --- app/api/Events.scala | 1 + app/services/mongodb/MongoSalatPlugin.scala | 5 +++++ app/util/Mail.scala | 1 + app/views/bookmarklet.scala.html | 1 + app/views/emails/footer.scala.html | 2 +- app/views/main.scala.html | 2 +- 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/api/Events.scala b/app/api/Events.scala index 9e420244a..0c711f588 100644 --- a/app/api/Events.scala +++ b/app/api/Events.scala @@ -35,6 +35,7 @@ class Events @Inject() (events: EventService, " branch:" + sys.props.getOrElse("build.branch", default = "unknown") +" sha1:" + sys.props.getOrElse("build.gitsha1", default = "unknown") + "

\n" + "

Request: " + re + "

\n" + "

Error: " + ex + "

") + // FIXME: hardcoded email val recipient: String = "opensource+clowder@ncsa.illinois.edu" Mail.sendEmail(subject, request.user, recipient, body) Ok(toJson("Send Email success")) diff --git a/app/services/mongodb/MongoSalatPlugin.scala b/app/services/mongodb/MongoSalatPlugin.scala index 2e994e691..b94922266 100644 --- a/app/services/mongodb/MongoSalatPlugin.scala +++ b/app/services/mongodb/MongoSalatPlugin.scala @@ -643,6 +643,7 @@ class MongoSalatPlugin(app: Application) extends Plugin { if (umd.keySet().size() > 0) { val userMD = Json.parse(com.mongodb.util.JSON.serialize(umd)) val user = User.anonymous + // FIXME: hardcoded URL val userURI = "https://clowder.ncsa.illinois.edu/clowder/api/users/" + user.id val creatorUser = UserAgent(user.id, "cat:user", MiniUser(user.id, user.fullName, user.avatarUrl.getOrElse(""), user.email), Some(new URL(userURI))) val metadataUser = models.Metadata(UUID.generate(), attachedTo.get, contextID, contextURL, createdAt, creatorUser, userMD, version) @@ -656,6 +657,7 @@ class MongoSalatPlugin(app: Application) extends Plugin { case Some(tmd) => { if (tmd.keySet().size() > 0) { val techMD = Json.parse(com.mongodb.util.JSON.serialize(tmd)) + // FIXME: hardcoded URL val creatorExtractor = ExtractorAgent(id = UUID.generate(), extractorId = Some(new URL("http://clowder.ncsa.illinois.edu/extractors/migration"))) val metadataTech = models.Metadata(UUID.generate(), attachedTo.get, contextID, contextURL, createdAt, creatorExtractor, techMD, version) metadataService.addMetadata(metadataTech) @@ -682,6 +684,7 @@ class MongoSalatPlugin(app: Application) extends Plugin { if (umd.keySet().size() > 0) { val userMD = Json.parse(com.mongodb.util.JSON.serialize(umd)) val user = User.anonymous + // FIXME: hardcoded URL val userURI = "https://clowder.ncsa.illinois.edu/clowder/api/users/" + user.id val creatorUser = UserAgent(user.id, "cat:user", MiniUser(user.id, user.fullName, user.avatarUrl.getOrElse(""), user.email), Some(new URL(userURI))) val metadataUser = models.Metadata(UUID.generate(), attachedTo.get, contextID, contextURL, createdAt, creatorUser, userMD, version) @@ -697,12 +700,14 @@ class MongoSalatPlugin(app: Application) extends Plugin { val tmdlist = tmd.asInstanceOf[BasicDBList] tmdlist.foreach { x => val techMD = Json.parse(com.mongodb.util.JSON.serialize(x)) + // FIXME: hardcoded URL val creatorExtractor = ExtractorAgent(id = UUID.generate(), extractorId = Some(new URL("http://clowder.ncsa.illinois.edu/extractors/migration"))) val metadataTech = models.Metadata(UUID.generate(), attachedTo.get, contextID, contextURL, createdAt, creatorExtractor, techMD, version) metadataService.addMetadata(metadataTech) } } else { val techMD = Json.parse(com.mongodb.util.JSON.serialize(tmd)) + // FIXME: hardcoded URL val creatorExtractor = ExtractorAgent(id = UUID.generate(), extractorId = Some(new URL("http://clowder.ncsa.illinois.edu/extractors/migration"))) val metadataTech = models.Metadata(UUID.generate(), attachedTo.get, contextID, contextURL, createdAt, creatorExtractor, techMD, version) metadataService.addMetadata(metadataTech) diff --git a/app/util/Mail.scala b/app/util/Mail.scala index 2f8dce106..7bdd9cef7 100644 --- a/app/util/Mail.scala +++ b/app/util/Mail.scala @@ -96,6 +96,7 @@ object Mail { } private def emailAddress(user: Option[User]): String = { + // FIXME: hardcoded email val from = current.configuration.getString("smtp.from").getOrElse("devnull@ncsa.illinois.edu") val name = current.configuration.getString("smtp.fromName").getOrElse("Clowder") user match { diff --git a/app/views/bookmarklet.scala.html b/app/views/bookmarklet.scala.html index 8cb728b40..b6da8190a 100644 --- a/app/views/bookmarklet.scala.html +++ b/app/views/bookmarklet.scala.html @@ -507,6 +507,7 @@ .attr('width', '100'); var link = jQuery('
') + // FIXME: hardcoded URL .attr('href', 'http://browndog.ncsa.illinois.edu') .attr('id', 'poweredby') .css('position', 'fixed') diff --git a/app/views/emails/footer.scala.html b/app/views/emails/footer.scala.html index 9b1662cc9..2c0088c3c 100644 --- a/app/views/emails/footer.scala.html +++ b/app/views/emails/footer.scala.html @@ -7,7 +7,7 @@ @if(sender!="") {This message was sent on behalf of @sender.
} This message was sent by @AppConfiguration.getDisplayName an - instance of Clowder running + instance of Clowder running @sys.props.getOrElse("build.version", default = "0.0.0")#@sys.props.getOrElse("build.bamboo", default = "development")
If you have any questions about this email please contact the server admins.
diff --git a/app/views/main.scala.html b/app/views/main.scala.html index aed1830b5..7af5f5d11 100644 --- a/app/views/main.scala.html +++ b/app/views/main.scala.html @@ -291,7 +291,7 @@
-

Powered by Clowder +

Powered by Clowder (@sys.props.getOrElse("build.version", default = "0.0.0")#@sys.props.getOrElse("build.bamboo", default = "development") branch:@sys.props.getOrElse("build.branch", default = "unknown") sha1:@sys.props.getOrElse("build.gitsha1", default = "unknown")).

From 01447f599c89e7faebc389e7a430c22ab5af9c7a Mon Sep 17 00:00:00 2001 From: Tim Yardley Date: Wed, 18 Dec 2019 22:11:51 -0600 Subject: [PATCH 8/9] revert Global.scala change... not sure where that came from --- app/Global.scala | 223 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 165 insertions(+), 58 deletions(-) diff --git a/app/Global.scala b/app/Global.scala index 3f5c264b9..24adc32b8 100644 --- a/app/Global.scala +++ b/app/Global.scala @@ -1,71 +1,178 @@ -import models.UUID -import play.api.mvc._ -import com.mongodb.casbah.Imports._ -import org.bson.types.ObjectId -import play.api.libs.json._ -import play.api.data.validation.ValidationError - -object Binders { - - type ObjectId = org.bson.types.ObjectId - - /** - * QueryString binder for ObjectId - */ - implicit def objectIdQueryStringBindable = new QueryStringBindable[ObjectId] { - def bind(key: String, params: Map[String, Seq[String]]) = params.get(key).flatMap(_.headOption).map { value => - if (ObjectId.isValid(value)) - Right(new ObjectId(value)) - else - Left("Cannot parse parameter " + key + " as ObjectId") +import java.io.{PrintWriter, StringWriter} +import java.time.Duration +import java.time.ZonedDateTime +import java.time.temporal.ChronoUnit + +import play.api.{Application, GlobalSettings} +import play.api.Logger +import play.filters.gzip.GzipFilter +import play.libs.Akka +import securesocial.core.SecureSocial +import services.{AppConfiguration, AppConfigurationService, CollectionService, DI, DatasetService, FileService, SpaceService, UserService} + +import scala.concurrent.Future +import scala.concurrent.duration._ +import play.api.libs.concurrent.Execution.Implicits._ +import models._ +import java.util.{Calendar, Date} + +import play.api.mvc.{RequestHeader, WithFilters} +import play.api.mvc.Results._ +import akka.actor.Cancellable +import filters.CORSFilter +import julienrf.play.jsonp.Jsonp +import play.Play +import play.api.Play.configuration +import play.api.libs.json.Json._ + +/** + * Configure application. Ensure mongo indexes if mongo plugin is enabled. + * + * @author Luigi Marini + */ +object Global extends WithFilters(new GzipFilter(), new Jsonp(), CORSFilter()) with GlobalSettings { + var extractorTimer: Cancellable = null + var jobTimer: Cancellable = null + var archivalTimer: Cancellable = null + + + override def onStart(app: Application) { + val appConfig: AppConfigurationService = DI.injector.getInstance(classOf[AppConfigurationService]) + val files: FileService = DI.injector.getInstance(classOf[FileService]) + + ServerStartTime.startTime = Calendar.getInstance().getTime + Logger.debug("\n----Server Start Time----" + ServerStartTime.startTime + "\n \n") + + val users: UserService = DI.injector.getInstance(classOf[UserService]) + + // set the default ToS version + AppConfiguration.setDefaultTermsOfServicesVersion() + + // add all new admins + users.updateAdmins() + + // create default roles + if (users.listRoles().isEmpty) { + Logger.debug("Ensuring roles exist") + users.updateRole(Role.Admin) + users.updateRole(Role.Editor) + users.updateRole(Role.Viewer) } - def unbind(key: String, value: ObjectId) = key + "=" + value.toString - } - /** - * Path binder for ObjectId. - */ - implicit def objectIdPathBindable = new PathBindable[ObjectId] { - def bind(key: String, value: String) = { - if (ObjectId.isValid(value)) - Right(new ObjectId(value)) - else - Left("Cannot parse parameter " + key + " as ObjectId") + // set default metadata definitions + MetadataDefinition.registerDefaultDefinitions() + + val archiveEnabled = Play.application.configuration.getBoolean("archiveEnabled", false) + if (archiveEnabled && archivalTimer == null) { + val archiveDebug = Play.application.configuration.getBoolean("archiveDebug", false) + val interval = if (archiveDebug) { 5 minutes } else { 1 day } + + // Determine time until next midnight + val now = ZonedDateTime.now + val midnight = now.truncatedTo(ChronoUnit.DAYS) + val sinceLastMidnight = Duration.between(midnight, now).getSeconds + val delay = if (archiveDebug) { 10 seconds } else { + (Duration.ofDays(1).getSeconds - sinceLastMidnight) seconds + } + + Logger.info("Starting archival loop - first iteration in " + delay + ", next iteration after " + interval) + archivalTimer = Akka.system.scheduler.schedule(delay, interval) { + Logger.info("Starting auto archive process...") + files.autoArchiveCandidateFiles() + } } - def unbind(key: String, value: ObjectId) = value.toString + + if (extractorTimer == null) { + extractorTimer = Akka.system().scheduler.schedule(0 minutes, 5 minutes) { + ExtractionInfoSetUp.updateExtractorsInfo() + } + } + + if (jobTimer == null) { + jobTimer = Akka.system().scheduler.schedule(0 minutes, 1 minutes) { + JobsScheduler.runScheduledJobs() + } + } + + // Get database counts from appConfig; generate them if unavailable or user count = 0 + appConfig.getProperty[Long]("countof.bytes") match { + case Some(filesBytes) => + Logger.info("Byte count found in appConfig; skipping database counting") + case None => { + // Reset byte count to zero before incrementing + appConfig.resetCount('bytes) + + Logger.info("Byte count not found in appConfig; scheduling database counting in 10s...") + Akka.system().scheduler.scheduleOnce(10 seconds) { + Logger.debug("Initializing appConfig byte count...") + val files: FileService = DI.injector.getInstance(classOf[FileService]) + + // Store the byte count in appConfig so it can be fetched quickly later + appConfig.incrementCount('bytes, files.bytes()) + Logger.info("Initialized appConfig byte count") + } + } + } + + Logger.info("Application has started") } - /** - * Convert a ObjectId to a Javascript String - */ - implicit def objectIdJavascriptLitteral = new JavascriptLitteral[ObjectId] { - def to(value: ObjectId) = value.toString + override def onStop(app: Application) { + extractorTimer.cancel() + jobTimer.cancel() + Logger.info("Application shutdown") + } + + private lazy val injector = services.DI.injector + private lazy val users: UserService = DI.injector.getInstance(classOf[UserService]) + + /** Used for dynamic controller dispatcher **/ + override def getControllerInstance[A](clazz: Class[A]) = { + injector.getInstance(clazz) + } + + override def onError(request: RequestHeader, ex: Throwable) = { + val sw = new StringWriter() + val pw = new PrintWriter(sw) + ex.printStackTrace(pw) + + if (request.path.contains("/api/")) { + Future(InternalServerError(toJson(Map("status" -> "error", + "request" -> request.toString(), + "exception" -> sw.toString.replace("\n", "\\n"))))) + } else { + implicit val user = SecureSocial.currentUser(request) match{ + case Some(identity) => users.findByIdentity(identity) + case None => None + } + Future(InternalServerError(views.html.errorPage(request, sw.toString)(user))) + } } - /** - * UUID path binder - */ - implicit def uuidPathBinder(implicit stringBinder: PathBindable[String]) = new PathBindable[UUID] { - override def bind(key: String, value: String): Either[String, UUID] = { - if (UUID.isValid(value)) - Right(UUID(value)) - else - Left(s"Cannot parse parameter $key") + override def onHandlerNotFound(request: RequestHeader) = { + if (request.path.contains("/api/")) { + Future(NotFound(toJson(Map("status" -> "not found", + "request" -> request.toString())))) + } else { + implicit val user = SecureSocial.currentUser(request) match { + case Some(identity) => users.findByIdentity(identity) + case None => None + } + Future(NotFound(views.html.errorPage(request, "Not found")(user))) } - override def unbind(key: String, uuid: UUID): String = uuid.stringify } - /** - * UUID query binder - */ - implicit def uuidQueryBinder(implicit stringBinder: QueryStringBindable[String]) = new QueryStringBindable[UUID] { - override def bind(key: String, params: Map[String, Seq[String]]): Option[Either[String, UUID]] = { - val value = params(key)(0) - if (UUID.isValid(value)) - Some(Right(UUID(value))) - else - Some(Left(s"Cannot parse parameter $key")) + override def onBadRequest(request: RequestHeader, error: String) = { + if (request.path.contains("/api/")) { + Future(BadRequest(toJson(Map("status" -> ("bad request"), + "message" -> error, + "request" -> request.toString())))) + } else { + implicit val user = SecureSocial.currentUser(request) match { + case Some(identity) => users.findByIdentity(identity) + case None => None + } + Future(BadRequest(views.html.errorPage(request, error)(user))) } - override def unbind(key: String, uuid: UUID): String = uuid.stringify } } From 52b68d2a8c7b2e55308dc422da9f09a3a8501944 Mon Sep 17 00:00:00 2001 From: Tim Yardley Date: Thu, 9 Jan 2020 10:28:04 -0600 Subject: [PATCH 9/9] cleanup spurious beta character --- app/services/ToolManagerPlugin.scala | 2 +- app/services/mongodb/MongoDBFileService.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/ToolManagerPlugin.scala b/app/services/ToolManagerPlugin.scala index 4b1c66bc2..b81e9b0df 100644 --- a/app/services/ToolManagerPlugin.scala +++ b/app/services/ToolManagerPlugin.scala @@ -310,7 +310,7 @@ class ToolManagerPlugin(application: Application) extends Plugin { val apipath = play.Play.application().configuration().getString("toolmanagerURI") + "/instances/" + instance.toolPath val statusRequest: Future[Response] = url(apipath).put(Json.obj( - "dataset" -> (dsURL.replace("/datasets", "/api/datasets") + ß"/download"), + "dataset" -> (dsURL.replace("/datasets", "/api/datasets") + "/download"), "key" -> play.Play.application().configuration().getString("commKey"), "id" -> instance.externalId.toString, "uploaderId" -> oId, diff --git a/app/services/mongodb/MongoDBFileService.scala b/app/services/mongodb/MongoDBFileService.scala index a68ada9b4..50d9c5a29 100644 --- a/app/services/mongodb/MongoDBFileService.scala +++ b/app/services/mongodb/MongoDBFileService.scala @@ -918,7 +918,7 @@ class MongoDBFileService @Inject() ( def searchUserMetadataFormulateQuery(requestedMetadataQuery: Any): List[File] = { Logger.debug("top: " + requestedMetadataQuery.asInstanceOf[java.util.LinkedHashMap[String,Any]].toString() ) var theQuery = searchMetadataFormulateQuery(requestedMetadataQuery.asInstanceOf[java.util.LinkedHashMap[String,Any]], "userMetadata") - Logger.debug("thequery: " + ßtheQuery.toString) + Logger.debug("thequery: " + theQuery.toString) FileDAO.find(theQuery).toList }