List of usage examples for java.nio.file Files copy
public static long copy(Path source, OutputStream out) throws IOException
From source file:de.blizzy.backup.restore.RestoreDialog.java
private void restoreEntry(Entry entry, File parentFolder, String outputFolder, int backupId, IProgressMonitor monitor, Shell shell) throws IOException, InterruptedException { if (monitor.isCanceled()) { throw new InterruptedException(); }/*from w w w .j a v a 2 s.c om*/ boolean isFolder = entry.type == EntryType.FOLDER; if (entry.type == EntryType.FAILED_FILE) { if (alwaysRestoreFromOlderBackups == null) { alwaysRestoreFromOlderBackups = Boolean.valueOf(promptRestoreFromOlderBackups(shell)); } if (alwaysRestoreFromOlderBackups.booleanValue()) { entry = findInOlderBackups(entry); } } if ((entry != null) && (entry.type != EntryType.FAILED_FILE)) { Path outputPath; if (entry.type == EntryType.FOLDER) { File newFolder = new File(parentFolder, escapeFileName(entry.name)); FileUtils.forceMkdir(newFolder); Cursor<Record> cursor = getEntriesCursor(backupId, entry.id, null, -1); try { for (Entry e : getEntries(cursor, false)) { restoreEntry(e, newFolder, outputFolder, backupId, monitor, shell); } } finally { database.closeQuietly(cursor); } outputPath = newFolder.toPath(); } else { File inputFile = Utils.toBackupFile(entry.backupPath, outputFolder); File outputFile = new File(parentFolder, escapeFileName(entry.name)); outputPath = outputFile.toPath(); InputStream in = null; try { InputStream fileIn = new BufferedInputStream(new FileInputStream(inputFile)); InputStream interceptIn = fileIn; for (IStorageInterceptor interceptor : storageInterceptors) { interceptIn = interceptor.interceptInputStream(interceptIn, entry.length); } InputStream compressIn = entry.compression.getInputStream(interceptIn); in = compressIn; Files.copy(in, outputPath); } finally { IOUtils.closeQuietly(in); } } FileAttributes fileAttributes = FileAttributes.get(outputPath); if (entry.hidden) { fileAttributes.setHidden(entry.hidden); } FileTime createTime = (entry.creationTime != null) ? FileTime.fromMillis(entry.creationTime.getTime()) : null; FileTime modTime = (entry.modificationTime != null) ? FileTime.fromMillis(entry.modificationTime.getTime()) : null; fileAttributes.setTimes(createTime, modTime); } if (!isFolder) { monitor.worked(1); } }
From source file:io.personium.core.model.impl.fs.DavCmpFsImplTest.java
/** * Test get()./* ww w . j a va 2s .c o m*/ * normal. * Range specification. * DavEncryptEnabled is true. * @throws Exception Unintended exception in test */ @Test public void get_Normal_range_encrypt_true() throws Exception { String contentPath = TEST_DIR_PATH + CONTENT_FILE; InputStream inputStream = null; File contentFile = new File(contentPath); try { inputStream = getSystemResourceAsStream("davFile/encrypt01.txt"); Files.copy(inputStream, contentFile.toPath()); // -------------------- // Test method args // -------------------- String rangeHeaderField = "bytes=10-40"; // -------------------- // Mock settings // -------------------- davCmpFsImpl = PowerMockito.spy(DavCmpFsImpl.create("", null)); Whitebox.setInternalState(davCmpFsImpl, "fsPath", TEST_DIR_PATH); doReturn("text/plain").when(davCmpFsImpl).getContentType(); doReturn(98L).when(davCmpFsImpl).getContentLength(); doReturn(DataCryptor.ENCRYPTION_TYPE_AES).when(davCmpFsImpl).getEncryptionType(); DataCryptor.setKeyString(AES_KEY); doReturn(CELL_ID).when(davCmpFsImpl).getCellId(); doReturn("\"1-1487652733383\"").when(davCmpFsImpl).getEtag(); // -------------------- // Expected result // -------------------- String sourceFileMD5 = md5Hex(getSystemResourceAsStream("davFile/range01.txt")); ResponseBuilder expected = Response.status(HttpStatus.SC_PARTIAL_CONTENT) .header(PersoniumCoreUtils.HttpHeaders.CONTENT_RANGE, "bytes 10-40/98") .header(HttpHeaders.CONTENT_LENGTH, 31L).header(HttpHeaders.CONTENT_TYPE, "text/plain") .header(ETAG, "\"1-1487652733383\"") .header(PersoniumCoreUtils.HttpHeaders.ACCEPT_RANGES, RangeHeaderHandler.BYTES_UNIT); // -------------------- // Run method // -------------------- ResponseBuilder actual = davCmpFsImpl.get(rangeHeaderField); // -------------------- // Confirm result // -------------------- assertThat(actual.build().getStatus(), is(expected.build().getStatus())); assertThat(actual.build().getMetadata().toString(), is(expected.build().getMetadata().toString())); StreamingOutputForDavFile entity = (StreamingOutputForDavFile) actual.build().getEntity(); ByteArrayOutputStream output = new ByteArrayOutputStream(); entity.write(output); assertThat(md5Hex(output.toByteArray()), is(sourceFileMD5)); } finally { if (inputStream != null) { inputStream.close(); } contentFile.delete(); } }
From source file:org.testeditor.fixture.swt.SwtBotFixture.java
/** * Cleans the Workspace of the AUT and creates a demo Project. * /* www . j a v a2 s . c om*/ * @throws IOException * on reset the workspace. * @throws URISyntaxException * on reset the workspace. */ private void prepareAUTWorkspace() throws IOException, URISyntaxException { File wsPathFile = new File(getWorkspacePath()); Path wsPath = wsPathFile.toPath(); if (wsPathFile.exists()) { Files.walkFileTree(wsPath, getDeleteFileVisitor()); LOGGER.info("Removed AUT_WS: " + getWorkspacePath()); } Files.createDirectory(wsPath); Map<String, String> env = new HashMap<String, String>(); env.put("create", "true"); FileSystem fs = FileSystems.newFileSystem(getClass().getResource("/DemoWebTests.zip").toURI(), env); Iterable<Path> rootDirectories = fs.getRootDirectories(); for (Path root : rootDirectories) { DirectoryStream<Path> directoryStream = Files.newDirectoryStream(root); for (Path path : directoryStream) { if (path.getFileName().startsWith("DemoWebTests.zip")) { LOGGER.info("Found DemoWebTest."); Files.copy(path, Paths.get(wsPath.toString(), "DemoWebTests.zip")); URI uriDemoZip = new URI("jar:" + Paths.get(wsPath.toString(), "/DemoWebTests.zip").toUri()); LOGGER.info(uriDemoZip); FileSystem zipFs = FileSystems.newFileSystem(uriDemoZip, env); copyFolder(zipFs.getPath("/"), Paths.get(getWorkspacePath())); zipFs.close(); } } } fs.close(); LOGGER.info("Created Demoproject in: " + getWorkspacePath()); }
From source file:lu.fisch.moenagade.model.Project.java
private void saveFiles() { if (directoryName != null) { // delete the "src" directory //IMAGES ARE INSIDE !!! deleteDirectory(new File(directoryName + System.getProperty("file.separator") + "src" + System.getProperty("file.separator"))); File fDir = new File(directoryName + System.getProperty("file.separator") + "versions"); if (!fDir.exists()) fDir.mkdir();/*from ww w.j a v a 2 s . c o m*/ fDir = new File(directoryName + System.getProperty("file.separator") + "src"); if (!fDir.exists()) fDir.mkdir(); fDir = new File(directoryName + System.getProperty("file.separator") + "src" + System.getProperty("file.separator") + "moenagade"); if (!fDir.exists()) fDir.mkdir(); fDir = new File(directoryName + System.getProperty("file.separator") + "src" + System.getProperty("file.separator") + "moenagade" + System.getProperty("file.separator") + "base"); if (!fDir.exists()) fDir.mkdir(); fDir = new File(directoryName + System.getProperty("file.separator") + "src" + System.getProperty("file.separator") + "moenagade" + System.getProperty("file.separator") + "worlds"); if (!fDir.exists()) fDir.mkdir(); fDir = new File(directoryName + System.getProperty("file.separator") + "src" + System.getProperty("file.separator") + "moenagade" + System.getProperty("file.separator") + "entities"); if (!fDir.exists()) fDir.mkdir(); fDir = new File(directoryName + System.getProperty("file.separator") + "src" + System.getProperty("file.separator") + "moenagade" + System.getProperty("file.separator") + "images"); if (!fDir.exists()) fDir.mkdir(); fDir = new File(directoryName + System.getProperty("file.separator") + "src" + System.getProperty("file.separator") + "moenagade" + System.getProperty("file.separator") + "sounds"); if (!fDir.exists()) fDir.mkdir(); fDir = new File(directoryName + System.getProperty("file.separator") + "bloxs"); if (!fDir.exists()) fDir.mkdir(); fDir = new File(directoryName + System.getProperty("file.separator") + "bloxs" + System.getProperty("file.separator") + "worlds"); if (!fDir.exists()) fDir.mkdir(); fDir = new File(directoryName + System.getProperty("file.separator") + "bloxs" + System.getProperty("file.separator") + "entities"); if (!fDir.exists()) fDir.mkdir(); fDir = new File(directoryName + System.getProperty("file.separator") + "bloxs" + System.getProperty("file.separator") + "images"); if (!fDir.exists()) fDir.mkdir(); fDir = new File(directoryName + System.getProperty("file.separator") + "bloxs" + System.getProperty("file.separator") + "sounds"); if (!fDir.exists()) fDir.mkdir(); // save all bloxs files to the bloxs directory try { main.saveToFile(directoryName + System.getProperty("file.separator") + "bloxs"); } catch (IOException ex) { JOptionPane.showMessageDialog(frame, "Error while saving entitiy '" + main.getName() + "'!\n" + ex.getMessage() + "\n", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); ex.printStackTrace(); } for (Entity entity : getEntities().values()) { try { entity.saveToFile(directoryName + System.getProperty("file.separator") + "bloxs" + System.getProperty("file.separator") + "entities"); } catch (IOException ex) { JOptionPane.showMessageDialog(frame, "Error while saving entitiy '" + entity.getName() + "'!\n" + ex.getMessage() + "\n", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); ex.printStackTrace(); } } for (World world : getWorlds().values()) { try { world.saveToFile(directoryName + System.getProperty("file.separator") + "bloxs" + System.getProperty("file.separator") + "worlds"); } catch (IOException ex) { JOptionPane.showMessageDialog(frame, "Error while saving world '" + world.getName() + "'!\n" + ex.getMessage() + "\n", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); ex.printStackTrace(); } } // copy images File imageDir = new File(getImageDirectory()); File[] files = imageDir.listFiles(); if (files != null) for (int i = 0; i < files.length; i++) { File file = files[i]; String extension = getExtension(file); //System.out.println(file.getName()); if (extension != null) { if (extension.equals("png") || extension.equals("jpg") || extension.equals("jpeg")) { File dest = new File(directoryName + System.getProperty("file.separator") + "src" + System.getProperty("file.separator") + "moenagade" + System.getProperty("file.separator") + "images" + System.getProperty("file.separator") + file.getName()); try { Files.copy(file.toPath(), dest.toPath()); } catch (IOException ex) { JOptionPane.showMessageDialog( frame, "Error while copying image '" + file.getName() + "'!\n" + ex.getMessage() + "\n", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); ex.printStackTrace(); } } } } // copy sounds File soundDir = new File(getSoundDirectory()); files = soundDir.listFiles(); if (files != null) for (int i = 0; i < files.length; i++) { File file = files[i]; String extension = getExtension(file); //System.out.println(file.getName()); if (extension != null) { if (extension.equals("wav")) { File dest = new File(directoryName + System.getProperty("file.separator") + "src" + System.getProperty("file.separator") + "moenagade" + System.getProperty("file.separator") + "sounds" + System.getProperty("file.separator") + file.getName()); try { Files.copy(file.toPath(), dest.toPath()); } catch (IOException ex) { // windows may still block the original ressource, so this can be ignored! // the media player seams not to always free well the ressources /*JOptionPane.showMessageDialog(frame, "Error while copying sound '"+file.getName()+"'!\n"+ ex.getMessage()+"\n","Error", JOptionPane.ERROR_MESSAGE,Moenagade.IMG_ERROR); /**/ ex.printStackTrace(); } } } } // create backups createBackupOf("src"); createBackupOf("bloxs"); // generate the java code for each bloxs files // and store it into the src folder // put game related classes there as well generateSource(); } }
From source file:debrepo.teamcity.web.DebDownloadController.java
private ModelAndView servePackage(HttpServletRequest request, HttpServletResponse response, File packagefile) throws IOException { if (!packagefile.canRead()) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; }/*from w ww . j av a 2 s . c o m*/ response.setContentType("application/octect-stream"); OutputStream os = null; try { os = response.getOutputStream(); Files.copy(packagefile.toPath(), os); os.flush(); Loggers.SERVER.info("DebDownloadController:: Returning 200 : Debian Package exists with the name: " + request.getPathInfo()); } catch (IOException e) { Loggers.SERVER.debug(e); } finally { if (os != null) { os.close(); } } return null; }
From source file:de.dal33t.powerfolder.Controller.java
/** * Saves the current config to disk//w ww. ja va 2s .c om */ public synchronized void saveConfig() { if (!started) { return; } logFine("Saving config (" + getConfigName() + ".config)"); Path file; Path tempFile; Path folderFile; Path tempFolderFile; Path backupFile; if (getConfigLocationBase() == null) { file = Paths.get(getConfigName() + ".config").toAbsolutePath(); tempFile = Paths.get(getConfigName() + ".writing.config").toAbsolutePath(); folderFile = Paths.get(getConfigName() + "-Folder.config").toAbsolutePath(); tempFolderFile = Paths.get(getConfigName() + "-Folder.writing.config").toAbsolutePath(); backupFile = Paths.get(getConfigName() + ".config.backup").toAbsolutePath(); } else { file = getConfigLocationBase().resolve(getConfigName() + ".config"); tempFile = getConfigLocationBase().resolve(getConfigName() + ".writing.config").toAbsolutePath(); backupFile = getConfigLocationBase().resolve(getConfigName() + ".config.backup"); folderFile = getConfigLocationBase().resolve(getConfigName() + "-Folder.config"); tempFolderFile = getConfigLocationBase().resolve(getConfigName() + "-Folder.writing.config") .toAbsolutePath(); } try { // Backup is done in #backupConfigAssets Files.deleteIfExists(backupFile); String distName = "PowerFolder"; if (distribution != null && StringUtils.isNotBlank(distribution.getName())) { distName = distribution.getName(); } Properties prev = new Properties(); if (Files.exists(file)) { try (BufferedInputStream in = new BufferedInputStream(Files.newInputStream(file))) { prev.load(in); } } if (!prev.equals(config.getRegular())) { // Store config in misc base PropertiesUtil.saveConfig(tempFile, config.getRegular(), distName + " config file (v" + PROGRAM_VERSION + ')'); Files.deleteIfExists(file); try { Files.move(tempFile, file); } catch (IOException e) { Files.copy(tempFile, file); Files.delete(tempFile); } } else { if (isFine()) { logFine("Not storing config to " + file + ". Base config remains unchanged"); } } if (!config.getFolders().isEmpty()) { Properties prevFolders = new Properties(); if (Files.exists(folderFile)) { try (BufferedInputStream in = new BufferedInputStream(Files.newInputStream(folderFile))) { prevFolders.load(in); } } if (!prevFolders.equals(config.getFolders())) { PropertiesUtil.saveConfig(tempFolderFile, config.getFolders(), distName + " folders config file (v" + PROGRAM_VERSION + ')'); Files.deleteIfExists(folderFile); try { Files.move(tempFolderFile, folderFile); } catch (IOException e) { Files.copy(tempFolderFile, folderFile); Files.delete(tempFolderFile); } } } } catch (IOException e) { // FATAL logSevere("Unable to save config. " + e, e); exit(1); } catch (Exception e) { // major problem , setting code is wrong e.printStackTrace(); logSevere("major problem , setting code is wrong", e); } }
From source file:edu.umass.cs.reconfiguration.SQLReconfiguratorDB.java
/** * @param finalStates/* ww w.ja va2s.c o m*/ * @param mergerGroup * @param mergerGroupEpoch * @return Merged checkpoint filename. */ public String fetchAndAggregateMergeeStates(Map<String, String> finalStates, String mergerGroup, int mergerGroupEpoch) { String mergerGroupCheckpointFile = this.getCheckpointFileNoTimestamp(mergerGroup + ":" + mergerGroupEpoch); for (String mergee : finalStates.keySet()) { // mergee is name:epoch format new File(this.getCheckpointFileNoTimestamp(mergee)).getParentFile().mkdirs(); LargeCheckpointer.restoreCheckpointHandle(finalStates.get(mergee), this.getCheckpointFileNoTimestamp(mergee)); } // all checkpoints collected above try { // create empty file for merging checkpoints if (this.createCheckpointFile(mergerGroupCheckpointFile)) Util.wipeoutFile(mergerGroupCheckpointFile); } catch (IOException ioe) { log.severe(this + " unable to create empty file " + mergerGroupCheckpointFile + " for merging mergee final state checkpoints "); ioe.printStackTrace(); return null; } assert (new File(mergerGroupCheckpointFile).exists() && new File(mergerGroupCheckpointFile).length() == 0); FileOutputStream fos = null; try { fos = new FileOutputStream(mergerGroupCheckpointFile); // merge each mergeeCheckpointFile into mergerGroupCheckpointFile long totalSize = 0; for (String mergee : finalStates.keySet()) { String mergeeCheckpointFile = this.getCheckpointFileNoTimestamp(mergee); totalSize += new File(mergeeCheckpointFile).length(); Files.copy(Paths.get(mergeeCheckpointFile), fos); } // sanity check and cleanup assert (totalSize == new File(mergerGroupCheckpointFile).length()); if (totalSize != new File(mergerGroupCheckpointFile).length()) log.severe(this + " expecting size " + totalSize + " B for merged final states but found " + new File(mergerGroupCheckpointFile).length() + " B"); else // clean up mergee file states for (String mergee : finalStates.keySet()) new File(this.getCheckpointFileNoTimestamp(mergee)).delete(); return mergerGroupCheckpointFile; } catch (IOException e) { log.severe(this + " unable to merge mergee files"); e.printStackTrace(); } finally { cleanup(fos); } return null; }
From source file:io.minio.MinioClient.java
/** * Gets object's data in the given bucket and stores it to given file name. * * </p><b>Example:</b><br> * <pre>{@code minioClient.getObject("my-bucketname", "my-objectname", "photo.jpg"); }</pre> * * @param bucketName Bucket name.// w w w .j av a 2s .c om * @param objectName Object name in the bucket. * @param fileName file name. * * @throws InvalidBucketNameException upon invalid bucket name is given * @throws NoResponseException upon no response from server * @throws IOException upon connection error * @throws XmlPullParserException upon parsing response xml * @throws ErrorResponseException upon unsuccessful execution * @throws InternalException upon internal library error */ public void getObject(String bucketName, String objectName, String fileName) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException, InternalException, InvalidArgumentException { Path filePath = Paths.get(fileName); boolean fileExists = Files.exists(filePath); if (fileExists && !Files.isRegularFile(filePath)) { throw new InvalidArgumentException(fileName + ": not a regular file"); } ObjectStat objectStat = statObject(bucketName, objectName); long length = objectStat.length(); String etag = objectStat.etag(); String tempFileName = fileName + "." + etag + ".part.minio"; Path tempFilePath = Paths.get(tempFileName); boolean tempFileExists = Files.exists(tempFilePath); if (tempFileExists && !Files.isRegularFile(tempFilePath)) { throw new IOException(tempFileName + ": not a regular file"); } long tempFileSize = 0; if (tempFileExists) { tempFileSize = Files.size(tempFilePath); if (tempFileSize > length) { Files.delete(tempFilePath); tempFileExists = false; tempFileSize = 0; } } if (fileExists) { long fileSize = Files.size(filePath); if (fileSize == length) { // already downloaded. nothing to do return; } else if (fileSize > length) { throw new InvalidArgumentException( "'" + fileName + "': object size " + length + " is smaller than file size " + fileSize); } else if (!tempFileExists) { // before resuming the download, copy filename to tempfilename Files.copy(filePath, tempFilePath); tempFileSize = fileSize; tempFileExists = true; } } InputStream is = null; OutputStream os = null; try { is = getObject(bucketName, objectName, tempFileSize); os = Files.newOutputStream(tempFilePath, StandardOpenOption.CREATE, StandardOpenOption.APPEND); long bytesWritten = ByteStreams.copy(is, os); is.close(); os.close(); if (bytesWritten != length - tempFileSize) { throw new IOException(tempFileName + ": unexpected data written. expected = " + (length - tempFileSize) + ", written = " + bytesWritten); } Files.move(tempFilePath, filePath, StandardCopyOption.REPLACE_EXISTING); } finally { if (is != null) { is.close(); } if (os != null) { os.close(); } } }
From source file:Main.Interface_Main.java
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed System.out.print(serialData); //Create a file chooser final JFileChooser fc = new JFileChooser(); FileFilter ft = new FileNameExtensionFilter("Comma Seperated Value (*.csv)", "csv"); fc.setFileFilter(ft);//from w w w . j a v a 2 s .c o m //In response to a button click: int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); System.out.println(file); try { /*BufferedWriter writer = null; writer = new BufferedWriter(new FileWriter(file + ".csv")); //add .txt? writer.write("time, amp, max, min, volt, max, min, wattage, mah, mwh, dp, dm"); writer.newLine(); for (int i = 0; i < csvData.size(); i++){ //String serialStringData = csvData.toString(); writer.write(csvData.get(i).toString()); writer.newLine(); } writer.close( ); */ File sFile = new File(logTmpFile); Files.copy(sFile.toPath(), file.toPath()); JOptionPane.showMessageDialog(this, "Data exported successfully!", "Success!", JOptionPane.INFORMATION_MESSAGE); } catch (java.io.IOException e) { JOptionPane.showMessageDialog(this, e); } } else { System.out.println("Save Canceled"); } }
From source file:ddf.test.itests.catalog.TestCatalog.java
@Test public void testMetacardDefinitionJsonFile() throws Exception { getServiceManager().startFeature(true, "catalog-core-validator"); Path definitionsDir = Paths.get(System.getProperty("ddf.home"), "etc/definitions"); definitionsDir = Files.createDirectories(definitionsDir); definitionsDir.toFile().deleteOnExit(); Path tmpFile = definitionsDir.resolve("definitions.json"); tmpFile.toFile().deleteOnExit();/* w w w. j av a2s . c o m*/ Files.copy(getClass().getClassLoader().getResourceAsStream("definitions.json"), tmpFile); expect("Service to be available: " + MetacardType.class.getName()).within(10, TimeUnit.SECONDS).until( () -> getServiceManager().getServiceReferences(MetacardType.class, "(name=new.metacard.type)"), not(empty())); String ddfMetacardXml = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("metacard1.xml"), UTF_8.name()); String modifiedMetacardXml = ddfMetacardXml.replaceFirst("ddf\\.metacard", "new.metacard.type") .replaceFirst("resource-uri", "new-attribute-required-2"); String id = ingest(modifiedMetacardXml, "text/xml"); configureShowInvalidMetacards("true"); try { String newMetacardXpath = String.format("/metacards/metacard[@id=\"%s\"]", id); executeOpenSearch("xml", "q=*").log().all().assertThat().body(hasXPath(newMetacardXpath)) .body(hasXPath(newMetacardXpath + "/type", is("new.metacard.type"))) .body(hasXPath("count(" + newMetacardXpath + "/string[@name=\"validation-errors\"]/value)", is("2"))) .body(hasXPath(newMetacardXpath + "/string[@name=\"validation-errors\"]/value[text()=\"point-of-contact is required\"]")) .body(hasXPath(newMetacardXpath + "/string[@name=\"validation-errors\"]/value[text()=\"new-attribute-required-1 is required\"]")) .body(hasXPath(newMetacardXpath + "/string[@name=\"new-attribute-required-2\"]/value", is("\" + uri + \""))); } finally { deleteMetacard(id); getServiceManager().stopFeature(true, "catalog-core-validator"); configureShowInvalidMetacards("false"); } }