Tabnine Logo
org.restlet.data
Code IndexAdd Tabnine to your IDE (free)

How to use org.restlet.data

Best Java code snippets using org.restlet.data (Showing top 20 results out of 801)

origin: internetarchive/heritrix3

      @Override
      protected Reference determineRootRef(Request request) {
        String ref = "file:/";
        return new Reference(ref);
      }};
anypath.setListingAllowed(true);
origin: stackoverflow.com

 LocationRequest locationRequest = LocationRequest.create()
  .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

PendingResult<Status> result = LocationServices.FusedLocationApi
  .requestLocationUpdates(
    googleApiClient,   // your connected GoogleApiClient
    locationRequest,   // a request to receive a new location
    locationListener); // the listener which will receive updated locations

// Callback is asynchronous. Use await() on a background thread or listen for
// the ResultCallback
result.setResultCallback(new ResultCallback<Status>() {
  void onResult(Status status) {
    if (status.isSuccess()) {
      // Successfully registered
    } else if (status.hasResolution()) {
      // Google provides a way to fix the issue
      status.startResolutionForResult(
        activity,     // your current activity used to receive the result
        RESULT_CODE); // the result code you'll look for in your
               // onActivityResult method to retry registering
    } else {
      // No recovery. Weep softly or inform the user.
      Log.e(TAG, "Registering failed: " + status.getStatusMessage());
    }
  }
});
origin: internetarchive/heritrix3

  protected String getStaticRef(String resource) {
    String rootRef = getRequest().getRootRef().toString();
    return rootRef + "/engine/static/" + resource;
  }
}
origin: internetarchive/heritrix3

/**
 * Constructs a nested Map data structure with the information represented
 * by this Resource. The result is particularly suitable for use with with
 * {@link XmlMarshaller}.
 * 
 * @return the nested Map data structure
 */
protected CrawlJobModel makeDataModel() {
  String baseRef = getRequest().getResourceRef().getBaseRef().toString();
  if (!baseRef.endsWith("/")) {
    baseRef += "/";
  }
  return new CrawlJobModel(cj,baseRef);
}
origin: internetarchive/heritrix3

/**
 * Constructs a nested Map data structure with the information represented
 * by this Resource. The result is particularly suitable for use with with
 * {@link XmlMarshaller}.
 * 
 * @return the nested Map data structure
 */
protected ScriptModel makeDataModel() {
  
  String baseRef = getRequest().getResourceRef().getBaseRef().toString();
  if(!baseRef.endsWith("/")) {
    baseRef += "/";
  }
  Reference baseRefRef = new Reference(baseRef);
  
  ScriptModel model = new ScriptModel(scriptingConsole,
      new Reference(baseRefRef, "..").getTargetRef().toString(),
      getAvailableScriptEngines());
  return model;
}
origin: internetarchive/heritrix3

  /**
   * Construct navigational URI for given parameters.
   * 
   * @param pos desired position in file
   * @param lines desired signed line count
   * @param reverse if line ordering should be displayed in reverse
   * @return String URI appropriate to navigate to desired view
   */
  protected String getControlUri(long pos, int lines, boolean reverse) {
    Form query = new Form(); 
    query.add("format","paged");
    if(pos!=0) {
      query.add("pos", Long.toString(pos));
    }
    if(lines!=128) {
      if(Math.abs(lines)<1) {
        lines = 1;
      }
      query.add("lines",Integer.toString(lines));
    }
    if(reverse) {
      query.add("reverse","y");
    }
    Reference viewRef = dirResource.getRequest().getOriginalRef().clone(); 
    viewRef.setQuery(query.getQueryString());
    
    return viewRef.toString(); 
  }
}
origin: internetarchive/heritrix3

/**
 * If client can accept text/html, always prefer it. WebKit-based browsers
 * claim to want application/xml, but we don't want to give it to them. See
 * <a href="https://webarchive.jira.com/browse/HER-1603">https://webarchive.jira.com/browse/HER-1603</a>
 */
