Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 047f66d

Browse files
authored
Merge pull request #356 from cloudant/291-refactor-datastore-callables-part-3
291 refactor datastore callables part 3
2 parents 233cec6 + d36f18c commit 047f66d

29 files changed

+1587
-734
lines changed

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/datastore/AttachmentManager.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public static void addAttachment(SQLDatabase db, String attachmentsDir,
197197
* @throws AttachmentException if there was an error preparing the attachment, e.g., reading
198198
* attachment data.
199199
*/
200-
protected static PreparedAttachment prepareAttachment(String attachmentsDir,
200+
public static PreparedAttachment prepareAttachment(String attachmentsDir,
201201
AttachmentStreamFactory attachmentStreamFactory,
202202
Attachment attachment)
203203
throws AttachmentException {
@@ -232,7 +232,7 @@ protected static PreparedAttachment prepareAttachment(String attachmentsDir,
232232
* @param attachments Attachments to search.
233233
* @return List of attachments which already exist in the attachment store, or an empty list if none.
234234
*/
235-
protected static List<SavedAttachment> findExistingAttachments(
235+
public static List<SavedAttachment> findExistingAttachments(
236236
Collection<? extends Attachment> attachments) {
237237
ArrayList<SavedAttachment> list = new ArrayList<SavedAttachment>();
238238
for (Attachment a : attachments) {
@@ -249,7 +249,7 @@ protected static List<SavedAttachment> findExistingAttachments(
249249
* @param attachments Attachments to search.
250250
* @return List of attachments which need adding to the attachment store, or an empty list if none.
251251
*/
252-
protected static List<Attachment> findNewAttachments(Collection<? extends Attachment> attachments) {
252+
public static List<Attachment> findNewAttachments(Collection<? extends Attachment> attachments) {
253253
ArrayList<Attachment> list = new ArrayList<Attachment>();
254254
for (Attachment a : attachments) {
255255
if (!(a instanceof SavedAttachment)) {
@@ -263,12 +263,13 @@ protected static List<Attachment> findNewAttachments(Collection<? extends Attach
263263
* Download each attachment in {@code attachments} to a temporary location, and
264264
* return a list of attachments suitable for passing to {@code setAttachments}.
265265
*
266-
* Typically {@code attachments} is found via a call to {@see findNewAttachments}.
266+
* Typically {@code attachments} is found via a call to {@link #findNewAttachments}.
267267
*
268268
* @param attachments List of attachments to prepare.
269269
* @return Attachments prepared for inserting into attachment store.
270+
* @see #findNewAttachments
270271
*/
271-
protected static List<PreparedAttachment> prepareAttachments(String attachmentsDir,
272+
public static List<PreparedAttachment> prepareAttachments(String attachmentsDir,
272273
AttachmentStreamFactory attachmentStreamFactory,
273274
List<Attachment> attachments)
274275
throws AttachmentException {
@@ -393,7 +394,7 @@ public static void copyAttachmentsToRevision(SQLDatabase db, List<SavedAttachmen
393394
* @param newSequence identifies sequence number of revision to copy attachment data to
394395
* @param filename filename of attachment to copy
395396
*/
396-
protected static void copyAttachment(SQLDatabase db, long parentSequence, long newSequence,
397+
public static void copyAttachment(SQLDatabase db, long parentSequence, long newSequence,
397398
String filename) throws SQLException {
398399
Cursor c = null;
399400
try{
@@ -409,7 +410,7 @@ protected static void copyAttachment(SQLDatabase db, long parentSequence, long n
409410
* Called by BasicDatastore on the execution queue, this needs have the db passed ot it
410411
* @param db database to purge attachments from
411412
*/
412-
protected static void purgeAttachments(SQLDatabase db, String attachmentsDir) {
413+
public static void purgeAttachments(SQLDatabase db, String attachmentsDir) {
413414
// it's easier to deal with Strings since java doesn't know how to compare byte[]s
414415
Set<String> currentKeys = new HashSet<String>();
415416
Cursor c = null;

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/datastore/Changes.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,22 @@ public class Changes {
3535

3636
private final List<DocumentRevision> results;
3737

38-
protected Changes(long lastSequence, List<DocumentRevision> results) {
38+
/**
39+
* <p>
40+
* Construct a list of changes
41+
* </p>
42+
* <p>
43+
* Note that this constructor is for internal use. To get a set of changes from a given sequence
44+
* number, use {@link com.cloudant.sync.datastore.Datastore#changes}
45+
* </p>
46+
* @param lastSequence the last sequence number of this change set
47+
* @param results the list of {@code DocumentRevision}s in this change set
48+
*
49+
* @see com.cloudant.sync.datastore.Datastore#changes
50+
*
51+
* @api_private
52+
*/
53+
public Changes(long lastSequence, List<DocumentRevision> results) {
3954
Misc.checkNotNull(results, "Changes results");
4055
this.lastSequence = lastSequence;
4156
this.results = results;

cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/datastore/DatastoreException.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ public class DatastoreException extends Exception {
2424
public DatastoreException(){
2525

2626
}
27-
2827
public DatastoreException(String message){
2928
super(message);
3029
}
3130

32-
public DatastoreException(Exception causedBy){
31+
public DatastoreException(Throwable causedBy){
3332
super(causedBy);
3433
}
3534

36-
public DatastoreException(String message, Exception causedBy){
35+
public DatastoreException(String message, Throwable causedBy){
3736
super(message,causedBy);
3837
}
3938

0 commit comments

Comments
 (0)