Builds a DOM response.

@param availableResources
list of resources to include in the output
@return streaming output
760553
public static StreamingOutput buildDOMResponse(final List<String> availableResources) {

        try {
            final Document document = createSurroundingXMLResp();
            final Element resElement = createResultElement(document);

            final List<Element> resources = createCollectionElement(availableResources, document);
            for (final Element resource : resources) {
                resElement.appendChild(resource);
            }
            document.appendChild(resElement);
            return createStream(document);
        } catch (final ParserConfigurationException exc) {
            throw new JaxRxException(exc);
        }
    }
689258
private TargetStream createStream(StreamSet streamSet,
                                    int priority,
                                    Reliability reliability,
                                    long completedPrefix)

                                    throws SIResourceException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(
        tc,
        "createStream",
        new Object[] { streamSet, Integer.valueOf(priority), reliability, Long.valueOf(completedPrefix) });

    TargetStream stream = null;
    stream = createStream(streamSet, priority, reliability);
    stream.setCompletedPrefix(completedPrefix);

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "createStream");

    return stream;
  }
162036
private void parseResources(Element element, BeanDefinitionBuilder builder,
                                ManagedList<AbstractBeanDefinition> resourceList) {
        NodeList resources = element.getChildNodes();

        for (int i = 0; i < resources.getLength(); i++) {
            Node node = resources.item(i);

            if (!(node instanceof Element)) {
                continue;
            }

            Element resource = (Element) resources.item(i);
            Class<? extends IPluginResource> resourceClass = null;

            switch (getResourceType(getNodeName(resource))) {
                case button:
                    resourceClass = PluginResourceButton.class;
                    break;
                
                case help:
                    resourceClass = PluginResourceHelp.class;
                    break;
                
                case menu:
                    resourceClass = PluginResourceMenu.class;
                    break;
                
                case property:
                    resourceClass = PluginResourcePropertyGroup.class;
                    break;
                
                case css:
                    resourceClass = PluginResourceCSS.class;
                    break;
                
                case bean:
                    resourceClass = PluginResourceBean.class;
                    break;
                
                case command:
                    resourceClass = PluginResourceCommand.class;
                    break;
                
                case action:
                    resourceClass = PluginResourceAction.class;
                    break;
            }

            if (resourceClass != null) {
                BeanDefinitionBuilder resourceBuilder = BeanDefinitionBuilder.genericBeanDefinition(resourceClass);
                addProperties(resource, resourceBuilder);
                resourceList.add(resourceBuilder.getBeanDefinition());
            }
        }
    }
478177
public static InputStream getResource2(String uri) {
    try {
      // If -Dwebdev=1 is set in VM args, we're in front end dev mode, so skip the class loader.
      // This is to allow the front end scripts/styles/templates to be loaded from the build
      //  directory during development.

      // Try all registered locations
      for( File f : RESOURCE_FILES ) {
        File f2 = new File(f,uri);
        if( f2.exists() )
          return new FileInputStream(f2);
      }

      // Fall through to jar file mode.
      ClassLoader cl = ClassLoader.getSystemClassLoader();
      InputStream is = loadResource(uri, cl);
      if (is == null && (cl=Thread.currentThread().getContextClassLoader())!=null) {
        is = loadResource(uri, cl);
      }
      if (is == null && (cl=JarHash.class.getClassLoader())!=null) {
        is = loadResource(uri, cl);
      }
      if (is != null) return is;

    } catch (FileNotFoundException ignore) {}

    Log.warn("Resource not found: " + uri);
    return null;
  }
472061
public InputStream getResourceAsStream(String resourceName, BeanContextChild child) throws IllegalArgumentException
	{
		if (resourceName == null || child == null)
		{
			throw new NullPointerException();
		}
		if (!contains(child))
		{
			throw new IllegalArgumentException(Messages.getString("beans.6D"));
		}

		return ClassLoader.getSystemResourceAsStream(resourceName);
	}
839400
@Override
	public InputStream getResourceAsStream(String resourceName) {
		URL url = getResourceUrl(resourceName);
		if (url != null) {
			try {
				return url.openStream();
			} catch (IOException e) {
				throw new JKException(e);
			}
		}
		return null;
	}
986208
public CmsResource buildResource() {

        return new CmsResource(
            m_structureId,
            m_resourceId,
            m_rootPath,
            m_type,
            m_flags,
            m_projectLastModified,
            m_state,
            m_dateCreated,
            m_userCreated,
            m_dateLastModified,
            m_userLastModified,
            m_dateReleased,
            m_dateExpired,
            m_length,
            m_flags,
            m_dateContent,
            m_version);
    }
