Class AbstractSilverpeasContentManager
- java.lang.Object
-
- org.silverpeas.core.contribution.contentcontainer.content.AbstractSilverpeasContentManager
-
- All Implemented Interfaces:
SilverpeasContentManager
public abstract class AbstractSilverpeasContentManager extends Object implements SilverpeasContentManager
Centralization of common treatments between all implementations ofSilverpeasContentManager
.- Author:
- silveryocha
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractSilverpeasContentManager.ContributionWrapper
Wrapper which permits to handle as aSilverContentInterface
each implementation of aContribution
.
-
Constructor Summary
Constructors Constructor Description AbstractSilverpeasContentManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected <T extends Contribution>
SilverContentVisibilitycomputeSilverContentVisibility(T contribution)
Gets the default content visibility of the given contribution.int
createSilverContent(Connection connection, String resourceId, String componentInstanceId, String userId)
Same ascreateSilverContent(Contribution, String)
, but here theConnection
is given and instead ofContribution
resource identifier and component instance identifier are given.
Internal methodcomputeSilverContentVisibility(Contribution)
will be called with a null parameter.int
createSilverContent(Connection connection, Contribution contribution, String userId)
Same ascreateSilverContent(Contribution, String)
, but here theConnection
is given.int
createSilverContent(Connection connection, Contribution contribution, String userId, boolean visible)
Same ascreateSilverContent(Contribution, String)
, but here theConnection
is given.<T extends Contribution>
intcreateSilverContent(T contribution, String userId)
Creates a silverpeas content from a contribution identifier and the instance of the component instance the resource belong to.void
deleteSilverContent(String resourceId, String componentInstanceId)
Deletes a silverpeas content from a resource identifier and the instance of the component instance the resource belong to.void
deleteSilverContent(Connection connection, String resourceId, String componentInstanceId)
Same asdeleteSilverContent(String, String)
, but here theConnection
is given.void
deleteSilverContent(Contribution contribution)
Same asdeleteSilverContent(String, String)
, but here theContribution
is given instead of resource identifier and component instance identifier.protected abstract List<Contribution>
getAccessibleContributions(List<ResourceReference> resourceReferences, String currentUserId)
Gets list of contribution from their identifier and the identifier of the component instance.protected abstract String
getContentIconFileName(String componentInstanceId)
Gets the icon url of the resource.protected ContentManagementEngine
getContentManager()
protected abstract Optional<Contribution>
getContribution(String resourceId, String componentInstanceId)
Gets the contribution from its identifier and the identifier of the component instance.int
getOrCreateSilverContentId(String resourceId, String componentInstanceId)
Gets the silverpeas content identifier for given resource (represented by an id) in the given component instance (represented by an id).<T extends Contribution>
intgetOrCreateSilverContentId(T contribution)
Gets the silverpeas content identifier about a contribution.
If no content identifier exists, then it is created.List<SilverContentInterface>
getSilverContentByReference(List<ResourceReference> resourceReferences, String currentUserId)
Find all the SilverContents with the given silverpeas content identifiers.int
getSilverContentId(String resourceId, String componentInstanceId)
Same asgetSilverContentId(Contribution)
, but giving resource identifier and component instance identifier instead ofContribution
instance.<T extends Contribution>
intgetSilverContentId(T contribution)
Gets the silverpeas content identifier about a contribution.<T extends Contribution>
voidupdateSilverContentVisibility(T contribution)
Updates the visibility of the given contribution.<T extends Contribution>
voidupdateSilverContentVisibility(T contribution, boolean visibility)
Update the visibility of the given contribution by explicitly giving it.
-
-
-
Method Detail
-
getContentManager
protected ContentManagementEngine getContentManager()
-
getSilverContentByReference
public List<SilverContentInterface> getSilverContentByReference(List<ResourceReference> resourceReferences, String currentUserId)
Description copied from interface:SilverpeasContentManager
Find all the SilverContents with the given silverpeas content identifiers.- Specified by:
getSilverContentByReference
in interfaceSilverpeasContentManager
- Parameters:
resourceReferences
- list of silverpeas content identifier as integercurrentUserId
- the identifier of the user accessing the content.- Returns:
- the content as
SilverpeasComponentInstance
-
getSilverContentId
public <T extends Contribution> int getSilverContentId(T contribution)
Description copied from interface:SilverpeasContentManager
Gets the silverpeas content identifier about a contribution.- Specified by:
getSilverContentId
in interfaceSilverpeasContentManager
- Type Parameters:
T
- a contribution implementation.- Parameters:
contribution
- a contribution.- Returns:
- a silverpeas content identifier as integer.
-
getOrCreateSilverContentId
public <T extends Contribution> int getOrCreateSilverContentId(T contribution)
Description copied from interface:SilverpeasContentManager
Gets the silverpeas content identifier about a contribution.
If no content identifier exists, then it is created.- Specified by:
getOrCreateSilverContentId
in interfaceSilverpeasContentManager
- Type Parameters:
T
- a contribution implementation.- Parameters:
contribution
- a contribution.- Returns:
- a silverpeas content identifier as integer.
-
getOrCreateSilverContentId
public int getOrCreateSilverContentId(String resourceId, String componentInstanceId)
Description copied from interface:SilverpeasContentManager
Gets the silverpeas content identifier for given resource (represented by an id) in the given component instance (represented by an id).
In a first time, the
Contribution
from the given identifiers is retrieved.
An error is thrown if it does not exists.
Then the getting or creating of the linked silverpeas content id is performed.
For performances, and if it knows his context, the caller can performedContentManagementEngine.getSilverContentId(String, String)
before calling this method.If no silverpeas content identifier exists, then it is created.
- Specified by:
getOrCreateSilverContentId
in interfaceSilverpeasContentManager
- Parameters:
resourceId
- a resource identifier.componentInstanceId
- a component instance identifier.- Returns:
- a silverpeas content identifier as integer.
-
getContribution
protected abstract Optional<Contribution> getContribution(String resourceId, String componentInstanceId)
Gets the contribution from its identifier and the identifier of the component instance.
The user rights are not verified here as this method must be used only for silverpeas content id management and not to provide the data to an other service.
- Parameters:
resourceId
- a resource identifier.componentInstanceId
- a component instance identifier.- Returns:
- an optional
Contribution
instance.
-
getAccessibleContributions
protected abstract List<Contribution> getAccessibleContributions(List<ResourceReference> resourceReferences, String currentUserId)
Gets list of contribution from their identifier and the identifier of the component instance.
Implementations of this method must handle the user rights on the resource.
- Parameters:
resourceReferences
- a list of resource identifier.currentUserId
- the identifier of the user accessing the content.- Returns:
- an optional
Contribution
instance.
-
getSilverContentId
public int getSilverContentId(String resourceId, String componentInstanceId)
Same asgetSilverContentId(Contribution)
, but giving resource identifier and component instance identifier instead ofContribution
instance.- Parameters:
resourceId
- a resource identifier.componentInstanceId
- the identifier of a component.- Returns:
- a silverpeas content identifier as integer.
-
createSilverContent
public <T extends Contribution> int createSilverContent(T contribution, String userId)
Description copied from interface:SilverpeasContentManager
Creates a silverpeas content from a contribution identifier and the instance of the component instance the resource belong to.- Specified by:
createSilverContent
in interfaceSilverpeasContentManager
- Type Parameters:
T
- a contribution implementation.- Parameters:
contribution
- a contribution.userId
- the identifier of the user responsible of the creation.- Returns:
- the identifier of the silverpeas content of the contribution as integer.
-
createSilverContent
public int createSilverContent(Connection connection, Contribution contribution, String userId) throws ContentManagerException
Same ascreateSilverContent(Contribution, String)
, but here theConnection
is given.- Throws:
ContentManagerException
- on technical error.
-
createSilverContent
public int createSilverContent(Connection connection, Contribution contribution, String userId, boolean visible) throws ContentManagerException
Same ascreateSilverContent(Contribution, String)
, but here theConnection
is given.- Throws:
ContentManagerException
- on technical error.
-
createSilverContent
public int createSilverContent(Connection connection, String resourceId, String componentInstanceId, String userId) throws ContentManagerException
Same ascreateSilverContent(Contribution, String)
, but here theConnection
is given and instead ofContribution
resource identifier and component instance identifier are given.
Internal methodcomputeSilverContentVisibility(Contribution)
will be called with a null parameter.- Throws:
ContentManagerException
- on technical error.
-
updateSilverContentVisibility
public <T extends Contribution> void updateSilverContentVisibility(T contribution) throws ContentManagerException
Updates the visibility of the given contribution.- Parameters:
contribution
- the content.- Throws:
ContentManagerException
-
updateSilverContentVisibility
public <T extends Contribution> void updateSilverContentVisibility(T contribution, boolean visibility) throws ContentManagerException
Update the visibility of the given contribution by explicitly giving it.- Parameters:
contribution
- the contentvisibility
- forces the visibility so that it bypasses the one set bycomputeSilverContentVisibility(Contribution)
. Only taken into account on a real update.- Throws:
ContentManagerException
-
computeSilverContentVisibility
protected <T extends Contribution> SilverContentVisibility computeSilverContentVisibility(T contribution)
Gets the default content visibility of the given contribution. Useful into creation process.- Parameters:
contribution
- a contribution.- Returns:
- a
SilverContentVisibility
instance initialized with default data.
-
deleteSilverContent
public void deleteSilverContent(String resourceId, String componentInstanceId)
Description copied from interface:SilverpeasContentManager
Deletes a silverpeas content from a resource identifier and the instance of the component instance the resource belong to.- Specified by:
deleteSilverContent
in interfaceSilverpeasContentManager
- Parameters:
resourceId
- the identifier of a resource.componentInstanceId
- the identifier of the component instance the resource belong to.
-
deleteSilverContent
public void deleteSilverContent(Contribution contribution)
Same asdeleteSilverContent(String, String)
, but here theContribution
is given instead of resource identifier and component instance identifier.
-
deleteSilverContent
public void deleteSilverContent(Connection connection, String resourceId, String componentInstanceId) throws ContentManagerException
Same asdeleteSilverContent(String, String)
, but here theConnection
is given.- Throws:
ContentManagerException
- on technical error.
-
-