Exemplo n.º 1
0
  public void removeContent(final Content content, boolean unmanaged) {
    Operation operation =
        new Operation.Builder(REMOVE, new ResourceAddress().add("deployment", content.getName()))
            .build();

    dispatcher.execute(
        new DMRAction(operation),
        new AsyncCallback<DMRResponse>() {
          @Override
          public void onFailure(final Throwable caught) {
            Console.error("Unable to remove deployment.", caught.getMessage());
          }

          @Override
          public void onSuccess(final DMRResponse response) {
            ModelNode result = response.get();
            if (result.isFailure()) {
              Console.error("Unable to remove deployment.", result.getFailureDescription());
            } else {
              Console.info(content.getName() + " successfully removed.");
              if (unmanaged) {
                loadUnassignedContent();
              } else {
                loadContentRepository();
              }
            }
          }
        });
  }
  /**
   * 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);
        }
      }
    }
  }
Exemplo n.º 3
0
  public void unassignContent(final Content content, Set<String> serverGroups) {
    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(REMOVE, address).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 unassign " + content.getName() + ".", caught.getMessage());
          }

          @Override
          public void onSuccess(final DMRResponse response) {
            ModelNode result = response.get();
            if (result.isFailure()) {
              Console.error(
                  "Unable to unassign " + content.getName() + ".", result.getFailureDescription());
            } else {
              Console.info(
                  content.getName() + " successfully unassigned from selected server groups.");
              loadContentRepository();
            }
          }
        });
  }
  public String renameNode(String newLabel)
      throws AccessDeniedException, ExchangeException, PathNotFoundException, RepositoryException {
    String returnValue;
    String parentPath = StringUtils.substringBeforeLast(this.getPath(), "/"); // $NON-NLS-1$
    newLabel = Path.getValidatedLabel(newLabel);

    // don't rename if it uses the same name as the current
    if (this.getPath().endsWith("/" + newLabel)) {
      return newLabel;
    }

    String dest = parentPath + "/" + newLabel; // $NON-NLS-1$
    if (getHierarchyManager().isExist(dest)) {
      newLabel = Path.getUniqueLabel(getHierarchyManager(), parentPath, newLabel);
      dest = parentPath + "/" + newLabel; // $NON-NLS-1$
    }
    this.deActivateNode(this.getPath());

    if (log.isInfoEnabled()) {
      log.info("Moving node from " + this.getPath() + " to " + dest); // $NON-NLS-1$ //$NON-NLS-2$
    }
    if (getHierarchyManager().isNodeData(this.getPath())) {
      Content parentPage = getHierarchyManager().getContent(parentPath);
      NodeData newNodeData = parentPage.createNodeData(newLabel);
      NodeData existingNodeData = getHierarchyManager().getNodeData(this.getPath());
      newNodeData.setValue(existingNodeData.getString());
      existingNodeData.delete();
      dest = parentPath;
    } else {
      // we can't rename a node. we must move
      // we must place the node at the same position
      Content current = getHierarchyManager().getContent(this.getPath());
      Content parent = current.getParent();
      String placedBefore = null;
      for (Iterator iter = parent.getChildren(current.getNodeTypeName()).iterator();
          iter.hasNext(); ) {
        Content child = (Content) iter.next();
        if (child.getHandle().equals(this.getPath())) {
          if (iter.hasNext()) {
            child = (Content) iter.next();
            placedBefore = child.getName();
          }
        }
      }

      getHierarchyManager().moveTo(this.getPath(), dest);

      // now set at the same place as before
      if (placedBefore != null) {
        parent.orderBefore(newLabel, placedBefore);
      }
    }

    Content newPage = getHierarchyManager().getContent(dest);
    returnValue = newLabel;
    newPage.updateMetaData();
    newPage.save();

    return returnValue;
  }
 public synchronized boolean equals(java.lang.Object obj) {
   if (!(obj instanceof Content)) return false;
   Content other = (Content) obj;
   if (obj == null) return false;
   if (this == obj) return true;
   if (__equalsCalc != null) {
     return (__equalsCalc == obj);
   }
   __equalsCalc = obj;
   boolean _equals;
   _equals =
       true
           && ((this.id == null && other.getId() == null)
               || (this.id != null && this.id.equals(other.getId())))
           && ((this.name == null && other.getName() == null)
               || (this.name != null && this.name.equals(other.getName())))
           && ((this.status == null && other.getStatus() == null)
               || (this.status != null && this.status.equals(other.getStatus())))
           && ((this.statusDefinedBy == null && other.getStatusDefinedBy() == null)
               || (this.statusDefinedBy != null
                   && this.statusDefinedBy.equals(other.getStatusDefinedBy())))
           && ((this.importDateTime == null && other.getImportDateTime() == null)
               || (this.importDateTime != null
                   && this.importDateTime.equals(other.getImportDateTime())))
           && ((this.lastModifiedDateTime == null && other.getLastModifiedDateTime() == null)
               || (this.lastModifiedDateTime != null
                   && this.lastModifiedDateTime.equals(other.getLastModifiedDateTime())))
           && ((this.userDefinedCustomTargetingValueIds == null
                   && other.getUserDefinedCustomTargetingValueIds() == null)
               || (this.userDefinedCustomTargetingValueIds != null
                   && java.util.Arrays.equals(
                       this.userDefinedCustomTargetingValueIds,
                       other.getUserDefinedCustomTargetingValueIds())))
           && ((this.mappingRuleDefinedCustomTargetingValueIds == null
                   && other.getMappingRuleDefinedCustomTargetingValueIds() == null)
               || (this.mappingRuleDefinedCustomTargetingValueIds != null
                   && java.util.Arrays.equals(
                       this.mappingRuleDefinedCustomTargetingValueIds,
                       other.getMappingRuleDefinedCustomTargetingValueIds())))
           && ((this.cmsSources == null && other.getCmsSources() == null)
               || (this.cmsSources != null
                   && java.util.Arrays.equals(this.cmsSources, other.getCmsSources())));
   __equalsCalc = null;
   return _equals;
 }
Exemplo n.º 6
0
 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));
   }
 }
Exemplo n.º 7
0
 /**
  * {@inheritDoc}
  *
  * <p>Creates a <tt>TransportManager</tt> instance suitable for an <tt>SctpConnection</tt> (e.g.
  * with 1 component only).
  */
 protected TransportManager createTransportManager(String xmlNamespace) throws IOException {
   if (IceUdpTransportPacketExtension.NAMESPACE.equals(xmlNamespace)) {
     Content content = getContent();
     return new IceUdpTransportManager(
         content.getConference(), isInitiator(), 1 /* num components */, content.getName());
   } else if (RawUdpTransportPacketExtension.NAMESPACE.equals(xmlNamespace)) {
     // TODO: support RawUdp once RawUdpTransportManager is updated
     // return new RawUdpTransportManager(this);
     throw new IllegalArgumentException("Unsupported Jingle transport " + xmlNamespace);
   } else {
     throw new IllegalArgumentException("Unsupported Jingle transport " + xmlNamespace);
   }
 }
