Example #1
0
 public Content get(Key key) throws Exception {
   // TODO retrieve the bkp address, then look at their content
   // if the content is a link (LINK:<key>), then recursively retrieve the
   // content
   // of the link.
   // JLG.debug("getFromKey:" + key);
   Content result = null;
   Queue<Address> queue = new LinkedList<Address>();
   Address[] address = getAddressList(key);
   Content[] contentArray = new Content[address.length];
   for (int i = 0; i < address.length; i++) {
     contentArray[i] = get(address[i]);
     if (contentArray[i] == null) {
       queue.offer(address[i]);
       // TODO reassign content to address
     } else {
       result = contentArray[i];
     }
   }
   if (result == null) {
     return null;
   }
   if (result.isLink()) {
     Link link = (Link) result;
     // JLG.debug("key " + key + " is a link on " + link.getTargetKey());
     result = get(link.getTargetKey());
   }
   return result;
 }
Example #2
0
  public void createUser(
      String login, String password, int backupNbr, Captcha captcha, String answer)
      throws Exception {
    LOG.info("creating user: "******", " + password + ", " + backupNbr + ", answer=" + answer);
    LOG.info("captcha=" + captcha);
    OCPUser user = new OCPUser(this, login, backupNbr);
    UserPublicInfo upi = user.getPublicInfo(this);

    ContactMap contactMap = ds().getComponent(ContactMap.class);
    Contact contact = contactMap.getContact(captcha.contactId);

    // 1) create the public part of the user.
    // catpcha is required in order to avoid massive fake user creation
    Data publicUserData = new Data(this, user, ds().serializer.serialize(upi));
    Link publicUserDataLink =
        new Link(user, this, UserPublicInfo.getKey(this, login), publicUserData.getKey(this));

    getClient().createUser(contact, publicUserData, publicUserDataLink, captcha, answer);

    // 2) create the private part of the user.
    // no need captcha because creation of object is checked by the user
    // public info
    Key key = new Key(hash(ucrypt(password, (login + password).getBytes())));
    byte[] content = ucrypt(password, ds().serializer.serialize(user));
    Content privateUserData = new Data(this, user, content);
    Link privateUserDataLink = new Link(user, this, key, privateUserData.getKey(this));

    setWithLink(user, privateUserData, privateUserDataLink);
  }
 /**
  * Build the summaries for the methods that belong to the given class.
  *
  * @param node the XML element that specifies which components to document
  * @param classContentTree content tree to which the documentation will be added
  */
 public void buildSerializableMethods(XMLNode node, Content classContentTree) {
   Content serializableMethodTree = methodWriter.getSerializableMethodsHeader();
   MemberDoc[] members = currentClass.serializationMethods();
   int membersLength = members.length;
   if (membersLength > 0) {
     for (int i = 0; i < membersLength; i++) {
       currentMember = members[i];
       Content methodsContentTree = methodWriter.getMethodsContentHeader((i == membersLength - 1));
       buildChildren(node, methodsContentTree);
       serializableMethodTree.addContent(methodsContentTree);
     }
   }
   if (currentClass.serializationMethods().length > 0) {
     classContentTree.addContent(
         methodWriter.getSerializableMethods(
             configuration.getText("doclet.Serialized_Form_methods"), serializableMethodTree));
     if (currentClass.isSerializable() && !currentClass.isExternalizable()) {
       if (currentClass.serializationMethods().length == 0) {
         Content noCustomizationMsg =
             methodWriter.getNoCustomizationMsg(
                 configuration.getText("doclet.Serializable_no_customization"));
         classContentTree.addContent(
             methodWriter.getSerializableMethods(
                 configuration.getText("doclet.Serialized_Form_methods"), noCustomizationMsg));
       }
     }
   }
 }
