Skip to content

Commit ab7b3fb

Browse files
committed
replace all line breaks with space to ensure swagger build
1 parent ccfe3df commit ab7b3fb

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

app/controllers/Application.scala

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import scala.collection.mutable.ListBuffer
1616
* Main application controller.
1717
*/
1818
@Singleton
19-
class Application @Inject() (files: FileService, collections: CollectionService, datasets: DatasetService,
20-
spaces: SpaceService, events: EventService, comments: CommentService,
21-
sections: SectionService, users: UserService, selections: SelectionService) extends SecuredController {
19+
class Application @Inject()(files: FileService, collections: CollectionService, datasets: DatasetService,
20+
spaces: SpaceService, events: EventService, comments: CommentService,
21+
sections: SectionService, users: UserService, selections: SelectionService) extends SecuredController {
2222
/**
2323
* Redirect any url's that have a trailing /
2424
*
@@ -34,10 +34,10 @@ class Application @Inject() (files: FileService, collections: CollectionService,
3434
Redirect("http://clowder.ncsa.illinois.edu/swagger/?url=" + swagger)
3535
}
3636

37-
/**
38-
* Returns the swagger documentation customized for this site.
39-
*/
40-
def swagger = Action { implicit request =>
37+
/**
38+
* Returns the swagger documentation customized for this site.
39+
*/
40+
def swagger = Action { implicit request =>
4141
Play.resource("/public/swagger.yml") match {
4242
case Some(resource) => {
4343
val https = Utils.https(request)
@@ -62,7 +62,8 @@ class Application @Inject() (files: FileService, collections: CollectionService,
6262
skipit = true
6363
"info:\n" +
6464
" title: " + AppConfiguration.getDisplayName + "\n" +
65-
" description: " + AppConfiguration.getWelcomeMessage + "\n" +
65+
// replace line breaks with space so swagger can build
66+
" description: " + AppConfiguration.getWelcomeMessage.replaceAll("\\n|\\r|\\r\\n", " ") + "\n" +
6667
" version: \"" + sys.props.getOrElse("build.version", default = "0.0.0").toString + "\"\n" +
6768
" termsOfService: " + routes.Application.tos().absoluteURL(https) + "\n" +
6869
" contact: " + "\n" +
@@ -89,29 +90,29 @@ class Application @Inject() (files: FileService, collections: CollectionService,
8990
def index = UserAction(needActive = false) { implicit request =>
9091
val appConfig: AppConfigurationService = DI.injector.getInstance(classOf[AppConfigurationService])
9192

92-
implicit val user = request.user
93+
implicit val user = request.user
9394

9495
var newsfeedEvents = List.empty[Event]
9596
if (!play.Play.application().configuration().getBoolean("clowder.disable.events", false)) {
9697
newsfeedEvents = user.fold(List.empty[Event])(u => events.getEvents(u.followedEntities, Some(20)))
97-
newsfeedEvents = newsfeedEvents ::: events.getRequestEvents(user, Some(20))
98+
newsfeedEvents = newsfeedEvents ::: events.getRequestEvents(user, Some(20))
9899
if (user.isDefined) {
99100
newsfeedEvents = (newsfeedEvents ::: events.getEventsByUser(user.get, Some(20)))
100101
.sorted(Ordering.by((_: Event).created).reverse).distinct.take(20)
101102
}
102103
}
103104

104105
user match {
105-
case Some(clowderUser) if (clowderUser.status==UserStatus.Inactive) => {
106+
case Some(clowderUser) if (clowderUser.status == UserStatus.Inactive) => {
106107
Redirect(routes.Error.notActivated())
107108
}
108-
case Some(clowderUser) if !(clowderUser.status==UserStatus.Inactive) => {
109+
case Some(clowderUser) if !(clowderUser.status == UserStatus.Inactive) => {
109110
newsfeedEvents = newsfeedEvents ::: events.getEventsByUser(clowderUser, Some(20))
110-
if( play.Play.application().configuration().getBoolean("showCommentOnHomepage")) newsfeedEvents = newsfeedEvents :::events.getCommentEvent(clowderUser, Some(20))
111+
if (play.Play.application().configuration().getBoolean("showCommentOnHomepage")) newsfeedEvents = newsfeedEvents ::: events.getCommentEvent(clowderUser, Some(20))
111112
newsfeedEvents = newsfeedEvents.sorted(Ordering.by((_: Event).created).reverse).distinct.take(20)
112113
val datasetsUser = datasets.listUser(12, Some(clowderUser), request.user.fold(false)(_.superAdminMode), clowderUser)
113114
val collectionList = collections.listUser(12, Some(clowderUser), request.user.fold(false)(_.superAdminMode), clowderUser)
114-
val collectionsWithThumbnails = collectionList.map {c =>
115+
val collectionsWithThumbnails = collectionList.map { c =>
115116
if (c.thumbnail_id.isDefined) {
116117
c
117118
} else {
@@ -126,7 +127,7 @@ class Application @Inject() (files: FileService, collections: CollectionService,
126127
for (aCollection <- collectionsWithThumbnails) {
127128
decodedCollections += Utils.decodeCollectionElements(aCollection)
128129
}
129-
val spacesUser = spaces.listUser(12, Some(clowderUser),request.user.fold(false)(_.superAdminMode), clowderUser)
130+
val spacesUser = spaces.listUser(12, Some(clowderUser), request.user.fold(false)(_.superAdminMode), clowderUser)
130131
var followers: List[(UUID, String, String, String)] = List.empty
131132
for (followerID <- clowderUser.followers.take(3)) {
132133
val userFollower = users.findById(followerID)
@@ -190,12 +191,12 @@ class Application @Inject() (files: FileService, collections: CollectionService,
190191
}
191192
Logger.debug("User selections" + user)
192193
val userSelections: List[String] =
193-
if(user.isDefined) selections.get(user.get.identityId.userId).map(_.id.stringify)
194+
if (user.isDefined) selections.get(user.get.identityId.userId).map(_.id.stringify)
194195
else List.empty[String]
195196
Logger.debug("User selection " + userSelections)
196197
Ok(views.html.home(AppConfiguration.getDisplayName, newsfeedEvents, clowderUser, datasetsUser,
197198
decodedCollections.toList, spacesUser, true, followers, followedUsers.take(12), followedFiles.take(8),
198-
followedDatasets.take(8), followedCollections.take(8),followedSpaces.take(8), Some(true), userSelections))
199+
followedDatasets.take(8), followedCollections.take(8), followedSpaces.take(8), Some(true), userSelections))
199200
}
200201
case _ => {
201202
// Set bytes from appConfig
@@ -234,10 +235,10 @@ class Application @Inject() (files: FileService, collections: CollectionService,
234235
val sanitezedWelcomeText = sanitizeHTML(AppConfiguration.getWelcomeMessage)
235236

236237
Ok(views.html.index(datasetsCount, filesCount, filesBytes, collectionsCount,
237-
spacesCount, usersCount, AppConfiguration.getDisplayName, sanitezedWelcomeText))
238+
spacesCount, usersCount, AppConfiguration.getDisplayName, sanitezedWelcomeText))
238239
}
239240

240-
def email(subject: String, body: String) = UserAction(needActive=false) { implicit request =>
241+
def email(subject: String, body: String) = UserAction(needActive = false) { implicit request =>
241242
if (request.user.isEmpty) {
242243
Redirect(routes.Application.index())
243244
} else {
@@ -252,10 +253,10 @@ class Application @Inject() (files: FileService, collections: CollectionService,
252253
Ok(views.html.tos(redirect))
253254
}
254255

255-
def options(path:String) = UserAction(needActive = false) { implicit request =>
256+
def options(path: String) = UserAction(needActive = false) { implicit request =>
256257
Logger.debug("---controller: PreFlight Information---")
257258
Ok("")
258-
}
259+
}
259260

260261
def healthz() = Action { implicit request =>
261262
Ok("healthy")
@@ -269,7 +270,7 @@ class Application @Inject() (files: FileService, collections: CollectionService,
269270
}
270271

271272
/**
272-
* Javascript routing.
273+
* Javascript routing.
273274
*/
274275
def javascriptRoutes = Action { implicit request =>
275276
Ok(
@@ -543,7 +544,7 @@ class Application @Inject() (files: FileService, collections: CollectionService,
543544
controllers.routes.javascript.FileLinks.createLink,
544545
controllers.routes.javascript.Search.search
545546
)
546-
).as(JSON)
547+
).as(JSON)
547548
}
548549

549550
}

0 commit comments

Comments
 (0)