Examples of ResourceDescriptor


Examples of org.joggito.core.descriptors.ResourceDescriptor

   * Returns the resource descriptor for the given bean type if exists,
   * otherwise throws a {@link DescriptorNotFoundException}.
   */
  private <T> ResourceDescriptor forceGetDescriptor(Class<T> beanType) {
    MetaContext metaContext = session.getMetaContext();
    final ResourceDescriptor desc = metaContext.getDescriptor(beanType);

    if (desc == null) { // no descriptor for bean type.
      throw new DescriptorNotFoundException(beanType);
    }
    return desc;
View Full Code Here

Examples of org.olat.commons.servlets.util.ResourceDescriptor

            response.sendError(HttpServletResponse.SC_NOT_FOUND, request
                    .getRequestURI());
            return false;
        }

        ResourceDescriptor rd = handler.getResourceDescriptor(request, relPath);
        if (rd == null) {
            // no handler found or relPath incomplete
            response.sendError(HttpServletResponse.SC_NOT_FOUND, request
                    .getRequestURI());
            return false;
        }

        setHeaders(response, rd);
        // check if modified since
        long ifModifiedSince = request.getDateHeader("If-Modified-Since");
        long lastMod = rd.getLastModified();
        if (lastMod != -1L && ifModifiedSince >= lastMod) {
            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            return false;
        }

        // server the resource
        if (copyContent) {
            InputStream is = handler.getInputStream(request, rd);
            if (is == null) {
                // resource not found or access denied
                response.sendError(HttpServletResponse.SC_NOT_FOUND, request
                        .getRequestURI());
                return false;
            }
            copyContent(response, is);
            if (logDebug) {
                long stop = System.currentTimeMillis()
                Tracing.logDebug("Serving resource '" + relPath + "' ("+rd.getSize()+" bytes) in "+ (stop-start) +"ms with handler '" + handlerName + "'.", StaticsLegacyDispatcher.class);

            }
        }
        return true;
    }
View Full Code Here

Examples of org.olat.commons.servlets.util.ResourceDescriptor

        i ++;
      }
      //FIXME:fj: handle appropriately
      Locale loc = UserSession.getUserSession(request).getLocale();
     
      ResourceDescriptor rd = new ResourceDescriptor(relPath);
      rd.setLastModified(f.lastModified());
      rd.setSize(f.length());
      String mimeType = WebappHelper.getMimeType(relPath);
      if (mimeType == null) mimeType = "application/octet-stream";
      rd.setContentType(mimeType);
      return rd;
    } catch (Exception e) {
      return null;
    }
  }
View Full Code Here

Examples of org.olat.commons.servlets.util.ResourceDescriptor

  public ResourceDescriptor getResourceDescriptor(HttpServletRequest request, String relPath) {
    if (root == null) return null;
    try {
      File f = new File(root + relPath);
      if (!f.exists() || f.isDirectory()) return null;
      ResourceDescriptor rd = new ResourceDescriptor(relPath);
      rd.setLastModified(f.lastModified());
      rd.setSize(f.length());
      String mimeType = WebappHelper.getMimeType(relPath);
      if (mimeType == null) mimeType = "application/octet-stream";
      if (mimeType.equals("text/html")) {
        mimeType = "text/html; charset=utf-8";
      }
      rd.setContentType(mimeType);
      return rd;
    } catch (Exception e) {
      return null;
    }
  }
View Full Code Here

Examples of org.olat.commons.servlets.util.ResourceDescriptor

  /**
   * @see org.olat.commons.servlets.pathhandlers.PathHandler#getResourceDescriptor(javax.servlet.http.HttpServletRequest, java.lang.String)
   */
  public ResourceDescriptor getResourceDescriptor(HttpServletRequest request, String relPath) {
    try {
      ResourceDescriptor rd = new ResourceDescriptor(relPath);
      File f = new File(QTIEditorPackage.getTmpBaseDir() + relPath);
      rd.setLastModified(f.lastModified());
      rd.setSize(f.length());
      String mimeType = WebappHelper.getMimeType(relPath);
      if (mimeType == null) mimeType = "application/octet-stream";
      rd.setContentType(mimeType);
      return rd;
    } catch (Exception e) {
      return null;
    }
  }
View Full Code Here

