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 voidaddProjectImport(Uri import_, ProjectGraphUri projectGraph)Add an import to a project.voidaddRoleToGroup(RightsGroupId group, SecurityRoleId role)Add a security role to a rights group.booleancanCreateProject()Can the current user create a project?booleancanDeleteProject(ProjectGraphUri projectGraph)Can the current user create a project?booleancheckGovernanceAreaExists(GovernanceAreaUri uri)Check if a governance area exists.booleancheckProjectExists(ProjectGraphUri projectGraph)Check if a project exists.voidclearProject(ProjectGraphUri projectGraph)Clear the contents of a project.voidcreateGovernanceArea(String label, GovernanceAreaType type, GovernanceAreaUri uri, Optional<String> labelLang)Create a governance area.ProjectGraphUricreateProject(CreateProjectParameters parameters)Create a project.voiddeleteProject(ProjectGraphUri projectGraph)Delete a project.voiddeleteResource(Uri base, Uri resource)Delete a resource such as a governance area.voidenableGovernanceRole(GovernanceRoleUri governanceRole, GovernanceAreaUri subjectArea)Enable a governance role.protected org.apache.http.client.methods.CloseableHttpResponseexecute(org.apache.http.client.methods.HttpUriRequest httpUriRequest)org.apache.http.client.methods.CloseableHttpResponseexecuteSwpViewClass(ExecuteSwpViewClassParameters parameters)Execute an arbitrary SWP view class.StringexecuteSwpViewClassToString(ExecuteSwpViewClassParameters parameters)Execute an arbitrary SWP view class and return its response (body) as a String.protected org.apache.http.client.methods.CloseableHttpResponseget(org.apache.http.client.utils.URIBuilder uriBuilder)protected ClientConfigurationgetClientConfiguration()protected org.apache.http.impl.client.CloseableHttpClientgetHttpClient()protected ClientExceptionnewClientException(org.apache.http.HttpResponse httpResponse)protected org.apache.http.client.utils.URIBuildernewSwpUriBuilder()protected org.apache.http.client.utils.URIBuildernewSwpUriBuilder(String viewClass)protected org.apache.http.client.utils.URIBuildernewUriBuilder(String relativeUriPath)protected org.apache.http.client.methods.CloseableHttpResponsepostForm(List<org.apache.http.NameValuePair> nameValuePairs, org.apache.http.client.utils.URIBuilder uriBuilder)protected StringtoString(org.apache.http.HttpResponse httpResponse)Convert an HttpResponse to a string, usually for logging.protected StringtoString(org.apache.http.HttpResponse httpResponse, String httpResponseEntity)Convert an HttpResponse to a string, usually for logging.protected static RuntimeExceptionwrap(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:AddProjectImportApiFunctionAdd an import to a project.- Specified by:
addProjectImportin 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:AddRoleToGroupApiFunctionAdd a security role to a rights group.- Specified by:
addRoleToGroupin 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:CanCreateProjectApiFunctionCan the current user create a project?- Specified by:
canCreateProjectin interfaceCanCreateProjectApiFunction- Returns:
- true if the current user can create a project
-
canDeleteProject
public final boolean canDeleteProject(ProjectGraphUri projectGraph)
Description copied from interface:CanDeleteProjectApiFunctionCan the current user create a project?- Specified by:
canDeleteProjectin 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:CheckGovernanceAreaExistsApiFunctionCheck if a governance area exists.- Specified by:
checkGovernanceAreaExistsin 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:CheckProjectExistsApiFunctionCheck if a project exists.- Specified by:
checkProjectExistsin 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:ClearProjectApiFunctionClear the contents of a project.- Specified by:
clearProjectin 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:CreateGovernanceAreaApiFunctionCreate a governance area.- Specified by:
createGovernanceAreain 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:CreateProjectApiFunctionCreate 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:
createProjectin interfaceCreateProjectApiFunction- Parameters:
parameters- parameters object- Returns:
- result object
-
deleteProject
public final void deleteProject(ProjectGraphUri projectGraph)
Description copied from interface:DeleteProjectApiFunctionDelete a project.- Specified by:
deleteProjectin 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:DeleteResourceApiFunctionDelete a resource such as a governance area.- Specified by:
deleteResourcein 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:EnableGovernanceRoleApiFunctionEnable a governance role.- Specified by:
enableGovernanceRolein 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:ExecuteSwpViewClassApiFunctionExecute an arbitrary SWP view class.- Specified by:
executeSwpViewClassin 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:ExecuteSwpViewClassApiFunctionExecute an arbitrary SWP view class and return its response (body) as a String.- Specified by:
executeSwpViewClassToStringin 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
-
-