Skip to content

Commit

Permalink
Merge pull request #56 from cloudogu/feature/50_file_history
Browse files Browse the repository at this point in the history
Feature/50 file history
  • Loading branch information
pfeuffer authored May 15, 2018
2 parents d2b04b9 + db41626 commit af31223
Show file tree
Hide file tree
Showing 54 changed files with 1,667 additions and 164 deletions.
56 changes: 54 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"fs-extra": "3.0.1",
"html-webpack-plugin": "2.29.0",
"jest": "20.0.4",
"jest-cli": "20.0.4",
"jest-junit-reporter": "^1.1.0",
"postcss-flexbugs-fixes": "3.2.0",
"postcss-loader": "2.0.8",
Expand Down
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,20 @@
<!-- Don't ship this dependency with the app -->
<optional>true</optional>
</dependency>

<!-- testing -->
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.7.1</version>
<scope>test</scope>
</dependency>
</dependencies>


Expand Down
24 changes: 23 additions & 1 deletion src/main/java/com/cloudogu/smeagol/wiki/domain/CommitId.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;

import java.io.Serializable;
import java.util.Objects;

/**
* The id of a commit in a source code management system.
*/
public final class CommitId {
public final class CommitId implements Serializable {

private static final long serialVersionUID = 1L;

private final String value;

Expand Down Expand Up @@ -34,4 +39,21 @@ public static CommitId valueOf(String value) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(value), "commit id is null or empty");
return new CommitId(value);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CommitId commitId = (CommitId) o;
return Objects.equals(value, commitId.getValue());
}

@Override
public int hashCode() {
return Objects.hash(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.cloudogu.smeagol.wiki.domain;

/**
* CommitRepository supplies the commits of a wiki.
*/
@SuppressWarnings("squid:S1609") // ignore functional interface warning
public interface CommitRepository {
/**
* Find the commits to a given path for a wiki.
*
* @param id id of wiki
* @param path search path
*
* @return History which contains the list of commits
*/
History findHistoryByWikiIdAndPath(WikiId id, Path path);
}
28 changes: 28 additions & 0 deletions src/main/java/com/cloudogu/smeagol/wiki/domain/History.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.cloudogu.smeagol.wiki.domain;

import java.util.List;

public class History {

private final WikiId wikiId;
private final Path path;
private final List<Commit> commits;

public History(WikiId wikiId, Path path, List<Commit> commits) {
this.wikiId = wikiId;
this.path = path;
this.commits = commits;
}

public WikiId getWikiId() {
return wikiId;
}

public Path getPath() {
return path;
}

public List<Commit> getCommits() {
return commits;
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/cloudogu/smeagol/wiki/domain/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public Optional<Commit> getCommit() {
return Optional.ofNullable(commit);
}

public void setCommit(Commit commit) {
this.commit = commit;
}

public Optional<Path> getOldPath() {
return Optional.ofNullable(oldPath);
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/cloudogu/smeagol/wiki/domain/PageRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ public interface PageRepository {
*/
Optional<Page> findByWikiIdAndPath(WikiId wikiId, Path path);

/**
* Find the page with the given path and commitId in the requested wiki.
*
* @param wikiId id of the wiki
* @param path path of the page
* @param commitId id of the commit
*
* @return page with path
*/
Optional<Page> findByWikiIdAndPathAndCommit(WikiId wikiId, Path path, CommitId commitId);

/**
* Deletes the page.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@

public class CommitResource extends ResourceSupport {

private AuthorResource author;
private String date;
private String message;
private final String commitId;
private final AuthorResource author;
private final String date;
private final String message;

public CommitResource(AuthorResource author, String date, String message) {
public CommitResource(String id, AuthorResource author, String date, String message) {
this.commitId = id;
this.author = author;
this.date = date;
this.message = message;
}

public String getCommitId() {
return commitId;
}

public AuthorResource getAuthor() {
return author;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.cloudogu.smeagol.wiki.infrastructure;

import com.cloudogu.smeagol.wiki.domain.Commit;

public class CommitResourceAssembler {
public CommitResource toResource(Commit commit) {
return new CommitResource(commit.getId().get().getValue(),
new AuthorResource(commit.getAuthor().getDisplayName().toString(),
commit.getAuthor().getEmail().toString()),
commit.getDate().toString(), commit.getMessage().toString());
}
}
Loading

0 comments on commit af31223

Please sign in to comment.