Class LinkingService
- java.lang.Object
-
- com.sodius.oslc.server.process.links.services.LinkingService
-
public abstract class LinkingService extends Object
Manages the linking services of the Linking Component.- Since:
- 3.1.0
-
-
Constructor Summary
Constructors Constructor Description LinkingService()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
createLocalLink(ApplicationArtifact artifact, ApplicationContainer container, LinkingType linkingType, Link remoteResource, ConfigContext configuration, HttpServletRequest request)
Creates/saves the local link when suitable.protected void
customizeDialogs(List<Service> services, LinkingType linkingType, ApplicationArtifact artifact, ApplicationContainer container)
Refines the available services' dialogs, given the artifact source of the linking and the container.protected void
customizeScopes(Collection<ContainerScope> scopes, ApplicationArtifact artifact, ApplicationContainer container)
Refines the available container scopes, given the artifact source of the linking and the container.protected Optional<String>
getCustomizedDialogCause(LinkingType linkingType, ApplicationArtifact artifact, ApplicationContainer container, boolean isCreationDialog)
Gets the cause to explain why a given type of dialog was excluded from the scopes.protected Optional<Feedback>
getCustomizedScopesFeedback(LinkingType linkingType, ApplicationArtifact artifact, ApplicationContainer container)
Gets a feedback to explain why a given linking type was excluded from the scopes.Response
getLinkCompact(URI link, URI linkingType, String containerId, String artifactId, String artifactType)
Resolves theCompact
resource of a linked artifact.protected Optional<String>
getMissingCompactInContextHint(URI compact, ApplicationArtifact artifact, ApplicationContainer container, LinkingType linkingType)
Provides a hint to solve the missing-compact-in-context issue.protected String
getMissingLinkContextWarningMessage(Compact compact, ApplicationArtifact artifact, ApplicationContainer container, LinkingType linkingType)
Gets the missing context warning message for a linked artifact.Response
getOslcUri(String url)
Response
getScope(String containerId, String artifactId, String artifactType)
Resolves the link types (or domains) available for linking per remote associated project.Response
getScopeExplanation(String containerId, String artifactId, String artifactType)
Explains with Feedback messages why a given link type (or domain) is available (or not) for linking.Response
getSupportedLinkingTypes(String containerId, String artifactId, String artifactType)
Responds all link types that are supported by the application, independently of friends and project associations.Response
getTarget(String containerId, String artifactId, String artifactType, URI linkingType, URI remoteServiceProvider, URI configuration, String configurationTitle)
Fetches the remote linking service provider (in the context of a GC if any) while scoping the dialogs to thelinking type
.Response
link(String containerId, String artifactId, String artifactType)
Creates (if applicable) a remote incoming link and (if applicable) a local outgoing link.Response
postScope(String containerId, String artifactId, String artifactType)
Determines the link types (or domains) available for linking given the linking resources (dropped/pasted elements).Response
validateScope(String containerId, String artifactId, String artifactType)
Evaluates a potential remote artifact URL against a previously-chosenlinking scope
.
-
-
-
Method Detail
-
customizeScopes
protected void customizeScopes(Collection<ContainerScope> scopes, ApplicationArtifact artifact, ApplicationContainer container)
Refines the available container scopes, given the artifact source of the linking and the container.The list of container scopes contains entries for associated containers and link types corresponding to the associations. This list is already filtered based on the given linking type, if any.
This implementation does nothing, i.e. not filtering out anything from the list. Subclasses may override to restrict the link types, for example if some of them are disabled at server administration level. Implementation should also override
getCustomizedScopesFeedback(LinkingType, ApplicationArtifact, ApplicationContainer)
in this case.- Parameters:
scopes
- the available container scopes and their link types.artifact
- the artifact source of the linking.container
- the local container owning the artifact.- Since:
- 3.8.0
-
getCustomizedScopesFeedback
protected Optional<Feedback> getCustomizedScopesFeedback(LinkingType linkingType, ApplicationArtifact artifact, ApplicationContainer container)
Gets a feedback to explain why a given linking type was excluded from the scopes.This implementation returns
Optional.empty()
, as no scope customization is done as a default. Implementations overridingcustomizeScopes(Collection, ApplicationArtifact, ApplicationContainer)
should also override this method to provide a detailed reason of the exclusion.- Parameters:
linkingType
- the given linking type.artifact
- the local linking artifact.container
- the local linking artifact container.- Returns:
- a feedback instance, or
Optional.empty()
if no details on the customized scopes. - Since:
- 3.8.0
-
getScope
public Response getScope(String containerId, String artifactId, String artifactType)
Resolves the link types (or domains) available for linking per remote associated project.- Parameters:
containerId
- the native linking artifact container Id.artifactId
- the native linking artifact Id.artifactType
- the linking artifact type, seeApplicationArtifact
.- Returns:
- the link types (or domains) available for linking if they exist; a suitable
feedback
otherwise. - Throws:
OslcWebApplicationException
- (bad request) if any parameter isnull
.
(not found) if either the native container or artifact are not available.
(forbidden) if the logged-in user cannot edit the native artifact for linking.
(server error) if the corresponding remote associations cannot be loaded.
-
getScopeExplanation
public Response getScopeExplanation(String containerId, String artifactId, String artifactType)
Explains with Feedback messages why a given link type (or domain) is available (or not) for linking.- Parameters:
containerId
- the native linking artifact container Id.artifactId
- the native linking artifact Id.artifactType
- the linking artifact type, seeApplicationArtifact
.- Returns:
- a Feedback with messages detailing the scope.
- Throws:
OslcWebApplicationException
- (bad request) if any parameter isnull
.
(not found) if either the native container or artifact are not available.
(forbidden) if the logged-in user cannot edit the native artifact for linking.
(server error) if the corresponding remote associations cannot be loaded.
-
getSupportedLinkingTypes
public Response getSupportedLinkingTypes(String containerId, String artifactId, String artifactType)
Responds all link types that are supported by the application, independently of friends and project associations. The given artifact information is used to resolve the corresponding standard OSLC type, to determine the applicable link types.- Parameters:
containerId
- the native linking artifact container Id.artifactId
- the native linking artifact Id.artifactType
- the linking artifact type, seeApplicationArtifact
.- Returns:
- the link types supported by the application for the given type of artifact.
- Throws:
OslcWebApplicationException
- (bad request) if any parameter isnull
.
(not found) if either the native container or artifact are not available.- Since:
- 3.5.0
-
postScope
public Response postScope(String containerId, String artifactId, String artifactType)
Determines the link types (or domains) available for linking given the linking resources (dropped/pasted elements).- Parameters:
containerId
- the native linking artifact container Id.artifactId
- the native linking artifact Id.artifactType
- the linking artifact type, seeApplicationArtifact
.- Returns:
- the link types (or domains) available for the linking resources.
- Throws:
OslcWebApplicationException
- (bad request) if any parameter isnull
or no association can be resolved for the linking resources.
(precondition failed) if an association is found but link types were disabled on the hosting application
(server error) if the corresponding remote associations cannot be loaded.
-
validateScope
public Response validateScope(String containerId, String artifactId, String artifactType)
Evaluates a potential remote artifact URL against a previously-chosenlinking scope
.This method is used to assert a dropped or pasted artifact belongs or is compatible with the chosen linking scope.
- Parameters:
containerId
- the native linking artifact container Id.artifactId
- the native linking artifact Id.artifactType
- the linking artifact type, seeApplicationArtifact
.- Returns:
- the
oslc:Compact
representation of thelinkingResource
with noFeedback
if the validation succeeded (which means the linking fromartifactId
toLinkingResource
is possible. An error feedback indicates the linking is not possible and a warning feedback means the linking is possible but some (GlobalConfiguration) issues may exists. - Throws:
OslcWebApplicationException
- (bad request) if any parameter (but theAbstractLinkingContext.getConfiguration()
isnull
(bad request) if theAbstractLinkingContext.getLinkingType()
is unknown.
(bad request) if thelinkingResource
is not a URL.
(bad request) if thelinkingResource
does not correspond to an OSLC linkable resource.
(not found) if either the native container or artifact are not available.
(forbidden) if the logged-in user cannot edit the native artifact for linking.
(server error) if the corresponding remote associations cannot be loaded.
(server error) if a remote communication fails.
-
customizeDialogs
protected void customizeDialogs(List<Service> services, LinkingType linkingType, ApplicationArtifact artifact, ApplicationContainer container)
Refines the available services' dialogs, given the artifact source of the linking and the container.The list of services are already filtered to the
linking domain
and linking range if any. This implementation does nothing, i.e. not filtering out anything from the list. Subclasses may override to add filtering criteria, for example if a dialog for a given resource type is not allowed.- Parameters:
services
- the available services and their dialogs.linkingType
- the linking type.artifact
- the artifact source of the linking.container
- the local container owning the artifact.- Since:
- 3.8.0
-
getCustomizedDialogCause
protected Optional<String> getCustomizedDialogCause(LinkingType linkingType, ApplicationArtifact artifact, ApplicationContainer container, boolean isCreationDialog)
Gets the cause to explain why a given type of dialog was excluded from the scopes.This implementation returns an empty optional. Subclasses may override to get the filtering criteria cause.
- Parameters:
linkingType
- the given linking type.artifact
- the local linking artifact.container
- the local linking artifact container.isCreationDialog
- whether the excluded dialog of interest if the creation dialog or not.- Returns:
- an empty
Optional
if no cause is provided, the contained cause otherwise. - Since:
- 3.8.0
-
getTarget
public Response getTarget(String containerId, String artifactId, String artifactType, URI linkingType, URI remoteServiceProvider, URI configuration, String configurationTitle)
Fetches the remote linking service provider (in the context of a GC if any) while scoping the dialogs to thelinking type
.An in-use global configuration can be provided by the hosting application if applicable (typically if there's a GC picker widget); otherwise, this end point will try to
resolve the indirect-in-use global configuration
if any.- Parameters:
containerId
- the native linking artifact container Id.artifactId
- the native linking artifact Id.artifactType
- the linking artifact type, seeApplicationArtifact
.linkingType
- the linking type.remoteServiceProvider
- the remoteServiceProvider
.configuration
- the (optional) in-use global configuration URI.configurationTitle
- the (optional) in-use global configuration title.- Returns:
- the remote linking service provider.
- Throws:
OslcWebApplicationException
- (bad request) if a non-optional parameter isnull
or the linking type is unknown.
(not found) if either the native container or artifact are not available.
(forbidden) if the logged-in user cannot edit the native artifact for linking.
(server error) if a remote communication fails.
-
createLocalLink
protected abstract void createLocalLink(ApplicationArtifact artifact, ApplicationContainer container, LinkingType linkingType, Link remoteResource, ConfigContext configuration, HttpServletRequest request)
Creates/saves the local link when suitable. This method is called ONLY when saving locally has meaning for the linking type nature.- Parameters:
artifact
- the local linking artifact.container
- the local linking artifact container.linkingType
- the linking type to be created.remoteResource
- the remote (target) resource.configuration
- the in-use global configuration, if any.request
- the current HTTP request.- Since:
- 3.8.0
-
link
public Response link(String containerId, String artifactId, String artifactType)
Creates (if applicable) a remote incoming link and (if applicable) a local outgoing link.- Parameters:
containerId
- the native linking artifact container Id.artifactId
- the native linking artifact Id.artifactType
- the linking artifact type, seeApplicationArtifact
.- Returns:
- a success response.
- Throws:
OslcWebApplicationException
- (bad request) if a non-optional parameter isnull
or the linking type is unknown.
(not found) if either the native container or artifact are not available.
(forbidden) if the logged-in user cannot edit the native artifact for linking.
(server error) if a remote communication fails.
-
getMissingCompactInContextHint
protected Optional<String> getMissingCompactInContextHint(URI compact, ApplicationArtifact artifact, ApplicationContainer container, LinkingType linkingType)
Provides a hint to solve the missing-compact-in-context issue.Applications can override this method to guide users on how to solve the issue.
- Parameters:
compact
- the missing compact URI.artifact
- the local linked artifact.container
- the local linked artifact container.linkingType
- the link type- Returns:
- an empty
Optional
if no guide is available; the contained hint otherwise. - Since:
- 3.8.0
-
getMissingLinkContextWarningMessage
protected String getMissingLinkContextWarningMessage(Compact compact, ApplicationArtifact artifact, ApplicationContainer container, LinkingType linkingType) throws Exception
Gets the missing context warning message for a linked artifact.This message warns users about a possibly missing GC when fetching
Compact
resources of linked artifacts.Applications can override this method to provide a more detailed message than the generic one.
- Parameters:
compact
- the remoteCompact
resource.artifact
- the local linked artifact.container
- the local linked artifact container.linkingType
- the link type- Returns:
No Global Configuration is being used for this link. However, one may be required given the nature of the associated projects. Please validate whether the artifact version is the expected one or make sure a proper Global Configuration is used.
- Throws:
Exception
- if any exception occurs trying build the appropriate message.- Since:
- 3.8.0
-
getLinkCompact
public Response getLinkCompact(URI link, URI linkingType, String containerId, String artifactId, String artifactType) throws ServletException, IOException
Resolves theCompact
resource of a linked artifact.Unlike
ProxyService.getCompact(String)
, this method is aimed to provide guidance and feedback to users when there is, or there may be, a Global Configuration issue. Applications can overridegetMissingCompactInContextHint(URI, ApplicationArtifact, ApplicationContainer, LinkingType)
and/orgetMissingLinkContextWarningMessage(Compact, ApplicationArtifact, ApplicationContainer, LinkingType)
to provide a more detailed hint/guidance.- Parameters:
link
- the remote resource URI.linkingType
- the linking type.containerId
- the local artifact container id.artifactId
- the local artifact id.artifactType
- the local artifact type.- Returns:
- the
Compact
representation of the remote resource. - Throws:
ServletException
- if request cannot be dispatched to a local resource.IOException
- if some I/O exception occurs.- Since:
- 3.3.0
-
-