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.
  • Constructor Details

  • Method Details

    • getInstanceName

      @NotNull public @NotNull String getInstanceName()
    • 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()
    • sanitizeUrl

      public String sanitizeUrl(String url)
    • 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 for getCurrentUrl(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)
      Will not bother putting any build information on the context
      Parameters:
      sectionName - - the section to retrieve the web items for
      request - - 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)
      Will not bother putting any build information on the context
      Parameters:
      location - - the location to retrieve the web sections for
      request - - 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 given location 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).

      See Also:
    • renderFreemarkerTemplateNoAction

      public String renderFreemarkerTemplateNoAction(String templateString, javax.servlet.http.HttpServletRequest request)
      Will not bother putting any build information on the context
      Parameters:
      templateString - - to render
      request - - 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()
    • hasProjectPermission

      public boolean hasProjectPermission(String permission, String projectKey)
    • 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 rendered WebPanels 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 a BambooActionSupport action the context used is taken from BambooActionSupport.getWebPanelContext(String)
      Parameters:
      location - the web panel will be displayed
      planKey - 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 rendered WebPanels 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 a BambooActionSupport action the context used is taken from BambooActionSupport.getWebPanelContext(String)
      Parameters:
      location - the web panel will be displayed
      resultsSummary - passed to the web panels in the context
      Returns:
      webPanels
    • getWebPanels

      public Collection<String> getWebPanels(@NotNull @NotNull String location)
      Gets all the rendered WebPanels for the location specified. If called in the context of rendering a BambooActionSupport action the context used is taken from BambooActionSupport.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 interface BareFreeMarkerContext
    • isXsrfTokenNeeded

      public boolean isXsrfTokenNeeded(@Nullable @Nullable String formActionDestination)
      Specified by:
      isXsrfTokenNeeded in interface BareFreeMarkerContext
    • 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()