use of io.jpom.system.JpomRuntimeException in project Jpom by dromara.
the class TomcatInfoModel method initTomcat.
/**
* 初始化
*/
public void initTomcat() {
String tomcatPath = pathAndCheck();
String appBase = getAppBase();
if (StrUtil.isEmpty(appBase) || StrUtil.SLASH.equals(appBase)) {
File webapps = FileUtil.file(tomcatPath, "webapps");
setAppBase(webapps.getAbsolutePath());
} else {
String path = FileUtil.normalize(appBase);
if (FileUtil.isAbsolutePath(path)) {
// appBase如:/project/、D:/project/
setAppBase(path);
} else {
// appBase填写的是对相路径如:project/dir
File webapps = FileUtil.file(tomcatPath, path);
setAppBase(webapps.getAbsolutePath());
}
}
InputStream inputStream = ResourceUtil.getStream("classpath:/bin/jpomAgent.zip");
if (inputStream == null) {
throw new JpomRuntimeException("jpomAgent.zip不存在");
}
// 解压代理工具到tomcat的appBase目录下
ZipUtil.unzip(inputStream, new File(getAppBase()), CharsetUtil.CHARSET_UTF_8);
}
use of io.jpom.system.JpomRuntimeException in project Jpom by dromara.
the class BaseDataService method saveJson.
/**
* 保存json对象
*
* @param filename 文件名
* @param json json数据
*/
protected void saveJson(String filename, BaseModel json) {
String key = json.getId();
// 读取文件,如果存在记录,则抛出异常
JSONObject allData;
JSONObject data = null;
allData = getJSONObject(filename);
if (allData != null) {
data = allData.getJSONObject(key);
} else {
allData = new JSONObject();
}
// 判断是否存在数据
if (null != data && 0 < data.keySet().size()) {
throw new JpomRuntimeException("数据Id已经存在啦:" + filename + " :" + key);
} else {
allData.put(key, json.toJson());
JsonFileUtil.saveJson(getDataFilePath(filename), allData);
}
}
use of io.jpom.system.JpomRuntimeException in project Jpom by dromara.
the class BaseDataService method updateJson.
/**
* 修改json对象
*
* @param filename 文件名
* @param json json数据
*/
protected void updateJson(String filename, BaseModel json) {
String key = json.getId();
// 读取文件,如果不存在记录,则抛出异常
JSONObject allData = getJSONObject(filename);
JSONObject data = allData.getJSONObject(key);
// 判断是否存在数据
if (null == data || 0 == data.keySet().size()) {
throw new JpomRuntimeException("数据不存在:" + key);
} else {
allData.put(key, json.toJson());
JsonFileUtil.saveJson(getDataFilePath(filename), allData);
}
}
use of io.jpom.system.JpomRuntimeException in project Jpom by dromara.
the class SvnKitUtil method checkOut.
private static String checkOut(SVNClientManager ourClientManager, String url, File targetPath) throws SVNException {
// 通过客户端管理类获得updateClient类的实例。
SVNUpdateClient updateClient = ourClientManager.getUpdateClient();
updateClient.setIgnoreExternals(false);
// 相关变量赋值
SVNURL svnurl = SVNURL.parseURIEncoded(url);
try {
// 要把版本库的内容check out到的目录
long workingVersion = updateClient.doCheckout(svnurl, targetPath, SVNRevision.HEAD, SVNRevision.HEAD, SVNDepth.INFINITY, true);
return String.format("把版本:%s check out ", workingVersion);
} catch (SVNAuthenticationException s) {
throw new JpomRuntimeException("账号密码不正确", s);
}
}
use of io.jpom.system.JpomRuntimeException in project Jpom by dromara.
the class ReleaseManage method doProject.
/**
* 发布项目
*/
private void doProject() {
// AfterOpt afterOpt, boolean clearOld, boolean diffSync
AfterOpt afterOpt = BaseEnum.getEnum(AfterOpt.class, this.buildExtraModule.getAfterOpt(), AfterOpt.No);
boolean clearOld = this.buildExtraModule.isClearOld();
boolean diffSync = this.buildExtraModule.isDiffSync();
String releaseMethodDataId = this.buildExtraModule.getReleaseMethodDataId();
String[] strings = StrUtil.splitToArray(releaseMethodDataId, CharPool.COLON);
if (ArrayUtil.length(strings) != 2) {
throw new IllegalArgumentException(releaseMethodDataId + " error");
}
NodeService nodeService = SpringUtil.getBean(NodeService.class);
NodeModel nodeModel = nodeService.getByKey(strings[0]);
Objects.requireNonNull(nodeModel, "节点不存在");
String projectId = strings[1];
if (diffSync) {
this.diffSyncProject(nodeModel, projectId, afterOpt, clearOld);
return;
}
File zipFile = BuildUtil.isDirPackage(this.resultFile);
boolean unZip = true;
if (zipFile == null) {
zipFile = this.resultFile;
unZip = false;
}
JsonMessage<String> jsonMessage = OutGivingRun.fileUpload(zipFile, null, projectId, unZip, afterOpt, nodeModel, this.userModel, clearOld);
if (jsonMessage.getCode() == HttpStatus.HTTP_OK) {
logRecorder.info("发布项目包成功:" + jsonMessage);
} else {
throw new JpomRuntimeException("发布项目包失败:" + jsonMessage);
}
}
Aggregations