// Path: src/de/neuland/firefly/migration/LockRepository.java
// @Repository
// @Scope("prototype")
// public class LockRepository {
//     @Autowired private ModelService modelService;
//     @Autowired private FlexibleSearchService searchService;
// 
//     public FireflyLockModel findByPk(PK pk) {
//         return modelService.get(pk);
//     }
// 
//     public FireflyLockModel create() {
//         return modelService.create(FireflyLockModel.class);
//     }
// 
//     public Optional<FireflyLockModel> findLock() {
//         final FlexibleSearchQuery query = new FlexibleSearchQuery(
//                         "SELECT {" + FireflyLockModel.PK + "} " +
//                         "FROM {" + FireflyLockModel._TYPECODE + "}");
//         try {
//             return Optional.fromNullable((FireflyLockModel) searchService.searchUnique(query));
//         } catch (ModelNotFoundException e) {
//             return Optional.absent();
//         } catch (AmbiguousIdentifierException e) {
//             throw new RuntimeException("Found more than one lock.", e);
//         }
//     }
// 
//     public void save(FireflyLockModel lock) {
//         modelService.save(lock);
//     }
// 
//     public void remove(FireflyLockModel lock) {
//         modelService.remove(lock);
//     }
// }
// 
// Path: web/src/de/neuland/firefly/rest/v1/model/Lock.java
// @XmlRootElement
// @XmlAccessorType(XmlAccessType.FIELD)
// public class Lock implements Serializable {
//     private final Date creationDate;
//     private final long clusterNode;
// 
//     public Lock() {
//         this(null,
//              -1);
//     }
// 
//     public Lock(Date creationDate,
//                 long clusterNode) {
//         this.creationDate = creationDate;
//         this.clusterNode = clusterNode;
//     }
// 
//     public Date getCreationDate() {
//         return creationDate;
//     }
// 
//     public long getClusterNode() {
//         return clusterNode;
//     }
// 
//     @Override public boolean equals(Object o) {
//         if (this == o)
//             return true;
// 
//         if (!(o instanceof Lock))
//             return false;
// 
//         Lock lock = (Lock) o;
// 
//         return new EqualsBuilder()
//                         .append(getClusterNode(), lock.getClusterNode())
//                         .append(getCreationDate(), lock.getCreationDate())
//                         .isEquals();
//     }
// 
//     @Override public int hashCode() {
//         return new HashCodeBuilder(17, 37)
//                         .append(getCreationDate())
//                         .append(getClusterNode())
//                         .toHashCode();
//     }
// 
//     @Override public String toString() {
//         return new ToStringBuilder(this)
//                         .append("creationDate", creationDate)
//                         .append("clusterNode", clusterNode)
//                         .toString();
//     }
// }


import com.google.common.base.Optional;
import de.hybris.platform.core.Registry;
import de.neuland.firefly.migration.LockRepository;
import de.neuland.firefly.model.FireflyLockModel;
import de.neuland.firefly.rest.v1.model.Lock;
import org.springframework.stereotype.Controller;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static javax.ws.rs.core.Response.Status.NO_CONTENT;
import static javax.ws.rs.core.Response.Status.OK;
package de.neuland.firefly.rest.v1;





@Controller("lockController-v1")
@Path("/v1/lock")
public class LockController {
    @GET
    @Produces(APPLICATION_JSON)
    public Response getLock() {
        Optional<FireflyLockModel> maybeLock = getLockRepository().findLock();

        if (maybeLock.isPresent()) {
            FireflyLockModel lock = maybeLock.get();
            Lock result = new Lock(lock.getCreationtime(),
                                   lock.getClusterNode());

            return Response.status(OK)
                           .entity(result)
                           .build();
        } else {
            return Response.status(NOT_FOUND)
                           .build();
        }
    }

