private static void deleteNode(final NodePK pk, final Connection connection) throws SQLException {
    NodeNotificationService notificationService = NodeNotificationService.getService();
    notificationService.notifyOnDeletionOf(pk);

    NodeDAO.deleteRow(connection, pk);
    NodeI18NDAO.removeTranslations(connection, Integer.parseInt(pk.getId()));
    IndexEntryPK indexEntry = new IndexEntryPK(pk.getComponentName(), "Node", pk.getId());
    IndexEngineProxy.removeIndexEntry(indexEntry);
  }
 /**
  * Builds and sends a webpages notification. A warning message is logged when an exception is
  * catched.
  *
  * @param resource
  * @param userId
  */
 public static void notify(final NodePK resource, final String userId) {
   try {
     UserNotificationHelper.buildAndSend(new WebPagesUserNotifier(resource, userId));
   } catch (final Exception e) {
     SilverTrace.warn(
         "webPages",
         "WebPagesUserNotifier.notify()",
         "webPages.EX_IMPOSSIBLE_DALERTER_LES_UTILISATEURS",
         "nodeId = " + resource.getId(),
         e);
   }
 }
示例#3
0
  /**
   * Selection des éléments nécessaires à la construction de l'url de l'item.
   *
   * @return
   * @throws Exception
   */
  public String getUrl() throws Exception {
    PublicationDetail pub = null;
    NodeDetail node = null;
    String page = "";
    if (idTopic != null) {
      node = themetracker.getTopic(idTopic);
    } else if (idPub != null) {
      pub = themetracker.getPublicationDetail(idPub);
      Collection<NodePK> fathers = pub.getPublicationBm().getAllFatherPK(pub.getPK());
      Iterator<NodePK> it = fathers.iterator();
      while (it.hasNext()) {
        NodePK pk = it.next();
        node = themetracker.getTopic(pk.getId());
        if (excludeTopicNamed != null) {
          StringTokenizer st = new StringTokenizer(node.getFullPath(), "/");
          boolean found = false;
          while (st.hasMoreTokens()) {
            if (themetracker.getTopic(st.nextToken()).getName().equals(excludeTopicNamed)) {
              found = true;
              break;
            }
          }
          if (found == false) break;
        } else {
          break;
        }
      }

      @SuppressWarnings("unchecked")
      Collection<PublicationDetail> pubs =
          themetracker.getPublicationsByTopic(node.getId() + ",order,asc");
      Iterator<PublicationDetail> iPubs = pubs.iterator();
      int order = 1;
      while (iPubs.hasNext()) {
        PublicationDetail p = iPubs.next();
        if (p.getId().equals(pub.getId())) break;
        order++;
      }
      if (order > 1) page = "-" + order;
    } else {
      throw new Exception("Pas de publication ou de theme");
    }

    if (Boolean.parseBoolean(usePageNumber)) {
      return generateFullSemanticPath(node, pub) + page;
    } else {
      return generateFullSemanticPath(node, pub) + "-" + idPub;
    }
  }
 /*
  * (non-Javadoc)
  * @see com.silverpeas.notification.builder.AbstractTemplateUserNotificationBuilder#
  * performNotificationResource(java.lang.String, java.lang.Object,
  * com.silverpeas.notification.model.NotificationResourceData)
  */
 @Override
 protected void performNotificationResource(
     final String language,
     final NodePK resource,
     final NotificationResourceData notificationResourceData) {
   // The resource name corresponds at the label of the instantiated application
   notificationResourceData.setResourceName(
       OrganisationControllerFactory.getOrganisationController()
           .getComponentInstLight(getComponentInstanceId())
           .getLabel());
   notificationResourceData.setResourceId(resource.getId());
   notificationResourceData.setResourceType(getTemplatePath());
   // Exceptionally the resource location is builded at this level
   // Normally, the location is builded by the delayed notification mechanism
   notificationResourceData.setResourceLocation(buildResourceLocation());
 }
  /**
   * Deletes the specified node and all of its children within the specified data source connection.
   *
   * @param pk the primary key of the father node to delete.
   * @param inConnection the connection to use in the deletion.
   * @param afterDeletion the method to invoke after the deletion of a node.
   */
  public static void deleteNodes(
      final NodePK pk, final Connection inConnection, final AnonymousMethodOnNode afterDeletion) {
    try {
      Collection<NodeDetail> children = NodeDAO.getChildrenDetails(inConnection, pk);
      for (NodeDetail childNode : children) {
        deleteNodes(childNode.getNodePK(), inConnection, afterDeletion);
      }

      deleteNode(pk, inConnection);
      if (afterDeletion != null) {
        afterDeletion.invoke(pk);
      }
    } catch (Exception ex) {
      throw new NodeRuntimeException(
          "NodeBmEJB.removeNode()",
          SilverpeasRuntimeException.ERROR,
          "node.DELETING_NODE_FAILED",
          "nodeId = " + pk.getId(),
          ex);
    }
  }