Skip to content

Commit

Permalink
issue #178 - reuse token in XMLRPC protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Oct 26, 2018
1 parent ff24750 commit c8ca5c1
Show file tree
Hide file tree
Showing 26 changed files with 281 additions and 273 deletions.
108 changes: 71 additions & 37 deletions CHANGELOG.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import static java.lang.String.format;

import java.io.Closeable;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Pattern;
Expand All @@ -16,7 +17,7 @@
*
* @author bsorrentino
*/
public interface ConfluenceService {
public interface ConfluenceService extends Closeable{

public enum Protocol {

Expand Down Expand Up @@ -174,8 +175,6 @@ void exportPage( String url,
ExportFormat exfmt,
java.io.File outputFile) throws Exception;

void call(java.util.function.Consumer<ConfluenceService> task) throws Exception;

//
// ATTACHMENT
//
Expand Down Expand Up @@ -217,4 +216,4 @@ default CompletableFuture<Model.Page> getOrCreatePage(
;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static org.bsc.confluence.xmlrpc.XMLRPCConfluenceServiceImpl.createInstanceDetectingVersion;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -125,16 +126,6 @@ public String toString() {
return xmlrpcService.toString();
}

@Override
public void call(java.util.function.Consumer<ConfluenceService> task) throws Exception {
try {
task.accept(this);
}
finally {
xmlrpcService.logout();
}
}

@Override
public List<Model.PageSummary> getDescendents(String pageId) throws Exception {
return xmlrpcService.getDescendents(pageId);
Expand All @@ -149,6 +140,15 @@ public void removePage(String pageId) throws Exception {
public void exportPage(String url, String spaceKey, String pageTitle, ExportFormat exfmt, File outputFile) throws Exception {
xmlrpcService.exportPage(url, spaceKey, pageTitle, exfmt, outputFile);
}

/* (non-Javadoc)
* @see java.io.Closeable#close()
*/
@Override
public void close() throws IOException {
xmlrpcService.logout();

}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static java.util.concurrent.CompletableFuture.completedFuture;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.List;
Expand Down Expand Up @@ -246,14 +247,6 @@ public void exportPage( String url,
outputFile);
}

@Override
public void call(java.util.function.Consumer<ConfluenceService> task) throws Exception {
if (task == null)
throw new java.lang.IllegalArgumentException("task is null!");

task.accept(this);
}

@Override
public Model.Attachment createAttachment() {
return new Attachment();
Expand Down Expand Up @@ -294,10 +287,12 @@ public CompletableFuture<Boolean> removePage(Model.Page parentPage, String title
}

@Override
public void removePage(String pageId) throws Exception {

public void removePage(String pageId) throws Exception {
rxDeletePageById(pageId);

}

@Override
public void close() throws IOException {
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Attachment() {
super();
}

public Attachment(Map data) {
public Attachment(Map<String,Object> data) {
super(data);
}

Expand Down Expand Up @@ -143,8 +143,8 @@ public void setComment(String comment) {
setString("comment", comment);
}

public Map toRawMap() {
Map map = super.toRawMap();
public Map<String,Object> toRawMap() {
Map<String,Object> map = super.toRawMap();
map.put("created", getCreated());
return map;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public BlogEntry() {
super();
}

public BlogEntry(Map data) {
public BlogEntry(Map<String,Object> data) {
super(data);
}

Expand Down Expand Up @@ -119,8 +119,8 @@ public void setLocks(int locks) {
setInt("locks", locks);
}

public Map toRawMap() {
Map map = super.toRawMap();
public Map<String,Object> toRawMap() {
Map<String,Object> map = super.toRawMap();
map.put("version", new Integer(getVersion()));
map.put("locks", new Integer(getLocks()));
return map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public BlogEntrySummary() {
super();
}

public BlogEntrySummary(Map data) {
public BlogEntrySummary(Map<String,Object> data) {
super(data);
}

Expand Down Expand Up @@ -98,8 +98,8 @@ public void setPublishDate(Date publishDate) {
setDate("publishDate", publishDate);
}

public Map toRawMap() {
Map map = super.toRawMap();
public Map<String,Object> toRawMap() {
Map<String,Object> map = super.toRawMap();
map.put("publishDate", getPublishDate());
map.put("locks", new Integer(getLocks()));
return map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Comment() {
super();
}

public Comment(Map data) {
public Comment(Map<String,Object> data) {
super(data);
}

Expand Down Expand Up @@ -109,8 +109,8 @@ public void setCreator(String creator) {
setString("creator", creator);
}

public Map toRawMap() {
Map map = super.toRawMap();
public Map<String,Object> toRawMap() {
Map<String,Object> map = super.toRawMap();
map.put("created", getCreated());
return map;
}
Expand Down
Loading

0 comments on commit c8ca5c1

Please sign in to comment.