if (Contexts.isSessionContextActive()) {
boolean passed = false;
try {
Identity.instance().checkPermission(
new PackageUUIDType(asset.getPackage().getUUID()),
RoleTypes.PACKAGE_DEVELOPER);
} catch (RuntimeException e) {
if (asset.getCategories().size() == 0) {
Identity.instance().checkPermission(
new CategoryPathType(null), RoleTypes.ANALYST);
} else {
RuntimeException exception = null;
for (CategoryItem cat : asset.getCategories()) {
try {
Identity.instance().checkPermission(
new CategoryPathType(cat.getName()),
RoleTypes.ANALYST);
passed = true;
} catch (RuntimeException re) {
exception = re;
}
}
if (!passed) {
throw exception;
}
}
}
}
log.info("USER:" + getCurrentUserName()
+ " CHANGING ASSET STATUS. Asset name, uuid: " + "["
+ asset.getName() + ", " + asset.getUUID() + "]" + " to ["
+ newState + "]");
String oldState = asset.getStateDescription();
asset.updateState(newState);
push("statusChange", oldState);
push("statusChange", newState);
addToDiscussionForAsset(asset.getUUID(), oldState + " -> "
+ newState);
} else {
if ( Contexts.isSessionContextActive() ) {
Identity.instance().checkPermission( new PackageUUIDType( uuid ),
RoleTypes.PACKAGE_DEVELOPER );
}
PackageItem pkg = repository.loadPackageByUUID( uuid );
log.info( "USER:" + getCurrentUserName() + " CHANGING Package STATUS. Asset name, uuid: " + "[" + pkg.getName() + ", " + pkg.getUUID() + "]" + " to [" + newState + "]" );