Get LEP script resource.

@param location {@code /config/tenant/{tenant-key}/{ms-name}/lep/a/b/c/SomeScript.groovy}
@return the LEP script resource
974583
@Override
    public Resource getResource(String location) {
        String cfgPath = StringUtils.removeStart(location, XM_MS_CONFIG_URL_PREFIX);
        return scriptResources.getOrDefault(cfgPath, XmLepScriptResource.nonExist());
    }
233051
public URI getLocation() {
        if (locationURI == null) {
            locationURI = moduleRef != null ? moduleRef.getLocation() : null;
            if (locationURI == null) {
                locationURI = classpathElement.getURI();
            }
        }
        return locationURI;
    }
1285371
public ResourceAddress newResourceAddress(String location, ResourceOptions options) {
        return newResourceAddress(location, options, null /* qualifier */);
    }
187058
ExecutionLocation getLocation(ParserRuleContext object) {
    Token start = object.getStart();
    return new ExecutionLocation(currentScope.declaringEnvironment.path, start.getLine(), start.getCharPositionInLine() + 1);
  }
967834
public static void validateScriptsCombination(Set<XmLepResourceSubType> scriptTypes,
                                                  LepMethod lepMethod,
                                                  UrlLepResourceKey compositeResourceKey) {
        byte mask = getCombinationMask(scriptTypes, lepMethod, compositeResourceKey);

        StringBuilder errors = new StringBuilder();
        if (isZero(mask, ZERO_PATTERN_NO_TENANT_AND_DEFAULT_AND_JAVA_CODE)) {
            errors.append(String.format("Has no one script of '%s', '%s' or native (java) implementation.",
                                        XmLepResourceSubType.TENANT, XmLepResourceSubType.DEFAULT));
        }

        if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_BEFORE)) {
            if (errors.length() > 0) {
                errors.append(" ");
            }

            errors.append(String.format("Has '%s' script with '%s'.", XmLepResourceSubType.BEFORE, XmLepResourceSubType.AROUND));
        }

        if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_AFTER)) {
            if (errors.length() > 0) {
                errors.append(" ");
            }

            errors.append(String.format("Has '%s' script with '%s'.", XmLepResourceSubType.AROUND, XmLepResourceSubType.AFTER));
        }

        if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_TENANT)) {
            if (errors.length() > 0) {
                errors.append(" ");
            }

            errors.append(String.format("Unallowed combination '%s' and '%s' scripts.", XmLepResourceSubType.AROUND, XmLepResourceSubType.TENANT));
        }

        if (errors.length() > 0) {
            throw new IllegalArgumentException(String.format("Resource key %s has script combination errors. %s",
                                                             compositeResourceKey,
                                                             errors.toString()));

        }
    }
334918
public RepositoryLogRecord getRecord(RepositoryPointer location) {
		if (!(location instanceof RepositoryPointerImpl)) {
			return null;
		}
		RepositoryPointerImpl real = (RepositoryPointerImpl)location;
		long pos = real.getRecordOffset();
		File file = fileBrowser.findFile(real);
		if (pos < 0 || file == null) {
			return null;
		}
		OneFileRecordIterator current = new OneFileRecordIterator(file, -1, new AllAcceptVerifier());
		RepositoryLogRecord rec = null;
		if (current.setPosition(pos)) {
			rec = current.next();
		}
		current.close();
		if (rec != null && real.equals(rec.getRepositoryPointer())) {
			return rec;
		} 		
		
		return null;
		
	}
1127435
public static ScriptFactory getScriptFactory() {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    if (processEngineConfiguration != null) {
      return processEngineConfiguration.getScriptFactory();
    }
    else {
      return new ScriptFactory();
    }
  }
430617
def _get_location(cli_ctx, namespace):
    
    location = None
    if getattr(namespace, 'location', None):
        location = namespace.location
    elif getattr(namespace, 'resource_group_name', None):
        location = _get_location_from_resource_group(cli_ctx, namespace.resource_group_name)
    if not location:
        location = get_one_of_subscription_locations(cli_ctx)
    return location
1151639
public static ResourceBundle getResourceBundle(File location, String name, Locale locale) {
        File[] files = new File[] { new File(location, name + "_" + locale.toString() + RESOURCE_FILE_EXT),
                                   new File(location, name + "_" + locale.getLanguage() + RESOURCE_FILE_EXT),
                                   new File(location, name + RESOURCE_FILE_EXT) };
        for (File file : files) {
            if (exists(file)) {
                try {
                    return new PropertyResourceBundle(new FileReader(file));
                } catch (IOException e) {
                    if (logger.isLoggable(Level.FINE)) {
                        logger.fine("The resource file was not loaded. The exception is " + e.getMessage());
                    }
                }
            }
        }
        return null;
    }
881156
@Nullable
  public static Location getParent(Location location) {
    URI source = location.toURI();

    // If it is root, return null
    if ("/".equals(source.getPath())) {
      return null;
    }

    URI resolvedParent = URI.create(source.toString() + "/..").normalize();
    return location.getLocationFactory().create(resolvedParent);
  }