public Variant getPreferredVariant() {
  boolean addExplicitTextHtmlPreference = false;
  for (Preference<MediaType> mediaTypePreference: getRequest().getClientInfo().getAcceptedMediaTypes()) {
    if (mediaTypePreference.getMetadata().equals(MediaType.TEXT_HTML)) {
      mediaTypePreference.setQuality(Float.MAX_VALUE);
      addExplicitTextHtmlPreference = false;
      break;
    } else if (mediaTypePreference.getMetadata().includes(MediaType.TEXT_HTML)) {
      addExplicitTextHtmlPreference = true;
    }
  }
  
  if (addExplicitTextHtmlPreference) {
    List<Preference<MediaType>> acceptedMediaTypes = getRequest().getClientInfo().getAcceptedMediaTypes();
    acceptedMediaTypes.add(new Preference<MediaType>(MediaType.TEXT_HTML, Float.MAX_VALUE));
    getRequest().getClientInfo().setAcceptedMediaTypes(acceptedMediaTypes);
  }
  
  
  return super.getPreferredVariant();
}

origin: internetarchive/heritrix3

public void acceptRepresentation(Representation entity) throws ResourceException {
  if (appCtx == null) {
    throw new ResourceException(404);
  }
  // copy op?
  Form form = getRequest().getEntityAsForm();
  beanPath = form.getFirstValue("beanPath");
  
  String newVal = form.getFirstValue("newVal");
  if(newVal!=null) {
    int i = beanPath.indexOf(".");
    String beanName = i<0?beanPath:beanPath.substring(0,i);
    Object namedBean = appCtx.getBean(beanName);
    BeanWrapperImpl bwrap = new BeanWrapperImpl(namedBean);
    String propPath = beanPath.substring(i+1);
    Object coercedVal = bwrap.convertIfNecessary(newVal, bwrap.getPropertyValue(propPath).getClass()); 
    bwrap.setPropertyValue(propPath, coercedVal);
  }
  Reference ref = getRequest().getResourceRef();
  ref.setPath(getBeansRefPath());
  ref.addSegment(beanPath);
  getResponse().redirectSeeOther(ref);
}
origin: internetarchive/heritrix3

public String getBeansRefPath() {
  Reference ref = getRequest().getResourceRef();
  String path = ref.getPath(); 
  int i = path.indexOf("/beans/");
  if(i>0) {
    return path.substring(0,i+"/beans/".length());
  }
  if(!path.endsWith("/")) {
    path += "/";
  }
  return path; 
}
origin: internetarchive/heritrix3

