Java Code Examples for org.openide.filesystems.FileObject#copy()
The following examples show how to use
org.openide.filesystems.FileObject#copy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertiesFileEntry.java From netbeans with Apache License 2.0 | 6 votes |
/** Copies entry to folder. Overrides superclass method. * @param folder folder where copy * @param suffix suffix to use * @exception IOException when error happens */ @Override public FileObject copy(FileObject folder, String suffix) throws IOException { if (LOG.isLoggable(FINER)) { LOG.finer("copy(" //NOI18N + FileUtil.getFileDisplayName(folder) + ", " //NOI18N + (suffix != null ? '"' + suffix + '"' : "<null>")//NOI18N + ')'); } String pasteSuffix = ((PropertiesDataObject)getDataObject()).getPasteSuffix(); if(pasteSuffix == null) return super.copy(folder, suffix); FileObject fileObject = getFile(); String basicName = getDataObject().getPrimaryFile().getName(); String newName = basicName + pasteSuffix + Util.getLocaleSuffix(this); return fileObject.copy(folder, newName, fileObject.getExt()); }
Example 2
Source File: VCSInterceptorTestCase.java From netbeans with Apache License 2.0 | 6 votes |
public void testFolderTreeCopied() throws IOException { inteceptor.copyHandler = copyHandler; FileObject fo = getVersionedFolder(); FileObject fromFolder = fo.createFolder("fromFolder"); FileObject movedChild = fromFolder.createData("copiedChild"); FileObject targetFolder = fo.createFolder("targetFolder"); VCSFileProxy fromProxy = VCSFileProxy.createFileProxy(fromFolder); logHandler.clear(); logHandler.ignoredMessages.add(createdExternalyFormat); // XXX FileObject toFolder = fromFolder.copy(targetFolder, "copy", null); VCSFileProxy toProxy = VCSFileProxy.createFileProxy(toFolder); assertTrue(inteceptor.getBeforeCopyFiles().contains(fromProxy)); assertTrue(inteceptor.getBeforeCopyFiles().contains(toProxy)); assertTrue(inteceptor.getDoCopyFiles().contains(fromProxy)); assertTrue(inteceptor.getDoCopyFiles().contains(toProxy)); assertTrue(inteceptor.getAfterCopyFiles().contains(fromProxy)); assertTrue(inteceptor.getAfterCopyFiles().contains(toProxy)); assertInterceptedCalls( f(getCopyHandlerFormat, fromProxy, toProxy), f(copyHandleFormat, fromProxy, toProxy), f(copySuccessFormat, fromProxy, toProxy) ); }
Example 3
Source File: VCSInterceptorTestCase.java From netbeans with Apache License 2.0 | 6 votes |
public void testFileCopied() throws IOException { inteceptor.copyHandler = copyHandler; FileObject fo = getVersionedFolder(); fo = fo.createData("copyme.txt"); logHandler.clear(); logHandler.ignoredMessages.add(createdExternalyFormat); // XXX FileObject fto = fo.copy(fo.getParent(), "copymeto", "txt"); VCSFileProxy fromProxy = VCSFileProxy.createFileProxy(fo); VCSFileProxy toProxy = VCSFileProxy.createFileProxy(fto); assertTrue(inteceptor.getBeforeCopyFiles().contains(fromProxy)); assertTrue(inteceptor.getBeforeCopyFiles().contains(toProxy)); assertTrue(inteceptor.getDoCopyFiles().contains(fromProxy)); assertTrue(inteceptor.getDoCopyFiles().contains(toProxy)); assertTrue(inteceptor.getAfterCopyFiles().contains(fromProxy)); assertTrue(inteceptor.getAfterCopyFiles().contains(toProxy)); assertInterceptedCalls( // f(fileLockedFormat, fromProxy); // XXX no lock before copy ??? f(getCopyHandlerFormat, fromProxy, toProxy), f(copyHandleFormat, fromProxy, toProxy), f(copySuccessFormat, fromProxy, toProxy) // XXX and this doesnt invoke createdExternaly but move does? ); }
Example 4
Source File: BaseModelTest.java From jeddict with Apache License 2.0 | 6 votes |
protected void reverseEngineeringTest(String... classes) { try { ProjectBuilder projectBuilder = new ProjectBuilder("reverse-engineering-test"); FileObject src = projectBuilder.getSrc(); EntityMappings entityMappings = createEntityMappings(); String packageName = this.getClass().getPackage().getName(); Set<String> classFqns = new HashSet<>(); for (String clazz : classes) { FileObject classPackage = getFileObject(src, packageName, "\\."); classFqns.add(packageName + '.' + clazz); File classFile = Utilities.toFile(this.getClass().getResource(clazz + JAVA_EXT_SUFFIX).toURI()); FileObject classFileObject = FileUtil.toFileObject(classFile); classFileObject.copy(classPackage, clazz, JAVA_EXT); } ClassWizardDescriptor descriptor = new ClassWizardDescriptor(); descriptor.loadSource(getProgressReporter(), entityMappings, src, classFqns, false); generateClasses(entityMappings, (String) null); } catch (Exception ex) { fail(Arrays.toString(classes) + " reverse engineering failed", ex); } }
Example 5
Source File: ProvidedExtensionsTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testCopy_BeforeSuccessFailure() throws IOException { FileObject fromFolder = FileUtil.toFileObject(getWorkDir()).createFolder("copyFrom"); FileObject toFolder = FileUtil.toFileObject(getWorkDir()).createFolder("copyTo"); assertNotNull(fromFolder); assertNotNull(toFolder); FileObject fromCopy = fromFolder.createData("aa"); assertNotNull(fromCopy); iListener.clear(); assertNotNull(iListener); assertEquals(0,iListener.beforeCopyCalls); assertEquals(0,iListener.copySuccessCalls); assertEquals(0,iListener.copyFailureCalls); // copy fromCopy.copy(toFolder, fromCopy.getName(), fromCopy.getExt()); assertTrue(fromCopy.isValid()); assertEquals(1,iListener.beforeCopyCalls); assertEquals(1,iListener.copySuccessCalls); iListener.clear(); try { // success assertEquals(0,iListener.copySuccessCalls); assertEquals(0,iListener.copyFailureCalls); // move to itself => failure fromCopy.copy(toFolder, fromCopy.getName(), fromCopy.getExt()); fail(); } catch (IOException ex) { // failure assertEquals(0,iListener.copySuccessCalls); assertEquals(1,iListener.copyFailureCalls); } }
Example 6
Source File: SaveAsAction.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
@Override protected void performAction(Node[] activatedNodes) { Node node = activatedNodes[0]; FileObject fo = node.getLookup().lookup(FileObject.class); if (fo != null) { FileChooserBuilder builder = new FileChooserBuilder(SaveAsAction.class); builder.setDirectoriesOnly(false); builder.setApproveText("Save"); builder.setControlButtonsAreShown(true); builder.setTitle("Save As..."); builder.setFilesOnly(true); builder.setFileFilter(new FileNameExtensionFilter(fo.getExt(), fo.getExt())); JFileChooser chooser = builder.createFileChooser(); chooser.setSelectedFile(new File(fo.getNameExt())); int resp = chooser.showSaveDialog(findDialogParent()); if (JFileChooser.APPROVE_OPTION == resp) { File saveFile = chooser.getSelectedFile(); if (saveFile != null) { try { saveFile.getParentFile().mkdirs(); FileObject dfo = FileUtil.toFileObject(saveFile.getParentFile()); if (dfo == null) { NotifyDescriptor nd = new NotifyDescriptor.Message("Unable to Save file!", NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notifyLater(nd); return; } if (saveFile.exists()) { saveFile.delete(); } fo.copy(dfo, saveFile.getName(), ""); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } } } }
Example 7
Source File: InterceptorTest.java From netbeans with Apache License 2.0 | 5 votes |
private void copyFO (File from, File to) throws DataObjectNotFoundException, IOException { FileObject foFrom = FileUtil.toFileObject(from); assertNotNull(foFrom); FileObject foTarget = FileUtil.toFileObject(to.getParentFile()); assertNotNull(foTarget); FileLock lock = foFrom.lock(); try { foFrom.copy(foTarget, getName(to), getExt(to)); } finally { lock.releaseLock(); } }
Example 8
Source File: HgCommandTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testDisableIBInFSEvents () throws Exception { CommandHandler handler = new CommandHandler(); Mercurial.LOG.addHandler(handler); Mercurial.LOG.setLevel(Level.ALL); File file = createFile(getWorkTreeDir(), "aaa"); commit(file); FileObject fo = FileUtil.toFileObject(file); fo.delete(); assertEquals(FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(file), null, null).get(file).getStatus()); assertFalse(handler.commandInvoked); fo.getParent().createData(file.getName()); assertNull(HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(file), null, null).get(file)); assertFalse(handler.commandInvoked); File copy = new File(file.getParentFile(), "copy"); fo.copy(fo.getParent(), copy.getName(), ""); assertEquals(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(copy), null, null).get(copy).getStatus()); assertFalse(handler.commandInvoked); File renamed = new File(file.getParentFile(), "renamed"); FileLock lock = fo.lock(); fo.move(lock, fo.getParent(), renamed.getName(), ""); lock.releaseLock(); assertEquals(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(renamed), null, null).get(renamed).getStatus()); assertEquals(FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(file), null, null).get(file).getStatus()); assertFalse(handler.commandInvoked); }
Example 9
Source File: VCSInterceptorTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testFileCopied() throws IOException { File f = new File(dataRootDir, "workdir/root-test-versioned"); FileObject fo = FileUtil.toFileObject(f); fo = fo.createData("copyme.txt"); File from = FileUtil.toFile(fo); FileObject fto = fo.copy(fo.getParent(), "copymeto", "txt"); assertTrue(inteceptor.getBeforeCopyFiles().contains(from)); assertTrue(inteceptor.getBeforeCopyFiles().contains(FileUtil.toFile(fo))); assertTrue(inteceptor.getDoCopyFiles().contains(from)); assertTrue(inteceptor.getDoCopyFiles().contains(FileUtil.toFile(fo))); assertTrue(inteceptor.getAfterCopyFiles().contains(from)); assertTrue(inteceptor.getAfterCopyFiles().contains(FileUtil.toFile(fo))); }
Example 10
Source File: FilesystemInterceptorTest.java From netbeans with Apache License 2.0 | 5 votes |
private void copyFO(File from, File to) throws DataObjectNotFoundException, IOException { FileObject foFrom = FileUtil.toFileObject(from); assertNotNull(foFrom); FileObject foTarget = FileUtil.toFileObject(to.getParentFile()); assertNotNull(foTarget); FileLock lock = foFrom.lock(); try { foFrom.copy(foTarget, getName(to), getExt(to)); } finally { lock.releaseLock(); } }
Example 11
Source File: AssetPackLoader.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public static void addAllFiles(ProjectAssetManager source, ProjectAssetManager dest, AssetConfiguration config) { Element assetElement = config.getAssetElement(); NodeList list = assetElement.getElementsByTagName("file"); try { if (dest == null) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!"); return; } } catch (Exception e) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!"); return; } for (int i = 0; i < list.getLength(); i++) { Element fileElem = (Element) list.item(i); try { String src = source.getAbsoluteAssetPath(fileElem.getAttribute("path")); if (src == null) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not find texture with manager!"); return; } FileObject srcFile = FileUtil.toFileObject(new File(src)); String destName = dest.getAssetFolderName() + "/" + fileElem.getAttribute("path"); String destFolder = destName.replace("\\", "/"); destFolder = destFolder.substring(0, destFolder.lastIndexOf("/")); FileObject folder = FileUtil.createFolder(new File(destFolder)); srcFile.copy(folder, srcFile.getName(), srcFile.getExt()); } catch (IOException ex) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not copy texture: {0}", ex.getMessage()); } } return; }
Example 12
Source File: AssetPackLoader.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private static void addVariationFiles(NodeList fileNodeList, ProjectAssetManager pm, ProjectAssetManager currentProjectAssetManager) { try { if (currentProjectAssetManager == null) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!"); return; } } catch (Exception e) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!"); return; } for (int i = 0; i < fileNodeList.getLength(); i++) { Element fileElem = (Element) fileNodeList.item(i); String type = fileElem.getAttribute("type"); try { if ("texture".equals(type) || "sound".equals(type) || "materialdef".equals(type) || "shader".equals(type) || "other".equals(type)) { String src = pm.getAbsoluteAssetPath(fileElem.getAttribute("path")); if (src == null) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not find texture with manager!"); return; } FileObject srcFile = FileUtil.toFileObject(new File(src)); String destName = currentProjectAssetManager.getAssetFolderName() + "/" + fileElem.getAttribute("path"); String destFolder = destName.replace("\\", "/"); destFolder = destFolder.substring(0, destFolder.lastIndexOf("/")); FileObject folder = FileUtil.createFolder(new File(destFolder)); srcFile.copy(folder, srcFile.getName(), srcFile.getExt()); } } catch (IOException ex) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not copy texture: {0}", ex.getMessage()); } } return; }
Example 13
Source File: WritableXMLFileSystemTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testCopyObjectAttrs() throws Exception { String someMethod = WritableXMLFileSystemTest.class.getName() + ".someMethod"; Layer l = new Layer(" <folder name=\"d\">\n <file name=\"f1\">\n <attr name=\"a\" methodvalue=\"" + someMethod + "\"/>\n </file>\n </folder>\n"); FileSystem fs = l.read(); FileObject f = fs.findResource("d/f1"); assertNotNull(f); f.copy(f.getParent(), "f2", null); assertEquals(" <folder name=\"d\">\n <file name=\"f1\">\n <attr name=\"a\" methodvalue=\"" + someMethod + "\"/>\n </file>\n <file name=\"f2\">\n <attr name=\"a\" methodvalue=\"" + someMethod + "\"/>\n </file>\n </folder>\n", l.write()); }
Example 14
Source File: UseFxTest.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { clearWorkDir(); super.setUp(); System.setProperty("sync.project.execution", "true"); // MockLookup.setLayersAndInstances(cgpi); InstalledFileLocatorImpl.registerDestDir(destDirF); ((DialogDisplayerImpl) Lookup.getDefault().lookup(DialogDisplayer.class)).reset(); DialogDisplayerImpl.returnFromNotify(DialogDescriptor.NO_OPTION); File prjDir = new File(new File(getDataDir(), "example-external-projects"), "javafx"); FileObject prj = FileUtil.toFileObject(prjDir); FileObject wrk = FileUtil.toFileObject(getWorkDir()); dir = prj.copy(wrk, "javafx", null); }
Example 15
Source File: UseHtml4JavaTest.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { clearWorkDir(); super.setUp(); System.setProperty("sync.project.execution", "true"); // MockLookup.setLayersAndInstances(cgpi); InstalledFileLocatorImpl.registerDestDir(destDirF); ((DialogDisplayerImpl) Lookup.getDefault().lookup(DialogDisplayer.class)).reset(); DialogDisplayerImpl.returnFromNotify(DialogDescriptor.NO_OPTION); File prjDir = new File(new File(getDataDir(), "example-external-projects"), "html4j"); FileObject prj = FileUtil.toFileObject(prjDir); FileObject wrk = FileUtil.toFileObject(getWorkDir()); dir = prj.copy(wrk, "html4j", null); }
Example 16
Source File: PersistenceManager.java From netbeans with Apache License 2.0 | 5 votes |
/** Copy settings file from Module Components module folder (Windows2/Components) * to Local Components folder (Windows2Local/Components). */ private void copySettingsFile (FileObject fo) throws IOException { if (DEBUG) Debug.log(PersistenceManager.class, "copySettingsFile fo:" + fo); FileObject destFolder = getComponentsLocalFolder(); try { fo.copy(destFolder,fo.getName(),fo.getExt()); } catch (IOException exc) { String annotation = NbBundle.getMessage(PersistenceManager.class, "EXC_CopyFails", destFolder); Exceptions.attachLocalizedMessage(exc, annotation); LOG.log(Level.INFO, null, exc); } }
Example 17
Source File: BaseActionProvider.java From netbeans with Apache License 2.0 | 5 votes |
private URL copyAppletHTML(FileObject file, String ext) { URL url = null; try { String buildDirProp = evaluator.getProperty("build.dir"); //NOI18N FileObject buildDir = buildDirProp != null ? updateHelper.getAntProjectHelper().resolveFileObject(buildDirProp) : null; if (buildDir == null) { buildDir = FileUtil.createFolder(project.getProjectDirectory(), buildDirProp); } FileObject htmlFile = file.getParent().getFileObject(file.getName(), "html"); //NOI18N if (htmlFile == null) { htmlFile = file.getParent().getFileObject(file.getName(), "HTML"); //NOI18N } if (htmlFile == null) { return null; } FileObject existingFile = buildDir.getFileObject(htmlFile.getName(), htmlFile.getExt()); if (existingFile != null) { existingFile.delete(); } FileObject targetHtml = htmlFile.copy(buildDir, file.getName(), ext); if (targetHtml != null) { String activePlatformName = evaluator.getProperty("platform.active"); //NOI18N url = AppletSupport.getHTMLPageURL(targetHtml, activePlatformName); } } catch (IOException ioe) { ErrorManager.getDefault().notify(ioe); return null; } return url; }
Example 18
Source File: AssetPackLoader.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public static void addModelFiles(ProjectAssetManager source, ProjectAssetManager dest, AssetConfiguration config) { Element assetElement = config.getAssetElement(); NodeList fileNodeList = assetElement.getElementsByTagName("file"); try { if (dest == null) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!"); return; } } catch (Exception e) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not get project asset manager!"); return; } for (int i = 0; i < fileNodeList.getLength(); i++) { Element fileElem = (Element) fileNodeList.item(i); String type = fileElem.getAttribute("type"); if ("texture".equals(type) || "sound".equals(type) || "materialdef".equals(type) || "shader".equals(type) || "other".equals(type)) { try { String src = source.getAbsoluteAssetPath(fileElem.getAttribute("path")); if (src == null) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not find texture with manager!"); return; } FileObject srcFile = FileUtil.toFileObject(new File(src)); String destName = dest.getAssetFolderName() + "/" + fileElem.getAttribute("path"); String destFolder = destName.replace("\\", "/"); destFolder = destFolder.substring(0, destFolder.lastIndexOf("/")); FileObject folder = FileUtil.createFolder(new File(destFolder)); srcFile.copy(folder, srcFile.getName(), srcFile.getExt()); } catch (IOException ex) { Logger.getLogger(AssetPackLoader.class.getName()).log(Level.SEVERE, "Could not copy texture: {0}", ex.getMessage()); } } } List<NodeList> varAssets = config.getVariationAssets(); if (varAssets != null) { for (NodeList nodeList : varAssets) { addVariationFiles(nodeList, source, dest); } } return; }
Example 19
Source File: CRUDTest.java From netbeans with Apache License 2.0 | 4 votes |
/** * Test creation of RESTful web service from an entity class which uses * property based access. Also tests functionality of the new RESTful web * service from entity classes wizard (buttons, updating model in the * wizard) */ public void testPropAccess() throws IOException { //copy entity class into a project FileObject fo = FileUtil.toFileObject(new File(getRestDataDir(), "Person.java.gf")); //NOI18N fo.copy(getProjectSourceRoot().createFolder("entity"), "Person", "java"); //NOI18N //RESTful Web Services from Entity Classes String restLabel = Bundle.getStringTrimmed("org.netbeans.modules.websvc.rest.wizard.Bundle", "Templates/WebServices/RestServicesFromEntities"); createNewWSFile(getProject(), restLabel); WizardOperator wo = new WizardOperator(restLabel); //have to wait until "retrieving message dissapers (see also issue 130835) new EventTool().waitNoEvent(2500); JListOperator availableEntities = new JListOperator(wo, 1); JListOperator selectedEntities = new JListOperator(wo, 2); //XXX - workaround for: http://www.netbeans.org/issues/show_bug.cgi?id=130835 //Add All >> String addAllLabel = Bundle.getStringTrimmed("org.netbeans.modules.websvc.rest.wizard.Bundle", "LBL_AddAll"); String removeAllLabel = Bundle.getStringTrimmed("org.netbeans.modules.websvc.rest.wizard.Bundle", "LBL_RemoveAll"); // wait till all classes are loaded into list new EventTool().waitNoEvent(2000); new JButtonOperator(wo, addAllLabel).push(); // wait till all classes are moved from one list to another new EventTool().waitNoEvent(2000); //<< Remove All (see bug #202010) new JButtonOperator(wo, removeAllLabel).push(); //XXX - end availableEntities.selectItem("Customer"); //NOI18N //Add > String addLabel = Bundle.getStringTrimmed("org.netbeans.modules.websvc.rest.wizard.Bundle", "LBL_Add"); new JButtonOperator(wo, addLabel).push(); availableEntities.selectItem("Product"); //NOI18N new JButtonOperator(wo, addLabel).push(); assertEquals("add failed in selected", 5, selectedEntities.getModel().getSize()); //NOI18N assertEquals("add failed in available", 3, availableEntities.getModel().getSize()); //NOI18N selectedEntities.selectItem("Product"); //NOI18N //< Remove String removeLabel = Bundle.getStringTrimmed("org.netbeans.modules.websvc.rest.wizard.Bundle", "LBL_Remove"); new JButtonOperator(wo, removeLabel).push(); assertEquals("remove failed in selected", 2, selectedEntities.getModel().getSize()); //NOI18N assertEquals("remove failed in available", 6, availableEntities.getModel().getSize()); //NOI18N //<< Remove All new JButtonOperator(wo, "Remove All").push(); assertEquals("remove all failed in selected", 0, selectedEntities.getModel().getSize()); //NOI18N assertEquals("remove all failed in available", 8, availableEntities.getModel().getSize()); //NOI18N availableEntities.selectItem("Person"); //NOI18N new JButtonOperator(wo, addLabel).push(); assertEquals("add in selected", 1, selectedEntities.getModel().getSize()); //NOI18N assertEquals("add in available", 7, availableEntities.getModel().getSize()); //NOI18N wo.next(); wo.finish(); wo.waitClosed(); new EventTool().waitNoEvent(1000); waitScanFinished(); Set<File> files = getFilesFromCustomPkg("service", "entity"); //NOI18N if (getJavaEEversion().equals(JavaEEVersion.JAVAEE5)) { files.addAll(getFilesFromCustomPkg("controller", "controller.exceptions", "service", "entity")); //NOI18N } if (JavaEEVersion.JAVAEE6.equals(getJavaEEversion()) || JavaEEVersion.JAVAEE7.equals(getJavaEEversion())) { assertEquals("Some files were not generated", 3, files.size()); //NOI18N } else { assertEquals("Some files were not generated", 7, files.size()); //NOI18N } checkFiles(files); //make sure all REST services nodes are visible in project log. view waitRestNodeChildren(8); }
Example 20
Source File: Controller.java From netbeans with Apache License 2.0 | 4 votes |
void saveTransaction(Node[] nodes) { if(!haveDirectories()) { // PENDING - report the error properly // This should not happen log("Couldn't get the directory"); //NOI18N return; } Node[] newNodes = new Node[nodes.length]; TransactionNode mvNode; String id; boolean error = false; for(int i=0; i < nodes.length; ++i) { mvNode = (TransactionNode)nodes[i]; id = mvNode.getID(); if(debug) log(" Saving " + id); //NOI18N if(currBeans.containsKey(id)) saveBeans.put(id, currBeans.remove(id)); // Note I didn't load the bean here yet. Will only do that // if the data is displayed. FileLock lock = null; try { FileObject fold = currDir.getFileObject(id, "xml"); //NOI18N lock = fold.lock(); fold.copy(saveDir, id, "xml"); //NOI18N if(debug) log(fold.getName()); fold.delete(lock); mvNode.setCurrent(false); newNodes[i] = mvNode; } catch(FileAlreadyLockedException falex) { error = true; // PENDING report properly } catch(IOException ioex) { error = true; // PENDING report properly } catch(Exception ex) { error = true; // PENDING report properly } finally { if(lock != null) lock.releaseLock(); } } if(!error) currTrans.remove(nodes); savedTrans.add(newNodes); }