571337
public static String resourceFileToString(final String location, final String fileName) {
        if (location == null || fileName == null) return null;

        final InputStream in = ResourceUtilities.class.getResourceAsStream(location + fileName);
        if (in == null) return null;

        final BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String line;
        final StringBuilder output = new StringBuilder("");
        try {
            while ((line = br.readLine()) != null) {
                output.append(line + "\n");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                LOG.error("Failed to close the InputStream", e);
            }
            try {
                br.close();
            } catch (IOException e) {
                LOG.error("Failed to close the BufferedReader", e);
            }
        }
        return output.toString();
    }
382305
public static Optional<CuratorFramework> getCuratorForLocation(URI location) {
        final String defaultConnectionString;
        final String namespace;

        if (getLocationType(location) != LocationType.EMO_HOST_DISCOVERY) {
            // Only host discovery may require ZooKeeper
            return Optional.absent();
        }

        if (getHostOverride(location).isPresent()) {
            // Fixed host discovery doesn't require ZooKeeper
            return Optional.absent();
        }

        Matcher matcher = getLocatorMatcher(location);
        checkArgument(matcher.matches(), "Invalid location: %s", location);

        if (matcher.group("universe") != null) {
            // Normal host discovery
            String universe = matcher.group("universe");
            Region region = getRegion(Objects.firstNonNull(matcher.group("region"), DEFAULT_REGION));
            namespace = format("%s/%s", universe, region);
            defaultConnectionString = DEFAULT_ZK_CONNECTION_STRING;
        } else {
            // Local host discovery; typically for developer testing
            namespace = null;
            defaultConnectionString = DEFAULT_LOCAL_ZK_CONNECTION_STRING;
        }

        String connectionString = getZkConnectionStringOverride(location).or(defaultConnectionString);

        CuratorFramework curator = CuratorFrameworkFactory.builder()
                .ensembleProvider(new ResolvingEnsembleProvider(connectionString))
                .retryPolicy(new BoundedExponentialBackoffRetry(100, 1000, 10))
                .threadFactory(new ThreadFactoryBuilder().setNameFormat("emo-zookeeper-%d").build())
                .namespace(namespace)
                .build();

        curator.start();

        return Optional.of(curator);
    }
818162
public @Nullable ScriptType getScriptType() {
        if (ScriptPattern.isP2PKH(this))
            return ScriptType.P2PKH;
        if (ScriptPattern.isP2PK(this))
            return ScriptType.P2PK;
        if (ScriptPattern.isP2SH(this))
            return ScriptType.P2SH;
        if (ScriptPattern.isP2WPKH(this))
            return ScriptType.P2WPKH;
        if (ScriptPattern.isP2WSH(this))
            return ScriptType.P2WSH;
        return null;
    }
558323
private ScriptExecutor createScriptExecutor() {
        String className = null;
        ClassLoader loader = ScriptExecutor.class.getClassLoader();

        // 1. try the JVM-instance-wide system property
        try {
            className = System.getProperty(property);
        } catch (RuntimeException e) { /* normally fails for applets */
        }

        // 2. if that fails, try META-INF/services/
        if (StringUtils.isEmpty(className)) {
            try {
                String service = "META-INF/services/" + property;
                InputStream in;
                BufferedReader reader;

                if (loader == null) {
                    in = ClassLoader.getSystemResourceAsStream(service);
                } else {
                    in = loader.getResourceAsStream(service);
                }

                if (in != null) {
                    reader = new BufferedReader(new InputStreamReader(in, System.getProperty("file.encoding", "UTF-8")));
                    className = reader.readLine();
                    in.close();
                }
            } catch (Exception e) {
            }
        }

        // 3. Distro-specific fallback
        if (className == null) {
            className = DEFAULT_SCRIPT;
        }

        Class clazz = ReflectionHelper.forName(className, loader);
        return (ScriptExecutor) ReflectionHelper.newInstance(clazz);
    }
401393
public static InputStream getRequiredResourceAsStream(Class<?> clzz, String location) {
        InputStream resourceStream = clzz.getResourceAsStream(location);

        if (resourceStream == null) {
            // Try with a leading "/"
            if (!location.startsWith("/")) {
                resourceStream = clzz.getResourceAsStream("/" + location);
            }
            if (resourceStream == null) {
                throw new RuntimeException("Resource file was not found at location " + location);
            }
        }

        return resourceStream;
    }
534670
private String getScriptAddress(@Nullable Script script) {
        String address = "";
        try {
            if (script != null) {
                address = script.getToAddress(params, true).toString();
            }
        } catch (Exception e) {
        }
        return address;
    }
1342810
public static ExecutableScript parseCamundaScript(Element scriptElement) {
    String scriptLanguage = scriptElement.attribute("scriptFormat");
    if (scriptLanguage == null || scriptLanguage.isEmpty()) {
      throw new BpmnParseException("Missing attribute 'scriptFormatAttribute' for 'script' element", scriptElement);
    }
    else {
      String scriptResource = scriptElement.attribute("resource");
      String scriptSource = scriptElement.getText();
      try {
        return ScriptUtil.getScript(scriptLanguage, scriptSource, scriptResource, getExpressionManager());
      }
      catch (ProcessEngineException e) {
        throw new BpmnParseException("Unable to process script", scriptElement, e);
      }
    }
  }