From 7ea5676cb21f5d2c2273244c50ba60fbf22e5844 Mon Sep 17 00:00:00 2001
From: ctayeb
+ * CAS is for Check And Swap, which is an identifier that permit optimistic concurrency
+ */
@Nullable
@JsonIgnore
private Long cas;
diff --git a/src/main/java/com/github/couchmove/pojo/Status.java b/src/main/java/com/github/couchmove/pojo/Status.java
index be82d2d..9c71f43 100644
--- a/src/main/java/com/github/couchmove/pojo/Status.java
+++ b/src/main/java/com/github/couchmove/pojo/Status.java
@@ -1,10 +1,25 @@
package com.github.couchmove.pojo;
/**
- * Created by tayebchlyah on 03/06/2017.
+ * Describes the current status of a {@link ChangeLog} execution
+ *
+ * @author ctayeb
+ * Created on 03/06/2017
*/
public enum Status {
+
+ /**
+ * The {@link ChangeLog} was successfully executed
+ */
EXECUTED,
+
+ /**
+ * The {@link ChangeLog} execution has failed
+ */
FAILED,
+
+ /**
+ * The {@link ChangeLog} execution was ignored
+ */
SKIPPED
}
diff --git a/src/main/java/com/github/couchmove/pojo/Type.java b/src/main/java/com/github/couchmove/pojo/Type.java
index 0b45d60..0adeb6b 100644
--- a/src/main/java/com/github/couchmove/pojo/Type.java
+++ b/src/main/java/com/github/couchmove/pojo/Type.java
@@ -1,13 +1,30 @@
package com.github.couchmove.pojo;
+import com.couchbase.client.java.query.N1qlQuery;
+import com.couchbase.client.java.view.DesignDocument;
import lombok.Getter;
/**
- * Created by tayebchlyah on 27/05/2017.
+ * Describes the type of the {@link ChangeLog}
+ *
+ * @author ctayeb
+ * Created on 27/05/2017
*/
public enum Type {
+
+ /**
+ * json documents
+ */
DOCUMENTS(""),
+
+ /**
+ * json document representing a {@link DesignDocument}
+ */
DESIGN_DOC(Constants.JSON),
+
+ /**
+ * n1ql file containing a list of {@link N1qlQuery}
+ */
N1QL(Constants.N1QL);
@Getter
diff --git a/src/main/java/com/github/couchmove/repository/CouchbaseRepository.java b/src/main/java/com/github/couchmove/repository/CouchbaseRepository.java
index f16189e..a8049d4 100644
--- a/src/main/java/com/github/couchmove/repository/CouchbaseRepository.java
+++ b/src/main/java/com/github/couchmove/repository/CouchbaseRepository.java
@@ -1,25 +1,86 @@
package com.github.couchmove.repository;
+import com.couchbase.client.java.Bucket;
+import com.couchbase.client.java.query.N1qlQuery;
+import com.couchbase.client.java.view.DesignDocument;
import com.github.couchmove.pojo.CouchbaseEntity;
/**
- * Created by tayebchlyah on 27/05/2017.
+ * A repository for encapsulating storage, retrieval, and removal of json documents to Couchbase {@link Bucket}
+ *
+ * @param
+ * Otherwise it {@link CouchbaseRepository#save(String, CouchbaseEntity)}
+ *
+ * @param id the per-bucket unique document id
+ * @param entity entity to convert and save
+ * @return saved entity with CAS
+ * @throws com.couchbase.client.java.error.CASMismatchException if the cas of entity is different from existing one
+ * @throws com.couchbase.client.java.error.DocumentAlreadyExistsException if the cas is not set and the document exists on couchbase
+ */
E checkAndSave(String id, E entity);
+ /**
+ * Removes a {@link CouchbaseEntity} from Couchbase Bucket identified by its id
+ *
+ * @param id the id of the document to remove
+ */
void delete(String id);
+ /**
+ * Retrieves a document from Couchbase {@link Bucket} by its ID.
+ *
+ *
+ * - If the document exists, convert it to {@link CouchbaseEntity} with CAS set (Check And Swap for optimistic concurrency)
+ *
+ * {@value PREFIX_ID} + {@link ChangeLog#version}
+ *
+ * @param changeLog The ChangeLog to save
+ * @return {@link ChangeLog} entity with CAS (Check And Swap, for optimistic concurrency) set
+ */
public ChangeLog save(ChangeLog changeLog) {
return repository.save(PREFIX_ID + changeLog.getVersion(), changeLog);
}
+ /**
+ * Inserts a {@link DesignDocument} into production
+ *
+ * @param name name of the {@link DesignDocument} to insert
+ * @param content the content of the {@link DesignDocument} to insert
+ */
public void importDesignDoc(String name, String content) {
logger.info("Inserting Design Document '{}'...", name);
repository.importDesignDoc(name, content);
}
+ /**
+ * Queries Couchbase {@link Bucket} with multiple {@link N1qlQuery}
+ *
+ * @param content containing multiple {@link N1qlQuery}
+ */
public void executeN1ql(String content) {
List
+ * Exemple : 188,100,312 {@link TimeUnit#MILLISECONDS} => 2d 4h 15m 15s 312ms
+ *
+ * @param duration duration to format
+ * @param timeUnit source timeUnit
+ * @return human readable duration format
+ */
+ public static String prettyFormatDuration(long duration, TimeUnit timeUnit) {
+ StringBuffer sb = new StringBuffer();
+ duration = appendUnit(sb, duration, timeUnit, DAYS/* */, "d", timeUnit::toDays);
+ duration = appendUnit(sb, duration, timeUnit, HOURS/* */, "h", timeUnit::toHours);
+ duration = appendUnit(sb, duration, timeUnit, MINUTES/* */, "min", timeUnit::toMinutes);
+ duration = appendUnit(sb, duration, timeUnit, SECONDS/* */, "s", timeUnit::toSeconds);
+ duration = appendUnit(sb, duration, timeUnit, MILLISECONDS, "ms", timeUnit::toMillis);
+ duration = appendUnit(sb, duration, timeUnit, MICROSECONDS, "μs", timeUnit::toMicros);
+ /* */
+ appendUnit(sb, duration, timeUnit, NANOSECONDS, "ns", timeUnit::toNanos);
+ return sb.toString();
+ }
+
+ private static long appendUnit(StringBuffer sb, long duration, TimeUnit source, TimeUnit destination, String unit, Function
+ * - Otherwise it return null
+ *
+ * @param id the id of the document
+ * @return the found and converted {@link CouchbaseEntity} with CAS set, or null if absent
+ */
E findOne(String id);
+ /**
+ * Save a json document buy its ID
+ *
+ * @param id the per-bucket unique document id
+ * @param jsonContent content of the json document
+ */
void save(String id, String jsonContent);
+ /**
+ * Inserts a {@link DesignDocument} into production
+ *
+ * @param name name of the {@link DesignDocument} to insert
+ * @param jsonContent the content of the {@link DesignDocument} to insert
+ */
void importDesignDoc(String name, String jsonContent);
+ /**
+ * Queries Couchbase {@link Bucket} with a {@link N1qlQuery}
+ *
+ * @param request {@link N1qlQuery} in String format
+ */
void query(String request);
+ /**
+ * @return name of the repository Couchbase {@link Bucket}
+ */
String getBucketName();
}
diff --git a/src/main/java/com/github/couchmove/repository/CouchbaseRepositoryImpl.java b/src/main/java/com/github/couchmove/repository/CouchbaseRepositoryImpl.java
index 66d8969..7d1ea63 100644
--- a/src/main/java/com/github/couchmove/repository/CouchbaseRepositoryImpl.java
+++ b/src/main/java/com/github/couchmove/repository/CouchbaseRepositoryImpl.java
@@ -22,7 +22,8 @@
import static org.slf4j.LoggerFactory.getLogger;
/**
- * Created by tayebchlyah on 27/05/2017.
+ * @author ctayeb
+ * Created on 27/05/2017
*/
// For tests
@NoArgsConstructor(access = AccessLevel.PACKAGE, force = true)
@@ -38,13 +39,7 @@ public class CouchbaseRepositoryImpl
+ *
+ *
+ * @param content content from where the requests are extracted
+ * @return multiple requests
+ */
static List
kMJT=a%=d z*>{KeWkS6EDlr1ELdo@xnx6@{QQuPgQReyP5!5D^gsTa|?;6u)fj|Mt%FsQ_4cXK9 z7MfVejDlKuy(%f3Ut|3MCndWHGyi?WPpA$0mw7=g<L%go@3IN>{^-#k$&%p1(A zygI9(SY4Tu-v`($^OfE+wP#W!{Yw{Ex?((1rZ*Eq_IprnH&s~`V0u>6Eh}^kM-}kQ zqEt(}s4cVM$+ZJudF{e8wx>o(_A4VL?$@rCpGP5rKVJR;#_TNIdqV7Xz9erCXz4X! zpe8+v9eaec4V&0t1U!^0KKe3c2bZa?z<8Ja`r|?&MVYeAyt-LP20TX`DqOxZPQmku zCUIH^ 9wM2XY3ZsLD>Uql6BrZ$jm(v9-D*C3Yl*VYKX@a|+lK zhOiI;C){|uE> (tfWPeg z0krqUher9 N*ZksmM~l>Z5m@8Pi98;|(S4MQdP6`Sh)->-L+)cu&rl zq2rcqM~tf*snB%AAUK^`S^Xf;l<;4B)$ _`$)^ zqLi4~ilHf^2ni+?3yUHIe2Dgk(V~1farh+JVc%euk0$2fhgL@ARj*z67OPM(X)*Iy zv72}e*QLSnz$RN@L5X?`QSC65C;HRw|oiVYHqpcZ5xY>rG^Vfsg3J+g3E<9gDd7sv-EeP^NfKV=*ZJUjh* zHmp9547Zh)v+C94(6VdZQ<%doKg&E*aWZot!tz3nQzZ;JB%c2!audzbV|gGAB0S*& zn&c~6T2TMJVo#nkp_8BtR& +b!=foTuQ4eZ9=Vj-$ 4)$ha7QP*j-SDS@Jrlc8F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enV&@JV++`4we#v7A@sBM<-J@Rft0cd2R(k&Kl z6G_V1!Qmvgc?f4x4J+bP&7mh}%cZ>|A~Ae;vqOIXkt&62B0E>Ko%p0>bO?BIkw_OE zy RNd{79w+jZ?+dmn+NeF|dN8A6l?l2BOGUbQ8_sW9m@~h;o2qX)81%QiDX7KEVD> zO}9bkwfKz{#N+fp5KmJjsZyVQ!qIO-o>kdXZ=IjHClznV88PI8B_+W{c4-(+n4?Z` z$v7}W2=DgER!!;)ZZ=!?(^_PIz @hL izNKDGB zE^Kq`2#*_J7V?83!b>e`i)Jf)NAmBsQH|%xy~8`;)Pp?o3U!=6s&-SGxP64lGK`ku zSW+f-)UJbr>#CFNo4iQqaQ&?V3FNFe`GpM=>JE`}0-)!LrN^-_Ux6?f2so8`STxI% zgGgtZN{Ke}Y)|gO%7=~ANxCbICHO={9hoCXsDsjdL7ND~JQ`$`DxeUr3>`_>hEACe z9TXI`YcXUMo(A;Nt+Sc!e6uK0ekuA*SZ|qmVO`&h1^`VCYITx1Di8a(945lc_mOj6 zQiHc(*Smfp4CFkuP{1>C%A}UvgvYIzE8x;9?zU(mti*%83xO|!nWH$oo^f@a6}>`g mhJ{Fq&u1(VrN429*e+)?W(R@)s%2z`%N(@IY!hBBM*ffKl&B>D literal 0 HcmV?d00001 diff --git a/release/deploy.sh b/release/deploy.sh new file mode 100755 index 0000000..6b26d5f --- /dev/null +++ b/release/deploy.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +openssl aes-256-cbc -K $encrypted_467352795a68_key -iv $encrypted_467352795a68_iv -in release/codesigning.asc.enc -out release/codesigning.asc -d +gpg --fast-import release/codesigning.asc + +mvn deploy -P sign,build-extras -DskipTests --settings release/settings.xml \ No newline at end of file diff --git a/release/settings.xml b/release/settings.xml new file mode 100644 index 0000000..cecf892 --- /dev/null +++ b/release/settings.xml @@ -0,0 +1,22 @@ + + \ No newline at end of file From a85b48eeac413dfcf670027ec69c041ba84514bc Mon Sep 17 00:00:00 2001 From: ctayeb+ + ++ +ossrh +${env.OSSRH_JIRA_USERNAME} +${env.OSSRH_JIRA_PASSWORD} ++ ++ +ossrh ++ +true ++ +${env.GPG_KEY_NAME} +${env.GPG_PASSPHRASE} +Date: Sat, 8 Jul 2017 13:59:20 +0200 Subject: [PATCH 39/42] Fix travis sonar branch config --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd9dd58..7a15585 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,9 @@ addons: organization: "differentway-github" token: secure: "fnzS5t/buOCMWV5xx8sGOcPG+6P3LZwFuyOjOI9efm8s6uaYc2dHaKz9A45W2FB6O74pCohO8hVOh+C610fdnlES4JZ3kEy0V4/NWB9jun6w0dT+kPFRCUPmcyrS1zVZvEtlzuy2dUSPUgKfWQKnufZMex1VxghJge022+bGKbxsSYCcn0/EkOnHKN3hcP/WtjgfMQ7NrGrR+nGzZIblQRDL2bLyhx7skI7aVyo4qv93GyFGk5dIqmJtXlh+p8ylzImrJnM+V74NbRQe+YkgYZbH1VNaAzhCiSCRc8YltrAyJXJ1kLS778rIaQptLu2kn3wsZbC1dgGikg0rhy++on/cMvYWPo8LhQO7hGq31pTIblXI3+l0aU+FrKCXbpofIxbXwzBmZUOLa+StfnB9ANvsC9sn2RZ0A73U7lo/4jGY5EmjjyCze7TcyDonySyA/BrmwvDgnxKXrkAcI5jsY4bK+3Zy8pZkCYhoqilTwMsvs54m5skmLA3qv6l4tdmtNRgZD3EUnNutkjpp86gbrMa6d4k0/b2pxSjnK+MhQWKcpgXbH+Z935gTVTUcWxslu+kPXOhuH2uuiScOCCc0O/R7kPjVbFWakdjylOLFubaGKi9PmCyoYfiAcjfhFGoD7t6pXWjQdo3aRSp1d20qnioKi/c0w66hVQImiSU77Dw=" - branches: - - master - - develop + branches: + - master + - develop script: # JaCoCo is used to have code coverage, the agent has to be activated From eb0d1d862a46f53909749b900a500b3d061702a6 Mon Sep 17 00:00:00 2001 From: differentway Date: Sun, 9 Jul 2017 21:29:38 +0200 Subject: [PATCH 40/42] Update README.md Add Sonar quality gate badge --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 60d7e23..270dad3 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,5 @@ Couchmove is widely inspired from [Flyway](http://flywaydb.org) : it strongly fa Check out our [wiki](https://github.com/differentway/couchmove/wiki) - --- -[![Build Status](https://travis-ci.org/differentway/couchmove.svg?branch=develop)](https://travis-ci.org/differentway/couchmove) [![Licence](https://img.shields.io/hexpm/l/plug.svg)](https://github.com/differentway/couchmove/blob/master/LICENSE) +[![Build Status](https://travis-ci.org/differentway/couchmove.svg?branch=develop)](https://travis-ci.org/differentway/couchmove) [![Quality Gate](https://sonarcloud.io/api/badges/gate?key=com.github.differentway:couchmove:develop)](https://sonarqube.com/dashboard/index/com.github.differentway:couchmove:develop) [![Licence](https://img.shields.io/hexpm/l/plug.svg)](https://github.com/differentway/couchmove/blob/master/LICENSE) From 1d0b423d23c427c18e5c99c4c75a53f50a415852 Mon Sep 17 00:00:00 2001 From: ctayeb Date: Sun, 23 Jul 2017 16:58:34 +0200 Subject: [PATCH 41/42] Fix javadoc --- .../com/github/couchmove/repository/CouchbaseRepository.java | 3 +-- .../java/com/github/couchmove/service/ChangeLogDBService.java | 4 ++-- src/main/java/com/github/couchmove/utils/Utils.java | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/couchmove/repository/CouchbaseRepository.java b/src/main/java/com/github/couchmove/repository/CouchbaseRepository.java index a8049d4..a3f47ae 100644 --- a/src/main/java/com/github/couchmove/repository/CouchbaseRepository.java +++ b/src/main/java/com/github/couchmove/repository/CouchbaseRepository.java @@ -46,11 +46,10 @@ public interface CouchbaseRepository { /** * Retrieves a document from Couchbase {@link Bucket} by its ID. * - *
* - If the document exists, convert it to {@link CouchbaseEntity} with CAS set (Check And Swap for optimistic concurrency) *
* @param id the id of the document * @return the found and converted {@link CouchbaseEntity} with CAS set, or null if absent */ diff --git a/src/main/java/com/github/couchmove/service/ChangeLogDBService.java b/src/main/java/com/github/couchmove/service/ChangeLogDBService.java index e5af3e5..34f6013 100644 --- a/src/main/java/com/github/couchmove/service/ChangeLogDBService.java +++ b/src/main/java/com/github/couchmove/service/ChangeLogDBService.java @@ -36,10 +36,10 @@ public ChangeLogDBService(Bucket bucket) { /** * Get corresponding ChangeLogs from Couchbase bucket *
* - Otherwise it return null - * + *- *
diff --git a/src/main/java/com/github/couchmove/utils/Utils.java b/src/main/java/com/github/couchmove/utils/Utils.java index 657224a..8b4c1bd 100644 --- a/src/main/java/com/github/couchmove/utils/Utils.java +++ b/src/main/java/com/github/couchmove/utils/Utils.java @@ -56,7 +56,7 @@ private static String initializeUserName() { /** * Format duration to human readable *- if a {@link ChangeLog} doesn't exist => return it as it its + *
- if a {@link ChangeLog} doesn't exist → return it as it its *
- else : *
- *
*- if checksum ({@link ChangeLog#checksum}) is reset (set to null), or description ({@link ChangeLog#description}) updated => reset {@link ChangeLog#cas} + *
- if checksum ({@link ChangeLog#checksum}) is reset (set to null), or description ({@link ChangeLog#description}) updated → reset {@link ChangeLog#cas} *
- return database version *
- * Exemple : 188,100,312 {@link TimeUnit#MILLISECONDS} => 2d 4h 15m 15s 312ms + * Exemple : 188,100,312 {@link TimeUnit#MILLISECONDS} → 2d 4h 15m 15s 312ms * * @param duration duration to format * @param timeUnit source timeUnit From 18dec4bdeaf5ae7cd6f9452db32210cf91afd1fc Mon Sep 17 00:00:00 2001 From: ctayeb
Date: Sun, 23 Jul 2017 16:27:09 +0200 Subject: [PATCH 42/42] Bump version 1.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 410f1a4..ebbe56b 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ com.github.differentway couchmove -1.0-SNAPSHOT +1.0