/** * @param spaceSummary * @return */ public List<XWikiEclipsePageSummary> getPageSummaries(String wiki, String space) throws XWikiEclipseStorageException { final List<XWikiEclipsePageSummary> result = new ArrayList<XWikiEclipsePageSummary>(); try { final IFolder pagesFolder = StorageUtils.createFolder(baseFolder.getFolder(PAGES_DIRECTORY)); List<IResource> pageFolderResources = getChildResources(pagesFolder, IResource.DEPTH_ONE); for (IResource pageFolderResource : pageFolderResources) { if (pageFolderResource instanceof IFile) { IFile file = (IFile) pageFolderResource; if (file.getFileExtension().equals(PAGE_SUMMARY_FILE_EXTENSION)) { IFile pageSummaryFile = (IFile) pageFolderResource; XWikiEclipsePageSummary pageSummary; try { pageSummary = (XWikiEclipsePageSummary) StorageUtils.readFromJSON( pageSummaryFile, XWikiEclipsePageSummary.class.getCanonicalName()); if (pageSummary.getWiki().equals(wiki) && pageSummary.getSpace().equals(space)) { result.add(pageSummary); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } } catch (CoreException e) { throw new XWikiEclipseStorageException(e); } return result; }
/** * @param wiki * @param space * @param page * @return * @throws Exception */ public List<XWikiEclipseObjectSummary> getObjectSummaries(String wiki, String space, String page) throws Exception { List<XWikiEclipseObjectSummary> result = new ArrayList<XWikiEclipseObjectSummary>(); final IFolder objectsFolder = StorageUtils.createFolder(baseFolder.getFolder(OBJECTS_DIRECTORY)); List<IResource> objectsFolderResources = getChildResources(objectsFolder, IResource.DEPTH_ONE); for (IResource objectsFolderResource : objectsFolderResources) { if (objectsFolderResource instanceof IFile && ((IFile) objectsFolderResource) .getFileExtension() .equals(OBJECT_SUMMARY_FILE_EXTENSION)) { IFile objectSummaryFile = (IFile) objectsFolderResource; XWikiEclipseObjectSummary objectSummary = (XWikiEclipseObjectSummary) StorageUtils.readFromJSON( objectSummaryFile, XWikiEclipseObjectSummary.class.getCanonicalName()); if (objectSummary.getWiki().equals(wiki) && objectSummary.getSpace().equals(space) && objectSummary.getPageName().equals(page)) { result.add(objectSummary); } } } return result; }
public List<XWikiEclipseSpaceSummary> getSpaces(String wikiId) throws XWikiEclipseStorageException { final List<XWikiEclipseSpaceSummary> result = new ArrayList<XWikiEclipseSpaceSummary>(); try { final IFolder spaceFolder = StorageUtils.createFolder(baseFolder.getFolder(SPACES_DIRECTORY)); List<IResource> spaceFolderResources = getChildResources(spaceFolder, IResource.DEPTH_ONE); for (IResource spaceFolderResource : spaceFolderResources) { if (spaceFolderResource instanceof IFile) { IFile wikiFile = (IFile) spaceFolderResource; XWikiEclipseSpaceSummary spaceSummary; try { spaceSummary = (XWikiEclipseSpaceSummary) StorageUtils.readFromJSON( wikiFile, XWikiEclipseSpaceSummary.class.getCanonicalName()); if (spaceSummary.getWiki().equals(wikiId)) { result.add(spaceSummary); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } catch (CoreException e) { throw new XWikiEclipseStorageException(e); } return result; }
public List<XWikiEclipseWikiSummary> getWikiSummaries() throws XWikiEclipseStorageException { final List<XWikiEclipseWikiSummary> result = new ArrayList<XWikiEclipseWikiSummary>(); try { final IFolder wikiFolder = StorageUtils.createFolder(baseFolder.getFolder(WIKIS_DIRECTORY)); List<IResource> wikiFolderResources = getChildResources(wikiFolder, IResource.DEPTH_ONE); for (IResource wikiFolderResource : wikiFolderResources) { if (wikiFolderResource instanceof IFile) { IFile wikiFile = (IFile) wikiFolderResource; XWikiEclipseWikiSummary wikiSummary; try { wikiSummary = (XWikiEclipseWikiSummary) StorageUtils.readFromJSON( wikiFile, XWikiEclipseWikiSummary.class.getCanonicalName()); result.add(wikiSummary); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } catch (CoreException e) { throw new XWikiEclipseStorageException(e); } return result; }
/** * @param wiki * @param className * @return * @throws Exception */ public XWikiEclipseClass getClass(String wiki, String className) throws Exception { IFolder classesFolder = StorageUtils.createFolder(baseFolder.getFolder(CLASSES_DIRECTORY)); IFile classFile = classesFolder.getFile(getFileNameForClass(wiki, className)); if (classFile.exists()) { XWikiEclipseClass result = (XWikiEclipseClass) StorageUtils.readFromJSON(classFile, XWikiEclipseClass.class.getCanonicalName()); return result; } // TODO Auto-generated method stub return null; }
public XWikiEclipsePage getPage(String wiki, String space, String pageName, String language) throws XWikiEclipseStorageException { try { IFolder pageFolder = StorageUtils.createFolder(baseFolder.getFolder(PAGES_DIRECTORY)); IFile pageFile = pageFolder.getFile(getFileNameForPage(wiki, space, pageName, language)); // $NON-NLS-1$ if (pageFile.exists()) { XWikiEclipsePage result = (XWikiEclipsePage) StorageUtils.readFromJSON(pageFile, XWikiEclipsePage.class.getCanonicalName()); return result; } } catch (Exception e) { throw new XWikiEclipseStorageException(e); } return null; }
public void removeSpace(String wiki, String space) throws XWikiEclipseStorageException { // Delete space summary file try { final IFolder spaceFolder = StorageUtils.createFolder(baseFolder.getFolder(SPACES_DIRECTORY)); List<IResource> spacesFolderResources = getChildResources(spaceFolder, IResource.DEPTH_ONE); for (IResource spacesFolderResource : spacesFolderResources) { if (spacesFolderResource instanceof IFile) { IFile spaceFile = (IFile) spacesFolderResource; if (spaceFile.getName().equals(getFileNameForSpaceSummary(wiki, space))) { spaceFile.delete(true, null); break; } } } } catch (CoreException e) { throw new XWikiEclipseStorageException(e); } }
public XWikiEclipseObject getObject( String wiki, String space, String page, String className, int number) throws XWikiEclipseStorageException { try { IFolder objectsFolder = StorageUtils.createFolder(baseFolder.getFolder(OBJECTS_DIRECTORY)); IFile objectFile = objectsFolder.getFile( getFileNameForObject(wiki, space, page, className, number)); // $NON-NLS-1$ if (objectFile.exists()) { XWikiEclipseObject result = (XWikiEclipseObject) StorageUtils.readFromJSON(objectFile, XWikiEclipseObject.class.getCanonicalName()); return result; } } catch (Exception e) { throw new XWikiEclipseStorageException(e); } return null; }