739729
private StringBuffer buildResourceList(ArrayList<CmsAccessControlEntry> entries) {

        StringBuffer result = new StringBuffer(256);
        Iterator<CmsAccessControlEntry> i = entries.iterator();
        boolean hasEntries = i.hasNext();

        if (hasEntries || !getInheritOption()) {
            // create headline for resource entries
            result.append(dialogSubheadline(key(Messages.GUI_PERMISSION_TITLE_0)));
        }

        // create the internal form
        result.append(buildInternalForm());

        if (hasEntries) {
            // only create output if entries are present
            result.append(dialogSpacer());
            // open white box
            result.append(dialogWhiteBox(HTML_START));

            // list all entries
            while (i.hasNext()) {
                CmsAccessControlEntry curEntry = i.next();
                result.append(buildPermissionEntryForm(curEntry, getEditable(), false, null));
                if (i.hasNext()) {
                    result.append(dialogSeparator());
                }
            }

            // close white box
            result.append(dialogWhiteBox(HTML_END));
        }
        return result;
    }
867372
public List<Resource> buildResources() {
        List<Resource> resources = new ArrayList<Resource>();
        for (ResourceBuilder builder : _resourceBuilders) {
            Resource resource = builder.build();
            if (resource != null) {
                resources.add(resource);
            }
        }
        return resources;
    }
1336659
public ResponseBuilder ldpOptions(final Resource res) {
        final String identifier = getBaseUrl() + req.getPartition() + req.getPath();

        LOGGER.debug("OPTIONS request for {}", identifier);

        final IRI graphName = ACL.equals(req.getExt()) ? PreferAccessControl : PreferUserManaged;

        // Check if this is already deleted
        checkDeleted(res, identifier);

        final ResponseBuilder builder = status(NO_CONTENT);

        ldpResourceTypes(res.getInteractionModel()).forEach(type -> builder.link(type.getIRIString(), "type"));

        if (res.isMemento() || TIMEMAP.equals(req.getExt())) {
            // Mementos and TimeMaps are read-only
            builder.header(ALLOW, join(",", GET, HEAD, OPTIONS));
        } else {
            builder.header(ACCEPT_PATCH, APPLICATION_SPARQL_UPDATE);
            // ACL resources allow a limited set of methods (no DELETE or POST)
            // If it's not a container, POST isn't allowed
            if (PreferAccessControl.equals(graphName) || res.getInteractionModel().equals(RDFSource) ||
                    res.getInteractionModel().equals(NonRDFSource)) {
                builder.header(ALLOW, join(",", GET, HEAD, OPTIONS, PATCH, PUT, DELETE));
            } else {
                // Containers and binaries support POST
                builder.header(ALLOW, join(",", GET, HEAD, OPTIONS, PATCH, PUT, DELETE, POST));
                builder.header(ACCEPT_POST, MEDIA_TYPES.stream().map(mt -> mt.getType() + "/" + mt.getSubtype())
                        .filter(mt -> !TEXT_HTML.equals(mt)).collect(joining(",")));
            }
        }

        return builder;
    }
702711
@Override
	public InputStream getResourceAsStream(String resourceName, boolean processingBundle)
			throws ResourceNotFoundException {

		if (ThreadLocalJawrContext.isInterruptingProcessingBundle()) {
			throw new InterruptBundlingProcessException();
		}

		generatorRegistry.loadGeneratorIfNeeded(resourceName);
		InputStream is = null;

		String resourceExtension = FileNameUtils.getExtension(resourceName);
		boolean generatedPath = generatorRegistry.isPathGenerated(resourceName);
		if (generatedPath || allowedExtensions.contains(resourceExtension.toLowerCase())) {
			List<StreamResourceReader> list = new ArrayList<>();
			list.addAll(streamResourceReaders);
			for (StreamResourceReader rsReader : list) {
				if (!(rsReader instanceof ResourceGenerator)
						|| ((ResourceGenerator) rsReader).getResolver().matchPath(resourceName)) {
					try {
						is = rsReader.getResourceAsStream(resourceName);
					} catch (Exception e) {
						if (LOGGER.isDebugEnabled()) {
							LOGGER.debug("An exception occured while trying to read resource '" + resourceName
									+ "'. Continuing with other readers. Error : ", e);
						} else if (LOGGER.isInfoEnabled()) {
							LOGGER.info("An exception occured while trying to read resource '" + resourceName
									+ "'. Continuing with other readers. Error : " + e.getMessage());
						}
					}
					if (is != null) {
						break;
					}
				}
			}
		} else {
			LOGGER.warn("The resource '" + resourceName + "' will not be read as its extension is not an allowed one.");
		}
		if (is == null) {
			throw new ResourceNotFoundException(resourceName);
		}

		return is;
	}
