@Override public Form getForm( String ctxUID ) { FormEditorContext context = formEditorContextManager.getRootEditorContext( ctxUID ); if ( context != null ) return context.getForm(); return null; }
@Override public Form getFormByPath( String ctxUID, String formPath ) { FormEditorContext editorContext = formEditorContextManager.getRootEditorContext( ctxUID ); if ( editorContext != null ) { try { Path currentForm = Paths.convert( ioService.get( new URI( editorContext.getPath() ) ) ); org.uberfire.java.nio.file.Path path = Paths.convert( currentForm ).getParent().resolve( formPath ); String xml = ioService.readAllString( path ).trim(); return formSerializationManager.loadFormFromXML( xml, path.toUri().toString() ); } catch ( Exception e ) { log.warn( "Error getting form {} from context {}: {}", formPath, ctxUID, e ); } } return null; }
TreeMap treeMap = new TreeMap<String, String>(); FormEditorContext context = formEditorContextManager.getRootEditorContext( namespace );
@Override public Form getFormById( String ctxUID, long formId ) { FormEditorContext editorContext = formEditorContextManager.getRootEditorContext( ctxUID ); if ( editorContext != null ) { try { if ( editorContext.getForm().getId().equals( new Long( formId ) ) ) { return editorContext.getForm(); } Path currentForm = Paths.convert( ioService.get( new URI( editorContext.getPath() ) ) ); Project project = projectService.resolveProject( currentForm ); FileUtils utils = FileUtils.getInstance(); List<org.uberfire.java.nio.file.Path> nioPaths = new ArrayList<org.uberfire.java.nio.file.Path>(); nioPaths.add( Paths.convert( project.getRootPath() ) ); Collection<FileUtils.ScanResult> forms = utils.scan( ioService, nioPaths, "form", true ); String header = formSerializationManager.generateHeaderFormFormId( formId ); for ( FileUtils.ScanResult form : forms ) { org.uberfire.java.nio.file.Path formPath = form.getFile(); org.uberfire.java.nio.file.Path path = Paths.convert( project.getRootPath() ).resolve( MAIN_RESOURCES_PATH ).resolve( formPath ); String xml = ioService.readAllString( path ).trim(); if ( xml.startsWith( header ) ) { return formSerializationManager.loadFormFromXML( xml ); } } } catch ( Exception e ) { log.warn( "Error getting form {} from context {}: {}", formId, ctxUID, e ); } } return null; }