Skip to content

The Unified and Autonomous Development Platform

Database backup

robin shine333726d7e850
diff --git a/commons.all/pom.xml b/commons.all/pom.xml
index 24f451e50a..002ddd9f50 100644
--- a/commons.all/pom.xml
+++ b/commons.all/pom.xml
@@ -32,6 +32,7 @@
<module>../commons.schedule</module>
<module>../commons.markdown</module>
+
<module>../gitplex.search</module>
<module>../commons.antlr</module>
</modules>
diff --git a/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/BootstrapUtils.java b/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/BootstrapUtils.java
index 65f0e4029b..00f2c72a92 100644
--- a/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/BootstrapUtils.java
+++ b/commons.bootstrap/src/main/java/com/pmease/commons/bootstrap/BootstrapUtils.java
@@ -8,8 +8,11 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
+import java.io.OutputStream;
+import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
public class BootstrapUtils {
@@ -64,7 +67,64 @@ public class BootstrapUtils {
}
}
- /**
+ /**
+ * Zip specified directory recursively as specified file.
+ * @param dir
+ * @param file
+ */
+ public static void zip(File dir, File file) {
+ try (OutputStream os = new FileOutputStream(file)) {
+ zip(dir, os);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ };
+ }
+
+ /**
+ * Zip specified directory recursively as specified file.
+ * @param dir
+ * @param file
+ */
+ public static void zip(File dir, OutputStream os) {
+ try (ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(os, BUFFER_SIZE))) {
+ zos.setLevel(Deflater.DEFAULT_COMPRESSION);
+ zip(zos, dir, "");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static void zip(ZipOutputStream zos, File dir, String basePath) {
+ byte buffer[] = new byte[BUFFER_SIZE];
+
+ try {
+ if (basePath.length() != 0)
+ zos.putNextEntry(new ZipEntry(basePath + "/"));
+
+ for (File file: dir.listFiles()) {
+ if (file.isDirectory()) {
+ if (basePath.length() != 0)
+ zip(zos, file, basePath + "/" + file.getName());
+ else
+ zip(zos, file, file.getName());
+ } else {
+ try (FileInputStream is = new FileInputStream(file)) {
+ if (basePath.length() != 0)
+ zos.putNextEntry(new ZipEntry(basePath + "/" + file.getName()));
+ else
+ zos.putNextEntry(new ZipEntry(file.getName()));
+ int len;
+ while ((len = is.read(buffer)) > 0)
+ zos.write(buffer, 0, len);
+ }
+ }
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
* Unzip files matching specified matcher from specified file to specified directory.
*
* @param srcFile
diff --git a/commons.hibernate/pom.xml b/commons.hibernate/pom.xml
index 66eb8c0775..cd6d747d03 100644
--- a/commons.hibernate/pom.xml
+++ b/commons.hibernate/pom.xml
@@ -33,6 +33,12 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernateVersion}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
@@ -43,6 +49,12 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernateVersion}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
@@ -104,6 +116,16 @@
<artifactId>commons.jetty</artifactId>
<version>1.0.31</version>
</dependency>
+ <dependency>
+ <groupId>org.dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.4.9</version>
+ </dependency>
</dependencies>
<repositories>
<repository>
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/DefaultPersistManager.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/DefaultPersistManager.java
new file mode 100644
index 0000000000..202b8df02c
--- /dev/null
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/DefaultPersistManager.java
@@ -0,0 +1,592 @@
+package com.pmease.commons.hibernate;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.inject.Named;
+import javax.persistence.ManyToOne;
+
+import org.apache.commons.io.IOUtils;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+import org.dom4j.io.XPP3Reader;
+import org.hibernate.Criteria;
+import org.hibernate.Interceptor;
+import org.hibernate.Query;
+import org.hibernate.ReplicationMode;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.boot.Metadata;
+import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.model.naming.Identifier;
+import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
+import org.hibernate.boot.registry.StandardServiceRegistry;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Projections;
+import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.hibernate.tool.schema.TargetType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.commons.hibernate.migration.MigrationHelper;
+import com.pmease.commons.hibernate.migration.Migrator;
+import com.pmease.commons.hibernate.migration.VersionTable;
+import com.pmease.commons.hibernate.migration.VersionedDocument;
+import com.pmease.commons.util.BeanUtils;
+import com.pmease.commons.util.ClassUtils;
+import com.pmease.commons.util.FileUtils;
+
+@Singleton
+public class DefaultPersistManager implements PersistManager, Provider<SessionFactory> {
+
+ private static final Logger logger = LoggerFactory.getLogger(DefaultPersistManager.class);
+
+ private final Set<ModelProvider> modelProviders;
+
+ private final PhysicalNamingStrategy physicalNamingStrategy;
+
+ private final Properties properties;
+
+ private final Migrator migrator;
+
+ private final Interceptor interceptor;
+
+ private final IdManager idManager;
+
+ private final Dao dao;
+
+ private StandardServiceRegistry serviceRegistry;
+
+ private Metadata metadata;
+
+ private volatile SessionFactory sessionFactory;
+
+ private String dbDataVersion;
+
+ @Inject
+ public DefaultPersistManager(Set<ModelProvider> modelProviders, PhysicalNamingStrategy physicalNamingStrategy,
+ @Named("hibernate") Properties properties, Migrator migrator, Interceptor interceptor,
+ IdManager idManager, Dao dao) {
+ this.modelProviders = modelProviders;
+ this.physicalNamingStrategy = physicalNamingStrategy;
+ this.properties = properties;
+ this.migrator = migrator;
+ this.interceptor = interceptor;
+ this.idManager = idManager;
+ this.dao = dao;
+ }
+
+ private boolean isMySQL() {
+ return properties.getProperty(PropertyNames.DIALECT).toLowerCase().contains("mysql");
+ }
+
+ private boolean isHSQL() {
+ return properties.getProperty(PropertyNames.DIALECT).toLowerCase().contains("hsql");
+ }
+
+ public void execute(List<String> sqls) {
+ Connection conn = null;
+ Statement stmt = null;
+ try {
+ conn = getConnection();
+ stmt = conn.createStatement();
+ for (String sql: sqls) {
+ logger.debug("Executing sql: " + sql);
+ stmt.execute(sql);
+ }
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ }
+ }
+ if (conn != null) {
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+ }
+
+ @Override
+ public void start() {
+ Preconditions.checkState(sessionFactory == null);
+
+ serviceRegistry = new StandardServiceRegistryBuilder().applySettings(properties).build();
+
+ dbDataVersion = readDbDataVersion();
+
+ logger.info("Checking data version...");
+ String appDataVersion = MigrationHelper.getVersion(migrator.getClass());
+ if (dbDataVersion != null && !dbDataVersion.equals(appDataVersion)) {
+ throw new RuntimeException("Data version mismatch "
+ + "(database data version: "+ dbDataVersion + ", application data version: "+ appDataVersion + "). "
+ + "Please follow instructions in the upgrade guide to upgrade the database.");
+ }
+
+ MetadataSources metadataSources = new MetadataSources(serviceRegistry);
+ for (Class<? extends AbstractEntity> each: ClassUtils.findImplementations(AbstractEntity.class, AbstractEntity.class)) {
+ metadataSources.addAnnotatedClass(each);
+ }
+
+ for (ModelProvider provider: modelProviders) {
+ for (Class<? extends AbstractEntity> modelClass: provider.getModelClasses())
+ metadataSources.addAnnotatedClass(modelClass);
+ }
+
+ metadata = metadataSources.getMetadataBuilder().applyPhysicalNamingStrategy(physicalNamingStrategy).build();
+
+ if (dbDataVersion == null) {
+ File tempFile = null;
+ try {
+ tempFile = File.createTempFile("schema", ".sql");
+ new SchemaExport().setOutputFile(tempFile.getAbsolutePath())
+ .setFormat(false).createOnly(EnumSet.of(TargetType.SCRIPT), metadata);
+ List<String> sqls = new ArrayList<String>();
+ for (String sql: FileUtils.readLines(tempFile)) {
+ if (shouldInclude(sql))
+ sqls.add(sql);
+ }
+ execute(sqls);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (tempFile != null)
+ tempFile.delete();
+ }
+
+ sessionFactory = metadata.getSessionFactoryBuilder().applyInterceptor(interceptor).build();
+
+ idManager.init();
+
+ Session session = sessionFactory.openSession();
+ Transaction transaction = session.beginTransaction();
+ try {
+ VersionTable dataVersion = new VersionTable();
+ dataVersion.versionColumn = appDataVersion;
+ session.save(dataVersion);
+ session.flush();
+ transaction.commit();
+ } catch (Exception e) {
+ transaction.rollback();
+ } finally {
+ session.close();
+ }
+ } else {
+ sessionFactory = metadata.getSessionFactoryBuilder().applyInterceptor(interceptor).build();
+ idManager.init();
+ }
+ }
+
+ @Override
+ public void stop() {
+ if (sessionFactory != null) {
+ Preconditions.checkState(!sessionFactory.isClosed());
+ sessionFactory.close();
+ sessionFactory = null;
+ }
+ }
+
+ @Override
+ public SessionFactory get() {
+ if (sessionFactory == null)
+ throw new RuntimeException("Persist service is either not started or is not configured.");
+ return sessionFactory;
+ }
+
+ @Override
+ public boolean isReady() {
+ return sessionFactory != null;
+ }
+
+ private Connection getConnection() {
+ try {
+ Class.forName(properties.getProperty(PropertyNames.DRIVER_PROPNAME));
+ Connection conn = DriverManager.getConnection(
+ properties.getProperty(PropertyNames.URL_PROPNAME),
+ properties.getProperty(PropertyNames.USER_PROPNAME),
+ properties.getProperty(PropertyNames.PASSWORD_PROPNAME));
+ return conn;
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ @Override
+ public String getDbDataVersion() {
+ return dbDataVersion;
+ }
+
+ private String getVersionTableName() {
+ JdbcEnvironment environment = serviceRegistry.getService(JdbcEnvironment.class);
+ Identifier identifier = Identifier.toIdentifier(VersionTable.class.getSimpleName());
+ return physicalNamingStrategy.toPhysicalTableName(identifier, environment).getText().toLowerCase();
+ }
+
+ private String getVersionFieldName() {
+ return VersionTable.class.getFields()[0].getName();
+ }
+
+ private String getVersionColumnName() {
+ JdbcEnvironment environment = serviceRegistry.getService(JdbcEnvironment.class);
+ Identifier identifier = Identifier.toIdentifier(getVersionFieldName());
+ return physicalNamingStrategy.toPhysicalColumnName(identifier, environment).getText();
+ }
+
+ private String readDbDataVersion() {
+ Connection conn = null;
+ Statement stmt = null;
+ ResultSet resultset = null;
+ try {
+ conn = getConnection();
+ conn.setAutoCommit(false);
+ String versionTableName = getVersionTableName();
+ resultset = conn.getMetaData().getTables(null, null, versionTableName, null);
+ if (!resultset.next()) {
+ return null;
+ } else {
+ try {
+ logger.info("Version table found. Catalog: {}, Schema: {}, Name: {}, Type: {}",
+ resultset.getString("TABLE_CAT"), resultset.getString("TABLE_SCHEM"),
+ resultset.getString("TABLE_NAME"), resultset.getString("TABLE_TYPE"));
+ } catch (Exception e) {
+ }
+ }
+ resultset.close();
+ stmt = conn.createStatement();
+ resultset = stmt.executeQuery("select " + getVersionColumnName() + " from " + versionTableName);
+ if (!resultset.next())
+ throw new RuntimeException("No data version found in database.");
+ String dataVersion = resultset.getString(1);
+ if (resultset.next())
+ throw new RuntimeException("Illegal data version format in database");
+ return dataVersion;
+ } catch (Throwable e) {
+ if (e.getMessage() != null && e.getMessage().contains("ORA-00942"))
+ return null;
+ else
+ throw Throwables.propagate(e);
+ } finally {
+ if (resultset != null) {
+ try {
+ resultset.close();
+ } catch (SQLException e) {
+ }
+ }
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ }
+ }
+ if (conn != null) {
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+ }
+
+ @Override
+ public void migrate(File dataDir) {
+ File versionFile = new File(dataDir, VersionTable.class.getSimpleName() + "s.xml");
+ VersionedDocument dom = readFile(versionFile);
+ List<Element> elements = dom.getRootElement().elements();
+ if (elements.size() != 1)
+ throw new RuntimeException("Incorrect data format: illegal data version");
+ Element versionElement = elements.iterator().next().element(getVersionFieldName());
+ if (versionElement == null) {
+ throw new RuntimeException("Incorrect data format: no data version");
+ }
+
+ if (MigrationHelper.migrate(versionElement.getText(), migrator, dataDir)) {
+ versionElement.setText(MigrationHelper.getVersion(migrator.getClass()));
+ writeFile(versionFile, dom, false);
+ }
+ }
+
+ private void writeFile(File file, VersionedDocument dom, boolean pretty) {
+ OutputStream os = null;
+ try {
+ os = new FileOutputStream(file);
+ OutputFormat format = new OutputFormat();
+ format.setIndent(pretty);
+ format.setNewlines(pretty);
+ format.setEncoding(Charsets.UTF_8.name());
+ XMLWriter writer = new XMLWriter(os, format);
+ writer.write(dom);
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ } finally {
+ IOUtils.closeQuietly(os);
+ }
+ }
+
+ private VersionedDocument readFile(File file) {
+ try {
+ char[] chars = FileUtils.readFileToString(file, Charsets.UTF_8.name()).toCharArray();
+ return new VersionedDocument(new XPP3Reader().read(chars));
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ /**
+ * Determines whether or not entityType1 has transitive foreign key
+ * dependency on entityType2.
+ *
+ * @param entityType1
+ * @param entityType2
+ * @return
+ */
+ private boolean hasForeignKeyDependency(Class<?> entityType1, Class<?> entityType2) {
+ for (Field field: BeanUtils.getFields(entityType1)) {
+ if (field.getAnnotation(ManyToOne.class) != null) {
+ if (field.getType() == entityType2)
+ return true;
+ if (field.getType() != entityType1 &&
+ hasForeignKeyDependency(field.getType(), entityType2)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public List<Class<?>> getEntityTypes() {
+ List<Class<?>> entityTypes = new ArrayList<>();
+ for (Iterator<String> it = sessionFactory.getAllClassMetadata().keySet().iterator(); it.hasNext();) {
+ String entityTypeName = (String) it.next();
+ try {
+ entityTypes.add(Class.forName(entityTypeName));
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /* Collections.sort does not work here */
+ List<Class<?>> sorted = new ArrayList<Class<?>>();
+ while (!entityTypes.isEmpty()) {
+ Class<?> dependencyLeaf = null;
+ for (Class<?> entityType: entityTypes) {
+ boolean hasDependents = false;
+ for (Class<?> each: entityTypes) {
+ if (each != entityType) {
+ if (hasForeignKeyDependency(each, entityType)) {
+ hasDependents = true;
+ break;
+ }
+ }
+ }
+ if (!hasDependents) {
+ dependencyLeaf = entityType;
+ break;
+ }
+ }
+ if (dependencyLeaf != null) {
+ sorted.add(dependencyLeaf);
+ entityTypes.remove(dependencyLeaf);
+ } else {
+ throw new RuntimeException("Looped foreigh key dependency found between model classes");
+ }
+ }
+ return sorted;
+ }
+
+ @Override
+ @Sessional
+ public void exportData(File exportDir, int batchSize) {
+ for (Class<?> entityType: getEntityTypes()) {
+ logger.info("Exporting table '" + entityType.getSimpleName() + "'...");
+
+ logger.info("Querying table ids...");
+
+ Criteria criteria = dao.getSession().createCriteria(entityType, "entity")
+ .setProjection(Projections.property("entity.id")).addOrder(Order.asc("id"));
+ @SuppressWarnings("unchecked")
+ List<Long> ids = criteria.list();
+ int count = ids.size();
+
+ for (int i=0; i<count/batchSize; i++) {
+ exportEntity(entityType, ids, i*batchSize, batchSize, batchSize, exportDir);
+ // clear session to free memory
+ dao.getSession().clear();
+ }
+
+ if (count%batchSize != 0) {
+ exportEntity(entityType, ids, count/batchSize*batchSize, count%batchSize, batchSize, exportDir);
+ }
+ logger.info("");
+ }
+
+ }
+
+ private void exportEntity(Class<?> entityType, List<Long> ids, int start, int count, int batchSize, File exportDir) {
+ logger.info("Loading table rows ({}->{}) from database...", String.valueOf(start+1), (start + count));
+
+ Query query = dao.getSession().createQuery("from " + entityType.getSimpleName() + " where id>=:fromId and id<=:toId");
+ query.setParameter("fromId", ids.get(start));
+ query.setParameter("toId", ids.get(start+count-1));
+
+ logger.info("Converting table rows to XML...");
+ VersionedDocument dom = new VersionedDocument();
+ Element rootElement = dom.addElement("list");
+ for (Object entity: query.list())
+ rootElement.appendContent(VersionedDocument.fromBean(entity));
+ String fileName;
+
+ if (start == 0)
+ fileName = entityType.getSimpleName() + "s.xml";
+ else
+ fileName = entityType.getSimpleName() + "s.xml." + (start/batchSize + 1);
+
+ logger.info("Writing resulting XML to file '" + fileName + "...");
+ writeFile(new File(exportDir, fileName), dom, true);
+ }
+
+ /*
+ * We do not use @Transactional annotation and will manage the session and transaction manually
+ * in this method to reduce memory usage if importing a large database.
+ */
+ @Sessional
+ @Override
+ public void importData(File dataDir) {
+ // check version
+ File versionFile = new File(dataDir, VersionTable.class.getSimpleName() + "s.xml");
+ VersionedDocument dom = readFile(versionFile);
+ List<Element> elements = dom.getRootElement().elements();
+ if (elements.size() != 1)
+ throw new RuntimeException("Incorrect data format: illegal data version");
+ Element versionElement = elements.iterator().next().element(getVersionFieldName());
+ if (versionElement == null) {
+ throw new RuntimeException("Incorrect data format: no data version");
+ }
+
+ if (versionElement.getText().equals(MigrationHelper.getVersion(migrator.getClass()))) {
+ throw new RuntimeException("Data version mismatch");
+ }
+
+ File tempFile = null;
+ try {
+ logger.info("Clearing database...");
+
+ tempFile = File.createTempFile("schema", ".sql");
+ new SchemaExport().setOutputFile(tempFile.getAbsolutePath())
+ .setFormat(false).drop(EnumSet.of(TargetType.SCRIPT), metadata);
+ List<String> sqls = new ArrayList<String>();
+ for (String sql: FileUtils.readLines(tempFile)) {
+ sqls.add(sql);
+ }
+ execute(sqls);
+
+ tempFile = File.createTempFile("schema", ".sql");
+ new SchemaExport().setOutputFile(tempFile.getAbsolutePath())
+ .setFormat(false).createOnly(EnumSet.of(TargetType.SCRIPT), metadata);
+ sqls.clear();
+ for (String sql: FileUtils.readLines(tempFile)) {
+ if (shouldInclude(sql) && !isCreatingForeignKey(sql))
+ sqls.add(sql);
+ }
+ execute(sqls);
+
+ List<Class<?>> entityTypes = getEntityTypes();
+ Collections.reverse(entityTypes);
+ for (Class<?> entityType: entityTypes) {
+ File[] dataFiles = dataDir.listFiles(new FilenameFilter() {
+
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.startsWith(entityType.getSimpleName() + "s.xml");
+ }
+
+ });
+ for (File file: dataFiles) {
+ try {
+ logger.info("Importing from data file '" + file.getName() + "'...");
+ dao.getSession().beginTransaction();
+ dom = readFile(file);
+ for (Element element: dom.getRootElement().elements()) {
+ element.detach();
+ AbstractEntity entity = (AbstractEntity) new VersionedDocument(DocumentHelper.createDocument(element)).toBean();
+ dao.getSession().replicate(entity, ReplicationMode.EXCEPTION);
+ }
+ dao.getSession().flush();
+ dao.getSession().clear();
+ dao.getSession().getTransaction().commit();
+ } catch (Throwable e) {
+ dao.getSession().getTransaction().rollback();
+ throw Throwables.propagate(e);
+ }
+ }
+ }
+
+ logger.info("Applying foreign key constraints...");
+
+ tempFile = File.createTempFile("schema", ".sql");
+ new SchemaExport().setOutputFile(tempFile.getAbsolutePath())
+ .setFormat(false).createOnly(EnumSet.of(TargetType.SCRIPT), metadata);
+ sqls.clear();
+ for (String sql: FileUtils.readLines(tempFile)) {
+ if (isCreatingForeignKey(sql)) {
+ sqls.add(sql);
+ }
+ }
+ execute(sqls);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (tempFile != null)
+ tempFile.delete();
+ }
+ }
+
+ private boolean isCreatingForeignKey(String sql) {
+ return sql.toLowerCase().contains(" foreign key ");
+ }
+
+ private boolean shouldInclude(String sql) {
+ // some databases will create index on foreign keys automatically, so
+ // we skip creating indexes for those
+ if (!sql.toLowerCase().startsWith("create index") || !sql.toLowerCase().endsWith("_id)")) {
+ return true;
+ } else {
+ return !isMySQL() && !isHSQL();
+ }
+ }
+
+}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/DefaultPersistService.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/DefaultPersistService.java
deleted file mode 100644
index 3f70cf34b3..0000000000
--- a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/DefaultPersistService.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package com.pmease.commons.hibernate;
-
-import java.util.Properties;
-import java.util.Set;
-
-import javax.annotation.Nullable;
-import javax.inject.Named;
-
-import org.hibernate.Interceptor;
-import org.hibernate.SessionFactory;
-import org.hibernate.boot.Metadata;
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
-import org.hibernate.boot.registry.StandardServiceRegistry;
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
-
-import com.google.common.base.Preconditions;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
-import com.pmease.commons.util.ClassUtils;
-
-@Singleton
-public class DefaultPersistService implements PersistService, Provider<SessionFactory> {
-
- private final Set<ModelProvider> modelProviders;
-
- private final PhysicalNamingStrategy physicalNamingStrategy;
-
- private final Properties properties;
-
- private final Interceptor interceptor;
-
- private volatile SessionFactory sessionFactory;
-
- @Inject
- public DefaultPersistService(Set<ModelProvider> modelProviders, PhysicalNamingStrategy physicalNamingStrategy,
- @Nullable @Named("hibernate") Properties properties, Interceptor interceptor) {
- this.modelProviders = modelProviders;
- this.physicalNamingStrategy = physicalNamingStrategy;
- this.properties = properties;
- this.interceptor = interceptor;
- }
-
- @Override
- public void start() {
- Preconditions.checkState(sessionFactory == null);
-
- StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder()
- .applySettings(properties).build();
-
- MetadataSources metadataSources = new MetadataSources(standardRegistry);
- for (Class<? extends AbstractEntity> each: ClassUtils.findImplementations(AbstractEntity.class, AbstractEntity.class)) {
- metadataSources.addAnnotatedClass(each);
- }
-
- for (ModelProvider provider: modelProviders) {
- for (Class<? extends AbstractEntity> modelClass: provider.getModelClasses())
- metadataSources.addAnnotatedClass(modelClass);
- }
-
- Metadata metadata = metadataSources.getMetadataBuilder()
- .applyPhysicalNamingStrategy(physicalNamingStrategy)
- .build();
- sessionFactory = metadata.getSessionFactoryBuilder().applyInterceptor(interceptor).build();
- }
-
- @Override
- public void stop() {
- if (sessionFactory != null) {
- Preconditions.checkState(!sessionFactory.isClosed());
- sessionFactory.close();
- sessionFactory = null;
- }
- }
-
- @Override
- public SessionFactory get() {
- if (sessionFactory == null)
- throw new RuntimeException("Persist service is either not started or is not configured.");
- return sessionFactory;
- }
-
- @Override
- public boolean isReady() {
- return sessionFactory != null;
- }
-
-}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernateFilter.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernateFilter.java
index af66f5dbc1..d71637cc8c 100644
--- a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernateFilter.java
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernateFilter.java
@@ -17,10 +17,10 @@ public class HibernateFilter implements Filter {
private final UnitOfWork unitOfWork;
- private final PersistService persistService;
+ private final PersistManager persistService;
@Inject
- public HibernateFilter(UnitOfWork unitOfWork, PersistService persistService) {
+ public HibernateFilter(UnitOfWork unitOfWork, PersistManager persistService) {
this.unitOfWork = unitOfWork;
this.persistService = persistService;
}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernateModule.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernateModule.java
index 7092c065fe..a806f0e5a1 100644
--- a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernateModule.java
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernateModule.java
@@ -1,108 +1,193 @@
-package com.pmease.commons.hibernate;
-
-import java.io.Serializable;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
-import java.util.Properties;
-
-import org.hibernate.CallbackException;
-import org.hibernate.Interceptor;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
-import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
-import org.hibernate.type.Type;
-
-import com.google.inject.matcher.AbstractMatcher;
-import com.google.inject.matcher.Matchers;
-import com.google.inject.name.Names;
-import com.google.inject.util.Providers;
-import com.pmease.commons.hibernate.dao.Dao;
-import com.pmease.commons.hibernate.dao.DefaultDao;
-import com.pmease.commons.hibernate.jackson.HibernateObjectMapperConfigurator;
-import com.pmease.commons.jackson.ObjectMapperConfigurator;
-import com.pmease.commons.jetty.ServletConfigurator;
-import com.pmease.commons.loader.AbstractPlugin;
-import com.pmease.commons.loader.AbstractPluginModule;
-
-public class HibernateModule extends AbstractPluginModule {
-
- @Override
- protected void configure() {
- super.configure();
-
- // Use an optional binding here in case our client does not like to
- // start persist service provided by this plugin
- bind(Interceptor.class).to(HibernateInterceptor.class);
- bind(Properties.class).annotatedWith(Names.named("hibernate")).toProvider(Providers.<Properties>of(null));
- bind(PhysicalNamingStrategy.class).to(PhysicalNamingStrategyStandardImpl.class);
-
- bind(PersistService.class).to(DefaultPersistService.class);
- bind(SessionFactory.class).toProvider(DefaultPersistService.class);
- bind(UnitOfWork.class).to(DefaultUnitOfWork.class);
- bind(Session.class).toProvider(DefaultUnitOfWork.class);
- bind(IdManager.class).to(DefaultIdManager.class);
-
- bind(Dao.class).to(DefaultDao.class);
-
- TransactionInterceptor transactionInterceptor = new TransactionInterceptor();
- requestInjection(transactionInterceptor);
-
- bindInterceptor(Matchers.any(), new AbstractMatcher<AnnotatedElement>() {
-
- @Override
- public boolean matches(AnnotatedElement element) {
- return element.isAnnotationPresent(Transactional.class) && !((Method) element).isSynthetic();
- }
-
- }, transactionInterceptor);
-
- SessionInterceptor sessionInterceptor = new SessionInterceptor();
- requestInjection(sessionInterceptor);
-
- bindInterceptor(Matchers.any(), new AbstractMatcher<AnnotatedElement>() {
-
- @Override
- public boolean matches(AnnotatedElement element) {
- return element.isAnnotationPresent(Sessional.class) && !((Method) element).isSynthetic();
- }
-
- }, sessionInterceptor);
-
- contribute(ObjectMapperConfigurator.class, HibernateObjectMapperConfigurator.class);
- contribute(ServletConfigurator.class, HibernateServletConfigurator.class);
-
- contribute(PersistListener.class, new PersistListener() {
-
- @Override
- public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
- throws CallbackException {
- return false;
- }
-
- @Override
- public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
- throws CallbackException {
- return false;
- }
-
- @Override
- public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
- String[] propertyNames, Type[] types) throws CallbackException {
- return false;
- }
-
- @Override
- public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
- throws CallbackException {
- }
- });
-
- }
-
- @Override
- protected Class<? extends AbstractPlugin> getPluginClass() {
- return HibernatePlugin.class;
- }
-
-}
+package com.pmease.commons.hibernate;
+
+import java.io.Serializable;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Properties;
+
+import javax.inject.Provider;
+import javax.inject.Singleton;
+import javax.persistence.OneToMany;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.hibernate.CallbackException;
+import org.hibernate.Interceptor;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
+import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
+import org.hibernate.collection.internal.PersistentBag;
+import org.hibernate.type.Type;
+
+import com.google.common.collect.Lists;
+import com.google.inject.matcher.AbstractMatcher;
+import com.google.inject.matcher.Matchers;
+import com.google.inject.name.Names;
+import com.google.inject.util.Providers;
+import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.commons.hibernate.dao.DefaultDao;
+import com.pmease.commons.hibernate.jackson.HibernateObjectMapperConfigurator;
+import com.pmease.commons.hibernate.migration.JpaConverter;
+import com.pmease.commons.hibernate.migration.PersistentBagConverter;
+import com.pmease.commons.hibernate.migration.VersionTable;
+import com.pmease.commons.jackson.ObjectMapperConfigurator;
+import com.pmease.commons.jetty.ServletConfigurator;
+import com.pmease.commons.loader.AbstractPlugin;
+import com.pmease.commons.loader.AbstractPluginModule;
+import com.pmease.commons.util.ClassUtils;
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.annotations.XStreamOmitField;
+import com.thoughtworks.xstream.converters.basic.NullConverter;
+import com.thoughtworks.xstream.converters.extended.ISO8601DateConverter;
+import com.thoughtworks.xstream.converters.extended.ISO8601SqlTimestampConverter;
+import com.thoughtworks.xstream.converters.reflection.ReflectionProvider;
+import com.thoughtworks.xstream.core.JVM;
+import com.thoughtworks.xstream.mapper.MapperWrapper;
+
+public class HibernateModule extends AbstractPluginModule {
+
+ @Override
+ protected void configure() {
+ super.configure();
+
+ // Use an optional binding here in case our client does not like to
+ // start persist service provided by this plugin
+ bind(Interceptor.class).to(HibernateInterceptor.class);
+ bind(Properties.class).annotatedWith(Names.named("hibernate")).toProvider(Providers.<Properties>of(null));
+ bind(PhysicalNamingStrategy.class).to(PhysicalNamingStrategyStandardImpl.class);
+
+ bind(PersistManager.class).to(DefaultPersistManager.class);
+ bind(SessionFactory.class).toProvider(DefaultPersistManager.class);
+ bind(UnitOfWork.class).to(DefaultUnitOfWork.class);
+ bind(Session.class).toProvider(DefaultUnitOfWork.class);
+ bind(IdManager.class).to(DefaultIdManager.class);
+ bind(Dao.class).to(DefaultDao.class);
+
+ TransactionInterceptor transactionInterceptor = new TransactionInterceptor();
+ requestInjection(transactionInterceptor);
+
+ bindInterceptor(Matchers.any(), new AbstractMatcher<AnnotatedElement>() {
+
+ @Override
+ public boolean matches(AnnotatedElement element) {
+ return element.isAnnotationPresent(Transactional.class) && !((Method) element).isSynthetic();
+ }
+
+ }, transactionInterceptor);
+
+ SessionInterceptor sessionInterceptor = new SessionInterceptor();
+ requestInjection(sessionInterceptor);
+
+ bindInterceptor(Matchers.any(), new AbstractMatcher<AnnotatedElement>() {
+
+ @Override
+ public boolean matches(AnnotatedElement element) {
+ return element.isAnnotationPresent(Sessional.class) && !((Method) element).isSynthetic();
+ }
+
+ }, sessionInterceptor);
+
+ contribute(ObjectMapperConfigurator.class, HibernateObjectMapperConfigurator.class);
+ contribute(ServletConfigurator.class, HibernateServletConfigurator.class);
+
+ contribute(PersistListener.class, new PersistListener() {
+
+ @Override
+ public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
+ throws CallbackException {
+ return false;
+ }
+
+ @Override
+ public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
+ throws CallbackException {
+ return false;
+ }
+
+ @Override
+ public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
+ String[] propertyNames, Type[] types) throws CallbackException {
+ return false;
+ }
+
+ @Override
+ public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types)
+ throws CallbackException {
+ }
+ });
+
+ contribute(ModelProvider.class, new ModelProvider() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Collection<Class<? extends AbstractEntity>> getModelClasses() {
+ return Lists.newArrayList(VersionTable.class);
+ }
+
+ });
+
+ // put your guice bindings here
+ bind(XStream.class).toProvider(new Provider<XStream>() {
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public XStream get() {
+ ReflectionProvider reflectionProvider = JVM.newReflectionProvider();
+ XStream xstream = new XStream(reflectionProvider) {
+
+ @Override
+ protected MapperWrapper wrapMapper(MapperWrapper next) {
+ return new MapperWrapper(next) {
+
+ @Override
+ public boolean shouldSerializeMember(Class definedIn, String fieldName) {
+ Field field = reflectionProvider.getField(definedIn, fieldName);
+
+ return field.getAnnotation(XStreamOmitField.class) == null &&
+ field.getAnnotation(Transient.class) == null &&
+ field.getAnnotation(OneToMany.class) == null &&
+ field.getAnnotation(Version.class) == null;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public String serializedClass(Class type) {
+ if (type == PersistentBag.class)
+ return super.serializedClass(ArrayList.class);
+ else if (type != null)
+ return super.serializedClass(ClassUtils.unproxy(type));
+ else
+ return super.serializedClass(type);
+ }
+
+ };
+ }
+
+ };
+
+ // register NullConverter as highest; otherwise NPE when unmarshal a map
+ // containing an entry with value set to null.
+ xstream.registerConverter(new NullConverter(), XStream.PRIORITY_VERY_HIGH);
+ xstream.registerConverter(new PersistentBagConverter(xstream.getMapper()), 200);
+ xstream.registerConverter(new JpaConverter(xstream.getMapper(), xstream.getReflectionProvider()));
+ xstream.registerConverter(new ISO8601DateConverter(), 100);
+ xstream.registerConverter(new ISO8601SqlTimestampConverter(), 100);
+ xstream.autodetectAnnotations(true);
+
+ return xstream;
+ }
+
+ }).in(Singleton.class);
+
+ }
+
+ @Override
+ protected Class<? extends AbstractPlugin> getPluginClass() {
+ return HibernatePlugin.class;
+ }
+
+}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernatePlugin.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernatePlugin.java
index dbbfd1c184..05fa4da939 100644
--- a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernatePlugin.java
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/HibernatePlugin.java
@@ -5,20 +5,16 @@ import com.pmease.commons.loader.AbstractPlugin;
public class HibernatePlugin extends AbstractPlugin {
- private final PersistService persistService;
-
- private final IdManager idManager;
+ private final PersistManager persistService;
@Inject
- public HibernatePlugin(PersistService persistService, IdManager idManager) {
+ public HibernatePlugin(PersistManager persistService) {
this.persistService = persistService;
- this.idManager = idManager;
}
@Override
public void start() {
persistService.start();
- idManager.init();
}
@Override
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/PersistManager.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/PersistManager.java
new file mode 100644
index 0000000000..0e3b11c1f8
--- /dev/null
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/PersistManager.java
@@ -0,0 +1,31 @@
+package com.pmease.commons.hibernate;
+
+import java.io.File;
+import java.util.List;
+
+public interface PersistManager {
+
+ void start();
+
+ void stop();
+
+ boolean isReady();
+
+ String getDbDataVersion();
+
+ /**
+ * @return hibernate entity types ordered using foreign key dependency
+ * information. For example, Build type comes before Configuration
+ * type as it has Build has foreign key reference to Configuration.
+ */
+ List<Class<?>> getEntityTypes();
+
+ void migrate(File dataDir);
+
+ void exportData(File dataDir, int batchSize);
+
+ // This method should only be called by a bootstrap action. That is, when the
+ // server is stopped. So it does not need an exclusive database lock.
+ void importData(File dataDir);
+
+}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/PersistService.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/PersistService.java
deleted file mode 100644
index dd1f72be99..0000000000
--- a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/PersistService.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.pmease.commons.hibernate;
-
-public interface PersistService {
-
- void start();
-
- void stop();
-
- boolean isReady();
-
-}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/PropertyNames.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/PropertyNames.java
new file mode 100644
index 0000000000..8bdde1a217
--- /dev/null
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/PropertyNames.java
@@ -0,0 +1,15 @@
+package com.pmease.commons.hibernate;
+
+public class PropertyNames {
+
+ public static final String DIALECT = "hibernate.dialect";
+
+ public static final String DRIVER_PROPNAME = "hibernate.connection.driver_class";
+
+ public static final String URL_PROPNAME = "hibernate.connection.url";
+
+ public static final String USER_PROPNAME = "hibernate.connection.username";
+
+ public static final String PASSWORD_PROPNAME = "hibernate.connection.password";
+
+}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/JpaConverter.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/JpaConverter.java
new file mode 100644
index 0000000000..2082ccba8b
--- /dev/null
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/JpaConverter.java
@@ -0,0 +1,242 @@
+package com.pmease.commons.hibernate.migration;
+
+import java.lang.reflect.Field;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.persistence.ManyToOne;
+
+import org.dom4j.Attribute;
+import org.dom4j.Branch;
+import org.dom4j.Element;
+import org.hibernate.collection.internal.PersistentBag;
+import org.hibernate.proxy.HibernateProxy;
+
+import com.google.common.base.Throwables;
+import com.pmease.commons.hibernate.AbstractEntity;
+import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.commons.loader.AppLoader;
+import com.pmease.commons.util.ClassUtils;
+import com.pmease.commons.util.ReflectionUtils;
+import com.pmease.commons.util.StringUtils;
+import com.thoughtworks.xstream.converters.MarshallingContext;
+import com.thoughtworks.xstream.converters.UnmarshallingContext;
+import com.thoughtworks.xstream.converters.reflection.ReflectionConverter;
+import com.thoughtworks.xstream.converters.reflection.ReflectionProvider;
+import com.thoughtworks.xstream.core.util.HierarchicalStreams;
+import com.thoughtworks.xstream.io.HierarchicalStreamReader;
+import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
+import com.thoughtworks.xstream.mapper.Mapper;
+
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class JpaConverter extends ReflectionConverter {
+
+ private ThreadLocal<Stack<HierarchicalStreamReader>> readerStack =
+ new ThreadLocal<Stack<HierarchicalStreamReader>>() {
+
+ @Override
+ protected Stack<HierarchicalStreamReader> initialValue() {
+ return new Stack<HierarchicalStreamReader>();
+ }
+
+ };
+
+ private ThreadLocal<Stack<HierarchicalStreamWriter>> writerStack =
+ new ThreadLocal<Stack<HierarchicalStreamWriter>>() {
+
+ @Override
+ protected Stack<HierarchicalStreamWriter> initialValue() {
+ return new Stack<HierarchicalStreamWriter>();
+ }
+
+ };
+
+ public JpaConverter(Mapper mapper, ReflectionProvider reflectionProvider) {
+ super(mapper, reflectionProvider);
+ }
+
+ @Override
+ public void marshal(Object original, HierarchicalStreamWriter writer, MarshallingContext context) {
+ try {
+ writerStack.get().push(writer);
+ if (original instanceof HibernateProxy)
+ original = ((HibernateProxy)original).getHibernateLazyInitializer().getImplementation();
+ super.marshal(original, writer, context);
+ } finally {
+ writerStack.get().pop();
+ }
+ }
+
+ @Override
+ protected void marshallField(MarshallingContext context, Object newObj, Field field) {
+ HierarchicalStreamWriter writer = writerStack.get().peek();
+ if (field.getAnnotation(ManyToOne.class) != null) {
+ super.marshallField(context, ((AbstractEntity) newObj).getId(), field);
+ } else if (newObj instanceof HibernateProxy) {
+ newObj = ((HibernateProxy)newObj).getHibernateLazyInitializer().getImplementation();
+ super.marshallField(context, newObj, field);
+ } else if (newObj instanceof VersionedDocument) {
+ marshallElement(writer, ((VersionedDocument)newObj).getRootElement());
+ } else if (Collection.class.isAssignableFrom(field.getType())
+ && ReflectionUtils.getCollectionElementType(field.getGenericType()) == VersionedDocument.class) {
+ for (VersionedDocument vdom: (List<VersionedDocument>)newObj) {
+ if (vdom != null) {
+ marshallElement(writer, vdom.getRootElement());
+ } else {
+ writer.startNode(mapper.serializedClass(null));
+ writer.endNode();
+ }
+ }
+ } else if (Map.class.isAssignableFrom(field.getType())
+ && ReflectionUtils.getMapValueType(field.getGenericType()) == VersionedDocument.class) {
+ for (Map.Entry<Object, VersionedDocument> entry:
+ ((Map<Object, VersionedDocument>)newObj).entrySet()) {
+ writer.startNode(mapper.serializedClass(Map.Entry.class));
+ if (entry.getKey() != null) {
+ writer.startNode(mapper.serializedClass(entry.getKey().getClass()));
+ context.convertAnother(entry.getKey());
+ writer.endNode();
+ } else {
+ writer.startNode(mapper.serializedClass(null));
+ writer.endNode();
+ }
+ if (entry.getValue() != null) {
+ marshallElement(writer, entry.getValue().getRootElement());
+ } else {
+ writer.startNode(mapper.serializedClass(null));
+ writer.endNode();
+ }
+ writer.endNode();
+ }
+ } else if (field.getType().isEnum()) {
+ writer.setValue(((Enum)newObj).name());
+ } else if (field.getType() == String.class) {
+ String stringValue = (String) newObj;
+ if (stringValue.indexOf('\0') != -1)
+ writer.setValue(StringUtils.replace(stringValue, "\0", ""));
+ else
+ writer.setValue(stringValue);
+ } else {
+ super.marshallField(context, newObj, field);
+ }
+ }
+
+ @Override
+ public Object unmarshal(HierarchicalStreamReader reader,
+ UnmarshallingContext context) {
+ try {
+ readerStack.get().push(reader);
+ return super.unmarshal(reader, context);
+ } finally {
+ readerStack.get().pop();
+ }
+ }
+
+ @Override
+ protected Object unmarshallField(UnmarshallingContext context,
+ Object result, Class type, Field field) {
+ HierarchicalStreamReader reader = readerStack.get().peek();
+ if (field.getAnnotation(ManyToOne.class) != null) {
+ return AppLoader.getInstance(Dao.class).load(
+ (Class<? extends AbstractEntity>) field.getType(),
+ Long.valueOf(reader.getValue()));
+ } else if (field.getType() == VersionedDocument.class) {
+ VersionedDocument vdom = new VersionedDocument();
+ reader.moveDown();
+ unmarshallElement(reader, vdom);
+ reader.moveUp();
+ return vdom;
+ } else if (Collection.class.isAssignableFrom(field.getType())
+ && ReflectionUtils.getCollectionElementType(field.getGenericType()) == VersionedDocument.class) {
+ Collection collection;
+ try {
+ collection = (Collection) mapper.defaultImplementationOf(
+ field.getType()).newInstance();
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ while (reader.hasMoreChildren()) {
+ reader.moveDown();
+ if (!reader.getNodeName().equals("null")) {
+ VersionedDocument vdom = new VersionedDocument();
+ unmarshallElement(reader, vdom);
+ collection.add(vdom);
+ } else {
+ collection.add(null);
+ }
+ reader.moveUp();
+ }
+ return collection;
+ } else if (Map.class.isAssignableFrom(field.getType())
+ && ReflectionUtils.getMapValueType(field.getGenericType()) == VersionedDocument.class) {
+ Map map;
+ try {
+ map = (Map) mapper.defaultImplementationOf(field.getType()).newInstance();
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ while (reader.hasMoreChildren()) {
+ reader.moveDown();
+ reader.moveDown();
+ Class keyType = HierarchicalStreams.readClassType(reader, mapper);
+ Object key;
+ if (!reader.getNodeName().equals("null"))
+ key = context.convertAnother(reader, keyType);
+ else
+ key = null;
+ reader.moveUp();
+ reader.moveDown();
+ if (!reader.getNodeName().equals("null")) {
+ VersionedDocument vdom = new VersionedDocument();
+ unmarshallElement(reader, vdom);
+ map.put(key, vdom);
+ } else {
+ map.put(key, null);
+ }
+ reader.moveUp();
+ reader.moveUp();
+ }
+ return map;
+ } else if (field.getType().isEnum()) {
+ // process this separately since the default implementation
+ // adds enum ordinal besides name for polymorphic enums
+ // (for example Subscription.Condition)
+ return Enum.valueOf((Class)field.getType(), reader.getValue());
+ } else {
+ return super.unmarshallField(context, result, type, field);
+ }
+ }
+
+ public boolean canConvert(Class clazz) {
+ return !ClassUtils.isSystemType(clazz) && clazz != PersistentBag.class;
+ }
+
+ private void marshallElement(HierarchicalStreamWriter writer, Element element) {
+ writer.startNode(element.getName());
+ for (Attribute attribute: (List<Attribute>)element.attributes())
+ writer.addAttribute(attribute.getName(), attribute.getValue());
+ if (element.getText().trim().length() != 0)
+ writer.setValue(element.getText().trim());
+ for (Element child: (List<Element>)element.elements())
+ marshallElement(writer, child);
+ writer.endNode();
+ }
+
+ private void unmarshallElement(HierarchicalStreamReader reader, Branch branch) {
+ Element element = branch.addElement(reader.getNodeName());
+ for (int i=0; i<reader.getAttributeCount(); i++) {
+ String attributeName = reader.getAttributeName(i);
+ String attributeValue = reader.getAttribute(i);
+ element.addAttribute(attributeName, attributeValue);
+ }
+ if (StringUtils.isNotBlank(reader.getValue()))
+ element.setText(reader.getValue().trim());
+ while (reader.hasMoreChildren()) {
+ reader.moveDown();
+ unmarshallElement(reader, element);
+ reader.moveUp();
+ }
+ }
+}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/MigrationHelper.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/MigrationHelper.java
new file mode 100644
index 0000000000..02c013ebc8
--- /dev/null
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/MigrationHelper.java
@@ -0,0 +1,163 @@
+package com.pmease.commons.hibernate.migration;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Throwables;
+import com.pmease.commons.util.StringUtils;
+
+public class MigrationHelper {
+
+ private static final Logger logger = LoggerFactory.getLogger(MigrationHelper.class);
+
+ private static final Pattern migrateMethodPattern =
+ Pattern.compile("^migrate(\\d+)$");
+
+ // caches the analysis result to speed up migration process (there might be many
+ // bean data need to be migrated, such as various repository/builder/step
+ // definitions, etc).
+ private static Map<String, MigratorAnalyzeResult> migratorAnalyzeResults =
+ new ConcurrentHashMap<String, MigratorAnalyzeResult>();
+
+ private static MigratorAnalyzeResult getMigratorAnalyzeResult(Class<?> migrator) {
+ MigratorAnalyzeResult migratorAnalyzeResult =
+ migratorAnalyzeResults.get(migrator.getName());
+ if (migratorAnalyzeResult == null) {
+ final MigratorAnalyzeResult newMigratorAnalyzeResult =
+ new MigratorAnalyzeResult();
+
+ Method[] methods = migrator.getDeclaredMethods();
+ for (int i=0; i<methods.length; i++) {
+ Method method = methods[i];
+ int migrateVersion = getVersion(method);
+ if (migrateVersion != 0) {
+ if (Modifier.isPrivate(method.getModifiers()) &&
+ !Modifier.isStatic(method.getModifiers())) {
+ method.setAccessible(true);
+ newMigratorAnalyzeResult.getMigrateVersions()
+ .put(method.getName(), migrateVersion);
+ newMigratorAnalyzeResult.getMigrateMethods().add(method);
+ } else {
+ throw new RuntimeException("Migrate method should be declared " +
+ "as a private non-static method.");
+ }
+ }
+ }
+
+ Collections.sort(newMigratorAnalyzeResult.getMigrateMethods(),
+ new Comparator<Method>() {
+
+ public int compare(Method migrate_x, Method migrate_y) {
+ return newMigratorAnalyzeResult.getMigrateVersions().get(migrate_x.getName()) -
+ newMigratorAnalyzeResult.getMigrateVersions().get(migrate_y.getName());
+ }
+
+ });
+ migratorAnalyzeResults.put(migrator.getName(), newMigratorAnalyzeResult);
+ return newMigratorAnalyzeResult;
+ } else {
+ return migratorAnalyzeResult;
+ }
+ }
+
+ private static int getVersion(Method method) {
+ Matcher matcher = migrateMethodPattern.matcher(method.getName());
+ if (matcher.find()) {
+ int migrateVersion = Integer.parseInt(matcher.group(1));
+ if (migrateVersion == 0) {
+ throw new RuntimeException("Invalid migrate method name: " + method.getName());
+ }
+ return migrateVersion;
+ } else
+ return 0;
+ }
+
+ public static String getVersion(Class<?> migratorClass) {
+ List<String> versionParts = new ArrayList<String>();
+ Class<?> current = migratorClass;
+ while (current != null && current != Object.class) {
+ versionParts.add(String.valueOf(getMigratorAnalyzeResult(current).getDataVersion()));
+ current = current.getSuperclass();
+ }
+ Collections.reverse(versionParts);
+ return StringUtils.join(versionParts, '.');
+ }
+
+ public static boolean migrate(String fromVersion, Object migrator, Object customData) {
+ Stack<Integer> versionParts = new Stack<Integer>();
+ for (String part: StringUtils.split(fromVersion, "."))
+ versionParts.push(Integer.valueOf(part));
+
+ boolean migrated = false;
+
+ Class<?> current = migrator.getClass();
+ while (current != null && current != Object.class) {
+ MigratorAnalyzeResult migratorAnalyzeResult = getMigratorAnalyzeResult(current);
+
+ int version;
+ if (!versionParts.empty())
+ version = versionParts.pop();
+ else
+ version = 0;
+ int size = migratorAnalyzeResult.getMigrateMethods().size();
+ int start;
+ if (version != 0) {
+ start = size;
+ for (int i=0; i<size; i++) {
+ Method method = migratorAnalyzeResult.getMigrateMethods().get(i);
+ if (method.getName().equals("migrate" + version)) {
+ start = i;
+ break;
+ }
+ }
+ if (start == size) {
+ logger.warn("Can not find migrate method (migrator: {}, method: {})",
+ current.getName(), "migrate" + version + "(Object)");
+ } else {
+ start++;
+ }
+ } else {
+ start = 0;
+ }
+
+ for (int i=start; i<size; i++) {
+ Method migrateMethod = migratorAnalyzeResult.getMigrateMethods().get(i);
+ int previousVersion;
+ if (i != 0) {
+ Method previousMigrateMethod =
+ migratorAnalyzeResult.getMigrateMethods().get(i-1);
+ previousVersion = migratorAnalyzeResult.getMigrateVersions()
+ .get(previousMigrateMethod.getName());
+ } else {
+ previousVersion = 0;
+ }
+ int currentVersion = migratorAnalyzeResult.getMigrateVersions()
+ .get(migrateMethod.getName());
+ Object[] params = new String[]{current.getName(),
+ String.valueOf(previousVersion),
+ String.valueOf(currentVersion)};
+ logger.debug("Migrating data (migrator: {}, from version: {}, " + "to version: {})", params);
+ try {
+ migrateMethod.invoke(migrator, customData, versionParts);
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ migrated = true;
+ }
+ current = current.getSuperclass();
+ }
+ return migrated;
+ }
+}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/MigrationListener.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/MigrationListener.java
new file mode 100644
index 0000000000..d16c4b3aec
--- /dev/null
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/MigrationListener.java
@@ -0,0 +1,7 @@
+package com.pmease.commons.hibernate.migration;
+
+public interface MigrationListener {
+
+ void afterMigration(Object bean);
+
+}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/Migrator.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/Migrator.java
new file mode 100644
index 0000000000..f1fa1a2cb1
--- /dev/null
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/Migrator.java
@@ -0,0 +1,5 @@
+package com.pmease.commons.hibernate.migration;
+
+public interface Migrator {
+
+}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/MigratorAnalyzeResult.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/MigratorAnalyzeResult.java
new file mode 100644
index 0000000000..4da5c791ae
--- /dev/null
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/MigratorAnalyzeResult.java
@@ -0,0 +1,30 @@
+package com.pmease.commons.hibernate.migration;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class MigratorAnalyzeResult {
+
+ private Map<String, Integer> migrateVersions = new HashMap<String, Integer>();
+
+ private List<Method> migrateMethods = new ArrayList<Method>();
+
+ public Map<String, Integer> getMigrateVersions() {
+ return migrateVersions;
+ }
+
+ public List<Method> getMigrateMethods() {
+ return migrateMethods;
+ }
+
+ public int getDataVersion() {
+ int size = migrateMethods.size();
+ if (size != 0)
+ return migrateVersions.get(migrateMethods.get(size - 1).getName());
+ else
+ return 0;
+ }
+}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/PersistentBagConverter.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/PersistentBagConverter.java
new file mode 100644
index 0000000000..4b6e92f551
--- /dev/null
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/PersistentBagConverter.java
@@ -0,0 +1,29 @@
+package com.pmease.commons.hibernate.migration;
+
+import java.util.ArrayList;
+
+import org.hibernate.collection.internal.PersistentBag;
+
+import com.thoughtworks.xstream.converters.MarshallingContext;
+import com.thoughtworks.xstream.converters.collections.CollectionConverter;
+import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
+import com.thoughtworks.xstream.mapper.Mapper;
+
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public class PersistentBagConverter extends CollectionConverter {
+
+ public PersistentBagConverter(Mapper mapper) {
+ super(mapper);
+ }
+
+ public void marshal(Object source, HierarchicalStreamWriter writer,
+ MarshallingContext context) {
+ source = new ArrayList((PersistentBag)source);
+ super.marshal(source, writer, context);
+ }
+
+ public boolean canConvert(Class type) {
+ return type == PersistentBag.class;
+ }
+
+}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/VersionTable.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/VersionTable.java
new file mode 100644
index 0000000000..6d3f07b189
--- /dev/null
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/VersionTable.java
@@ -0,0 +1,16 @@
+package com.pmease.commons.hibernate.migration;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+
+@Entity
+@Table
+public class VersionTable extends AbstractEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ public String versionColumn;
+
+}
diff --git a/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/VersionedDocument.java b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/VersionedDocument.java
new file mode 100644
index 0000000000..d0ba0d5160
--- /dev/null
+++ b/commons.hibernate/src/main/java/com/pmease/commons/hibernate/migration/VersionedDocument.java
@@ -0,0 +1,492 @@
+package com.pmease.commons.hibernate.migration;
+
+import java.io.ByteArrayOutputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Nullable;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.ObjectUtils.Null;
+import org.dom4j.Branch;
+import org.dom4j.Comment;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.DocumentType;
+import org.dom4j.Element;
+import org.dom4j.InvalidXPathException;
+import org.dom4j.Node;
+import org.dom4j.ProcessingInstruction;
+import org.dom4j.QName;
+import org.dom4j.Visitor;
+import org.dom4j.XPath;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+import org.dom4j.io.XPP3Reader;
+import org.xml.sax.EntityResolver;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
+import com.pmease.commons.loader.AppLoader;
+import com.pmease.commons.util.ClassUtils;
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.core.util.HierarchicalStreams;
+import com.thoughtworks.xstream.io.xml.Dom4JReader;
+import com.thoughtworks.xstream.io.xml.Dom4JWriter;
+import com.thoughtworks.xstream.mapper.CannotResolveClassException;
+
+public final class VersionedDocument implements Document, Externalizable {
+
+ private static final long serialVersionUID = 1L;
+
+ private transient String xml;
+
+ private transient Document wrapped;
+
+ public VersionedDocument() {
+ wrapped = DocumentHelper.createDocument();
+ }
+
+ public VersionedDocument(Document wrapped) {
+ this.wrapped = Preconditions.checkNotNull(wrapped);
+ }
+
+ public synchronized void setWrapped(Document wrapped) {
+ this.wrapped = Preconditions.checkNotNull(wrapped);
+ }
+
+ public Document addComment(String comment) {
+ return getWrapped().addComment(comment);
+ }
+
+ public Document addDocType(String name, String publicId, String systemId) {
+ return getWrapped().addDocType(name, publicId, systemId);
+ }
+
+ public Document addProcessingInstruction(String target, String text) {
+ return getWrapped().addProcessingInstruction(target, text);
+ }
+
+ public Document addProcessingInstruction(String target, Map<String, String> data) {
+ return getWrapped().addProcessingInstruction(target, data);
+ }
+
+ public DocumentType getDocType() {
+ return getWrapped().getDocType();
+ }
+
+ public EntityResolver getEntityResolver() {
+ return getWrapped().getEntityResolver();
+ }
+
+ public Element getRootElement() {
+ return getWrapped().getRootElement();
+ }
+
+ public String getXMLEncoding() {
+ return getWrapped().getXMLEncoding();
+ }
+
+ public void setDocType(DocumentType docType) {
+ getWrapped().setDocType(docType);
+ }
+
+ public void setEntityResolver(EntityResolver entityResolver) {
+ getWrapped().setEntityResolver(entityResolver);
+ }
+
+ public void setRootElement(Element rootElement) {
+ getWrapped().setRootElement(rootElement);
+ }
+
+ public void setXMLEncoding(String encoding) {
+ getWrapped().setXMLEncoding(encoding);
+ }
+
+ public void add(Node node) {
+ getWrapped().add(node);
+ }
+
+ public void add(Comment comment) {
+ getWrapped().add(comment);
+ }
+
+ public void add(Element element) {
+ getWrapped().add(element);
+ }
+
+ public void add(ProcessingInstruction pi) {
+ getWrapped().add(pi);
+ }
+
+ public Element addElement(String name) {
+ return getWrapped().addElement(name);
+ }
+
+ public Element addElement(QName qname) {
+ return getWrapped().addElement(qname);
+ }
+
+ public Element addElement(String qualifiedName, String namespaceURI) {
+ return getWrapped().addElement(qualifiedName, namespaceURI);
+ }
+
+ public void appendContent(Branch branch) {
+ getWrapped().appendContent(branch);
+ }
+
+ public void clearContent() {
+ getWrapped().clearContent();
+ }
+
+ public List<Node> content() {
+ return getWrapped().content();
+ }
+
+ public Element elementByID(String elementID) {
+ return getWrapped().elementByID(elementID);
+ }
+
+ public int indexOf(Node node) {
+ return getWrapped().indexOf(node);
+ }
+
+ public Node node(int index) throws IndexOutOfBoundsException {
+ return getWrapped().node(index);
+ }
+
+ public int nodeCount() {
+ return getWrapped().nodeCount();
+ }
+
+ public Iterator<Node> nodeIterator() {
+ return getWrapped().nodeIterator();
+ }
+
+ public void normalize() {
+ getWrapped().normalize();
+ }
+
+ public ProcessingInstruction processingInstruction(String target) {
+ return getWrapped().processingInstruction(target);
+ }
+
+ public List<ProcessingInstruction> processingInstructions() {
+ return getWrapped().processingInstructions();
+ }
+
+ public List<ProcessingInstruction> processingInstructions(String target) {
+ return getWrapped().processingInstructions(target);
+ }
+
+ public boolean remove(Node node) {
+ return getWrapped().remove(node);
+ }
+
+ public boolean remove(Comment comment) {
+ return getWrapped().remove(comment);
+ }
+
+ public boolean remove(Element element) {
+ return getWrapped().remove(element);
+ }
+
+ public boolean remove(ProcessingInstruction pi) {
+ return getWrapped().remove(pi);
+ }
+
+ public boolean removeProcessingInstruction(String target) {
+ return getWrapped().removeProcessingInstruction(target);
+ }
+
+ public void setContent(List<Node> content) {
+ getWrapped().setContent(content);
+ }
+
+ public void setProcessingInstructions(List<ProcessingInstruction> listOfPIs) {
+ getWrapped().setProcessingInstructions(listOfPIs);
+ }
+
+ public void accept(Visitor visitor) {
+ getWrapped().accept(visitor);
+ }
+
+ public String asXML() {
+ return getWrapped().asXML();
+ }
+
+ public Node asXPathResult(Element parent) {
+ return getWrapped().asXPathResult(parent);
+ }
+
+ public XPath createXPath(String xpathExpression)
+ throws InvalidXPathException {
+ return getWrapped().createXPath(xpathExpression);
+ }
+
+ public Node detach() {
+ return getWrapped().detach();
+ }
+
+ public Document getDocument() {
+ return getWrapped().getDocument();
+ }
+
+ public String getName() {
+ return getWrapped().getName();
+ }
+
+ public short getNodeType() {
+ return getWrapped().getNodeType();
+ }
+
+ public String getNodeTypeName() {
+ return getWrapped().getNodeTypeName();
+ }
+
+ public Element getParent() {
+ return getWrapped().getParent();
+ }
+
+ public String getPath() {
+ return getWrapped().getPath();
+ }
+
+ public String getPath(Element context) {
+ return getWrapped().getPath(context);
+ }
+
+ public String getStringValue() {
+ return getWrapped().getStringValue();
+ }
+
+ public String getText() {
+ return getWrapped().getText();
+ }
+
+ public String getUniquePath() {
+ return getWrapped().getUniquePath();
+ }
+
+ public String getUniquePath(Element context) {
+ return getWrapped().getUniquePath(context);
+ }
+
+ public boolean hasContent() {
+ return getWrapped().hasContent();
+ }
+
+ public boolean isReadOnly() {
+ return getWrapped().isReadOnly();
+ }
+
+ public boolean matches(String xpathExpression) {
+ return getWrapped().matches(xpathExpression);
+ }
+
+ public Number numberValueOf(String xpathExpression) {
+ return getWrapped().numberValueOf(xpathExpression);
+ }
+
+ public List<Node> selectNodes(String xpathExpression) {
+ return getWrapped().selectNodes(xpathExpression);
+ }
+
+ public List<Node> selectNodes(String xpathExpression,
+ String comparisonXPathExpression) {
+ return getWrapped().selectNodes(xpathExpression, comparisonXPathExpression);
+ }
+
+ public List<Node> selectNodes(String xpathExpression,
+ String comparisonXPathExpression, boolean removeDuplicates) {
+ return getWrapped().selectNodes(xpathExpression, comparisonXPathExpression,
+ removeDuplicates);
+ }
+
+ public Object selectObject(String xpathExpression) {
+ return getWrapped().selectObject(xpathExpression);
+ }
+
+ public Node selectSingleNode(String xpathExpression) {
+ return getWrapped().selectSingleNode(xpathExpression);
+ }
+
+ public void setDocument(Document document) {
+ getWrapped().setDocument(document);
+ }
+
+ public void setName(String name) {
+ getWrapped().setName(name);
+ }
+
+ public void setParent(Element parent) {
+ getWrapped().setParent(parent);
+ }
+
+ public void setText(String text) {
+ getWrapped().setText(text);
+ }
+
+ public boolean supportsParent() {
+ return getWrapped().supportsParent();
+ }
+
+ public String valueOf(String xpathExpression) {
+ return getWrapped().valueOf(xpathExpression);
+ }
+
+ public void write(Writer writer) throws IOException {
+ getWrapped().write(writer);
+ }
+
+ @Override
+ public Object clone() {
+ return new VersionedDocument((Document) getWrapped().clone());
+ }
+
+ public String toXML() {
+ return toXML(true);
+ }
+
+ public String toXML(boolean pretty) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ OutputFormat format = new OutputFormat();
+ format.setEncoding(Charsets.UTF_8.name());
+ if (pretty) {
+ format.setIndent(true);
+ format.setNewlines(true);
+ } else {
+ format.setIndent(false);
+ format.setNewlines(false);
+ }
+ new XMLWriter(baos, format).write(getWrapped());
+ return baos.toString(Charsets.UTF_8.name());
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ public static VersionedDocument fromXML(String xml) {
+ try {
+ return new VersionedDocument(new XPP3Reader().read(xml.toCharArray()));
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ public synchronized Document getWrapped() {
+ if (wrapped == null) {
+ wrapped = fromXML(Preconditions.checkNotNull(xml)).getWrapped();
+ }
+ return wrapped;
+ }
+
+ public static VersionedDocument fromBean(@Nullable Object bean) {
+ Document dom = DocumentHelper.createDocument();
+ AppLoader.getInstance(XStream.class).marshal(bean, new Dom4JWriter(dom));
+ VersionedDocument versionedDom = new VersionedDocument(dom);
+ if (bean != null) {
+ versionedDom.setVersion(MigrationHelper.getVersion(ClassUtils.unproxy(bean.getClass())));
+ }
+ return versionedDom;
+ }
+
+ /**
+ * Convert this document to bean. Migration will performed if necessary.
+ * During the migration, content of the document will also get updated
+ * to reflect current migration result.
+ * @return
+ */
+ public Object toBean() {
+ return toBean(null);
+ }
+
+ /**
+ * Convert this document to bean. Migration will performed if necessary.
+ * During the migration, content of the document will also get updated
+ * to reflect current migration result.
+ * @return
+ */
+ public Object toBean(MigrationListener listener) {
+ return toBean(listener, null);
+ }
+
+ /**
+ * Convert this document to bean. Migration will performed if necessary.
+ * During the migration, content of the document will also get updated
+ * to reflect current migration result.
+ * @return
+ */
+ public Object toBean(MigrationListener listener, Class<?> beanClass) {
+ XStream xstream = AppLoader.getInstance(XStream.class);
+ Dom4JReader domReader = new Dom4JReader(this);
+ Class<?> origBeanClass;
+ try {
+ origBeanClass = HierarchicalStreams.readClassType(domReader, xstream.getMapper());
+ } catch (CannotResolveClassException e) {
+ if (beanClass == null)
+ throw e;
+ else
+ origBeanClass = beanClass;
+ }
+
+ if (origBeanClass == null)
+ return null;
+ else if (origBeanClass == Null.class)
+ return ObjectUtils.NULL;
+
+ if (beanClass == null)
+ beanClass = origBeanClass;
+ else
+ getRootElement().setName(xstream.getMapper().serializedClass(beanClass));
+ if (getVersion() != null) {
+ try {
+ Object migrator = beanClass.newInstance();
+ if (MigrationHelper.migrate(getVersion(), migrator, this)) {
+ setVersion(MigrationHelper.getVersion(migrator.getClass()));
+ Object bean = xstream.unmarshal(domReader);
+ if (listener != null)
+ listener.afterMigration(bean);
+ return bean;
+ } else {
+ return xstream.unmarshal(domReader);
+ }
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ return xstream.unmarshal(domReader);
+ }
+ }
+
+ public String getVersion() {
+ Preconditions.checkNotNull(getRootElement());
+ return getRootElement().attributeValue("revision");
+ }
+
+ public void setVersion(String version) {
+ Preconditions.checkNotNull(getRootElement());
+ getRootElement().addAttribute("revision", version);
+ }
+
+ public synchronized void writeExternal(ObjectOutput out) throws IOException {
+ if (wrapped != null)
+ out.writeObject(toXML(false));
+ else
+ out.writeObject(xml);
+ }
+
+ public synchronized void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ xml = Preconditions.checkNotNull((String) in.readObject());
+ wrapped = null;
+ }
+
+}
diff --git a/commons.jackson/src/main/java/com/pmease/commons/jackson/ObjectMapperProvider.java b/commons.jackson/src/main/java/com/pmease/commons/jackson/ObjectMapperProvider.java
index 642420e085..37bc6c527c 100644
--- a/commons.jackson/src/main/java/com/pmease/commons/jackson/ObjectMapperProvider.java
+++ b/commons.jackson/src/main/java/com/pmease/commons/jackson/ObjectMapperProvider.java
@@ -69,7 +69,7 @@ public class ObjectMapperProvider implements Provider<ObjectMapper> {
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE);
- mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
+ mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
for (ObjectMapperConfigurator each: configurators)
each.configure(mapper);
diff --git a/commons.loader/src/main/java/com/pmease/commons/loader/AppLoader.java b/commons.loader/src/main/java/com/pmease/commons/loader/AppLoader.java
index 548e526f55..61366df53e 100644
--- a/commons.loader/src/main/java/com/pmease/commons/loader/AppLoader.java
+++ b/commons.loader/src/main/java/com/pmease/commons/loader/AppLoader.java
@@ -63,8 +63,7 @@ public class AppLoader implements Startable {
throw new RuntimeException(e);
}
} else if (!tempDir.mkdir()) {
- throw new RuntimeException("Can not create directory '" +
- tempDir.getAbsolutePath() + "'.");
+ throw new RuntimeException("Can not create directory '" + tempDir.getAbsolutePath() + "'.");
}
System.setProperty("java.io.tmpdir", tempDir.getAbsolutePath());
diff --git a/commons.schedule/src/main/java/com/pmease/commons/schedule/DefaultTaskScheduler.java b/commons.schedule/src/main/java/com/pmease/commons/schedule/DefaultTaskScheduler.java
index 328e8eea79..f885aeb776 100644
--- a/commons.schedule/src/main/java/com/pmease/commons/schedule/DefaultTaskScheduler.java
+++ b/commons.schedule/src/main/java/com/pmease/commons/schedule/DefaultTaskScheduler.java
@@ -16,10 +16,14 @@ import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Singleton
public class DefaultTaskScheduler implements TaskScheduler {
+ private static final Logger logger = LoggerFactory.getLogger(DefaultTaskScheduler.class);
+
private Scheduler quartz;
public DefaultTaskScheduler() {
@@ -86,11 +90,13 @@ public class DefaultTaskScheduler implements TaskScheduler {
public static class HelperTask implements Job {
- public void execute(JobExecutionContext context)
- throws JobExecutionException {
- SchedulableTask task = (SchedulableTask) context.getTrigger()
- .getJobDataMap().get("task");
- task.execute();
+ public void execute(JobExecutionContext context) throws JobExecutionException {
+ SchedulableTask task = (SchedulableTask) context.getTrigger().getJobDataMap().get("task");
+ try {
+ task.execute();
+ } catch (Exception e) {
+ logger.error("Error executing scheduled task", e);
+ }
}
}
diff --git a/commons.util/pom.xml b/commons.util/pom.xml
index ea4a2db295..4c19ca9fb7 100644
--- a/commons.util/pom.xml
+++ b/commons.util/pom.xml
@@ -57,10 +57,6 @@
<artifactId>commons.bootstrap</artifactId>
<version>1.0.31</version>
</dependency>
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
diff --git a/commons.util/src/main/java/com/pmease/commons/util/BeanUtils.java b/commons.util/src/main/java/com/pmease/commons/util/BeanUtils.java
index 8359329efa..82ee0dbed5 100644
--- a/commons.util/src/main/java/com/pmease/commons/util/BeanUtils.java
+++ b/commons.util/src/main/java/com/pmease/commons/util/BeanUtils.java
@@ -1,11 +1,14 @@
package com.pmease.commons.util;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import com.google.common.base.Preconditions;
@@ -28,6 +31,28 @@ public class BeanUtils {
}
}
+ /**
+ * Get declared fields in the whole class hierarchy.
+ * If there are fields with the same name in super-class and sub-class,
+ * fields in the sub-class with be returned only.
+ */
+ public static List<Field> getFields(Class<?> clazz) {
+ List<Field> fields = new ArrayList<Field>();
+ Set<String> existingNames = new HashSet<String>();
+
+ Class<?> current = clazz;
+ while (current != null) {
+ for (Field field: current.getDeclaredFields()) {
+ if (!Modifier.isStatic(field.getModifiers()) && !existingNames.contains(field.getName())) {
+ fields.add(field);
+ existingNames.add(field.getName());
+ }
+ }
+ current = current.getSuperclass();
+ }
+ return fields;
+ }
+
/**
* Get suffix of accessor method name for specified property. For instance,
* getter suffix for property &quot;value&quot; would be &quot;Value&quot;.
diff --git a/commons.util/src/main/java/com/pmease/commons/util/ClassUtils.java b/commons.util/src/main/java/com/pmease/commons/util/ClassUtils.java
index 0b231bdf79..3f955dde8f 100644
--- a/commons.util/src/main/java/com/pmease/commons/util/ClassUtils.java
+++ b/commons.util/src/main/java/com/pmease/commons/util/ClassUtils.java
@@ -129,4 +129,13 @@ public class ClassUtils extends org.apache.commons.lang3.ClassUtils {
superClass = (Class<T>) clazz.getSuperclass();
return superClass;
}
+
+ public static boolean isSystemType(Class<?> type) {
+ return type.getName().startsWith("java")
+ || type.getName().startsWith("javax")
+ || type.isArray()
+ || type.isPrimitive()
+ || type.isEnum();
+ }
+
}
diff --git a/commons.util/src/main/java/com/pmease/commons/util/ReflectionUtils.java b/commons.util/src/main/java/com/pmease/commons/util/ReflectionUtils.java
index fdfa47f55e..341a8d9e1c 100644
--- a/commons.util/src/main/java/com/pmease/commons/util/ReflectionUtils.java
+++ b/commons.util/src/main/java/com/pmease/commons/util/ReflectionUtils.java
@@ -10,6 +10,7 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -379,4 +380,57 @@ public class ReflectionUtils {
return null;
}
+ public static Class<?> getCollectionElementType(Type type) {
+ if (type instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType)type;
+ Type rawType = parameterizedType.getRawType();
+ if (rawType instanceof Class<?>) {
+ Class<?> rawClazz = (Class<?>) rawType;
+ if (Collection.class.isAssignableFrom(rawClazz)) {
+ Type elementType = parameterizedType.getActualTypeArguments()[0];
+ if (elementType instanceof Class<?>)
+ return (Class<?>) elementType;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static Class<?> getMapKeyType(Type type) {
+ if (type instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType)type;
+ Type rawType = parameterizedType.getRawType();
+
+ if (rawType instanceof Class<?>) {
+ Class<?> rawClazz = (Class<?>) rawType;
+ if (Map.class.isAssignableFrom(rawClazz)) {
+ Type valueType = parameterizedType.getActualTypeArguments()[0];
+ if (valueType instanceof Class<?>)
+ return (Class<?>) valueType;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static Class<?> getMapValueType(Type type) {
+ if (type instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType)type;
+ Type rawType = parameterizedType.getRawType();
+
+ if (rawType instanceof Class<?>) {
+ Class<?> rawClazz = (Class<?>) rawType;
+ if (Map.class.isAssignableFrom(rawClazz)) {
+ Type valueType = parameterizedType.getActualTypeArguments()[1];
+ if (valueType instanceof Class<?>) {
+ return (Class<?>) valueType;
+ } else if (valueType instanceof ParameterizedType) {
+ return (Class<?>) ((ParameterizedType)valueType).getRawType();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
}
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/concrete/ConcreteListPropertyEditor.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/concrete/ConcreteListPropertyEditor.java
index 773fd66c7d..5b9fefabee 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/concrete/ConcreteListPropertyEditor.java
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/list/concrete/ConcreteListPropertyEditor.java
@@ -1,374 +1,374 @@
-package com.pmease.commons.wicket.editable.list.concrete;
-
-import static de.agilecoders.wicket.jquery.JQuery.$;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.Component;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.ajax.markup.html.form.AjaxButton;
-import org.apache.wicket.behavior.AttributeAppender;
-import org.apache.wicket.feedback.FeedbackMessage;
-import org.apache.wicket.feedback.FencedFeedbackPanel;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.CheckBox;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.repeater.RepeatingView;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.util.convert.ConversionException;
-
-import com.pmease.commons.util.ClassUtils;
-import com.pmease.commons.wicket.behavior.sortable.SortBehavior;
-import com.pmease.commons.wicket.behavior.sortable.SortPosition;
-import com.pmease.commons.wicket.editable.DefaultBeanDescriptor;
-import com.pmease.commons.wicket.editable.EditableUtils;
-import com.pmease.commons.wicket.editable.ErrorContext;
-import com.pmease.commons.wicket.editable.PathSegment;
-import com.pmease.commons.wicket.editable.PathSegment.Property;
-import com.pmease.commons.wicket.editable.PropertyContext;
-import com.pmease.commons.wicket.editable.PropertyDescriptor;
-import com.pmease.commons.wicket.editable.PropertyEditor;
-
-@SuppressWarnings("serial")
-public class ConcreteListPropertyEditor extends PropertyEditor<List<Serializable>> {
-
- private final List<PropertyContext<Serializable>> propertyContexts;
-
- private final Class<?> elementClass;
-
- public ConcreteListPropertyEditor(String id, PropertyDescriptor propertyDescriptor, IModel<List<Serializable>> model) {
- super(id, propertyDescriptor, model);
-
- elementClass = EditableUtils.getElementClass(propertyDescriptor.getPropertyGetter().getGenericReturnType());
-
- propertyContexts = new ArrayList<>();
-
- for (PropertyDescriptor each: new DefaultBeanDescriptor(elementClass).getPropertyDescriptors()) {
- propertyContexts.add(PropertyContext.of(each));
- }
-
- }
-
- @SuppressWarnings("unchecked")
- private List<Serializable> newList() {
- if (ClassUtils.isConcrete(getPropertyDescriptor().getPropertyClass())) {
- try {
- return (List<Serializable>) getPropertyDescriptor().getPropertyClass().newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- } else {
- return new ArrayList<Serializable>();
- }
- }
-
- private Serializable newElement() {
- try {
- return (Serializable) elementClass.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- if (getPropertyDescriptor().isPropertyRequired()) {
- add(new WebMarkupContainer("enable").setVisible(false));
- } else {
- add(new CheckBox("enable", new IModel<Boolean>() {
-
- @Override
- public void detach() {
-
- }
-
- @Override
- public Boolean getObject() {
- return ConcreteListPropertyEditor.this.get("listEditor").isVisible();
- }
-
- @Override
- public void setObject(Boolean object) {
- ConcreteListPropertyEditor.this.get("listEditor").setVisible(object);
- }
-
- }).add(new AjaxFormComponentUpdatingBehavior("onclick") {
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- target.add(ConcreteListPropertyEditor.this.get("listEditor"));
- }
-
- }));
-
- }
-
- List<Serializable> list = getModelObject();
- if (list == null && getPropertyDescriptor().isPropertyRequired())
- list = newList();
- add(newListEditor(list));
- }
-
- private Component newListEditor(List<Serializable> list) {
- final WebMarkupContainer table = new WebMarkupContainer("listEditor");
-
- table.setOutputMarkupId(true);
- table.setOutputMarkupPlaceholderTag(true);
-
- table.add(new ListView<PropertyContext<Serializable>>("headers", propertyContexts) {
-
- @Override
- protected void populateItem(ListItem<PropertyContext<Serializable>> item) {
- item.add(new Label("header", EditableUtils.getName(item.getModelObject().getPropertyGetter())));
- item.add(AttributeAppender.append("class", " " + item.getModelObject().getPropertyName()));
-
- String required;
- if (item.getModelObject().isPropertyRequired() && item.getModelObject().getPropertyClass() != boolean.class)
- required = "*";
- else
- required = "&nbsp;";
-
- item.add(new Label("required", required).setEscapeModelStrings(false));
- }
-
- });
-
- final RepeatingView rows = new RepeatingView("elements");
- table.add(rows);
-
- if (list != null) {
- for (Serializable element: list) {
- addRow(rows, element);
- }
- } else {
- table.setVisible(false);
- }
-
- final WebMarkupContainer noElementsRow = new WebMarkupContainer("noElementsRow") {
-
- @Override
- protected void onConfigure() {
- super.onConfigure();
- setVisible(rows.size() == 0);
- }
-
- };
- noElementsRow.setOutputMarkupPlaceholderTag(true);
- table.add(noElementsRow);
-
- WebMarkupContainer noElementsColumn = new WebMarkupContainer("noElementsColumn");
- noElementsColumn.add(AttributeModifier.append("colspan", propertyContexts.size() + 1));
- noElementsRow.add(noElementsColumn);
-
- WebMarkupContainer newRow = new WebMarkupContainer("newRow");
- newRow.add(AttributeModifier.append("colspan", propertyContexts.size() + 1));
- newRow.add(new AjaxButton("addElement") {
-
- @SuppressWarnings("deprecation")
- @Override
- protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
- super.onSubmit(target, form);
-
- Component lastRow;
- if (rows.size() != 0)
- lastRow = rows.get(rows.size() - 1);
- else
- lastRow = null;
-
- Component newRow = addRow(rows, newElement());
- String script = String.format("$('<tr id=\"%s\"></tr>')", newRow.getMarkupId());
- if (lastRow != null)
- script += ".insertAfter('#" + lastRow.getMarkupId() + "');";
- else
- script += ".appendTo('#" + table.getMarkupId() + ">tbody');";
-
- target.prependJavaScript(script);
- target.add(newRow);
-
- if (rows.size() == 1)
- target.add(noElementsRow);
-
- //target.focusComponent(newRow);
- //target.add(TableListPropertyEditor.this.get("listEditor"));
- }
-
- }.setDefaultFormProcessing(false));
-
- table.add(newRow);
-
- table.add(new SortBehavior() {
-
- @SuppressWarnings("deprecation")
- @Override
- protected void onSort(AjaxRequestTarget target, SortPosition from, SortPosition to) {
- /*
- List<Component> children = new ArrayList<>();
- for (Component child: rows)
- children.add(child);
-
- Component fromChild = children.remove(from.getItemIndex());
- children.add(to.getItemIndex(), fromChild);
-
- rows.removeAll();
- for (Component child: children)
- rows.add(child);
- */
-
- // Do not use code above as removing components outside of a container and add again
- // can cause the fenced feedback panel not functioning properly
- int fromIndex = from.getItemIndex()-1;
- int toIndex = to.getItemIndex()-1;
- if (fromIndex < toIndex) {
- for (int i=0; i<toIndex-fromIndex; i++)
- rows.swap(fromIndex+i, fromIndex+i+1);
- } else {
- for (int i=0; i<fromIndex-toIndex; i++)
- rows.swap(fromIndex-i, fromIndex-i-1);
- }
- }
-
- }.sortable("tbody").handle(".handle").helperClass("sort-helper"));
-
- return table;
- }
-
- private WebMarkupContainer addRow(final RepeatingView rows, Serializable element) {
- final WebMarkupContainer row = new WebMarkupContainer(rows.newChildId());
- row.setOutputMarkupId(true);
- rows.add(row);
-
- RepeatingView columns = new RepeatingView("properties");
- row.add(columns);
-
- for (PropertyContext<Serializable> propertyContext: propertyContexts) {
- WebMarkupContainer column = new WebMarkupContainer(columns.newChildId());
- column.add(AttributeAppender.append("class", " " + propertyContext.getPropertyName()));
- columns.add(column);
-
- Serializable propertyValue = (Serializable) propertyContext.getPropertyValue(element);
- PropertyEditor<?> propertyEditor = propertyContext.renderForEdit("propertyEditor", Model.of(propertyValue));
- column.add(propertyEditor);
- column.add(new FencedFeedbackPanel("feedback", propertyEditor));
- }
-
- row.add(new AjaxButton("deleteElement") {
-
- @Override
- protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
- super.onSubmit(target, form);
-
- target.appendJavaScript($(row).chain("remove").get());
- rows.remove(row);
-
- if (rows.size() == 0) {
- WebMarkupContainer table = (WebMarkupContainer) ConcreteListPropertyEditor.this.get("listEditor");
- target.add(table.get("noElementsRow"));
- }
- //target.add(TableListPropertyEditor.this.get("listEditor"));
- //target.focusComponent(null);
- }
-
- }.setDefaultFormProcessing(false));
-
- return row;
- }
-
- @SuppressWarnings("unchecked")
- private List<PropertyEditor<Serializable>> getPropertyEditorsAtRow(int index) {
- WebMarkupContainer table = (WebMarkupContainer) get("listEditor");
- RepeatingView rows = (RepeatingView) table.get("elements");
-
- int currentIndex = 0;
- Iterator<Component> it = rows.iterator();
- Component row = it.next();
- while (currentIndex++ < index) {
- row = it.next();
- }
-
- List<PropertyEditor<Serializable>> propertyEditors = new ArrayList<>();
- RepeatingView columns = (RepeatingView) row.get("properties");
- for (Component column: columns) {
- propertyEditors.add((PropertyEditor<Serializable>) column.get("propertyEditor"));
- }
-
- return propertyEditors;
- }
-
- @Override
- public ErrorContext getErrorContext(PathSegment pathSegment) {
- final int index = ((PathSegment.Element) pathSegment).getIndex();
- final String messagePrefix = "Item " + (index+1) + ": ";
-
- return new ErrorContext() {
-
- @Override
- public void addError(String errorMessage) {
- error(messagePrefix + errorMessage);
- }
-
- @Override
- public boolean hasErrors(boolean recursive) {
- for (FeedbackMessage message: getFeedbackMessages()) {
- if (message.getMessage().toString().startsWith(messagePrefix)) {
- return true;
- }
- }
-
- if (recursive) {
- for (PropertyEditor<Serializable> propertyEditor: getPropertyEditorsAtRow(index)) {
- if (propertyEditor.hasErrors(true))
- return true;
- }
- }
- return false;
- }
-
- @Override
- public ErrorContext getErrorContext(PathSegment pathSegment) {
- PathSegment.Property property = (Property) pathSegment;
-
- for (PropertyEditor<Serializable> propertyEditor: getPropertyEditorsAtRow(index)) {
- if (propertyEditor.getPropertyDescriptor().getPropertyName().equals(property.getName()))
- return propertyEditor;
- }
- return null;
- }
-
- };
- }
-
- @Override
- protected List<Serializable> convertInputToValue() throws ConversionException {
- if (get("listEditor").isVisible()) {
- List<Serializable> newList = newList();
-
- RepeatingView rows = (RepeatingView) get("listEditor").get("elements");
- for (Component row: rows) {
- Serializable element = newElement();
- newList.add(element);
-
- RepeatingView columns = (RepeatingView) row.get("properties");
- for (Component column: columns) {
- @SuppressWarnings("unchecked")
- PropertyEditor<Serializable> propertyEditor = (PropertyEditor<Serializable>) column.get("propertyEditor");
-
- propertyEditor.getPropertyDescriptor().setPropertyValue(element, propertyEditor.getConvertedInput());
- }
- }
- return newList;
- } else {
- return null;
- }
- }
-}
+package com.pmease.commons.wicket.editable.list.concrete;
+
+import static de.agilecoders.wicket.jquery.JQuery.$;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;
+import org.apache.wicket.behavior.AttributeAppender;
+import org.apache.wicket.feedback.FeedbackMessage;
+import org.apache.wicket.feedback.FencedFeedbackPanel;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.CheckBox;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.repeater.RepeatingView;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.util.convert.ConversionException;
+
+import com.pmease.commons.util.ClassUtils;
+import com.pmease.commons.wicket.behavior.sortable.SortBehavior;
+import com.pmease.commons.wicket.behavior.sortable.SortPosition;
+import com.pmease.commons.wicket.editable.DefaultBeanDescriptor;
+import com.pmease.commons.wicket.editable.EditableUtils;
+import com.pmease.commons.wicket.editable.ErrorContext;
+import com.pmease.commons.wicket.editable.PathSegment;
+import com.pmease.commons.wicket.editable.PathSegment.Property;
+import com.pmease.commons.wicket.editable.PropertyContext;
+import com.pmease.commons.wicket.editable.PropertyDescriptor;
+import com.pmease.commons.wicket.editable.PropertyEditor;
+
+@SuppressWarnings("serial")
+public class ConcreteListPropertyEditor extends PropertyEditor<List<Serializable>> {
+
+ private final List<PropertyContext<Serializable>> propertyContexts;
+
+ private final Class<?> elementClass;
+
+ public ConcreteListPropertyEditor(String id, PropertyDescriptor propertyDescriptor, IModel<List<Serializable>> model) {
+ super(id, propertyDescriptor, model);
+
+ elementClass = EditableUtils.getElementClass(propertyDescriptor.getPropertyGetter().getGenericReturnType());
+
+ propertyContexts = new ArrayList<>();
+
+ for (PropertyDescriptor each: new DefaultBeanDescriptor(elementClass).getPropertyDescriptors()) {
+ propertyContexts.add(PropertyContext.of(each));
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private List<Serializable> newList() {
+ if (ClassUtils.isConcrete(getPropertyDescriptor().getPropertyClass())) {
+ try {
+ return (List<Serializable>) getPropertyDescriptor().getPropertyClass().newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ return new ArrayList<Serializable>();
+ }
+ }
+
+ private Serializable newElement() {
+ try {
+ return (Serializable) elementClass.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ if (getPropertyDescriptor().isPropertyRequired()) {
+ add(new WebMarkupContainer("enable").setVisible(false));
+ } else {
+ add(new CheckBox("enable", new IModel<Boolean>() {
+
+ @Override
+ public void detach() {
+
+ }
+
+ @Override
+ public Boolean getObject() {
+ return ConcreteListPropertyEditor.this.get("listEditor").isVisible();
+ }
+
+ @Override
+ public void setObject(Boolean object) {
+ ConcreteListPropertyEditor.this.get("listEditor").setVisible(object);
+ }
+
+ }).add(new AjaxFormComponentUpdatingBehavior("click") {
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ target.add(ConcreteListPropertyEditor.this.get("listEditor"));
+ }
+
+ }));
+
+ }
+
+ List<Serializable> list = getModelObject();
+ if (list == null && getPropertyDescriptor().isPropertyRequired())
+ list = newList();
+ add(newListEditor(list));
+ }
+
+ private Component newListEditor(List<Serializable> list) {
+ final WebMarkupContainer table = new WebMarkupContainer("listEditor");
+
+ table.setOutputMarkupId(true);
+ table.setOutputMarkupPlaceholderTag(true);
+
+ table.add(new ListView<PropertyContext<Serializable>>("headers", propertyContexts) {
+
+ @Override
+ protected void populateItem(ListItem<PropertyContext<Serializable>> item) {
+ item.add(new Label("header", EditableUtils.getName(item.getModelObject().getPropertyGetter())));
+ item.add(AttributeAppender.append("class", " " + item.getModelObject().getPropertyName()));
+
+ String required;
+ if (item.getModelObject().isPropertyRequired() && item.getModelObject().getPropertyClass() != boolean.class)
+ required = "*";
+ else
+ required = "&nbsp;";
+
+ item.add(new Label("required", required).setEscapeModelStrings(false));
+ }
+
+ });
+
+ final RepeatingView rows = new RepeatingView("elements");
+ table.add(rows);
+
+ if (list != null) {
+ for (Serializable element: list) {
+ addRow(rows, element);
+ }
+ } else {
+ table.setVisible(false);
+ }
+
+ final WebMarkupContainer noElementsRow = new WebMarkupContainer("noElementsRow") {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisible(rows.size() == 0);
+ }
+
+ };
+ noElementsRow.setOutputMarkupPlaceholderTag(true);
+ table.add(noElementsRow);
+
+ WebMarkupContainer noElementsColumn = new WebMarkupContainer("noElementsColumn");
+ noElementsColumn.add(AttributeModifier.append("colspan", propertyContexts.size() + 1));
+ noElementsRow.add(noElementsColumn);
+
+ WebMarkupContainer newRow = new WebMarkupContainer("newRow");
+ newRow.add(AttributeModifier.append("colspan", propertyContexts.size() + 1));
+ newRow.add(new AjaxButton("addElement") {
+
+ @SuppressWarnings("deprecation")
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ super.onSubmit(target, form);
+
+ Component lastRow;
+ if (rows.size() != 0)
+ lastRow = rows.get(rows.size() - 1);
+ else
+ lastRow = null;
+
+ Component newRow = addRow(rows, newElement());
+ String script = String.format("$('<tr id=\"%s\"></tr>')", newRow.getMarkupId());
+ if (lastRow != null)
+ script += ".insertAfter('#" + lastRow.getMarkupId() + "');";
+ else
+ script += ".appendTo('#" + table.getMarkupId() + ">tbody');";
+
+ target.prependJavaScript(script);
+ target.add(newRow);
+
+ if (rows.size() == 1)
+ target.add(noElementsRow);
+
+ //target.focusComponent(newRow);
+ //target.add(TableListPropertyEditor.this.get("listEditor"));
+ }
+
+ }.setDefaultFormProcessing(false));
+
+ table.add(newRow);
+
+ table.add(new SortBehavior() {
+
+ @SuppressWarnings("deprecation")
+ @Override
+ protected void onSort(AjaxRequestTarget target, SortPosition from, SortPosition to) {
+ /*
+ List<Component> children = new ArrayList<>();
+ for (Component child: rows)
+ children.add(child);
+
+ Component fromChild = children.remove(from.getItemIndex());
+ children.add(to.getItemIndex(), fromChild);
+
+ rows.removeAll();
+ for (Component child: children)
+ rows.add(child);
+ */
+
+ // Do not use code above as removing components outside of a container and add again
+ // can cause the fenced feedback panel not functioning properly
+ int fromIndex = from.getItemIndex()-1;
+ int toIndex = to.getItemIndex()-1;
+ if (fromIndex < toIndex) {
+ for (int i=0; i<toIndex-fromIndex; i++)
+ rows.swap(fromIndex+i, fromIndex+i+1);
+ } else {
+ for (int i=0; i<fromIndex-toIndex; i++)
+ rows.swap(fromIndex-i, fromIndex-i-1);
+ }
+ }
+
+ }.sortable("tbody").handle(".handle").helperClass("sort-helper"));
+
+ return table;
+ }
+
+ private WebMarkupContainer addRow(final RepeatingView rows, Serializable element) {
+ final WebMarkupContainer row = new WebMarkupContainer(rows.newChildId());
+ row.setOutputMarkupId(true);
+ rows.add(row);
+
+ RepeatingView columns = new RepeatingView("properties");
+ row.add(columns);
+
+ for (PropertyContext<Serializable> propertyContext: propertyContexts) {
+ WebMarkupContainer column = new WebMarkupContainer(columns.newChildId());
+ column.add(AttributeAppender.append("class", " " + propertyContext.getPropertyName()));
+ columns.add(column);
+
+ Serializable propertyValue = (Serializable) propertyContext.getPropertyValue(element);
+ PropertyEditor<?> propertyEditor = propertyContext.renderForEdit("propertyEditor", Model.of(propertyValue));
+ column.add(propertyEditor);
+ column.add(new FencedFeedbackPanel("feedback", propertyEditor));
+ }
+
+ row.add(new AjaxButton("deleteElement") {
+
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ super.onSubmit(target, form);
+
+ target.appendJavaScript($(row).chain("remove").get());
+ rows.remove(row);
+
+ if (rows.size() == 0) {
+ WebMarkupContainer table = (WebMarkupContainer) ConcreteListPropertyEditor.this.get("listEditor");
+ target.add(table.get("noElementsRow"));
+ }
+ //target.add(TableListPropertyEditor.this.get("listEditor"));
+ //target.focusComponent(null);
+ }
+
+ }.setDefaultFormProcessing(false));
+
+ return row;
+ }
+
+ @SuppressWarnings("unchecked")
+ private List<PropertyEditor<Serializable>> getPropertyEditorsAtRow(int index) {
+ WebMarkupContainer table = (WebMarkupContainer) get("listEditor");
+ RepeatingView rows = (RepeatingView) table.get("elements");
+
+ int currentIndex = 0;
+ Iterator<Component> it = rows.iterator();
+ Component row = it.next();
+ while (currentIndex++ < index) {
+ row = it.next();
+ }
+
+ List<PropertyEditor<Serializable>> propertyEditors = new ArrayList<>();
+ RepeatingView columns = (RepeatingView) row.get("properties");
+ for (Component column: columns) {
+ propertyEditors.add((PropertyEditor<Serializable>) column.get("propertyEditor"));
+ }
+
+ return propertyEditors;
+ }
+
+ @Override
+ public ErrorContext getErrorContext(PathSegment pathSegment) {
+ final int index = ((PathSegment.Element) pathSegment).getIndex();
+ final String messagePrefix = "Item " + (index+1) + ": ";
+
+ return new ErrorContext() {
+
+ @Override
+ public void addError(String errorMessage) {
+ error(messagePrefix + errorMessage);
+ }
+
+ @Override
+ public boolean hasErrors(boolean recursive) {
+ for (FeedbackMessage message: getFeedbackMessages()) {
+ if (message.getMessage().toString().startsWith(messagePrefix)) {
+ return true;
+ }
+ }
+
+ if (recursive) {
+ for (PropertyEditor<Serializable> propertyEditor: getPropertyEditorsAtRow(index)) {
+ if (propertyEditor.hasErrors(true))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public ErrorContext getErrorContext(PathSegment pathSegment) {
+ PathSegment.Property property = (Property) pathSegment;
+
+ for (PropertyEditor<Serializable> propertyEditor: getPropertyEditorsAtRow(index)) {
+ if (propertyEditor.getPropertyDescriptor().getPropertyName().equals(property.getName()))
+ return propertyEditor;
+ }
+ return null;
+ }
+
+ };
+ }
+
+ @Override
+ protected List<Serializable> convertInputToValue() throws ConversionException {
+ if (get("listEditor").isVisible()) {
+ List<Serializable> newList = newList();
+
+ RepeatingView rows = (RepeatingView) get("listEditor").get("elements");
+ for (Component row: rows) {
+ Serializable element = newElement();
+ newList.add(element);
+
+ RepeatingView columns = (RepeatingView) row.get("properties");
+ for (Component column: columns) {
+ @SuppressWarnings("unchecked")
+ PropertyEditor<Serializable> propertyEditor = (PropertyEditor<Serializable>) column.get("propertyEditor");
+
+ propertyEditor.getPropertyDescriptor().setPropertyValue(element, propertyEditor.getConvertedInput());
+ }
+ }
+ return newList;
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditor.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditor.java
index 445f89cd94..e719df9b23 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditor.java
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/editable/reflection/ReflectionPropertyEditor.java
@@ -55,7 +55,7 @@ public class ReflectionPropertyEditor extends PropertyEditor<Serializable> {
}
}
- }).add(new AjaxFormComponentUpdatingBehavior("onclick"){
+ }).add(new AjaxFormComponentUpdatingBehavior("click"){
@Override
protected void onUpdate(AjaxRequestTarget target) {
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/page/common.css b/commons.wicket/src/main/java/com/pmease/commons/wicket/page/common.css
index 08e6868433..83f2be35a4 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/page/common.css
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/page/common.css
@@ -233,6 +233,13 @@ form>.test-feedback {
margin-top: 12px;
}
+.value.editor.property>.bean.editor {
+ border-top: 1px dotted #BBB;
+ margin-top: 12px;
+ padding-top: 12px;
+ border-bottom: 1px dotted #BBB;
+ padding-bottom: 4px;
+}
.viewer .reflection>table>tbody>tr.name-omitted>td {
padding: 0;
}
diff --git a/gitplex.core/pom.xml b/gitplex.core/pom.xml
index 277d06acb5..7b6d8a5ede 100644
--- a/gitplex.core/pom.xml
+++ b/gitplex.core/pom.xml
@@ -1,113 +1,113 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>gitplex.core</artifactId>
- <parent>
- <groupId>com.pmease</groupId>
- <artifactId>parent.general</artifactId>
- <version>1.0.31</version>
- </parent>
- <build>
- <plugins>
- <plugin>
- <groupId>com.pmease</groupId>
- <artifactId>plugin.maven</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-archetype-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>com.pmease</groupId>
- <artifactId>commons.loader</artifactId>
- <version>1.0.31</version>
- </dependency>
- <dependency>
- <groupId>com.pmease</groupId>
- <artifactId>commons.git</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.xodus</groupId>
- <artifactId>xodus-entity-store</artifactId>
- </dependency>
- <dependency>
- <groupId>com.pmease</groupId>
- <artifactId>commons.git</artifactId>
- <version>1.0.0</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.pmease</groupId>
- <artifactId>commons.jetty</artifactId>
- <version>1.0.31</version>
- </dependency>
- <dependency>
- <groupId>com.pmease</groupId>
- <artifactId>commons.loader</artifactId>
- <version>1.0.31</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.pmease</groupId>
- <artifactId>commons.schedule</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>com.pmease</groupId>
- <artifactId>commons.hibernate</artifactId>
- <version>1.0.30</version>
- </dependency>
- <dependency>
- <groupId>com.pmease</groupId>
- <artifactId>commons.shiro</artifactId>
- <version>1.0.30</version>
- </dependency>
- <dependency>
- <groupId>com.pmease</groupId>
- <artifactId>commons.markdown</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>com.pmease</groupId>
- <artifactId>commons.lang</artifactId>
- <version>1.0.0</version>
- </dependency>
- </dependencies>
- <repositories>
- <repository>
- <id>pmeaseRepo</id>
- <name>PMEase Repository</name>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- <url>http://artifact.pmease.com/</url>
- </repository>
- </repositories>
- <properties>
- <moduleClass>com.pmease.gitplex.core.CoreModule</moduleClass>
- </properties>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>gitplex.core</artifactId>
+ <parent>
+ <groupId>com.pmease</groupId>
+ <artifactId>parent.general</artifactId>
+ <version>1.0.31</version>
+ </parent>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.pmease</groupId>
+ <artifactId>plugin.maven</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>com.pmease</groupId>
+ <artifactId>commons.loader</artifactId>
+ <version>1.0.31</version>
+ </dependency>
+ <dependency>
+ <groupId>com.pmease</groupId>
+ <artifactId>commons.git</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.xodus</groupId>
+ <artifactId>xodus-entity-store</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.pmease</groupId>
+ <artifactId>commons.git</artifactId>
+ <version>1.0.0</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.pmease</groupId>
+ <artifactId>commons.jetty</artifactId>
+ <version>1.0.31</version>
+ </dependency>
+ <dependency>
+ <groupId>com.pmease</groupId>
+ <artifactId>commons.loader</artifactId>
+ <version>1.0.31</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.pmease</groupId>
+ <artifactId>commons.schedule</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.pmease</groupId>
+ <artifactId>commons.hibernate</artifactId>
+ <version>1.0.30</version>
+ </dependency>
+ <dependency>
+ <groupId>com.pmease</groupId>
+ <artifactId>commons.shiro</artifactId>
+ <version>1.0.30</version>
+ </dependency>
+ <dependency>
+ <groupId>com.pmease</groupId>
+ <artifactId>commons.markdown</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.pmease</groupId>
+ <artifactId>commons.lang</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+ <repositories>
+ <repository>
+ <id>pmeaseRepo</id>
+ <name>PMEase Repository</name>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ <url>http://artifact.pmease.com/</url>
+ </repository>
+ </repositories>
+ <properties>
+ <moduleClass>com.pmease.gitplex.core.CoreModule</moduleClass>
+ </properties>
+</project>
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java
index 659b3842bd..ecd0fcc2c5 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/CoreModule.java
@@ -11,6 +11,7 @@ import com.pmease.commons.git.GitConfig;
import com.pmease.commons.hibernate.AbstractEntity;
import com.pmease.commons.hibernate.ModelProvider;
import com.pmease.commons.hibernate.PrefixedNamingStrategy;
+import com.pmease.commons.hibernate.migration.Migrator;
import com.pmease.commons.jetty.ServletConfigurator;
import com.pmease.commons.loader.AbstractPlugin;
import com.pmease.commons.loader.AbstractPluginModule;
@@ -84,6 +85,7 @@ import com.pmease.gitplex.core.manager.impl.DefaultTeamMembershipManager;
import com.pmease.gitplex.core.manager.impl.DefaultUserAuthorizationManager;
import com.pmease.gitplex.core.manager.impl.DefaultVisitInfoManager;
import com.pmease.gitplex.core.manager.impl.DefaultWorkExecutor;
+import com.pmease.gitplex.core.migration.DataMigrator;
import com.pmease.gitplex.core.security.SecurityRealm;
import com.pmease.gitplex.core.setting.SpecifiedGit;
import com.pmease.gitplex.core.setting.SystemGit;
@@ -100,6 +102,8 @@ public class CoreModule extends AbstractPluginModule {
protected void configure() {
super.configure();
+ bind(Migrator.class).to(DataMigrator.class);
+
bind(PhysicalNamingStrategy.class).toInstance(new PrefixedNamingStrategy("g_"));
contribute(ModelProvider.class, new ModelProvider() {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java
index d6d104fdfa..61bad7d53a 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Account.java
@@ -42,7 +42,8 @@ import com.pmease.gitplex.core.security.protectedobject.ProtectedObject;
import com.pmease.gitplex.core.util.validation.AccountName;
@Entity
-@Table(indexes={@Index(columnList="email"), @Index(columnList="fullName"),
+@Table(indexes={
+ @Index(columnList="email"), @Index(columnList="fullName"),
@Index(columnList="noSpaceName"), @Index(columnList="noSpaceFullName")})
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@Editable
@@ -82,7 +83,7 @@ public class Account extends AbstractUser implements ProtectedObject {
/*
* Optimistic lock is necessary to ensure database integrity when update
- * gate keepers and integration policies upon account renaming/deletion
+ * gatekeepers and integration policies upon account renaming/deletion
*/
@Version
private long version;
@@ -218,7 +219,7 @@ public class Account extends AbstractUser implements ProtectedObject {
+ "<li>None: No any permissions granted on repositories"
+ "<li>Read: Able to pull and browse repositories"
+ "<li>Write: Has full read privilege, and can also push to "
- + "repositories unless gate keeper prevents")
+ + "repositories unless gatekeeper prevents")
@ExcludeValues("ADMIN")
@NotNull
public DepotPrivilege getDefaultPrivilege() {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/BranchWatch.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/BranchWatch.java
index 8da97762f5..50b774059e 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/BranchWatch.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/BranchWatch.java
@@ -3,6 +3,7 @@ package com.pmease.gitplex.core.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@@ -11,8 +12,9 @@ import javax.persistence.UniqueConstraint;
import com.pmease.commons.hibernate.AbstractEntity;
@Entity
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_depot_id", "branch", "g_user_id"})
+@Table(
+ indexes={@Index(columnList="g_depot_id"), @Index(columnList="g_user_id"), @Index(columnList="branch")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_depot_id", "branch", "g_user_id"})
})
public class BranchWatch extends AbstractEntity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java
index 1f09fd7581..7718c4622b 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeComment.java
@@ -40,7 +40,9 @@ import com.pmease.gitplex.core.security.SecurityUtils;
* which can be updated from background thread.
*/
@Entity
-@Table(indexes={@Index(columnList="uuid"), @Index(columnList="commit"),
+@Table(indexes={
+ @Index(columnList="g_depot_id"), @Index(columnList="g_user_id"),
+ @Index(columnList="uuid"), @Index(columnList="commit"),
@Index(columnList="path"), @Index(columnList="compareCommit")})
@DynamicUpdate
public class CodeComment extends AbstractEntity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentRelation.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentRelation.java
index 8b22e0fa19..c239584632 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentRelation.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentRelation.java
@@ -2,6 +2,7 @@ package com.pmease.gitplex.core.entity;
import javax.persistence.Entity;
import javax.persistence.FetchType;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@@ -12,8 +13,9 @@ import org.hibernate.annotations.FetchMode;
import com.pmease.commons.hibernate.AbstractEntity;
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_request_id", "g_comment_id"})
+@Table(
+ indexes={@Index(columnList="g_request_id"), @Index(columnList="g_comment_id")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_request_id", "g_comment_id"})
})
@Entity
public class CodeCommentRelation extends AbstractEntity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentReply.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentReply.java
index 7667dfd708..bc3300c5e9 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentReply.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentReply.java
@@ -2,7 +2,9 @@ package com.pmease.gitplex.core.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.Index;
import javax.persistence.Lob;
+import javax.persistence.Table;
import org.hibernate.annotations.DynamicUpdate;
@@ -14,6 +16,7 @@ import com.pmease.gitplex.core.entity.support.CodeCommentActivity;
* which can be updated from background thread.
*/
@Entity
+@Table(indexes={@Index(columnList="g_comment_id"), @Index(columnList="g_user_id")})
@DynamicUpdate
public class CodeCommentReply extends CodeCommentActivity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentStatusChange.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentStatusChange.java
index e1b22f6528..ba8a5d487d 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentStatusChange.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/CodeCommentStatusChange.java
@@ -1,12 +1,15 @@
package com.pmease.gitplex.core.entity;
import javax.persistence.Entity;
+import javax.persistence.Index;
+import javax.persistence.Table;
import org.hibernate.annotations.DynamicUpdate;
import com.pmease.gitplex.core.entity.support.CodeCommentActivity;
@Entity
+@Table(indexes={@Index(columnList="g_comment_id"), @Index(columnList="g_user_id")})
@DynamicUpdate
public class CodeCommentStatusChange extends CodeCommentActivity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Config.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Config.java
index 2301e52ae9..6a5af62873 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Config.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Config.java
@@ -1,57 +1,57 @@
-package com.pmease.gitplex.core.entity;
-
-import java.io.Serializable;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Lob;
-
-import org.hibernate.annotations.Cache;
-import org.hibernate.annotations.CacheConcurrencyStrategy;
-
-import com.pmease.commons.hibernate.AbstractEntity;
-
-/**
- * This entity stores object in serialized form, with one entity
- * representing one object.
- *
- */
-@Entity
-@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
-public class Config extends AbstractEntity {
-
- private static final long serialVersionUID = 1L;
-
- public enum Key {SYSTEM, MAIL, QOS};
-
- @Column(nullable=false, unique=true)
- private Key key;
-
- /*
- * This field is allowed to be null to indicate particular setting is not
- * available (the record will always be available after interactive setup
- * to indicate that the setting has been prompted (although the user may
- * skipped the setting), so we can not use existence of record to indicate
- * a null setting.
- */
- @Lob
- @Column(length=65535)
- private Serializable setting;
-
- public Key getKey() {
- return key;
- }
-
- public void setKey(Key key) {
- this.key = key;
- }
-
- public Serializable getSetting() {
- return setting;
- }
-
- public void setSetting(Serializable setting) {
- this.setting = setting;
- }
-
-}
+package com.pmease.gitplex.core.entity;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Lob;
+
+import org.hibernate.annotations.Cache;
+import org.hibernate.annotations.CacheConcurrencyStrategy;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+
+/**
+ * This entity stores object in serialized form, with one entity
+ * representing one object.
+ *
+ */
+@Entity
+@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
+public class Config extends AbstractEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ public enum Key {SYSTEM, MAIL, BACKUP};
+
+ @Column(nullable=false, unique=true)
+ private Key key;
+
+ /*
+ * This field is allowed to be null to indicate particular setting is not
+ * available (the record will always be available after interactive setup
+ * to indicate that the setting has been prompted (although the user may
+ * skipped the setting), so we can not use existence of record to indicate
+ * a null setting.
+ */
+ @Lob
+ @Column(length=65535)
+ private Serializable setting;
+
+ public Key getKey() {
+ return key;
+ }
+
+ public void setKey(Key key) {
+ this.key = key;
+ }
+
+ public Serializable getSetting() {
+ return setting;
+ }
+
+ public void setSetting(Serializable setting) {
+ this.setting = setting;
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java
index d9b9ff9a48..0fad865619 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Depot.java
@@ -22,6 +22,7 @@ import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
@@ -87,7 +88,7 @@ import com.pmease.commons.wicket.editable.annotation.Markdown;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.support.IntegrationPolicy;
import com.pmease.gitplex.core.event.RefUpdated;
-import com.pmease.gitplex.core.gatekeeper.AndGateKeeper;
+import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;
import com.pmease.gitplex.core.gatekeeper.GateKeeper;
import com.pmease.gitplex.core.manager.ConfigManager;
import com.pmease.gitplex.core.manager.DepotManager;
@@ -99,7 +100,9 @@ import com.pmease.gitplex.core.security.protectedobject.ProtectedObject;
import com.pmease.gitplex.core.util.validation.DepotName;
@Entity
-@Table(uniqueConstraints={@UniqueConstraint(columnNames={"g_account_id", "name"})})
+@Table(
+ indexes={@Index(columnList="g_forkedFrom_id"), @Index(columnList="g_account_id"), @Index(columnList="name")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_account_id", "name"})})
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@DynamicUpdate
@Editable
@@ -139,14 +142,14 @@ public class Depot extends AbstractEntity implements AccountBelonging {
/*
* Optimistic lock is necessary to ensure database integrity when update
- * gate keepers and integration policies upon depot renaming/deletion
+ * gatekeepers and integration policies upon depot renaming/deletion
*/
@Version
private long version;
@Lob
@Column(nullable=false, length=65535)
- private ArrayList<GateKeeper> gateKeepers = new ArrayList<>();
+ private GateKeeper gateKeeper = new DefaultGateKeeper();
@Lob
@Column(nullable=false, length=65535)
@@ -232,12 +235,12 @@ public class Depot extends AbstractEntity implements AccountBelonging {
@NotNull
@Valid
- public List<GateKeeper> getGateKeepers() {
- return gateKeepers;
+ public GateKeeper getGateKeeper() {
+ return gateKeeper;
}
- public void setGateKeepers(ArrayList<GateKeeper> gateKeepers) {
- this.gateKeepers = gateKeepers;
+ public void setGateKeeper(GateKeeper gateKeeper) {
+ this.gateKeeper = gateKeeper;
}
@Valid
@@ -377,13 +380,6 @@ public class Depot extends AbstractEntity implements AccountBelonging {
return true;
}
- public GateKeeper getGateKeeper() {
- AndGateKeeper andGateKeeper = new AndGateKeeper();
- for (GateKeeper each: getGateKeepers())
- andGateKeeper.getGateKeepers().add(each);
- return andGateKeeper;
- }
-
/**
* Find fork root of this repository.
*
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/OrganizationMembership.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/OrganizationMembership.java
index b928e4302b..1ade3c9f94 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/OrganizationMembership.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/OrganizationMembership.java
@@ -1,54 +1,56 @@
-package com.pmease.gitplex.core.entity;
-
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
-
-import com.pmease.commons.hibernate.AbstractEntity;
-
-@Entity
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_user_id", "g_organization_id"})
-})
-public class OrganizationMembership extends AbstractEntity {
-
- private static final long serialVersionUID = 1L;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(nullable=false)
- private Account user;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(nullable=false)
- private Account organization;
-
- private boolean admin;
-
- public Account getUser() {
- return user;
- }
-
- public void setUser(Account user) {
- this.user = user;
- }
-
- public Account getOrganization() {
- return organization;
- }
-
- public void setOrganization(Account organization) {
- this.organization = organization;
- }
-
- public boolean isAdmin() {
- return admin;
- }
-
- public void setAdmin(boolean admin) {
- this.admin = admin;
- }
-
-}
+package com.pmease.gitplex.core.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Index;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+
+@Entity
+@Table(
+ indexes={@Index(columnList="g_user_id"), @Index(columnList="g_organization_id")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_user_id", "g_organization_id"})
+})
+public class OrganizationMembership extends AbstractEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private Account user;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private Account organization;
+
+ private boolean admin;
+
+ public Account getUser() {
+ return user;
+ }
+
+ public void setUser(Account user) {
+ this.user = user;
+ }
+
+ public Account getOrganization() {
+ return organization;
+ }
+
+ public void setOrganization(Account organization) {
+ this.organization = organization;
+ }
+
+ public boolean isAdmin() {
+ return admin;
+ }
+
+ public void setAdmin(boolean admin) {
+ this.admin = admin;
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
index b8251cef47..214b176ea4 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequest.java
@@ -72,8 +72,14 @@ import com.pmease.gitplex.core.security.SecurityUtils;
* which can be updated from background thread.
*/
@DynamicUpdate
-@Table(indexes={@Index(columnList="title"), @Index(columnList="uuid"), @Index(columnList="numberStr"), @Index(columnList="noSpaceTitle")},
- uniqueConstraints={@UniqueConstraint(columnNames={"g_targetdepot_id", "number"})})
+@Table(
+ indexes={
+ @Index(columnList="title"), @Index(columnList="uuid"),
+ @Index(columnList="numberStr"), @Index(columnList="noSpaceTitle"),
+ @Index(columnList="number"), @Index(columnList="g_targetDepot_id"),
+ @Index(columnList="g_sourceDepot_id"), @Index(columnList="g_submitter_id"),
+ @Index(columnList="g_assignee_id")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_targetDepot_id", "number"})})
public class PullRequest extends AbstractEntity {
private static final long serialVersionUID = 1L;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestComment.java
index 37638f928c..4bee944126 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestComment.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestComment.java
@@ -6,9 +6,11 @@ import javax.annotation.Nullable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
+import javax.persistence.Table;
import javax.persistence.Version;
import org.hibernate.annotations.DynamicUpdate;
@@ -21,6 +23,7 @@ import com.pmease.commons.hibernate.AbstractEntity;
* which can be updated from background thread.
*/
@Entity
+@Table(indexes={@Index(columnList="g_request_id"), @Index(columnList="g_user_id")})
@DynamicUpdate
public class PullRequestComment extends AbstractEntity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestNotification.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestNotification.java
index 15ffc11304..a4b6d6511b 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestNotification.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestNotification.java
@@ -5,6 +5,7 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@@ -13,8 +14,9 @@ import javax.persistence.UniqueConstraint;
import com.pmease.commons.hibernate.AbstractEntity;
@Entity
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_request_id", "g_user_id", "task"})
+@Table(
+ indexes={@Index(columnList="g_request_id"), @Index(columnList="g_user_id"), @Index(columnList="task")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_request_id", "g_user_id", "task"})
})
public class PullRequestNotification extends AbstractEntity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReference.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReference.java
index 6261c857cb..783c8fcfe4 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReference.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReference.java
@@ -1,75 +1,77 @@
-package com.pmease.gitplex.core.entity;
-
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
-
-import org.hibernate.annotations.Fetch;
-import org.hibernate.annotations.FetchMode;
-
-import com.pmease.commons.hibernate.AbstractEntity;
-
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_referenced_id", "g_referencedBy_id"})
-})
-@Entity
-public class PullRequestReference extends AbstractEntity {
-
- private static final long serialVersionUID = 1L;
-
- @ManyToOne(fetch=FetchType.EAGER)
- @Fetch(FetchMode.JOIN)
- @JoinColumn(nullable=false)
- private PullRequest referenced;
-
- @ManyToOne(fetch=FetchType.EAGER)
- @Fetch(FetchMode.JOIN)
- @JoinColumn(nullable=false)
- private PullRequest referencedBy;
-
- @Column(nullable=false)
- private Date date;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(nullable=false)
- private Account user;
-
- public PullRequest getReferenced() {
- return referenced;
- }
-
- public void setReferenced(PullRequest referenced) {
- this.referenced = referenced;
- }
-
- public PullRequest getReferencedBy() {
- return referencedBy;
- }
-
- public void setReferencedBy(PullRequest referencedBy) {
- this.referencedBy = referencedBy;
- }
-
- public Date getDate() {
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
- public Account getUser() {
- return user;
- }
-
- public void setUser(Account user) {
- this.user = user;
- }
-
-}
+package com.pmease.gitplex.core.entity;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Index;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import org.hibernate.annotations.Fetch;
+import org.hibernate.annotations.FetchMode;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+
+@Table(
+ indexes={@Index(columnList="g_referenced_id"), @Index(columnList="g_referencedBy_id"), @Index(columnList="g_user_id")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_referenced_id", "g_referencedBy_id"})
+})
+@Entity
+public class PullRequestReference extends AbstractEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ @ManyToOne(fetch=FetchType.EAGER)
+ @Fetch(FetchMode.JOIN)
+ @JoinColumn(nullable=false)
+ private PullRequest referenced;
+
+ @ManyToOne(fetch=FetchType.EAGER)
+ @Fetch(FetchMode.JOIN)
+ @JoinColumn(nullable=false)
+ private PullRequest referencedBy;
+
+ @Column(nullable=false)
+ private Date date;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private Account user;
+
+ public PullRequest getReferenced() {
+ return referenced;
+ }
+
+ public void setReferenced(PullRequest referenced) {
+ this.referenced = referenced;
+ }
+
+ public PullRequest getReferencedBy() {
+ return referencedBy;
+ }
+
+ public void setReferencedBy(PullRequest referencedBy) {
+ this.referencedBy = referencedBy;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public Account getUser() {
+ return user;
+ }
+
+ public void setUser(Account user) {
+ this.user = user;
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReview.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReview.java
index a3310f54cd..366c8b224c 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReview.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReview.java
@@ -5,6 +5,7 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@@ -13,8 +14,9 @@ import javax.persistence.UniqueConstraint;
import com.pmease.commons.hibernate.AbstractEntity;
@Entity
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_user_id", "g_update_id"})
+@Table(
+ indexes={@Index(columnList="g_user_id"), @Index(columnList="g_update_id")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_user_id", "g_update_id"})
})
public class PullRequestReview extends AbstractEntity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReviewInvitation.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReviewInvitation.java
index 9aa7b1806b..808ee8dd31 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReviewInvitation.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestReviewInvitation.java
@@ -5,6 +5,7 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@@ -13,8 +14,9 @@ import javax.persistence.UniqueConstraint;
import com.pmease.commons.hibernate.AbstractEntity;
@Entity
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_user_id", "g_request_id"})
+@Table(
+ indexes={@Index(columnList="g_user_id"), @Index(columnList="g_request_id")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_user_id", "g_request_id"})
})
public class PullRequestReviewInvitation extends AbstractEntity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestStatusChange.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestStatusChange.java
index 48758dfbd9..8bc4642d88 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestStatusChange.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestStatusChange.java
@@ -6,8 +6,10 @@ import javax.annotation.Nullable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
+import javax.persistence.Table;
import javax.persistence.Version;
import org.hibernate.annotations.DynamicUpdate;
@@ -15,6 +17,7 @@ import org.hibernate.annotations.DynamicUpdate;
import com.pmease.commons.hibernate.AbstractEntity;
@Entity
+@Table(indexes={@Index(columnList="g_request_id"), @Index(columnList="g_user_id")})
@DynamicUpdate
public class PullRequestStatusChange extends AbstractEntity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestUpdate.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestUpdate.java
index 0c65d50c1b..ce76badc5b 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestUpdate.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestUpdate.java
@@ -37,7 +37,7 @@ import com.pmease.commons.hibernate.AbstractEntity;
import com.pmease.gitplex.core.manager.impl.DefaultCodeCommentRelationManager;
@Entity
-@Table(indexes={@Index(columnList="uuid"), @Index(columnList="date")})
+@Table(indexes={@Index(columnList="g_request_id"), @Index(columnList="uuid"), @Index(columnList="date")})
public class PullRequestUpdate extends AbstractEntity {
private static final long serialVersionUID = 1L;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestVerification.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestVerification.java
index 3dc9028252..044210ef53 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestVerification.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestVerification.java
@@ -3,6 +3,7 @@ package com.pmease.gitplex.core.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@@ -11,8 +12,10 @@ import javax.persistence.UniqueConstraint;
import com.pmease.commons.hibernate.AbstractEntity;
@Entity
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_request_id", "commit", "configuration"})
+@Table(
+ indexes={@Index(columnList="g_request_id"), @Index(columnList="g_user_id"),
+ @Index(columnList="commit"), @Index(columnList="configuration")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_request_id", "commit", "configuration"})
})
public class PullRequestVerification extends AbstractEntity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestWatch.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestWatch.java
index c9cb5bbb86..6600a03925 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestWatch.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/PullRequestWatch.java
@@ -1,66 +1,68 @@
-package com.pmease.gitplex.core.entity;
-
-import javax.annotation.Nullable;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
-
-import com.pmease.commons.hibernate.AbstractEntity;
-
-@Entity
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_request_id", "g_user_id"})
-})
-public class PullRequestWatch extends AbstractEntity {
-
- private static final long serialVersionUID = 1L;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(nullable=false)
- private PullRequest request;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(nullable=false)
- private Account user;
-
- private String reason;
-
- private boolean ignore;
-
- public PullRequest getRequest() {
- return request;
- }
-
- public void setRequest(PullRequest request) {
- this.request = request;
- }
-
- public Account getUser() {
- return user;
- }
-
- public void setUser(Account user) {
- this.user = user;
- }
-
- @Nullable
- public String getReason() {
- return reason;
- }
-
- public void setReason(String reason) {
- this.reason = reason;
- }
-
- public boolean isIgnore() {
- return ignore;
- }
-
- public void setIgnore(boolean ignore) {
- this.ignore = ignore;
- }
-
-}
+package com.pmease.gitplex.core.entity;
+
+import javax.annotation.Nullable;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Index;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+
+@Entity
+@Table(
+ indexes={@Index(columnList="g_request_id"), @Index(columnList="g_user_id")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_request_id", "g_user_id"})
+})
+public class PullRequestWatch extends AbstractEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private PullRequest request;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private Account user;
+
+ private String reason;
+
+ private boolean ignore;
+
+ public PullRequest getRequest() {
+ return request;
+ }
+
+ public void setRequest(PullRequest request) {
+ this.request = request;
+ }
+
+ public Account getUser() {
+ return user;
+ }
+
+ public void setUser(Account user) {
+ this.user = user;
+ }
+
+ @Nullable
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public boolean isIgnore() {
+ return ignore;
+ }
+
+ public void setIgnore(boolean ignore) {
+ this.ignore = ignore;
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Team.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Team.java
index 0287cd191e..b145041642 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Team.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/Team.java
@@ -9,6 +9,7 @@ import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
@@ -25,7 +26,9 @@ import com.pmease.commons.wicket.editable.annotation.Markdown;
import com.pmease.gitplex.core.util.validation.DepotName;
@Entity
-@Table(uniqueConstraints={@UniqueConstraint(columnNames={"g_organization_id", "name"})})
+@Table(
+ indexes={@Index(columnList="g_organization_id"), @Index(columnList="name")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_organization_id", "name"})})
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@Editable
public class Team extends AbstractEntity {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/TeamAuthorization.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/TeamAuthorization.java
index a276781ba5..ce2cb46845 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/TeamAuthorization.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/TeamAuthorization.java
@@ -1,57 +1,59 @@
-package com.pmease.gitplex.core.entity;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
-
-import com.pmease.commons.hibernate.AbstractEntity;
-import com.pmease.gitplex.core.security.privilege.DepotPrivilege;
-
-@Entity
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_team_id", "g_depot_id"})
-})
-public class TeamAuthorization extends AbstractEntity {
-
- private static final long serialVersionUID = 1L;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(nullable=false)
- private Depot depot;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(nullable=false)
- private Team team;
-
- @Column(nullable=false)
- private DepotPrivilege privilege = DepotPrivilege.READ;
-
- public Depot getDepot() {
- return depot;
- }
-
- public void setDepot(Depot depot) {
- this.depot = depot;
- }
-
- public Team getTeam() {
- return team;
- }
-
- public void setTeam(Team team) {
- this.team = team;
- }
-
- public DepotPrivilege getPrivilege() {
- return privilege;
- }
-
- public void setPrivilege(DepotPrivilege privilege) {
- this.privilege = privilege;
- }
-
-}
+package com.pmease.gitplex.core.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Index;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+import com.pmease.gitplex.core.security.privilege.DepotPrivilege;
+
+@Entity
+@Table(
+ indexes={@Index(columnList="g_team_id"), @Index(columnList="g_depot_id")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_team_id", "g_depot_id"})
+})
+public class TeamAuthorization extends AbstractEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private Depot depot;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private Team team;
+
+ @Column(nullable=false)
+ private DepotPrivilege privilege = DepotPrivilege.READ;
+
+ public Depot getDepot() {
+ return depot;
+ }
+
+ public void setDepot(Depot depot) {
+ this.depot = depot;
+ }
+
+ public Team getTeam() {
+ return team;
+ }
+
+ public void setTeam(Team team) {
+ this.team = team;
+ }
+
+ public DepotPrivilege getPrivilege() {
+ return privilege;
+ }
+
+ public void setPrivilege(DepotPrivilege privilege) {
+ this.privilege = privilege;
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/TeamMembership.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/TeamMembership.java
index 6e71909680..91e536094d 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/TeamMembership.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/TeamMembership.java
@@ -1,44 +1,46 @@
-package com.pmease.gitplex.core.entity;
-
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
-
-import com.pmease.commons.hibernate.AbstractEntity;
-
-@Entity
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_user_id", "g_team_id"})
-})
-public class TeamMembership extends AbstractEntity {
-
- private static final long serialVersionUID = 1L;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(nullable=false)
- private Account user;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(nullable=false)
- private Team team;
-
- public Account getUser() {
- return user;
- }
-
- public void setUser(Account user) {
- this.user = user;
- }
-
- public Team getTeam() {
- return team;
- }
-
- public void setTeam(Team team) {
- this.team = team;
- }
-
-}
+package com.pmease.gitplex.core.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Index;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+
+@Entity
+@Table(
+ indexes={@Index(columnList="g_user_id"), @Index(columnList="g_team_id")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_user_id", "g_team_id"})
+})
+public class TeamMembership extends AbstractEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private Account user;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private Team team;
+
+ public Account getUser() {
+ return user;
+ }
+
+ public void setUser(Account user) {
+ this.user = user;
+ }
+
+ public Team getTeam() {
+ return team;
+ }
+
+ public void setTeam(Team team) {
+ this.team = team;
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/UserAuthorization.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/UserAuthorization.java
index 7022cd742e..bbb13995ad 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/UserAuthorization.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/entity/UserAuthorization.java
@@ -1,57 +1,59 @@
-package com.pmease.gitplex.core.entity;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
-
-import com.pmease.commons.hibernate.AbstractEntity;
-import com.pmease.gitplex.core.security.privilege.DepotPrivilege;
-
-@Entity
-@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"g_user_id", "g_depot_id"})
-})
-public class UserAuthorization extends AbstractEntity {
-
- private static final long serialVersionUID = 1L;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(nullable=false)
- private Depot depot;
-
- @ManyToOne(fetch=FetchType.LAZY)
- @JoinColumn(nullable=false)
- private Account user;
-
- @Column(nullable=false)
- private DepotPrivilege privilege = DepotPrivilege.READ;
-
- public Depot getDepot() {
- return depot;
- }
-
- public void setDepot(Depot depot) {
- this.depot = depot;
- }
-
- public Account getUser() {
- return user;
- }
-
- public void setUser(Account user) {
- this.user = user;
- }
-
- public DepotPrivilege getPrivilege() {
- return privilege;
- }
-
- public void setPrivilege(DepotPrivilege privilege) {
- this.privilege = privilege;
- }
-
-}
+package com.pmease.gitplex.core.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Index;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import com.pmease.commons.hibernate.AbstractEntity;
+import com.pmease.gitplex.core.security.privilege.DepotPrivilege;
+
+@Entity
+@Table(
+ indexes={@Index(columnList="g_user_id"), @Index(columnList="g_depot_id")},
+ uniqueConstraints={@UniqueConstraint(columnNames={"g_user_id", "g_depot_id"})
+})
+public class UserAuthorization extends AbstractEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private Depot depot;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(nullable=false)
+ private Account user;
+
+ @Column(nullable=false)
+ private DepotPrivilege privilege = DepotPrivilege.READ;
+
+ public Depot getDepot() {
+ return depot;
+ }
+
+ public void setDepot(Depot depot) {
+ this.depot = depot;
+ }
+
+ public Account getUser() {
+ return user;
+ }
+
+ public void setUser(Account user) {
+ this.user = user;
+ }
+
+ public DepotPrivilege getPrivilege() {
+ return privilege;
+ }
+
+ public void setPrivilege(DepotPrivilege privilege) {
+ this.privilege = privilege;
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AbstractGateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AbstractGateKeeper.java
index b9732ac1ec..88e7b4b435 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AbstractGateKeeper.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AbstractGateKeeper.java
@@ -57,7 +57,7 @@ public abstract class AbstractGateKeeper implements GateKeeper {
}
/**
- * Check gate keeper against specified pull request without considering enable flag. This is
+ * Check gatekeeper against specified pull request without considering enable flag. This is
* typically used to determine whether or not to accept a pull request.
*
* @param request
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AndGateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AndGateKeeper.java
index b8857ee0cd..dc6b111634 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AndGateKeeper.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/AndGateKeeper.java
@@ -13,7 +13,7 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Pending;
@Editable(name="And Composition", icon="fa-object-group", order=100,
category=GateKeeper.CATEGORY_COMPOSITION,
- description="This gate keeper will be passed if all contained gate keepers are passed")
+ description="This gatekeeper will be passed if all contained child gatekeepers are passed")
@Horizontal
public class AndGateKeeper extends AndOrGateKeeper {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedTeam.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedTeam.java
similarity index 94%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedTeam.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedTeam.java
index fe8924fe0f..72af1bbb99 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedTeam.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedTeam.java
@@ -15,9 +15,9 @@ import com.pmease.gitplex.core.entity.PullRequestReview;
import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
@Editable(order=100, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=
- "This gate keeper will be passed if the commit is approved by specified number of users "
+ "This gatekeeper will be passed if the commit is approved by specified number of users "
+ "from specified team")
-public class IfApprovedBySpecifiedTeam extends TeamAwareGateKeeper {
+public class ApprovedBySpecifiedTeam extends TeamAwareGateKeeper {
private static final long serialVersionUID = 1L;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedUser.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedUser.java
similarity index 91%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedUser.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedUser.java
index c379e165e1..a675342306 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfApprovedBySpecifiedUser.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ApprovedBySpecifiedUser.java
@@ -1,75 +1,75 @@
-package com.pmease.gitplex.core.gatekeeper;
-
-import org.eclipse.jgit.lib.ObjectId;
-import org.hibernate.validator.constraints.NotEmpty;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.pmease.commons.wicket.editable.annotation.Editable;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.annotation.AccountChoice;
-import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.PullRequestReview;
-import com.pmease.gitplex.core.entity.Account;
-import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
-import com.pmease.gitplex.core.manager.AccountManager;
-
-@Editable(order=200, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=
- "This gate keeper will be passed if the commit is approved by specified user")
-public class IfApprovedBySpecifiedUser extends AbstractGateKeeper {
-
- private static final long serialVersionUID = 1L;
-
- private String userName;
-
- @Editable(name="Select User")
- @AccountChoice
- @NotEmpty
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- @Override
- public GateCheckResult doCheckRequest(PullRequest request) {
- Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));
-
- PullRequestReview.Result result = user.checkReviewSince(request.getReferentialUpdate());
- if (result == null) {
- request.pickReviewers(Sets.newHashSet(user), 1);
-
- return pending(Lists.newArrayList("To be approved by " + user.getDisplayName()));
- } else if (result == PullRequestReview.Result.APPROVE) {
- return passed(Lists.newArrayList("Approved by " + user.getDisplayName()));
- } else {
- return failed(Lists.newArrayList("Disapproved by " + user.getDisplayName()));
- }
- }
-
- @Override
- protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
- return pending(Lists.newArrayList("Need approval from " + user.getName()));
- }
-
- @Override
- protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {
- return pending(Lists.newArrayList("Need approval from " + user.getName()));
- }
-
- @Override
- public void onAccountRename(String oldName, String newName) {
- if (userName.equals(oldName))
- userName = newName;
- }
-
- @Override
- public boolean onAccountDelete(String accountName) {
- return userName.equals(accountName);
- }
-
-}
+package com.pmease.gitplex.core.gatekeeper;
+
+import org.eclipse.jgit.lib.ObjectId;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.pmease.commons.wicket.editable.annotation.Editable;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.annotation.AccountChoice;
+import com.pmease.gitplex.core.entity.Depot;
+import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.PullRequestReview;
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
+import com.pmease.gitplex.core.manager.AccountManager;
+
+@Editable(order=200, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=
+ "This gatekeeper will be passed if the commit is approved by specified user")
+public class ApprovedBySpecifiedUser extends AbstractGateKeeper {
+
+ private static final long serialVersionUID = 1L;
+
+ private String userName;
+
+ @Editable(name="Select User")
+ @AccountChoice
+ @NotEmpty
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ public GateCheckResult doCheckRequest(PullRequest request) {
+ Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));
+
+ PullRequestReview.Result result = user.checkReviewSince(request.getReferentialUpdate());
+ if (result == null) {
+ request.pickReviewers(Sets.newHashSet(user), 1);
+
+ return pending(Lists.newArrayList("To be approved by " + user.getDisplayName()));
+ } else if (result == PullRequestReview.Result.APPROVE) {
+ return passed(Lists.newArrayList("Approved by " + user.getDisplayName()));
+ } else {
+ return failed(Lists.newArrayList("Disapproved by " + user.getDisplayName()));
+ }
+ }
+
+ @Override
+ protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
+ return pending(Lists.newArrayList("Need approval from " + user.getName()));
+ }
+
+ @Override
+ protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {
+ return pending(Lists.newArrayList("Need approval from " + user.getName()));
+ }
+
+ @Override
+ public void onAccountRename(String oldName, String newName) {
+ if (userName.equals(oldName))
+ userName = newName;
+ }
+
+ @Override
+ public boolean onAccountDelete(String accountName) {
+ return userName.equals(accountName);
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfThenGateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ConditionalGateKeeper.java
similarity index 91%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfThenGateKeeper.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ConditionalGateKeeper.java
index e2ddca770e..f676350755 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfThenGateKeeper.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/ConditionalGateKeeper.java
@@ -13,11 +13,12 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Failed;
import com.pmease.gitplex.core.gatekeeper.checkresult.Passed;
import com.pmease.gitplex.core.gatekeeper.checkresult.Pending;
-@Editable(name="If...Then... Composition", order=300, icon="fa-object-group",
+@Editable(name="Conditional Composition", order=300, icon="fa-object-group",
category=GateKeeper.CATEGORY_COMPOSITION,
- description="If first gate keeper is passed, then go ahead to check second gate keeper")
+ description="If first gatekeeper is passed, then continue to check second gatekeeper; "
+ + "otherwise consider the conditional composition as passed")
@Horizontal
-public class IfThenGateKeeper extends CompositeGateKeeper {
+public class ConditionalGateKeeper extends CompositeGateKeeper {
private static final long serialVersionUID = 1L;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedTeam.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedTeam.java
similarity index 94%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedTeam.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedTeam.java
index 4d7a0f9fd8..e1224545b2 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedTeam.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedTeam.java
@@ -15,11 +15,11 @@ import com.pmease.gitplex.core.entity.PullRequestReview;
import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
@Editable(order=300, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=
- "This gate keeper will be passed if the commit gets specified number "
+ "This gatekeeper will be passed if the commit gets specified number "
+ "of disapprovals from specified team. It normally works together "
+ "with a NOT container to reject the pull request in case there are "
+ "disapprovals")
-public class IfDisapprovedBySpecifiedTeam extends TeamAwareGateKeeper {
+public class DisapprovedBySpecifiedTeam extends TeamAwareGateKeeper {
private static final long serialVersionUID = 1L;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedUser.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedUser.java
similarity index 91%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedUser.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedUser.java
index 9363703efa..c51d7c36ad 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfDisapprovedBySpecifiedUser.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/DisapprovedBySpecifiedUser.java
@@ -1,72 +1,72 @@
-package com.pmease.gitplex.core.gatekeeper;
-
-import org.eclipse.jgit.lib.ObjectId;
-import org.hibernate.validator.constraints.NotEmpty;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.pmease.commons.wicket.editable.annotation.Editable;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.annotation.AccountChoice;
-import com.pmease.gitplex.core.entity.Account;
-import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.PullRequestReview;
-import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
-import com.pmease.gitplex.core.manager.AccountManager;
-
-@Editable(order=300, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=
- "This gate keeper will be passed if the commit is disapproved by specified user. "
- + "It normally works together with a NOT container to reject the pull request "
- + "in case the user disapproved it")
-public class IfDisapprovedBySpecifiedUser extends AbstractGateKeeper {
-
- private static final long serialVersionUID = 1L;
-
- private String userName;
-
- @Editable(name="Select User")
- @AccountChoice
- @NotEmpty
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- @Override
- protected GateCheckResult doCheckRequest(PullRequest request) {
- Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));
- PullRequestReview.Result result = user.checkReviewSince(request.getReferentialUpdate());
- if (result == PullRequestReview.Result.DISAPPROVE) {
- return passed(Lists.newArrayList("Disapproved by " + userName));
- } else {
- return failed(Lists.newArrayList("Not disapproved by " + userName));
- }
- }
-
- @Override
- protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
- return failed(Lists.newArrayList("Not disapproved by " + userName));
- }
-
- @Override
- protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit,
- ObjectId newCommit) {
- return failed(Lists.newArrayList("Not disapproved by " + userName));
- }
-
- @Override
- public void onAccountRename(String oldName, String newName) {
- if (userName.equals(oldName))
- userName = newName;
- }
-
- @Override
- public boolean onAccountDelete(String accountName) {
- return userName.equals(accountName);
- }
-
-}
+package com.pmease.gitplex.core.gatekeeper;
+
+import org.eclipse.jgit.lib.ObjectId;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.pmease.commons.wicket.editable.annotation.Editable;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.annotation.AccountChoice;
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.core.entity.Depot;
+import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.PullRequestReview;
+import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
+import com.pmease.gitplex.core.manager.AccountManager;
+
+@Editable(order=300, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=
+ "This gatekeeper will be passed if the commit is disapproved by specified user. "
+ + "It normally works together with a NOT container to reject the pull request "
+ + "in case the user disapproved it")
+public class DisapprovedBySpecifiedUser extends AbstractGateKeeper {
+
+ private static final long serialVersionUID = 1L;
+
+ private String userName;
+
+ @Editable(name="Select User")
+ @AccountChoice
+ @NotEmpty
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ protected GateCheckResult doCheckRequest(PullRequest request) {
+ Account user = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));
+ PullRequestReview.Result result = user.checkReviewSince(request.getReferentialUpdate());
+ if (result == PullRequestReview.Result.DISAPPROVE) {
+ return passed(Lists.newArrayList("Disapproved by " + userName));
+ } else {
+ return failed(Lists.newArrayList("Not disapproved by " + userName));
+ }
+ }
+
+ @Override
+ protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
+ return failed(Lists.newArrayList("Not disapproved by " + userName));
+ }
+
+ @Override
+ protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit,
+ ObjectId newCommit) {
+ return failed(Lists.newArrayList("Not disapproved by " + userName));
+ }
+
+ @Override
+ public void onAccountRename(String oldName, String newName) {
+ if (userName.equals(oldName))
+ userName = newName;
+ }
+
+ @Override
+ public boolean onAccountDelete(String accountName) {
+ return userName.equals(accountName);
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.java
index d5d2f77a28..ea03d033a8 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/GateKeeper.java
@@ -15,14 +15,14 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
@Editable(name="Misc")
public interface GateKeeper extends Serializable {
- String CATEGORY_BASIC = "Basic Gate Keepers";
+ String CATEGORY_BASIC = "Basic Gatekeepers";
String CATEGORY_USER = "Check Approver/Submitter";
- String CATEGORY_COMPOSITION = "Gate Keeper Compositions";
+ String CATEGORY_COMPOSITION = "Gatekeeper Compositions";
/**
- * Check the gate keeper against specified request. This is typically used to determine
+ * Check the gatekeeper against specified request. This is typically used to determine
* whether or not to accept a pull request.
*
* @param request
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/NotGateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/NotGateKeeper.java
index d03ac4185b..838918f908 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/NotGateKeeper.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/NotGateKeeper.java
@@ -12,7 +12,7 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Failed;
import com.pmease.gitplex.core.gatekeeper.checkresult.Passed;
@Editable(name="Not Composition", order=400, icon="fa-object-group", category=GateKeeper.CATEGORY_COMPOSITION,
- description="This gate keeper will be passed if contained gate keeper is not passed")
+ description="This gatekeeper will be passed if contained gatekeeper is not passed")
@Horizontal
public class NotGateKeeper extends CompositeGateKeeper {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/OrGateKeeper.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/OrGateKeeper.java
index f0cfe51433..a3fc2c6817 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/OrGateKeeper.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/OrGateKeeper.java
@@ -12,7 +12,7 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.Passed;
import com.pmease.gitplex.core.gatekeeper.checkresult.Pending;
@Editable(name="Or Composition", order=200, icon="fa-object-group", category=GateKeeper.CATEGORY_COMPOSITION,
- description="This gate keeper will be passed if any of the contained gate keepers is passed")
+ description="This gatekeeper will be passed if any of the contained gatekeepers is passed")
@Horizontal
public class OrGateKeeper extends AndOrGateKeeper {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPerformSpecifiedOperations.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PerformSpecifiedOperations.java
similarity index 94%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPerformSpecifiedOperations.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PerformSpecifiedOperations.java
index ed23afc435..a83f60e8b8 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPerformSpecifiedOperations.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PerformSpecifiedOperations.java
@@ -17,9 +17,9 @@ import com.pmease.gitplex.core.entity.Account;
import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
@Editable(order=200, icon="fa-wrench", description=
- "This gate keeper will be passed if one of specified operations is performed")
+ "This gatekeeper will be passed if one of specified operations is performed")
@ClassValidating
-public class IfPerformSpecifiedOperations extends AbstractGateKeeper implements Validatable {
+public class PerformSpecifiedOperations extends AbstractGateKeeper implements Validatable {
private static final long serialVersionUID = 1L;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPushWithoutRewritingHistory.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PushWithoutRewritingHistory.java
similarity index 92%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPushWithoutRewritingHistory.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PushWithoutRewritingHistory.java
index 7013a275fe..2d62d78ad6 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfPushWithoutRewritingHistory.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/PushWithoutRewritingHistory.java
@@ -10,11 +10,11 @@ import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.entity.Account;
import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
-@Editable(order=2000, icon="fa-ext fa-repo-lock", description="This gate keeper will be passed if the push "
+@Editable(order=2000, icon="fa-ext fa-repo-lock", description="This gatekeeper will be passed if the push "
+ "operation does not rewrite history of target branch. Rewriting history of public branches "
+ "is dangerous, and it happens when user forces a push without merging/rebasing with the "
+ "branch head")
-public class IfPushWithoutRewritingHistory extends AbstractGateKeeper {
+public class PushWithoutRewritingHistory extends AbstractGateKeeper {
private static final long serialVersionUID = 1L;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmitWithGerritStylePatch.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmitWithGerritStylePatch.java
similarity index 93%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmitWithGerritStylePatch.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmitWithGerritStylePatch.java
index d98d9d3dae..c51f64a9df 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmitWithGerritStylePatch.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmitWithGerritStylePatch.java
@@ -14,10 +14,10 @@ import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
-@Editable(order=3000, icon="fa-ext fa-file-diff", description="This gate keeper will be passed if the pull request "
+@Editable(order=3000, icon="fa-ext fa-file-diff", description="This gatekeeper will be passed if the pull request "
+ "is submitted with gerrit style patch, that is, only one commit is submitted for review at "
+ "a time, and subsequent updates to the review should be done by amending previous commit")
-public class IfSubmitWithGerritStylePatch extends AbstractGateKeeper {
+public class SubmitWithGerritStylePatch extends AbstractGateKeeper {
private static final long serialVersionUID = 1L;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedTeam.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedTeam.java
similarity index 89%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedTeam.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedTeam.java
index b6faa0d677..8c223ce51e 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedTeam.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedTeam.java
@@ -12,8 +12,8 @@ import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
@Editable(order=500, icon="fa-group", category=GateKeeper.CATEGORY_USER, description=
- "This gate keeper will be passed if the commit is submitted by a member of specified team")
-public class IfSubmittedBySpecifiedTeam extends TeamAwareGateKeeper {
+ "This gatekeeper will be passed if the commit is submitted by a member of specified team")
+public class SubmittedBySpecifiedTeam extends TeamAwareGateKeeper {
private static final long serialVersionUID = 1L;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedUser.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedUser.java
similarity index 90%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedUser.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedUser.java
index ba252844bc..b5633c3aae 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfSubmittedBySpecifiedUser.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/SubmittedBySpecifiedUser.java
@@ -1,70 +1,70 @@
-package com.pmease.gitplex.core.gatekeeper;
-
-import org.eclipse.jgit.lib.ObjectId;
-import org.hibernate.validator.constraints.NotEmpty;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.pmease.commons.wicket.editable.annotation.Editable;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.annotation.AccountChoice;
-import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.entity.PullRequest;
-import com.pmease.gitplex.core.entity.Account;
-import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
-import com.pmease.gitplex.core.manager.AccountManager;
-
-@Editable(order=600, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=
- "This gate keeper will be passed if the commit is submitted by specified user")
-public class IfSubmittedBySpecifiedUser extends AbstractGateKeeper {
-
- private static final long serialVersionUID = 1L;
-
- private String userName;
-
- @Editable(name="Select User")
- @AccountChoice
- @NotEmpty
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- @Override
- public GateCheckResult doCheckRequest(PullRequest request) {
- return checkSubmitter(request.getSubmitter());
- }
-
- private GateCheckResult checkSubmitter(Account user) {
- Account expectedUser = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));
- if (expectedUser.equals(user))
- return passed(Lists.newArrayList("Submitted by " + expectedUser.getDisplayName()));
- else
- return failed(Lists.newArrayList("Not submitted by " + expectedUser.getDisplayName()));
- }
-
- @Override
- protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
- return checkSubmitter(user);
- }
-
- @Override
- protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {
- return checkSubmitter(user);
- }
-
- @Override
- public void onAccountRename(String oldName, String newName) {
- if (userName.equals(oldName))
- userName = newName;
- }
-
- @Override
- public boolean onAccountDelete(String accountName) {
- return userName.equals(accountName);
- }
-
-}
+package com.pmease.gitplex.core.gatekeeper;
+
+import org.eclipse.jgit.lib.ObjectId;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.pmease.commons.wicket.editable.annotation.Editable;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.annotation.AccountChoice;
+import com.pmease.gitplex.core.entity.Depot;
+import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.entity.Account;
+import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
+import com.pmease.gitplex.core.manager.AccountManager;
+
+@Editable(order=600, icon="fa-user", category=GateKeeper.CATEGORY_USER, description=
+ "This gatekeeper will be passed if the commit is submitted by specified user")
+public class SubmittedBySpecifiedUser extends AbstractGateKeeper {
+
+ private static final long serialVersionUID = 1L;
+
+ private String userName;
+
+ @Editable(name="Select User")
+ @AccountChoice
+ @NotEmpty
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ public GateCheckResult doCheckRequest(PullRequest request) {
+ return checkSubmitter(request.getSubmitter());
+ }
+
+ private GateCheckResult checkSubmitter(Account user) {
+ Account expectedUser = Preconditions.checkNotNull(GitPlex.getInstance(AccountManager.class).findByName(userName));
+ if (expectedUser.equals(user))
+ return passed(Lists.newArrayList("Submitted by " + expectedUser.getDisplayName()));
+ else
+ return failed(Lists.newArrayList("Not submitted by " + expectedUser.getDisplayName()));
+ }
+
+ @Override
+ protected GateCheckResult doCheckFile(Account user, Depot depot, String branch, String file) {
+ return checkSubmitter(user);
+ }
+
+ @Override
+ protected GateCheckResult doCheckPush(Account user, Depot depot, String refName, ObjectId oldCommit, ObjectId newCommit) {
+ return checkSubmitter(user);
+ }
+
+ @Override
+ public void onAccountRename(String oldName, String newName) {
+ if (userName.equals(oldName))
+ userName = newName;
+ }
+
+ @Override
+ public boolean onAccountDelete(String accountName) {
+ return userName.equals(accountName);
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedFiles.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedFiles.java
similarity index 95%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedFiles.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedFiles.java
index 0f5fa8ab6d..46ed789355 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedFiles.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedFiles.java
@@ -20,8 +20,8 @@ import com.pmease.gitplex.core.util.ParentAwareMatcher;
import com.pmease.gitplex.core.util.includeexclude.IncludeExcludeUtils;
@Editable(order=300, icon="fa-file-text", description=
- "This gate keeper will be passed if specified files are modified")
-public class IfTouchSpecifiedFiles extends AbstractGateKeeper {
+ "This gatekeeper will be passed if specified files are modified")
+public class TouchSpecifiedFiles extends AbstractGateKeeper {
private static final long serialVersionUID = 1L;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedRefs.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedRefs.java
similarity index 95%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedRefs.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedRefs.java
index 9a79c5f6d2..4ff0a8eb1e 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedRefs.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/TouchSpecifiedRefs.java
@@ -18,8 +18,8 @@ import com.pmease.gitplex.core.util.includeexclude.IncludeExcludeParser;
import com.pmease.gitplex.core.util.includeexclude.IncludeExcludeUtils;
@Editable(order=100, icon="fa-code-fork", description=
- "This gate keeper will be passed if specified refs is being touched")
-public class IfTouchSpecifiedRefs extends AbstractGateKeeper {
+ "This gatekeeper will be passed if specified refs is being touched")
+public class TouchSpecifiedRefs extends AbstractGateKeeper {
private static final long serialVersionUID = 1L;
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfVerifiedByBuilds.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/VerifiedByBuilds.java
similarity index 94%
rename from gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfVerifiedByBuilds.java
rename to gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/VerifiedByBuilds.java
index 5978359134..fc23e4659a 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfVerifiedByBuilds.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/VerifiedByBuilds.java
@@ -18,10 +18,10 @@ import com.pmease.gitplex.core.gatekeeper.checkresult.GateCheckResult;
import com.pmease.gitplex.core.manager.PullRequestVerificationManager;
@Editable(icon="fa-check-circle", order=1000,
- description="This gate keeper will be satisfied if commit is verified successfully "
+ description="This gatekeeper will be satisfied if commit is verified successfully "
+ "by specified number of builds. To make this working, your CI system has to "
+ "be configured to build against GitPlex pull requests")
-public class IfVerifiedByBuilds extends AbstractGateKeeper {
+public class VerifiedByBuilds extends AbstractGateKeeper {
private static final long serialVersionUID = 1L;
@@ -32,7 +32,7 @@ public class IfVerifiedByBuilds extends AbstractGateKeeper {
private boolean blockMode = true;
@Editable(order=100, description="This specified number of builds has to be reported successful "
- + "for this gate keeper to be passed. Normally this number represents number of build "
+ + "for this gatekeeper to be passed. Normally this number represents number of build "
+ "configurations setting up to verify the branch.")
@Min(1)
public int getLeastPassCount() {
@@ -52,7 +52,7 @@ public class IfVerifiedByBuilds extends AbstractGateKeeper {
this.checkIntegrated = checkIntegrated;
}
- @Editable(order=300, description="If this is checked, subsequent gate keepers will not be checked "
+ @Editable(order=300, description="If this is checked, subsequent gatekeepers will not be checked "
+ "while waiting for the build results. This can be used to only notify relevant voters "
+ "when the commit passes build.")
public boolean isBlockMode() {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/Blocking.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/Blocking.java
index a4f87bc59d..49f7cd7878 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/Blocking.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/Blocking.java
@@ -3,8 +3,8 @@ package com.pmease.gitplex.core.gatekeeper.checkresult;
import java.util.List;
/*
- * Same as Pending, but followed gate keeper should not be checked unless result
- * of this gate keeper has been determined.
+ * Same as Pending, but followed gatekeeper should not be checked unless result
+ * of this gatekeeper has been determined.
*/
@SuppressWarnings("serial")
public class Blocking extends GateCheckResult {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/GateCheckResult.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/GateCheckResult.java
index 1988338eef..4fe358cbd8 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/GateCheckResult.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/checkresult/GateCheckResult.java
@@ -36,7 +36,7 @@ public abstract class GateCheckResult implements Serializable {
return this instanceof Ignored;
}
- public boolean allowIntegration() {
+ public boolean isPassedOrIgnored() {
return isPassed() || isIgnored();
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/ConfigManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/ConfigManager.java
index 1047f38f9e..9d79cf1e53 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/ConfigManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/ConfigManager.java
@@ -1,63 +1,82 @@
-package com.pmease.gitplex.core.manager;
-
-import javax.annotation.Nullable;
-
-import com.pmease.commons.hibernate.dao.EntityManager;
-import com.pmease.gitplex.core.entity.Config;
-import com.pmease.gitplex.core.setting.MailSetting;
-import com.pmease.gitplex.core.setting.SystemSetting;
-
-public interface ConfigManager extends EntityManager<Config> {
-
- /**
- * Retrieve config by key.
- * <p>
- * @param key
- * key of the config
- * @return
- * config associated with specified key, or <tt>null</tt> if
- * no config record found for the key
- */
- Config getConfig(Config.Key key);
-
- /**
- * Get system setting.
- * <p>
- * @return
- * system setting, never <tt>null</tt>
- * @throws
- * RuntimeException if system setting record is not found
- * @throws
- * NullPointerException if system setting record exists but value is null
- */
- SystemSetting getSystemSetting();
-
- /**
- * Save specified system setting.
- * <p>
- * @param systemSetting
- * system setting to be saved
- */
- void saveSystemSetting(SystemSetting systemSetting);
-
- /**
- * Get mail setting.
- * <p>
- * @return
- * mail setting, or <tt>null</tt> if mail setting record exists but value is
- * null.
- * @throws
- * RuntimeException if mail setting record is not found
- */
- MailSetting getMailSetting();
-
- /**
- * Save specified mail setting.
- * <p>
- * @param mailSetting
- * mail setting to be saved. Use <tt>null</tt> to clear the setting (but
- * setting record will still be remained in database)
- */
- void saveMailSetting(@Nullable MailSetting mailSetting);
-
-}
+package com.pmease.gitplex.core.manager;
+
+import javax.annotation.Nullable;
+
+import com.pmease.commons.hibernate.dao.EntityManager;
+import com.pmease.gitplex.core.entity.Config;
+import com.pmease.gitplex.core.setting.BackupSetting;
+import com.pmease.gitplex.core.setting.MailSetting;
+import com.pmease.gitplex.core.setting.SystemSetting;
+
+public interface ConfigManager extends EntityManager<Config> {
+
+ /**
+ * Retrieve config by key.
+ * <p>
+ * @param key
+ * key of the config
+ * @return
+ * config associated with specified key, or <tt>null</tt> if
+ * no config record found for the key
+ */
+ Config getConfig(Config.Key key);
+
+ /**
+ * Get system setting.
+ * <p>
+ * @return
+ * system setting, never <tt>null</tt>
+ * @throws
+ * RuntimeException if system setting record is not found
+ * @throws
+ * NullPointerException if system setting record exists but value is null
+ */
+ SystemSetting getSystemSetting();
+
+ /**
+ * Save specified system setting.
+ * <p>
+ * @param systemSetting
+ * system setting to be saved
+ */
+ void saveSystemSetting(SystemSetting systemSetting);
+
+ /**
+ * Get mail setting.
+ * <p>
+ * @return
+ * mail setting, or <tt>null</tt> if mail setting record exists but value is
+ * null.
+ * @throws
+ * RuntimeException if mail setting record is not found
+ */
+ MailSetting getMailSetting();
+
+ /**
+ * Save specified mail setting.
+ * <p>
+ * @param mailSetting
+ * mail setting to be saved. Use <tt>null</tt> to clear the setting (but
+ * setting record will still be remained in database)
+ */
+ void saveMailSetting(@Nullable MailSetting mailSetting);
+
+ /**
+ * Get backup setting.
+ * <p>
+ * @return
+ * backup setting, or <tt>null</tt> if backup setting record exists but value is null
+ * @throws
+ * RuntimeException if backup setting record is not found
+ */
+ BackupSetting getBackupSetting();
+
+ /**
+ * Save specified backup setting.
+ * <p>
+ * @param backupSetting
+ * backup setting to be saved. Use <tt>null</tt> to clear the setting (but
+ * setting record will still be remained in database)
+ */
+ void saveBackupSetting(@Nullable BackupSetting backupSetting);
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/DataManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/DataManager.java
index 336e9b242f..7edb5ccc8e 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/DataManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/DataManager.java
@@ -1,11 +1,16 @@
-package com.pmease.gitplex.core.manager;
-
-import java.util.List;
-
-import com.pmease.commons.util.init.ManualConfig;
-
-public interface DataManager {
-
- List<ManualConfig> init();
-
-}
+package com.pmease.gitplex.core.manager;
+
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import com.pmease.commons.util.init.ManualConfig;
+import com.pmease.gitplex.core.setting.BackupSetting;
+
+public interface DataManager {
+
+ List<ManualConfig> init();
+
+ void scheduleBackup(@Nullable BackupSetting backupSetting);
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.java
index b9b8d24bda..e22743cb3d 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultAccountManager.java
@@ -28,7 +28,6 @@ import com.pmease.gitplex.core.entity.PullRequestStatusChange;
import com.pmease.gitplex.core.entity.support.IntegrationPolicy;
import com.pmease.gitplex.core.event.lifecycle.SystemStarting;
import com.pmease.gitplex.core.event.pullrequest.PullRequestStatusChangeEvent;
-import com.pmease.gitplex.core.gatekeeper.GateKeeper;
import com.pmease.gitplex.core.manager.AccountManager;
import com.pmease.gitplex.core.manager.DepotManager;
import com.pmease.gitplex.core.manager.PullRequestManager;
@@ -68,9 +67,7 @@ public class DefaultAccountManager extends AbstractEntityManager<Account> implem
for (IntegrationPolicy integrationPolicy: depot.getIntegrationPolicies()) {
integrationPolicy.onAccountRename(oldName, account.getName());
}
- for (GateKeeper gateKeeper: depot.getGateKeepers()) {
- gateKeeper.onAccountRename(oldName, account.getName());
- }
+ depot.getGateKeeper().onAccountRename(oldName, account.getName());
}
}
@@ -139,10 +136,7 @@ public class DefaultAccountManager extends AbstractEntityManager<Account> implem
if (it.next().onAccountDelete(account.getName()))
it.remove();
}
- for (Iterator<GateKeeper> it = depot.getGateKeepers().iterator(); it.hasNext();) {
- if (it.next().onAccountDelete(account.getName()))
- it.remove();
- }
+ depot.getGateKeeper().onAccountDelete(account.getName());
}
doAfterCommit(new Runnable() {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultConfigManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultConfigManager.java
index 2102eba6df..568de9b7c3 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultConfigManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultConfigManager.java
@@ -1,94 +1,128 @@
-package com.pmease.gitplex.core.manager.impl;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.hibernate.criterion.Restrictions;
-
-import com.google.common.base.Preconditions;
-import com.pmease.commons.hibernate.Sessional;
-import com.pmease.commons.hibernate.Transactional;
-import com.pmease.commons.hibernate.dao.AbstractEntityManager;
-import com.pmease.commons.hibernate.dao.Dao;
-import com.pmease.commons.hibernate.dao.EntityCriteria;
-import com.pmease.gitplex.core.entity.Config;
-import com.pmease.gitplex.core.entity.Config.Key;
-import com.pmease.gitplex.core.manager.ConfigManager;
-import com.pmease.gitplex.core.setting.MailSetting;
-import com.pmease.gitplex.core.setting.SystemSetting;
-
-@Singleton
-public class DefaultConfigManager extends AbstractEntityManager<Config> implements ConfigManager {
-
- private volatile Long systemSettingConfigId;
-
- private volatile Long mailSettingConfigId;
-
- @Inject
- public DefaultConfigManager(Dao dao) {
- super(dao);
- }
-
- @Sessional
- @Override
- public SystemSetting getSystemSetting() {
- Config config;
- if (systemSettingConfigId == null) {
- config = getConfig(Key.SYSTEM);
- Preconditions.checkNotNull(config);
- systemSettingConfigId = config.getId();
- } else {
- config = load(systemSettingConfigId);
- }
- SystemSetting setting = (SystemSetting) config.getSetting();
- Preconditions.checkNotNull(setting);
- return setting;
- }
-
- @Transactional
- @Override
- public void saveSystemSetting(SystemSetting systemSetting) {
- Preconditions.checkNotNull(systemSetting);
-
- Config config = getConfig(Key.SYSTEM);
- if (config == null) {
- config = new Config();
- config.setKey(Key.SYSTEM);
- }
- config.setSetting(systemSetting);
- dao.persist(config);
- }
-
- @Sessional
- @Override
- public Config getConfig(Key key) {
- return find(EntityCriteria.of(Config.class).add(Restrictions.eq("key", key)));
- }
-
- @Sessional
- @Override
- public MailSetting getMailSetting() {
- Config config;
- if (mailSettingConfigId == null) {
- config = getConfig(Key.MAIL);
- Preconditions.checkNotNull(config);
- mailSettingConfigId = config.getId();
- } else {
- config = load(mailSettingConfigId);
- }
- return (MailSetting) config.getSetting();
- }
-
- @Transactional
- @Override
- public void saveMailSetting(MailSetting mailSetting) {
- Config config = getConfig(Key.MAIL);
- if (config == null) {
- config = new Config();
- config.setKey(Key.MAIL);
- }
- config.setSetting(mailSetting);
- dao.persist(config);
- }
-
-}
+package com.pmease.gitplex.core.manager.impl;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.hibernate.criterion.Restrictions;
+
+import com.google.common.base.Preconditions;
+import com.pmease.commons.hibernate.Sessional;
+import com.pmease.commons.hibernate.Transactional;
+import com.pmease.commons.hibernate.dao.AbstractEntityManager;
+import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.commons.hibernate.dao.EntityCriteria;
+import com.pmease.gitplex.core.entity.Config;
+import com.pmease.gitplex.core.entity.Config.Key;
+import com.pmease.gitplex.core.manager.ConfigManager;
+import com.pmease.gitplex.core.manager.DataManager;
+import com.pmease.gitplex.core.setting.BackupSetting;
+import com.pmease.gitplex.core.setting.MailSetting;
+import com.pmease.gitplex.core.setting.SystemSetting;
+
+@Singleton
+public class DefaultConfigManager extends AbstractEntityManager<Config> implements ConfigManager {
+
+ private final DataManager dataManager;
+
+ private volatile Long systemSettingConfigId;
+
+ private volatile Long mailSettingConfigId;
+
+ private volatile Long backupSettingConfigId;
+
+ @Inject
+ public DefaultConfigManager(Dao dao, DataManager dataManager) {
+ super(dao);
+ this.dataManager = dataManager;
+ }
+
+ @Sessional
+ @Override
+ public SystemSetting getSystemSetting() {
+ Config config;
+ if (systemSettingConfigId == null) {
+ config = getConfig(Key.SYSTEM);
+ Preconditions.checkNotNull(config);
+ systemSettingConfigId = config.getId();
+ } else {
+ config = load(systemSettingConfigId);
+ }
+ SystemSetting setting = (SystemSetting) config.getSetting();
+ Preconditions.checkNotNull(setting);
+ return setting;
+ }
+
+ @Transactional
+ @Override
+ public void saveSystemSetting(SystemSetting systemSetting) {
+ Preconditions.checkNotNull(systemSetting);
+
+ Config config = getConfig(Key.SYSTEM);
+ if (config == null) {
+ config = new Config();
+ config.setKey(Key.SYSTEM);
+ }
+ config.setSetting(systemSetting);
+ dao.persist(config);
+ }
+
+ @Sessional
+ @Override
+ public Config getConfig(Key key) {
+ return find(EntityCriteria.of(Config.class).add(Restrictions.eq("key", key)));
+ }
+
+ @Sessional
+ @Override
+ public MailSetting getMailSetting() {
+ Config config;
+ if (mailSettingConfigId == null) {
+ config = getConfig(Key.MAIL);
+ Preconditions.checkNotNull(config);
+ mailSettingConfigId = config.getId();
+ } else {
+ config = load(mailSettingConfigId);
+ }
+ return (MailSetting) config.getSetting();
+ }
+
+ @Transactional
+ @Override
+ public void saveMailSetting(MailSetting mailSetting) {
+ Config config = getConfig(Key.MAIL);
+ if (config == null) {
+ config = new Config();
+ config.setKey(Key.MAIL);
+ }
+ config.setSetting(mailSetting);
+ dao.persist(config);
+ }
+
+ @Sessional
+ @Override
+ public BackupSetting getBackupSetting() {
+ Config config;
+ if (backupSettingConfigId == null) {
+ config = getConfig(Key.BACKUP);
+ Preconditions.checkNotNull(config);
+ backupSettingConfigId = config.getId();
+ } else {
+ config = load(backupSettingConfigId);
+ }
+ return (BackupSetting) config.getSetting();
+ }
+
+ @Transactional
+ @Override
+ public void saveBackupSetting(BackupSetting backupSetting) {
+ Config config = getConfig(Key.BACKUP);
+ if (config == null) {
+ config = new Config();
+ config.setKey(Key.BACKUP);
+ }
+ config.setSetting(backupSetting);
+ dao.persist(config);
+ dataManager.scheduleBackup(backupSetting);
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDataManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDataManager.java
index 3f882ac3f8..5f05342f8d 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDataManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDataManager.java
@@ -1,5 +1,6 @@
package com.pmease.gitplex.core.manager.impl;
+import java.io.File;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.ArrayList;
@@ -9,39 +10,73 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import javax.validation.Validator;
+import org.joda.time.DateTime;
+import org.joda.time.format.DateTimeFormat;
+import org.quartz.CronScheduleBuilder;
+import org.quartz.ScheduleBuilder;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+import com.pmease.commons.bootstrap.Bootstrap;
+import com.pmease.commons.bootstrap.BootstrapUtils;
import com.pmease.commons.hibernate.IdManager;
+import com.pmease.commons.hibernate.PersistManager;
+import com.pmease.commons.hibernate.Sessional;
import com.pmease.commons.hibernate.Transactional;
+import com.pmease.commons.loader.Listen;
import com.pmease.commons.loader.ManagedSerializedForm;
+import com.pmease.commons.schedule.SchedulableTask;
+import com.pmease.commons.schedule.TaskScheduler;
+import com.pmease.commons.util.FileUtils;
import com.pmease.commons.util.init.ManualConfig;
import com.pmease.commons.util.init.Skippable;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.Account;
import com.pmease.gitplex.core.entity.Config;
import com.pmease.gitplex.core.entity.Config.Key;
+import com.pmease.gitplex.core.event.lifecycle.SystemStarting;
import com.pmease.gitplex.core.manager.AccountManager;
import com.pmease.gitplex.core.manager.ConfigManager;
import com.pmease.gitplex.core.manager.DataManager;
+import com.pmease.gitplex.core.manager.MailManager;
+import com.pmease.gitplex.core.setting.BackupSetting;
import com.pmease.gitplex.core.setting.MailSetting;
import com.pmease.gitplex.core.setting.SystemSetting;
@Singleton
public class DefaultDataManager implements DataManager, Serializable {
+ private static final String BACKUP_DATETIME_FORMAT = "yyyy-MM-dd_HH-mm-ss";
+
private final AccountManager accountManager;
private final ConfigManager configManager;
private final IdManager idManager;
+ private final TaskScheduler taskScheduler;
+
private final Validator validator;
+ private final PersistManager persistManager;
+
+ private final MailManager mailManager;
+
+ private String backupTaskId;
+
@Inject
- public DefaultDataManager(IdManager idManager, AccountManager accountManager, ConfigManager configManager, Validator validator) {
+ public DefaultDataManager(IdManager idManager, AccountManager accountManager,
+ ConfigManager configManager, TaskScheduler taskScheduler,
+ PersistManager persistManager, MailManager mailManager,
+ Validator validator) {
this.accountManager = accountManager;
this.configManager = configManager;
this.validator = validator;
this.idManager = idManager;
+ this.taskScheduler = taskScheduler;
+ this.persistManager = persistManager;
+ this.mailManager = mailManager;
}
@SuppressWarnings("serial")
@@ -128,9 +163,89 @@ public class DefaultDataManager implements DataManager, Serializable {
});
}
+ Config backupConfig = configManager.getConfig(Key.BACKUP);
+ if (backupConfig == null) {
+ configManager.saveBackupSetting(null);
+ } else if (backupConfig.getSetting() != null && !validator.validate(backupConfig.getSetting()).isEmpty()) {
+ Serializable backupSetting = backupConfig.getSetting();
+ manualConfigs.add(new ManualConfig("Specify Backup Setting", backupSetting) {
+
+ @Override
+ public Skippable getSkippable() {
+ return null;
+ }
+
+ @Override
+ public void complete() {
+ configManager.saveBackupSetting((BackupSetting) getSetting());
+ }
+
+ });
+ }
+
return manualConfigs;
}
+ @Override
+ public void scheduleBackup(BackupSetting backupSetting) {
+ if (backupTaskId != null)
+ taskScheduler.unschedule(backupTaskId);
+ if (backupSetting != null) {
+ backupTaskId = taskScheduler.schedule(new SchedulableTask() {
+
+ @Override
+ public void execute() {
+ File tempDir = null;
+ try {
+ File backupDir = new File(backupSetting.getFolder());
+ if (!backupDir.isAbsolute())
+ backupDir = new File(Bootstrap.installDir, backupSetting.getFolder());
+ if (!backupDir.exists()) {
+ throw new RuntimeException("Backup directory does not exist: " + backupDir.getAbsolutePath());
+ }
+ tempDir = FileUtils.createTempDir("backup");
+ persistManager.exportData(tempDir, BackupSetting.BATCH_SIZE);
+ File backupFile = new File(backupDir,
+ DateTimeFormat.forPattern(BACKUP_DATETIME_FORMAT).print(new DateTime()) + ".zip");
+ BootstrapUtils.zip(tempDir, backupFile);
+ } catch (Exception e) {
+ notifyBackupError(e);
+ throw Throwables.propagate(e);
+ } finally {
+ if (tempDir != null)
+ FileUtils.deleteDir(tempDir);
+ }
+ }
+
+ @Override
+ public ScheduleBuilder<?> getScheduleBuilder() {
+ return CronScheduleBuilder.cronSchedule(backupSetting.getSchedule());
+ }
+
+ });
+ }
+ }
+
+ @Listen
+ public void on(SystemStarting event) {
+ scheduleBackup(configManager.getBackupSetting());
+ }
+
+ @Sessional
+ protected void notifyBackupError(Exception e) {
+ Account root = accountManager.getRoot();
+ String url = configManager.getSystemSetting().getServerUrl();
+ String body = String.format(""
+ + "GitPlex url: <a href='%s'>%s</a>"
+ + "<p style='margin: 16px 0;'>"
+ + "<b>Error detail:</b>"
+ + "<pre style='font-family: monospace;'>%s</pre>"
+ + "<p style='margin: 16px 0;'>"
+ + "-- Sent by GitPlex",
+ url, url, Throwables.getStackTraceAsString(e));
+ mailManager.sendMail(Lists.newArrayList(root), "GitPlex database auto-backup failed", body);
+ }
+
public Object writeReplace() throws ObjectStreamException {
return new ManagedSerializedForm(DataManager.class);
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDepotManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDepotManager.java
index ea2df2bc26..b4f33206de 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDepotManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultDepotManager.java
@@ -51,7 +51,7 @@ import com.pmease.gitplex.core.event.depot.DepotTransferred;
import com.pmease.gitplex.core.event.lifecycle.SystemStarted;
import com.pmease.gitplex.core.event.lifecycle.SystemStarting;
import com.pmease.gitplex.core.event.lifecycle.SystemStopping;
-import com.pmease.gitplex.core.gatekeeper.GateKeeper;
+import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;
import com.pmease.gitplex.core.manager.AccountManager;
import com.pmease.gitplex.core.manager.CodeCommentInfoManager;
import com.pmease.gitplex.core.manager.CommitInfoManager;
@@ -144,10 +144,8 @@ public class DefaultDepotManager extends AbstractEntityManager<Depot> implements
for (IntegrationPolicy policy: each.getIntegrationPolicies()) {
policy.onDepotTransfer(depot, oldAccount);
}
- for (Iterator<GateKeeper> it = each.getGateKeepers().iterator(); it.hasNext();) {
- if (it.next().onDepotTransfer(each, depot, oldAccount))
- it.remove();
- }
+ if (each.getGateKeeper().onDepotTransfer(each, depot, oldAccount))
+ each.setGateKeeper(new DefaultGateKeeper());
}
}
if (oldName != null && !depot.getName().equals(oldName)) {
@@ -157,9 +155,7 @@ public class DefaultDepotManager extends AbstractEntityManager<Depot> implements
for (IntegrationPolicy integrationPolicy: each.getIntegrationPolicies()) {
integrationPolicy.onDepotRename(depot.getAccount(), oldName, depot.getName());
}
- for (GateKeeper gateKeeper: each.getGateKeepers()) {
- gateKeeper.onDepotRename(depot, oldName);
- }
+ each.getGateKeeper().onDepotRename(depot, oldName);
}
}
@@ -199,10 +195,8 @@ public class DefaultDepotManager extends AbstractEntityManager<Depot> implements
if (it.next().onDepotDelete(depot))
it.remove();
}
- for (Iterator<GateKeeper> it = each.getGateKeepers().iterator(); it.hasNext();) {
- if (it.next().onDepotDelete(depot))
- it.remove();
- }
+ if (each.getGateKeeper().onDepotDelete(depot))
+ each.setGateKeeper(new DefaultGateKeeper());
}
doAfterCommit(new Runnable() {
@@ -340,10 +334,8 @@ public class DefaultDepotManager extends AbstractEntityManager<Depot> implements
it.remove();
}
}
- for (Iterator<GateKeeper> it = each.getGateKeepers().iterator(); it.hasNext();) {
- if (it.next().onRefDelete(event.getRefName()))
- it.remove();
- }
+ if (each.getGateKeeper().onRefDelete(event.getRefName()))
+ each.setGateKeeper(new DefaultGateKeeper());
}
}
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultTeamManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultTeamManager.java
index eecff67544..0f31192699 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultTeamManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultTeamManager.java
@@ -1,7 +1,5 @@
package com.pmease.gitplex.core.manager.impl;
-import java.util.Iterator;
-
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -15,7 +13,7 @@ import com.pmease.commons.hibernate.dao.EntityCriteria;
import com.pmease.gitplex.core.entity.Account;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.Team;
-import com.pmease.gitplex.core.gatekeeper.GateKeeper;
+import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;
import com.pmease.gitplex.core.manager.TeamManager;
@Singleton
@@ -31,9 +29,7 @@ public class DefaultTeamManager extends AbstractEntityManager<Team> implements T
public void save(Team team, String oldName) {
if (oldName != null && !oldName.equals(team.getName())) {
for (Depot depot: team.getOrganization().getDepots()) {
- for (GateKeeper gateKeeper: depot.getGateKeepers()) {
- gateKeeper.onTeamRename(oldName, team.getName());
- }
+ depot.getGateKeeper().onTeamRename(oldName, team.getName());
}
}
dao.persist(team);
@@ -43,10 +39,8 @@ public class DefaultTeamManager extends AbstractEntityManager<Team> implements T
@Override
public void delete(Team team) {
for (Depot depot: team.getOrganization().getDepots()) {
- for (Iterator<GateKeeper> it = depot.getGateKeepers().iterator(); it.hasNext();) {
- if (it.next().onTeamDelete(team.getName()))
- it.remove();
- }
+ if (depot.getGateKeeper().onTeamDelete(team.getName()))
+ depot.setGateKeeper(new DefaultGateKeeper());
}
dao.remove(team);
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/migration/DataMigrator.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/migration/DataMigrator.java
new file mode 100644
index 0000000000..ad276c571d
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/migration/DataMigrator.java
@@ -0,0 +1,10 @@
+package com.pmease.gitplex.core.migration;
+
+import javax.inject.Singleton;
+
+import com.pmease.commons.hibernate.migration.Migrator;
+
+@Singleton
+public class DataMigrator implements Migrator {
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.java
index de0a33faaf..ad7705c655 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/security/SecurityUtils.java
@@ -96,11 +96,11 @@ public class SecurityUtils extends org.apache.shiro.SecurityUtils {
Account currentUser = getAccount();
return currentUser != null
&& currentUser.asSubject().isPermitted(ObjectPermission.ofDepotWrite(depot))
- && depot.getGateKeeper().checkPush(currentUser, depot, refName, oldCommit, newCommit).isPassed();
+ && depot.getGateKeeper().checkPush(currentUser, depot, refName, oldCommit, newCommit).isPassedOrIgnored();
}
public static boolean canModify(Depot depot, String branch, @Nullable String file) {
- return canWrite(depot) && depot.getGateKeeper().checkFile(getAccount(), depot, branch, file).isPassed();
+ return canWrite(depot) && depot.getGateKeeper().checkFile(getAccount(), depot, branch, file).isPassedOrIgnored();
}
public static boolean canManage(Account account) {
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/setting/BackupSetting.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/setting/BackupSetting.java
new file mode 100644
index 0000000000..9a6be08cf4
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/setting/BackupSetting.java
@@ -0,0 +1,104 @@
+package com.pmease.gitplex.core.setting;
+
+import java.io.File;
+import java.io.Serializable;
+import java.text.ParseException;
+import java.util.UUID;
+
+import javax.validation.ConstraintValidatorContext;
+
+import org.hibernate.validator.constraints.NotEmpty;
+import org.quartz.CronExpression;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.pmease.commons.bootstrap.Bootstrap;
+import com.pmease.commons.util.FileUtils;
+import com.pmease.commons.validation.ClassValidating;
+import com.pmease.commons.validation.Validatable;
+import com.pmease.commons.wicket.editable.annotation.Editable;
+
+@Editable
+@ClassValidating
+public class BackupSetting implements Serializable, Validatable {
+
+ private static final long serialVersionUID = 1L;
+
+ private final static Logger logger = LoggerFactory.getLogger(BackupSetting.class);
+
+ public static final int BATCH_SIZE = 1000;
+
+ private String schedule;
+
+ private String folder;
+
+ @Editable(order=100, name="Backup Schedule", description=
+ "Optionally specify a cron expression to schedule database auto-backup. The cron expression format is " +
+ "<em>&lt;seconds&gt; &lt;minutes&gt; &lt;hours&gt; &lt;day-of-month&gt; &lt;month&gt; &lt;day-of-week&gt;</em>." +
+ "For example, <em>0 0 1 * * ?</em> means 1:00am every day. For details of the format, refer " +
+ "to <a href='http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06'>Quartz tutorial</a>." +
+ "The backup files will be placed into <em>backup</em> folder under GitPlex " +
+ "installation directory. Leave this property empty if you do not want to enable database " +
+ "auto backup.")
+ @NotEmpty
+ public String getSchedule() {
+ return schedule;
+ }
+
+ public void setSchedule(String schedule) {
+ this.schedule = schedule;
+ }
+
+ @Editable(order=200, name="Backup Directory", description=
+ "Specify the directory to which the auto backup files will be stored. Non-absolute path " +
+ "will be considered to be relative to installation directory of GitPlex.")
+ @NotEmpty
+ public String getFolder() {
+ return folder;
+ }
+
+ public void setFolder(String folder) {
+ this.folder = folder;
+ }
+
+ @Override
+ public boolean isValid(ConstraintValidatorContext context) {
+ boolean hasErrors = false;
+ if (schedule != null) {
+ try {
+ new CronExpression(schedule);
+ } catch (ParseException e) {
+ context.buildConstraintViolationWithTemplate(e.getMessage())
+ .addPropertyNode("schedule").addConstraintViolation();
+ hasErrors = true;
+ }
+ }
+ if (folder != null) {
+ File folder = new File(getFolder());
+ if (!folder.isAbsolute())
+ folder = new File(Bootstrap.installDir, getFolder());
+ if (!folder.exists()) {
+ context.buildConstraintViolationWithTemplate("Backup directory does not exist")
+ .addPropertyNode("folder").addConstraintViolation();
+ hasErrors = true;
+ } else {
+ // test file permission
+ File tempFile = new File(folder, UUID.randomUUID().toString());
+ try {
+ tempFile.createNewFile();
+ FileUtils.deleteFile(tempFile);
+ } catch (Exception e) {
+ logger.error("Error testing backup directory.", e);
+ context.buildConstraintViolationWithTemplate("Unable to create test file under backup directory. "
+ + "Please make sure the user running GitPlex process has write permission to the backup directory.")
+ .addPropertyNode("folder").addConstraintViolation();
+ hasErrors = true;
+ }
+ }
+ }
+ if (hasErrors)
+ context.disableDefaultConstraintViolation();
+ return !hasErrors;
+ }
+
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/util/ParentAwareMatcher.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/util/ParentAwareMatcher.java
index 04ef9ae94e..8e59032801 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/util/ParentAwareMatcher.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/util/ParentAwareMatcher.java
@@ -1,30 +1,30 @@
-package com.pmease.gitplex.core.util;
-
-/**
- * Besides the normal child aware match, this matcher also matches
- * parent path ending with slash. For instance, if pattern is defined
- * as &quot;parent/child&quot;, it will match value &quot;parent/&quot;.
- * A scenario using this matcher:
- * <ol>
- * <li> A gate keeper is defined to require that all created tags should match
- * the format &quot;refs/tags/v*&quot;
- * <li> The tag creation link checks the gate keeper using ref value &quot;refs/tags/&quot;
- * to see if tag creation is allowed, and it matches meaning one can create tag
- * <li> User then input tag name, and this name will be matched again with the gate keeper
- * and if it does not starts with letter &quot;v&quot;, the tag creation will not be allowed
- *
- * @author robin
- *
- */
-public class ParentAwareMatcher extends ChildAwareMatcher {
-
- @Override
- public boolean matches(String rule, String value) {
- if (rule.startsWith(value) && value.endsWith("/")) {
- return true;
- } else {
- return super.matches(rule, value);
- }
- }
-
-}
+package com.pmease.gitplex.core.util;
+
+/**
+ * Besides the normal child aware match, this matcher also matches
+ * parent path ending with slash. For instance, if pattern is defined
+ * as &quot;parent/child&quot;, it will match value &quot;parent/&quot;.
+ * A scenario using this matcher:
+ * <ol>
+ * <li> A gatekeeper is defined to require that all created tags should match
+ * the format &quot;refs/tags/v*&quot;
+ * <li> The tag creation link checks the gatekeeper using ref value &quot;refs/tags/&quot;
+ * to see if tag creation is allowed, and it matches meaning one can create tag
+ * <li> User then input tag name, and this name will be matched again with the gatekeeper
+ * and if it does not starts with letter &quot;v&quot;, the tag creation will not be allowed
+ *
+ * @author robin
+ *
+ */
+public class ParentAwareMatcher extends ChildAwareMatcher {
+
+ @Override
+ public boolean matches(String rule, String value) {
+ if (rule.startsWith(value) && value.endsWith("/")) {
+ return true;
+ } else {
+ return super.matches(rule, value);
+ }
+ }
+
+}
diff --git a/gitplex.product/src/test/java/gitplex/product/Test.java b/gitplex.product/src/test/java/gitplex/product/Test.java
index 01392fb01b..1dc75c4121 100644
--- a/gitplex.product/src/test/java/gitplex/product/Test.java
+++ b/gitplex.product/src/test/java/gitplex/product/Test.java
@@ -1,10 +1,16 @@
package gitplex.product;
+import java.lang.reflect.Field;
+
+import com.pmease.commons.hibernate.migration.VersionTable;
+
public class Test {
@org.junit.Test
public void test() {
- System.out.println(Test.class.getSimpleName());
+ for (Field field: VersionTable.class.getFields()) {
+ System.out.println(field.getName());
+ }
}
-
+
}
\ No newline at end of file
diff --git a/gitplex.product/system/conf/hibernate.properties b/gitplex.product/system/conf/hibernate.properties
index 763b6aa336..1fadcd401f 100644
--- a/gitplex.product/system/conf/hibernate.properties
+++ b/gitplex.product/system/conf/hibernate.properties
@@ -103,7 +103,6 @@ hibernate.use_sql_comments=true
javax.persistence.validation.mode=none
hibernate.validator.apply_to_ddl=false
-hibernate.hbm2ddl.auto=update
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
hibernate.cache.use_query_cache=true
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/createbranch/CreateBranchPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/createbranch/CreateBranchPanel.java
index 1e0b71925c..eb28e9d3fa 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/createbranch/CreateBranchPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/createbranch/CreateBranchPanel.java
@@ -88,7 +88,7 @@ abstract class CreateBranchPanel extends Panel {
Account user = Preconditions.checkNotNull(SecurityUtils.getAccount());
GateCheckResult checkResult = depot.getGateKeeper().checkPush(user,
depot, Constants.R_HEADS + branchName, ObjectId.zeroId(), commitId);
- if (!checkResult.isPassed()) {
+ if (!checkResult.isPassedOrIgnored()) {
form.error(Joiner.on(", ").join(checkResult.getReasons()));
target.focusComponent(nameInput);
target.add(form);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/createtag/CreateTagPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/createtag/CreateTagPanel.java
index 0466210158..a627b89dd5 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/createtag/CreateTagPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/createtag/CreateTagPanel.java
@@ -108,7 +108,7 @@ abstract class CreateTagPanel extends Panel {
Account user = Preconditions.checkNotNull(SecurityUtils.getAccount());
GateCheckResult checkResult = depot.getGateKeeper().checkPush(user,
depot, Constants.R_TAGS + tagName, ObjectId.zeroId(), commitId);
- if (!checkResult.isPassed()) {
+ if (!checkResult.isPassedOrIgnored()) {
form.error(Joiner.on(", ").join(checkResult.getReasons()));
target.focusComponent(nameInput);
target.add(form);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/privilegeselection/PrivilegeSelectionPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/privilegeselection/PrivilegeSelectionPanel.html
index 99a2009c27..18e651ca90 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/privilegeselection/PrivilegeSelectionPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/privilegeselection/PrivilegeSelectionPanel.html
@@ -1,18 +1,18 @@
-<wicket:panel>
- <div class="privilege selection">
- <a wicket:id="read">
- <div class="title">Read</div>
- <div class="description">Able to pull and browse the repository</div>
- </a>
- <a wicket:id="write">
- <div class="title">Write</div>
- <div class="description">Has full read privilege, and can also push to
- the repository unless gate keeper prevents</div>
- </a>
- <a wicket:id="admin">
- <div class="title">Admin</div>
- <div class="description">Has full write privilege, and can also manage
- settings of the repository</div>
- </a>
- </div>
+<wicket:panel>
+ <div class="privilege selection">
+ <a wicket:id="read">
+ <div class="title">Read</div>
+ <div class="description">Able to pull and browse the repository</div>
+ </a>
+ <a wicket:id="write">
+ <div class="title">Write</div>
+ <div class="description">Has full read privilege, and can also push to
+ the repository unless gatekeeper prevents</div>
+ </a>
+ <a wicket:id="admin">
+ <div class="title">Admin</div>
+ <div class="description">Has full write privilege, and can also manage
+ settings of the repository</div>
+ </a>
+ </div>
</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/requestreviewer/ReviewerAvatar.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/requestreviewer/ReviewerAvatar.java
index ba8cc1cb23..7851a6aa4e 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/requestreviewer/ReviewerAvatar.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/pullrequest/requestreviewer/ReviewerAvatar.java
@@ -62,13 +62,13 @@ public class ReviewerAvatar extends RemoveableAvatar {
if (nowInvited.contains(invitation.getUser())) {
getSession().warn("Reviewer '" + invitation.getUser().getDisplayName()
- + "' is required by gate keeper and can not be removed");
+ + "' is required by gatekeeper and can not be removed");
} else {
nowInvited.removeAll(prevInvited);
if (!nowInvited.isEmpty()) {
getSession().warn("Reviewer '" + invitation.getUser().getDisplayName()
+ "' is removed and user '" + nowInvited.iterator().next().getDisplayName()
- + "' is added as reviewer automatically to satisfy gate keeper requirement.");
+ + "' is added as reviewer automatically to satisfy gatekeeper requirement.");
}
}
if (!request.isNew()) {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/mapper/UrlMapper.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/mapper/UrlMapper.java
index 374618750f..0569a73d6e 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/mapper/UrlMapper.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/mapper/UrlMapper.java
@@ -27,6 +27,7 @@ import com.pmease.gitplex.web.page.account.teams.TeamDepotListPage;
import com.pmease.gitplex.web.page.account.teams.TeamEditPage;
import com.pmease.gitplex.web.page.account.teams.TeamListPage;
import com.pmease.gitplex.web.page.account.teams.TeamMemberListPage;
+import com.pmease.gitplex.web.page.admin.DatabaseBackupPage;
import com.pmease.gitplex.web.page.admin.MailSettingPage;
import com.pmease.gitplex.web.page.admin.SystemSettingPage;
import com.pmease.gitplex.web.page.admin.account.AccountListPage;
@@ -101,6 +102,7 @@ public class UrlMapper extends CompoundRequestMapper {
add(new NoVersionMountedMapper("administration/accounts/new", NewUserPage.class));
add(new NoVersionMountedMapper("administration/settings/system", SystemSettingPage.class));
add(new NoVersionMountedMapper("administration/settings/mail", MailSettingPage.class));
+ add(new NoVersionMountedMapper("administration/settings/backup", DatabaseBackupPage.class));
}
private void addAccountPages() {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/AdministrationPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/AdministrationPage.java
index ec782fbdf8..39e598bacc 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/AdministrationPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/AdministrationPage.java
@@ -31,6 +31,7 @@ public abstract class AdministrationPage extends LayoutPage {
tabs.add(new AdministrationTab("All Accounts", "fa fa-fw fa-users", AccountListPage.class, NewUserPage.class));
tabs.add(new AdministrationTab("System Setting", "fa fa-fw fa-sliders", SystemSettingPage.class));
tabs.add(new AdministrationTab("Mail Setting", "fa fa-fw fa-envelope", MailSettingPage.class));
+ tabs.add(new AdministrationTab("Database Backup", "fa fa-fw fa-database", DatabaseBackupPage.class));
add(new Tabbable("tabs", tabs));
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/BackupSettingHolder.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/BackupSettingHolder.java
new file mode 100644
index 0000000000..e114918d6e
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/BackupSettingHolder.java
@@ -0,0 +1,24 @@
+package com.pmease.gitplex.web.page.admin;
+
+import java.io.Serializable;
+
+import com.pmease.commons.wicket.editable.annotation.Editable;
+import com.pmease.gitplex.core.setting.BackupSetting;
+
+@Editable
+public class BackupSettingHolder implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private BackupSetting backupSetting;
+
+ @Editable(name="Enable Auto Backup")
+ public BackupSetting getBackupSetting() {
+ return backupSetting;
+ }
+
+ public void setBackupSetting(BackupSetting backupSetting) {
+ this.backupSetting = backupSetting;
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/DatabaseBackupPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/DatabaseBackupPage.html
new file mode 100644
index 0000000000..96ae37a0d8
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/DatabaseBackupPage.html
@@ -0,0 +1,11 @@
+<wicket:extend>
+ <div class="database-backup">
+ <form wicket:id="backupSetting" class="leave-confirm">
+ <div wicket:id="editor"></div>
+ <div class="actions">
+ <input type="submit" class="btn btn-primary dirty-aware" value="Save setting"></input>
+ <a wicket:id="backupNow" class="btn btn-primary">Backup now</a>
+ </div>
+ </form>
+ </div>
+</wicket:extend>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/DatabaseBackupPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/DatabaseBackupPage.java
new file mode 100644
index 0000000000..0c32faf915
--- /dev/null
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/DatabaseBackupPage.java
@@ -0,0 +1,72 @@
+package com.pmease.gitplex.web.page.admin;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.tika.mime.MimeTypes;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.link.ResourceLink;
+import org.apache.wicket.request.resource.AbstractResource;
+
+import com.pmease.commons.bootstrap.BootstrapUtils;
+import com.pmease.commons.hibernate.PersistManager;
+import com.pmease.commons.util.FileUtils;
+import com.pmease.commons.wicket.editable.BeanContext;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.manager.ConfigManager;
+import com.pmease.gitplex.core.setting.BackupSetting;
+
+@SuppressWarnings("serial")
+public class DatabaseBackupPage extends AdministrationPage {
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ BackupSettingHolder backupSettingHolder = new BackupSettingHolder();
+ backupSettingHolder.setBackupSetting(GitPlex.getInstance(ConfigManager.class).getBackupSetting());
+ Form<?> form = new Form<Void>("backupSetting") {
+
+ @Override
+ protected void onSubmit() {
+ super.onSubmit();
+ GitPlex.getInstance(ConfigManager.class).saveBackupSetting(backupSettingHolder.getBackupSetting());
+ getSession().success("Backup setting has been updated");
+
+ setResponsePage(DatabaseBackupPage.class);
+ }
+
+ };
+ form.add(BeanContext.editBean("editor", backupSettingHolder));
+ form.add(new ResourceLink<Void>("backupNow", new AbstractResource() {
+
+ @Override
+ protected ResourceResponse newResourceResponse(Attributes attributes) {
+ ResourceResponse response = new ResourceResponse();
+ response.setContentType(MimeTypes.OCTET_STREAM);
+ response.disableCaching();
+ response.setFileName("backup.zip");
+ response.setWriteCallback(new WriteCallback() {
+
+ @Override
+ public void writeData(Attributes attributes) throws IOException {
+ File tempDir = FileUtils.createTempDir("backup");
+ try {
+ GitPlex.getInstance(PersistManager.class).exportData(tempDir, BackupSetting.BATCH_SIZE);
+ BootstrapUtils.zip(tempDir, attributes.getResponse().getOutputStream());
+ } finally {
+ FileUtils.deleteDir(tempDir);
+ }
+ }
+ });
+
+ return response;
+
+ }
+
+ }));
+
+ add(form);
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/administration.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/administration.css
index f2db243c2c..d53394be85 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/administration.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/admin/administration.css
@@ -1,9 +1,12 @@
-#administration.sidebar>table>tbody>tr>td.content {
- padding: 20px;
-}
-.account.list .type {
- width: 20%;
-}
-.account.list .actions {
- width: 10%;
+#administration.sidebar>table>tbody>tr>td.content {
+ padding: 20px;
+}
+.account.list .type {
+ width: 20%;
+}
+.account.list .actions {
+ width: 10%;
+}
+.auto-backup {
+ margin-bottom: 20px;
}
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html
index 6fbf3a2ba9..56762abcb8 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/newrequest/NewRequestPage.html
@@ -1,106 +1,106 @@
-<wicket:extend>
- <div id="new-request">
- <div class="head">Open Pull Request</div>
- <div class="body">
- <div class="branches clearfix">
- <div class="branch pull-left">
- <label>Target</label>
- <div wicket:id="target"></div>
- </div>
- <div class="action pull-left">
- <a wicket:id="swap" title="Swap" class="swap btn btn-default"><i class="fa fa-exchange"></i></a>
- </div>
- <div class="branch pull-left">
- <label>Source</label>
- <div wicket:id="source"></div>
- </div>
- </div>
- <div wicket:id="status" class="status"></div>
- <ul wicket:id="tabs" class="nav nav-tabs"></ul>
- <div wicket:id="tabPanel" class="tab-panel"></div>
- </div>
- </div>
- <wicket:fragment wicket:id="openedFrag">
- <div class="alert alert-info">
- <div>Pull request #<span wicket:id="no"></span> is already open for this comparison:</div>
- <b><a wicket:id="link"><span wicket:id="label"></span></a></b>
- </div>
- </wicket:fragment>
- <wicket:fragment wicket:id="sameBranchFrag">
- <div class="alert alert-warning">
- <div class="summary">
- <span class="fa fa-lg fa-warning"></span>
- <span>Please select different branches to integrate.</span>
- </div>
- </div>
- </wicket:fragment>
- <wicket:fragment wicket:id="integratedFrag">
- <div class="alert alert-success">
- <div class="summary">
- <span class="fa fa-lg fa-check-circle"></span>
- <a wicket:id="targetBranch"></a> is up to date with all commits from <a wicket:id="sourceBranch"></a>.
- Try <a wicket:id="swapBranches">swap source and target</a> for the comparison.
- </div>
- </div>
- </wicket:fragment>
- <wicket:fragment wicket:id="rejectedFrag">
- <div class="alert alert-danger">
- <div class="summary">
- <span class="fa fa-lg fa-ban"></span>
- <span class="message">Gate keeper of target repository rejects the integration request for below reasons:</span>
- </div>
- <ul class="detail">
- <li wicket:id="reasons"><span wicket:id="reason"></span></li>
- </ul>
- </div>
- </wicket:fragment>
- <wicket:fragment wicket:id="canSendFrag">
- <div class="can-send">
- <form wicket:id="form">
- <table>
- <tr class="title">
- <td class="name">Title <span class="required"></span></td>
- <td wicket:id="title" class="value">
- <input wicket:id="title" type="text" class="form-control focusable" placeholder="Input title here">
- <div wicket:id="feedback"></div>
- </td>
- </tr>
- <tr class="description">
- <td class="name">Description</td>
- <td class="value"><textarea wicket:id="comment" rows="5" class="form-control focusable"></textarea></td>
- </tr>
- <tr class="assignee">
- <td class="name">Assignee <span class="required"></span></td>
- <td wicket:id="assignee" class="value">
- <input wicket:id="assignee" type="hidden"></input>
- <div wicket:id="feedback"></div>
- <div class="help-block">
- <i class="fa fa-info-circle"></i> Assignee is responsible for integration of the
- pull request after it passes gate keeper check.
- </div>
- </td>
- </tr>
- <tr class="reviewers">
- <td class="name">Reviewers</td>
- <td wicket:id="reviewers" class="value">
- <ul class="clearfix list-unstyled">
- <li wicket:id="reviewers" class="pull-left">
- <a wicket:id="avatar"></a>
- </li>
- <wicket:enclosure child="addReviewer">
- <li class="pull-left"><input wicket:id="addReviewer" type="hidden"></input></li>
- </wicket:enclosure>
- </ul>
- <div wicket:id="prePopulateHint" class="help-block">
- <i class="fa fa-info-circle"></i> GitPlex pre-populated some reviewers above as suggested
- by gate keeper of the repository. You may adjust the list by removing existing (hovering mouse
- over reviewer avatar) or adding more.
- </div>
- </td>
- </tr>
- </table>
- <input wicket:id="send" type="submit" class="btn btn-primary" value="Send Pull Request"></input>
- </form>
- </div>
- </wicket:fragment>
+<wicket:extend>
+ <div id="new-request">
+ <div class="head">Open Pull Request</div>
+ <div class="body">
+ <div class="branches clearfix">
+ <div class="branch pull-left">
+ <label>Target</label>
+ <div wicket:id="target"></div>
+ </div>
+ <div class="action pull-left">
+ <a wicket:id="swap" title="Swap" class="swap btn btn-default"><i class="fa fa-exchange"></i></a>
+ </div>
+ <div class="branch pull-left">
+ <label>Source</label>
+ <div wicket:id="source"></div>
+ </div>
+ </div>
+ <div wicket:id="status" class="status"></div>
+ <ul wicket:id="tabs" class="nav nav-tabs"></ul>
+ <div wicket:id="tabPanel" class="tab-panel"></div>
+ </div>
+ </div>
+ <wicket:fragment wicket:id="openedFrag">
+ <div class="alert alert-info">
+ <div>Pull request #<span wicket:id="no"></span> is already open for this comparison:</div>
+ <b><a wicket:id="link"><span wicket:id="label"></span></a></b>
+ </div>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="sameBranchFrag">
+ <div class="alert alert-warning">
+ <div class="summary">
+ <span class="fa fa-lg fa-warning"></span>
+ <span>Please select different branches to integrate.</span>
+ </div>
+ </div>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="integratedFrag">
+ <div class="alert alert-success">
+ <div class="summary">
+ <span class="fa fa-lg fa-check-circle"></span>
+ <a wicket:id="targetBranch"></a> is up to date with all commits from <a wicket:id="sourceBranch"></a>.
+ Try <a wicket:id="swapBranches">swap source and target</a> for the comparison.
+ </div>
+ </div>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="rejectedFrag">
+ <div class="alert alert-danger">
+ <div class="summary">
+ <span class="fa fa-lg fa-ban"></span>
+ <span class="message">Gatekeeper of target repository rejects the integration request for below reasons:</span>
+ </div>
+ <ul class="detail">
+ <li wicket:id="reasons"><span wicket:id="reason"></span></li>
+ </ul>
+ </div>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="canSendFrag">
+ <div class="can-send">
+ <form wicket:id="form">
+ <table>
+ <tr class="title">
+ <td class="name">Title <span class="required"></span></td>
+ <td wicket:id="title" class="value">
+ <input wicket:id="title" type="text" class="form-control focusable" placeholder="Input title here">
+ <div wicket:id="feedback"></div>
+ </td>
+ </tr>
+ <tr class="description">
+ <td class="name">Description</td>
+ <td class="value"><textarea wicket:id="comment" rows="5" class="form-control focusable"></textarea></td>
+ </tr>
+ <tr class="assignee">
+ <td class="name">Assignee <span class="required"></span></td>
+ <td wicket:id="assignee" class="value">
+ <input wicket:id="assignee" type="hidden"></input>
+ <div wicket:id="feedback"></div>
+ <div class="help-block">
+ <i class="fa fa-info-circle"></i> Assignee is responsible for integration of the
+ pull request after it passes gatekeeper check.
+ </div>
+ </td>
+ </tr>
+ <tr class="reviewers">
+ <td class="name">Reviewers</td>
+ <td wicket:id="reviewers" class="value">
+ <ul class="clearfix list-unstyled">
+ <li wicket:id="reviewers" class="pull-left">
+ <a wicket:id="avatar"></a>
+ </li>
+ <wicket:enclosure child="addReviewer">
+ <li class="pull-left"><input wicket:id="addReviewer" type="hidden"></input></li>
+ </wicket:enclosure>
+ </ul>
+ <div wicket:id="prePopulateHint" class="help-block">
+ <i class="fa fa-info-circle"></i> GitPlex pre-populated some reviewers above as suggested
+ by gatekeeper of the repository. You may adjust the list by removing existing (hovering mouse
+ over reviewer avatar) or adding more.
+ </div>
+ </td>
+ </tr>
+ </table>
+ <input wicket:id="send" type="submit" class="btn btn-primary" value="Send Pull Request"></input>
+ </form>
+ </div>
+ </wicket:fragment>
</wicket:extend>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.html
index f93c09d8ce..4aaeac3a1f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/RequestDetailPage.html
@@ -1,116 +1,116 @@
-<wicket:extend>
- <div id="request-detail">
- <div wicket:id="requestHead" class="head clearfix">
- <div wicket:id="title" class="title pull-left"></div>
- <div wicket:id="number" class="number pull-left"></div>
- <a wicket:id="editLink" title="Edit title" class="edit"><i class="fa fa-pencil"></i></a>
- <form wicket:id="editForm" class="pull-left form-inline">
- <input wicket:id="title" type="text" placeholder="Input title" class="form-control focusable"></input>
- <input wicket:id="save" type="submit" value="Save" class="btn btn-primary"/>
- <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"/>
- </form>
- </div>
- <div wicket:id="statusAndBranches" class="status-and-branches clearfix">
- <div wicket:id="status" class="label pull-left status"></div>
- <div class="pull-left branches">
- <a wicket:id="user"></a> <span wicket:id="action"></span> into <a wicket:id="target" class="branch"></a>
- from <a wicket:id="source" class="branch"></a> <span wicket:id="date"></span>
- </div>
- </div>
- <div wicket:id="requestSummary" class="summary well">
- <div wicket:id="discardedNote">
- <i class="fa fa-info-circle"></i> This pull request has been discarded.
- </div>
- <div wicket:id="pendingUpdateNote" class="note">
- <i class="fa fa-exclamation-triangle"></i> This pull request does not pass gate keeper
- checks below, and needs to be updated with new commits.
- </div>
- <div wicket:id="pendingApprovalNote" class="note">
- <i class="fa fa-exclamation-triangle"></i> This pull request needs to be approved before it can
- be integrated.
- </div>
- <div wicket:id="integratedNote" class="integrated-note">
- <div wicket:id="fastForwarded">
- <i class="fa fa-info-circle"></i> Target branch was fast-forwarded to source branch.
- </div>
- <div wicket:id="merged">
- <i class="fa fa-info-circle"></i> Target branch was merged with source branch.
- </div>
- <div wicket:id="mergedOutside">
- <i class="fa fa-info-circle"></i> Target branch was merged with source branch by someone outside of this pull request.
- </div>
- <div wicket:id="squashed">
- <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was squashed
- before merging into target branch. Run this command if you want to sync local
- branch with the source branch:
- <kbd>git fetch origin && git rebase</kbd>
- </p>
- </div>
- <div wicket:id="sourceRebased">
- <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was rebased
- before merging into target branch. Run this command if you want to sync local
- branch with the source branch:
- <kbd>git fetch origin && git rebase</kbd>
- </p>
- </div>
- <div wicket:id="targetRebased">
- <p><i class="fa fa-info-circle"></i> Per integration strategy, target branch was rebased on top of source branch.
- Run this command if you want to sync local branch with the target branch:
- <kbd>git fetch origin && git rebase</kbd>
- </p>
- </div>
- </div>
- <div wicket:id="statusReasons" class="status-reasons">
- <ul><li wicket:id="reasons" class="reason"><span wicket:id="reason"></span></li></ul>
- </div>
- <div wicket:id="integrationPreview" class="integration-preview">
- <div wicket:id="calculating">
- <wicket:link>
- <img src="ajax-indicator.gif"></img> Calculating integration preview...
- </wicket:link>
- </div>
- <div wicket:id="noConflict" class="no-conflict">
- <label><i class="fa fa-check-circle"></i> Able to integrate without conflicts.</label>
- <wicket:enclosure child="preview">
- <a wicket:id="preview">Preview</a> the integration result.
- </wicket:enclosure>
- <wicket:enclosure child="verification">
- <span class="fa fa-arrow-right"></span> Build of the integration is <span wicket:id="verification"></span>
- </wicket:enclosure>
- </div>
- <div wicket:id="conflict" class="conflict">
- <span><i class="fa fa-warning"></i> There are integration conflicts.</span>
- <wicket:enclosure child="resolveInstructionsTrigger">
- Please follow <a wicket:id="resolveInstructionsTrigger" href="javascript:void(0);">this instruction</a> to resolve the conflicts.
- </wicket:enclosure>
- </div>
- </div>
- <div wicket:id="operations" class="operations">
- <div class="buttons">
- <a wicket:id="approve" class="btn btn-primary">Approve</a>
- <a wicket:id="disapprove" class="btn btn-primary">Disapprove</a>
- <a wicket:id="integrate" class="btn btn-success">Integrate</a>
- <a wicket:id="discard" class="btn btn-danger">Discard</a>
- <a wicket:id="reopen" class="btn btn-primary">Reopen</a>
- <a wicket:id="deleteSourceBranch" class="btn btn-primary">Delete source branch</a>
- <a wicket:id="restoreSourceBranch" class="btn btn-primary">Restore source branch</a>
- </div>
- <div wicket:id="confirm" class="confirm"></div>
- </div>
- </div>
- <ul wicket:id="requestTabs" class="tabs nav nav-tabs"></ul>
- <wicket:child></wicket:child>
- </div>
- <wicket:fragment wicket:id="operationConfirmFrag">
- <form wicket:id="form" class="leave-confirm">
- <div wicket:id="hint" class="hint"></div>
- <div wicket:id="feedback"></div>
- <textarea wicket:id="note" class="form-control focusable" rows="5" placeholder="Leave a note"></textarea>
- <input wicket:id="submit" type="submit" value="Confirm" class="btn"></input>
- <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"></input>
- </form>
- </wicket:fragment>
- <wicket:fragment wicket:id="codeCommentsTabLinkFrag">
- <a wicket:id="link"><i class="fa fa-circle"></i> Code Comments</a>
- </wicket:fragment>
+<wicket:extend>
+ <div id="request-detail">
+ <div wicket:id="requestHead" class="head clearfix">
+ <div wicket:id="title" class="title pull-left"></div>
+ <div wicket:id="number" class="number pull-left"></div>
+ <a wicket:id="editLink" title="Edit title" class="edit"><i class="fa fa-pencil"></i></a>
+ <form wicket:id="editForm" class="pull-left form-inline">
+ <input wicket:id="title" type="text" placeholder="Input title" class="form-control focusable"></input>
+ <input wicket:id="save" type="submit" value="Save" class="btn btn-primary"/>
+ <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"/>
+ </form>
+ </div>
+ <div wicket:id="statusAndBranches" class="status-and-branches clearfix">
+ <div wicket:id="status" class="label pull-left status"></div>
+ <div class="pull-left branches">
+ <a wicket:id="user"></a> <span wicket:id="action"></span> into <a wicket:id="target" class="branch"></a>
+ from <a wicket:id="source" class="branch"></a> <span wicket:id="date"></span>
+ </div>
+ </div>
+ <div wicket:id="requestSummary" class="summary well">
+ <div wicket:id="discardedNote">
+ <i class="fa fa-info-circle"></i> This pull request has been discarded.
+ </div>
+ <div wicket:id="pendingUpdateNote" class="note">
+ <i class="fa fa-exclamation-triangle"></i> This pull request does not pass gatekeeper
+ checks below, and needs to be updated with new commits.
+ </div>
+ <div wicket:id="pendingApprovalNote" class="note">
+ <i class="fa fa-exclamation-triangle"></i> This pull request needs to be approved before it can
+ be integrated.
+ </div>
+ <div wicket:id="integratedNote" class="integrated-note">
+ <div wicket:id="fastForwarded">
+ <i class="fa fa-info-circle"></i> Target branch was fast-forwarded to source branch.
+ </div>
+ <div wicket:id="merged">
+ <i class="fa fa-info-circle"></i> Target branch was merged with source branch.
+ </div>
+ <div wicket:id="mergedOutside">
+ <i class="fa fa-info-circle"></i> Target branch was merged with source branch by someone outside of this pull request.
+ </div>
+ <div wicket:id="squashed">
+ <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was squashed
+ before merging into target branch. Run this command if you want to sync local
+ branch with the source branch:
+ <kbd>git fetch origin && git rebase</kbd>
+ </p>
+ </div>
+ <div wicket:id="sourceRebased">
+ <p><i class="fa fa-info-circle"></i> Per integration strategy, pending commits in source branch was rebased
+ before merging into target branch. Run this command if you want to sync local
+ branch with the source branch:
+ <kbd>git fetch origin && git rebase</kbd>
+ </p>
+ </div>
+ <div wicket:id="targetRebased">
+ <p><i class="fa fa-info-circle"></i> Per integration strategy, target branch was rebased on top of source branch.
+ Run this command if you want to sync local branch with the target branch:
+ <kbd>git fetch origin && git rebase</kbd>
+ </p>
+ </div>
+ </div>
+ <div wicket:id="statusReasons" class="status-reasons">
+ <ul><li wicket:id="reasons" class="reason"><span wicket:id="reason"></span></li></ul>
+ </div>
+ <div wicket:id="integrationPreview" class="integration-preview">
+ <div wicket:id="calculating">
+ <wicket:link>
+ <img src="ajax-indicator.gif"></img> Calculating integration preview...
+ </wicket:link>
+ </div>
+ <div wicket:id="noConflict" class="no-conflict">
+ <label><i class="fa fa-check-circle"></i> Able to integrate without conflicts.</label>
+ <wicket:enclosure child="preview">
+ <a wicket:id="preview">Preview</a> the integration result.
+ </wicket:enclosure>
+ <wicket:enclosure child="verification">
+ <span class="fa fa-arrow-right"></span> Build of the integration is <span wicket:id="verification"></span>
+ </wicket:enclosure>
+ </div>
+ <div wicket:id="conflict" class="conflict">
+ <span><i class="fa fa-warning"></i> There are integration conflicts.</span>
+ <wicket:enclosure child="resolveInstructionsTrigger">
+ Please follow <a wicket:id="resolveInstructionsTrigger" href="javascript:void(0);">this instruction</a> to resolve the conflicts.
+ </wicket:enclosure>
+ </div>
+ </div>
+ <div wicket:id="operations" class="operations">
+ <div class="buttons">
+ <a wicket:id="approve" class="btn btn-primary">Approve</a>
+ <a wicket:id="disapprove" class="btn btn-primary">Disapprove</a>
+ <a wicket:id="integrate" class="btn btn-success">Integrate</a>
+ <a wicket:id="discard" class="btn btn-danger">Discard</a>
+ <a wicket:id="reopen" class="btn btn-primary">Reopen</a>
+ <a wicket:id="deleteSourceBranch" class="btn btn-primary">Delete source branch</a>
+ <a wicket:id="restoreSourceBranch" class="btn btn-primary">Restore source branch</a>
+ </div>
+ <div wicket:id="confirm" class="confirm"></div>
+ </div>
+ </div>
+ <ul wicket:id="requestTabs" class="tabs nav nav-tabs"></ul>
+ <wicket:child></wicket:child>
+ </div>
+ <wicket:fragment wicket:id="operationConfirmFrag">
+ <form wicket:id="form" class="leave-confirm">
+ <div wicket:id="hint" class="hint"></div>
+ <div wicket:id="feedback"></div>
+ <textarea wicket:id="note" class="form-control focusable" rows="5" placeholder="Leave a note"></textarea>
+ <input wicket:id="submit" type="submit" value="Confirm" class="btn"></input>
+ <input wicket:id="cancel" type="button" value="Cancel" class="btn btn-default"></input>
+ </form>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="codeCommentsTabLinkFrag">
+ <a wicket:id="link"><i class="fa fa-circle"></i> Code Comments</a>
+ </wicket:fragment>
</wicket:extend>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/ResolveConflictInstructionPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/ResolveConflictInstructionPanel.java
index 18faf639b8..3492fe2dc7 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/ResolveConflictInstructionPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/ResolveConflictInstructionPanel.java
@@ -69,7 +69,7 @@ class ResolveConflictInstructionPanel extends Panel {
fragment.add(differentRepoContainer);
} else if (user != null
&& SecurityUtils.canWrite(targetDepot)
- && targetDepot.getGateKeeper().checkPush(user, request.getTargetDepot(), request.getTargetRef(), request.getTarget().getObjectId(), ObjectId.fromString(preview.getRequestHead())).allowIntegration()) {
+ && targetDepot.getGateKeeper().checkPush(user, request.getTargetDepot(), request.getTargetRef(), request.getTarget().getObjectId(), ObjectId.fromString(preview.getRequestHead())).isPassedOrIgnored()) {
fragment = new Fragment("content", "mergeInTargetFrag", this);
fragment.add(new Label("destRepoName", request.getTarget().getDepot()));
fragment.add(new Label("destBranchNameForCheckout", request.getTargetBranch()));
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.html
index ed21905b4c..94f02aec44 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.html
@@ -1,84 +1,84 @@
-<wicket:extend>
- <table class="overview">
- <tr>
- <td class="activities">
- <table>
- <tr wicket:id="requestActivities" class="activity">
- <td wicket:id="avatar" class="avatar"><a wicket:id="avatar"></a></td>
- <td class="spacer"></td>
- <td wicket:id="content" class="content"></td>
- </tr>
- </table>
- <div wicket:id="addComment" class="add-comment">
- <form wicket:id="form" class="leave-confirm">
- <div wicket:id="feedback"></div>
- <textarea wicket:id="input" class="form-control" rows="5" placeholder="Leave a comment"></textarea>
- <div class="actions">
- <button wicket:id="comment" class="dirty-aware btn btn-primary">Comment</button>
- </div>
- </form>
- </div>
- </td>
- <td class="info">
- <div class="well">
- <div wicket:id="assignee" class="assignee"></div>
- <div wicket:id="reviewers" class="reviewers">
- <label>Reviewers:</label>
- <ul class="clearfix list-unstyled">
- <li wicket:id="reviewers" class="pull-left">
- <a wicket:id="avatar"></a>
- <span wicket:id="result"></span>
- </li>
- </ul>
- <wicket:enclosure child="addReviewer">
- <div>
- <input wicket:id="addReviewer" type="hidden"></input>
- </div>
- </wicket:enclosure>
- </div>
- <div wicket:id="integrationStrategy" class="integration-strategy">
- <label>
- Integration Strategy:
- <span wicket:id="help" class="fa fa-question-circle pointer small"></span>
- </label>
- <div>
- <select wicket:id="editor"></select>
- <span wicket:id="viewer"></span>
- </div>
- </div>
- <div wicket:id="watch" class="watch">
- <div>
- <label>Watch Status:</label>
- <select wicket:id="option"></select>
- </div>
- <div class="help-block"><i class="fa fa-info-circle small"></i> <span wicket:id="help"></span></div>
- </div>
- <div wicket:id="manage" class="manage">
- <a wicket:id="synchronize" class="check btn btn-default">Synchronize</a>
- <p class="help-block"><i class="fa fa-info-circle"></i> In case the pull request status is out of sync with underlying
- repository, you may synchronize them manually here</p>
- <a wicket:id="delete" class="delete btn btn-danger">Delete</a>
- </div>
- </div>
- </td>
- </tr>
- </table>
- <wicket:fragment wicket:id="assigneeEditFrag">
- <label>Assigned To: <span wicket:id="help" class="fa fa-question-circle pointer small"></span></label>
- <div>
- <input wicket:id="assignee" type="hidden"></input>
- </div>
- </wicket:fragment>
- <wicket:fragment wicket:id="assigneeViewFrag">
- <label>Assigned To: <span wicket:id="help" class="fa fa-question-circle pointer small"></span></label>
- <span wicket:id="assignee" class="avatar"></span>
- </wicket:fragment>
- <wicket:fragment wicket:id="noAssigneeFrag">
- This pull request will be integrated automatically as long as it passes gate keeper check.
- </wicket:fragment>
- <wicket:fragment wicket:id="sinceChangesRowContentFrag">
- <div>
- <span class="icon fa fa-ext fa-file-diff"></span> <a wicket:id="sinceChanges">Changes since last visit</a>
- </div>
- </wicket:fragment>
+<wicket:extend>
+ <table class="overview">
+ <tr>
+ <td class="activities">
+ <table>
+ <tr wicket:id="requestActivities" class="activity">
+ <td wicket:id="avatar" class="avatar"><a wicket:id="avatar"></a></td>
+ <td class="spacer"></td>
+ <td wicket:id="content" class="content"></td>
+ </tr>
+ </table>
+ <div wicket:id="addComment" class="add-comment">
+ <form wicket:id="form" class="leave-confirm">
+ <div wicket:id="feedback"></div>
+ <textarea wicket:id="input" class="form-control" rows="5" placeholder="Leave a comment"></textarea>
+ <div class="actions">
+ <button wicket:id="comment" class="dirty-aware btn btn-primary">Comment</button>
+ </div>
+ </form>
+ </div>
+ </td>
+ <td class="info">
+ <div class="well">
+ <div wicket:id="assignee" class="assignee"></div>
+ <div wicket:id="reviewers" class="reviewers">
+ <label>Reviewers:</label>
+ <ul class="clearfix list-unstyled">
+ <li wicket:id="reviewers" class="pull-left">
+ <a wicket:id="avatar"></a>
+ <span wicket:id="result"></span>
+ </li>
+ </ul>
+ <wicket:enclosure child="addReviewer">
+ <div>
+ <input wicket:id="addReviewer" type="hidden"></input>
+ </div>
+ </wicket:enclosure>
+ </div>
+ <div wicket:id="integrationStrategy" class="integration-strategy">
+ <label>
+ Integration Strategy:
+ <span wicket:id="help" class="fa fa-question-circle pointer small"></span>
+ </label>
+ <div>
+ <select wicket:id="editor"></select>
+ <span wicket:id="viewer"></span>
+ </div>
+ </div>
+ <div wicket:id="watch" class="watch">
+ <div>
+ <label>Watch Status:</label>
+ <select wicket:id="option"></select>
+ </div>
+ <div class="help-block"><i class="fa fa-info-circle small"></i> <span wicket:id="help"></span></div>
+ </div>
+ <div wicket:id="manage" class="manage">
+ <a wicket:id="synchronize" class="check btn btn-default">Synchronize</a>
+ <p class="help-block"><i class="fa fa-info-circle"></i> In case the pull request status is out of sync with underlying
+ repository, you may synchronize them manually here</p>
+ <a wicket:id="delete" class="delete btn btn-danger">Delete</a>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
+ <wicket:fragment wicket:id="assigneeEditFrag">
+ <label>Assigned To: <span wicket:id="help" class="fa fa-question-circle pointer small"></span></label>
+ <div>
+ <input wicket:id="assignee" type="hidden"></input>
+ </div>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="assigneeViewFrag">
+ <label>Assigned To: <span wicket:id="help" class="fa fa-question-circle pointer small"></span></label>
+ <span wicket:id="assignee" class="avatar"></span>
+ </wicket:fragment>
+ <wicket:fragment wicket:id="noAssigneeFrag">
+ This pull request will be integrated automatically as long as it passes gatekeeper check.
+ </wicket:fragment>
+ <wicket:fragment wicket:id="sinceChangesRowContentFrag">
+ <div>
+ <span class="icon fa fa-ext fa-file-diff"></span> <a wicket:id="sinceChanges">Changes since last visit</a>
+ </div>
+ </wicket:fragment>
</wicket:extend>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.java
index 01246c220f..63dffbca57 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/pullrequest/requestdetail/overview/RequestOverviewPage.java
@@ -83,7 +83,7 @@ public class RequestOverviewPage extends RequestDetailPage {
private static final String ASSIGNEE_HELP = "Assignee has write permission to the "
+ "repository and is resonsible for integrating the pull request into "
- + "target branch after it passes gate keeper check.";
+ + "target branch after it passes gatekeeper check.";
private enum WatchStatus {
WATCHING("Watching"),
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/DepotSettingPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/DepotSettingPage.java
index 4124a660f2..f782c0f7a0 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/DepotSettingPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/DepotSettingPage.java
@@ -52,7 +52,7 @@ public abstract class DepotSettingPage extends DepotPage {
*/
tabs.add(new DepotSettingTab("Collaborators", "fa fa-fw fa-user", DepotCollaboratorListPage.class));
}
- tabs.add(new DepotSettingTab("Gate Keepers", "fa fa-fw fa-eye", GateKeeperPage.class));
+ tabs.add(new DepotSettingTab("Gatekeepers", "fa fa-fw fa-eye", GateKeeperPage.class));
tabs.add(new DepotSettingTab("Integration Policies", "fa fa-fw fa-puzzle-piece", IntegrationPolicyPage.class));
add(new Tabbable("depotSettingTabs", tabs));
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/depot-setting.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/depot-setting.css
index 0bd14f8f87..989c4dbc6a 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/depot-setting.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/depot-setting.css
@@ -1,208 +1,207 @@
-#depot-setting>table>tbody>tr>td.nav {
- width: 200px;
- border-right: 1px solid #DDD;
- white-space: nowrap;
- padding: 20px 0;
-}
-#depot-setting>table>tbody>tr>td.nav a {
- display: block;
- color: #666;
- text-decoration: none;
- padding: 6px 12px;
- font-family: monospace;
-}
-#depot-setting>table>tbody>tr>td.nav li:hover a {
- background: #F5F5F5;
- color: #010203;
-}
-#depot-setting>table>tbody>tr>td.nav li.active a {
- background: #E8E8E8;
- color: #010203;
- font-weight: bold;
-}
-#depot-setting>table>tbody>tr>td.content {
- padding: 20px;
-}
-#depot-setting .general-setting form .delete {
- margin-right: 0;
-}
-
-.integration-policy-setting .handle {
- cursor: move;
- margin-right: 8px;
-}
-.integration-policy-setting .panel-heading a {
- color: #444;
- margin-right: 8px;
-}
-.integration-policy-setting .add-new {
- display: block;
- padding: 16px;
- background: #F2F2F2;
- border: 1px solid #DDD;
- border-radius: 4px;
- font-size: 16px;
- color: #444;
- margin-bottom: 16px;
-}
-.integration-policy-setting a.add-new:hover {
- text-decoration: none;
- background-color: #EBEBEB;
- border-color: #ADADAD;
-}
-.integration-policy-setting a.add-new .fa {
- margin-left: 8px;
-}
-
-.gate-keeper-add.well {
- font-size:16px;
-}
-.gate-keeper-add .fa {
- margin-left: 8px;
-}
-.gate-keeper-add:hover, .gate-keeper-add:focus {
- background-color: #EBEBEB;
- border-color: #ADADAD;
- cursor: pointer;
-}
-.gate-keeper-selector.floating {
- border-radius: 0;
-}
-.gate-keeper-selector.floating>.content {
- width: 600px;
-}
-.gate-keeper-selector .panel {
- border: none;
- border-radius: 0;
-}
-.gate-keeper-selector .panel-heading {
- border-top: 1px solid #CCCCCC;
- border-radius: 0;
-}
-.gate-keeper-selector .panel-group>.panel:first-child>.panel-heading {
- border-top: none;
-}
-.gate-keeper-selector .panel-heading.collapsed:hover, .gate-keeper-selector .panel-heading.collapsed:focus {
- border-color: #999999;
- background-color: #E0E0E0;
- cursor: pointer;
-}
-.gate-keeper-selector .panel-group .panel + .panel {
- margin-top: 0px;
-}
-.gate-keeper-selector .fa {
- width: 20px;
-}
-.gate-keeper-description {
- font-size: 13px;
- color: #888888;
-}
-.gate-keeper-item {
- margin-bottom: 6px;
- padding: 4px;
- border: 1px solid white;
-}
-.gate-keeper-item:hover, .gate-keeper-item:focus {
- background-color: #EBEBEB;
- cursor: pointer;
- border: 1px solid #ADADAD;
- border-radius: 4px;
-}
-.gate-keeper-name {
- font-size: 15px;
- margin-top: -4px;
-}
-.gate-keeper-editor {
- max-height: 600px;
- overflow: auto;
-}
-.gate-keeper-editor .gate-keeper-name {
- font-weight: bold;
- font-size: 16px;
- margin-top: 0;
- margin-bottom: 4px;
-}
-.gate-keeper-editor .modal-header .fa {
- width: 20px;
- margin-right: 8px;
- margin-top: 4px;
-}
-.gate-keeper-editor form>.feedback {
- margin: 20px 16px -16px 16px;
-}
-.gate-keeper-editor form>.feedback .alert {
- margin-bottom: 0;
-}
-.gate-keeper .panel-title {
- font-size: 14px;
-}
-.gate-keeper .panel-heading {
- padding: 8px;
-}
-.gate-keeper .fa {
- margin-left: 8px;
- cursor: pointer;
-}
-.gate-keeper .gate-keeper-add {
- margin: 0px;
- padding: 8px;
- font-size: 14px;
-}
-.gate-keeper .reflection {
- margin-bottom: 0;
-}
-
-.gate-keeper.panel {
- border: 1px solid #BBBBBB;
-}
-.gate-keeper.panel>.panel-heading {
- border-color: #BBBBBB;
-}
-.gate-keeper.panel.disabled, .gate-keeper.panel.disabled .panel {
- color: #AAA;
-}
-.gate-keeper.panel.disabled>.panel-heading, .gate-keeper.panel.disabled .panel-heading {
- color: #AAA;
-}
-.gate-keeper.panel.disabled .fa {
- color: inherit;
-}
-.gate-keeper table.viewer {
- font-size: 13px !important;
- color: #444444;
-}
-.gate-keeper td.child {
- padding-right: 12px;
-}
-.gate-keeper table.children>tbody>tr>td.child:last-child {
- padding-right: 0;
-}
-.gate-keeper.panel .panel-body {
- overflow:auto;
-}
-.gate-keeper td.ifthen.connector {
- width:1px;
-}
-.gate-keeper td.ifthen.connector .fa {
- margin: 0 6px 0 8px;
- color: #666666;
- font-size: 36px;
-}
-
-#depot-setting .authorization .list table td.actions {
- width: 20%;
- white-space: nowrap;
-}
-#depot-setting .authorization .list td.name .note {
- font-size: 12px;
- color: #888;
- margin-top: 4px;
-}
-#depot-setting .authorization .list td.privilege {
- width: 20%;
-}
-
-.modal .transfer-depot .message {
- font-size: 13px;
- margin-bottom: 20px;
-}
+#depot-setting>table>tbody>tr>td.nav {
+ width: 200px;
+ border-right: 1px solid #DDD;
+ white-space: nowrap;
+ padding: 20px 0;
+}
+#depot-setting>table>tbody>tr>td.nav a {
+ display: block;
+ color: #666;
+ text-decoration: none;
+ padding: 6px 12px;
+ font-family: monospace;
+}
+#depot-setting>table>tbody>tr>td.nav li:hover a {
+ background: #F5F5F5;
+ color: #010203;
+}
+#depot-setting>table>tbody>tr>td.nav li.active a {
+ background: #E8E8E8;
+ color: #010203;
+ font-weight: bold;
+}
+#depot-setting>table>tbody>tr>td.content {
+ padding: 20px;
+}
+#depot-setting .general-setting form .delete {
+ margin-right: 0;
+}
+
+.integration-policy-setting .handle {
+ cursor: move;
+ margin-right: 8px;
+}
+.integration-policy-setting .panel-heading a {
+ color: #444;
+ margin-right: 8px;
+}
+.integration-policy-setting .add-new {
+ display: block;
+ padding: 16px;
+ background: #F2F2F2;
+ border: 1px solid #DDD;
+ border-radius: 4px;
+ font-size: 16px;
+ color: #444;
+ margin-bottom: 16px;
+}
+.integration-policy-setting a.add-new:hover {
+ text-decoration: none;
+ background-color: #EBEBEB;
+ border-color: #ADADAD;
+}
+.integration-policy-setting a.add-new .fa {
+ margin-left: 8px;
+}
+
+.gate-keeper-add.well {
+ font-size:16px;
+}
+.gate-keeper-add .fa {
+ margin-left: 8px;
+}
+.gate-keeper-add:hover, .gate-keeper-add:focus {
+ background-color: #EBEBEB;
+ border-color: #ADADAD;
+ cursor: pointer;
+}
+.gate-keeper-selector.floating {
+ border-radius: 0;
+}
+.gate-keeper-selector.floating>.content {
+ width: 600px;
+}
+.gate-keeper-selector .panel {
+ border: none;
+ border-radius: 0;
+}
+.gate-keeper-selector .panel-heading {
+ border-top: 1px solid #CCCCCC;
+ border-radius: 0;
+}
+.gate-keeper-selector .panel-group>.panel:first-child>.panel-heading {
+ border-top: none;
+}
+.gate-keeper-selector .panel-heading.collapsed:hover, .gate-keeper-selector .panel-heading.collapsed:focus {
+ border-color: #999999;
+ background-color: #E0E0E0;
+ cursor: pointer;
+}
+.gate-keeper-selector .panel-group .panel + .panel {
+ margin-top: 0px;
+}
+.gate-keeper-selector .fa {
+ width: 20px;
+}
+.gate-keeper-description {
+ font-size: 13px;
+ color: #888888;
+}
+.gate-keeper-item {
+ margin-bottom: 6px;
+ padding: 4px;
+ border: 1px solid white;
+}
+.gate-keeper-item:hover, .gate-keeper-item:focus {
+ background-color: #EBEBEB;
+ cursor: pointer;
+ border: 1px solid #ADADAD;
+ border-radius: 4px;
+}
+.gate-keeper-name {
+ font-size: 15px;
+ margin-top: -4px;
+}
+.gate-keeper-editor {
+ max-height: 600px;
+ overflow: auto;
+}
+.gate-keeper-editor .gate-keeper-name {
+ font-weight: bold;
+ font-size: 16px;
+ margin-top: 0;
+ margin-bottom: 4px;
+}
+.gate-keeper-editor .modal-header .fa {
+ width: 20px;
+ margin-right: 8px;
+ margin-top: 4px;
+}
+.gate-keeper-editor form>.feedback {
+ margin: 20px 16px -16px 16px;
+}
+.gate-keeper-editor form>.feedback .alert {
+ margin-bottom: 0;
+}
+.gate-keeper .panel-title {
+ font-size: 14px;
+}
+.gate-keeper .panel-heading {
+ padding: 8px;
+}
+.gate-keeper .fa {
+ margin-left: 8px;
+ cursor: pointer;
+}
+.gate-keeper .gate-keeper-add {
+ margin: 0px;
+ padding: 8px;
+ font-size: 14px;
+}
+.gate-keeper .reflection {
+ margin-bottom: 0;
+}
+
+.gate-keeper.panel {
+ border: 1px solid #BBBBBB;
+}
+
+.gate-keeper.panel>.panel-heading {
+ border-color: #BBBBBB;
+}
+.gate-keeper.panel.disabled, .gate-keeper.panel.disabled .panel {
+ color: #AAA;
+}
+.gate-keeper.panel.disabled>.panel-heading, .gate-keeper.panel.disabled .panel-heading {
+ color: #AAA;
+}
+.gate-keeper.panel.disabled .fa {
+ color: inherit;
+}
+.gate-keeper table.viewer {
+ font-size: 13px !important;
+ color: #444444;
+}
+.gate-keeper td.child {
+ padding-right: 12px;
+}
+.gate-keeper table.children>tbody>tr>td.child:last-child {
+ padding-right: 0;
+}
+.gate-keeper.panel .panel-body {
+ overflow:auto;
+}
+.gate-keeper.panel table.ifthen>tbody>tr.if>td {
+ padding-bottom: 16px;
+}
+.gate-keeper.panel table.ifthen>tbody>tr>td>div>div.panel {
+ margin-bottom: 0;
+}
+
+#depot-setting .authorization .list table td.actions {
+ width: 20%;
+ white-space: nowrap;
+}
+#depot-setting .authorization .list td.name .note {
+ font-size: 12px;
+ color: #888;
+ margin-top: 4px;
+}
+#depot-setting .authorization .list td.privilege {
+ width: 20%;
+}
+
+.modal .transfer-depot .message {
+ font-size: 13px;
+ margin-bottom: 20px;
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.html
index 06fca2755f..305fa8b8a9 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.html
@@ -1,21 +1,9 @@
-<wicket:extend>
- <div class="gate-keeper-setting">
- <div wicket:id="gateKeeperSetting">
- <div wicket:id="gateKeepers">
- <div wicket:id="gateKeeper"></div>
- </div>
- <div wicket:id="gateKeeperDropdownTrigger" class="well gate-keeper-add">Add Gate Keeper <i class="fa fa-lg fa-plus-circle"></i></div>
- </div>
- <div class="help-block">
- <h5>Define gate keepers to determine whether or not to accept a pull request or push operation.
- Gate keepers plays an important role in GitPlex, for instance, you may use it to:
- </h5>
- <ul>
- <li>Control write access to certain branches or directories.</li>
- <li>Require different user to approve different tree of the repository.</li>
- <li>Have continuous integration system verifying the code before accepting
- the pull request.</li>
- </ul>
- </div>
- </div>
+<wicket:extend>
+ <div class="gate-keeper-setting">
+ <div wicket:id="gateKeeper"></div>
+ <div class="help-block">
+ <i class="fa fa-info-circle"></i> Repository can only be modified if checking of defined gatekeeper is passed. Multiple gatekeepers can be
+ combined together with various composite gatekeepers
+ </div>
+ </div>
</wicket:extend>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.java
index e320ef4402..cf8ba45e7b 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPage.java
@@ -1,112 +1,107 @@
-package com.pmease.gitplex.web.page.depot.setting.gatekeeper;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import com.pmease.commons.util.ReflectionUtils;
-import com.pmease.commons.wicket.component.modal.ModalPanel;
-import com.pmease.commons.wicket.editable.EditableUtils;
-import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.core.gatekeeper.GateKeeper;
-import com.pmease.gitplex.core.manager.DepotManager;
-import com.pmease.gitplex.web.page.depot.setting.DepotSettingPage;
-
-@SuppressWarnings("serial")
-public class GateKeeperPage extends DepotSettingPage {
-
- private static final String CONTAINER_ID = "gateKeeperSetting";
-
- public GateKeeperPage(PageParameters params) {
- super(params);
- }
-
- private WebMarkupContainer newContent() {
- WebMarkupContainer content = new WebMarkupContainer(CONTAINER_ID);
- content.setOutputMarkupId(true);
-
- content.add(new ListView<GateKeeper>("gateKeepers", getDepot().getGateKeepers()) {
-
- @Override
- protected void populateItem(final ListItem<GateKeeper> item) {
- item.add(new GateKeeperPanel("gateKeeper", item.getModelObject()) {
-
- @Override
- protected void onDelete(AjaxRequestTarget target) {
- getDepot().getGateKeepers().remove(item.getIndex());
- onGateKeeperChanged(target);
- }
-
- @Override
- protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {
- getDepot().getGateKeepers().set(item.getIndex(), gateKeeper);
- onGateKeeperChanged(target);
- }
-
- });
- }
-
- });
- content.add(new GateKeeperLink("gateKeeperDropdownTrigger") {
-
- @Override
- protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {
- final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);
- if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {
- getDepot().getGateKeepers().add(gateKeeper);
- onGateKeeperChanged(target);
- } else {
- new ModalPanel(target) {
-
- @Override
- protected Component newContent(String id) {
- return new GateKeeperEditor(id, gateKeeper) {
-
- @Override
- protected void onCancel(AjaxRequestTarget target) {
- close(target);
- }
-
- @Override
- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
- close(target);
- getDepot().getGateKeepers().add(gateKeeper);
- onGateKeeperChanged(target);
- }
-
- };
- }
-
- };
- }
- }
-
- });
- content.add(new WebMarkupContainer("gateKeeperPanel").setVisible(false));
- content.add(new WebMarkupContainer("gateKeeperModal").setOutputMarkupPlaceholderTag(true).setVisible(false));
- return content;
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- add(newContent());
- }
-
- private void onGateKeeperChanged(AjaxRequestTarget target) {
- GitPlex.getInstance(DepotManager.class).save(getDepot(), null, null);
- replace(newContent());
- target.add(get(CONTAINER_ID));
- }
-
- @Override
- protected void onSelect(AjaxRequestTarget target, Depot depot) {
- setResponsePage(GateKeeperPage.class, GateKeeperPage.paramsOf(depot));
- }
-
-}
+package com.pmease.gitplex.web.page.depot.setting.gatekeeper;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.behavior.AttributeAppender;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+import com.pmease.commons.util.ReflectionUtils;
+import com.pmease.commons.wicket.component.modal.ModalPanel;
+import com.pmease.commons.wicket.editable.EditableUtils;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.entity.Depot;
+import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;
+import com.pmease.gitplex.core.gatekeeper.GateKeeper;
+import com.pmease.gitplex.core.manager.DepotManager;
+import com.pmease.gitplex.web.page.depot.setting.DepotSettingPage;
+
+@SuppressWarnings("serial")
+public class GateKeeperPage extends DepotSettingPage {
+
+ public GateKeeperPage(PageParameters params) {
+ super(params);
+ }
+
+ private Component newContent() {
+ if (getDepot().getGateKeeper() instanceof DefaultGateKeeper) {
+ return new GateKeeperLink("gateKeeper") {
+
+ @Override
+ protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {
+ final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);
+ if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {
+ getDepot().setGateKeeper(gateKeeper);
+ onGateKeeperChanged(target);
+ } else {
+ new ModalPanel(target) {
+
+ @Override
+ protected Component newContent(String id) {
+ return new GateKeeperEditor(id, gateKeeper) {
+
+ @Override
+ protected void onCancel(AjaxRequestTarget target) {
+ close(target);
+ }
+
+ @Override
+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
+ close(target);
+ getDepot().setGateKeeper(gateKeeper);
+ onGateKeeperChanged(target);
+ }
+
+ };
+ }
+
+ };
+ }
+ }
+
+ @Override
+ public IModel<?> getBody() {
+ return Model.of("Define gatekeeper <i class='fa fa-plus-circle'></i>");
+ }
+
+ }.setOutputMarkupId(true).setEscapeModelStrings(false).add(AttributeAppender.append("class", "well gate-keeper-add"));
+ } else {
+ return new GateKeeperPanel("gateKeeper", getDepot().getGateKeeper()) {
+
+ @Override
+ protected void onDelete(AjaxRequestTarget target) {
+ getDepot().setGateKeeper(new DefaultGateKeeper());
+ onGateKeeperChanged(target);
+ }
+
+ @Override
+ protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {
+ getDepot().setGateKeeper(gateKeeper);
+ onGateKeeperChanged(target);
+ }
+
+ }.setOutputMarkupId(true);
+ }
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ add(newContent());
+ }
+
+ private void onGateKeeperChanged(AjaxRequestTarget target) {
+ GitPlex.getInstance(DepotManager.class).save(getDepot(), null, null);
+ Component content = newContent();
+ replace(content);
+ target.add(content);
+ }
+
+ @Override
+ protected void onSelect(AjaxRequestTarget target, Depot depot) {
+ setResponsePage(GateKeeperPage.class, GateKeeperPage.paramsOf(depot));
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.html
index 4aa7737550..645766881a 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.html
@@ -2,9 +2,10 @@
<div wicket:id="container" class="gate-keeper panel panel-default ">
<div class="panel-heading">
<span wicket:id="title" class="panel-title"></span>
- <span wicket:id="edit" class="fa fa-pencil" title="Edit this gate keeper"></span>
- <span wicket:id="delete" class="fa fa-trash" title="Delete this gate keeper"></span>
+ <span wicket:id="edit" class="fa fa-pencil" title="Edit this gatekeeper"></span>
+ <span wicket:id="delete" class="fa fa-trash" title="Delete this gatekeeper"></span>
<span wicket:id="enable" class="fa "></span>
+ <span wicket:id="help" class="fa fa-question-circle"></span>
<div wicket:id="editor"></div>
</div>
<div class="panel-body">
@@ -15,7 +16,7 @@
<div wicket:id="children">
<div wicket:id="child"></div>
</div>
- <div wicket:id="childTypeSelectorTrigger" class="well gate-keeper-add">Add Child Gate Keeper<i class="fa fa-plus-circle"></i></div>
+ <div wicket:id="childTypeSelectorTrigger" class="well gate-keeper-add">Add gatekeeper <i class="fa fa-plus-circle"></i></div>
</wicket:fragment>
<wicket:fragment wicket:id="orFrag">
<table class="children">
@@ -25,26 +26,27 @@
</td>
</tr>
</table>
- <div wicket:id="childTypeSelectorTrigger" class="well gate-keeper-add">Add Child Gate Keeper<i class="fa fa-plus-circle"></i></div>
+ <div wicket:id="childTypeSelectorTrigger" class="well gate-keeper-add">Add gatekeeper <i class="fa fa-plus-circle"></i></div>
</wicket:fragment>
<wicket:fragment wicket:id="ifThenFrag">
<table class="ifthen">
- <tr>
- <td class="ifthen if">
- <div wicket:id="if"></div>
- <div wicket:id="ifTypeSelectorTrigger" class="well gate-keeper-add">Define If Gate Keeper<i class="fa fa-plus-circle"></i></div>
+ <tr class="if">
+ <td>
+ <label>If</label>
+ <div wicket:id="ifGate"></div>
</td>
- <td class="ifthen connector"><div class="fa fa-arrow-right"></div></td>
- <td class="ifthen then">
- <div wicket:id="then"></div>
- <div wicket:id="thenTypeSelectorTrigger" class="well gate-keeper-add">Define Then Gate Keeper<i class="fa fa-plus-circle"></i></div>
+ </tr>
+ <tr class="then">
+ <td>
+ <label>Then check</label>
+ <div wicket:id="thenGate"></div>
</td>
</tr>
</table>
</wicket:fragment>
<wicket:fragment wicket:id="notFrag">
<div wicket:id="gateKeeper"></div>
- <div wicket:id="gateKeeperTypeSelectorTrigger" class="well gate-keeper-add">Define Contained Condition<i class="fa fa-plus-circle"></i></div>
+ <div wicket:id="gateKeeperTypeSelectorTrigger" class="well gate-keeper-add">Define gatekeeper <i class="fa fa-plus-circle"></i></div>
</wicket:fragment>
<wicket:fragment wicket:id="otherFrag">
<div wicket:id="viewer"></div>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.java
index a09422a368..40264ec746 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/gatekeeper/GateKeeperPanel.java
@@ -1,390 +1,396 @@
-package com.pmease.gitplex.web.page.depot.setting.gatekeeper;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.behavior.AttributeAppender;
-import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.Fragment;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.Model;
-
-import com.pmease.commons.util.ReflectionUtils;
-import com.pmease.commons.wicket.ajaxlistener.ConfirmListener;
-import com.pmease.commons.wicket.component.modal.ModalLink;
-import com.pmease.commons.wicket.component.modal.ModalPanel;
-import com.pmease.commons.wicket.editable.BeanContext;
-import com.pmease.commons.wicket.editable.EditableUtils;
-import com.pmease.gitplex.core.gatekeeper.AbstractGateKeeper;
-import com.pmease.gitplex.core.gatekeeper.AndGateKeeper;
-import com.pmease.gitplex.core.gatekeeper.AndOrGateKeeper;
-import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;
-import com.pmease.gitplex.core.gatekeeper.GateKeeper;
-import com.pmease.gitplex.core.gatekeeper.IfThenGateKeeper;
-import com.pmease.gitplex.core.gatekeeper.NotGateKeeper;
-
-@SuppressWarnings("serial")
-abstract class GateKeeperPanel extends Panel {
-
- private final GateKeeper gateKeeper;
-
- public GateKeeperPanel(String id, GateKeeper gateKeeper) {
- super(id);
- this.gateKeeper = gateKeeper;
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- final WebMarkupContainer container = new WebMarkupContainer("container");
- add(container);
-
- if(!gateKeeper.isEnabled())
- container.add(AttributeAppender.append("class", "disabled"));
-
- final Class<? extends GateKeeper> clazz = gateKeeper.getClass();
- container.add(new Label("title", EditableUtils.getName(clazz)));
- container.add(new ModalLink("edit") {
-
- @Override
- protected void onConfigure() {
- super.onConfigure();
-
- setVisible(EditableUtils.hasEditableProperties(clazz));
- }
-
- @Override
- protected Component newContent(String id) {
- return new GateKeeperEditor(id, gateKeeper) {
-
- @Override
- protected void onCancel(AjaxRequestTarget target) {
- close(target);
- }
-
- @Override
- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
- close(target);
- GateKeeperPanel.this.onChange(target, gateKeeper);
- }
-
- };
- }
-
- });
-
- container.add(new AjaxLink<Void>("delete") {
-
- @Override
- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
- super.updateAjaxAttributes(attributes);
- attributes.getAjaxCallListeners().add(new ConfirmListener("Do you really want to delete this gate keeper?"));
- }
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- onDelete(target);
- }
-
- });
-
- container.add(new AjaxLink<Void>("enable") {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- ((AbstractGateKeeper) gateKeeper).setEnabled(!gateKeeper.isEnabled());
- onChange(target, gateKeeper);
- }
-
- @Override
- protected void onComponentTag(ComponentTag tag) {
- super.onComponentTag(tag);
- if (gateKeeper.isEnabled()) {
- tag.append("class", "fa-check-square-o", " ");
- } else {
- tag.append("class", "fa-square-o", " ");
- }
- }
-
- }.add(AttributeAppender.append("title", Model.of(gateKeeper.isEnabled()?"Disable this gate keeper":"Enable this gate keeper"))));
-
- container.add(new WebMarkupContainer("editor").setOutputMarkupPlaceholderTag(true).setVisible(false));
-
- if (AndOrGateKeeper.class.isAssignableFrom(clazz)) {
- final AndOrGateKeeper andOrGateKeeper = (AndOrGateKeeper) gateKeeper;
- final Fragment fragment;
- if (andOrGateKeeper instanceof AndGateKeeper)
- fragment = new Fragment("content", "andFrag", GateKeeperPanel.this);
- else
- fragment = new Fragment("content", "orFrag", GateKeeperPanel.this);
-
- fragment.add(new ListView<GateKeeper>("children", andOrGateKeeper.getGateKeepers()) {
-
- @Override
- protected void populateItem(final ListItem<GateKeeper> item) {
- item.add(new GateKeeperPanel("child", item.getModelObject()) {
-
- @Override
- protected void onDelete(AjaxRequestTarget target) {
- andOrGateKeeper.getGateKeepers().remove(item.getIndex());
- GateKeeperPanel.this.onChange(target, andOrGateKeeper);
- }
-
- @Override
- protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {
- andOrGateKeeper.getGateKeepers().set(item.getIndex(), gateKeeper);
- GateKeeperPanel.this.onChange(target, andOrGateKeeper);
- }
-
- });
- }
-
- });
- fragment.add(new GateKeeperLink("childTypeSelectorTrigger") {
-
- @Override
- protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {
- final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);
- if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {
- andOrGateKeeper.getGateKeepers().add(gateKeeper);
- GateKeeperPanel.this.onChange(target, andOrGateKeeper);
- } else {
- new ModalPanel(target) {
-
- @Override
- protected Component newContent(String id) {
- return new GateKeeperEditor(id, gateKeeper) {
-
- @Override
- protected void onCancel(AjaxRequestTarget target) {
- close(target);
- }
-
- @Override
- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
- close(target);
- fragment.replace(new WebMarkupContainer("childEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));
- andOrGateKeeper.getGateKeepers().add(gateKeeper);
- GateKeeperPanel.this.onChange(target, andOrGateKeeper);
- }
-
- };
- }
-
- };
- }
- }
-
- });
-
- fragment.add(new WebMarkupContainer("childEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));
- container.add(fragment);
- } else if (clazz == NotGateKeeper.class) {
- final NotGateKeeper notGateKeeper = (NotGateKeeper) gateKeeper;
- final Fragment fragment = new Fragment("content", "notFrag", GateKeeperPanel.this);
-
- if (notGateKeeper.getGateKeeper() instanceof DefaultGateKeeper) {
- fragment.add(new GateKeeperLink("gateKeeperTypeSelectorTrigger") {
-
- @Override
- protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {
- final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);
- if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {
- notGateKeeper.setGateKeeper(gateKeeper);
- GateKeeperPanel.this.onChange(target, notGateKeeper);
- } else {
- new ModalPanel(target) {
-
- @Override
- protected Component newContent(String id) {
- return new GateKeeperEditor(id, gateKeeper) {
-
- @Override
- protected void onCancel(AjaxRequestTarget target) {
- close(target);
- }
-
- @Override
- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
- close(target);
- fragment.replace(new WebMarkupContainer("gateKeeperEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));
- notGateKeeper.setGateKeeper(gateKeeper);
- GateKeeperPanel.this.onChange(target, notGateKeeper);
- }
-
- };
- }
-
- };
- }
- }
-
- });
-
- fragment.add(new WebMarkupContainer("gateKeeper").setVisible(false));
- fragment.add(new WebMarkupContainer("gateKeeperEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));
- } else {
- fragment.add(new GateKeeperPanel("gateKeeper", notGateKeeper.getGateKeeper()) {
-
- @Override
- protected void onDelete(AjaxRequestTarget target) {
- notGateKeeper.setGateKeeper(new DefaultGateKeeper());
- GateKeeperPanel.this.onChange(target, notGateKeeper);
- }
-
- @Override
- protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {
- notGateKeeper.setGateKeeper(gateKeeper);
- GateKeeperPanel.this.onChange(target, notGateKeeper);
- }
-
- });
- fragment.add(new WebMarkupContainer("gateKeeperTypeSelectorTrigger").setVisible(false));
- fragment.add(new WebMarkupContainer("gateKeeperTypeSelector").setVisible(false));
- fragment.add(new WebMarkupContainer("gateKeeperEditor").setVisible(false));
- }
- container.add(fragment);
- } else if (clazz == IfThenGateKeeper.class) {
- final IfThenGateKeeper ifThenGateKeeper = (IfThenGateKeeper) gateKeeper;
- final Fragment fragment = new Fragment("content", "ifThenFrag", GateKeeperPanel.this);
-
- if (ifThenGateKeeper.getIfGate() instanceof DefaultGateKeeper) {
- fragment.add(new GateKeeperLink("ifTypeSelectorTrigger") {
-
- @Override
- protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {
- final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);
- if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {
- ifThenGateKeeper.setIfGate(gateKeeper);
- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
- } else {
- new ModalPanel(target) {
-
- @Override
- protected Component newContent(String id) {
- return new GateKeeperEditor(id, gateKeeper) {
-
- @Override
- protected void onCancel(AjaxRequestTarget target) {
- close(target);
- }
-
- @Override
- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
- close(target);
- fragment.replace(new WebMarkupContainer("ifEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));
- ifThenGateKeeper.setIfGate(gateKeeper);
- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
- }
-
- };
- }
-
- };
- }
- }
-
- });
- fragment.add(new WebMarkupContainer("if").setVisible(false));
- fragment.add(new WebMarkupContainer("ifEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));
- } else {
- fragment.add(new GateKeeperPanel("if", ifThenGateKeeper.getIfGate()) {
-
- @Override
- protected void onDelete(AjaxRequestTarget target) {
- ifThenGateKeeper.setIfGate(new DefaultGateKeeper());
- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
- }
-
- @Override
- protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {
- ifThenGateKeeper.setIfGate(gateKeeper);
- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
- }
-
- });
- fragment.add(new WebMarkupContainer("ifTypeSelectorTrigger").setVisible(false));
- fragment.add(new WebMarkupContainer("ifTypeSelector").setVisible(false));
- fragment.add(new WebMarkupContainer("ifEditor").setVisible(false));
- }
-
- if (ifThenGateKeeper.getThenGate() instanceof DefaultGateKeeper) {
- fragment.add(new GateKeeperLink("thenTypeSelectorTrigger") {
-
- @Override
- protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {
- final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);
- if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {
- ifThenGateKeeper.setThenGate(gateKeeper);
- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
- } else {
- new ModalPanel(target) {
-
- @Override
- protected Component newContent(String id) {
- return new GateKeeperEditor(id, gateKeeper) {
-
- @Override
- protected void onCancel(AjaxRequestTarget target) {
- close(target);
- }
-
- @Override
- protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
- close(target);
- fragment.replace(new WebMarkupContainer("thenEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));
- ifThenGateKeeper.setThenGate(gateKeeper);
- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
- }
-
- };
- }
-
- };
- }
- }
-
- });
-
- fragment.add(new WebMarkupContainer("then").setVisible(false));
- fragment.add(new WebMarkupContainer("thenEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));
- } else {
- fragment.add(new GateKeeperPanel("then", ifThenGateKeeper.getThenGate()) {
-
- @Override
- protected void onDelete(AjaxRequestTarget target) {
- ifThenGateKeeper.setThenGate(new DefaultGateKeeper());
- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
- }
-
- @Override
- protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {
- ifThenGateKeeper.setThenGate(gateKeeper);
- GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
- }
-
- });
- fragment.add(new WebMarkupContainer("thenTypeSelectorTrigger").setVisible(false));
- fragment.add(new WebMarkupContainer("thenTypeSelector").setVisible(false));
- fragment.add(new WebMarkupContainer("thenEditor").setVisible(false));
- }
-
- container.add(fragment);
- } else {
- Fragment fragment = new Fragment("content", "otherFrag", GateKeeperPanel.this);
- fragment.add(BeanContext.viewBean("viewer", gateKeeper));
- container.add(fragment);
- }
- }
-
- protected abstract void onDelete(AjaxRequestTarget target);
-
- protected abstract void onChange(AjaxRequestTarget target, GateKeeper gateKeeper);
-
-}
+package com.pmease.gitplex.web.page.depot.setting.gatekeeper;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.behavior.AttributeAppender;
+import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Fragment;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+
+import com.pmease.commons.util.ReflectionUtils;
+import com.pmease.commons.wicket.ajaxlistener.ConfirmListener;
+import com.pmease.commons.wicket.component.modal.ModalLink;
+import com.pmease.commons.wicket.component.modal.ModalPanel;
+import com.pmease.commons.wicket.editable.BeanContext;
+import com.pmease.commons.wicket.editable.EditableUtils;
+import com.pmease.gitplex.core.gatekeeper.AbstractGateKeeper;
+import com.pmease.gitplex.core.gatekeeper.AndGateKeeper;
+import com.pmease.gitplex.core.gatekeeper.AndOrGateKeeper;
+import com.pmease.gitplex.core.gatekeeper.DefaultGateKeeper;
+import com.pmease.gitplex.core.gatekeeper.GateKeeper;
+import com.pmease.gitplex.core.gatekeeper.ConditionalGateKeeper;
+import com.pmease.gitplex.core.gatekeeper.NotGateKeeper;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior;
+
+@SuppressWarnings("serial")
+abstract class GateKeeperPanel extends Panel {
+
+ private final GateKeeper gateKeeper;
+
+ public GateKeeperPanel(String id, GateKeeper gateKeeper) {
+ super(id);
+ this.gateKeeper = gateKeeper;
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ final WebMarkupContainer container = new WebMarkupContainer("container");
+ add(container);
+
+ if(!gateKeeper.isEnabled())
+ container.add(AttributeAppender.append("class", "disabled"));
+
+ final Class<? extends GateKeeper> clazz = gateKeeper.getClass();
+ container.add(new Label("title", EditableUtils.getName(clazz)));
+ container.add(new ModalLink("edit") {
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+
+ setVisible(EditableUtils.hasEditableProperties(clazz));
+ }
+
+ @Override
+ protected Component newContent(String id) {
+ return new GateKeeperEditor(id, gateKeeper) {
+
+ @Override
+ protected void onCancel(AjaxRequestTarget target) {
+ close(target);
+ }
+
+ @Override
+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
+ close(target);
+ GateKeeperPanel.this.onChange(target, gateKeeper);
+ }
+
+ };
+ }
+
+ });
+
+ container.add(new AjaxLink<Void>("delete") {
+
+ @Override
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new ConfirmListener("Do you really want to delete this gatekeeper?"));
+ }
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ onDelete(target);
+ }
+
+ });
+
+ container.add(new AjaxLink<Void>("enable") {
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ ((AbstractGateKeeper) gateKeeper).setEnabled(!gateKeeper.isEnabled());
+ onChange(target, gateKeeper);
+ }
+
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ super.onComponentTag(tag);
+ if (gateKeeper.isEnabled()) {
+ tag.append("class", "fa-check-square-o", " ");
+ } else {
+ tag.append("class", "fa-square-o", " ");
+ }
+ }
+
+ }.add(AttributeAppender.append("title", Model.of(gateKeeper.isEnabled()?"Disable this gatekeeper":"Enable this gatekeeper"))));
+
+ container.add(new WebMarkupContainer("help").add(new TooltipBehavior(Model.of(EditableUtils.getDescription(gateKeeper.getClass())))));
+
+ container.add(new WebMarkupContainer("editor").setOutputMarkupPlaceholderTag(true).setVisible(false));
+
+ if (AndOrGateKeeper.class.isAssignableFrom(clazz)) {
+ final AndOrGateKeeper andOrGateKeeper = (AndOrGateKeeper) gateKeeper;
+ final Fragment fragment;
+ if (andOrGateKeeper instanceof AndGateKeeper)
+ fragment = new Fragment("content", "andFrag", GateKeeperPanel.this);
+ else
+ fragment = new Fragment("content", "orFrag", GateKeeperPanel.this);
+
+ fragment.add(new ListView<GateKeeper>("children", andOrGateKeeper.getGateKeepers()) {
+
+ @Override
+ protected void populateItem(final ListItem<GateKeeper> item) {
+ item.add(new GateKeeperPanel("child", item.getModelObject()) {
+
+ @Override
+ protected void onDelete(AjaxRequestTarget target) {
+ andOrGateKeeper.getGateKeepers().remove(item.getIndex());
+ GateKeeperPanel.this.onChange(target, andOrGateKeeper);
+ }
+
+ @Override
+ protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {
+ andOrGateKeeper.getGateKeepers().set(item.getIndex(), gateKeeper);
+ GateKeeperPanel.this.onChange(target, andOrGateKeeper);
+ }
+
+ });
+ }
+
+ });
+ fragment.add(new GateKeeperLink("childTypeSelectorTrigger") {
+
+ @Override
+ protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {
+ final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);
+ if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {
+ andOrGateKeeper.getGateKeepers().add(gateKeeper);
+ GateKeeperPanel.this.onChange(target, andOrGateKeeper);
+ } else {
+ new ModalPanel(target) {
+
+ @Override
+ protected Component newContent(String id) {
+ return new GateKeeperEditor(id, gateKeeper) {
+
+ @Override
+ protected void onCancel(AjaxRequestTarget target) {
+ close(target);
+ }
+
+ @Override
+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
+ close(target);
+ fragment.replace(new WebMarkupContainer("childEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));
+ andOrGateKeeper.getGateKeepers().add(gateKeeper);
+ GateKeeperPanel.this.onChange(target, andOrGateKeeper);
+ }
+
+ };
+ }
+
+ };
+ }
+ }
+
+ });
+
+ fragment.add(new WebMarkupContainer("childEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));
+ container.add(fragment);
+ } else if (clazz == NotGateKeeper.class) {
+ final NotGateKeeper notGateKeeper = (NotGateKeeper) gateKeeper;
+ final Fragment fragment = new Fragment("content", "notFrag", GateKeeperPanel.this);
+
+ if (notGateKeeper.getGateKeeper() instanceof DefaultGateKeeper) {
+ fragment.add(new GateKeeperLink("gateKeeperTypeSelectorTrigger") {
+
+ @Override
+ protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {
+ final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);
+ if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {
+ notGateKeeper.setGateKeeper(gateKeeper);
+ GateKeeperPanel.this.onChange(target, notGateKeeper);
+ } else {
+ new ModalPanel(target) {
+
+ @Override
+ protected Component newContent(String id) {
+ return new GateKeeperEditor(id, gateKeeper) {
+
+ @Override
+ protected void onCancel(AjaxRequestTarget target) {
+ close(target);
+ }
+
+ @Override
+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
+ close(target);
+ fragment.replace(new WebMarkupContainer("gateKeeperEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));
+ notGateKeeper.setGateKeeper(gateKeeper);
+ GateKeeperPanel.this.onChange(target, notGateKeeper);
+ }
+
+ };
+ }
+
+ };
+ }
+ }
+
+ });
+
+ fragment.add(new WebMarkupContainer("gateKeeper").setVisible(false));
+ fragment.add(new WebMarkupContainer("gateKeeperEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));
+ } else {
+ fragment.add(new GateKeeperPanel("gateKeeper", notGateKeeper.getGateKeeper()) {
+
+ @Override
+ protected void onDelete(AjaxRequestTarget target) {
+ notGateKeeper.setGateKeeper(new DefaultGateKeeper());
+ GateKeeperPanel.this.onChange(target, notGateKeeper);
+ }
+
+ @Override
+ protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {
+ notGateKeeper.setGateKeeper(gateKeeper);
+ GateKeeperPanel.this.onChange(target, notGateKeeper);
+ }
+
+ });
+ fragment.add(new WebMarkupContainer("gateKeeperTypeSelectorTrigger").setVisible(false));
+ fragment.add(new WebMarkupContainer("gateKeeperTypeSelector").setVisible(false));
+ fragment.add(new WebMarkupContainer("gateKeeperEditor").setVisible(false));
+ }
+ container.add(fragment);
+ } else if (clazz == ConditionalGateKeeper.class) {
+ final ConditionalGateKeeper ifThenGateKeeper = (ConditionalGateKeeper) gateKeeper;
+ final Fragment fragment = new Fragment("content", "ifThenFrag", GateKeeperPanel.this);
+
+ if (ifThenGateKeeper.getIfGate() instanceof DefaultGateKeeper) {
+ fragment.add(new GateKeeperLink("ifGate") {
+
+ @Override
+ protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {
+ final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);
+ if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {
+ ifThenGateKeeper.setIfGate(gateKeeper);
+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
+ } else {
+ new ModalPanel(target) {
+
+ @Override
+ protected Component newContent(String id) {
+ return new GateKeeperEditor(id, gateKeeper) {
+
+ @Override
+ protected void onCancel(AjaxRequestTarget target) {
+ close(target);
+ }
+
+ @Override
+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
+ close(target);
+ fragment.replace(new WebMarkupContainer("ifEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));
+ ifThenGateKeeper.setIfGate(gateKeeper);
+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
+ }
+
+ };
+ }
+
+ };
+ }
+ }
+
+ @Override
+ public IModel<?> getBody() {
+ return Model.of("Define gatekeeper <i class='fa fa-plus-circle'></i>");
+ }
+
+ }.setEscapeModelStrings(false).add(AttributeAppender.append("class", "well gate-keeper-add")));
+ } else {
+ fragment.add(new GateKeeperPanel("ifGate", ifThenGateKeeper.getIfGate()) {
+
+ @Override
+ protected void onDelete(AjaxRequestTarget target) {
+ ifThenGateKeeper.setIfGate(new DefaultGateKeeper());
+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
+ }
+
+ @Override
+ protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {
+ ifThenGateKeeper.setIfGate(gateKeeper);
+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
+ }
+
+ });
+ }
+ fragment.add(new WebMarkupContainer("ifEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));
+
+ if (ifThenGateKeeper.getThenGate() instanceof DefaultGateKeeper) {
+ fragment.add(new GateKeeperLink("thenGate") {
+
+ @Override
+ protected void onSelect(AjaxRequestTarget target, Class<? extends GateKeeper> gateKeeperClass) {
+ final GateKeeper gateKeeper = ReflectionUtils.instantiateClass(gateKeeperClass);
+ if (EditableUtils.isDefaultInstanceValid(gateKeeperClass)) {
+ ifThenGateKeeper.setThenGate(gateKeeper);
+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
+ } else {
+ new ModalPanel(target) {
+
+ @Override
+ protected Component newContent(String id) {
+ return new GateKeeperEditor(id, gateKeeper) {
+
+ @Override
+ protected void onCancel(AjaxRequestTarget target) {
+ close(target);
+ }
+
+ @Override
+ protected void onSave(AjaxRequestTarget target, GateKeeper gateKeeper) {
+ close(target);
+ fragment.replace(new WebMarkupContainer("thenEditor").setOutputMarkupPlaceholderTag(true).setVisible(true));
+ ifThenGateKeeper.setThenGate(gateKeeper);
+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
+ }
+
+ };
+ }
+
+ };
+ }
+ }
+
+ @Override
+ public IModel<?> getBody() {
+ return Model.of("Define gatekeeper <i class='fa fa-plus-circle'></i>");
+ }
+
+ }.setEscapeModelStrings(false).add(AttributeAppender.append("class", "well gate-keeper-add")));
+ } else {
+ fragment.add(new GateKeeperPanel("thenGate", ifThenGateKeeper.getThenGate()) {
+
+ @Override
+ protected void onDelete(AjaxRequestTarget target) {
+ ifThenGateKeeper.setThenGate(new DefaultGateKeeper());
+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
+ }
+
+ @Override
+ protected void onChange(AjaxRequestTarget target, GateKeeper gateKeeper) {
+ ifThenGateKeeper.setThenGate(gateKeeper);
+ GateKeeperPanel.this.onChange(target, ifThenGateKeeper);
+ }
+
+ });
+ }
+ fragment.add(new WebMarkupContainer("thenEditor").setOutputMarkupPlaceholderTag(true).setVisible(false));
+
+ container.add(fragment);
+ } else {
+ Fragment fragment = new Fragment("content", "otherFrag", GateKeeperPanel.this);
+ fragment.add(BeanContext.viewBean("viewer", gateKeeper));
+ container.add(fragment);
+ }
+ }
+
+ protected abstract void onDelete(AjaxRequestTarget target);
+
+ protected abstract void onChange(AjaxRequestTarget target, GateKeeper gateKeeper);
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/general/GeneralSettingPage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/general/GeneralSettingPage.html
index 21b55a4476..a54cd8e2a1 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/general/GeneralSettingPage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/setting/general/GeneralSettingPage.html
@@ -1,37 +1,37 @@
-<wicket:extend>
- <div class="general-setting">
- <form wicket:id="form" class="leave-confirm">
- <div wicket:id="editor"></div>
- <div class="actions">
- <input class="btn btn-primary dirty-aware" value="Update" type="submit"></input>
- <a wicket:id="delete" class="delete btn btn-danger pull-right">Delete</a>
- <a wicket:id="transfer" class="transfer btn btn-danger pull-right">Transfer</a>
- </div>
- </form>
- </div>
- <wicket:fragment wicket:id="transferFrag">
- <div class="transfer-depot">
- <!-- Add form tag so that the default delete button can be triggered when user hits return -->
- <form wicket:id="form">
- <div class="modal-header">
- <h4 id="modal-title" class="modal-title">
- Transfer repository to another account
- </h4>
- </div>
- <div class="modal-body">
- <div class="message">You can only transfer repository to accounts you have administrative
- rights on. Also note that original team references in repository
- authorization and gate keeper definition will be removed after transferring as teams are local to account.</div>
- <div class="form-group">
- <input wicket:id="account" type="hidden" class="form-control" placeholder="Select destination account..."></input>
- <div wicket:id="feedback"></div>
- </div>
- </div>
- <div class="modal-footer">
- <input wicket:id="transfer" type="submit" class="btn btn-danger dirty-aware" value="Transfer"></input>
- <a wicket:id="cancel" class="btn btn-default">Cancel</a>
- </div>
- </form>
- </div>
- </wicket:fragment>
+<wicket:extend>
+ <div class="general-setting">
+ <form wicket:id="form" class="leave-confirm">
+ <div wicket:id="editor"></div>
+ <div class="actions">
+ <input class="btn btn-primary dirty-aware" value="Update" type="submit"></input>
+ <a wicket:id="delete" class="delete btn btn-danger pull-right">Delete</a>
+ <a wicket:id="transfer" class="transfer btn btn-danger pull-right">Transfer</a>
+ </div>
+ </form>
+ </div>
+ <wicket:fragment wicket:id="transferFrag">
+ <div class="transfer-depot">
+ <!-- Add form tag so that the default delete button can be triggered when user hits return -->
+ <form wicket:id="form">
+ <div class="modal-header">
+ <h4 id="modal-title" class="modal-title">
+ Transfer repository to another account
+ </h4>
+ </div>
+ <div class="modal-body">
+ <div class="message">You can only transfer repository to accounts you have administrative
+ rights on. Also note that original team references in repository
+ authorization and gatekeeper definition will be removed after transferring as teams are local to account.</div>
+ <div class="form-group">
+ <input wicket:id="account" type="hidden" class="form-control" placeholder="Select destination account..."></input>
+ <div wicket:id="feedback"></div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <input wicket:id="transfer" type="submit" class="btn btn-danger dirty-aware" value="Transfer"></input>
+ <a wicket:id="cancel" class="btn btn-default">Cancel</a>
+ </div>
+ </form>
+ </div>
+ </wicket:fragment>
</wicket:extend>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java
index b0cb500a9b..8148d762c8 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/test/TestPage.java
@@ -1,9 +1,13 @@
package com.pmease.gitplex.web.page.test;
+import javax.validation.Validator;
+
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.link.Link;
import com.pmease.commons.wicket.page.CommonPage;
+import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.setting.BackupSetting;
@SuppressWarnings("serial")
public class TestPage extends CommonPage {
@@ -16,6 +20,10 @@ public class TestPage extends CommonPage {
@Override
public void onClick() {
+ BackupSetting backupSetting = new BackupSetting();
+ backupSetting.setSchedule("0 * * * ?");
+ backupSetting.setFolder("w:\\temp");
+ System.out.println(GitPlex.getInstance(Validator.class).validate(backupSetting).size());
}
});
diff --git a/parent.general/pom.xml b/parent.general/pom.xml
index 22d9627d6e..d7e047d573 100644
--- a/parent.general/pom.xml
+++ b/parent.general/pom.xml
@@ -1,618 +1,613 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.pmease</groupId>
- <artifactId>parent.general</artifactId>
- <version>1.0.31</version>
- <packaging>pom</packaging>
- <prerequisites>
- <maven>3.0</maven>
- </prerequisites>
- <build>
- <finalName>${project.groupId}.${project.artifactId}-${project.version}</finalName>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>archetype-resource/pom.xml</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <excludes>
- <exclude>archetype-resource/pom.xml</exclude>
- </excludes>
- </resource>
- <resource>
- <directory>src/main/java</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- </resources>
- <testResources>
- <testResource>
- <directory>src/test/resources</directory>
- </testResource>
- <testResource>
- <directory>src/test/java</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </testResource>
- </testResources>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <versionRange>[1.0.0,)</versionRange>
- <goals>
- <goal>enforce</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore />
- </action>
- </pluginExecution>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>com.pmease</groupId>
- <artifactId>plugin.maven</artifactId>
- <versionRange>[1.0.0,]</versionRange>
- <goals>
- <goal>check-project-dependencies</goal>
- <goal>generate-artifact-descriptor</goal>
- <goal>generate-plugin-resources</goal>
- <goal>generate-product-resources</goal>
- <goal>create-product-sandbox</goal>
- <goal>copy-antlr-tokens</goal>
- <goal>run-ant</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <execute>
- <runOnIncremental>true</runOnIncremental>
- <runOnConfiguration>true</runOnConfiguration>
- </execute>
- </action>
- </pluginExecution>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <versionRange>[1.0.0,]</versionRange>
- <goals>
- <goal>jar</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore />
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-archetype-plugin</artifactId>
- <version>2.2</version>
- <executions>
- <execution>
- <id>install-archetype</id>
- <phase>install</phase>
- <goals>
- <goal>update-local-catalog</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.5</version>
- <configuration>
- <escapeString>\</escapeString>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
- <executions>
- <execution>
- <id>default-jar</id>
- <phase>never</phase>
- <configuration>
- <finalName>unwanted</finalName>
- <classifier>unwanted</classifier>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.7</version>
- <dependencies>
- <dependency>
- <groupId>ant</groupId>
- <artifactId>ant-apache-regexp</artifactId>
- <version>1.6.5</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- <version>1.8.6</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.gant</groupId>
- <artifactId>gant_groovy1.8</artifactId>
- <version>1.9.7</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>com.pmease</groupId>
- <artifactId>plugin.maven</artifactId>
- <version>1.0.31</version>
- <executions>
- <execution>
- <id>check-project-dependencies</id>
- <phase>compile</phase>
- <goals>
- <goal>check-project-dependencies</goal>
- </goals>
- </execution>
- <execution>
- <id>copy-antlr-tokens</id>
- <phase>compile</phase>
- <goals>
- <goal>copy-antlr-tokens</goal>
- </goals>
- </execution>
- <execution>
- <id>generate-artifact-descriptor</id>
- <phase>compile</phase>
- <goals>
- <goal>generate-artifact-descriptor</goal>
- </goals>
- </execution>
- <execution>
- <id>package-artifact</id>
- <phase>package</phase>
- <goals>
- <goal>package-artifact</goal>
- </goals>
- </execution>
- <execution>
- <id>generate-plugin-resources</id>
- <phase>compile</phase>
- <goals>
- <goal>generate-plugin-resources</goal>
- </goals>
- </execution>
- <execution>
- <id>generate-product-resources</id>
- <phase>compile</phase>
- <goals>
- <goal>generate-product-resources</goal>
- </goals>
- </execution>
- <execution>
- <id>create-product-sandbox</id>
- <phase>compile</phase>
- <goals>
- <goal>create-product-sandbox</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.1.2</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>package</phase>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-maven-plugin</artifactId>
- <version>${antlrVersion}</version>
- <executions>
- <execution>
- <goals>
- <goal>antlr4</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.2</version>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <phase>package</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- <configuration>
- <additionalparam>-Xdoclint:none</additionalparam>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>1.3.1</version>
- <executions>
- <execution>
- <id>enforce-java</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireJavaVersion>
- <version>1.8.0</version>
- </requireJavaVersion>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4jVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- <version>${slf4jVersion}</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>${logbackVersion}</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>${logbackVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.1</version>
- </dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.7</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- </dependency>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>16.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.quartz-scheduler</groupId>
- <artifactId>quartz</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1</version>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.xodus</groupId>
- <artifactId>xodus-entity-store</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tika</groupId>
- <artifactId>tika-core</artifactId>
- <version>1.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-email</artifactId>
- <version>1.3.3</version>
- </dependency>
- <dependency>
- <groupId>org.jsoup</groupId>
- <artifactId>jsoup</artifactId>
- <version>1.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <version>1.7</version>
- </dependency>
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.1</version>
- </dependency>
- <dependency>
- <groupId>joda-time</groupId>
- <artifactId>joda-time</artifactId>
- <version>2.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-collections4</artifactId>
- <version>4.1</version>
- </dependency>
- <dependency>
- <groupId>org.javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.20.0-GA</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-compress</artifactId>
- <version>1.8</version>
- </dependency>
- <dependency>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant</artifactId>
- <version>1.9.1</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <version>${jettyVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-servlets</artifactId>
- <version>${jettyVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-servlet</artifactId>
- <version>${jettyVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-websocket</artifactId>
- <version>${jettyVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <version>${jettyVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty.websocket</groupId>
- <artifactId>websocket-server</artifactId>
- <version>${jettyVersion}</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>${servletVersion}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- <version>${jacksonVersion}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>${jacksonVersion}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.datatype</groupId>
- <artifactId>jackson-datatype-guava</artifactId>
- <version>${jacksonVersion}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.datatype</groupId>
- <artifactId>jackson-datatype-joda</artifactId>
- <version>${jacksonVersion}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.jaxrs</groupId>
- <artifactId>jackson-jaxrs-json-provider</artifactId>
- <version>${jacksonVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.containers</groupId>
- <artifactId>jersey-container-servlet</artifactId>
- <version>${jerseyVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.ext</groupId>
- <artifactId>jersey-bean-validation</artifactId>
- <version>${jerseyVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- <version>5.2.4.Final</version>
- </dependency>
- <dependency>
- <groupId>org.reflections</groupId>
- <artifactId>reflections</artifactId>
- <version>0.9.9</version>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr4-runtime</artifactId>
- <version>${antlrVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.unbescape</groupId>
- <artifactId>unbescape</artifactId>
- <version>1.1.2.RELEASE</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.9.5</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>${powermockVersion}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>${powermockVersion}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <pluginRepositories>
- <!-- access central repository via http protocol as otherwise m2e
- will access central via https protocol to cause certificate error -->
- <pluginRepository>
- <id>central</id>
- <url>http://repo1.maven.org/maven2</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- </pluginRepository>
- <pluginRepository>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- <id>pmeaseRepo</id>
- <name>PMEase Repository</name>
- <url>http://artifact.pmease.com/</url>
- </pluginRepository>
- </pluginRepositories>
- <repositories>
- <!-- access central repository via http protocol as otherwise m2e
- will access central via https protocol to cause certificate error -->
- <repository>
- <id>central</id>
- <url>http://repo1.maven.org/maven2</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- </repository>
- <repository>
- <id>pmeaseRepo</id>
- <name>PMEase Repository</name>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- <url>http://artifact.pmease.com/</url>
- </repository>
- <repository>
- <id>apache-snapshots</id>
- <name>Apache Snapshots</name>
- <url>http://repository.apache.org/snapshots/</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>sonatype-snapshots</id>
- <name>Sonatype Snapshots</name>
- <url>https://oss.sonatype.org/content/repositories/snapshots</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
- <distributionManagement>
- <repository>
- <id>pmeaseRepo</id>
- <url>http://artifact.pmease.com/</url>
- </repository>
- </distributionManagement>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <slf4jVersion>1.7.5</slf4jVersion>
- <logbackVersion>1.0.11</logbackVersion>
- <jerseyVersion>2.13</jerseyVersion>
- <jettyVersion>9.3.8.v20160314</jettyVersion>
- <jacksonVersion>2.4.3</jacksonVersion>
- <powermockVersion>1.5.1</powermockVersion>
- <servletVersion>3.1.0</servletVersion>
- <antlrVersion>4.5.1-1</antlrVersion>
- </properties>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.pmease</groupId>
+ <artifactId>parent.general</artifactId>
+ <version>1.0.31</version>
+ <packaging>pom</packaging>
+ <prerequisites>
+ <maven>3.0</maven>
+ </prerequisites>
+ <build>
+ <finalName>${project.groupId}.${project.artifactId}-${project.version}</finalName>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>archetype-resource/pom.xml</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <excludes>
+ <exclude>archetype-resource/pom.xml</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <versionRange>[1.0.0,)</versionRange>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>com.pmease</groupId>
+ <artifactId>plugin.maven</artifactId>
+ <versionRange>[1.0.0,]</versionRange>
+ <goals>
+ <goal>check-project-dependencies</goal>
+ <goal>generate-artifact-descriptor</goal>
+ <goal>generate-plugin-resources</goal>
+ <goal>generate-product-resources</goal>
+ <goal>create-product-sandbox</goal>
+ <goal>copy-antlr-tokens</goal>
+ <goal>run-ant</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <execute>
+ <runOnIncremental>true</runOnIncremental>
+ <runOnConfiguration>true</runOnConfiguration>
+ </execute>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <versionRange>[1.0.0,]</versionRange>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.2</version>
+ <executions>
+ <execution>
+ <id>install-archetype</id>
+ <phase>install</phase>
+ <goals>
+ <goal>update-local-catalog</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <escapeString>\</escapeString>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <phase>never</phase>
+ <configuration>
+ <finalName>unwanted</finalName>
+ <classifier>unwanted</classifier>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-apache-regexp</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.8.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.gant</groupId>
+ <artifactId>gant_groovy1.8</artifactId>
+ <version>1.9.7</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>com.pmease</groupId>
+ <artifactId>plugin.maven</artifactId>
+ <version>1.0.31</version>
+ <executions>
+ <execution>
+ <id>check-project-dependencies</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>check-project-dependencies</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>copy-antlr-tokens</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>copy-antlr-tokens</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-artifact-descriptor</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>generate-artifact-descriptor</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>package-artifact</id>
+ <phase>package</phase>
+ <goals>
+ <goal>package-artifact</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-plugin-resources</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>generate-plugin-resources</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-product-resources</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>generate-product-resources</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>create-product-sandbox</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>create-product-sandbox</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.2</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <version>${antlrVersion}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>antlr4</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.2</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ <configuration>
+ <additionalparam>-Xdoclint:none</additionalparam>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.3.1</version>
+ <executions>
+ <execution>
+ <id>enforce-java</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>1.8.0</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4jVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jul-to-slf4j</artifactId>
+ <version>${slf4jVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>${logbackVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logbackVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.7</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>16.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.quartz-scheduler</groupId>
+ <artifactId>quartz</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.xodus</groupId>
+ <artifactId>xodus-entity-store</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tika</groupId>
+ <artifactId>tika-core</artifactId>
+ <version>1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-email</artifactId>
+ <version>1.3.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jsoup</groupId>
+ <artifactId>jsoup</artifactId>
+ <version>1.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.7</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ <version>2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
+ <version>4.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.20.0-GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ <version>1.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>${jettyVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlets</artifactId>
+ <version>${jettyVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <version>${jettyVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-websocket</artifactId>
+ <version>${jettyVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>${jettyVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.websocket</groupId>
+ <artifactId>websocket-server</artifactId>
+ <version>${jettyVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>${servletVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>${jacksonVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>${jacksonVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.datatype</groupId>
+ <artifactId>jackson-datatype-guava</artifactId>
+ <version>${jacksonVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.datatype</groupId>
+ <artifactId>jackson-datatype-joda</artifactId>
+ <version>${jacksonVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ <version>${jacksonVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet</artifactId>
+ <version>${jerseyVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.ext</groupId>
+ <artifactId>jersey-bean-validation</artifactId>
+ <version>${jerseyVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>5.2.4.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <version>0.9.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ <version>${antlrVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.unbescape</groupId>
+ <artifactId>unbescape</artifactId>
+ <version>1.1.2.RELEASE</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>${powermockVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>${powermockVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <pluginRepositories>
+ <!-- access central repository via http protocol as otherwise m2e
+ will access central via https protocol to cause certificate error -->
+ <pluginRepository>
+ <id>central</id>
+ <url>http://repo1.maven.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </pluginRepository>
+ <pluginRepository>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ <id>pmeaseRepo</id>
+ <name>PMEase Repository</name>
+ <url>http://artifact.pmease.com/</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <repositories>
+ <!-- access central repository via http protocol as otherwise m2e
+ will access central via https protocol to cause certificate error -->
+ <repository>
+ <id>central</id>
+ <url>http://repo1.maven.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ <repository>
+ <id>pmeaseRepo</id>
+ <name>PMEase Repository</name>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ <url>http://artifact.pmease.com/</url>
+ </repository>
+ <repository>
+ <id>apache-snapshots</id>
+ <name>Apache Snapshots</name>
+ <url>http://repository.apache.org/snapshots/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>sonatype-snapshots</id>
+ <name>Sonatype Snapshots</name>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <distributionManagement>
+ <repository>
+ <id>pmeaseRepo</id>
+ <url>http://artifact.pmease.com/</url>
+ </repository>
+ </distributionManagement>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <slf4jVersion>1.7.5</slf4jVersion>
+ <logbackVersion>1.0.11</logbackVersion>
+ <jerseyVersion>2.13</jerseyVersion>
+ <jettyVersion>9.3.8.v20160314</jettyVersion>
+ <jacksonVersion>2.4.3</jacksonVersion>
+ <powermockVersion>1.5.1</powermockVersion>
+ <servletVersion>3.1.0</servletVersion>
+ <antlrVersion>4.5.1-1</antlrVersion>
+ </properties>
+</project>