/** * Computes the bundle path from the bundle * * @param bundle * @return */ protected String computeBundlePath(final ImportSource.IRepositoryFileBundle bundle) { String bundlePath = bundle.getPath(); bundlePath = RepositoryFilenameUtils.separatorsToRepository(bundlePath); if (bundlePath.startsWith(RepositoryFile.SEPARATOR)) { bundlePath = bundlePath.substring(1); } return bundlePath; }
protected void initialize() { try { ZipEntry entry = zipInputStream.getNextEntry(); while (entry != null) { final String entryName = RepositoryFilenameUtils.separatorsToRepository(entry.getName()); File tempFile = null; boolean isDir = entry.isDirectory(); if (!isDir) { if (!solutionHelper.isInApprovedExtensionList(entryName)) { zipInputStream.closeEntry(); entry = zipInputStream.getNextEntry(); continue; } tempFile = File.createTempFile("zip", null); tempFile.deleteOnExit(); FileOutputStream fos = new FileOutputStream(tempFile); IOUtils.copy(zipInputStream, fos); fos.close(); } File file = new File(entryName); RepositoryFile repoFile = new RepositoryFile.Builder(file.getName()).folder(isDir).hidden(false).build(); String parentDir = new File(entryName).getParent() == null ? RepositoryFile.SEPARATOR : new File(entryName).getParent() + RepositoryFile.SEPARATOR; IRepositoryFileBundle repoFileBundle = new RepositoryFileBundle(repoFile, null, parentDir, tempFile, "UTF-8", null); if (file.getName().equals("exportManifest.xml")) { initializeAclManifest(repoFileBundle); } else { files.add(repoFileBundle); } zipInputStream.closeEntry(); entry = zipInputStream.getNextEntry(); } zipInputStream.close(); } catch (IOException exception) { final String errorMessage = Messages.getInstance().getErrorString("", exception.getLocalizedMessage()); log.trace(errorMessage); } }