Examples of org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor

        } else {
            // Using Embedded extension model - the defined type is actually a copy of another plugin's service or server type.
            LOG.debug("Parsing embedded service type {" + pluginDescriptor.getName() + "}"
                    + serviceDescriptor.getName() + ", which extends type {" + sourcePlugin + "}" + sourceType + "...");

            ResourceDescriptor sourceTypeDescriptor;
            if (sourceType.isEmpty()) {
                sourceTypeDescriptor = serviceDescriptor;
            } else {
                Map<String, ServiceDescriptor> pluginServiceDescriptors = getPluginServiceDescriptors(sourcePlugin);
                sourceTypeDescriptor = pluginServiceDescriptors.get(sourceType);
                if (sourceTypeDescriptor == null) {
                    Map<String, ServerDescriptor> pluginServerDescriptors = getPluginServerDescriptors(sourcePlugin);
                    sourceTypeDescriptor = pluginServerDescriptors.get(sourceType);
                }
            }

            if (sourceTypeDescriptor == null) {
                LOG.warn("There is no service or server type named [" + sourceType + "] from a plugin named ["
                        + sourcePlugin + "]. This is probably because that plugin is missing. Resource Type [{"
                        + pluginDescriptor.getName() + "}" + serviceDescriptor.getName() + "] will be ignored.");
                return null;
            }

            serviceResourceType = new ResourceType(serviceDescriptor.getName(), pluginDescriptor.getName(),
                ResourceCategory.SERVICE, parentType);

            // Let the plugin writer override these, or if not, parseResourceDescriptor() will pick up the source type's
            // values.
            serviceResourceType.setDescription(serviceDescriptor.getDescription());
            serviceResourceType.setSubCategory(serviceDescriptor.getSubCategory());

            serviceResourceType.setCreationDataType(convertCreationDataType(serviceDescriptor.getCreationDataType()));
            serviceResourceType.setCreateDeletePolicy(convertCreateDeletePolicy(serviceDescriptor
                .getCreateDeletePolicy()));
            serviceResourceType.setSingleton(serviceDescriptor.isSingleton());
            serviceResourceType.setSupportsMissingAvailabilityType(serviceDescriptor
                .isSupportsMissingAvailabilityType());

            String discoveryClass;
            if (serviceDescriptor.getDiscovery() != null) {
                discoveryClass = getFullyQualifiedComponentClassName(getPluginPackage(sourcePlugin), serviceDescriptor
                    .getDiscovery());
            } else {
                discoveryClass = getFullyQualifiedComponentClassName(getPluginPackage(sourcePlugin),
                        sourceTypeDescriptor.getDiscovery());
            }

            String componentClass;
            if (serviceDescriptor.getClazz() != null) {
                componentClass = getFullyQualifiedComponentClassName(getPluginPackage(sourcePlugin), serviceDescriptor
                    .getClazz());
            } else {
                componentClass = getFullyQualifiedComponentClassName(getPluginPackage(sourcePlugin),
                        sourceTypeDescriptor.getClazz());
            }

            parseResourceDescriptor(sourceTypeDescriptor, serviceResourceType, discoveryClass, componentClass,
                sourcePlugin);
        }
View Full Code Here

Examples of org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor

        } else if (sourcePlugin.length() > 0) {
            // Using Embedded extension model - the defined type is actually a copy of another plugin's service or server type.
            log.debug("Parsing embedded service type {" + pluginDescriptor.getName() + "}"
                    + serviceDescriptor.getName() + ", which extends type {" + sourcePlugin + "}" + sourceType + "...");

            ResourceDescriptor sourceTypeDescriptor;
            if (sourceType.isEmpty()) {
                sourceTypeDescriptor = serviceDescriptor;
            } else {
                Map<String, ServiceDescriptor> pluginServiceDescriptors = getPluginServiceDescriptors(sourcePlugin);
                sourceTypeDescriptor = pluginServiceDescriptors.get(sourceType);
View Full Code Here

Examples of org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor

     * @return The parsed {@link ConfigurationDefinition}
     */
    public static ConfigurationDefinition loadPluginConfigDefFor(PluginDescriptor descriptor, String path,
        String configName) {
        try {
            ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
            return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getPluginConfiguration());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor

     * @return The parsed {@link ConfigurationDefinition}
     */
    public static ConfigurationDefinition loadResourceConfigDefFor(PluginDescriptor descriptor, String path,
        String configName) {
        try {
            ResourceDescriptor resourceDescriptor = (ResourceDescriptor) find(descriptor, path);
            return ConfigurationMetadataParser.parse(configName, resourceDescriptor.getResourceConfiguration());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor

    /**
     * Returns the plugin descriptor.
     */
    public ResourceDescriptor getResourceDescriptor(String name) {
        ResourceDescriptor rd = descriptors.get(name);
        if (rd == null)
            throw new IllegalStateException("no descriptor " + name + " in " + descriptors.keySet());
        return rd;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.