210812
public ResponseDownloadResource toDownloadResource() {
        final ResponseDownloadResource resource = createResponseDownloadResource();
        if (contentType != null) {
            resource.contentType(contentType);
        }
        for (Entry<String, String[]> entry : headerMap.entrySet()) {
            resource.header(entry.getKey(), entry.getValue());
        }
        if (needsFileNameEncoding) {
            resource.encodeFileName(getHeaderFileNameEncoding()); // should be before content-disposition process
        }
        if (reservedHeaderContentDispositionAttachment) {
            resource.headerContentDispositionAttachment();
        }
        if (reservedHeaderContentDispositionInline) {
            resource.headerContentDispositionInline();
        }
        if (!returnAsEmptyBody && byteData == null && streamCall == null && zipStreamCall == null) {
            throwStreamByteDataInputStreamNotFoundException();
        }
        if (byteData != null) {
            resource.data(byteData);
        }
        if (streamCall != null) {
            if (contentLength != null) {
                resource.stream(streamCall, contentLength);
            } else {
                resource.stream(streamCall);
            }
        }
        if (zipStreamCall != null) {
            resource.zipStreamChunked(zipStreamCall);
        }
        if (returnAsEmptyBody) {
            resource.asEmptyBody();
        }
        return resource;
    }
1101064
public String buildResourceList() {

        // check how many resources are selected to decide using a div or not
        boolean scroll = (getResourceList().size() > 6);

        StringBuffer result = new StringBuffer(1024);

        result.append(dialogWhiteBoxStart());

        // if the output to long, wrap it in a div
        if (scroll) {
            result.append("<div style='width: 100%; height:100px; overflow: auto;'>\n");
        }

        result.append("<table border=\"0\">\n");
        Iterator<String> i = getResourceList().iterator();
        while (i.hasNext()) {
            String resName = i.next();
            result.append("\t<tr>\n");
            result.append("\t\t<td class='textbold' style=\"vertical-align:top;\">");
            result.append(CmsResource.getName(resName));
            result.append("&nbsp;</td>\n\t\t<td style=\"vertical-align:top;\">");
            String title = null;
            try {
                // get the title property value
                title = getCms().readPropertyObject(resName, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue(
                    null);
            } catch (CmsException e) {
                // ignore this exception, title not found
            }
            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(title)) {
                // show the title information
                result.append(title);
            }
            result.append("</td>\n\t</tr>\n");
        }
        result.append("</table>");

        // close the div if needed
        if (scroll) {
            result.append("</div>\n");
        }
        result.append(dialogWhiteBoxEnd());
        return result.toString();
    }
40308
public InputStream getResourceAsStream(String resourceName) {
		InputStream is = null;
		String realPath = getRealResourcePath(resourceName);
		if (isFileSystemPath(resourceName, realPath)) { // The resource has been
														// remapped to a file
														// system path
			try {
				is = new FileInputStream(realPath);
			} catch (FileNotFoundException e) {
				LOGGER.debug("The resource " + realPath + " has not been found");
			}
		}
		if (is == null) {
			is = super.getResourceAsStream(realPath);
		}
		return is;
	}
916689
protected String build(Response response) {
    StringBuilder sb = new StringBuilder();
    sb.append("<div class='container'>");
    sb.append("<div class='row-fluid'>");
    sb.append("<div class='span12'>");
    sb.append(buildJSONResponseBox(response));
    if( response._status == Response.Status.done ) response.toJava(sb);
    sb.append(buildResponseHeader(response));
    Builder builder = response.getBuilderFor(ROOT_OBJECT);
    if (builder == null) {
      sb.append("<h3>"+name()+"</h3>");
      builder = OBJECT_BUILDER;
    }
    for( String h : response.getHeaders() ) sb.append(h);
    if( response._response==null ) {
      boolean done = response._req.toHTML(sb);
      if(!done) {
        JsonParser parser = new JsonParser();
        String json = new String(response._req.writeJSON(new AutoBuffer()).buf());
        JsonObject o = (JsonObject) parser.parse(json);
        sb.append(builder.build(response, o, ""));
      }
    } else sb.append(builder.build(response,response._response,""));
    sb.append("</div></div></div>");
    return sb.toString();
  }
144467
public static Drawable createFromResourceStream(Resources res, TypedValue value, InputStream is, String srcName, BitmapFactory.Options opts) {
        return Drawable.createFromResourceStream(res, value, is, srcName, opts);
    }
1333671
public static InputStream getResourceAsStream(String resourceName) throws URISyntaxException,
            ClassNotFoundException {
        return ResourceUtil.class.getClassLoader().getResourceAsStream(resourceName);
    }