    @DELETE
    public Response removeLock() {
// Path: src/de/neuland/firefly/migration/LockRepository.java
// @Repository
// @Scope("prototype")
// public class LockRepository {
//     @Autowired private ModelService modelService;
//     @Autowired private FlexibleSearchService searchService;
// 
//     public FireflyLockModel findByPk(PK pk) {
//         return modelService.get(pk);
//     }
// 
//     public FireflyLockModel create() {
//         return modelService.create(FireflyLockModel.class);
//     }
// 
//     public Optional<FireflyLockModel> findLock() {
//         final FlexibleSearchQuery query = new FlexibleSearchQuery(
//                         "SELECT {" + FireflyLockModel.PK + "} " +
//                         "FROM {" + FireflyLockModel._TYPECODE + "}");
//         try {
//             return Optional.fromNullable((FireflyLockModel) searchService.searchUnique(query));
//         } catch (ModelNotFoundException e) {
//             return Optional.absent();
//         } catch (AmbiguousIdentifierException e) {
//             throw new RuntimeException("Found more than one lock.", e);
//         }
//     }
// 
//     public void save(FireflyLockModel lock) {
//         modelService.save(lock);
//     }
// 
//     public void remove(FireflyLockModel lock) {
//         modelService.remove(lock);
//     }
// }
// 
// Path: web/src/de/neuland/firefly/rest/v1/model/Lock.java
// @XmlRootElement
// @XmlAccessorType(XmlAccessType.FIELD)
// public class Lock implements Serializable {
//     private final Date creationDate;
//     private final long clusterNode;
// 
//     public Lock() {
//         this(null,
//              -1);
//     }
// 
//     public Lock(Date creationDate,
//                 long clusterNode) {
//         this.creationDate = creationDate;
//         this.clusterNode = clusterNode;
//     }
// 
//     public Date getCreationDate() {
//         return creationDate;
//     }
// 
//     public long getClusterNode() {
//         return clusterNode;
//     }
// 
//     @Override public boolean equals(Object o) {
//         if (this == o)
//             return true;
// 
//         if (!(o instanceof Lock))
//             return false;
// 
//         Lock lock = (Lock) o;
// 
//         return new EqualsBuilder()
//                         .append(getClusterNode(), lock.getClusterNode())
//                         .append(getCreationDate(), lock.getCreationDate())
//                         .isEquals();
//     }
// 
//     @Override public int hashCode() {
//         return new HashCodeBuilder(17, 37)
//                         .append(getCreationDate())
//                         .append(getClusterNode())
//                         .toHashCode();
//     }
// 
//     @Override public String toString() {
//         return new ToStringBuilder(this)
//                         .append("creationDate", creationDate)
//                         .append("clusterNode", clusterNode)
//                         .toString();
//     }
// }


// Path: web/src/de/neuland/firefly/rest/v1/LockController.java
import com.google.common.base.Optional;
import de.hybris.platform.core.Registry;
import de.neuland.firefly.migration.LockRepository;
import de.neuland.firefly.model.FireflyLockModel;
import de.neuland.firefly.rest.v1.model.Lock;
import org.springframework.stereotype.Controller;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static javax.ws.rs.core.Response.Status.NO_CONTENT;
import static javax.ws.rs.core.Response.Status.OK;

package de.neuland.firefly.rest.v1;





@Controller("lockController-v1")
@Path("/v1/lock")
public class LockController {
    @GET
    @Produces(APPLICATION_JSON)
    public Response getLock() {
        Optional<FireflyLockModel> maybeLock = getLockRepository().findLock();

        if (maybeLock.isPresent()) {
            FireflyLockModel lock = maybeLock.get();
            Lock result = new Lock(lock.getCreationtime(),
                                   lock.getClusterNode());

            return Response.status(OK)
                           .entity(result)
                           .build();
        } else {
            return Response.status(NOT_FOUND)
                           .build();
        }
    }

    @DELETE
    public Response removeLock() {
        LockRepository lockRepository = getLockRepository();