/* (non-Javadoc)
@see org.apereo.portal.rendering.xslt.TransformerConfigurationSource#getTransformerConfigurationKey(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
328820
@Override
    public final CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
        final CacheKeyBuilder<String, String> cacheKeyBuilder = CacheKey.builder(getName());

        final PreferencesScope stylesheetPreferencesScope =
                this.getStylesheetPreferencesScope(request);

        this.stylesheetUserPreferencesService.populateStylesheetParameters(
                request, stylesheetPreferencesScope, cacheKeyBuilder);

        this.stylesheetUserPreferencesService.populateOutputProperties(
                request, stylesheetPreferencesScope, cacheKeyBuilder);

        return cacheKeyBuilder.build();
    }
497007
public static XslTransformer getTransformer(File xslFile) throws TransformerConfigurationException {
    	if (xslFile == null) {
    		throw new IllegalArgumentException("xslFile is null");
    	}
        return getTransformer(new StreamSource(xslFile));
    }
113145
@Override
  public Config getResolvedConfig(final ConfigKeyPath configKey) {
    return getResolvedConfig(configKey, Optional.<Config>absent());
  }
1255491
@Override
	public String generateKey(HttpServletRequest request) {
		boolean exportNames = TypeUtil.asBoolean(request
				.getAttribute(IHttpTransport.EXPORTMODULENAMES_REQATTRNAME));
		return eyecatcher + ":" + (exportNames ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	}
1310269
public static Transformer newTransformer(Source source, JstlUriResolver uriResolver) throws TransformerConfigurationException {
        TRANSFORMER_FACTORY.setURIResolver(uriResolver);
        Transformer transformer = TRANSFORMER_FACTORY.newTransformer(source);
        // Although newTansformer() is not allowed to return null, Xalan does.
        // Trap that here by throwing the expected TransformerConfigurationException.
        if (transformer == null) {
            throw new TransformerConfigurationException("newTransformer returned null. XSLT may be invalid.");
        }
        return transformer;
    }
1082726
public static transformglobal_binding get(nitro_service service) throws Exception{
		transformglobal_binding obj = new transformglobal_binding();
		transformglobal_binding response = (transformglobal_binding) obj.get_resource(service);
		return response;
	}
541507
function getTransformCacheKey(opts: {|
  +cacheVersion: string,
  +projectRoot: string,
  +transformerConfig: TransformerConfig,
|}): string {
  const {transformerPath, transformerConfig} = opts.transformerConfig;

  // eslint-disable-next-line lint/flow-no-fixme
  /* $FlowFixMe: dynamic requires prevent static typing :'(  */
  const Transformer = require(transformerPath);
  const transformerInstance = new Transformer(
    opts.projectRoot,
    transformerConfig,
  );

  const transformerKey =
    typeof transformerInstance.getCacheKey !== 'undefined'
      ? transformerInstance.getCacheKey()
      : '';

  const cacheKeyParts = [
    'metro-cache',
    VERSION,
    opts.cacheVersion,
    path.relative(path.join(__dirname, '../../../..'), opts.projectRoot),
    getKeyFromFiles([require.resolve(transformerPath)]),
    transformerKey,
  ];

  return crypto
    .createHash('sha1')
    .update(cacheKeyParts.join('$'))
    .digest('hex');
}
1004616
String getTransformationPath() {

        String path = System.getProperty("opencms.config.transform");
        if (path == null) {
            path = CmsStringUtil.joinPaths(m_baseFolder.getAbsolutePath(), DEFAULT_XSLT_FILENAME);
        }
        return path;
    }
719
public synchronized Map<String, Object> getConfiguration(String key) {
		return Optional.ofNullable(inventory.get(key))
				.flatMap(v->v.getConfiguration())
				.map(v->v.getMap())
				.orElse(null);
	}
105120
@Override
    public CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
        final CacheKey parentKey = this.wrappedComponent.getCacheKey(request, response);
        final CacheKey attributeKey = this.attributeSource.getCacheKey(request, response);
        return CacheKey.build(this.beanName, parentKey, attributeKey);
    }
1219775
public static synchronized String getProperty(String key, boolean required) {
		if (mProperties == null) {
			mProperties = initializeConfigurationProperties();
		}
		String value = mProperties.getProperty(key);
		if (value == null && required) {
			throw new RuntimeException("Property not found: " + key);
		}
		return value;
	}
957356
public static String convertToJavaIdentifier( String key, JsonConfig jsonConfig ) {
      try{
         return jsonConfig.getJavaIdentifierTransformer()
               .transformToJavaIdentifier( key );
      }catch( JSONException jsone ){
         throw jsone;
      }catch( Exception e ){
         throw new JSONException( e );
      }
   }
775086
private static Transformer newTransformer() {

		if (TEMPLATES == null) {
			throw new IllegalStateException("TransformXMLInterceptor not initialized.");
		}

		try {
			return TEMPLATES.newTransformer();
		} catch (TransformerConfigurationException ex) {
			throw new SystemException("Could not create transformer for " + RESOURCE_NAME, ex);
		}
	}
