I need to write a program that will create pages in a target space, under a specific parent, based on existing template, filling in certain “fields” (e.g.: ${description}) based on data from a CSV file.
I am using confluence-rest-client version 5.10.9 even though I am communicating with version 6.15.
I cannot find any (or meaningful) examples of using the Java API. I’m not sure I’m even doing the authentication right. This is a CLI application to be used rarely, to convert old data into new Conf pages, so OAuth or other methods beyond URL, user name and password are overkill.
This is what I’m doing to try and “authenticate”:
AuthenticatedWebResourceProvider client = new AuthenticatedWebResourceProvider(RestClientFactory.newClient(),
getConfluenceCredential().getConfluenceURI(), null);
client.setAuthContext(getConfluenceCredential().getUserName(),
getConfluenceCredential().getUserPassword().toCharArray());
Executor executor = new ThreadPoolExecutor(1,5,1,TimeUnit.MINUTES, new ArrayBlockingQueue(2));
Which “execute” w/o exception.
Then, while looking up the target space:
promiseOptionSpace = spaceService.find()
.withKeys(spaceKey)
.withType(SpaceType.GLOBAL)
.fetchOne();
if ( promiseOptionSpace != null ) result = promiseOptionSpace.get().get();
At runtime I’m getting:
Caused by: java.lang.NullPointerException
at com.atlassian.confluence.rest.client.AbstractRemoteService.newRestWebResource(AbstractRemoteService.java:59)
at com.atlassian.confluence.rest.client.RemoteSpaceServiceImpl.newSpacesRestResource(RemoteSpaceServiceImpl.java:205)
at com.atlassian.confluence.rest.client.RemoteSpaceServiceImpl.newSpacesRestResource(RemoteSpaceServiceImpl.java:213)
at com.atlassian.confluence.rest.client.RemoteSpaceServiceImpl.access$100(RemoteSpaceServiceImpl.java:36)
at com.atlassian.confluence.rest.client.RemoteSpaceServiceImpl$RemoteSpaceFinderImpl.fetchOne(RemoteSpaceServiceImpl.java:141)
at gov.texas.dps.itd.ias.ws.atlassian.confluence.dao.SpaceDAOImpl.getByKey(SpaceDAOImpl.java:50)
What am I doing wrong or forgetting?
Are there no Java/REST API Examples?