/* (non-Javadoc)
@see com.ibm.jaggr.service.impl.modulebuilder.javascript.JavaScriptModuleBuilder#handles(java.lang.String, com.ibm.jaggr.service.resource.IResource)
425177
@Override
	public boolean handles(String mid, IResource resource) {
		Matcher m = re.matcher(mid);
		return super.handles(mid, resource) &&
				m.matches() && m.group(5).length() == 0;
	}
1017897
function (resourcesHandler) {
                if (ariaUtilsType.isString(resourcesHandler)) {
                    resourcesHandler = loadResourcesHandler(resourcesHandler, this);
                    this._autoDisposeHandler = true;
                }
                this._resourcesHandler = resourcesHandler;
            }
760174
protected static boolean handle(ServletRequest req, ServletResponse res) {
		return handler.handle((HttpServletRequest)req, (HttpServletResponse)res);
	}
904709
function resourcesHandlerError (args) {
        var scope = args.scope;

        // resources handler is not an AT class, no need to dispose
        scope._autoDisposeHandler = false;

        scope.$logError(scope.INVALID_RESOURCES_HANDLER, args.classpath);
    }
1299500
public void handle(String pathInContext,
                       String pathParams,
                       HttpRequest request,
                       HttpResponse response)
        throws HttpException, IOException
    {
        Resource resource = getResource(pathInContext);
        if (resource==null)
            return;

        // Is the method allowed?
        if (!isMethodAllowed(request.getMethod()))
        {
            if(log.isDebugEnabled())log.debug("Method not allowed: "+request.getMethod());
            if (resource.exists())
            {
                setAllowHeader(response);
                response.sendError(HttpResponse.__405_Method_Not_Allowed);
            }
            return;
        }

        // Handle the request
        try
        {
            if(log.isDebugEnabled())log.debug("PATH="+pathInContext+" RESOURCE="+resource);
            
            // check filename
            String method=request.getMethod();
            if (method.equals(HttpRequest.__GET) ||
                method.equals(HttpRequest.__POST) ||
                method.equals(HttpRequest.__HEAD))
                handleGet(request, response, pathInContext, pathParams, resource);  
            else if (method.equals(HttpRequest.__PUT))
                handlePut(request, response, pathInContext, resource);
            else if (method.equals(HttpRequest.__DELETE))
                handleDelete(request, response, pathInContext, resource);
            else if (method.equals(HttpRequest.__OPTIONS))
                handleOptions(response, pathInContext);
            else if (method.equals(HttpRequest.__MOVE))
                handleMove(request, response, pathInContext, resource);
            else if (method.equals(HttpRequest.__TRACE))
                handleTrace(request, response);
            else
            {
                if(log.isDebugEnabled())log.debug("Unknown action:"+method);
                // anything else...
                try{
                    if (resource.exists())
                        response.sendError(HttpResponse.__501_Not_Implemented);
                }
                catch(Exception e) {LogSupport.ignore(log,e);}
            }
        }
        catch(IllegalArgumentException e)
        {
            LogSupport.ignore(log,e);
        }
        finally
        {
            if (resource!=null && !(resource instanceof CachedResource))
                resource.release();
        }
    }
871999
@Override
  public void handle(
      final String target,
      final HttpServletRequest request,
      final HttpServletResponse response,
      final int i)
      throws IOException, ServletException {
    LOG.log(Level.INFO, "JettyHandler handle is entered with target: {0} ", target);

    final Request baseRequest = (request instanceof Request) ? (Request) request :
        HttpConnection.getCurrentConnection().getRequest();

    response.setContentType("text/html;charset=utf-8");

    final ParsedHttpRequest parsedHttpRequest = new ParsedHttpRequest(request);
    final HttpHandler handler = validate(request, response, parsedHttpRequest);
    if (handler != null) {
      LOG.log(Level.INFO, "calling HttpHandler.onHttpRequest from JettyHandler.handle() for {0}.",
          handler.getUriSpecification());
      handler.onHttpRequest(parsedHttpRequest, response);
      response.setStatus(HttpServletResponse.SC_OK);
    }

    baseRequest.setHandled(true);
    LOG.log(Level.INFO, "JettyHandler handle exists");
  }
833115
@Override
    public void run() {
        try {
            handle();
        } catch (Exception e) {
            Throwables.throwIfUnchecked(e);
            throw new RuntimeException(e);
        }
    }
1311822
@Override
    public void handle(Response<ByteSource> rs) throws RestEndpointIOException {
        if (!hasError(rs)) {
            return;
        }

        handleError(rs.getUri(), rs.getHttpMethod(), rs.getStatus(), rs.getReason(), rs.getBody());

    }
72786
public void handle() {
        try {
            for (handleIndex++; handleIndex < handlers.size(); handleIndex++) {
                handlers.get(handleIndex).handle(this);
            }
        } catch (final Exception e) {
            final String requestLog = Requests.getLog(request);
            LOGGER.log(Level.ERROR, "Handler process failed: " + requestLog, e);

            setRenderer(new Http500Renderer(e));
        }
    }
1363570
@Override
  public final void handle(final Map<String, Object> pReqVars,
    final IRequestData pRequestData) throws Exception {
    String processorName = pRequestData.getParameter("nmPrc");
    if (processorName == null) {
      //WHandlerAndJsp requires handle NULL request:
      return;
    }
    IProcessor proc = this.processorsFactory.lazyGet(pReqVars, processorName);
    proc.process(pReqVars, pRequestData);
  }
506966
public void processSource(String[] filenames)
    {
        for (int i = 0; i != filenames.length; ++i) {
            String filename = filenames[i];
            if (!filename.endsWith(".js")) {
                addError("msg.extension.not.js", filename);
                return;
            }
            File f = new File(filename);
            String source = readSource(f);
            if (source == null) return;

            String mainClassName = targetName;
            if (mainClassName == null) {
                String name = f.getName();
                String nojs = name.substring(0, name.length() - 3);
                mainClassName = getClassName(nojs);
            }
            if (targetPackage.length() != 0) {
                mainClassName = targetPackage+"."+mainClassName;
            }

            Object[] compiled
                = compiler.compileToClassFiles(source, filename, 1,
                                               mainClassName);
            if (compiled == null || compiled.length == 0) {
                return;
            }

            File targetTopDir = null;
            if (destinationDir != null) {
                targetTopDir = new File(destinationDir);
            } else {
                String parent = f.getParent();
                if (parent != null) {
                    targetTopDir = new File(parent);
                }
            }
            for (int j = 0; j != compiled.length; j += 2) {
                String className = (String)compiled[j];
                byte[] bytes = (byte[])compiled[j + 1];
                File outfile = getOutputFile(targetTopDir, className);
                try {
                    FileOutputStream os = new FileOutputStream(outfile);
                    try {
                        os.write(bytes);
                    } finally {
                        os.close();
                    }
                } catch (IOException ioe) {
                    addFormatedError(ioe.toString());
                }
            }
        }
    }
884844
private final void addHandle(WSJdbcConnection handle) throws ResourceException {
        (numHandlesInUse < handlesInUse.length - 1 ? handlesInUse : resizeHandleList())[numHandlesInUse++] = handle;
        if (!inRequest && dsConfig.get().enableBeginEndRequest)
            try {
                inRequest = true;
                mcf.jdbcRuntime.beginRequest(sqlConn);
            } catch (SQLException x) {
                FFDCFilter.processException(x, getClass().getName(), "548", this);
                throw new DataStoreAdapterException("DSA_ERROR", x, getClass());
            }
    }
1286732
@Override
	public void handle(final T throwable, final boolean throwRuntimeException) {
		this.logger.error(throwable);
		if (throwRuntimeException) {
			if (throwable instanceof RuntimeException) {
				throw (RuntimeException) throwable;
			}
			throw new RuntimeException(throwable);
		}
	}
564613
@Override
    public void handle(RequestContext context) throws SecurityProviderException, IOException {
        RedirectUtils.redirect(context.getRequest(), context.getResponse(), getTargetUrl());
    }
844904
function resourcesHandlerLoaded (args) {
        var scope = args.scope, handler = Aria.getClassInstance(args.classpath);
        var pendingSuggestion = scope._resourcesHandler.pendingSuggestion;

        scope._resourcesHandler = handler;
        scope._autoDisposeHandler = true;

        if (pendingSuggestion) {
            if (pendingSuggestion.entry) {
                handler.getSuggestions(pendingSuggestion.entry, pendingSuggestion.callback);
            } else {
                handler.getAllSuggestions(pendingSuggestion.callback);
            }
        }
    }
1076862
@Override
	public IResource convert(final IResource resource) {
		final String sourceMethod = "convert"; //$NON-NLS-1$
		final boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(sourceMethod, sourceMethod, new Object[]{resource});
		}
		IResource result = resource;

		if (!isSkipResourceConversion.get()) {
			if (!resource.isFolder()) {
				// is the request for a JavaScript file
				if (resource.getPath().endsWith(".js") && resource.getPath().length() > 3) { //$NON-NLS-1$
					if (!resource.exists()){
						// The requested javascript file doesn't exist.  See if we can satisfy the request
						// by converting a .jsx file.

						// Construct a resource object for the .jsx file with the same base name
						// and in the same directory as the requested javascript file.
						String path = resource.getReferenceURI().getPath();
						int idx = path.lastIndexOf("/"); //$NON-NLS-1$
						String name = path.substring(idx == -1 ? 0 : idx+1, path.length()-3) + ".jsx"; //$NON-NLS-1$
						IResource jsxRes = aggregator.newResource(resource.resolve(name));
						if (jsxRes.exists()) {
							ICache cache = aggregator.getCacheManager().getCache();
							try {
								IResourceConverterCache jsxCache = (IResourceConverterCache)cache.getCache(JSX_CACHE_NAME);
								if (jsxCache == null) {
									throw new NotFoundException(JSX_CACHE_NAME);
								}
								// Use the resource's reference uri as the cache key
								String cacheKey = resource.getReferenceURI().toString();
								// get the converted resource from the cache.
								jsxRes.setReferenceURI(resource.getReferenceURI());
								result = jsxCache.convert(cacheKey, jsxRes);
							} catch (IOException ex) {
								log.logp(Level.WARNING, sourceClass, sourceMethod, ex.getMessage(), ex);
								result = new ExceptionResource(resource.getReferenceURI(), resource.lastModified(), ex);
							}
						}
					}
				}
			} else {
				// It's a folder resource.  Wrap the folder resource so that we can override the
				// tree walker so as to make .jsx files in folder listings appear as .js files.
				return new FolderResourceWrapper(resource);
			}
		}
		if (isTraceLogging) {
			log.exiting(sourceClass, sourceMethod, result);
		}
		return result;
	}
899202
public void handleSuccess ()
    {
        if (_listener instanceof InvocationService.ConfirmListener) {
            reportRequestProcessed();
        } else if (_listener instanceof InvocationService.ResultListener && _resultSet) {
            reportRequestProcessed(_result);
        }
    }