Example #4
0
 /**
  * Generate the deprecated API list.
  *
  * @param deprapi list of deprecated API built already.
  */
 protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi) throws IOException {
   Content body = getHeader();
   body.addContent(getContentsList(deprapi));
   String memberTableSummary;
   String[] memberTableHeader = new String[1];
   HtmlTree div = new HtmlTree(HtmlTag.DIV);
   div.addStyle(HtmlStyle.contentContainer);
   for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
     if (deprapi.hasDocumentation(i)) {
       addAnchor(deprapi, i, div);
       memberTableSummary =
           configuration.getText(
               "doclet.Member_Table_Summary",
               configuration.getText(HEADING_KEYS[i]),
               configuration.getText(SUMMARY_KEYS[i]));
       memberTableHeader[0] =
           configuration.getText(
               "doclet.0_and_1",
               configuration.getText(HEADER_KEYS[i]),
               configuration.getText("doclet.Description"));
       writers[i].addDeprecatedAPI(
           deprapi.getList(i), HEADING_KEYS[i], memberTableSummary, memberTableHeader, div);
     }
   }
   body.addContent(div);
   addNavLinks(false, body);
   addBottom(body);
   printHtmlDocument(null, true, body);
 }
 private void removeAllContents(Project project, Content notRemove) {
   if (project.isDisposed()) {
     return;
   }
   final MessageView messageView = MessageView.SERVICE.getInstance(project);
   Content[] contents = messageView.getContentManager().getContents();
   for (Content content : contents) {
     if (content.isPinned()) {
       continue;
     }
     if (content == notRemove) {
       continue;
     }
     boolean toRemove = CONTENT_ID_KEY.get(content) == myContentId;
     if (!toRemove) {
       final Object contentSessionId = SESSION_ID_KEY.get(content);
       toRemove =
           contentSessionId != null
               && contentSessionId != mySessionId; // the content was added by previous compilation
     }
     if (toRemove) {
       messageView.getContentManager().removeContent(content, true);
     }
   }
 }
  @Override
  public void validate() throws CruiseControlException {
    // Must be set
    ValidationHelper.assertEncoding(this.encoding, getClass());
    ValidationHelper.assertIsSet(this.file, "file", getClass());
    // Invalid combination
    ValidationHelper.assertFalse(!this.overwrite && this.append, "action not set properly");

    // Set the file
    this.file = joinPath(this.file);
    ValidationHelper.assertIsNotDirectory(this.file, "file", getClass());

    if (!this.overwrite) {
      // When overwrite is disabled, the file must not exist
      try {
        ValidationHelper.assertNotExists(this.file, "file", getClass());
      } catch (CruiseControlException e) {
        ValidationHelper.fail("Trying to overwrite file without permition.");
      }
    }

    for (Content c : this.messages) {
      c.validate();
    }
  }
  /**
   * Notifies this <tt>Conference</tt> that the ordered list of <tt>Endpoint</tt>s of {@link
   * #speechActivity} i.e. the dominant speaker history has changed.
   *
   * <p>This instance notifies the video <tt>Channel</tt>s about the change so that they may update
   * their last-n lists and report to this instance which <tt>Endpoint</tt>s are to be asked for
   * video keyframes.
   */
  private void speechActivityEndpointsChanged() {
    List<Endpoint> endpoints = null;

    for (Content content : getContents()) {
      if (MediaType.VIDEO.equals(content.getMediaType())) {
        Set<Endpoint> endpointsToAskForKeyframes = null;

        endpoints = speechActivity.getEndpoints();
        for (Channel channel : content.getChannels()) {
          if (!(channel instanceof RtpChannel)) continue;

          RtpChannel rtpChannel = (RtpChannel) channel;
          List<Endpoint> channelEndpointsToAskForKeyframes =
              rtpChannel.speechActivityEndpointsChanged(endpoints);

          if ((channelEndpointsToAskForKeyframes != null)
              && !channelEndpointsToAskForKeyframes.isEmpty()) {
            if (endpointsToAskForKeyframes == null) {
              endpointsToAskForKeyframes = new HashSet<>();
            }
            endpointsToAskForKeyframes.addAll(channelEndpointsToAskForKeyframes);
          }
        }

        if ((endpointsToAskForKeyframes != null) && !endpointsToAskForKeyframes.isEmpty()) {
          content.askForKeyframes(endpointsToAskForKeyframes);
        }
      }
    }
  }
  @Nullable
  private static RunContentDescriptor chooseReuseContentForDescriptor(
      final ContentManager contentManager, final RunContentDescriptor descriptor) {
    Content content = null;
    if (descriptor != null) {
      if (descriptor.isContentReuseProhibited()) {
        return null;
      }
      final Content attachedContent = descriptor.getAttachedContent();
      if (attachedContent != null && attachedContent.isValid()) content = attachedContent;
    }
    if (content == null) {
      content = contentManager.getSelectedContent();
      if (content != null && content.isPinned()) content = null;
    }
    if (content == null || !isTerminated(content)) {
      return null;
    }
    final RunContentDescriptor oldDescriptor = getRunContentDescriptorByContent(content);
    if (oldDescriptor != null && !oldDescriptor.isContentReuseProhibited()) {
      return oldDescriptor;
    }

    return null;
  }
 @Override
 public boolean serialize(final ByteBuffer buffer) {
   if (this.contents.size() > 65535) {
     return false;
   }
   buffer.putShort((short) this.contents.size());
   for (int i = 0; i < this.contents.size(); ++i) {
     final Content contents_element = this.contents.get(i);
     final boolean contents_element_ok = contents_element.serialize(buffer);
     if (!contents_element_ok) {
       return false;
     }
   }
   if (this.contentsSelection != null) {
     buffer.put((byte) 1);
     final boolean contentsSelection_ok = this.contentsSelection.serialize(buffer);
     if (!contentsSelection_ok) {
       return false;
     }
   } else {
     buffer.put((byte) 0);
   }
   if (this.buyableContents.size() > 65535) {
     return false;
   }
   buffer.putShort((short) this.buyableContents.size());
   for (int i = 0; i < this.buyableContents.size(); ++i) {
     final BuyableContent buyableContents_element = this.buyableContents.get(i);
     final boolean buyableContents_element_ok = buyableContents_element.serialize(buffer);
     if (!buyableContents_element_ok) {
       return false;
     }
   }
   return true;
 }
