// Path: src/main/java/com/maxdemarzi/Labels.java
// public enum Labels implements Label {
//     User,
//     Post,
//     Tag
// }
// 
// Path: src/main/java/com/maxdemarzi/RelationshipTypes.java
// public enum  RelationshipTypes implements RelationshipType {
//     BLOCKS,
//     FOLLOWS,
//     MUTES,
//     LIKES,
//     REPLIED_TO
// }
// 
// Path: src/main/java/com/maxdemarzi/posts/PostExceptions.java
// public class PostExceptions extends Exceptions {
// 
//     public static final Exceptions missingStatusParameter() {
//         return new Exceptions(400, "Missing status Parameter.");
//     }
//     public static final Exceptions emptyStatusParameter() {
//         return new Exceptions(400, "Empty status Parameter.");
//     }
//     public static final Exceptions postNotFound() {
//         return new Exceptions(400, "Post not Found.");
//     }
//     public static final Exceptions postAlreadyReposted() {
//         return new Exceptions(400, "Post already Reposted.");
//     }
// 
//     private PostExceptions(int code, String error) {
//         super(code, error);
//     }
// }
// 
// Path: src/main/java/com/maxdemarzi/Properties.java
// public final class Properties {
// 
//     private Properties() {
//         throw new IllegalAccessError("Utility class");
//     }
// 
//     public static final String COUNT = "count";
//     public static final String EMAIL = "email";
//     public static final String FOLLOWERS_YOU_KNOW = "followers_you_know";
//     public static final String FOLLOWERS_YOU_KNOW_COUNT = "followers_you_know_count";
//     public static final String HASH = "hash";
//     public static final String I_FOLLOW = "i_follow";
//     public static final String FOLLOWS_ME = "follows_me";
//     public static final String LIKES = "likes";
//     public static final String LIKED = "liked";
//     public static final String LIKED_TIME = "liked_time";
//     public static final String NAME = "name";
//     public static final String PASSWORD = "password";
//     public static final String USERNAME = "username";
//     public static final String REPOSTS = "reposts";
//     public static final String REPOSTED = "reposted";
//     public static final String REPOSTED_TIME = "reposted_time";
//     public static final String REPOSTER_NAME = "reposter_name";
//     public static final String REPOSTER_USERNAME = "reposter_username";
//     public static final String STATUS = "status";
//     public static final String TIME = "time";
// 
// }
// 
// Path: src/main/java/com/maxdemarzi/Time.java
// public static final DateTimeFormatter dateFormatter = DateTimeFormatter
//         .ofPattern("yyyy_MM_dd")
//         .withZone(utc);
// 
// Path: src/main/java/com/maxdemarzi/Time.java
// public static final ZoneId utc = TimeZone.getTimeZone("UTC").toZoneId();


