Skip to content

Commit

Permalink
1.7 Preversion
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-yves-monnet committed Apr 2, 2020
1 parent fd2fe14 commit 8f2a460
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 87 deletions.
121 changes: 95 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<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>org.bonitasoft.command</groupId>
<artifactId>bonita-commanddeployment</artifactId>
<!-- ATTENTION : when this number change, please change it in BonitaCommandDeployment.java -->
<version>1.7</version>
<name>bonita-commanddeployment</name>
<properties>
<modelVersion>4.0.0</modelVersion>
<groupId>org.bonitasoft.command</groupId>
<artifactId>bonita-commanddeployment</artifactId>
<!-- ATTENTION : when this number change, please change it in BonitaCommandDeployment.java -->
<version>1.7</version>
<name>bonita-commanddeployment</name>

<properties>
<bonita.version>7.6.0</bonita.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>

<dependencies>


<dependency>
Expand All @@ -31,22 +31,91 @@
<artifactId>bonita-event</artifactId>
<version>1.8.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>logPageBonita</id>
<name>logPageBonita</name>
<url>https://raw.githubusercontent.com/Bonitasoft-Community/bonitamavenrepository/master</url>
<layout>default</layout>
</repository>
</dependencies>

<repositories>
<repository>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>logPageBonita</id>
<name>logPageBonita</name>
<url>https://raw.githubusercontent.com/Bonitasoft-Community/bonitamavenrepository/master</url>
<layout>default</layout>
</repository>
</repositories>
<build>
<plugins>
<!-- ******************** Copy JAR files under bonitamavenrepository **************** -->
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
import java.nio.file.*;

String groupIdPath = "${project.groupId}".replace('.', '/');

String fileName = "${artifactId}-${version}.jar";
Path destPath = Paths.get( "../bonitamavenrepository/${groupIdPath}/${artifactId}/${version}" );

Path sourceJarFile = Paths.get("target/"+fileName);
Path destJarFile = Paths.get( destPath.toString()+"/"+fileName);
copyFile( sourceJarFile, destJarFile);

Path sourcePom = Paths.get("pom.xml" );
Path destPom = Paths.get( destPath.toString()+"/${artifactId}-${version}.pom" );
copyFile( sourcePom, destPom);
return;

public void copyFile( Path sourcePath, Path destinationPath ) {
try {
Path parentPath = destinationPath.getParent();
println(" Create Directory:"+parentPath.toString());
Files.createDirectories(parentPath);


try {
if (destinationPath.toFile().exists()) {
println(" Delete existing file:"+destinationPath.toString());
Files.delete(destinationPath);
}
} catch(Exception e) {
println(" Error during deletion "+e.getMessage());
}
println(" Copy:"+sourcePath+" =>"+destinationPath);


def file = sourcePath.toFile();
def newFile = destinationPath.toFile();
Files.copy(file.toPath(), newFile.toPath());

} catch(Exception e )
{
println("Exception "+e.getMessage());
}
}




</source>
</configuration>
</execution>
</executions>
</plugin>


</plugins>
</build>
</project>
31 changes: 25 additions & 6 deletions src/main/java/org/bonitasoft/command/BonitaCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public abstract class BonitaCommand extends TenantCommand {
public final static String CST_VERB = "verb";
public final static String CST_VERB_AFTERDEPLOIMENT = "AFTERDEPLOYMENT";
public final static String CST_VERB_PING = "PING";
public final static String CST_VER_HELP = "HELP";
public final static String CST_VERBE_HELP = "HELP";

/**
* this constant is defined too in MilkQuartzJob to have an independent JAR
Expand Down Expand Up @@ -120,6 +120,7 @@ public static class ExecuteParameters {
public String verb;
public Map<String, Serializable> parametersCommand;


/** to avoid the cast, return as String parameters. If the parameter is not a String, return null */
public String getParametersString(String name) {
return getParametersString(name, null);
Expand All @@ -142,6 +143,22 @@ public Long getParametersLong(String name, Long defaultValue) {
return defaultValue;
if (parametersCommand.get(name) instanceof Long)
return (Long) parametersCommand.get(name);
try {
return Long.parseLong( parametersCommand.get(name).toString());
}
catch(Exception e) {}
return defaultValue;
}
/** to avoid the cast, return as Long parameters. If the parameter is not a Long, return null */
public Integer getParametersInt(String name, Integer defaultValue) {
if (parametersCommand.get(name) == null)
return defaultValue;
if (parametersCommand.get(name) instanceof Integer)
return (Integer) parametersCommand.get(name);
try {
return Integer.parseInt( parametersCommand.get(name).toString());
}
catch(Exception e) {}
return defaultValue;
}

Expand Down Expand Up @@ -183,7 +200,7 @@ public void setTenantId(Long tenantId) {
public static class ExecuteAnswer {

public boolean logAnswer = true;
public List<BEvent> listEvents = new ArrayList<BEvent>();
public List<BEvent> listEvents = new ArrayList<>();
// to keep the serialisation, it must be a HashMap()
public HashMap<String, Object> result = new HashMap<>();
/*
Expand Down Expand Up @@ -233,10 +250,11 @@ public ExecuteAnswer afterRestart(ExecuteParameters executeParameters, TenantSer

@SuppressWarnings("unchecked")
public ExecuteAnswer executeCommandVerbe(String verb, Map<String, Serializable> parameters, TenantServiceAccessor serviceAccessor) {
ExecuteParameters executeParameters = new ExecuteParameters();
ExecuteParameters executeParameters = new ExecuteParameters();
executeParameters.parameters = parameters;
executeParameters.verb = (String) parameters.get(CST_VERB);
executeParameters.setTenantId((Long) parameters.get(CST_TENANTID));

executeParameters.parametersCommand = (Map<String, Serializable>) parameters.get(BonitaCommand.CST_PARAMETER_COMMAND);

return executeCommand(executeParameters, serviceAccessor);
Expand Down Expand Up @@ -268,7 +286,7 @@ public String getHelp(Map<String, Serializable> parameters, long tenantId, Tenan
public Serializable execute(Map<String, Serializable> parameters, TenantServiceAccessor serviceAccessor)
throws SCommandParameterizationException, SCommandExecutionException {

BonitaCommand executableCmdControl = getInstance();
BonitaCommand executableCmdControl = getInstance();
return executableCmdControl.executeSingleton(parameters, serviceAccessor);
}

Expand Down Expand Up @@ -298,7 +316,8 @@ private Serializable executeSingleton(Map<String, Serializable> parameters, Tena
executeParameters.verb = (String) parameters.get(CST_VERB);
executeParameters.setTenantId((Long) parameters.get(CST_TENANTID));
executeParameters.parametersCommand = (Map<String, Serializable>) parameters.get(BonitaCommand.CST_PARAMETER_COMMAND);



logger.fine(logHeader + "BonitaCommand Verb[" + (executeParameters.verb == null ? null : executeParameters.verb.toString()) + "] Tenant[" + executeParameters.tenantId + "]");

// ------------------- ping ?
Expand All @@ -314,7 +333,7 @@ private Serializable executeSingleton(Map<String, Serializable> parameters, Tena

checkExecuteAfterRestart( parameters, serviceAccessor);

} else if (CST_VER_HELP.equals(executeParameters.verb)) {
} else if (CST_VERBE_HELP.equals(executeParameters.verb)) {
checkExecuteAfterRestart( parameters, serviceAccessor);

executeAnswer = new ExecuteAnswer();
Expand Down
Loading

0 comments on commit 8f2a460

Please sign in to comment.