if (bundleData == null) { data = (AbstractBundleData) getElementFactory().createBundleData(AbstractFrameworkAdaptor.this, id); } else { data = bundleData; }
data = (AbstractBundleData) getElementFactory().createBundleData(AbstractFrameworkAdaptor.this, id);
			public org.eclipse.osgi.framework.adaptor.BundleData begin() throws BundleException {				long id;				try {					/*					 * Open InputStream first to trigger prereq installs, if any,					 * before allocating bundle id.					 */					InputStream in = source.getInputStream();					URL sourceURL = source.getURL();					String protocol = sourceURL == null ? null : sourceURL.getProtocol();					try {						try {							id = getNextBundleId();						} catch (IOException e) {							throw new BundleException(AdaptorMsg.formatter.getString("ADAPTOR_STORAGE_EXCEPTION"), e); //$NON-NLS-1$						}						if (bundleData == null) {							data = (AbstractBundleData) getElementFactory().createBundleData(AbstractFrameworkAdaptor.this, id);						} else {							data = bundleData;						}						data.setLastModified(System.currentTimeMillis());						data.setLocation(location);						data.setStartLevel(getInitialBundleStartLevel());						if (in instanceof ReferenceInputStream) {							URL reference = ((ReferenceInputStream) in).getReference();							if (!"file".equals(reference.getProtocol())) { //$NON-NLS-1$								throw new BundleException(AdaptorMsg.formatter.getString("ADAPTOR_URL_CREATE_EXCEPTION", reference)); //$NON-NLS-1$							}							data.setReference(true);							data.setFileName(reference.getPath());							data.initializeNewBundle();						} else {							File genDir = data.createGenerationDir();							if (!genDir.exists()) {								throw new IOException(AdaptorMsg.formatter.getString("ADAPTOR_DIRECTORY_CREATE_EXCEPTION", genDir.getPath())); //$NON-NLS-1$							}							String fileName = mapLocationToName(location);							File outFile = new File(genDir, fileName);							if ("file".equals(protocol)) { //$NON-NLS-1$								File inFile = new File(source.getURL().getPath());								if (inFile.isDirectory()) {									copyDir(inFile, outFile);								} else {									readFile(in, outFile);								}							} else {								readFile(in, outFile);							}							data.setReference(false);							data.setFileName(fileName);							data.initializeNewBundle();						}					} finally {						try {							in.close();						} catch (IOException e) {						}					}				} catch (IOException ioe) {					throw new BundleException(AdaptorMsg.formatter.getString("BUNDLE_READ_EXCEPTION"), ioe); //$NON-NLS-1$				}				return (data);			}