Package com.atlassian.bamboo.ww2
Class FreemarkerContext
java.lang.Object
com.atlassian.bamboo.ww2.FreemarkerContext
- All Implemented Interfaces:
BareFreeMarkerContext
This class is similar to BambooActionSupport but does not require an action or action context. This makes this
functionality available to any servlets as well.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
-
Constructor Summary
ConstructorsConstructorDescriptionFreemarkerContext
(AdministrationConfigurationAccessor administrationConfigurationAccessor, BambooLicenseManager bambooLicenseManager, BambooPermissionManager bambooPermissionManager, BambooUserManager bambooUserManager, BootstrapManager bootstrapManager, CachedPlanManager cachedPlanManager, CachedRepositoryDefinitionManager cachedRepositoryDefinitionManager, CommentManager commentManager, DarkFeatureService darkFeatureService, DocumentationLinkProvider documentationLinkProvider, FeatureManager featureManager, GravatarService gravatarService, CachedDeploymentProjectService cachedDeploymentProjectService, CachedEnvironmentService cachedEnvironmentService, NotificationManager notificationManager, PlanFavouriteService planFavouriteService, PlanManager planManager, com.atlassian.plugin.PluginAccessor pluginAccessor, NodeStatusProvider nodeStatusProvider, StorageCappingService storageCappingService, VcsRepositoryViewerManager vcsRepositoryViewerManager, com.atlassian.plugin.web.api.DynamicWebInterfaceManager webInterfaceManager, com.atlassian.plugin.webresource.WebResourceIntegration webResourceIntegration, LookAndFeelAssetsProvider lookAndFeelAssetsProvider, CustomVariableContext customVariableContext, HigherOrderAvatarProvider higherOrderAvatarProvider, BambooClusterNodeHeartbeatService clusterNodeHeartbeatService) -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
canCreatePlanInProject
(@NotNull Project project) boolean
boolean
Checks if the current user has permissions sufficient to run custom/parameterised build of a given plan@Nullable BambooUser
getBambooUser
(@Nullable String username) @Nullable String
getCurrentUrl
(javax.servlet.http.HttpServletRequest request) List<com.atlassian.plugin.web.api.WebItem>
getDynamicWebItemsForSectionNoAction
(String sectionName, javax.servlet.http.HttpServletRequest request) Obtain a list of web items within the provided location.List<com.atlassian.plugin.web.api.WebSection>
getDynamicWebSectionsForLocationNoAction
(String location, javax.servlet.http.HttpServletRequest request) Obtain a list of web sections within the provided location.@Nullable String
@NotNull String
int
@NotNull String
@NotNull NodeLifecycleState
@NotNull String
@NotNull NodeStatusInfo
@NotNull String
getNotificationAvatarUrl
(@Nullable String userName, String size) @Nullable PluggableFooter
Gets the pluggable footer plugin.@Nullable PluggableTopNavigation
Gets the pluggable top navigation plugin.getRandomString
(int length) int
@Nullable String
getRequestUrl
(javax.servlet.http.HttpServletRequest request) It's alternate method forgetCurrentUrl(HttpServletRequest)
.@Nullable String
getRssLink
(@NotNull DeploymentProject project) @Nullable String
getRssLink
(@NotNull ImmutablePlan plan) @Nullable String
getRssRepositoryId
(@NotNull DeploymentProject project) @Nullable String
getRssRepositoryId
(@NotNull ImmutablePlan plan) @Nullable com.atlassian.user.User
getUser
(@Nullable javax.servlet.http.HttpServletRequest request) getWebFragmentsContextMapNoAction
(javax.servlet.http.HttpServletRequest request) A context map that gets appended to for web fragments.getWebItems
(String sectionName, javax.servlet.http.HttpServletRequest request) Returns a list of Map objects with prefilled text, id, accesskey, href fields for a template engine layer to consomeList<com.atlassian.plugin.web.descriptors.WebItemModuleDescriptor>
getWebItemsForSectionNoAction
(String sectionName, javax.servlet.http.HttpServletRequest request) Deprecated.getWebPanels
(@NotNull String location) Gets all the renderedWebPanel
s for the location specified.getWebPanels
(@NotNull String location, @NotNull Map<String, Object> context) getWebPanelsForPlan
(@NotNull String location, @NotNull String planKey) Gets all the renderedWebPanel
s for the location specified for a specific plan key.getWebPanelsForResultsSummary
(@NotNull String location, @NotNull ResultsSummary resultsSummary) Gets all the renderedWebPanel
s for the location specified for a specific ResultSummary.List<com.atlassian.plugin.web.descriptors.WebSectionModuleDescriptor>
getWebSectionsForLocationNoAction
(String location, javax.servlet.http.HttpServletRequest request) Deprecated.getWebSectionsWithItems
(@NotNull String location, @NotNull javax.servlet.http.HttpServletRequest request, @NotNull String pageCrumb) Return a DTO storing all web sections for the givenlocation
together with a list of all web items under each web section.@Nullable String
boolean
boolean
boolean
hasComments
(@NotNull BambooIdProvider entity) boolean
boolean
hasGlobalPermission
(String permission) Does this user have the global permission right?boolean
hasLinkedDeployments
(@Nullable PlanKey planKey) boolean
hasProjectAdminPermission
(@NotNull Project project) boolean
hasProjectPermission
(String permission, String projectKey) boolean
boolean
isAuthorBambooServer
(@Nullable String userName) Is the supplied author user the bamboo server?boolean
isAwaitingSpecsExecution
(@Nullable ImmutablePlan plan) boolean
isBambooSpecsFailure
(@Nullable ImmutableResultsSummary buildResult) boolean
isBambooSpecsResult
(@Nullable ImmutableResultsSummary buildResult) boolean
isBambooSpecsSuccess
(@Nullable ImmutableResultsSummary buildResult) boolean
boolean
isFavourite
(ImmutablePlan plan, javax.servlet.http.HttpServletRequest request) boolean
boolean
boolean
isRssManagedPlan
(@Nullable ImmutablePlan plan) boolean
isRssRepositoryProject
(@NotNull ImmutablePlan plan) boolean
boolean
boolean
isXsrfTokenNeeded
(@Nullable String formActionDestination) renderFreemarkerTemplateNoAction
(String templateString, javax.servlet.http.HttpServletRequest request) Will not bother putting any build information on the contextsanitizeUrl
(String url) @NotNull String
sanitizeUsernameToAvatarId
(@Nullable String username) @Nullable Boolean
shouldShowActionTip
(@NotNull String actionKey, @NotNull javax.servlet.http.HttpServletRequest request) Check if provided action-key is available inside user preferences.
-
Constructor Details
-
FreemarkerContext
@Inject public FreemarkerContext(AdministrationConfigurationAccessor administrationConfigurationAccessor, BambooLicenseManager bambooLicenseManager, BambooPermissionManager bambooPermissionManager, BambooUserManager bambooUserManager, BootstrapManager bootstrapManager, CachedPlanManager cachedPlanManager, CachedRepositoryDefinitionManager cachedRepositoryDefinitionManager, CommentManager commentManager, DarkFeatureService darkFeatureService, DocumentationLinkProvider documentationLinkProvider, FeatureManager featureManager, GravatarService gravatarService, CachedDeploymentProjectService cachedDeploymentProjectService, CachedEnvironmentService cachedEnvironmentService, NotificationManager notificationManager, PlanFavouriteService planFavouriteService, PlanManager planManager, com.atlassian.plugin.PluginAccessor pluginAccessor, NodeStatusProvider nodeStatusProvider, StorageCappingService storageCappingService, VcsRepositoryViewerManager vcsRepositoryViewerManager, com.atlassian.plugin.web.api.DynamicWebInterfaceManager webInterfaceManager, com.atlassian.plugin.webresource.WebResourceIntegration webResourceIntegration, LookAndFeelAssetsProvider lookAndFeelAssetsProvider, CustomVariableContext customVariableContext, HigherOrderAvatarProvider higherOrderAvatarProvider, BambooClusterNodeHeartbeatService clusterNodeHeartbeatService)
-
-
Method Details
-
getInstanceName
-
getFaviconPath
-
getUser
@Nullable @TemplateAccessible public @Nullable com.atlassian.user.User getUser(@Nullable @Nullable javax.servlet.http.HttpServletRequest request) -
isEnableSignup
@TemplateAccessible public boolean isEnableSignup() -
isUserAutocompleteAllowed
@TemplateAccessible public boolean isUserAutocompleteAllowed() -
sanitizeUrl
-
getCurrentUrl
-
getRequestUrl
It's alternate method forgetCurrentUrl(HttpServletRequest)
. In some circumstances getCurrentUrl doesn't work correctly. For example: it doesn't work for"/plugins/servlet/*"
- Parameters:
request
-- Returns:
- url of request
-
hasBuilds
@TemplateAccessible public boolean hasBuilds() -
getRemainingJobsLimit
@TemplateAccessible public int getRemainingJobsLimit() -
isFavourite
@TemplateAccessible public boolean isFavourite(ImmutablePlan plan, javax.servlet.http.HttpServletRequest request) -
getNotificationAvatarUrl
-
getBambooUser
@Nullable @TemplateAccessible public @Nullable BambooUser getBambooUser(@Nullable @Nullable String username) -
isAuthorBambooServer
Is the supplied author user the bamboo server?- Parameters:
userName
-- Returns:
- true if the author is the bamboo server, otherwise false.
-
getRandomString
-
getWebItemsForSectionNoAction
@Deprecated @TemplateAccessible public List<com.atlassian.plugin.web.descriptors.WebItemModuleDescriptor> getWebItemsForSectionNoAction(String sectionName, javax.servlet.http.HttpServletRequest request) Deprecated.Will not bother putting any build information on the context- Parameters:
sectionName
- - the section to retrieve the web items forrequest
- - the http request- Returns:
- all web items contained within the provided section
-
getDynamicWebItemsForSectionNoAction
@TemplateAccessible public List<com.atlassian.plugin.web.api.WebItem> getDynamicWebItemsForSectionNoAction(String sectionName, javax.servlet.http.HttpServletRequest request) Obtain a list of web items within the provided location. Will include web items generated dynamically by web item providers. Does not put any build/plan information to the context.- See Also:
-
WebItem
WebItemProvider
DynamicWebInterfaceManager
-
getWebItems
@NotNull @TemplateAccessible public @NotNull List<Map<String,Object>> getWebItems(String sectionName, javax.servlet.http.HttpServletRequest request) Returns a list of Map objects with prefilled text, id, accesskey, href fields for a template engine layer to consome- Parameters:
sectionName
-request
-- Returns:
-
getWebSectionsForLocationNoAction
@Deprecated @TemplateAccessible public List<com.atlassian.plugin.web.descriptors.WebSectionModuleDescriptor> getWebSectionsForLocationNoAction(String location, javax.servlet.http.HttpServletRequest request) Deprecated.Will not bother putting any build information on the context- Parameters:
location
- - the location to retrieve the web sections forrequest
- - the http request- Returns:
- all web sections contained within the provided location
-
getDynamicWebSectionsForLocationNoAction
public List<com.atlassian.plugin.web.api.WebSection> getDynamicWebSectionsForLocationNoAction(String location, javax.servlet.http.HttpServletRequest request) Obtain a list of web sections within the provided location. Will include web sections generated dynamically by web section providers. Does not put any build/plan information to the context.- See Also:
-
WebSection
WebSectionProvider
DynamicWebInterfaceManager
-
getWebSectionsWithItems
@TemplateAccessible public List<FreemarkerContext.WebSectionDto> getWebSectionsWithItems(@NotNull @NotNull String location, @NotNull @NotNull javax.servlet.http.HttpServletRequest request, @NotNull @NotNull String pageCrumb) Return a DTO storing all web sections for the givenlocation
together with a list of all web items under each web section.Based on the
pageCrumb
the result will also contain information whether a web section or a web item is currently active or not.This method supports dynamically generated web sections and web items (produced by web section providers and web item providers, respectively).
-
renderFreemarkerTemplateNoAction
public String renderFreemarkerTemplateNoAction(String templateString, javax.servlet.http.HttpServletRequest request) Will not bother putting any build information on the context- Parameters:
templateString
- - to renderrequest
- - the http request- Returns:
- The rendered string
-
hasGlobalPermission
Does this user have the global permission right?- Parameters:
permission
- The global permission being checked.- Returns:
true
if the current user has this permission;false
otherwise.
-
hasGlobalAdminPermission
@TemplateAccessible public boolean hasGlobalAdminPermission() -
hasProjectPermission
-
hasRestrictedAdminPermission
@TemplateAccessible public boolean hasRestrictedAdminPermission() -
hasProjectAdminPermission
-
canCreateProject
@TemplateAccessible public boolean canCreateProject() -
canCreatePlanInProject
-
canCreatePlan
@TemplateAccessible public boolean canCreatePlan() -
canRunCustomBuild
Checks if the current user has permissions sufficient to run custom/parameterised build of a given plan -
hasAdminPermission
@TemplateAccessible public boolean hasAdminPermission() -
getBambooLicenseManager
-
getNodeLifecycleState
-
getNodeStatusInfo
-
shouldShowActionTip
@Nullable @TemplateAccessible public @Nullable Boolean shouldShowActionTip(@NotNull @NotNull String actionKey, @NotNull @NotNull javax.servlet.http.HttpServletRequest request) Check if provided action-key is available inside user preferences.- Parameters:
request
-actionKey
-- Returns:
- Boolean
-
getWebFragmentsContextMapNoAction
@TemplateAccessible public Map<String,Object> getWebFragmentsContextMapNoAction(javax.servlet.http.HttpServletRequest request) A context map that gets appended to for web fragments. Will not look for any build information to put on the context path.- Parameters:
request
- - servlet request- Returns:
- A context map that gets appended to for web fragments.
-
getWebPanelsForPlan
@TemplateAccessible public Collection<String> getWebPanelsForPlan(@NotNull @NotNull String location, @NotNull @NotNull String planKey) Gets all the renderedWebPanel
s for the location specified for a specific plan key. Allows the same web panel location to be used in multiple places on page with different plan contexts. If called in the context of rendering aBambooActionSupport
action the context used is taken fromBambooActionSupport.getWebPanelContext(String)
- Parameters:
location
- the web panel will be displayedplanKey
- key of the plan for the context- Returns:
- webPanels
-
getWebPanelsForResultsSummary
@TemplateAccessible public Collection<String> getWebPanelsForResultsSummary(@NotNull @NotNull String location, @NotNull @NotNull ResultsSummary resultsSummary) Gets all the renderedWebPanel
s for the location specified for a specific ResultSummary. Allows the same web panel location to be used in multiple places on page with different plan contexts. If called in the context of rendering aBambooActionSupport
action the context used is taken fromBambooActionSupport.getWebPanelContext(String)
- Parameters:
location
- the web panel will be displayedresultsSummary
- passed to the web panels in the context- Returns:
- webPanels
-
getWebPanels
Gets all the renderedWebPanel
s for the location specified. If called in the context of rendering aBambooActionSupport
action the context used is taken fromBambooActionSupport.getWebPanelContext(String)
- Parameters:
location
-- Returns:
- webPanels
-
getWebPanels
-
getFeatureManager
-
getDarkFeatureService
-
getHelpLink
-
getStorageCappingService
-
getRssLink
@Nullable @TemplateAccessible public @Nullable String getRssLink(@NotNull @NotNull ImmutablePlan plan) -
getRssRepositoryId
@Nullable @TemplateAccessible public @Nullable String getRssRepositoryId(@NotNull @NotNull ImmutablePlan plan) -
getRssLink
@TemplateAccessible @Nullable public @Nullable String getRssLink(@NotNull @NotNull DeploymentProject project) -
getRssRepositoryId
@TemplateAccessible @Nullable public @Nullable String getRssRepositoryId(@NotNull @NotNull DeploymentProject project) -
isRssRepositoryProject
-
isRssManagedPlan
-
isRepositoryDashboardOn
@TemplateAccessible public boolean isRepositoryDashboardOn() -
getServerId
-
getXsrfToken
- Specified by:
getXsrfToken
in interfaceBareFreeMarkerContext
-
isXsrfTokenNeeded
@TemplateAccessible public boolean isXsrfTokenNeeded(@Nullable @Nullable String formActionDestination) - Specified by:
isXsrfTokenNeeded
in interfaceBareFreeMarkerContext
-
hasLinkedDeployments
-
sanitizeUsernameToAvatarId
-
isFunctionalTest
@TemplateAccessible public boolean isFunctionalTest() -
hasComments
-
isShowAdminContactDetailsToAnonymousUsers
@TemplateAccessible public boolean isShowAdminContactDetailsToAnonymousUsers() -
getNotificationManager
-
isBambooSpecsFailure
@TemplateAccessible public boolean isBambooSpecsFailure(@Nullable @Nullable ImmutableResultsSummary buildResult) -
isBambooSpecsSuccess
@TemplateAccessible public boolean isBambooSpecsSuccess(@Nullable @Nullable ImmutableResultsSummary buildResult) -
isBambooSpecsResult
@TemplateAccessible public boolean isBambooSpecsResult(@Nullable @Nullable ImmutableResultsSummary buildResult) -
toDate
-
isAwaitingSpecsExecution
-
getLiveNodeCount
@TemplateAccessible public int getLiveNodeCount() -
getNodeId
-
getNodeName
-
getDynamicWebItemsForSectionNoAction(String, HttpServletRequest)