Skip to content

Commit

Permalink
Further licence coverage. Apply null check to grailsApplication.
Browse files Browse the repository at this point in the history
  • Loading branch information
acampbell3000 committed Jul 21, 2010
1 parent 78a3ab2 commit 1885f87
Show file tree
Hide file tree
Showing 28 changed files with 402 additions and 42 deletions.
16 changes: 16 additions & 0 deletions grails-app/conf/BuildConfig.groovy
@@ -1,4 +1,20 @@

/**
* Copyright 2010 Anthony Campbell (anthonycampbell.co.uk)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

grails.project.dependency.resolution = {
inherits "global" // inherit Grails' default dependencies
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
Expand Down
17 changes: 17 additions & 0 deletions grails-app/conf/UrlMappings.groovy
@@ -1,3 +1,20 @@

/**
* Copyright 2010 Anthony Campbell (anthonycampbell.co.uk)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
Expand Down
Expand Up @@ -100,10 +100,10 @@ class AlbumController {
final String feed = "${params.feed}" ?: ""

// Prepare display values
final boolean showPrivate = grailsApplication.config?.picasa?.showPrivateAlbums ?: false
final boolean showPrivate = grailsApplication?.config?..picasa?.showPrivateAlbums ?: false
final int offset = params.int("offset") ?: 0
final int max = Math.min(new Integer(params.int("max") ?:
(grailsApplication.config?.picasa?.max ?: 10)).intValue(), 500)
(grailsApplication?.config?..picasa?.max ?: 10)).intValue(), 500)
final String listView = isAjax ? "_list" : "list"
flash.message = ""

Expand Down Expand Up @@ -170,8 +170,8 @@ class AlbumController {
default: "Photo Albums"))
generator("Grails Picasa Plug-in " + grailsApplication.metadata['app.version'])

if (grailsApplication.config?.picasa?.rssManagingEditor instanceof String) {
managingEditor(grailsApplication.config.picasa.rssManagingEditor ?: "")
if (grailsApplication?.config?..picasa?.rssManagingEditor instanceof String) {
managingEditor(grailsApplication?.config?.picasa.rssManagingEditor ?: "")
}

for (a in albumList) {
Expand Down Expand Up @@ -275,7 +275,7 @@ class AlbumController {

// Prepare display values
final String albumId = "${params?.id}" ?: ""
final boolean showPrivate = grailsApplication.config?.picasa?.showPrivateAlbums ?: false
final boolean showPrivate = grailsApplication?.config?..picasa?.showPrivateAlbums ?: false
final String showView = isAjax ? "_show" : "show"
flash.message = ""

Expand Down
Expand Up @@ -9,6 +9,8 @@ package uk.co.anthonycampbell.grails.plugins.picasa
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* @author Anthony Campbell (anthonycampbell.co.uk)
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -29,8 +31,6 @@ import org.apache.commons.lang.StringUtils
* Controller which handles all of the common actions for the Comment
* domain class. In addition, the class also provides support for ajax
* requests.
*
* @author Anthony Campbell (anthonycampbell.co.uk)
*/
class CommentController {

Expand Down Expand Up @@ -166,7 +166,7 @@ class CommentController {
final String paramPhotoId = (params.photoId && StringUtils.isNumeric(params.photoId)) ? "${params.photoId}" : ""
int offset = (params.int("offset") == null) ? -1 : params.int("offset")
final int max = Math.min(new Integer(params.int("max") ?:
(grailsApplication.config?.picasa?.maxComments ?: 10)).intValue(), 500)
(grailsApplication?.config?..picasa?.maxComments ?: 10)).intValue(), 500)
final String listView = isAjax ? "_list" : "list"
flash.message = ""
flash.oauthError = ""
Expand Down Expand Up @@ -216,8 +216,8 @@ class CommentController {
default: "RSS feed for the photo comment listing"))
generator("Grails Picasa Plug-in " + grailsApplication.metadata['app.version'])

