List of usage examples for org.w3c.dom Document getFirstChild
public Node getFirstChild();
From source file:org.ebayopensource.turmeric.eclipse.resources.util.SOAIntfUtil.java
/** * The format should be the following//w ww.ja va 2 s. c o m * <wsdl:service name="CreativeService"> * <wsdl:documentation> * <version>1.0</version> * </wsdl:documentation> * ... * * @param project the project * @param newVersion the new version * @param monitor the monitor * @throws Exception the exception */ public static void modifyWsdlAppInfoVersion(final IProject project, final String newVersion, IProgressMonitor monitor) throws Exception { monitor.setTaskName("Modifying service WSDL..."); final String serviceName = project.getName(); final IFile wsdlFile = SOAServiceUtil.getWsdlFile(project, serviceName); InputStream ins = null; Definition wsdl = null; try { ins = wsdlFile.getContents(); wsdl = WSDLUtil.readWSDL(ins); } finally { IOUtils.closeQuietly(ins); } monitor.worked(10); if (wsdl == null) return; DOMParser domParser = new DOMParser(); Document doc = null; try { ins = wsdlFile.getContents(); domParser.parse(new InputSource(ins)); doc = domParser.getDocument(); } finally { IOUtils.closeQuietly(ins); } monitor.worked(10); if (doc == null) return; Node wsdlNode = doc.getFirstChild(); Node serviceNode = null; for (int i = wsdlNode.getChildNodes().getLength() - 1; i >= 0; i--) { Node node = wsdlNode.getChildNodes().item(i); if (node.getNodeType() == Node.ELEMENT_NODE && ELEM_NAME_SERVICE.equals(node.getLocalName())) { serviceNode = node; break; } } monitor.worked(10); if (serviceNode == null) return; Node documentationNode = null; for (int i = 0; i < serviceNode.getChildNodes().getLength(); i++) { Node node = serviceNode.getChildNodes().item(i); if (ELEM_NAME_DOCUMENTATION.equals(node.getLocalName())) { documentationNode = node; } } monitor.worked(10); boolean needUpdateWsdl = false; if (documentationNode != null) { //we found the documentation node Node verNode = null; for (int i = 0; i < documentationNode.getChildNodes().getLength(); i++) { Node node = documentationNode.getChildNodes().item(i); if (ELEM_NAME_VERSION_V2_CAMEL_CASE.equals(node.getLocalName()) || ELEM_NAME_VERSION_V3_CAMEL_CASE.equals(node.getLocalName())) { verNode = node; break; } } if (verNode == null) { // add version node to document node if there is no version // node. Element v3Version = doc.createElement("version"); Text versionText = doc.createTextNode(newVersion); v3Version.appendChild(versionText); documentationNode.appendChild(v3Version); needUpdateWsdl = true; } else { if (ELEM_NAME_VERSION_V2_CAMEL_CASE.equals(verNode.getLocalName())) { // if current version node is V2 format, replace it with V3 // format Element v3Version = doc.createElement("version"); Text versionText = doc.createTextNode(newVersion); v3Version.appendChild(versionText); documentationNode.replaceChild(v3Version, verNode); needUpdateWsdl = true; } else { // current version format is V3, update version value. for (int i = 0; i < verNode.getChildNodes().getLength(); i++) { Node node = verNode.getChildNodes().item(i); if (node.getNodeType() == Node.TEXT_NODE && newVersion.equals(node.getNodeValue()) == false) { logger.warning("Version defined in WSDL's service section->", node.getNodeValue(), " is older than the new version->", newVersion); node.setNodeValue(newVersion); needUpdateWsdl = true; break; } } } } } monitor.worked(10); if (needUpdateWsdl == true) { FileWriter writer = null; try { writer = new FileWriter(wsdlFile.getLocation().toFile()); XMLUtil.writeXML(wsdlNode, writer); } finally { IOUtils.closeQuietly(writer); wsdlFile.refreshLocal(IResource.DEPTH_ONE, monitor); } } else { logger.info("WSDL already have the correct version '", newVersion, "', skip the modification for WSDL->", wsdlFile.getLocation()); } monitor.worked(10); }
From source file:org.eclipse.swordfish.plugins.ws.wsdlgenerator.HttpEndpointListener.java
private void processEndpoint(HttpEndpoint endpoint) { try {//from w ww.j a va 2 s .c o m NMRDestination destination = getCxfEndpoint(endpoint); if (destination == null) { return; } Definition definition = new ServiceWSDLBuilder(bus, destination.getEndpointInfo().getService()).build(); /*WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class) .getWSDLFactory().newWSDLWriter(); definition.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry()); Document document = wsdlWriter.getDocument(definition);*/ Document document = WSDLFactory.newInstance().newWSDLWriter().getDocument(definition); addAddressElementIfNeeded(document, endpoint.getLocationURI()); String wsdlSource = new SourceTransformer().toString(document.getFirstChild()); if (LOG.isDebugEnabled()) { LOG.debug(wsdlSource); } String filePath = File.createTempFile("swordfish.wsdl.", null).getPath(); FileWriter fstream = new FileWriter(filePath); BufferedWriter out = new BufferedWriter(fstream); out.write(wsdlSource); out.close(); endpoint.setWsdlResource(new FileSystemResource(filePath)); } catch (Exception ex) { LOG.error("Could not generate wsdl for endpoint " + endpoint, ex); } }
From source file:org.eclipse.swordfish.plugins.ws.wsdlgenerator.HttpEndpointListener.java
private void addAddressElementIfNeeded(Document document, String location) throws TransformerException { String wsdlSource = new SourceTransformer().toString(document.getFirstChild()); List<Element> elementList = DOMUtils.findAllElementsByTagNameNS(document.getDocumentElement(), "http://schemas.xmlsoap.org/wsdl/", "port"); if (elementList.size() > 0) { Element portElement = elementList.get(0); if (DOMUtils.getFirstElement(portElement) == null) { Element addressElement = document.createElementNS("http://schemas.xmlsoap.org/wsdl/soap/", "address"); portElement.appendChild(addressElement); addressElement.setAttribute("location", location); }/*from ww w . ja va2s .c o m*/ } }
From source file:org.etudes.component.app.melete.MeleteSecurityServiceImpl.java
/** * {@inheritDoc}/*from www. j a va 2s. c o m*/ */ public String archive(String siteId, Document doc, Stack stack, String archivePath, List attachments) { logger.debug("siteid as arg in archive function is " + siteId); int count = 0; try { Element modulesElement = doc.createElement(MeleteSecurityService.class.getName()); if (siteId != null && siteId.length() > 0) { List<Module> selectList = getModuleService().getModules(siteId); count = selectList.size(); File basePackDir = new File(archivePath); List orgResElements = getMeleteExportService().generateOrganizationResourceItems(selectList, true, basePackDir, SiteService.getSite(siteId).getTitle(), siteId); if (orgResElements != null && orgResElements.size() > 0) { String xmlstr = createdom4jtree((org.dom4j.Element) (org.dom4j.Element) orgResElements.get(0)); // read organizations 4j document as w3c document org.w3c.dom.Document meletew3cDocument = Xml.readDocumentFromString(xmlstr); org.w3c.dom.Element meletew3cElement = (org.w3c.dom.Element) meletew3cDocument.getFirstChild(); org.w3c.dom.Element meletew3cNewElement = (org.w3c.dom.Element) ((Element) stack.peek()) .getOwnerDocument().importNode(meletew3cElement, true); modulesElement.appendChild(meletew3cNewElement); // now resources document xmlstr = createdom4jtree((org.dom4j.Element) (org.dom4j.Element) orgResElements.get(1)); org.w3c.dom.Document meletew3cResDocument = Xml.readDocumentFromString(xmlstr); org.w3c.dom.Element meletew3cElement1 = (org.w3c.dom.Element) meletew3cResDocument .getFirstChild(); org.w3c.dom.Element meletew3cNewElement1 = (org.w3c.dom.Element) ((Element) stack.peek()) .getOwnerDocument().importNode(meletew3cElement1, true); modulesElement.appendChild(meletew3cNewElement1); ((Element) stack.peek()).appendChild(modulesElement); stack.push(modulesElement); } } // stack.pop(); } catch (IdUnusedException iue) { logger.debug("error in melete during site archive"); return "error archiving modules"; } catch (Exception ex) { if (logger.isDebugEnabled()) { logger.debug("error in melete during site archive" + ex.toString()); ex.printStackTrace(); } return "error archiving modules"; } return "archiving modules: (" + count + ") modules archived successfully. \n"; }
From source file:org.exoplatform.cms.common.CommonUtils.java
static public File getXMLFile(ByteArrayOutputStream bos, String appName, String objectType, Date createDate, String fileName) throws Exception { byte[] byteData = bos.toByteArray(); DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); InputStream is = new ByteArrayInputStream(byteData); Document document = docBuilder.parse(is); org.w3c.dom.Attr namespace = document.createAttribute("xmlns:exoks"); namespace.setValue("http://www.exoplatform.com/exoks/2.0"); document.getFirstChild().getAttributes().setNamedItem(namespace); org.w3c.dom.Attr attName = document.createAttribute("exoks:applicationName"); attName.setValue(appName);/*from w w w. j a v a2 s . c o m*/ document.getFirstChild().getAttributes().setNamedItem(attName); org.w3c.dom.Attr dataType = document.createAttribute("exoks:objectType"); dataType.setValue(objectType); document.getFirstChild().getAttributes().setNamedItem(dataType); org.w3c.dom.Attr exportDate = document.createAttribute("exoks:exportDate"); exportDate.setValue(createDate.toString()); document.getFirstChild().getAttributes().setNamedItem(exportDate); org.w3c.dom.Attr checkSum = document.createAttribute("exoks:checkSum"); checkSum.setValue(generateCheckSum(byteData)); document.getFirstChild().getAttributes().setNamedItem(checkSum); DOMSource source = new DOMSource(document.getFirstChild()); File file = new File(fileName + ".xml"); file.deleteOnExit(); file.createNewFile(); StreamResult result = new StreamResult(file); TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(); transformer.transform(source, result); return file; }
From source file:org.exoplatform.forum.service.impl.JCRDataStorage.java
public void importXML(String nodePath, ByteArrayInputStream bis, int typeImport) throws Exception { String nodeName = ""; byte[] bdata = new byte[bis.available()]; bis.read(bdata);//from ww w.jav a 2s . c om DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); ByteArrayInputStream is = new ByteArrayInputStream(bdata); Document doc = docBuilder.parse(is); doc.getDocumentElement().normalize(); String typeNodeExport = ((org.w3c.dom.Node) doc.getFirstChild().getChildNodes().item(0).getChildNodes() .item(0)).getTextContent(); SessionProvider sProvider = CommonUtils.createSystemProvider(); List<String> patchNodeImport = new ArrayList<String>(); try { Node forumHome = getForumHomeNode(sProvider); is = new ByteArrayInputStream(bdata); if (!typeNodeExport.equals(EXO_FORUM_CATEGORY) && !typeNodeExport.equals(EXO_FORUM)) { // All nodes when import need reset childnode if (typeNodeExport.equals(EXO_CATEGORY_HOME)) { nodePath = getCategoryHome(sProvider).getPath(); Node categoryHome = getCategoryHome(sProvider); nodeName = "CategoryHome"; addDataFromXML(categoryHome, nodePath, sProvider, is, nodeName); } else if (typeNodeExport.equals(EXO_USER_PROFILE_HOME)) { Node userProfile = getUserProfileHome(sProvider); nodeName = "UserProfileHome"; nodePath = getUserProfileHome(sProvider).getPath(); addDataFromXML(userProfile, nodePath, sProvider, is, nodeName); } else if (typeNodeExport.equals(EXO_TAG_HOME)) { Node tagHome = getTagHome(sProvider); nodePath = getTagHome(sProvider).getPath(); nodeName = "TagHome"; addDataFromXML(tagHome, nodePath, sProvider, is, nodeName); } else if (typeNodeExport.equals(EXO_FORUM_BB_CODE_HOME)) { nodePath = dataLocator.getBBCodesLocation(); Node bbcodeNode = getBBCodesHome(sProvider); nodeName = "forumBBCode"; addDataFromXML(bbcodeNode, nodePath, sProvider, is, nodeName); } // Node import but don't need reset childnodes else if (typeNodeExport.equals(EXO_ADMINISTRATION_HOME)) { nodePath = getForumSystemHome(sProvider).getPath(); Node node = getAdminHome(sProvider); node.remove(); getForumSystemHome(sProvider).save(); typeImport = ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING; Session session = forumHome.getSession(); session.importXML(nodePath, is, typeImport); session.save(); } else if (typeNodeExport.equals(EXO_BAN_IP_HOME)) { nodePath = getForumSystemHome(sProvider).getPath(); Node node = getBanIPHome(sProvider); node.remove(); getForumSystemHome(sProvider).save(); typeImport = ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING; Session session = forumHome.getSession(); session.importXML(nodePath, is, typeImport); session.save(); } else { throw new RuntimeException("unknown type of node to export :" + typeNodeExport); } } else { if (typeNodeExport.equals(EXO_FORUM_CATEGORY)) { // Check if import forum but the data import have structure of a category --> Error if (nodePath.split("/").length == 6) { throw new ConstraintViolationException(); } nodePath = getCategoryHome(sProvider).getPath(); } Session session = forumHome.getSession(); NodeIterator iter = ((Node) session.getItem(nodePath)).getNodes(); while (iter.hasNext()) { patchNodeImport.add(iter.nextNode().getName()); } session.importXML(nodePath, is, typeImport); session.save(); NodeIterator newIter = ((Node) session.getItem(nodePath)).getNodes(); while (newIter.hasNext()) { Node node = newIter.nextNode(); if (patchNodeImport.contains(node.getName())) patchNodeImport.remove(node.getName()); else patchNodeImport.add(node.getName()); } } // update forum statistic and profile of owner post. if (typeNodeExport.equals(EXO_FORUM_CATEGORY) || typeNodeExport.equals(EXO_FORUM)) { for (String string : patchNodeImport) { updateForum(nodePath + "/" + string, false); } } else if (typeNodeExport.equals(EXO_CATEGORY_HOME)) { updateForum(null); } } finally { is.close(); } }
From source file:org.gluu.oxtrust.ldap.service.Shibboleth2ConfService.java
private HashMap<String, Object> initTrustParamMap(List<GluuSAMLTrustRelationship> trustRelationships) { log.trace("Starting trust parameters map initialization."); HashMap<String, Object> trustParams = new HashMap<String, Object>(); // Metadata signature verification engines // https://wiki.shibboleth.net/confluence/display/SHIB2/IdPTrustEngine List<Map<String, String>> trustEngines = new ArrayList<Map<String, String>>(); // the map of {inum,number} for easy naming of relying parties. Map<String, String> trustIds = new HashMap<String, String>(); // Trust relationships that are part of some federation List<GluuSAMLTrustRelationship> deconstructed = new ArrayList<GluuSAMLTrustRelationship>(); // the map of {inum,number} for easy naming of federated relying // parties.//from w w w. ja va 2s . com Map<String, String> deconstructedIds = new HashMap<String, String>(); // the map of {inum, {inum, inum, inum...}} describing the federations // and TRs defined from them. Map<String, List<String>> deconstructedMap = new HashMap<String, List<String>>(); // entityIds defined in each TR. Map<String, List<String>> trustEntityIds = new HashMap<String, List<String>>(); int id = 1; for (GluuSAMLTrustRelationship trustRelationship : trustRelationships) { boolean isPartOfFederation = !(trustRelationship.getSpMetaDataSourceType() == GluuMetadataSourceType.URI || trustRelationship.getSpMetaDataSourceType() == GluuMetadataSourceType.FILE); if (!isPartOfFederation) { // Set Id trustIds.put(trustRelationship.getInum(), String.valueOf(id++)); // Set entityId String idpMetadataFolder = applicationConfiguration.getShibboleth2IdpRootDir() + File.separator + SHIB2_IDP_METADATA_FOLDER + File.separator; File metadataFile = new File(idpMetadataFolder + trustRelationship.getSpMetaDataFN()); List<String> entityIds = getEntityIdFromMetadataFile(metadataFile); // if for some reason metadata is corrupted or missing - mark // trust relationship INACTIVE // user will be able to fix this in UI if (entityIds == null) { trustRelationship.setStatus(GluuStatus.INACTIVE); TrustService.instance().updateTrustRelationship(trustRelationship); continue; } trustEntityIds.put(trustRelationship.getInum(), entityIds); try { filterService.parseFilters(trustRelationship); ProfileConfigurationService.instance().parseProfileConfigurations(trustRelationship); } catch (Exception e) { log.error("Failed to parse stored metadataFilter configuration for trustRelationship " + trustRelationship.getDn(), e); } if (trustRelationship.getMetadataFilters().get("signatureValidation") != null) { Map<String, String> trustEngine = new HashMap<String, String>(); trustEngine.put("id", "Trust" + StringHelper.removePunctuation(trustRelationship.getInum())); trustEngine.put("certPath", applicationConfiguration.getShibboleth2IdpRootDir() + File.separator + SHIB2_IDP_METADATA_FOLDER + File.separator + "credentials" + File.separator + trustRelationship.getMetadataFilters().get("signatureValidation") .getFilterCertFileName()); trustEngines.add(trustEngine); } // If there is an intrusive filter - push it to the end of the // list. if (trustRelationship.getGluuSAMLMetaDataFilter() != null) { List<String> filtersList = new ArrayList<String>(); String entityRoleWhiteList = null; for (String filterXML : trustRelationship.getGluuSAMLMetaDataFilter()) { Document xmlDocument = null; try { xmlDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new java.io.ByteArrayInputStream(filterXML.getBytes())); } catch (Exception e) { log.error("GluuSAMLMetaDataFilter contains invalid value.", e); continue; } if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue() .equals(FilterService.ENTITY_ROLE_WHITE_LIST_TYPE)) { entityRoleWhiteList = filterXML; continue; } filtersList.add(filterXML); } if (entityRoleWhiteList != null) { filtersList.add(entityRoleWhiteList); } trustRelationship.setGluuSAMLMetaDataFilter(filtersList); } } else { String federationInum = trustRelationship.getContainerFederation().getInum(); if (deconstructedMap.get(federationInum) == null) { deconstructedMap.put(federationInum, new ArrayList<String>()); } deconstructedMap.get(federationInum).add(trustRelationship.getEntityId()); deconstructed.add(trustRelationship); deconstructedIds.put(trustRelationship.getEntityId(), String.valueOf(id++)); } } for (String trustRelationshipInum : trustEntityIds.keySet()) { List<String> federatedSites = deconstructedMap.get(trustRelationshipInum); if (federatedSites != null) { trustEntityIds.get(trustRelationshipInum).removeAll(federatedSites); } } trustParams.put("idpCredentialsPath", applicationConfiguration.getShibboleth2IdpRootDir() + File.separator + SHIB2_IDP_METADATA_FOLDER + File.separator + "credentials" + File.separator); trustParams.put("deconstructed", deconstructed); trustParams.put("deconstructedIds", deconstructedIds); trustParams.put("trustEngines", trustEngines); trustParams.put("trusts", trustRelationships); trustParams.put("trustIds", trustIds); trustParams.put("trustEntityIds", trustEntityIds); return trustParams; }
From source file:org.gluu.oxtrust.ldap.service.Shibboleth3ConfService.java
private HashMap<String, Object> initTrustParamMap(List<GluuSAMLTrustRelationship> trustRelationships) { //TODO: change for IDP3 log.trace("Starting trust parameters map initialization."); HashMap<String, Object> trustParams = new HashMap<String, Object>(); // Metadata signature verification engines // https://wiki.shibboleth.net/confluence/display/SHIB2/IdPTrustEngine List<Map<String, String>> trustEngines = new ArrayList<Map<String, String>>(); // the map of {inum,number} for easy naming of relying parties. Map<String, String> trustIds = new HashMap<String, String>(); // Trust relationships that are part of some federation List<GluuSAMLTrustRelationship> deconstructed = new ArrayList<GluuSAMLTrustRelationship>(); // the map of {inum,number} for easy naming of federated relying // parties.//from www . j av a2s .c o m Map<String, String> deconstructedIds = new HashMap<String, String>(); // the map of {inum, {inum, inum, inum...}} describing the federations // and TRs defined from them. Map<String, List<String>> deconstructedMap = new HashMap<String, List<String>>(); // entityIds defined in each TR. Map<String, List<String>> trustEntityIds = new HashMap<String, List<String>>(); int id = 1; for (GluuSAMLTrustRelationship trustRelationship : trustRelationships) { boolean isPartOfFederation = !(trustRelationship.getSpMetaDataSourceType() == GluuMetadataSourceType.URI || trustRelationship.getSpMetaDataSourceType() == GluuMetadataSourceType.FILE); if (!isPartOfFederation) { // Set Id trustIds.put(trustRelationship.getInum(), String.valueOf(id++)); // Set entityId String idpMetadataFolder = applicationConfiguration.getShibboleth2IdpRootDir() + File.separator + SHIB3_IDP_METADATA_FOLDER + File.separator; File metadataFile = new File(idpMetadataFolder + trustRelationship.getSpMetaDataFN()); List<String> entityIds = SAMLMetadataParser.getEntityIdFromMetadataFile(metadataFile); // if for some reason metadata is corrupted or missing - mark // trust relationship INACTIVE // user will be able to fix this in UI if (entityIds == null) { trustRelationship.setStatus(GluuStatus.INACTIVE); TrustService.instance().updateTrustRelationship(trustRelationship); continue; } trustEntityIds.put(trustRelationship.getInum(), entityIds); try { filterService.parseFilters(trustRelationship); ProfileConfigurationService.instance().parseProfileConfigurations(trustRelationship); } catch (Exception e) { log.error("Failed to parse stored metadataFilter configuration for trustRelationship " + trustRelationship.getDn(), e); } if (trustRelationship.getMetadataFilters().get("signatureValidation") != null) { Map<String, String> trustEngine = new HashMap<String, String>(); trustEngine.put("id", "Trust" + StringHelper.removePunctuation(trustRelationship.getInum())); trustEngine.put("certPath", applicationConfiguration.getShibboleth2IdpRootDir() + File.separator + SHIB3_IDP_METADATA_FOLDER + File.separator + "credentials" + File.separator + trustRelationship.getMetadataFilters().get("signatureValidation") .getFilterCertFileName()); trustEngines.add(trustEngine); } // If there is an intrusive filter - push it to the end of the // list. if (trustRelationship.getGluuSAMLMetaDataFilter() != null) { List<String> filtersList = new ArrayList<String>(); String entityRoleWhiteList = null; for (String filterXML : trustRelationship.getGluuSAMLMetaDataFilter()) { Document xmlDocument = null; try { xmlDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new java.io.ByteArrayInputStream(filterXML.getBytes())); } catch (Exception e) { log.error("GluuSAMLMetaDataFilter contains invalid value.", e); continue; } if (xmlDocument.getFirstChild().getAttributes().getNamedItem("xsi:type").getNodeValue() .equals(FilterService.ENTITY_ROLE_WHITE_LIST_TYPE)) { entityRoleWhiteList = filterXML; continue; } filtersList.add(filterXML); } if (entityRoleWhiteList != null) { filtersList.add(entityRoleWhiteList); } trustRelationship.setGluuSAMLMetaDataFilter(filtersList); } } else { String federationInum = trustRelationship.getContainerFederation().getInum(); if (deconstructedMap.get(federationInum) == null) { deconstructedMap.put(federationInum, new ArrayList<String>()); } deconstructedMap.get(federationInum).add(trustRelationship.getEntityId()); deconstructed.add(trustRelationship); deconstructedIds.put(trustRelationship.getEntityId(), String.valueOf(id++)); } } for (String trustRelationshipInum : trustEntityIds.keySet()) { List<String> federatedSites = deconstructedMap.get(trustRelationshipInum); if (federatedSites != null) { trustEntityIds.get(trustRelationshipInum).removeAll(federatedSites); } } trustParams.put("idpCredentialsPath", applicationConfiguration.getShibboleth2IdpRootDir() + File.separator + SHIB3_IDP_METADATA_FOLDER + File.separator + "credentials" + File.separator); trustParams.put("deconstructed", deconstructed); trustParams.put("deconstructedIds", deconstructedIds); trustParams.put("trustEngines", trustEngines); trustParams.put("trusts", trustRelationships); trustParams.put("trustIds", trustIds); trustParams.put("trustEntityIds", trustEntityIds); return trustParams; }
From source file:org.gvnix.flex.FlexOperationsImpl.java
private void updateDependencies() { InputStream templateInputStream = FileUtils.getInputStream(getClass(), "dependencies.xml"); Validate.notNull(templateInputStream, "Could not acquire dependencies.xml file"); Document dependencyDoc; try {// w w w . j a va 2 s .c o m dependencyDoc = XmlUtils.getDocumentBuilder().parse(templateInputStream); } catch (Exception e) { throw new IllegalStateException(e); } Element dependenciesElement = (Element) dependencyDoc.getFirstChild(); List<Dependency> dependencies = new ArrayList<Dependency>(); List<Element> flexDependencies = XmlUtils.findElements("/dependencies/springFlex/dependency", dependenciesElement); for (Element dependency : flexDependencies) { dependencies.add(new Dependency(dependency)); } this.projectOperations.addDependencies(projectOperations.getFocusedModuleName(), dependencies); this.projectOperations.addProperty(projectOperations.getFocusedModuleName(), new Property("flex.version", "4.1.0.16248")); fixBrokenFlexDependency(); this.projectOperations.updateProjectType(projectOperations.getFocusedModuleName(), ProjectType.WAR); }
From source file:org.gvnix.flex.FlexOperationsImpl.java
private void configureFlexBuild() { this.metadataService.get(ProjectMetadata.getProjectIdentifier(projectOperations.getFocusedModuleName())); Repository externalRepository = new Repository("spring-external", "Spring External Repository", "http://maven.springframework.org/external"); if (!projectOperations.getFocusedModule().isRepositoryRegistered(externalRepository)) { this.projectOperations.addRepository(projectOperations.getFocusedModuleName(), externalRepository); }// ww w .j a v a2 s .co m Repository flexRepository = new Repository("flex", "Sonatype Flex Repo", "http://repository.sonatype.org/content/groups/flexgroup"); if (!projectOperations.getFocusedModule().isRepositoryRegistered(flexRepository)) { this.projectOperations.addRepository(projectOperations.getFocusedModuleName(), flexRepository); } if (!projectOperations.getFocusedModule().isPluginRepositoryRegistered(flexRepository)) { this.projectOperations.addPluginRepository(projectOperations.getFocusedModuleName(), flexRepository); } // Tag repository of spring flex to download blazeds // 4.0.0.14931 dependencies Repository springFlexRepository = new Repository("spring-flex", "Spring Flex Repository", "https://github.com/SpringSource/spring-flex/raw/spring-flex-1.5.1.RC5/local-repo"); if (!projectOperations.getFocusedModule().isRepositoryRegistered(springFlexRepository)) { this.projectOperations.addRepository(projectOperations.getFocusedModuleName(), springFlexRepository); } // gvNIX repositoy to download Flex addon annotations dependency Repository gvNixRepository = new Repository("gvnix", "gvNIX Repository", "https://gvnix.googlecode.com/svn/repo"); if (!projectOperations.getFocusedModule().isRepositoryRegistered(gvNixRepository)) { this.projectOperations.addRepository(projectOperations.getFocusedModuleName(), gvNixRepository); } InputStream templateInputStream = FileUtils.getInputStream(getClass(), "plugins.xml"); Validate.notNull(templateInputStream, "Could not acquire plugins.xml file"); Document pluginDoc; try { pluginDoc = XmlUtils.getDocumentBuilder().parse(templateInputStream); } catch (Exception e) { throw new IllegalStateException(e); } Element pluginsElement = (Element) pluginDoc.getFirstChild(); List<Element> flexPlugins = XmlUtils.findElements("/plugins/springFlex/plugin", pluginsElement); for (Element pluginElement : flexPlugins) { // TODO - this is a temporary hack - currently it's the only easy // way to update an existing plugin Plugin flexPlugin = new Plugin(pluginElement); if (projectOperations.getFocusedModule().isBuildPluginRegistered(flexPlugin)) { this.projectOperations.removeBuildPlugin(projectOperations.getFocusedModuleName(), flexPlugin); } this.projectOperations.addBuildPlugin(projectOperations.getFocusedModuleName(), flexPlugin); } fixBrokenFlexPlugin(); String flexPropertiesFileId = getPathResolver().getIdentifier(LogicalPath.getInstance(Path.ROOT, ""), ".flexProperties"); if (!this.fileManager.exists(flexPropertiesFileId)) { StringTemplate flexPropertiesTemplate = this.templateGroup .getInstanceOf(TEMPLATE_PATH + "/flex_properties"); flexPropertiesTemplate.setAttribute("projectName", projectOperations.getProjectName(projectOperations.getFocusedModuleName())); this.fileManager.createOrUpdateTextFileIfRequired(flexPropertiesFileId, flexPropertiesTemplate.toString(), true); } String actionScriptPropertiesFiledId = getPathResolver() .getIdentifier(LogicalPath.getInstance(Path.ROOT, ""), ".actionScriptProperties"); if (!this.fileManager.exists(actionScriptPropertiesFiledId)) { StringTemplate actionScriptPropertiesTemplate = this.templateGroup .getInstanceOf(TEMPLATE_PATH + "/actionscript_properties"); actionScriptPropertiesTemplate.setAttribute("projectName", projectOperations.getProjectName(projectOperations.getFocusedModuleName())); actionScriptPropertiesTemplate.setAttribute("projectUUID", UUID.randomUUID()); this.fileManager.createOrUpdateTextFileIfRequired(actionScriptPropertiesFiledId, actionScriptPropertiesTemplate.toString(), true); } }