// Validate count against the metainfo.xml
int priority =
component.getMandatoryOptionInt(ResourceKeys.COMPONENT_PRIORITY);
if (priority <= 0) {
throw new BadConfigException("Component %s %s value out of range %d",
name,
ResourceKeys.COMPONENT_PRIORITY,
priority);
}
String existing = priorityMap.get(priority);
if (existing != null) {
throw new BadConfigException(
"Component %s has a %s value %d which duplicates that of %s",
name,
ResourceKeys.COMPONENT_PRIORITY,
priority,
existing);
}
priorityMap.put(priority, name);
}
try {
// Validate the app definition
instanceDefinition.getAppConfOperations().
getGlobalOptions().getMandatoryOption(AgentKeys.APP_DEF);
} catch (BadConfigException bce) {
throw new BadConfigException("Application definition must be provided. " + bce.getMessage());
}
String appDef = instanceDefinition.getAppConfOperations().
getGlobalOptions().getMandatoryOption(AgentKeys.APP_DEF);
log.info("Validating app definition {}", appDef);
String extension = appDef.substring(appDef.lastIndexOf(".") + 1, appDef.length());
if (!"zip".equalsIgnoreCase(extension)) {
throw new BadConfigException("App definition must be packaged as a .zip file. File provided is " + appDef);
}
String appHome = instanceDefinition.getAppConfOperations().
getGlobalOptions().get(AgentKeys.PACKAGE_PATH);
String agentImage = instanceDefinition.getInternalOperations().
get(OptionKeys.INTERNAL_APPLICATION_IMAGE_PATH);
if (SliderUtils.isUnset(appHome) && SliderUtils.isUnset(agentImage)) {
throw new BadConfigException("Either agent package path " +
AgentKeys.PACKAGE_PATH + " or image root " +
OptionKeys.INTERNAL_APPLICATION_IMAGE_PATH
+ " must be provided.");
}
}