Skip to content

Commit

Permalink
Merge branch 'gissue_180_RAS_application_versioning' into ghub_rvd_ma…
Browse files Browse the repository at this point in the history
…ster
  • Loading branch information
otsakir committed Feb 5, 2015
2 parents 378c78b + 89a056d commit 3f34d7f
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.mobicents.servlet.restcomm.rvd.exceptions.packaging.PackagingException;
import org.mobicents.servlet.restcomm.rvd.exceptions.ras.RasException;
import org.mobicents.servlet.restcomm.rvd.exceptions.ras.RestcommAppAlreadyExists;
import org.mobicents.servlet.restcomm.rvd.exceptions.ras.UnsupportedRasApplicationVersion;
import org.mobicents.servlet.restcomm.rvd.model.ModelMarshaler;
import org.mobicents.servlet.restcomm.rvd.model.RappItem;
import org.mobicents.servlet.restcomm.rvd.model.client.ProjectState;
Expand Down Expand Up @@ -137,6 +138,20 @@ public String importAppToWorkspace( InputStream packageZipStream, String loggedU
//RappConfig config = storageBase.loadModelFromFile( tempDir.getPath() + "/app/" + "config", RappConfig.class );
RappConfig config = workspaceStorage.loadModelFromFile( tempDir.getPath() + "/app/" + "config", RappConfig.class );

int effectivePackageVersion = 1;
if (info.getRasVersion() != null)
try {
effectivePackageVersion = Integer.parseInt(info.getRasVersion());
} catch (NumberFormatException e) {
//effectivePackageVersion = 1; // already done
}

int runtimePackageVersion = Integer.parseInt(RvdConfiguration.getRasApplicationVersion());

if (runtimePackageVersion < effectivePackageVersion)
throw new UnsupportedRasApplicationVersion("Incompatible application package. Version " + effectivePackageVersion + " is not supported");


// Reject applications with no unique id.
// TODO At some point control this check using a flag
//if ( RvdUtils.isEmpty(info.getId()) ) {
Expand Down Expand Up @@ -195,6 +210,10 @@ public void saveApp(Rapp rapp, String projectName) throws RvdValidationException
if ( ! report.isOk() )
throw new RvdValidationException("Cannot validate rapp", report);

// set version since they are affected from the current RVD runtime
rapp.getInfo().setRasVersion(RvdConfiguration.getRasApplicationVersion());
rapp.getInfo().setRvdAppVersion(RvdConfiguration.getRvdProjectVersion());

// preserve the app's id
Rapp existingRapp = FsPackagingStorage.loadRapp(projectName,workspaceStorage);
rapp.getInfo().setId( existingRapp.getInfo().getId() );
Expand All @@ -214,6 +233,10 @@ public void createApp(Rapp rapp, String projectName) throws RvdValidationExcepti
if ( ! report.isOk() )
throw new RvdValidationException("Cannot validate rapp", report);

// set version since they are affected from the current RVD runtime
rapp.getInfo().setRasVersion(RvdConfiguration.getRasApplicationVersion());
rapp.getInfo().setRvdAppVersion(RvdConfiguration.getRvdProjectVersion());

// rapp.getInfo().setId(generateAppId(projectName)); // Let the RAS administrator choose an id for the app after submission
FsPackagingStorage.storeRapp(rapp, projectName, workspaceStorage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class RvdConfiguration {
public static final String WAVS_DIRECTORY_NAME = "wavs";
private static final String RVD_PROJECT_VERSION = "1.3"; // version for rvd project syntax
private static final String PACKAGING_VERSION = "1.0";
private static final String RAS_APPLICATION_VERSION = "2"; // version of the RAS application specification
public static final String STICKY_PREFIX = "sticky_"; // a prefix for rvd sticky variable names
public static final String MODULE_PREFIX = "module_"; // a prefix for rvd module-scoped variable names
public static final String CORE_VARIABLE_PREFIX = "core_"; // a prefix for rvd variables that come from Restcomm parameters
Expand Down Expand Up @@ -95,6 +96,10 @@ public static String getPackagingVersion() {
return PACKAGING_VERSION;
}

public static String getRasApplicationVersion() {
return RAS_APPLICATION_VERSION;
}

public String getExternalServiceBase() {
return externalServiceBase;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.mobicents.servlet.restcomm.rvd.exceptions.ras;

public class UnsupportedRasApplicationVersion extends RasException {

public UnsupportedRasApplicationVersion() {
// TODO Auto-generated constructor stub
}

public UnsupportedRasApplicationVersion(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}

public UnsupportedRasApplicationVersion(String message) {
super(message);
// TODO Auto-generated constructor stub
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.mobicents.servlet.restcomm.rvd.exceptions.project.ProjectException;
import org.mobicents.servlet.restcomm.rvd.exceptions.ras.InvalidRestcommAppPackage;
import org.mobicents.servlet.restcomm.rvd.exceptions.ras.RestcommAppAlreadyExists;
import org.mobicents.servlet.restcomm.rvd.exceptions.ras.UnsupportedRasApplicationVersion;
import org.mobicents.servlet.restcomm.rvd.http.RestService;
import org.mobicents.servlet.restcomm.rvd.http.RvdResponse;
import org.mobicents.servlet.restcomm.rvd.model.ModelMarshaler;
Expand Down Expand Up @@ -230,8 +231,8 @@ public Response listRapps(@Context HttpServletRequest request) {
* @return
*/
@POST
@Path("apps/{name}")
public Response newRasApp(@PathParam("name") String projectNameOverride, @Context HttpServletRequest request) {
@Path("apps")
public Response newRasApp(@Context HttpServletRequest request) {
logger.info("uploading new ras app");

BuildService buildService = new BuildService(workspaceStorage);
Expand Down Expand Up @@ -283,6 +284,9 @@ public Response newRasApp(@PathParam("name") String projectNameOverride, @Contex
} catch (InvalidRestcommAppPackage e ) {
logger.error(e.getMessage(), e);
return buildErrorResponse(Status.INTERNAL_SERVER_ERROR, RvdResponse.Status.ERROR, e);
} catch (UnsupportedRasApplicationVersion e) {
logger.warn(e.getMessage());
return buildErrorResponse(Status.INTERNAL_SERVER_ERROR, RvdResponse.Status.ERROR, e);
} catch ( Exception e /* TODO - use a more specific type !!! */) {
logger.error(e.getMessage(), e);
return Response.status(Status.INTERNAL_SERVER_ERROR).build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.mobicents.servlet.restcomm.rvd.model.packaging;

import org.mobicents.servlet.restcomm.rvd.RvdConfiguration;
import org.mobicents.servlet.restcomm.rvd.validation.ValidatableModel;
import org.mobicents.servlet.restcomm.rvd.validation.ValidationReport;

Expand All @@ -14,7 +13,8 @@ public class RappInfo extends ValidatableModel {
private String name;
private String description;
private String appVersion;
private String rvdAppVersion = RvdConfiguration.getRvdProjectVersion();
private String rvdAppVersion;
private String rasVersion;
private String id;

public RappInfo() {
Expand Down Expand Up @@ -61,6 +61,14 @@ public void setId(String id) {
this.id = id;
}

public String getRasVersion() {
return rasVersion;
}

public void setRasVersion(String rasVersion) {
this.rasVersion = rasVersion;
}

@Override
public ValidationReport validate(ValidationReport report) {
// TODO Auto-generated method stub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ App.controller('projectManagerCtrl', function ( $scope, $http, $location, $route
}).success(function(data, status, headers, config) {
console.log('Project imported successfully');
$scope.refreshProjectList();
notifications.put({message:"Project imported successfully", type:"success"});
}).error(function(data, status, headers, config) {
if (status == 400) {// BAD REQUEST
console.log(data.exception.message);
Expand Down

0 comments on commit 3f34d7f

Please sign in to comment.