Exemplo n.º 8
0
 public void launchAssignContentDialog(Content content) {
   Set<String> assignedServerGroupNames =
       Sets.newHashSet(Lists.transform(content.getAssignments(), Assignment::getServerGroup));
   Set<String> serverGroupNames =
       Sets.newHashSet(
           Lists.transform(serverGroupStore.getServerGroups(), ServerGroupRecord::getName));
   serverGroupNames.removeAll(assignedServerGroupNames);
   if (serverGroupNames.isEmpty()) {
     Console.warning(content.getName() + " is already assigned to all server groups.");
   } else {
     assignContentDialog.open(content, Ordering.natural().immutableSortedCopy(serverGroupNames));
   }
 }
  /**
   * Expires this <tt>Conference</tt>, its <tt>Content</tt>s and their respective <tt>Channel</tt>s.
   * Releases the resources acquired by this instance throughout its life time and prepares it to be
   * garbage collected.
   */
  public void expire() {
    synchronized (this) {
      if (expired) return;
      else expired = true;
    }

    EventAdmin eventAdmin = videobridge.getEventAdmin();
    if (eventAdmin != null) eventAdmin.sendEvent(EventFactory.conferenceExpired(this));

    setRecording(false);
    if (recorderEventHandler != null) {
      recorderEventHandler.close();
      recorderEventHandler = null;
    }

    Videobridge videobridge = getVideobridge();

    try {
      videobridge.expireConference(this);
    } finally {
      // Expire the Contents of this Conference.
      for (Content content : getContents()) {
        try {
          content.expire();
        } catch (Throwable t) {
          logger.warn(
              "Failed to expire content " + content.getName() + " of conference " + getID() + "!",
              t);
          if (t instanceof InterruptedException) Thread.currentThread().interrupt();
          else if (t instanceof ThreadDeath) throw (ThreadDeath) t;
        }
      }

      // Close the transportManagers of this Conference. Normally, there
      // will be no TransportManager left to close at this point because
      // all Channels have expired and the last Channel to be removed from
      // a TransportManager closes the TransportManager. However, a
      // Channel may have expired before it has learned of its
      // TransportManager and then the TransportManager will not close.
      closeTransportManagers();

      if (logger.isInfoEnabled()) {
        logger.info(
            "Expired conference " + getID() + ". " + videobridge.getConferenceCountString());
      }
    }
  }
  /**
   * Gets a <tt>Content</tt> of this <tt>Conference</tt> which has a specific name. If a
   * <tt>Content</tt> of this <tt>Conference</tt> with the specified <tt>name</tt> does not exist at
   * the time the method is invoked, the method initializes a new <tt>Content</tt> instance with the
   * specified <tt>name</tt> and adds it to the list of <tt>Content</tt>s of this
   * <tt>Conference</tt>.
   *
   * @param name the name of the <tt>Content</tt> which is to be returned
   * @return a <tt>Content</tt> of this <tt>Conference</tt> which has the specified <tt>name</tt>
   */
  public Content getOrCreateContent(String name) {
    Content content;

    synchronized (contents) {
      for (Content aContent : contents) {
        if (aContent.getName().equals(name)) {
          aContent.touch(); // It seems the content is still active.
          return aContent;
        }
      }

      content = new Content(this, name);
      if (isRecording()) {
        content.setRecording(true, getRecordingPath());
      }
      contents.add(content);
    }

    if (logger.isInfoEnabled()) {
      /*
       * The method Videobridge.getChannelCount() should better be
       * executed outside synchronized blocks in order to reduce the risks
       * of causing deadlocks.
       */
      Videobridge videobridge = getVideobridge();

      logger.info(
          "Created content "
              + name
              + " of conference "
              + getID()
              + ". "
              + videobridge.getConferenceCountString());
    }

    return content;
  }
 @Override
 public void render(SafeHtmlBuilder safeHtmlBuilder, Content model) {
   safeHtmlBuilder.appendEscaped(model.getName());
 }
Exemplo n.º 12
0
 /**
  * Returns a <tt>Content</tt> from the list of <tt>Content</tt>s of this <tt>conference</tt> IQ
  * which has a specific name. If no such <tt>Content</tt> exists, returns <tt>null</tt>.
  *
  * @param contentName the name of the <tt>Content</tt> to be returned
  * @return a <tt>Content</tt> from the list of <tt>Content</tt>s of this <tt>conference</tt> IQ
  *     which has the specified <tt>contentName</tt> if such a <tt>Content</tt> exists; otherwise,
  *     <tt>null</tt>
  */
 public Content getContent(String contentName) {
   for (Content content : getContents()) if (contentName.equals(content.getName())) return content;
   return null;
 }