Package net.pterodactylus.sone.data

Examples of net.pterodactylus.sone.data.Sone


   * @param soneLockedEvent
   *            The event
   */
  @Subscribe
  public void soneLocked(SoneLockedEvent soneLockedEvent) {
    final Sone sone = soneLockedEvent.sone();
    ScheduledFuture<?> tickerObject = ticker.schedule(new Runnable() {

      @Override
      @SuppressWarnings("synthetic-access")
      public void run() {
View Full Code Here


  /**
   * {@inheritDoc}
   */
  @Override
  protected JsonReturnObject createJsonObject(FreenetRequest request) {
    Sone currentSone = getCurrentSone(request.getToadletContext(), false);
    Collection<Notification> notifications = webInterface.getNotifications().getNotifications();
    List<Notification> filteredNotifications = ListNotificationFilters.filterNotifications(notifications, currentSone);
    Collections.sort(filteredNotifications, Notification.CREATED_TIME_SORTER);
    ArrayNode jsonNotifications = new ArrayNode(instance);
    for (Notification notification : filteredNotifications) {
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  protected JsonReturnObject createJsonObject(FreenetRequest request) {
    Sone currentSone = getCurrentSone(request.getToadletContext());
    Profile profile = currentSone.getProfile();
    String fieldId = request.getHttpRequest().getParam("field");
    Field field = profile.getFieldById(fieldId);
    if (field == null) {
      return createErrorJsonObject("invalid-field-id");
    }
    String direction = request.getHttpRequest().getParam("direction");
    try {
      if ("up".equals(direction)) {
        profile.moveFieldUp(field);
      } else if ("down".equals(direction)) {
        profile.moveFieldDown(field);
      } else {
        return createErrorJsonObject("invalid-direction");
      }
    } catch (IllegalArgumentException iae1) {
      return createErrorJsonObject("not-possible");
    }
    currentSone.setProfile(profile);
    webInterface.getCore().touchConfiguration();
    return createSuccessJsonObject();
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  protected JsonReturnObject createJsonObject(FreenetRequest request) {
    Sone currentSone = getCurrentSone(request.getToadletContext(), false);
    if (currentSone == null) {
      return createErrorJsonObject("auth-required");
    }
    String soneId = request.getHttpRequest().getParam("sone");
    Optional<Sone> sone = webInterface.getCore().getSone(soneId);
View Full Code Here

  protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
    super.processTemplate(request, templateContext);
    if (request.getMethod() == Method.POST) {
      String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
      String identity = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
      Sone currentSone = getCurrentSone(request.getToadletContext());
      Optional<Sone> sone = webInterface.getCore().getSone(identity);
      if (sone.isPresent()) {
        webInterface.getCore().untrustSone(currentSone, sone.get());
      }
      throw new RedirectException(returnPage);
View Full Code Here

  @Override
  protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
    super.processTemplate(request, templateContext);
    if (request.getMethod() == Method.POST) {
      if (request.getHttpRequest().isPartSet("deleteSone")) {
        Sone currentSone = getCurrentSone(request.getToadletContext());
        webInterface.getCore().deleteSone(currentSone);
      }
      throw new RedirectException("index.html");
    }
  }
View Full Code Here

      if (selectedIdentity == null) {
        templateContext.set("errorNoIdentity", true);
        return;
      }
      /* create Sone. */
      Sone sone = webInterface.getCore().createSone(selectedIdentity);
      if (sone == null) {
        logger.log(Level.SEVERE, String.format("Could not create Sone for OwnIdentity: %s", selectedIdentity));
        /* TODO - go somewhere else */
      }

 
View Full Code Here

  @Override
  protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
    super.processTemplate(request, templateContext);
    if (request.getMethod() == Method.POST) {
      String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
      Sone currentSone = getCurrentSone(request.getToadletContext());
      String soneIds = request.getHttpRequest().getPartAsStringFailsafe("sone", 2000);
      for (String soneId : soneIds.split("[ ,]+")) {
        webInterface.getCore().unfollowSone(currentSone, soneId);
      }
      throw new RedirectException(returnPage);
View Full Code Here

    String soneId = request.getHttpRequest().getParam("sone");
    Optional<Sone> sone = webInterface.getCore().getSone(soneId);
    if (!sone.isPresent()) {
      return createErrorJsonObject("invalid-sone-id");
    }
    Sone currentSone = getCurrentSone(request.getToadletContext());
    if (currentSone == null) {
      return createErrorJsonObject("auth-required");
    }
    webInterface.getCore().followSone(currentSone, soneId);
    webInterface.getCore().markSoneKnown(sone.get());
View Full Code Here

*/
public class LockSoneCommandTest {

  @Test
  public void testLockingALocalSone() throws FcpException {
    Sone localSone = mock(Sone.class);
    when(localSone.getId()).thenReturn("LocalSone");
    when(localSone.isLocal()).thenReturn(true);
    Core core = mock(Core.class);
    when(core.getSone(eq("LocalSone"))).thenReturn(Optional.of(localSone));
    when(core.getLocalSone(eq("LocalSone"), anyBoolean())).thenReturn(localSone);
    SimpleFieldSet fields = new SimpleFieldSetBuilder().put("Sone", "LocalSone").get();

View Full Code Here

TOP

Related Classes of net.pterodactylus.sone.data.Sone

Copyright © 2018 www.massapicom. 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.