Class SwpClient
- java.lang.Object
-
- org.topbraidlive.client.java.impl.SwpClient
-
- All Implemented Interfaces:
AddProjectImportApiFunction
,AddRoleToGroupApiFunction
,ApiFunction
,CanCreateProjectApiFunction
,CanDeleteProjectApiFunction
,CheckGovernanceAreaExistsApiFunction
,CheckProjectExistsApiFunction
,ClearProjectApiFunction
,CreateGovernanceAreaApiFunction
,CreateProjectApiFunction
,DeleteProjectApiFunction
,DeleteResourceApiFunction
,EnableGovernanceRoleApiFunction
,ExecuteSwpViewClassApiFunction
public final class SwpClient extends Object implements AddProjectImportApiFunction, AddRoleToGroupApiFunction, CanCreateProjectApiFunction, CanDeleteProjectApiFunction, CheckGovernanceAreaExistsApiFunction, CheckProjectExistsApiFunction, ClearProjectApiFunction, CreateGovernanceAreaApiFunction, CreateProjectApiFunction, EnableGovernanceRoleApiFunction, ExecuteSwpViewClassApiFunction, DeleteProjectApiFunction, DeleteResourceApiFunction
Client for server functions implemented in SWP.
-
-
Constructor Summary
Constructors Constructor Description SwpClient(ClientConfiguration clientConfiguration, org.apache.http.impl.client.CloseableHttpClient httpClient)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addProjectImport(Uri import_, ProjectGraphUri projectGraph)
Add an import to a project.void
addRoleToGroup(RightsGroupId group, SecurityRoleId role)
Add a security role to a rights group.boolean
canCreateProject()
Can the current user create a project?boolean
canDeleteProject(ProjectGraphUri projectGraph)
Can the current user create a project?boolean
checkGovernanceAreaExists(GovernanceAreaUri uri)
Check if a governance area exists.boolean
checkProjectExists(ProjectGraphUri projectGraph)
Check if a project exists.void
clearProject(ProjectGraphUri projectGraph)
Clear the contents of a project.void
createGovernanceArea(String label, GovernanceAreaType type, GovernanceAreaUri uri, Optional<String> labelLang)
Create a governance area.ProjectGraphUri
createProject(CreateProjectParameters parameters)
Create a project.void
deleteProject(ProjectGraphUri projectGraph)
Delete a project.void
deleteResource(Uri base, Uri resource)
Delete a resource such as a governance area.void
enableGovernanceRole(GovernanceRoleUri governanceRole, GovernanceAreaUri subjectArea)
Enable a governance role.protected org.apache.http.client.methods.CloseableHttpResponse
execute(org.apache.http.client.methods.HttpUriRequest httpUriRequest)
org.apache.http.client.methods.CloseableHttpResponse
executeSwpViewClass(ExecuteSwpViewClassParameters parameters)
Execute an arbitrary SWP view class.String
executeSwpViewClassToString(ExecuteSwpViewClassParameters parameters)
Execute an arbitrary SWP view class and return its response (body) as a String.protected org.apache.http.client.methods.CloseableHttpResponse
get(org.apache.http.client.utils.URIBuilder uriBuilder)
protected ClientConfiguration
getClientConfiguration()
protected org.apache.http.impl.client.CloseableHttpClient
getHttpClient()
protected ClientException
newClientException(org.apache.http.HttpResponse httpResponse)
protected org.apache.http.client.utils.URIBuilder
newSwpUriBuilder()
protected org.apache.http.client.utils.URIBuilder
newSwpUriBuilder(String viewClass)
protected org.apache.http.client.utils.URIBuilder
newUriBuilder(String relativeUriPath)
protected org.apache.http.client.methods.CloseableHttpResponse
postForm(List<org.apache.http.NameValuePair> nameValuePairs, org.apache.http.client.utils.URIBuilder uriBuilder)
protected String
toString(org.apache.http.HttpResponse httpResponse)
Convert an HttpResponse to a string, usually for logging.protected String
toString(org.apache.http.HttpResponse httpResponse, String httpResponseEntity)
Convert an HttpResponse to a string, usually for logging.protected static RuntimeException
wrap(IOException e)
-
-
-
Constructor Detail
-
SwpClient
public SwpClient(ClientConfiguration clientConfiguration, org.apache.http.impl.client.CloseableHttpClient httpClient)
-
-
Method Detail
-
addProjectImport
public final void addProjectImport(Uri import_, ProjectGraphUri projectGraph)
Description copied from interface:AddProjectImportApiFunction
Add an import to a project.- Specified by:
addProjectImport
in interfaceAddProjectImportApiFunction
- Parameters:
import_
- URI of a graph to import (importee), such as urn:x-evn-master:childprojectGraph
- URI of the project graph to be imported into (importer), such as urn:x-evn-master:parent
-
addRoleToGroup
public final void addRoleToGroup(RightsGroupId group, SecurityRoleId role)
Description copied from interface:AddRoleToGroupApiFunction
Add a security role to a rights group.- Specified by:
addRoleToGroup
in interfaceAddRoleToGroupApiFunction
- Parameters:
group
- a rights group such as "readAnyGraphGrp"role
- a role such as "ANY_ROLE" or "Admin"
-
canCreateProject
public final boolean canCreateProject()
Description copied from interface:CanCreateProjectApiFunction
Can the current user create a project?- Specified by:
canCreateProject
in interfaceCanCreateProjectApiFunction
- Returns:
- true if the current user can create a project
-
canDeleteProject
public final boolean canDeleteProject(ProjectGraphUri projectGraph)
Description copied from interface:CanDeleteProjectApiFunction
Can the current user create a project?- Specified by:
canDeleteProject
in interfaceCanDeleteProjectApiFunction
- Parameters:
projectGraph
- URI of the project graph e.g., urn:x-evn-master:abcdefg- Returns:
- true if the current user can delete the project
-
checkGovernanceAreaExists
public final boolean checkGovernanceAreaExists(GovernanceAreaUri uri)
Description copied from interface:CheckGovernanceAreaExistsApiFunction
Check if a governance area exists.- Specified by:
checkGovernanceAreaExists
in interfaceCheckGovernanceAreaExistsApiFunction
- Parameters:
uri
- URI of the governance area- Returns:
- true if the governance area exists
-
checkProjectExists
public final boolean checkProjectExists(ProjectGraphUri projectGraph)
Description copied from interface:CheckProjectExistsApiFunction
Check if a project exists.- Specified by:
checkProjectExists
in interfaceCheckProjectExistsApiFunction
- Parameters:
projectGraph
- URI of the project graph e.g., urn:x-evn-master:abcdefg- Returns:
- true if the project exists
-
clearProject
public final void clearProject(ProjectGraphUri projectGraph)
Description copied from interface:ClearProjectApiFunction
Clear the contents of a project.- Specified by:
clearProject
in interfaceClearProjectApiFunction
- Parameters:
projectGraph
- URI of the project graph e.g., urn:x-evn-master:abcdefg
-
createGovernanceArea
public final void createGovernanceArea(String label, GovernanceAreaType type, GovernanceAreaUri uri, Optional<String> labelLang)
Description copied from interface:CreateGovernanceAreaApiFunction
Create a governance area.- Specified by:
createGovernanceArea
in interfaceCreateGovernanceAreaApiFunction
- Parameters:
label
- label of the new governance areatype
- type of governance areauri
- URI for the new governance arealabelLang
- optional language specifier for the laber
-
createProject
public final ProjectGraphUri createProject(CreateProjectParameters parameters)
Description copied from interface:CreateProjectApiFunction
Create a project.This function will not fail if you try to create a duplicate project graph. Instead, the server will append a suffix to the project graph URI. This function returns the project graph URI that was created.
- Specified by:
createProject
in interfaceCreateProjectApiFunction
- Parameters:
parameters
- parameters object- Returns:
- result object
-
deleteProject
public final void deleteProject(ProjectGraphUri projectGraph)
Description copied from interface:DeleteProjectApiFunction
Delete a project.- Specified by:
deleteProject
in interfaceDeleteProjectApiFunction
- Parameters:
projectGraph
- URI of the project graph e.g., urn:x-evn-master:abcdefg
-
deleteResource
public final void deleteResource(Uri base, Uri resource)
Description copied from interface:DeleteResourceApiFunction
Delete a resource such as a governance area.- Specified by:
deleteResource
in interfaceDeleteResourceApiFunction
- Parameters:
base
- URI of the project graph e.g., urn:x-evn-master:abcdefgresource
- URI of the resource
-
enableGovernanceRole
public final void enableGovernanceRole(GovernanceRoleUri governanceRole, GovernanceAreaUri subjectArea)
Description copied from interface:EnableGovernanceRoleApiFunction
Enable a governance role.- Specified by:
enableGovernanceRole
in interfaceEnableGovernanceRoleApiFunction
- Parameters:
governanceRole
- URI of the governance role e.g., http://edg.topbraid.solutions/model/dataStewardsubjectArea
- URI of the governance subject area e.g., urn:x-tb-governance:test
-
executeSwpViewClass
public final org.apache.http.client.methods.CloseableHttpResponse executeSwpViewClass(ExecuteSwpViewClassParameters parameters)
Description copied from interface:ExecuteSwpViewClassApiFunction
Execute an arbitrary SWP view class.- Specified by:
executeSwpViewClass
in interfaceExecuteSwpViewClassApiFunction
- Parameters:
parameters
- parameters object- Returns:
- HTTP response; must be closed by the caller
-
executeSwpViewClassToString
public final String executeSwpViewClassToString(ExecuteSwpViewClassParameters parameters)
Description copied from interface:ExecuteSwpViewClassApiFunction
Execute an arbitrary SWP view class and return its response (body) as a String.- Specified by:
executeSwpViewClassToString
in interfaceExecuteSwpViewClassApiFunction
- Parameters:
parameters
- parameters object- Returns:
- the response body
-
newSwpUriBuilder
protected final org.apache.http.client.utils.URIBuilder newSwpUriBuilder()
-
newSwpUriBuilder
protected final org.apache.http.client.utils.URIBuilder newSwpUriBuilder(String viewClass)
-
wrap
protected static final RuntimeException wrap(IOException e)
-
getClientConfiguration
protected final ClientConfiguration getClientConfiguration()
-
execute
protected final org.apache.http.client.methods.CloseableHttpResponse execute(org.apache.http.client.methods.HttpUriRequest httpUriRequest)
-
get
protected final org.apache.http.client.methods.CloseableHttpResponse get(org.apache.http.client.utils.URIBuilder uriBuilder)
-
getHttpClient
protected final org.apache.http.impl.client.CloseableHttpClient getHttpClient()
-
newClientException
protected final ClientException newClientException(org.apache.http.HttpResponse httpResponse) throws IOException
- Throws:
IOException
-
newUriBuilder
protected final org.apache.http.client.utils.URIBuilder newUriBuilder(String relativeUriPath)
-
postForm
protected final org.apache.http.client.methods.CloseableHttpResponse postForm(List<org.apache.http.NameValuePair> nameValuePairs, org.apache.http.client.utils.URIBuilder uriBuilder)
-
toString
protected final String toString(org.apache.http.HttpResponse httpResponse) throws IOException
Convert an HttpResponse to a string, usually for logging.Consumes the entity (body) in order to convert it to a string.
- Throws:
IOException
-
toString
protected final String toString(org.apache.http.HttpResponse httpResponse, String httpResponseEntity) throws IOException
Convert an HttpResponse to a string, usually for logging.Uses an entity (body) that has been previously converted to a string.
- Throws:
IOException
-
-