public BuilderResult buildAsset(RuleAsset asset) throws SerializableException {
if ( Contexts.isSessionContextActive() ) {
Identity.instance().checkPermission( new PackageNameType( asset.metaData.packageName ),
RoleTypes.PACKAGE_DEVELOPER );
}
BuilderResult result = new BuilderResult();
try {
AssetItem item = repository.loadAssetByUUID( asset.uuid );
ContentHandler handler = ContentManager.getHandler( item.getFormat() );// new
// AssetContentFormatHandler();
handler.storeAssetContent( asset,
item );
if ( handler instanceof IValidating ) {
return ((IValidating) handler).validateAsset( item );
} else {
ContentPackageAssembler asm = new ContentPackageAssembler( item );
if ( !asm.hasErrors() ) {
return null;
} else {
result.lines = generateBuilderResults( asm );
}
}
} catch ( Exception e ) {
log.error( e );
result = new BuilderResult();
BuilderResultLine res = new BuilderResultLine();
res.assetName = asset.metaData.name;
res.assetFormat = asset.metaData.format;
res.message = "Unable to validate this asset. (Check log for detailed messages).";