if (grailsApplication.config?.picasa?.rssManagingEditor instanceof String) {
managingEditor(grailsApplication.config.picasa.rssManagingEditor ?: "")
if (grailsApplication?.config?..picasa?.rssManagingEditor instanceof String) {
managingEditor(grailsApplication?.config?.picasa.rssManagingEditor ?: "")
}

for (c in commentList) {
Expand Down Expand Up @@ -332,7 +332,7 @@ class CommentController {
final String photoId = (params.photoId && StringUtils.isNumeric(params.photoId)) ? "${params.photoId}" : ""
final int offset = params.int("offset") ?: 0
final int max = Math.min(new Integer(params.int("max") ?:
(grailsApplication.config?.picasa?.maxComments ?: 10)).intValue(), 500)
(grailsApplication?.config?..picasa?.maxComments ?: 10)).intValue(), 500)
final String createView = isAjax ? "_comments" : "comments"
flash.message = ""
flash.oauthError = ""
Expand Down
Expand Up @@ -135,10 +135,10 @@ class PhotoController {

// Prepare display values
final String paramAlbumId = (params.albumId && StringUtils.isNumeric(params?.albumId)) ? "${params.albumId}" : ""
final boolean showPrivate = grailsApplication.config?.picasa?.showPrivatePhotos ?: false
final boolean showPrivate = grailsApplication?.config?..picasa?.showPrivatePhotos ?: false
final int offset = params.int("offset") ?: 0
final int max = Math.min(new Integer(params.int("max") ?:
(grailsApplication.config?.picasa?.max ?: 10)).intValue(), 500)
(grailsApplication?.config?..picasa?.max ?: 10)).intValue(), 500)
final String listView = isAjax ? "_list" : "list"
flash.message = ""

