Пример #1
0
  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);
  }
Пример #2
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;
    }
  }
 /**
  * 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);
   }
 }
 @Override
 public boolean isReadable(ShareableResource resource) {
   Ticket ticket = SharingServiceFactory.getSharingTicketService().getTicket(resource.getToken());
   try {
     if (ticket != null && ticket instanceof NodeTicket) {
       NodePK nodePk =
           new NodePK(String.valueOf(ticket.getSharedObjectId()), ticket.getComponentId());
       Collection<NodePK> autorizedNodes = getNodeDescendants(nodePk);
       autorizedNodes.add(nodePk);
       if (resource.getAccessedObject() instanceof AttachmentDetail) {
         AttachmentDetail attachment = (AttachmentDetail) resource.getAccessedObject();
         return isPublicationReadable(
             attachment.getForeignKey(), nodePk.getInstanceId(), autorizedNodes);
       }
       if (resource.getAccessedObject() instanceof SimpleDocument) {
         SimpleDocument attachment = (SimpleDocument) resource.getAccessedObject();
         return isPublicationReadable(
             new ForeignPK(attachment.getForeignId(), attachment.getInstanceId()),
             nodePk.getInstanceId(),
             autorizedNodes);
       }
       if (resource.getAccessedObject() instanceof Document) {
         Document document = (Document) resource.getAccessedObject();
         return isPublicationReadable(
             document.getForeignKey(), nodePk.getInstanceId(), autorizedNodes);
       }
       if (resource.getAccessedObject() instanceof NodeDetail) {
         NodeDetail node = (NodeDetail) resource.getAccessedObject();
         return autorizedNodes.contains(node.getNodePK());
       }
     }
   } catch (Exception ex) {
     return false;
   }
   return false;
 }
 /*
  * (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());
 }
  /**
   * Method declaration
   *
   * @param userId
   * @param node
   * @see
   */
  public void addFavoritNode(String userId, NodePK node) {
    SilverTrace.info(
        "favorit",
        "FavoritBmEJB.addFavoritNode",
        "root.MSG_GEN_ENTER_METHOD",
        "userId = " + userId + ", node = " + node.toString());
    Connection con = null;

    try {
      con = getConnection();
      NodeActorLinkDAO.add(con, rootTableName, userId, node);
    } catch (Exception e) {
      throw new FavoritRuntimeException("favorit.CANNOT_ADD_FAVORIT", e);
    } finally {
      freeConnection(con);
    }
  }
  /**
   * Method declaration
   *
   * @param node
   * @param path
   * @see
   */
  public void removeFavoritByNodePath(NodePK node, String path) {
    SilverTrace.info(
        "favorit",
        "FavoritBmEJB.removeFavoritByNodePath",
        "root.MSG_GEN_ENTER_METHOD",
        "node = " + node.toString() + ", path = " + path);
    Connection con = null;

    try {
      con = getConnection();
      NodeActorLinkDAO.removeByNodePath(con, rootTableName, node, path);
    } catch (Exception e) {
      throw new FavoritRuntimeException("favorit.CANNOT_REMOVE_FAVORIT_BY_NODE", e);
    } finally {
      freeConnection(con);
    }
  }
 /**
  * Method declaration
  *
  * @param node
  * @param path
  * @see
  */
 @Override
 public void unsubscribeByPath(NodePK node, String path) {
   SilverTrace.info(
       "subscribe", "SubscribeBmEJB.removeSubscriptionsByPath", "root.MSG_GEN_ENTER_METHOD");
   Connection con = null;
   try {
     con = getConnection();
     subscriptionDao.removeByNodePath(con, node.getComponentName(), path);
   } catch (SQLException e) {
     DBUtil.rollback(con);
     throw new SubscribeRuntimeException(
         "SubscribeBmEJB.removeSubscriptionsByPath()",
         SilverpeasRuntimeException.ERROR,
         "subscribe.CANNOT_REMOVE_NODE_SUBSCRIBES",
         e);
   } finally {
     DBUtil.close(con);
   }
 }
Пример #9
0
  /**
   * 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);
    }
  }
 /*
  * (non-Javadoc)
  * @see
  * com.silverpeas.notification.builder.AbstractResourceUserNotificationBuilder#getResourceURL(
  * java.lang.Object)
  */
 @Override
 protected String getResourceURL(final NodePK resource) {
   return URLManager.getURL(null, null, resource.getInstanceId()) + "Main";
 }