Package cc.concurrent.config.server.model

Examples of cc.concurrent.config.server.model.FileCurrent


        ValidUtil.checkRegex(".{1,100}", comment, "注释的长度必须在1到100内");
        String formatXml = XmlUtil.format(xml);

        int version = 1;
        String username = FlashRequestContext.getCurrentContext().getUsername();
        FileCurrent fileCurrent = new FileCurrent(appName, fileName, version, formatXml, comment, username, new Date(), 0, null, null);
        FileHistory fileHistory = new FileHistory(appName, fileName, version, formatXml, comment, username, new Date(), false, null, null);
        fileCurrentDao.addFileCurrent(fileCurrent);
        fileHistoryDao.addFileHistory(fileHistory);
    }
View Full Code Here


        checkAppName(appName);
        ValidUtil.checkRegex("[_0-9a-zA-Z]{3,20}", fileName, "fileName需要匹配正则表达式[_0-9a-zA-Z]{3,20}");
        ValidUtil.checkRegex(".{1,100}", comment, "注释的长度必须在1到100内");
        String formatXml = XmlUtil.format(xml);

        FileCurrent oldFileCurrent = fileCurrentDao.getFileCurrent(appName, fileName);
        checkArgument(oldFileCurrent.getVersion() == version, "only latest version can update");

        String username = FlashRequestContext.getCurrentContext().getUsername();
        FileCurrent fileCurrent = new FileCurrent(appName, fileName, version + 1, formatXml, comment, username, new Date(),
                oldFileCurrent.getLastPublishVersion(), oldFileCurrent.getLastPublisher(), oldFileCurrent.getLastPublishTime());
        FileHistory fileHistory = new FileHistory(appName, fileName, version + 1, formatXml, comment, username, new Date(), false, null, null);
        fileCurrentDao.updateFileCurrent(fileCurrent);
        fileHistoryDao.addFileHistory(fileHistory);
    }
View Full Code Here

        fileHistoryDao.addFileHistory(fileHistory);
    }

    public void publishFile(String appName, String fileName, int version) {
        checkAppName(appName);
        FileCurrent fileCurrent = fileCurrentDao.getFileCurrent(appName, fileName);
        checkNotNull(fileCurrent);
        checkArgument(fileCurrent.getVersion() == version, "only latest version can update");
        FileHistory fileHistory = fileHistoryDao.getFileHistory(appName, fileName, version);
        checkNotNull(fileHistory);
        checkArgument(!fileHistory.isPublished(), "has published");

        String xml = fileHistory.getXml();
        String md5 = Md5Util.md5(xml);
        FilePublished filePublished = new FilePublished(appName, fileName, version, xml, md5);
        if (filePublishedDao.updateFilePublished(filePublished) == 0) {
            filePublishedDao.addFilePublished(filePublished);
        }

        String username = FlashRequestContext.getCurrentContext().getUsername();
        fileCurrent.setLastPublisher(username);
        fileCurrent.setLastPublishTime(new Date());
        fileCurrent.setLastPublishVersion(version);
        fileCurrentDao.updateFileCurrent(fileCurrent);
        fileHistoryDao.updatePublish(appName, fileName, version, true, username, new Date());
    }
View Full Code Here

    public FileHistory getFileHistory(String appName, String fileName, int version) {
        checkAppName(appName);
        FileHistory fileHistory = fileHistoryDao.getFileHistory(appName, fileName, version);
        checkNotNull(fileHistory, "app[%s] file[%s] version[%s] don't exsit", appName, fileName, version);

        FileCurrent fileCurrent = fileCurrentDao.getFileCurrent(appName, fileName);
        boolean isLatest = fileCurrent.getVersion() == version ? true : false;
        fileHistory.setLatest(isLatest);

        return fileHistory;
    }
View Full Code Here

        String sql = "select app_name, file_name, version, xml, comment, creator, create_time, last_publish_version, last_publisher, last_publish_time " +
                "from config_file_current where app_name=?";
        return getJdbcTemplate().query(sql, new Object[]{appName}, new RowMapper<FileCurrent>() {
            @Override
            public FileCurrent mapRow(ResultSet rs, int rowNum) throws SQLException {
                return new FileCurrent(rs.getString(1), rs.getString(2), rs.getInt(3), rs.getString(4),
                        rs.getString(5), rs.getString(6), rs.getDate(7), rs.getInt(8), rs.getString(9), rs.getDate(10));
            }
        });
    }
View Full Code Here

        String sql = "select app_name, file_name, version, xml, comment, creator, create_time, last_publish_version, last_publisher, last_publish_time " +
                "from config_file_current where app_name=? and file_name=?";
        List<FileCurrent> r = getJdbcTemplate().query(sql, new Object[]{appName, fileName}, new RowMapper<FileCurrent>() {
            @Override
            public FileCurrent mapRow(ResultSet rs, int rowNum) throws SQLException {
                return new FileCurrent(rs.getString(1), rs.getString(2), rs.getInt(3), rs.getString(4),
                        rs.getString(5), rs.getString(6), rs.getDate(7), rs.getInt(8), rs.getString(9), rs.getDate(10));
            }
        });
        return !r.isEmpty() ? r.get(0) : null;
    }
View Full Code Here

TOP

Related Classes of cc.concurrent.config.server.model.FileCurrent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.