Example #10
0
  /* ------------------------------------------------------------ */
  private void shrinkCache() {
    // While we need to shrink
    while (_cache.size() > 0
        && (_cachedFiles.get() > _maxCachedFiles || _cachedSize.get() > _maxCacheSize)) {
      // Scan the entire cache and generate an ordered list by last accessed time.
      SortedSet<Content> sorted =
          new TreeSet<Content>(
              new Comparator<Content>() {
                public int compare(Content c1, Content c2) {
                  if (c1._lastAccessed < c2._lastAccessed) return -1;

                  if (c1._lastAccessed > c2._lastAccessed) return 1;

                  if (c1._length < c2._length) return -1;

                  return c1._key.compareTo(c2._key);
                }
              });
      for (Content content : _cache.values()) sorted.add(content);

      // Invalidate least recently used first
      for (Content content : sorted) {
        if (_cachedFiles.get() <= _maxCachedFiles && _cachedSize.get() <= _maxCacheSize) break;
        if (content == _cache.remove(content.getKey())) content.invalidate();
      }
    }
  }
 private void startTag(String aPrefix, String aName, XmlPullParser aParser) throws Exception {
   if ("entry".equals(aName)) {
     tweets.addTweet(currentTweet = new Tweet());
   } else if ("published".equals(aName)) {
     aParser.next();
     currentTweet.setPublished(dateFormat.parse(aParser.getText()));
   } else if (("title".equals(aName)) && (currentTweet != null)) {
     aParser.next();
     currentTweet.setTitle(aParser.getText());
   } else if ("content".equals(aName)) {
     Content _c = new Content();
     _c.setType(aParser.getAttributeValue(null, "type"));
     aParser.next();
     _c.setValue(aParser.getText());
     currentTweet.setContent(_c);
   } else if ("lang".equals(aName)) {
     aParser.next();
     currentTweet.setLanguage(aParser.getText());
   } else if ("author".equals(aName)) {
     currentTweet.setAuthor(currentAuthor = new Author());
   } else if ("name".equals(aName)) {
     aParser.next();
     currentAuthor.setName(aParser.getText());
   } else if ("uri".equals(aName)) {
     aParser.next();
     currentAuthor.setUri(aParser.getText());
   }
 }
