Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to create RemotePage with subpages?

Romeo Mottola February 2, 2014

Hello,

i'am using the SOAP API. I've completed the steps (by Bob Swift) to built my own Java classes.

(like ConfluenceSoapService, ConfluenceSoapServiceServiceloactor, and so on ...) in use of the WSDL file and the cmd.exe.

here: https://bobswift.atlassian.net/wiki/display/CSOAPLIB/Confluence+SOAP+Library

Now i have a small client that creates a simple Page on my local Confluence-Instance.

public class Connection {

	private ConfluenceSoapServiceServiceLocator csssl;
	private static ConfluenceSoapService css;
	private String TOKEN;
	
	private String SERVER = "http://localhost:8090";
	private String ENDPOINT = "/rpc/soap-axis/confluenceservice-v2";
	
	private String USER;
    private String PASSWORD;

    
    
	public Connection(String server, String endpoint, String user,
			String password) {
		SERVER = server;
		ENDPOINT = endpoint;
		USER = user;
		PASSWORD = password;
	}

	public Connection(String user, String password) {
		
		this.USER = user;
		this.PASSWORD = password;
		
		csssl = new ConfluenceSoapServiceServiceLocator();
		csssl.setConfluenceserviceV2EndpointAddress(SERVER + ENDPOINT);
		
		try {
			css = csssl.getConfluenceserviceV2();
			TOKEN = css.login(USER, PASSWORD);
		} catch (ServiceException e) {
			e.printStackTrace();
		} catch (AuthenticationFailedException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (java.rmi.RemoteException e) {
			e.printStackTrace();
		}
		System.out.println("connected to "+SERVER+" as "+USER+" ...");
	}

	public ConfluenceSoapService getCss() {
		return css;
	}
	
	public String getToken() {
		return this.TOKEN;
	}
}

import javax.swing.JOptionPane;

import org.swift.common.soap.confluence.InvalidSessionException;
import org.swift.common.soap.confluence.NotPermittedException;
import org.swift.common.soap.confluence.RemoteException;
import org.swift.common.soap.confluence.RemotePage;
import org.swift.common.soap.confluence.VersionMismatchException;

public class Main {

	public static void main(String[] args) 
			throws InvalidSessionException, NotPermittedException, VersionMismatchException, RemoteException, java.rmi.RemoteException {
		
		Connection con = new Connection("admin", "password");
		
		RemotePage rp = new RemotePage();
		rp.setTitle("New Page");
		rp.setSpace("Test");
		
		RemotePage checkIfExists = con.getCss().getPage(con.getToken(), rp.getSpace(), rp.getTitle());
		if (checkIfExists!=null) {
			
			System.out.println("Page '" + rp.getTitle() + "' already exists ...");
			rp.setTitle(JOptionPane.showInputDialog(null, "Type in another name for the new page"));
			System.out.println(rp.getTitle() + " set as new name ...");
			con.getCss().storePage(con.getToken(), rp);
			System.out.println("New page: '" + rp.getTitle() + "' added ...");
		}
		else {
			con.getCss().storePage(con.getToken(), rp);
			System.out.println("New page: '" + rp.getTitle() + "' added ...");
		}
	}
}

But i want to create varios pages with subpages. a few helpful answers would be great :-)

kind regards

Romeo

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Romeo Mottola February 5, 2014

I need to develop a java based client to add pages with various contents to confluence. Especially pages with subpages. These pages will contain Documentations for our Software, so there'll be many pages.

... way to do this?

TAGS
AUG Leaders

Atlassian Community Events