throws ResourceException {
  Form form = getRequest().getEntityAsForm();
  String newContents = form.getFirstValue("contents");
  EditRepresentation er;
  try {
  Reference ref = getRequest().getOriginalRef().clone(); 
  getResponse().redirectSeeOther(ref);
origin: internetarchive/heritrix3

@Override
public void acceptRepresentation(Representation entity) throws ResourceException {
  Form form = getRequest().getEntityAsForm();
  chosenEngine = form.getFirstValue("engine");
  String script = form.getFirstValue("script");
  if(StringUtils.isBlank(script)) {
    script="";
  }
  ScriptEngine eng = MANAGER.getEngineByName(chosenEngine);
  
  scriptingConsole.bind("scriptResource",  this);
  scriptingConsole.execute(eng, script);
  scriptingConsole.unbind("scriptResource");
  
  //TODO: log script, results somewhere; job log INFO? 
  
  getResponse().setEntity(represent());
}
 
origin: internetarchive/heritrix3

      @Override
      protected Reference determineRootRef(Request request) {
        try {
          return new Reference(
            EngineApplication.this.getEngine()
            .getJob(TextUtils.urlUnescape(
              (String)request.getAttributes().get("job")))
            .getJobDir().getCanonicalFile().toURI().toString());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }};
jobdir.setListingAllowed(true);
origin: internetarchive/heritrix3

public static void addFlash(Response response, String message, Kind kind) {
  dropboxes.put(nextdrop,new Flash(message, kind));
  Series<CookieSetting> cookies = response.getCookieSettings();
  CookieSetting flashdrop = null; 
  for(CookieSetting cs : cookies) {
    if(cs.getName().equals("flashdrop")) {
      flashdrop = cs; 
    }
  }
  if(flashdrop == null) {
    cookies.add(new CookieSetting("flashdrop",Long.toString(nextdrop)));
  } else {
    flashdrop.setValue(flashdrop.getValue()+","+Long.toString(nextdrop));
  }
  nextdrop++;
}

origin: internetarchive/heritrix3

public ReportGenResource(Context ctx, Request req, Response res) throws ResourceException {
  super(ctx, req, res);
  getVariants().add(new Variant(MediaType.TEXT_PLAIN));
  reportClass = (String)req.getAttributes().get("reportClass");
}
origin: internetarchive/heritrix3

protected void copyJob(String copyTo, boolean asProfile)
    throws ResourceException {
  try {
    getEngine().copy(cj, copyTo, asProfile);
  } catch (IOException e) {
    Flash.addFlash(getResponse(), "Job not copied: " + e.getMessage(),
        Flash.Kind.NACK);
    getResponse().redirectSeeOther(getRequest().getOriginalRef());
    return;
  }
  // redirect to destination job page
  getResponse().redirectSeeOther(copyTo);
}
origin: internetarchive/heritrix3

/**
 * Constructs a nested Map data structure with the information represented
 * by this Resource. The result is particularly suitable for use with with
 * {@link XmlMarshaller}.
 * 
 * @return the nested Map data structure
 */
protected EngineModel makeDataModel() {
  String baseRef = getRequest().getResourceRef().getBaseRef().toString();
  if(!baseRef.endsWith("/")) {
    baseRef += "/";
  }
  
  return new EngineModel(getEngine(), baseRef);
}
 
origin: internetarchive/heritrix3

protected String getStaticRef(String resource) {
  String rootRef = dirResource.getRequest().getRootRef().toString();
  return rootRef + "/engine/static/" + resource;
}
origin: internetarchive/heritrix3

public JobRelatedResource(Context ctx, Request req, Response res) throws ResourceException {
  super(ctx, req, res);
  cj = getEngine().getJob((String)req.getAttributes().get("job"));
  if(cj==null) {
    throw new ResourceException(404);
  }
}
 
origin: internetarchive/heritrix3

  protected void writeHtml(Writer writer) {
    String baseRef = getRequest().getResourceRef().getBaseRef().toString();
    if(!baseRef.endsWith("/")) {
      baseRef += "/";
    }
    Configuration tmpltCfg = getTemplateConfiguration();

    ViewModel viewModel = new ViewModel();
    viewModel.setFlashes(Flash.getFlashes(getRequest()));
    viewModel.put("baseRef",baseRef);
    viewModel.put("model",makeDataModel());

    try {
      Template template = tmpltCfg.getTemplate("Beans.ftl");
      template.process(viewModel, writer);
      writer.flush();
    } catch (IOException e) { 
      throw new RuntimeException(e); 
    } catch (TemplateException e) { 
      throw new RuntimeException(e); 
    }
    
  }
}
origin: internetarchive/heritrix3

protected void writeHtml(Writer writer) {
  EngineModel model = makeDataModel();
  String baseRef = getRequest().getResourceRef().getBaseRef().toString();
  if(!baseRef.endsWith("/")) {
    baseRef += "/";
  }
  Configuration tmpltCfg = getTemplateConfiguration();
  ViewModel viewModel = new ViewModel();
  viewModel.setFlashes(Flash.getFlashes(getRequest()));
  viewModel.put("baseRef",baseRef);
  viewModel.put("fileSeparator", File.separator);
  viewModel.put("engine", model);
  try {
    Template template = tmpltCfg.getTemplate("Engine.ftl");
    template.process(viewModel, writer);
    writer.flush();
  } catch (IOException e) { 
    throw new RuntimeException(e); 
  } catch (TemplateException e) { 
    throw new RuntimeException(e); 
  }
}
org.restlet.data

Most used classes

  • Reference
    Reference to a Uniform Resource Identifier (URI). Contrary to the java.net.URI class, this interface
  • Form
    Form which is a specialized modifiable list of parameters.
  • Status
    Status to return after handling a call.
  • MediaType
    Media type used in representations and preferences.
  • Parameter
    Multi-usage parameter. Note that the name and value properties are thread safe, stored in volatile m
  • Response,
  • Method,
  • Request,
  • ChallengeResponse,
  • Preference,
  • Protocol,
  • ChallengeScheme,
  • CharacterSet,
  • Conditions,
  • Tag,
  • Language,
  • ChallengeRequest,
  • CookieSetting,
  • Cookie
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now