private String getHomeFolderPrefix() { final String homeFolderPath = _homeFolder.getQualifiedPath(); if ("/".equals(homeFolderPath)) { return homeFolderPath; } return homeFolderPath + "/"; }
@RequestMapping(method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) @ResponseBody @RolesAllowed(SecurityRoles.ADMIN) public String uploadRepository(@PathVariable("tenant") final String tenant, @RequestParam("file") final MultipartFile file) throws IOException { final TenantContext context = _tenantContextFactory.getContext(tenant); final RepositoryFolder rootFolder = context.getTenantRootFolder(); if (file.getSize() == 0){ return "Failure. The file is empty"; } final String contentType = file.getContentType().trim(); if ((!contentType.equals("application/zip")) && (!contentType.equals("application/octet-stream"))) { return "Failure. The file isn't a .zip archive"; } logger.info("Uploading ZIP file for tenant repository: {}", tenant); try (final InputStream inputStream = file.getInputStream()) { final ZipInputStream zipInputStream = new ZipInputStream(inputStream); if (isValidRepository(zipInputStream)) { final File oldRepositoryZipFile = createZipfolder(rootFolder); decompress(zipInputStream, rootFolder); return "Success.\nNew repository path: " + rootFolder.getQualifiedPath() + ".\nOld repository backed up to: " + oldRepositoryZipFile.toString(); } else { return "Failure. The repository does not contain a conf.xml file"; } } }
/** * {@inheritDoc} * * This implementation of the method can be used as a reference. It uses the * parent's qualified path and appends '/' and this node's own name to it. * Can also be overridden by subclasses in case a more effective way is * possible. */ @Override public String getQualifiedPath() { final RepositoryFolder parent = getParent(); if (parent == null || parent instanceof Repository) { return '/' + getName(); } return parent.getQualifiedPath() + '/' + getName(); }
public static void main(final String[] args) { final DCModuleImpl module = new DCModuleImpl(DataCleanerHome.get()); final DataCleanerConfiguration configuration = Guice.createInjector(module).getInstance(DataCleanerConfiguration.class); final ComponentReferenceDocumentationBuilder docBuilder = new ComponentReferenceDocumentationBuilder(configuration.getEnvironment().getDescriptorProvider()); final RepositoryFolder folder = configuration.getHomeFolder().toRepositoryFolder().getOrCreateFolder("documentation"); // clean up the directory final List<RepositoryFile> htmlFiles = folder.getFiles(null, ".html"); for (final RepositoryFile file : htmlFiles) { file.delete(); } docBuilder.writeDocumentationToRepositoryFolder(folder); System.out.println("Documentation written to: " + folder.getQualifiedPath()); } }