private String getSwaggerRegistryPath(String swaggerDocName, String serviceProvider) { String pathExpression = Utils.getRxtService().getStoragePath(CommonConstants.SWAGGER_MEDIA_TYPE); pathExpression = CommonUtil.getPathFromPathExpression( pathExpression, requestContext.getResource().getProperties(), null); pathExpression = CommonUtil.replaceExpressionOfPath(pathExpression, "provider", serviceProvider); swaggerResourcesPath = pathExpression; pathExpression = CommonUtil.replaceExpressionOfPath(pathExpression, "name", swaggerDocName); String swaggerPath = pathExpression; /** * Fix for the REGISTRY-3052 : validation is to check the whether this invoked by * ZIPWSDLMediaTypeHandler Setting the registry and absolute paths to current session to avoid * incorrect resource path entry in REG_LOG table */ if (CurrentSession.getLocalPathMap() != null && !Boolean.valueOf( CurrentSession.getLocalPathMap().get(CommonConstants.ARCHIEVE_UPLOAD))) { swaggerPath = CommonUtil.getRegistryPath( requestContext.getRegistry().getRegistryContext(), pathExpression); if (log.isDebugEnabled()) { log.debug( "Saving current session local paths, key: " + swaggerPath + " | value: " + pathExpression); } CurrentSession.getLocalPathMap().put(swaggerPath, pathExpression); } return swaggerPath; }
public static boolean removeHandler(Registry configSystemRegistry, String handlerName) throws RegistryException, XMLStreamException { String handlerConfiguration = getHandlerConfiguration(configSystemRegistry, handlerName); if (handlerConfiguration != null) { OMElement element = AXIOMUtil.stringToOM(handlerConfiguration); try { try { configSystemRegistry.beginTransaction(); RegistryConfigurationProcessor.HandlerDefinitionObject handlerDefinitionObject = new RegistryConfigurationProcessor.HandlerDefinitionObject(null, element).invoke(); String[] methods = handlerDefinitionObject.getMethods(); Filter filter = handlerDefinitionObject.getFilter(); Handler handler = handlerDefinitionObject.getHandler(); if (handlerDefinitionObject.getTenantId() != -1) { CurrentSession.setCallerTenantId(handlerDefinitionObject.getTenantId()); // We need to swap the tenant id for this call, if the handler has overriden the // default value. configSystemRegistry .getRegistryContext() .getHandlerManager() .removeHandler( methods, filter, handler, HandlerLifecycleManager.USER_DEFINED_HANDLER_PHASE); CurrentSession.removeCallerTenantId(); } else { configSystemRegistry .getRegistryContext() .getHandlerManager() .removeHandler( methods, filter, handler, HandlerLifecycleManager.USER_DEFINED_HANDLER_PHASE); } configSystemRegistry.commitTransaction(); return true; } catch (Exception e) { configSystemRegistry.rollbackTransaction(); throw e; } } catch (Exception e) { if (e instanceof RegistryException) { throw (RegistryException) e; } else if (e instanceof XMLStreamException) { throw (XMLStreamException) e; } throw new RegistryException("Unable to build handler configuration", e); } } return false; }
/** * Method to register a system resource (or collection) path. * * @param absolutePath the absolute path of the system resource (or collection) */ public void registerSystemResourcePath(String absolutePath) { systemResourcePaths.add(CurrentSession.getTenantId() + ":" + absolutePath); }
/** * Method to determine whether a system resource (or collection) path has been registered. * * @param absolutePath the absolute path of the system resource (or collection) * @return true if the system resource (or collection) path is registered or false if not. */ public boolean isSystemResourcePathRegistered(String absolutePath) { return systemResourcePaths.contains(CurrentSession.getTenantId() + ":" + absolutePath); }
public ByteArrayOutputStream execute(String template, String type) throws IOException { Registry governanceRegistry; try { Registry registry = getRegistry(); governanceRegistry = GovernanceUtils.getGovernanceUserRegistry(registry, CurrentSession.getUser()); GenericArtifactManager suiteArtifactManager = new GenericArtifactManager(governanceRegistry, "suites"); GenericArtifact[] genericArtifacts = suiteArtifactManager.getAllGenericArtifacts(); GenericArtifactManager caseArtifactManager = new GenericArtifactManager(governanceRegistry, "case"); List<TestSuiteReportBean> beanList = new LinkedList<TestSuiteReportBean>(); for (GenericArtifact artifact : genericArtifacts) { TestSuiteReportBean bean = new TestSuiteReportBean(); String[] attributeKeys = artifact.getAttributeKeys(); List<String> testCases = new ArrayList<String>(); for (String key : attributeKeys) { if (key.equals("overview_name")) { String value = artifact.getAttribute(key); bean.setOverview_name(value); } else if (key.equals("overview_version")) { String value = artifact.getAttribute(key); bean.setOverview_version(value); } else if (key.equals("overview_type")) { String value = artifact.getAttribute(key); bean.setOverview_type(value); } if (key.equals("testCases_entry")) { String[] values = artifact.getAttributes(key); for (String value : values) { Resource r = registry.get( RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + value.split(":")[1]); GenericArtifact a = caseArtifactManager.getGenericArtifact(r.getUUID()); testCases.add(a.getAttribute("overview_name")); } } } bean.setTestCases_entry(testCases.toString().replaceAll("[ \\[\\] ]", "")); beanList.add(bean); } String templateContent = new String((byte[]) registry.get(template).getContent()); JRDataSource dataSource = new JRBeanCollectionDataSource(beanList); JasperPrint print = new JasperPrintProvider() .createJasperPrint(dataSource, templateContent, new ReportParamMap[0]); return new ReportStream().getReportStream(print, type.toLowerCase()); } catch (RegistryException e) { log.error("Error while getting the Governance Registry", e); } catch (JRException e) { log.error("Error occured while creating the jasper print ", e); } catch (ReportingException e) { log.error("Error while generating the report", e); } return new ByteArrayOutputStream(0); }