mirror of https://github.com/Rekoe/rk_svnadmin
clean
parent
83e4723502
commit
af42cb1f00
|
@ -16,6 +16,7 @@ import org.nutz.mvc.Setup;
|
|||
import org.nutz.plugins.view.freemarker.FreeMarkerConfigurer;
|
||||
|
||||
import com.rekoe.domain.Pj;
|
||||
import com.rekoe.domain.ProjectConfig;
|
||||
import com.rekoe.domain.User;
|
||||
import com.rekoe.domain.Usr;
|
||||
import com.rekoe.service.UserService;
|
||||
|
@ -47,6 +48,7 @@ public class MvcSetup implements Setup {
|
|||
Daos.createTablesInPackage(dao, User.class.getPackage().getName(), false);
|
||||
Daos.migration(dao, Usr.class, true, true, false);
|
||||
Daos.migration(dao, Pj.class, true, true, false);
|
||||
Daos.migration(dao, ProjectConfig.class, true, true, false);
|
||||
if (0 == dao.count(User.class)) {
|
||||
FileSqlManager fm = new FileSqlManager("init_system_h2.sql");
|
||||
List<Sql> sqlList = fm.createCombo(fm.keys());
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.rekoe.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
|
@ -12,6 +14,8 @@ import org.nutz.dao.entity.annotation.Name;
|
|||
import org.nutz.dao.entity.annotation.Prev;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
|
||||
import com.rekoe.valueadaptor.StringJsonAdaptor;
|
||||
|
||||
@Table("project_config")
|
||||
public class ProjectConfig implements Serializable {
|
||||
|
||||
|
@ -32,6 +36,28 @@ public class ProjectConfig implements Serializable {
|
|||
@Default("http://127.0.0.1/")
|
||||
private String domainPath;
|
||||
|
||||
@Column("def_dirs")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 225, adaptor = StringJsonAdaptor.class)
|
||||
@Default("[server,client,art,design,plan]")
|
||||
@Comment("默认初始化目录")
|
||||
private List<String> dirs;
|
||||
|
||||
public List<String> getDirs() {
|
||||
if (dirs == null) {
|
||||
this.dirs = new ArrayList<>();
|
||||
}
|
||||
return dirs;
|
||||
}
|
||||
|
||||
public void setDirs(List<String> dirs) {
|
||||
this.dirs = dirs;
|
||||
}
|
||||
|
||||
public ProjectConfig addDir(String dir) {
|
||||
getDirs().add(dir);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectConfig() {
|
||||
super();
|
||||
}
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
import org.nutz.json.JsonField;
|
||||
|
||||
public class Action {
|
||||
private String type;
|
||||
private String status;
|
||||
private String currency;
|
||||
private String amount;
|
||||
@JsonField("time_created")
|
||||
private String timeCreated;
|
||||
@JsonField("time_updated")
|
||||
private String timeUpdated;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public void setCurrency(String currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public String getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(String amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getTimeCreated() {
|
||||
return timeCreated;
|
||||
}
|
||||
|
||||
public void setTimeCreated(String timeCreated) {
|
||||
this.timeCreated = timeCreated;
|
||||
}
|
||||
|
||||
public String getTimeUpdated() {
|
||||
return timeUpdated;
|
||||
}
|
||||
|
||||
public void setTimeUpdated(String timeUpdated) {
|
||||
this.timeUpdated = timeUpdated;
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
public class Application {
|
||||
|
||||
private String name;
|
||||
private String namespace;
|
||||
private String id;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
public void setNamespace(String namespace) {
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
import org.nutz.json.JsonField;
|
||||
|
||||
public class Dispute {
|
||||
|
||||
@JsonField("user_comment")
|
||||
private String userComment;
|
||||
@JsonField("time_created")
|
||||
private String timeCreated;
|
||||
@JsonField("user_email")
|
||||
private String userEmail;
|
||||
private String status;
|
||||
private String reason;
|
||||
|
||||
public String getUserComment() {
|
||||
return userComment;
|
||||
}
|
||||
|
||||
public void setUserComment(String userComment) {
|
||||
this.userComment = userComment;
|
||||
}
|
||||
|
||||
public String getTimeCreated() {
|
||||
return timeCreated;
|
||||
}
|
||||
|
||||
public void setTimeCreated(String timeCreated) {
|
||||
this.timeCreated = timeCreated;
|
||||
}
|
||||
|
||||
public String getUserEmail() {
|
||||
return userEmail;
|
||||
}
|
||||
|
||||
public void setUserEmail(String userEmail) {
|
||||
this.userEmail = userEmail;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.nutz.json.JsonField;
|
||||
|
||||
public class Entry {
|
||||
|
||||
private String id;
|
||||
private long time;
|
||||
@JsonField("changed_fields")
|
||||
private List<String> changedFields;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public List<String> getChangedFields() {
|
||||
return changedFields;
|
||||
}
|
||||
|
||||
public void setChangedFields(List<String> changedFields) {
|
||||
this.changedFields = changedFields;
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
public class Error {
|
||||
|
||||
private ErrorInfo error;
|
||||
|
||||
public ErrorInfo getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(ErrorInfo error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
public class ErrorInfo {
|
||||
|
||||
private String message;
|
||||
private String type;
|
||||
private int code;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
import com.restfb.Facebook;
|
||||
|
||||
public class FacebookRequestResult {
|
||||
|
||||
@Facebook
|
||||
private boolean success;
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
public class Items {
|
||||
|
||||
private String type;
|
||||
private String product;
|
||||
private int quantity;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
public void setProduct(String product) {
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
public int getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(int quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.nutz.json.JsonField;
|
||||
|
||||
public class Order {
|
||||
|
||||
private String id;
|
||||
private Application application;
|
||||
private PlatformUser user;
|
||||
private List<Action> actions;
|
||||
@JsonField("refundable_amount")
|
||||
private RefundableAmount refundableAmount;
|
||||
private String country;
|
||||
@JsonField("request_id")
|
||||
private String requestID;
|
||||
@JsonField("created_time")
|
||||
private String createdTime;
|
||||
@JsonField("payout_foreign_exchange_rate")
|
||||
private int payoutForeignExchangeRate;
|
||||
private List<Items> items;
|
||||
private List<Dispute> disputes;
|
||||
private int test;
|
||||
|
||||
public int getTest() {
|
||||
return test;
|
||||
}
|
||||
|
||||
public void setTest(int test) {
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
public List<Dispute> getDisputes() {
|
||||
return disputes;
|
||||
}
|
||||
|
||||
public void setDisputes(List<Dispute> disputes) {
|
||||
this.disputes = disputes;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Application getApplication() {
|
||||
return application;
|
||||
}
|
||||
|
||||
public void setApplication(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public PlatformUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(PlatformUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public List<Action> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public void setActions(List<Action> actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
public RefundableAmount getRefundableAmount() {
|
||||
return refundableAmount;
|
||||
}
|
||||
|
||||
public void setRefundableAmount(RefundableAmount refundableAmount) {
|
||||
this.refundableAmount = refundableAmount;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getRequestID() {
|
||||
return requestID;
|
||||
}
|
||||
|
||||
public void setRequestID(String requestID) {
|
||||
this.requestID = requestID;
|
||||
}
|
||||
|
||||
public String getCreatedTime() {
|
||||
return createdTime;
|
||||
}
|
||||
|
||||
public void setCreatedTime(String createdTime) {
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
public int getPayoutForeignExchangeRate() {
|
||||
return payoutForeignExchangeRate;
|
||||
}
|
||||
|
||||
public void setPayoutForeignExchangeRate(int payoutForeignExchangeRate) {
|
||||
this.payoutForeignExchangeRate = payoutForeignExchangeRate;
|
||||
}
|
||||
|
||||
public List<Items> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<Items> items) {
|
||||
this.items = items;
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.nutz.json.JsonField;
|
||||
|
||||
//{"object":"payments","entry":[{"id":"577551589029171","time":1402986080,"changed_fields":["actions"]}]}
|
||||
public class PayObject {
|
||||
|
||||
private String object;
|
||||
@JsonField("entry")
|
||||
private List<Entry> entryList;
|
||||
|
||||
public List<Entry> getEntryList() {
|
||||
return entryList;
|
||||
}
|
||||
|
||||
public void setEntryList(List<Entry> entryList) {
|
||||
this.entryList = entryList;
|
||||
}
|
||||
|
||||
public String getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
public void setObject(String object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
public class PlatformUser {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package com.rekoe.module.facebook.pay;
|
||||
|
||||
public class RefundableAmount {
|
||||
|
||||
private String currency;
|
||||
private String amount;
|
||||
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public void setCurrency(String currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public String getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(String amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
|
@ -61,6 +61,8 @@ public class ProjectService extends BaseService<Pj> {
|
|||
return num;
|
||||
}
|
||||
|
||||
@Inject
|
||||
private RepositoryService repositoryService;
|
||||
/**
|
||||
* 保存。<br>
|
||||
* 数据库里已经存在相同的路径或url的项目,不可以保存。<br>
|
||||
|
@ -115,6 +117,7 @@ public class ProjectService extends BaseService<Pj> {
|
|||
pjAuth.setRw("rw");
|
||||
pjAuth.setGr(Constants.GROUP_MANAGER);
|
||||
projectAuthService.saveByGr(pjAuth);
|
||||
repositoryService.createDir(pj);
|
||||
} else {
|
||||
dao().update(pj);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ package com.rekoe.service;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.dao.Cnd;
|
||||
|
@ -13,6 +14,7 @@ import org.nutz.ioc.loader.annotation.IocBean;
|
|||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.tmatesoft.svn.core.SVNAuthenticationException;
|
||||
import org.tmatesoft.svn.core.SVNCommitInfo;
|
||||
import org.tmatesoft.svn.core.SVNDirEntry;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.SVNProperties;
|
||||
|
@ -23,11 +25,14 @@ import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
|
|||
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
|
||||
import org.tmatesoft.svn.core.io.SVNRepository;
|
||||
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
|
||||
import org.tmatesoft.svn.core.wc.SVNClientManager;
|
||||
import org.tmatesoft.svn.core.wc.SVNCommitClient;
|
||||
import org.tmatesoft.svn.core.wc.SVNRevision;
|
||||
import org.tmatesoft.svn.core.wc.SVNWCUtil;
|
||||
|
||||
import com.rekoe.domain.Pj;
|
||||
import com.rekoe.domain.PjUsr;
|
||||
import com.rekoe.domain.ProjectConfig;
|
||||
import com.rekoe.domain.Usr;
|
||||
import com.rekoe.utils.EncryptUtil;
|
||||
import com.rekoe.utils.UsrProvider;
|
||||
|
@ -43,6 +48,7 @@ public class RepositoryService {
|
|||
*/
|
||||
private final Log LOG = Logs.get();
|
||||
|
||||
private SVNClientManager manager;
|
||||
@Inject
|
||||
private ProjectService projectService;
|
||||
|
||||
|
@ -127,6 +133,68 @@ public class RepositoryService {
|
|||
return repository;
|
||||
}
|
||||
|
||||
@Inject
|
||||
private ProjectConfigService projectConfigService;
|
||||
|
||||
public String getProjectSVNUrl(Pj pj) {
|
||||
ProjectConfig conf = projectConfigService.get();
|
||||
String svnurl = conf.getDomainPath() + pj.getPj();
|
||||
return parseURL(svnurl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建初始化的文件夹
|
||||
*
|
||||
* @param pj
|
||||
* @throws SVNException
|
||||
*/
|
||||
public synchronized void createDir(Pj pj) {
|
||||
Usr usr = UsrProvider.getCurrentUsr();
|
||||
String svnUrl = getProjectSVNUrl(pj);
|
||||
if (StringUtils.isBlank(svnUrl)) {
|
||||
throw new RuntimeException("URL不可以为空");
|
||||
}
|
||||
String svnUserName = usr.getUsr();
|
||||
String svnPassword = usr.getPsw();
|
||||
if (!com.rekoe.utils.Constants.HTTP_MUTIL.equals(pj.getType())) {
|
||||
// pj_usr覆盖用户的密码
|
||||
PjUsr pjUsr = projectUserService.get(pj.getPj(), svnUserName);
|
||||
if (pjUsr != null) {
|
||||
svnPassword = pjUsr.getPsw();
|
||||
}
|
||||
}
|
||||
svnPassword = EncryptUtil.decrypt(svnPassword);// 解密
|
||||
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(svnUserName, svnPassword);
|
||||
this.manager.setAuthenticationManager(authManager);
|
||||
boolean makeParents = true;
|
||||
String commitMessage = "mkdir by Rekoe";
|
||||
ProjectConfig conf = projectConfigService.get();
|
||||
List<String> dirs = conf.getDirs();
|
||||
SVNURL[] urlAr = new SVNURL[dirs.size()];
|
||||
int i = 0;
|
||||
for (String url : dirs) {
|
||||
try {
|
||||
urlAr[i] = SVNURL.parseURIEncoded(url);
|
||||
} catch (SVNException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
SVNCommitClient commitClient = SVNClientManager.newInstance().getCommitClient();
|
||||
try {
|
||||
SVNCommitInfo info = commitClient.doMkDir(urlAr, commitMessage, null, makeParents);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
long newRevision = info.getNewRevision();
|
||||
if (newRevision >= 0)
|
||||
LOG.debug("commit successful: new revision = " + newRevision);
|
||||
else
|
||||
LOG.debug("no commits performed (commit operation returned new revision < 0)");
|
||||
}
|
||||
} catch (SVNException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回项目仓库的根
|
||||
*
|
||||
|
@ -219,6 +287,8 @@ public class RepositoryService {
|
|||
* For using over file:///
|
||||
*/
|
||||
FSRepositoryFactory.setup();
|
||||
|
||||
this.manager = SVNClientManager.newInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue