Class WebResource

    • Constructor Summary

      Constructors 
      Constructor Description
      WebResource()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected java.lang.String calculatePath()
      Returns the path to access this web resource.
      WebResource clone()  
      java.util.Date getCreatedDateTime()
      Returns the date-time this web resource was created.
      java.lang.String getDynamicPath()
      Returns the dynamic path to access this web resource.
      java.lang.String getFriendlyPath()
      Returns the friendly path to access this web resource.
      java.lang.String getFriendlyURLPattern()
      Returns the pattern to be used to resolve friendly URL for this web resource.
      java.lang.String getId()
      Returns the unique identifier for this web resource.
      java.util.Locale getLocale()
      Returns the locale for this web resource.
      abstract java.lang.String getName()
      Returns the name for this web resource.
      PageCacheConfig getPageCache()
      Returns the cache definition for this web resource.
      java.lang.String getParameter​(java.lang.String parameterName)
      Returns the value of a parameter for this web resource.
      abstract java.util.Map<java.lang.String,​java.lang.String[]> getParameterMap()
      Returns a map containing all parameters for this web resource.
      java.lang.String[] getParameterValues​(java.lang.String parameterName)
      Returns the values of a parameter for this web resource.
      abstract WebResource getParent()
      Returns the web resource of the parent element of this web resource.
      java.lang.String getPath()
      Returns the path to access this web resource.
      abstract IProject getProject()
      Returns the project this web resource belongs to (if any).
      It is important to notice that the relation webresource <-> project is not persisted.
      abstract java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getProperties()
      Returns the properties for this web resource.
      protected java.lang.String getRecommendedFileExtension()
      Returns the file extension recommended for this web resource, according to its configurations.
      protected abstract java.lang.String getSeoRuleUrlPattern()
      Get the Url Path from the SeoRule linked to this WebResource.
      abstract java.lang.String getTitle()
      Returns the title for this web resource.
      abstract java.lang.String getUrlTitle()
      Returns the title value meant to be used for friendly URL generation of this web resource.
      IWebsite getWebsite()
      Returns the website this web resource belongs to.
      protected boolean hasSSI()
      Returns whether this web resource has Server Side Include (requires SSI pos-processing).
      protected boolean isAvailableForGetRequest()
      Returns whether this web resource is available for a GET request to it.
      boolean isCacheEnabled()
      Returns if the cache is enabled for this web resource.
      boolean isCacheEnabled​(boolean considerGuestOnlyCache)
      Deprecated.
      since 10.3.0 replaced by isCacheEnabled().
      protected boolean isDynamicRequestValid​(javax.servlet.http.HttpServletRequest request)
      Indicates whether the given request is a valid dynamic request for this web resource.
      protected boolean isFriendlyURLEnabled()
      Indicates if friendly URL is enabled for this web resource.
      protected java.lang.String localize​(java.lang.String key)
      Returns the localized version of the given string.
      protected boolean mayBePersisted()
      Indicates whether this web resource may be persisted.
      protected void setDynamicPath​(java.lang.String dynamicPath)
      Sets the dynamic path for this web resource.
      protected void setFriendlyPath​(java.lang.String friendlyPath)
      Sets the friendly path for this web resource.
      protected void setId​(java.lang.String id)
      Sets the unique identifier for this web resource.
      protected void setLocale​(java.util.Locale locale)
      Sets the locale for this web resource.
      protected void setPageCache​(PageCacheConfig pageCache)
      Sets the cache definition for this web resource.
      protected void setWebsite​(IWebsite website)
      Sets the website this web resource belongs to.
      java.lang.String toString()
      Returns a string representation for debug and logging purposes.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • WebResource

        public WebResource()
    • Method Detail

      • getId

        public java.lang.String getId()
        Returns the unique identifier for this web resource.
        Returns:
        the unique identifier for this web resource, or null if it is not persisted.
        Since:
        5.0.0
      • setId

        protected void setId​(java.lang.String id)
        Sets the unique identifier for this web resource.
        Parameters:
        id - the value to set.
        Since:
        5.0.0
      • getDynamicPath

        public java.lang.String getDynamicPath()
        Returns the dynamic path to access this web resource. The dynamic path, starts with '/' and is relative to the portal web application root.
        Returns:
        the dynamic path for this web resource.
        Since:
        5.0.0
        See Also:
        getFriendlyPath()
      • setDynamicPath

        protected void setDynamicPath​(java.lang.String dynamicPath)
        Sets the dynamic path for this web resource.
        Parameters:
        dynamicPath - the dynamic path relative to the portal web application root. It must start with '/'.
        Since:
        5.0.0
      • getFriendlyPath

        public java.lang.String getFriendlyPath()
        Returns the friendly path to access this web resource. The friendly path, if set, always starts with '/' and is relative to the portal web application root. One exception to this rule is if the friendly path corresponds to the application root, in this case an empty string is returned.

        Note that even thought a friendly path is returned, the use of friendly URL may be disabled for this web resource.

        Returns:
        the friendly path or null if there is no friendly path set.
        Since:
        5.0.0
        See Also:
        getPath()
      • isFriendlyURLEnabled

        protected boolean isFriendlyURLEnabled()
        Indicates if friendly URL is enabled for this web resource.
        Returns:
        true if it is enabled, false otherwise.
        Since:
        5.0.0
      • setFriendlyPath

        protected void setFriendlyPath​(java.lang.String friendlyPath)
        Sets the friendly path for this web resource.
        Parameters:
        friendlyPath - the friendly path relative to the portal web application root. It must start with '/', or be null for no friendly path set.
        Since:
        5.0.0
      • getFriendlyURLPattern

        public java.lang.String getFriendlyURLPattern()
        Returns the pattern to be used to resolve friendly URL for this web resource.

        The specific syntax or usage of the pattern is up to the IURLResolver configured for this web resource.

        Returns:
        the pattern.
        Since:
        5.0.0
      • getSeoRuleUrlPattern

        protected abstract java.lang.String getSeoRuleUrlPattern()
                                                          throws PortalException
        Get the Url Path from the SeoRule linked to this WebResource.
        Returns:
        The url path pattern or null if not specified.
        Throws:
        PortalException
        Since:
        10.1.0
      • getLocale

        public java.util.Locale getLocale()
        Returns the locale for this web resource.
        Returns:
        the locale.
        Since:
        5.0.0
      • setLocale

        protected void setLocale​(java.util.Locale locale)
        Sets the locale for this web resource.

        This method must be called inside a transactional context, so that PortalTransactionFactory.getCurrentTransaction() does not return null.

        Parameters:
        locale - the locale to set.
        Since:
        5.0.0
      • getCreatedDateTime

        public java.util.Date getCreatedDateTime()
        Returns the date-time this web resource was created.
        Returns:
        the date-time this web resource was created.
        Since:
        5.0.0
      • getPageCache

        public PageCacheConfig getPageCache()
        Returns the cache definition for this web resource.
        Returns:
        the cache object or null if this web resource does not have cache.
        Since:
        5.0.0
      • setPageCache

        protected void setPageCache​(PageCacheConfig pageCache)
        Sets the cache definition for this web resource.
        Parameters:
        pageCache - the cache definition.
        Since:
        5.0.0
      • getWebsite

        public IWebsite getWebsite()
        Returns the website this web resource belongs to.

        The full URL to access this web resource is composed by a base URL of the web site it belongs, and the path of this web resource.

        If this web resource is located in an area of portal that do not belong to any website, this method will return null.

        Returns:
        the website this web resource belongs to.
        Since:
        6.2.0
      • setWebsite

        protected void setWebsite​(IWebsite website)
        Sets the website this web resource belongs to.

        The website of the web resource must be set during its creation. The website of an existing web resource cannot be changed. It must be deleted and recreated instead.

        Parameters:
        website - the website.
        Since:
        6.2.0
        See Also:
        getWebsite()
      • getPath

        public final java.lang.String getPath()
        Returns the path to access this web resource. The returned value is taken from cache configuration, getFriendlyPath() or getDynamicPath().
        Returns:
        the path to access this web resource, starting with '/' and relative to the portal web application root.
        Since:
        5.0.0
      • calculatePath

        protected java.lang.String calculatePath()
        Returns the path to access this web resource. The returned value is taken from cache configuration, getFriendlyPath() or getDynamicPath().
        Returns:
        the path to access this web resource, starting with '/' and relative to the portal web application root.
        Since:
        12.1.0
      • isCacheEnabled

        @Deprecated
        public boolean isCacheEnabled​(boolean considerGuestOnlyCache)
        Deprecated.
        since 10.3.0 replaced by isCacheEnabled(). From version 10.3.0 on, the parameter considerGuestOnlyCache is ignored.
        Returns if the cache is enabled for this web resource for the current user.
        Parameters:
        considerGuestOnlyCache - indicates if the result should be true even if the cache is only for guest.
        Returns:
        true if the cache is enabled, false otherwise.
        Since:
        5.0.0
      • isCacheEnabled

        public boolean isCacheEnabled()
        Returns if the cache is enabled for this web resource.
        Returns:
        true if the cache is enabled, false otherwise.
        Since:
        10.3.0
      • getParent

        public abstract WebResource getParent()
        Returns the web resource of the parent element of this web resource.
        Returns:
        the parent of this web resource, or null if it has no parent.
        Since:
        5.0.0
      • getName

        public abstract java.lang.String getName()
        Returns the name for this web resource. The name is usually used for management display purposes.
        Returns:
        this web resource's name, localized according to its locale.
        Since:
        5.0.0
        See Also:
        getLocale()
      • getTitle

        public abstract java.lang.String getTitle()
        Returns the title for this web resource. The title is usually used as an end-user title.
        Returns:
        this web resource's title, localized according to its locale.
        Since:
        5.0.0
        See Also:
        getLocale()
      • getUrlTitle

        public abstract java.lang.String getUrlTitle()
        Returns the title value meant to be used for friendly URL generation of this web resource.
        Returns:
        the title value.
        Since:
        10.0.0
        See Also:
        IURLResolver
      • getParameterMap

        public abstract java.util.Map<java.lang.String,​java.lang.String[]> getParameterMap()
        Returns a map containing all parameters for this web resource.
        Returns:
        an immutable map containing all parameters for this web resource.
        Since:
        5.0.0
      • getParameter

        public java.lang.String getParameter​(java.lang.String parameterName)
        Returns the value of a parameter for this web resource. If the parameter has multiple values, the first is returned.
        Parameters:
        parameterName - the parameter name.
        Returns:
        the value, or null if no parameter with such name exists for this web resource.
        Since:
        5.0.0
      • getParameterValues

        public java.lang.String[] getParameterValues​(java.lang.String parameterName)
        Returns the values of a parameter for this web resource.
        Parameters:
        parameterName - the parameter name.
        Returns:
        the values, or null if no parameter with such name exists for this web resource.
        Since:
        5.0.0
      • getProperties

        public abstract java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getProperties()
        Returns the properties for this web resource.
        Returns:
        a immutable map where the key is the property name and the value is a list of the property's values.
        Since:
        5.0.0
      • localize

        protected java.lang.String localize​(java.lang.String key)
        Returns the localized version of the given string. The localization is done based on this web resource's locale.
        Parameters:
        key - the string.
        Returns:
        the localized version.
        Since:
        5.0.0
        See Also:
        getLocale()
      • mayBePersisted

        protected boolean mayBePersisted()
        Indicates whether this web resource may be persisted.

        There are other rules relating to web resource persisting. If this method returns false, this web resource may never be persisted. If this method returns true, it will depend on the other rules to decide if it will be persisted.

        This method may be called when the web resource object is not with all its attributes set yet.

        Returns:
        whether this web resource may be persisted.
        Since:
        6.0.0
      • isAvailableForGetRequest

        protected boolean isAvailableForGetRequest()
        Returns whether this web resource is available for a GET request to it.

        Normally non-persisted web resources whose dynamic path differs from the main path indicates that it was not generated

        Returns:
        true if this web resource is available, false otherwise.
        Since:
        6.0.0
      • isDynamicRequestValid

        protected boolean isDynamicRequestValid​(javax.servlet.http.HttpServletRequest request)
        Indicates whether the given request is a valid dynamic request for this web resource.
        Parameters:
        request - the request.
        Returns:
        true if valid, false otherwise.
        Since:
        6.0.0
      • hasSSI

        protected boolean hasSSI()
        Returns whether this web resource has Server Side Include (requires SSI pos-processing).
        Returns:
        true if this web resource has SSI, false otherwise.
        Since:
        6.0.0
      • getRecommendedFileExtension

        protected java.lang.String getRecommendedFileExtension()
        Returns the file extension recommended for this web resource, according to its configurations.
        Returns:
        the extension, starting with '.'. Example: ".htm"
        Since:
        6.0.0
      • toString

        public java.lang.String toString()
        Returns a string representation for debug and logging purposes.
        Overrides:
        toString in class java.lang.Object
        Returns:
        string representation for debug and logging purposes.
        Since:
        5.0.0
      • clone

        public WebResource clone()
                          throws java.lang.CloneNotSupportedException
        Specified by:
        clone in interface ICloneableCacheEntry
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
      • getProject

        public abstract IProject getProject()
                                     throws PortalException
        Returns the project this web resource belongs to (if any).
        It is important to notice that the relation webresource <-> project is not persisted. Instead, it is calculated at runtime.
        This method may require a current transaction.
        Returns:
        the project this web resource belongs to (if any).
        Throws:
        PortalException
        Since:
        12.4.0