org.opencms.ade.publish
Class CmsPublish

java.lang.Object
  extended by org.opencms.ade.publish.CmsPublish
Direct Known Subclasses:
CmsExtendedPublish, CmsRelease

public class CmsPublish
extends java.lang.Object

ADE publishing features.

Since:
8.0.0

Nested Class Summary
 class CmsPublish.ResourcesAndRelated
          Just for passing around resources and their related together but not mixed up.
 
Field Summary
protected static int GROUP_DAYS_NUMBER
          The number of day groups.
protected static int GROUP_SESSIONS_GAP
          The gap between session groups.
protected static int GROUP_SESSIONS_NUMBER
          The number of session groups.
protected  CmsObject m_cms
          The current cms context.
protected  CmsPublishOptions m_options
          The options.
protected  java.util.Locale m_workplaceLocale
          The current user workplace locale.
 
Constructor Summary
CmsPublish(CmsObject cms)
          Constructor with default options.
CmsPublish(CmsObject cms, CmsPublishOptions options)
          Constructor with options.
 
Method Summary
protected  void addRelated(CmsPublish.ResourcesAndRelated resourceList)
          Adds related resource to a publish list.
protected  void addSiblings(CmsPublish.ResourcesAndRelated resourceList)
          Adds siblings to a publish list.
protected  CmsPublishResource createPublishResource(CmsResource resource, java.util.List<CmsResource> pubList, java.util.Set<CmsResource> allPubRes, java.util.Set<CmsResource> published, CmsPublish.ResourcesAndRelated permissions, CmsPublish.ResourcesAndRelated locked)
          Creates a CmsPublishResource from a CmsResource.
protected  java.util.Set<CmsResource> getAlreadyPublishedResources(CmsPublish.ResourcesAndRelated publishResources)
          Returns already published resources.
protected  CmsPublish.ResourcesAndRelated getBlockingLockedResources(CmsPublish.ResourcesAndRelated publishResources, java.util.Set<CmsResource> exclude)
          Returns locked resources that do not belong to the current user.
 java.util.List<CmsPublishResource> getBrokenResources(java.util.List<CmsResource> pubResources)
          Checks for possible broken links when the given list of resources would be published.
 java.util.List<CmsProjectBean> getManageableProjects()
          Returns the current user's manageable projects.
 CmsPublishOptions getOptions()
          Returns the options.
protected  java.lang.String getOuAwareName(java.lang.String name)
          Returns the simple name if the ou is the same as the current user's ou.
 java.util.List<CmsPublishGroup> getPublishGroups()
          Returns the list of publish groups with resources that can be published.
 java.util.List<CmsPublishResource> getPublishResourceBeans()
          Gets the list of publish resource beans.
 java.util.List<CmsPublishResource> getPublishResourceBeans(CmsPublish.ResourcesAndRelated rawPublishResources)
          Gets the publish resources as a list of CmsPublishResource beans.
 java.util.List<CmsResource> getPublishResources()
          Gets the publish resources as a list of CmsResource objects.
 CmsPublish.ResourcesAndRelated getPublishResourcesInternal()
          Returns the resources stored in the user's publish list.
protected  java.util.List<CmsResource> getRawPublishResources()
          Gets the raw list of publish resources without any related resources or siblings.
protected  java.util.List<CmsPublishResource> getRelatedResources(CmsResource resource, java.util.Set<CmsResource> resources, java.util.Set<CmsResource> published, CmsPublish.ResourcesAndRelated permissions, CmsPublish.ResourcesAndRelated locked)
          Returns a string with a list of related resources in the publish list.
protected  CmsPublishResourceInfo getResourceInfo(CmsResource resource, java.util.Set<CmsResource> published, CmsPublish.ResourcesAndRelated permissions, CmsPublish.ResourcesAndRelated locked)
          Returns the additional info for the given resource.
protected  java.lang.String getResourceName(java.lang.String rootPath, java.lang.String siteRoot)
          Formats the given resource path depending on the site root.
