Search in sources :

Example 6 with JpomRuntimeException

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);
}
Also used : InputStream(java.io.InputStream) JpomRuntimeException(io.jpom.system.JpomRuntimeException) File(java.io.File)

Example 7 with JpomRuntimeException

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);
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JpomRuntimeException(io.jpom.system.JpomRuntimeException)

Example 8 with JpomRuntimeException

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);
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JpomRuntimeException(io.jpom.system.JpomRuntimeException)

Example 9 with JpomRuntimeException

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);
    }
}
Also used : JpomRuntimeException(io.jpom.system.JpomRuntimeException)

Example 10 with JpomRuntimeException

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);
    }
}
Also used : NodeModel(io.jpom.model.data.NodeModel) NodeService(io.jpom.service.node.NodeService) JpomRuntimeException(io.jpom.system.JpomRuntimeException) AfterOpt(io.jpom.model.AfterOpt) File(java.io.File)

Aggregations

JpomRuntimeException (io.jpom.system.JpomRuntimeException)16 JSONObject (com.alibaba.fastjson.JSONObject)7 File (java.io.File)6 InputStream (java.io.InputStream)4 BetweenFormatter (cn.hutool.core.date.BetweenFormatter)2 DateUtil (cn.hutool.core.date.DateUtil)2 FileUtil (cn.hutool.core.io.FileUtil)2 LineHandler (cn.hutool.core.io.LineHandler)2 Tuple (cn.hutool.core.lang.Tuple)2 SecureUtil (cn.hutool.crypto.SecureUtil)2 Db (cn.hutool.db.Db)2 JsonMessage (cn.jiangzeyin.common.JsonMessage)2 JSON (com.alibaba.fastjson.JSON)2 AfterOpt (io.jpom.model.AfterOpt)2 NodeModel (io.jpom.model.data.NodeModel)2 JarFile (java.util.jar.JarFile)2 ZipFile (java.util.zip.ZipFile)2 JdbcSQLNonTransientException (org.h2.jdbc.JdbcSQLNonTransientException)2 CollUtil (cn.hutool.core.collection.CollUtil)1 Convert (cn.hutool.core.convert.Convert)1