1201300
protected CmsContainerElementBean transformContainerElement(
        CmsObject cms,
        CmsTemplateMapperConfiguration config,
        CmsContainerElementBean element) {

        if (m_forSave) {
            try {
                element.initResource(cms);
            } catch (Exception e) {
                LOG.error(e.getLocalizedMessage(), e);
                return null;
            }
        }
        Map<String, String> settings = element.getIndividualSettings();
        if (settings == null) {
            settings = new HashMap<>();
        }
        Map<String, String> newSettings = new HashMap<>();
        for (Map.Entry<String, String> entry : settings.entrySet()) {
            String key = entry.getKey();
            if (CmsTemplateContextInfo.SETTING.equals(key)) {
                continue;
            }
            String value = entry.getValue();
            if (value == null) {
                continue;
            }
            String newValue = value;
            if (key.startsWith(CmsFormatterConfig.FORMATTER_SETTINGS_KEY)) {
                if (CmsUUID.isValidUUID(value)) {
                    String newId = config.getMappedFormatterConfiguration(value);
                    if (newId != null) {
                        newValue = newId;
                    }
                } else if (value.startsWith(CmsFormatterConfig.SCHEMA_FORMATTER_ID)) {
                    String schemaFormatterIdStr = value.substring(CmsFormatterConfig.SCHEMA_FORMATTER_ID.length());
                    if (CmsUUID.isValidUUID(schemaFormatterIdStr)) {
                        CmsUUID schemaFormatterId = new CmsUUID(schemaFormatterIdStr);
                        CmsUUID mappedFormatterId = config.getMappedFormatterJspId(schemaFormatterId);
                        if (mappedFormatterId != null) {
                            newValue = CmsFormatterConfig.SCHEMA_FORMATTER_ID + mappedFormatterId;
                        }
                    }
                }
            }
            newSettings.put(key, newValue);
        }
        CmsContainerElementBean newElement = element.clone();
        newElement.updateIndividualSettings(newSettings);
        CmsUUID formatterId = element.getFormatterId();
        if ((formatterId == null) && m_forSave) {
            try {
                if (element.isGroupContainer(cms)) {
                    // ID for group-container.jsp
                    formatterId = new CmsUUID("e7029fa2-761e-11e0-bd7f-9ffeadaf4d46");
                    newElement.setFormatterId(formatterId);
                } else if (OpenCms.getResourceManager().matchResourceType(
                    "function",
                    element.getResource().getTypeId())) {
                    formatterId = new CmsUUID("087ba7c9-e7fc-4336-acb8-d3416a4eb1fd");
                    newElement.setFormatterId(formatterId);
                }
            } catch (CmsException e) {
                LOG.warn(e.getLocalizedMessage(), e);
            }
        }
        CmsUUID mappedFormatterJspId = config.getMappedFormatterJspId(formatterId);
        if (mappedFormatterJspId != null) {
            newElement.setFormatterId(mappedFormatterJspId);
        }
        return newElement;
    }
274181
private Transformer createTransformer(boolean indent) {

    try {
      Transformer result = this.transformerFactory.newTransformer();
      if (indent) {
        result.setOutputProperty(OutputKeys.INDENT, "yes");
      }
      return result;
    } catch (TransformerConfigurationException e) {
      throw new IllegalStateException("XML Transformer misconfigured!" + " Probably your JVM does not support the required JAXP version!", e);
    }
  }
1262141
private String transformKey(String key, String src, String tgt) {
        StringBuilder sb = new StringBuilder();
        String[] srcTokens = src.split(WILDCARD_DELIM_REGEX);
        String[] tgtTokens = tgt.split(WILDCARD_DELIM_REGEX);
        int len = Math.max(srcTokens.length, tgtTokens.length);
        int pos = 0;
        int start = 0;
        
        for (int i = 0; i <= len; i++) {
            String srcx = i >= srcTokens.length ? "" : srcTokens[i];
            String tgtx = i >= tgtTokens.length ? "" : tgtTokens[i];
            pos = i == len ? key.length() : pos;
            
            if ("*".equals(srcx) || "?".equals(srcx)) {
                start = pos;
            } else {
                pos = key.indexOf(srcx, pos);
                
                if (pos > start) {
                    sb.append(key.substring(start, pos));
                }
                
                start = pos += srcx.length();
                sb.append(tgtx);
            }
            
        }
        
        return sb.toString();
    }
281085
public Transformer getTransformer(HttpServletRequest req, ServletTask servletTask, ScreenModel screen)
            throws ServletException, IOException
    {
        String stylesheet = null;
        if (stylesheet == null)
            stylesheet = req.getParameter(DBParams.TEMPLATE);
        if (stylesheet == null)
            if (screen != null)
                if (screen.getScreenFieldView() != null)
                    stylesheet = screen.getScreenFieldView().getStylesheetPath();
        if (stylesheet == null)
            stylesheet = req.getParameter("stylesheet");
        if (stylesheet == null)
            stylesheet = "org/jbundle/res/docs/styles/xsl/flat/base/menus";
        
        try {
            if (hmTransformers.get(stylesheet) != null)
                return hmTransformers.get(stylesheet);
            String stylesheetFixed = BaseServlet.fixStylesheetPath(stylesheet, screen, true);
            
            InputStream stylesheetStream = this.getFileStream(servletTask, stylesheetFixed, null);
            if (stylesheetStream == null)
            {
                stylesheetFixed = BaseServlet.fixStylesheetPath(stylesheet, screen, false);  // Try it without browser mod
                stylesheetStream = this.getFileStream(servletTask, stylesheetFixed, null);
            }
            if (stylesheetStream == null)
                Utility.getLogger().warning("XmlFile not found " + stylesheetFixed);   // TODO - Display an error here
            StreamSource stylesheetSource = new StreamSource(stylesheetStream);
            
            if (tFact == null)
                tFact = TransformerFactory.newInstance();
            URIResolver resolver = new MyURIResolver(servletTask, stylesheetFixed);
            tFact.setURIResolver(resolver);
            Transformer transformer = tFact.newTransformer(stylesheetSource);
            //transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            //transformer.setOutputProperty(OutputKeys.METHOD, "xml");
            hmTransformers.put(stylesheet, transformer);
            return transformer;
        } catch (TransformerConfigurationException ex)    {
            ex.printStackTrace();
        }
        return null;
    }