Expand Down Expand Up @@ -208,8 +208,8 @@ class PhotoController {
generator("Grails Picasa Plug-in " + grailsApplication.metadata['app.version'])
lastBuildDate(album?.dateCreated?.format(DateUtil.RFC_822) ?: "")

if (grailsApplication.config?.picasa?.rssManagingEditor instanceof String) {
managingEditor(grailsApplication.config.picasa.rssManagingEditor ?: "")
if (grailsApplication?.config?..picasa?.rssManagingEditor instanceof String) {
managingEditor(grailsApplication?.config?.picasa.rssManagingEditor ?: "")
}

if (album?.image) {
Expand Down Expand Up @@ -328,10 +328,10 @@ class PhotoController {
// Prepare display values
final String albumId = (params.albumId && StringUtils.isNumeric(params.albumId)) ? "${params.albumId}" : ""
final String photoId = (params.photoId && StringUtils.isNumeric(params.photoId)) ? "${params.photoId}" : ""
final boolean showPrivate = grailsApplication.config?.picasa?.showPrivatePhotos ?: false
final boolean showPrivate = grailsApplication?.config?..picasa?.showPrivatePhotos ?: false
int offset = (params.int("offset") == null) ? -1 : params.int("offset")
final int max = Math.min(new Integer(params.int("max") ?:
(grailsApplication.config?.picasa?.maxComments ?: 10)).intValue(), 500)
(grailsApplication?.config?..picasa?.maxComments ?: 10)).intValue(), 500)
final String showView = isAjax ? "_show" : "show"
flash.message = ""

Expand Down
Expand Up @@ -142,8 +142,8 @@ class TagController {
generator("Grails Picasa Plug-in " + grailsApplication.metadata['app.version'])
lastBuildDate(date.format(DateUtil.RFC_822))

if (grailsApplication.config?.picasa?.rssManagingEditor instanceof String) {
managingEditor(grailsApplication.config?.picasa?.rssManagingEditor ?: "")
if (grailsApplication?.config?..picasa?.rssManagingEditor instanceof String) {
managingEditor(grailsApplication?.config?..picasa?.rssManagingEditor ?: "")
}

for (t in tagList) {
Expand Down Expand Up @@ -219,10 +219,10 @@ class TagController {

// Prepare display values
final String paramTagId = "${params.id}" ?: ""
final boolean showPrivate = grailsApplication.config?.picasa?.showPrivatePhotos ?: false
final boolean showPrivate = grailsApplication?.config?..picasa?.showPrivatePhotos ?: false
final int offset = params.int("offset") ?: 0
final int max = Math.min(new Integer(params.int("max") ?:
(grailsApplication.config?.picasa?.max ?: 10)).intValue(), 500)
(grailsApplication?.config?..picasa?.max ?: 10)).intValue(), 500)
final String listView = isAjax ? "_show" : "show"
flash.message = ""

Expand Down Expand Up @@ -293,8 +293,8 @@ class TagController {
default: "RSS feed for the tag listing"))
generator("Grails Picasa Plug-in " + grailsApplication.metadata['app.version'])

if (grailsApplication.config?.picasa?.rssManagingEditor instanceof String) {
managingEditor(grailsApplication.config.picasa.rssManagingEditor ?: "")
if (grailsApplication?.config?..picasa?.rssManagingEditor instanceof String) {
managingEditor(grailsApplication?.config?.picasa.rssManagingEditor ?: "")
}

for (p in photoList) {
Expand Down
@@ -1,5 +1,21 @@
package uk.co.anthonycampbell.grails.plugins.picasa

/**
* Copyright 2010 Anthony Campbell (anthonycampbell.co.uk)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Picasa plug-in Album domain class.
*
Expand Down
@@ -1,5 +1,21 @@
package uk.co.anthonycampbell.grails.plugins.picasa

/**
* Copyright 2010 Anthony Campbell (anthonycampbell.co.uk)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Picasa plug-in Comment domain class.
*
Expand Down
@@ -1,5 +1,21 @@
package uk.co.anthonycampbell.grails.plugins.picasa

/**
* Copyright 2010 Anthony Campbell (anthonycampbell.co.uk)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Picasa plug-in Get Point domain class.
*
Expand Down
@@ -1,5 +1,21 @@
package uk.co.anthonycampbell.grails.plugins.picasa

/**
* Copyright 2010 Anthony Campbell (anthonycampbell.co.uk)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Picasa plug-in Person domain class.
*
Expand Down
@@ -1,5 +1,21 @@
package uk.co.anthonycampbell.grails.plugins.picasa

/**
* Copyright 2010 Anthony Campbell (anthonycampbell.co.uk)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Picasa plug-in Photo domain class.
*
Expand Down
@@ -1,5 +1,21 @@
package uk.co.anthonycampbell.grails.plugins.picasa

/**
* Copyright 2010 Anthony Campbell (anthonycampbell.co.uk)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Picasa plug-in Tag domain class.
*
Expand Down
Expand Up @@ -100,11 +100,11 @@ class PicasaCommentService implements InitializingBean {
this.picasaApplicationName = this.getClass().getPackage().getName() +
"-" + grailsApplication.metadata['app.name'] +
"-" + grailsApplication.metadata['app.version']
this.allowComments = grailsApplication.config?.picasa?.allowComments
this.allowComments = grailsApplication?.config?..picasa?.allowComments

// Collect oauth config
this.picasaConsumerKey = grailsApplication.config?.oauth?.picasa?.consumer.key
this.picasaConsumerSecret = grailsApplication.config?.oauth?.picasa?.consumer.secret
this.picasaConsumerKey = grailsApplication?.config?..oauth?.picasa?.consumer.key
this.picasaConsumerSecret = grailsApplication?.config?..oauth?.picasa?.consumer.secret

// Remove any existing OAuth access
removeOAuthAccess()
Expand Down
Expand Up @@ -73,7 +73,7 @@ class PicasaService implements InitializingBean {
void afterPropertiesSet() {
log?.info "Initialising the ${this.getClass().getSimpleName()}..."

CACHE = PicasaServiceCache.getInstance(grailsApplication.config?.picasa?.cacheTimeout)
CACHE = PicasaServiceCache.getInstance(grailsApplication?.config?..picasa?.cacheTimeout)
reset()
}

Expand Down Expand Up @@ -123,16 +123,16 @@ class PicasaService implements InitializingBean {
log?.info "Resetting ${this.getClass().getSimpleName()} configuration..."

// Get configuration from Config.groovy
this.picasaUsername = grailsApplication.config?.picasa?.username
this.picasaPassword = grailsApplication.config?.picasa?.password
this.picasaUsername = grailsApplication?.config?..picasa?.username
this.picasaPassword = grailsApplication?.config?..picasa?.password
this.picasaApplicationName = this.getClass().getPackage().getName() +
"-" + grailsApplication.metadata['app.name'] +
"-" + grailsApplication.metadata['app.version']
this.picasaImgmax = grailsApplication.config?.picasa?.imgmax
this.picasaThumbsize = grailsApplication.config?.picasa?.thumbsize
this.picasaMaxResults = grailsApplication.config?.picasa?.maxResults
this.allowCache = grailsApplication.config?.picasa?.allowCache
this.cacheTimeout = grailsApplication.config?.picasa?.cacheTimeout
this.picasaImgmax = grailsApplication?.config?..picasa?.imgmax
this.picasaThumbsize = grailsApplication?.config?..picasa?.thumbsize
this.picasaMaxResults = grailsApplication?.config?..picasa?.maxResults
this.allowCache = grailsApplication?.config?..picasa?.allowCache
this.cacheTimeout = grailsApplication?.config?..picasa?.cacheTimeout

// Empty cache
CACHE?.purge()
Expand Down
2 changes: 1 addition & 1 deletion grails-app/views/album/_list.gsp
Expand Up @@ -46,7 +46,7 @@

<div id="contentFooter">
<div id="pagination">
<g:remotePaginate action="ajaxList" update="listAlbum" max="${grailsApplication.config?.picasa?.max ?: 10}" maxsteps="${grailsApplication.config?.picasa?.maxSteps ?: 10}" total="${albumInstanceTotal}" />
<g:remotePaginate action="ajaxList" update="listAlbum" max="${grailsApplication?.config?..picasa?.max ?: 10}" maxsteps="${grailsApplication?.config?..picasa?.maxSteps ?: 10}" total="${albumInstanceTotal}" />
</div>
<div id="feeds">
<a href="${createLink(action: 'list')}/feed/rss">RSS</a> |
Expand Down
2 changes: 1 addition & 1 deletion grails-app/views/comment/_list.gsp
Expand Up @@ -18,7 +18,7 @@

<div id="contentFooter">
<div id="pagination">
<g:remotePaginate controller="comment" action="ajaxList" update="listComment" albumId="${albumId}" photoId="${photoId}" max="${grailsApplication.config?.picasa?.maxComments ?: 10}" maxsteps="${grailsApplication.config?.picasa?.maxCommentSteps ?: 10}" total="${commentInstanceTotal}" />
<g:remotePaginate controller="comment" action="ajaxList" update="listComment" albumId="${albumId}" photoId="${photoId}" max="${grailsApplication?.config?..picasa?.maxComments ?: 10}" maxsteps="${grailsApplication?.config?..picasa?.maxCommentSteps ?: 10}" total="${commentInstanceTotal}" />
</div>
<div id="feeds">
<a href="${createLink(controller: 'comment', action: 'list')}/${(StringUtils.isNotEmpty(albumId) && StringUtils.isNotEmpty(photoId)) ? "/$albumId/$photoId/" : "" }feed/rss">RSS</a> |
Expand Down

0 comments on commit 1885f87

Please sign in to comment.