com.pyxis.greenhopper.gadget
Class CommonGadgetValidation

java.lang.Object
  extended by com.pyxis.greenhopper.gadget.CommonGadgetValidation

public class CommonGadgetValidation
extends java.lang.Object

This class contains some common validation methods that can be used in the gadget resources All UserPref parameters refer to the variable names used to store gadget data, e.g. projectId or versionId.

Since:
v5.1

Field Summary
static java.lang.String PROJECT_PREFIX
           
 
Constructor Summary
CommonGadgetValidation(com.atlassian.jira.project.ProjectManager projectManager, com.atlassian.jira.security.JiraAuthenticationContext authenticationContext, com.atlassian.jira.project.version.VersionManager versionManager, com.atlassian.jira.security.PermissionManager permissionManager, GreenHopperLicenseManager ghLicense)
          Create a new validation object.
 
Method Summary
 java.util.Set<java.lang.String> splitContextNames(java.lang.String contextNames)
          Splits the context names string into an set.
 Context validateContext(BoardContext boardContext, java.lang.String contextName, java.util.Collection<ValidationError> errors, java.lang.String contextUserPref)
          This validation method is used to check that a specified context that has been chosen in the gadget user prefs exists and is a valid context
 com.atlassian.jira.project.Project validateForSavedProjectIdUserPref(java.util.Collection<ValidationError> errors, java.lang.String projectIdStr, java.lang.String projectUserPref)
          Validate the project id
 boolean validateLicense(java.util.Collection<ValidationError> errors)
          Validate the GreenHopper license
 com.atlassian.jira.project.Project validateProjectId(java.util.Collection<ValidationError> errors, java.lang.String projectIdStr, java.lang.String projectUserPref)
          Validate the project id.
 Context validateSavedContextUserPref(BoardContext boardContext, java.lang.String contextName, java.util.Collection<ValidationError> errors, java.lang.String contextUserPref)
          This method can be used to validate a context specified in a gadget before the gadget is rendered.
 com.atlassian.jira.project.version.Version validateVersion(BoardContext boardContext, java.lang.String versionId, java.util.Collection<ValidationError> errors, java.lang.String versionUserPref)
          Validates a version string
 com.atlassian.jira.project.version.Version validateVersionForSavedPref(BoardContext boardContext, java.lang.String versionId, java.util.Collection<ValidationError> errors, java.lang.String versionUserPref)
          Validates a version string for a saved preference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROJECT_PREFIX

public static final java.lang.String PROJECT_PREFIX
See Also:
Constant Field Values
Constructor Detail

CommonGadgetValidation

public CommonGadgetValidation(com.atlassian.jira.project.ProjectManager projectManager,
                              com.atlassian.jira.security.JiraAuthenticationContext authenticationContext,
                              com.atlassian.jira.project.version.VersionManager versionManager,
                              com.atlassian.jira.security.PermissionManager permissionManager,
                              GreenHopperLicenseManager ghLicense)
Create a new validation object.

Method Detail

validateLicense

public boolean validateLicense(java.util.Collection<ValidationError> errors)
Validate the GreenHopper license

Parameters:
errors -
Returns:
true if the validation succeeded

validateProjectId

public com.atlassian.jira.project.Project validateProjectId(java.util.Collection<ValidationError> errors,
                                                            java.lang.String projectIdStr,
                                                            java.lang.String projectUserPref)
Validate the project id.

Returns:
a project object if the id is valid

validateForSavedProjectIdUserPref

public com.atlassian.jira.project.Project validateForSavedProjectIdUserPref(java.util.Collection<ValidationError> errors,
                                                                            java.lang.String projectIdStr,
                                                                            java.lang.String projectUserPref)
Validate the project id

Parameters:
errors -
projectIdStr -
projectUserPref -
Returns:
a project object if the id is valid

validateVersion

public com.atlassian.jira.project.version.Version validateVersion(BoardContext boardContext,
                                                                  java.lang.String versionId,
                                                                  java.util.Collection<ValidationError> errors,
                                                                  java.lang.String versionUserPref)
Validates a version string

Parameters:
boardContext -
versionId -
errors -
versionUserPref -
Returns:
the version if validation succeeded

validateVersionForSavedPref

public com.atlassian.jira.project.version.Version validateVersionForSavedPref(BoardContext boardContext,
                                                                              java.lang.String versionId,
                                                                              java.util.Collection<ValidationError> errors,
                                                                              java.lang.String versionUserPref)
Validates a version string for a saved preference

Parameters:
boardContext -
versionId -
errors -
versionUserPref -
Returns:
the version if validation succeeded

validateSavedContextUserPref

public Context validateSavedContextUserPref(BoardContext boardContext,
                                            java.lang.String contextName,
                                            java.util.Collection<ValidationError> errors,
                                            java.lang.String contextUserPref)
This method can be used to validate a context specified in a gadget before the gadget is rendered. This validate method would usually be called in the generate method of a gadget resource.

Parameters:
boardContext - - the boardContext of the project for the context being checked
contextName - - the name of the context being validated
errors - - Collection where errors will be logged
contextUserPref - - the user pref which stores the context user pref in the gadget

validateContext

public Context validateContext(BoardContext boardContext,
                               java.lang.String contextName,
                               java.util.Collection<ValidationError> errors,
                               java.lang.String contextUserPref)
This validation method is used to check that a specified context that has been chosen in the gadget user prefs exists and is a valid context

Parameters:
boardContext - - the boardContext of the project for the context being checked
contextName - - the name of the context being validated
errors - - Collection where errors will be logged
contextUserPref - - the user pref which stores the context user pref in the gadget

splitContextNames

public java.util.Set<java.lang.String> splitContextNames(java.lang.String contextNames)
Splits the context names string into an set.

Parameters:
contextNames - context names separated by pipes.
Returns:
an array containing all context names found in contextNames


Copyright © 2007-2012 Atlassian. All Rights Reserved.