protected void doExecute(DeploymentSessionImpl session) throws Exception {
// Allow proper rollback in case the drop fails...
addRollback(new RollbackCommitAction(session));
AbstractDeploymentPackage source = session.getSourceAbstractDeploymentPackage();
BundleContext context = session.getBundleContext();
Map expectedResources = new HashMap();
AbstractInfo[] resourceInfos = (AbstractInfo[]) source.getResourceInfos();
for (int i = 0; i < resourceInfos.length; i++) {
AbstractInfo resourceInfo = resourceInfos[i];
if (!resourceInfo.isMissing()) {
expectedResources.put(resourceInfo.getPath(), resourceInfo);
}
}
try {
while (!expectedResources.isEmpty()) {
AbstractInfo jarEntry = source.getNextEntry();
if (jarEntry == null) {
throw new DeploymentException(CODE_OTHER_ERROR, "Expected more resources in the stream: " + expectedResources.keySet());
}
String name = jarEntry.getPath();
ResourceInfoImpl resourceInfo = (ResourceInfoImpl) expectedResources.remove(name);
if (resourceInfo == null) {
throw new DeploymentException(CODE_OTHER_ERROR, "Resource '" + name + "' is not described in the manifest.");
}
ServiceReference ref = source.getResourceProcessor(name);
if (ref == null) {
throw new DeploymentException(CODE_PROCESSOR_NOT_FOUND, "No resource processor for resource: '" + name + "'");
}
if (!isValidCustomizer(session, ref)) {
throw new DeploymentException(CODE_FOREIGN_CUSTOMIZER, "Resource processor for resource '" + name + "' belongs to foreign deployment package");
}
ResourceProcessor resourceProcessor = (ResourceProcessor) context.getService(ref);
if (resourceProcessor == null) {
throw new DeploymentException(CODE_PROCESSOR_NOT_FOUND, "No resource processor for resource: '" + name + "'");
}
try {
if (m_commitCommand.addResourceProcessor(resourceProcessor)) {
resourceProcessor.begin(session);
}
resourceProcessor.process(name, source.getCurrentEntryStream());
}
catch (ResourceProcessorException rpe) {
if (rpe.getCode() == ResourceProcessorException.CODE_RESOURCE_SHARING_VIOLATION) {
throw new DeploymentException(CODE_RESOURCE_SHARING_VIOLATION, "Sharing violation while processing resource '" + name + "'", rpe);
}