/**
* Yona, 21st Century Project Hosting SW
*
* Copyright Yona & Yobi Authors & NAVER Corp.
* https://yona.io
**/
package models;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.ExpressionList;
import com.avaje.ebean.Page;
import com.avaje.ebean.RawSqlBuilder;
import models.enumeration.ProjectScope;
import models.enumeration.RequestState;
import models.enumeration.ResourceType;
import models.enumeration.RoleType;
import models.resource.GlobalResource;
import models.resource.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.tmatesoft.svn.core.SVNException;
import play.data.validation.Constraints;
import play.db.ebean.Model;
import play.db.ebean.Transactional;
import playRepository.*;
import utils.CacheStore;
import utils.FileUtil;
import utils.JodaDateUtil;
import validation.ExConstraints;
import javax.annotation.Nonnull;
import javax.persistence.*;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.*;
import static utils.CacheStore.getProjectCacheKey;
import static utils.CacheStore.projectMap;
import static utils.HttpUtil.decodeUrlString;
@Entity
public class Project extends Model implements LabelOwner {
private static final long serialVersionUID = 1L;
public static final play.db.ebean.Model.Finder find = new Finder<>(Long.class, Project.class);
private static final int DRAFT_TIME_IN_MILLIS = 1000 * 60 * 60;
@Id
public Long id;
@Constraints.Required
@Constraints.Pattern("^[a-zA-Z0-9-_\\.가-힣]+$")
@ExConstraints.Restricted({".", "..", ".git"})
public String name;
public String overview;
public String vcs;
public String siteurl;
public String owner;
public Date createdDate;
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
public Set issues;
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
public List projectUser;
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
public List posts;
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
public List milestones;
/** Project Notification */
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
public List notifications;
private long lastIssueNumber;
private long lastPostingNumber;
public boolean isCodeAccessibleMemberOnly;
@ManyToMany
public Set