Example #12
0
 public Evaluator(
     ReportPage page,
     ReportPages pages,
     Content content,
     ContentState contentState,
     DataContainer dataContainer) {
   this.basicContext = new BasicContext();
   this.basicContext.report = content.getReport();
   this.basicContext.data = content.getData();
   this.basicContext.dataRecord = content.getData().getRecord();
   this.contentContext = new ContentContext();
   this.contentContext.content = content;
   this.contentContext.contentState = contentState;
   this.pageContext = new PageContext();
   this.pageContext.page = page;
   this.pageContext.pages = pages;
   this.pageContext.dataContainer = dataContainer;
   {
     ContentDesign cd = this.contentContext.content.design;
     if (cd.variables != null) {
       for (String k : cd.variables.keySet()) {
         this.pageContext.variables.put(k, this.evalTry(cd.variables.get(k)));
       }
     }
   }
 }
Example #13
0
  /* ------------------------------------------------------------ */
  private HttpContent load(String pathInContext, Resource resource) throws IOException {
    Content content = null;

    if (resource == null || !resource.exists()) return null;

    // Will it fit in the cache?
    if (!resource.isDirectory() && isCacheable(resource)) {
      // Create the Content (to increment the cache sizes before adding the content
      content = new Content(pathInContext, resource);

      // reduce the cache to an acceptable size.
      shrinkCache();

      // Add it to the cache.
      Content added = _cache.putIfAbsent(pathInContext, content);
      if (added != null) {
        content.invalidate();
        content = added;
      }

      return content;
    }

    return new HttpContent.ResourceAsHttpContent(
        resource,
        _mimeTypes.getMimeByExtension(resource.toString()),
        getMaxCachedFileSize(),
        _etags);
  }
  public void assignContent(Content content, Set<String> serverGroups, boolean enable) {
    List<Operation> operations = new ArrayList<>();
    for (String serverGroup : serverGroups) {
      ResourceAddress address =
          new ResourceAddress()
              .add("server-group", serverGroup)
              .add("deployment", content.getName());
      Operation operation =
          new Operation.Builder(ADD, address)
              .param("runtime-name", content.getRuntimeName())
              .param("enabled", enable)
              .build();
      operations.add(operation);
    }
    dispatcher.execute(
        new DMRAction(new Composite(operations)),
        new AsyncCallback<DMRResponse>() {
          @Override
          public void onFailure(final Throwable caught) {
            Console.error("Unable to assign " + content.getName() + ".", caught.getMessage());
          }

          @Override
          public void onSuccess(final DMRResponse response) {
            ModelNode result = response.get();
            if (result.isFailure()) {
              Console.error(
                  "Unable to assign " + content.getName() + ".", result.getFailureDescription());
            } else {
              Console.info(content.getName() + " successfully assigned to selected server groups.");
              loadContentRepository();
            }
          }
        });
  }
 public final void internalToString(final StringBuilder repr, final String prefix) {
   repr.append(prefix).append("contents=");
   if (this.contents.isEmpty()) {
     repr.append("{}").append('\n');
   } else {
     repr.append("(").append(this.contents.size()).append(" elements)...\n");
     for (int i = 0; i < this.contents.size(); ++i) {
       final Content contents_element = this.contents.get(i);
       contents_element.internalToString(repr, prefix + i + "/ ");
     }
   }
   repr.append(prefix).append("contentsSelection=");
   if (this.contentsSelection == null) {
     repr.append("{}").append('\n');
   } else {
     repr.append("...\n");
     this.contentsSelection.internalToString(repr, prefix + "  ");
   }
   repr.append(prefix).append("buyableContents=");
   if (this.buyableContents.isEmpty()) {
     repr.append("{}").append('\n');
   } else {
     repr.append("(").append(this.buyableContents.size()).append(" elements)...\n");
     for (int i = 0; i < this.buyableContents.size(); ++i) {
       final BuyableContent buyableContents_element = this.buyableContents.get(i);
       buyableContents_element.internalToString(repr, prefix + i + "/ ");
     }
   }
 }
  /**
   * Sets the values of the properties of a specific <tt>ColibriConferenceIQ</tt> to the values of
   * the respective properties of this instance. Thus, the specified <tt>iq</tt> may be thought of
   * as a description of this instance.
   *
   * <p><b>Note</b>: The copying of the values is deep i.e. the <tt>Contents</tt>s of this instance
   * are described in the specified <tt>iq</tt>.
   *
   * @param iq the <tt>ColibriConferenceIQ</tt> to set the values of the properties of this instance
   *     on
   */
  public void describeDeep(ColibriConferenceIQ iq) {
    describeShallow(iq);

    if (isRecording()) {
      ColibriConferenceIQ.Recording recordingIQ =
          new ColibriConferenceIQ.Recording(State.ON.toString());
      recordingIQ.setDirectory(getRecordingDirectory());
      iq.setRecording(recordingIQ);
    }
    for (Content content : getContents()) {
      ColibriConferenceIQ.Content contentIQ = iq.getOrCreateContent(content.getName());

      for (Channel channel : content.getChannels()) {
        if (channel instanceof SctpConnection) {
          ColibriConferenceIQ.SctpConnection sctpConnectionIQ =
              new ColibriConferenceIQ.SctpConnection();

          channel.describe(sctpConnectionIQ);
          contentIQ.addSctpConnection(sctpConnectionIQ);
        } else {
          ColibriConferenceIQ.Channel channelIQ = new ColibriConferenceIQ.Channel();

          channel.describe(channelIQ);
          contentIQ.addChannel(channelIQ);
        }
      }
    }
  }
 /**
  * Add the modifier and type for the member in the member summary.
  *
  * @param member the member to add the type for
  * @param type the type to add
  * @param tdSummaryType the content tree to which the modified and type will be added
  */
 protected void addModifierAndType(ProgramElementDoc member, Type type, Content tdSummaryType) {
   HtmlTree code = new HtmlTree(HtmlTag.CODE);
   addModifier(member, code);
   if (type == null) {
     if (member.isClass()) {
       code.addContent("class");
     } else {
       code.addContent("interface");
     }
     code.addContent(writer.getSpace());
   } else {
     if (member instanceof ExecutableMemberDoc
         && ((ExecutableMemberDoc) member).typeParameters().length > 0) {
       Content typeParameters =
           ((AbstractExecutableMemberWriter) this).getTypeParameters((ExecutableMemberDoc) member);
       code.addContent(typeParameters);
       // Code to avoid ugly wrapping in member summary table.
       if (typeParameters.charCount() > 10) {
         code.addContent(new HtmlTree(HtmlTag.BR));
       } else {
         code.addContent(writer.getSpace());
       }
       code.addContent(
           writer.getLink(
               new LinkInfoImpl(configuration, LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
     } else {
       code.addContent(
           writer.getLink(
               new LinkInfoImpl(configuration, LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
     }
   }
   tdSummaryType.addContent(code);
 }
Example #18
0
  /**
   * A {@link StartTag} can be only written after we are sure that all the necessary namespace
   * declarations are given.
   */
  boolean isReadyToCommit() {
    if (owner != null && owner.isBlocked()) return false;

    for (Content c = getNext(); c != null; c = c.getNext())
      if (c.concludesPendingStartTag()) return true;

    return false;
  }
Example #19
0
 /**
  * Get Full Text
  *
  * @return text
  */
 private String getText() {
   Content c = getContent();
   String str = "";
   try {
     str = c.getString(0, c.length() - 1); // 	cr at end
   } catch (Exception e) {
   }
   return str;
 } //	getString
 /** {@inheritDoc} */
 public Content getConstructorDetailsTreeHeader(ClassDoc classDoc, Content memberDetailsTree) {
   memberDetailsTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_DETAILS);
   Content constructorDetailsTree = writer.getMemberTreeHeader();
   constructorDetailsTree.addContent(writer.getMarkerAnchor(SectionName.CONSTRUCTOR_DETAIL));
   Content heading =
       HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, writer.constructorDetailsLabel);
   constructorDetailsTree.addContent(heading);
   return constructorDetailsTree;
 }
 /** {@inheritDoc} */
 protected void addNavDetailLink(boolean link, Content liNav) {
   if (link) {
     liNav.addContent(
         writer.getHyperLink(
             SectionName.CONSTRUCTOR_DETAIL, writer.getResource("doclet.navConstructor")));
   } else {
     liNav.addContent(writer.getResource("doclet.navConstructor"));
   }
 }
 private MailBuilder text(String text, boolean html) {
   Preconditions.checkNotNull(text, "text can't be null");
   Content content = new Content();
   content.text = text;
   content.html = html;
   contents.add(content);
   textOnly = contents.size() == 1;
   return this;
 }
Example #23
0
 public Evaluator(Content content, ContentState contentState) {
   this.basicContext = new BasicContext();
   this.basicContext.report = content.getReport();
   this.basicContext.data = content.getData();
   this.basicContext.dataRecord = content.getData().getRecord();
   this.contentContext = new ContentContext();
   this.contentContext.content = content;
   this.contentContext.contentState = contentState;
 }
 /**
  * Add the deprecated information for the given member.
  *
  * @param member the member being documented.
  * @param contentTree the content tree to which the deprecated information will be added.
  */
 protected void addDeprecatedInfo(ProgramElementDoc member, Content contentTree) {
   Content output =
       (new DeprecatedTaglet()).getTagletOutput(member, writer.getTagletWriterInstance(false));
   if (!output.isEmpty()) {
     Content deprecatedContent = output;
     Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent);
     contentTree.addContent(div);
   }
 }
Example #25
0
 /* ------------------------------------------------------------ */
 public void flushCache() {
   if (_cache != null) {
     while (_cache.size() > 0) {
       for (String path : _cache.keySet()) {
         Content content = _cache.remove(path);
         if (content != null) content.invalidate();
       }
     }
   }
 }
 public void launchUnassignContentDialog(Content content) {
   if (content.getAssignments().isEmpty()) {
     Console.warning(content.getName() + " is not assigned to a server group.");
   } else {
     Set<String> assignedServerGroupNames =
         Sets.newHashSet(Lists.transform(content.getAssignments(), Assignment::getServerGroup));
     unassignContentDialog.open(
         content, Ordering.natural().immutableSortedCopy(assignedServerGroupNames));
   }
 }
 /**
  * Build the member details contents of the page.
  *
  * @param node the XML element that specifies which components to document
  * @param annotationContentTree the content tree to which the documentation will be added
  */
 public void buildAnnotationTypeMemberDetails(XMLNode node, Content annotationContentTree) {
   Content memberDetailsTree = writer.getMemberTreeHeader();
   buildChildren(node, memberDetailsTree);
   if (memberDetailsTree.isValid()) {
     Content memberDetails = writer.getMemberTreeHeader();
     writer.addAnnotationDetailsMarker(memberDetails);
     memberDetails.addContent(writer.getMemberTree(memberDetailsTree));
     annotationContentTree.addContent(writer.getMemberDetailsTree(memberDetails));
   }
 }
  private int getComponentNumNamed(String s) {
    for (int i = 0; i < getContentManager().getContentCount(); i++) {
      final Content content = getContentManager().getContent(i);
      if (content != null && s.equals(content.getDisplayName())) {
        return i;
      }
    }

    return -1;
  }
 private void close() {
   MessageView messageView = MessageView.SERVICE.getInstance(myProject);
   Content[] contents = messageView.getContentManager().getContents();
   for (Content content : contents) {
     if (content.getComponent() == this) {
       messageView.getContentManager().removeContent(content, true);
       return;
     }
   }
 }
Example #30
0
 @Override
 public int serializedSize() {
   int size = 0;
   size += 2;
   for (int i = 0; i < this.gems.size(); ++i) {
     final Content gems_element = this.gems.get(i);
     size += gems_element.serializedSize();
   }
   return size;
 }