import com.fasterxml.jackson.databind.ObjectMapper;
import com.maxdemarzi.Labels;
import com.maxdemarzi.RelationshipTypes;
import com.maxdemarzi.posts.PostExceptions;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.neo4j.dbms.api.DatabaseManagementService;
import org.neo4j.graphdb.*;
import javax.ws.rs.Path;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.temporal.ChronoUnit;
import java.util.*;
import static com.maxdemarzi.Properties.*;
import static com.maxdemarzi.Time.dateFormatter;
import static com.maxdemarzi.Time.utc;
import static java.util.Collections.reverseOrder;
    @Path("/{username}/follows/{username2}")
    public Response removeFollows(@PathParam("username") final String username,
                                  @PathParam("username2") final String username2) throws IOException {
        Map<String, Object> results;
        try (Transaction tx = db.beginTx()) {
            Node user = findUser(username, tx);
            Node user2 = findUser(username2, tx);

            if (user.getDegree(RelationshipTypes.FOLLOWS, Direction.OUTGOING)
                    < user2.getDegree(RelationshipTypes.FOLLOWS, Direction.INCOMING)) {
                for (Relationship r1: user.getRelationships(Direction.OUTGOING, RelationshipTypes.FOLLOWS) ) {
                    if (r1.getEndNode().equals(user2)) {
                        r1.delete();
                    }
                }
            } else {
                for (Relationship r1 : user2.getRelationships(Direction.INCOMING, RelationshipTypes.FOLLOWS)) {
                    if (r1.getStartNode().equals(user)) {
                        r1.delete();
                    }
                }
            }

            tx.commit();
        }
        return Response.noContent().build();
    }

    public static Node findUser(String username, Transaction tx) {
        if (username == null) { return null; }
// Path: src/main/java/com/maxdemarzi/Labels.java
// public enum Labels implements Label {
//     User,
//     Post,
//     Tag
// }
// 
// Path: src/main/java/com/maxdemarzi/RelationshipTypes.java
// public enum  RelationshipTypes implements RelationshipType {
//     BLOCKS,
//     FOLLOWS,
//     MUTES,
//     LIKES,
//     REPLIED_TO
// }
// 
// Path: src/main/java/com/maxdemarzi/posts/PostExceptions.java
// public class PostExceptions extends Exceptions {
// 
//     public static final Exceptions missingStatusParameter() {
//         return new Exceptions(400, "Missing status Parameter.");
//     }
//     public static final Exceptions emptyStatusParameter() {
//         return new Exceptions(400, "Empty status Parameter.");
//     }
//     public static final Exceptions postNotFound() {
//         return new Exceptions(400, "Post not Found.");
//     }
//     public static final Exceptions postAlreadyReposted() {
//         return new Exceptions(400, "Post already Reposted.");
//     }
// 
//     private PostExceptions(int code, String error) {
//         super(code, error);
//     }
// }
// 
// Path: src/main/java/com/maxdemarzi/Properties.java
// public final class Properties {
// 
//     private Properties() {
//         throw new IllegalAccessError("Utility class");
//     }
// 
//     public static final String COUNT = "count";
//     public static final String EMAIL = "email";
//     public static final String FOLLOWERS_YOU_KNOW = "followers_you_know";
//     public static final String FOLLOWERS_YOU_KNOW_COUNT = "followers_you_know_count";
//     public static final String HASH = "hash";
//     public static final String I_FOLLOW = "i_follow";
//     public static final String FOLLOWS_ME = "follows_me";
//     public static final String LIKES = "likes";
//     public static final String LIKED = "liked";
//     public static final String LIKED_TIME = "liked_time";
//     public static final String NAME = "name";
//     public static final String PASSWORD = "password";
//     public static final String USERNAME = "username";
//     public static final String REPOSTS = "reposts";
//     public static final String REPOSTED = "reposted";
//     public static final String REPOSTED_TIME = "reposted_time";
//     public static final String REPOSTER_NAME = "reposter_name";
//     public static final String REPOSTER_USERNAME = "reposter_username";
//     public static final String STATUS = "status";
//     public static final String TIME = "time";
// 
// }
// 
// Path: src/main/java/com/maxdemarzi/Time.java
// public static final DateTimeFormatter dateFormatter = DateTimeFormatter
//         .ofPattern("yyyy_MM_dd")
//         .withZone(utc);
// 
// Path: src/main/java/com/maxdemarzi/Time.java
// public static final ZoneId utc = TimeZone.getTimeZone("UTC").toZoneId();


// Path: src/main/java/com/maxdemarzi/users/Users.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.maxdemarzi.Labels;
import com.maxdemarzi.RelationshipTypes;
import com.maxdemarzi.posts.PostExceptions;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.neo4j.dbms.api.DatabaseManagementService;
import org.neo4j.graphdb.*;
import javax.ws.rs.Path;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.temporal.ChronoUnit;
import java.util.*;
import static com.maxdemarzi.Properties.*;
import static com.maxdemarzi.Time.dateFormatter;
import static com.maxdemarzi.Time.utc;
import static java.util.Collections.reverseOrder;

    @Path("/{username}/follows/{username2}")
    public Response removeFollows(@PathParam("username") final String username,
                                  @PathParam("username2") final String username2) throws IOException {
        Map<String, Object> results;
        try (Transaction tx = db.beginTx()) {
            Node user = findUser(username, tx);
            Node user2 = findUser(username2, tx);

            if (user.getDegree(RelationshipTypes.FOLLOWS, Direction.OUTGOING)
                    < user2.getDegree(RelationshipTypes.FOLLOWS, Direction.INCOMING)) {
                for (Relationship r1: user.getRelationships(Direction.OUTGOING, RelationshipTypes.FOLLOWS) ) {
                    if (r1.getEndNode().equals(user2)) {
                        r1.delete();
                    }
                }
            } else {
                for (Relationship r1 : user2.getRelationships(Direction.INCOMING, RelationshipTypes.FOLLOWS)) {
                    if (r1.getStartNode().equals(user)) {
                        r1.delete();
                    }
                }
            }

            tx.commit();
        }
        return Response.noContent().build();
    }

    public static Node findUser(String username, Transaction tx) {
        if (username == null) { return null; }
        Node user = tx.findNode(Labels.User, USERNAME, username);