protected  CmsPublish.ResourcesAndRelated getResourcesWithoutPermissions(CmsPublish.ResourcesAndRelated publishResources, java.util.Set<CmsResource> exclude)
          Returns the sublist of the publish list with resources without publish permissions.
 void publishResources(java.util.List<CmsResource> resources)
          Publishes the given list of resources.
 CmsPublishResource relationToBean(CmsRelation relation)
          Creates a publish resource bean from the target information of a relation object.
 void removeResourcesFromPublishList(java.util.Collection<CmsUUID> idsToRemove)
          Removes the given resources from the user's publish list.
protected  CmsPublishResource resourceToBean(CmsResource resource, CmsPublishResourceInfo info, boolean removable, java.util.List<CmsPublishResource> related)
          Creates a publish resource bean instance from the given parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUP_DAYS_NUMBER

protected static final int GROUP_DAYS_NUMBER
The number of day groups.

See Also:
Constant Field Values

GROUP_SESSIONS_GAP

protected static final int GROUP_SESSIONS_GAP
The gap between session groups.

See Also:
Constant Field Values

GROUP_SESSIONS_NUMBER

protected static final int GROUP_SESSIONS_NUMBER
The number of session groups.

See Also:
Constant Field Values

m_cms

protected final CmsObject m_cms
The current cms context.


m_workplaceLocale

protected final java.util.Locale m_workplaceLocale
The current user workplace locale.


m_options

protected final CmsPublishOptions m_options
The options.

Constructor Detail

CmsPublish

public CmsPublish(CmsObject cms)
Constructor with default options.

Parameters:
cms - the current cms context

CmsPublish

public CmsPublish(CmsObject cms,
                  CmsPublishOptions options)
Constructor with options.

Parameters:
cms - the current cms context
options - the options to use
Method Detail

getBrokenResources

public java.util.List<CmsPublishResource> getBrokenResources(java.util.List<CmsResource> pubResources)
Checks for possible broken links when the given list of resources would be published.

Parameters:
pubResources - list of resources to be published
Returns:
a list of resources that would produce broken links when published

getManageableProjects

public java.util.List<CmsProjectBean> getManageableProjects()
Returns the current user's manageable projects.

Returns:
the current user's manageable projects

getOptions

public CmsPublishOptions getOptions()
Returns the options.

Returns:
the options

getPublishGroups

public java.util.List<CmsPublishGroup> getPublishGroups()
Returns the list of publish groups with resources that can be published.

Returns:
the list of publish groups with resources that can be published

getPublishResourceBeans

public java.util.List<CmsPublishResource> getPublishResourceBeans()
Gets the list of publish resource beans.

Returns:
the list of publish resource beans

getPublishResourceBeans

public java.util.List<CmsPublishResource> getPublishResourceBeans(CmsPublish.ResourcesAndRelated rawPublishResources)
Gets the publish resources as a list of CmsPublishResource beans.

Parameters:
rawPublishResources - the publish resources which should be converted to publish resource beans
Returns:
the publish resource beans

getPublishResources

public java.util.List<CmsResource> getPublishResources()
Gets the publish resources as a list of CmsResource objects.

Returns:
the publish resources

getPublishResourcesInternal

public CmsPublish.ResourcesAndRelated getPublishResourcesInternal()
Returns the resources stored in the user's publish list.

Returns:
the resources stored in the user's publish list

publishResources

public void publishResources(java.util.List<CmsResource> resources)
                      throws CmsException
Publishes the given list of resources.

Parameters:
resources - list of resources to publish
Throws:
CmsException - if something goes wrong

relationToBean

public CmsPublishResource relationToBean(CmsRelation relation)
Creates a publish resource bean from the target information of a relation object.

Parameters:
relation - the relation to use
Returns:
the publish resource bean for the relation target

removeResourcesFromPublishList

public void removeResourcesFromPublishList(java.util.Collection<CmsUUID> idsToRemove)
                                    throws CmsException
Removes the given resources from the user's publish list.

Parameters:
idsToRemove - list of structure ids identifying the resources to be removed
Throws:
CmsException - if something goes wrong

addRelated

protected void addRelated(CmsPublish.ResourcesAndRelated resourceList)
Adds related resource to a publish list.

Parameters:
resourceList - the publish listto which the related resources should be added

addSiblings

protected void addSiblings(CmsPublish.ResourcesAndRelated resourceList)
Adds siblings to a publish list.

