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

      @Nullable @TemplateAccessible public @Nullable String 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

      @TemplateAccessible 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

      @TemplateAccessible public boolean hasBuilds()
    • getRemainingJobsLimit

      @TemplateAccessible public int getRemainingJobsLimit()
    • isFavourite

      @TemplateAccessible public boolean isFavourite(ImmutablePlan plan, javax.servlet.http.HttpServletRequest request)
    • getNotificationAvatarUrl

      @NotNull @TemplateAccessible public @NotNull String getNotificationAvatarUrl(@Nullable @Nullable String userName, String size)
    • getBambooUser

      @Nullable @TemplateAccessible public @Nullable BambooUser getBambooUser(@Nullable @Nullable String username)
    • isAuthorBambooServer

      @TemplateAccessible 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

      @TemplateAccessible public String getRandomString(int length)
    • getWebItemsForSectionNoAction

      @Deprecated @TemplateAccessible 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

      @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)
      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

      @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 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

      @TemplateAccessible 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

      @TemplateAccessible public boolean hasGlobalAdminPermission()
    • hasProjectPermission

      public boolean hasProjectPermission(String permission, String projectKey)
    • hasRestrictedAdminPermission

      @TemplateAccessible public boolean hasRestrictedAdminPermission()
    • hasProjectAdminPermission

      @TemplateAccessible public boolean hasProjectAdminPermission(@NotNull @NotNull Project project)
    • canCreateProject

      @TemplateAccessible public boolean canCreateProject()
    • canCreatePlanInProject

      @TemplateAccessible public boolean canCreatePlanInProject(@NotNull @NotNull Project project)
    • canCreatePlan

      @TemplateAccessible public boolean canCreatePlan()
    • canRunCustomBuild

      @TemplateAccessible public boolean canRunCustomBuild(PlanIdentifier plan)
      Checks if the current user has permissions sufficient to run custom/parameterised build of a given plan
    • hasAdminPermission

      @TemplateAccessible public boolean hasAdminPermission()
    • getBambooLicenseManager

      @TemplateAccessible public BambooLicenseManager getBambooLicenseManager()
    • getNodeLifecycleState

      @NotNull @TemplateAccessible public @NotNull NodeLifecycleState getNodeLifecycleState()
    • getNodeStatusInfo

      @NotNull @TemplateAccessible 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 @TemplateAccessible public @Nullable PluggableFooter getPluggableFooter()
      Gets the pluggable footer plugin.
      Returns:
      The pluggable footer plugin, if it exists, or null.
    • 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 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

      @TemplateAccessible 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

      @TemplateAccessible 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

      @TemplateAccessible public Collection<String> getWebPanels(@NotNull @NotNull String location, @NotNull @NotNull Map<String,Object> context)
    • getFeatureManager

      @TemplateAccessible public FeatureManager getFeatureManager()
    • getDarkFeatureService

      @TemplateAccessible public DarkFeatureService getDarkFeatureService()
    • getHelpLink

      @TemplateAccessible public DocumentationLinkProvider getHelpLink()
    • getStorageCappingService

      @TemplateAccessible public StorageCappingService 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

      @TemplateAccessible public boolean isRssRepositoryProject(@NotNull @NotNull ImmutablePlan plan)
    • isRssManagedPlan

      @TemplateAccessible public boolean isRssManagedPlan(@Nullable @Nullable ImmutablePlan plan)
    • isRepositoryDashboardOn

      @TemplateAccessible public boolean isRepositoryDashboardOn()
    • getServerId

      @TemplateAccessible public String getServerId()
    • getXsrfToken

      @Nullable @TemplateAccessible public @Nullable String getXsrfToken()
      Specified by:
      getXsrfToken in interface BareFreeMarkerContext
    • isXsrfTokenNeeded

      @TemplateAccessible public boolean isXsrfTokenNeeded(@Nullable @Nullable String formActionDestination)
      Specified by:
      isXsrfTokenNeeded in interface BareFreeMarkerContext
    • hasLinkedDeployments

      @TemplateAccessible public boolean hasLinkedDeployments(@Nullable @Nullable PlanKey planKey)
    • sanitizeUsernameToAvatarId

      @NotNull @TemplateAccessible public @NotNull String sanitizeUsernameToAvatarId(@Nullable @Nullable String username)
    • isFunctionalTest

      @TemplateAccessible public boolean isFunctionalTest()
    • hasComments

      @TemplateAccessible public boolean hasComments(@NotNull @NotNull BambooIdProvider entity)
    • isShowAdminContactDetailsToAnonymousUsers

      @TemplateAccessible public boolean isShowAdminContactDetailsToAnonymousUsers()
    • getNotificationManager

      @TemplateAccessible public NotificationManager 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

      @TemplateAccessible public Date toDate(Instant instant)
    • isAwaitingSpecsExecution

      @TemplateAccessible public boolean isAwaitingSpecsExecution(@Nullable @Nullable ImmutablePlan plan)
    • getLiveNodeCount

      @TemplateAccessible public int getLiveNodeCount()
    • getNodeId

      @NotNull @TemplateAccessible public @NotNull String getNodeId()
    • getNodeName

      @NotNull @TemplateAccessible public @NotNull String getNodeName()