@Restrict("#{identity.loggedIn}")
public String importClassicDRL(InputStream drlStream,
String packageName) throws IOException,
DroolsParserException {
ClassicDRLImporter imp = new ClassicDRLImporter( drlStream );
PackageItem pkg = null;
if ( packageName == null ) {
packageName = imp.getPackageName();
}
if ( packageName == null || "".equals( packageName ) ) {
throw new IllegalArgumentException( "Missing package name." );
}
boolean existing = repository.containsPackage( packageName );
// Check if the package is archived
if ( existing && repository.isPackageArchived( packageName ) ) {
// Remove the package so it can be created again.
PackageItem item = repository.loadPackage( packageName );
item.remove();
existing = false;
}
if ( existing ) {
pkg = repository.loadPackage( packageName );