/** * Add all children as candidates * * @param root the root context * @param parent the parent context * @param metaData the structure meta data * @param deployers the structure deployers * @param attributes the visitor attributes uses {@link VisitorAttributes#DEFAULT} when null * @throws Exception for any error */ protected void addChildren(VirtualFile root, VirtualFile parent, StructureMetaData metaData, VFSStructuralDeployers deployers, VisitorAttributes attributes) throws Exception { if (parent == null) throw new IllegalArgumentException("Null parent"); StructureContext context = new StructureContext(root, null, parent, metaData, deployers, null); addChildren(context, attributes); }
@Override protected void determineStructure(Deployment deployment, StructureMetaData structure) throws Exception { if (deployment instanceof VFSDeployment == false) throw new DeploymentException("Structure can only be determined for VFSDeployments " + deployment); VFSDeployment vfsDeployment = (VFSDeployment) deployment; VirtualFile root = vfsDeployment.getRoot(); if (root == null) throw new IllegalStateException("Deployment has no root " + deployment); StructureContext context = new StructureContext(root, structure, this); if (doDetermineStructure(context) == false) throw new DeploymentException("No deployer recognised the structure of " + deployment.getName()); } }
public boolean determineStructure(VirtualFile file, StructureContext parentContext) throws DeploymentException { StructureMetaData structure = StructureMetaDataFactory.createStructureMetaData(); StructureContext context = new StructureContext(file, structure, parentContext); boolean result = doDetermineStructure(context); if (result) { String relativePath = AbstractStructureDeployer.getRelativePath(context.getParent(), file); // Something said it recognised it ContextInfo recognised = structure.getContext(""); if (recognised == null) throw new IllegalStateException("Something recognised the deployment, but there is no context? " + file); // Create the context in the parent structure ContextInfo parentContextInfo; List<MetaDataEntry> metaDataPath = recognised.getMetaDataPath(); if (metaDataPath == null || metaDataPath.isEmpty()) parentContextInfo = StructureMetaDataFactory.createContextInfo(relativePath, recognised.getClassPath()); else parentContextInfo = StructureMetaDataFactory.createContextInfo(recognised.getClassPath(), metaDataPath, relativePath); // copy the modification type information parentContextInfo.setModificationType(recognised.getModificationType()); StructureMetaData structureMetaData = parentContext.getMetaData(); structureMetaData.addContext(parentContextInfo); MutableAttachments attachments = (MutableAttachments) parentContextInfo.getPredeterminedManagedObjects(); attachments.addAttachment(StructureMetaData.class, structure); } return result; }