Parameters:
resourceList - the publish list to which siblings should be added

createPublishResource

protected CmsPublishResource createPublishResource(CmsResource resource,
                                                   java.util.List<CmsResource> pubList,
                                                   java.util.Set<CmsResource> allPubRes,
                                                   java.util.Set<CmsResource> published,
                                                   CmsPublish.ResourcesAndRelated permissions,
                                                   CmsPublish.ResourcesAndRelated locked)
Creates a CmsPublishResource from a CmsResource.

Parameters:
resource - the resource to convert
pubList - a publish list
allPubRes - a set of all publish resources
published - a set of already published resources
permissions - resources for which we don't have the permissions
locked - resources which are locked by another user
Returns:
a publish resource bean

getAlreadyPublishedResources

protected java.util.Set<CmsResource> getAlreadyPublishedResources(CmsPublish.ResourcesAndRelated publishResources)
Returns already published resources.

Parameters:
publishResources - the resources from which we should find the already published resources
Returns:
already published resources

getBlockingLockedResources

protected CmsPublish.ResourcesAndRelated getBlockingLockedResources(CmsPublish.ResourcesAndRelated publishResources,
                                                                    java.util.Set<CmsResource> exclude)
Returns locked resources that do not belong to the current user.

Parameters:
publishResources - the publish resources for which we should find the locked resources
exclude - the resources to exclude
Returns:
the locked and related resources
See Also:
CmsLock.getBlockingLockedResources()

getOuAwareName

protected java.lang.String getOuAwareName(java.lang.String name)
Returns the simple name if the ou is the same as the current user's ou.

Parameters:
name - the fully qualified name to check
Returns:
the simple name if the ou is the same as the current user's ou

getRawPublishResources

protected java.util.List<CmsResource> getRawPublishResources()
                                                      throws CmsException
Gets the raw list of publish resources without any related resources or siblings.

Returns:
the raw list of publish resources
Throws:
CmsException - if something goes wrong

getRelatedResources

protected java.util.List<CmsPublishResource> getRelatedResources(CmsResource resource,
                                                                 java.util.Set<CmsResource> resources,
                                                                 java.util.Set<CmsResource> published,
                                                                 CmsPublish.ResourcesAndRelated permissions,
                                                                 CmsPublish.ResourcesAndRelated locked)
Returns a string with a list of related resources in the publish list.

Parameters:
resource - the resource to use
resources - the resources the user can really publish
published - the already published resources
permissions - the resource the current user does not have publish permissions for
locked - the locked resources
Returns:
a string with a list of related resources in the publish list, or null if none

getResourceInfo

protected CmsPublishResourceInfo getResourceInfo(CmsResource resource,
                                                 java.util.Set<CmsResource> published,
                                                 CmsPublish.ResourcesAndRelated permissions,
                                                 CmsPublish.ResourcesAndRelated locked)
Returns the additional info for the given resource.

Parameters:
resource - the resource to use
published - the already published resources
permissions - the resource the current user does not have publish permissions for
locked - the locked resources
Returns:
the additional info for the given resource

getResourceName

protected java.lang.String getResourceName(java.lang.String rootPath,
                                           java.lang.String siteRoot)
Formats the given resource path depending on the site root.

Parameters:
rootPath - the resource path to format
siteRoot - the site root
Returns:
the formatted resource path

getResourcesWithoutPermissions

protected CmsPublish.ResourcesAndRelated getResourcesWithoutPermissions(CmsPublish.ResourcesAndRelated publishResources,
                                                                        java.util.Set<CmsResource> exclude)
Returns the sublist of the publish list with resources without publish permissions.

Parameters:
publishResources - the publish resources for which we should get the resources without permission
exclude - the resources to exclude
Returns:
the list with resources without publish permissions

resourceToBean

protected CmsPublishResource resourceToBean(CmsResource resource,
                                            CmsPublishResourceInfo info,
                                            boolean removable,
                                            java.util.List<CmsPublishResource> related)
Creates a publish resource bean instance from the given parameters.

Parameters:
resource - the resource
info - the publish information, if any
removable - if removable
related - the list of related resources
Returns:
the publish resource bean