Package com.atlassian.bamboo.ww2
Class FreemarkerContext
- java.lang.Object
-
- com.atlassian.bamboo.ww2.FreemarkerContext
-
- All Implemented Interfaces:
BareFreeMarkerContext
public class FreemarkerContext extends Object implements 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 Classes Modifier and Type Class Description static class
FreemarkerContext.WebItemDto
static class
FreemarkerContext.WebSectionDto
-
Constructor Summary
Constructors Constructor Description 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, LinkedDeploymentProjectCacheService linkedDeploymentProjectCacheService, 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, SystemInfo systemInfo, com.atlassian.plugin.webresource.WebResourceUrlProvider webResourceUrlProvider, CustomVariableContext customVariableContext, HigherOrderAvatarProvider higherOrderAvatarProvider, BambooClusterNodeHeartbeatService clusterNodeHeartbeatService)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
canCreatePlan()
boolean
canCreatePlanInProject(@NotNull Project project)
boolean
canCreateProject()
boolean
canRunCustomBuild(PlanIdentifier plan)
Checks if the current user has permissions sufficient to run custom/parameterised build of a given planBambooLicenseManager
getBambooLicenseManager()
@Nullable BambooUser
getBambooUser(@Nullable String username)
BootstrapManager
getBootstrapManager()
@Nullable String
getCurrentUrl(javax.servlet.http.HttpServletRequest request)
DarkFeatureService
getDarkFeatureService()
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
getFaviconPath()
FeatureManager
getFeatureManager()
@Nullable String
getGravatarUrl(@Nullable String userName, String size)
Deprecated.DocumentationLinkProvider
getHelpLink()
@NotNull String
getInstanceName()
int
getLiveNodeCount()
@Nullable String
getLogoPath()
@NotNull String
getNodeId()
@NotNull NodeLifecycleState
getNodeLifecycleState()
@NotNull NodeStatusInfo
getNodeStatusInfo()
@NotNull String
getNotificationAvatarUrl(@Nullable String userName, String size)
NotificationManager
getNotificationManager()
@Nullable PluggableFooter
getPluggableFooter()
Gets the pluggable footer plugin.@Nullable PluggableTopNavigation
getPluggableTopNavigation()
Gets the pluggable top navigation plugin.String
getRandomString(int length)
int
getRemainingJobsLimit()
@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)
StorageCappingService
getStorageCappingService()
@Nullable com.atlassian.user.User
getUser(@Nullable javax.servlet.http.HttpServletRequest request)
Map<String,Object>
getWebFragmentsContextMapNoAction(javax.servlet.http.HttpServletRequest request)
A context map that gets appended to for web fragments.@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 consomeList<com.atlassian.plugin.web.descriptors.WebItemModuleDescriptor>
getWebItemsForSectionNoAction(String sectionName, javax.servlet.http.HttpServletRequest request)
Deprecated.Collection<String>
getWebPanels(@NotNull String location)
Gets all the renderedWebPanel
s for the location specified.Collection<String>
getWebPanels(@NotNull String location, @NotNull Map<String,Object> context)
Collection<String>
getWebPanelsForPlan(@NotNull String location, @NotNull String planKey)
Gets all the renderedWebPanel
s for the location specified for a specific plan key.Collection<String>
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.List<FreemarkerContext.WebSectionDto>
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
getXsrfToken()
boolean
hasAdminPermission()
boolean
hasBuilds()
boolean
hasComments(@NotNull BambooIdProvider entity)
boolean
hasGlobalAdminPermission()
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
hasRestrictedAdminPermission()
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
isEnableSignup()
boolean
isFavourite(ImmutablePlan plan, javax.servlet.http.HttpServletRequest request)
boolean
isFunctionalTest()
boolean
isRepositoryDashboardOn()
boolean
isRssManagedPlan(@Nullable ImmutablePlan plan)
boolean
isRssRepositoryProject(@NotNull ImmutablePlan plan)
boolean
isShowAdminContactDetailsToAnonymousUsers()
boolean
isUserAutocompleteAllowed()
boolean
isXsrfTokenNeeded(@Nullable String formActionDestination)
String
renderFreemarkerTemplateNoAction(String templateString, javax.servlet.http.HttpServletRequest request)
Will not bother putting any build information on the contextString
sanitizeUrl(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 Detail
-
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, LinkedDeploymentProjectCacheService linkedDeploymentProjectCacheService, 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, SystemInfo systemInfo, com.atlassian.plugin.webresource.WebResourceUrlProvider webResourceUrlProvider, CustomVariableContext customVariableContext, HigherOrderAvatarProvider higherOrderAvatarProvider, BambooClusterNodeHeartbeatService clusterNodeHeartbeatService)
-
-
Method Detail
-
getInstanceName
@NotNull public @NotNull String getInstanceName()
-
getLogoPath
@Nullable public @Nullable String getLogoPath()
-
getFaviconPath
@Nullable public @Nullable String getFaviconPath()
-
getUser
@Nullable public @Nullable com.atlassian.user.User getUser(@Nullable @Nullable javax.servlet.http.HttpServletRequest request)
-
isEnableSignup
public boolean isEnableSignup()
-
isUserAutocompleteAllowed
public boolean isUserAutocompleteAllowed()
-
getCurrentUrl
@Nullable public @Nullable String getCurrentUrl(javax.servlet.http.HttpServletRequest request)
-
getRequestUrl
@Nullable public @Nullable String getRequestUrl(javax.servlet.http.HttpServletRequest request)
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
public boolean hasBuilds()
-
getRemainingJobsLimit
public int getRemainingJobsLimit()
-
isFavourite
public boolean isFavourite(ImmutablePlan plan, javax.servlet.http.HttpServletRequest request)
-
getGravatarUrl
@Nullable @Deprecated(since="9.5") public @Nullable String getGravatarUrl(@Nullable @Nullable String userName, String size)
Deprecated.
-
getNotificationAvatarUrl
@NotNull public @NotNull String getNotificationAvatarUrl(@Nullable @Nullable String userName, String size)
-
getBambooUser
@Nullable public @Nullable BambooUser getBambooUser(@Nullable @Nullable String username)
-
isAuthorBambooServer
public boolean isAuthorBambooServer(@Nullable @Nullable String userName)
Is the supplied author user the bamboo server?- Parameters:
userName
-- Returns:
- true if the author is the bamboo server, otherwise false.
-
getRandomString
public String getRandomString(int length)
-
getWebItemsForSectionNoAction
@Deprecated 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
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 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 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
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
public boolean hasGlobalPermission(String permission)
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
public boolean hasGlobalAdminPermission()
-
hasRestrictedAdminPermission
public boolean hasRestrictedAdminPermission()
-
hasProjectAdminPermission
public boolean hasProjectAdminPermission(@NotNull @NotNull Project project)
-
canCreateProject
public boolean canCreateProject()
-
canCreatePlanInProject
public boolean canCreatePlanInProject(@NotNull @NotNull Project project)
-
canCreatePlan
public boolean canCreatePlan()
-
canRunCustomBuild
public boolean canRunCustomBuild(PlanIdentifier plan)
Checks if the current user has permissions sufficient to run custom/parameterised build of a given plan
-
hasAdminPermission
public boolean hasAdminPermission()
-
getBambooLicenseManager
public BambooLicenseManager getBambooLicenseManager()
-
getNodeLifecycleState
@NotNull public @NotNull NodeLifecycleState getNodeLifecycleState()
-
getNodeStatusInfo
@NotNull public @NotNull NodeStatusInfo getNodeStatusInfo()
-
getPluggableTopNavigation
@Nullable public @Nullable PluggableTopNavigation getPluggableTopNavigation()
Gets the pluggable top navigation plugin.- Returns:
- The pluggable top navigation plugin, if it exists, or null.
-
getPluggableFooter
@Nullable public @Nullable PluggableFooter getPluggableFooter()
Gets the pluggable footer plugin.- Returns:
- The pluggable footer plugin, if it exists, or null.
-
shouldShowActionTip
@Nullable 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
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
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
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
public Collection<String> getWebPanels(@NotNull @NotNull String location)
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
public Collection<String> getWebPanels(@NotNull @NotNull String location, @NotNull @NotNull Map<String,Object> context)
-
getFeatureManager
public FeatureManager getFeatureManager()
-
getDarkFeatureService
public DarkFeatureService getDarkFeatureService()
-
getHelpLink
public DocumentationLinkProvider getHelpLink()
-
getStorageCappingService
public StorageCappingService getStorageCappingService()
-
getRssLink
@Nullable public @Nullable String getRssLink(@NotNull @NotNull ImmutablePlan plan)
-
getRssRepositoryId
@Nullable public @Nullable String getRssRepositoryId(@NotNull @NotNull ImmutablePlan plan)
-
getRssLink
@Nullable public @Nullable String getRssLink(@NotNull @NotNull DeploymentProject project)
-
getRssRepositoryId
@Nullable public @Nullable String getRssRepositoryId(@NotNull @NotNull DeploymentProject project)
-
isRssRepositoryProject
public boolean isRssRepositoryProject(@NotNull @NotNull ImmutablePlan plan)
-
isRssManagedPlan
public boolean isRssManagedPlan(@Nullable @Nullable ImmutablePlan plan)
-
isRepositoryDashboardOn
public boolean isRepositoryDashboardOn()
-
getBootstrapManager
public BootstrapManager getBootstrapManager()
-
getXsrfToken
@Nullable public @Nullable String getXsrfToken()
- Specified by:
getXsrfToken
in interfaceBareFreeMarkerContext
-
isXsrfTokenNeeded
public boolean isXsrfTokenNeeded(@Nullable @Nullable String formActionDestination)
- Specified by:
isXsrfTokenNeeded
in interfaceBareFreeMarkerContext
-
hasLinkedDeployments
public boolean hasLinkedDeployments(@Nullable @Nullable PlanKey planKey)
-
sanitizeUsernameToAvatarId
@NotNull public @NotNull String sanitizeUsernameToAvatarId(@Nullable @Nullable String username)
-
isFunctionalTest
public boolean isFunctionalTest()
-
hasComments
public boolean hasComments(@NotNull @NotNull BambooIdProvider entity)
-
isShowAdminContactDetailsToAnonymousUsers
public boolean isShowAdminContactDetailsToAnonymousUsers()
-
getNotificationManager
public NotificationManager getNotificationManager()
-
isBambooSpecsFailure
public boolean isBambooSpecsFailure(@Nullable @Nullable ImmutableResultsSummary buildResult)
-
isBambooSpecsSuccess
public boolean isBambooSpecsSuccess(@Nullable @Nullable ImmutableResultsSummary buildResult)
-
isBambooSpecsResult
public boolean isBambooSpecsResult(@Nullable @Nullable ImmutableResultsSummary buildResult)
-
isAwaitingSpecsExecution
public boolean isAwaitingSpecsExecution(@Nullable @Nullable ImmutablePlan plan)
-
getLiveNodeCount
public int getLiveNodeCount()
-
getNodeId
@NotNull public @NotNull String getNodeId()
-
-