/**
   * Removes a new process instance
   *
   * @param instanceId instance id
   */
  public void removeProcessInstance(String instanceId) throws WorkflowException {
    SilverTrace.info(
        "worflowEngine",
        "ProcessInstanceManagerImpl.removeProcessInstance()",
        "root.MSG_GEN_ENTER_METHOD",
        "InstanceId=" + instanceId);
    ProcessInstanceImpl instance;
    Database db = null;
    try {
      // Delete forms data associated with this instance
      removeProcessInstanceData(instanceId);

      // Constructs the query
      db = WorkflowJDOManager.getDatabase();
      db.begin();
      instance = (ProcessInstanceImpl) db.load(ProcessInstanceImpl.class, instanceId);
      db.remove(instance);
      db.commit();
    } catch (PersistenceException pe) {
      throw new WorkflowException(
          "ProcessInstanceManagerImpl.removeProcessInstance", "EX_ERR_CASTOR_REMOVE_INSTANCE", pe);
    } finally {
      WorkflowJDOManager.closeDatabase(db);
    }

    WorkflowHub.getErrorManager().removeErrorsOfInstance(instanceId);
    SilverTrace.info(
        "worflowEngine",
        "ProcessInstanceManagerImpl.removeProcessInstance()",
        "root.MSG_GEN_EXIT_METHOD");
  }
  /**
   * Method declaration
   *
   * @param id
   * @param percent
   * @throws TodoException
   * @see
   */
  public void setToDoPercentCompleted(String id, String percent) throws TodoException {
    SilverTrace.info(
        "todo", "ToDoSessionController.setToDoPercentCompleted()", "root.MSG_GEN_ENTER_METHOD");
    ToDoHeader todo = getToDoHeader(id);

    try {
      todo.setPercentCompleted(new Integer(percent).intValue());
    } catch (Exception e) {
      SilverTrace.warn(
          "todo",
          "ToDoSessionController.setToDoPercentCompleted()",
          "todo.MSG_CANT_SET_TODO_PERCENTCOMPLETED");
    }

    try {
      calendarBm.updateToDo(todo);
      SilverTrace.info(
          "todo", "ToDoSessionController.setToDoPercentCompleted()", "root.MSG_GEN_EXIT_METHOD");
    } catch (Exception e) {
      throw new TodoException(
          "ToDoSessionController.setToDoPercentCompleted()",
          SilverpeasException.ERROR,
          "todo.MSG_CANT_UPDATE_TODO_DETAIL",
          e);
    }
  }
 public Vector<AttachmentDetail> getAttachmentsByPKAndContext(
     AttachmentPK foreignKey, String context, Connection con) throws AttachmentException {
   if (con == null) {
     SilverTrace.info(
         "attachment",
         "AttachmentBmImpl.getAttachmentsByPKAndContext()",
         "root.MSG_GEN_PARAM_VALUE",
         "parameter con is null, new connection is created !");
     con = getConnection();
   } else {
     SilverTrace.info(
         "attachment",
         "AttachmentBmImpl.getAttachmentsByPKAndContext()",
         "root.MSG_GEN_PARAM_VALUE",
         "parameter con is not null, this connection is used !");
   }
   try {
     return dao.findByPKAndContext(con, foreignKey, context);
   } catch (SQLException se) {
     throw new AttachmentException(
         "AttachmentBmImpl.createAttachment()",
         SilverpeasException.ERROR,
         "attachment.EX_RECORD_NOT_LOAD",
         se);
   } finally {
     closeConnection(con);
   }
 }
 public Collection<SimpleDocument> getAttachments() {
   if (getPK() == null) {
     SilverTrace.info(
         "publication",
         "PublicationDetail.getAttachments()",
         "root.MSG_GEN_ENTER_METHOD",
         "getPK() is null !");
   } else {
     SilverTrace.info(
         "publication",
         "PublicationDetail.getAttachments()",
         "root.MSG_GEN_ENTER_METHOD",
         "getPK() is not null !");
   }
   AttachmentPK foreignKey =
       new AttachmentPK(getPK().getId(), getPK().getSpace(), getPK().getComponentName());
   SilverTrace.info(
       "publication",
       "PublicationDetail.getAttachments()",
       "root.MSG_GEN_PARAM_VALUE",
       "foreignKey = " + foreignKey.toString());
   Collection<SimpleDocument> attachmentList =
       AttachmentServiceFactory.getAttachmentService()
           .listDocumentsByForeignKeyAndType(foreignKey, DocumentType.attachment, null);
   SilverTrace.info(
       "publication",
       "PublicationDetail.getAttachments()",
       "root.MSG_GEN_PARAM_VALUE",
       "attachmentList.size() = " + attachmentList.size());
   return attachmentList;
 }
  public String getFieldValue(String fieldNameAndLanguage) {
    SilverTrace.info(
        "publication",
        "PublicationDetail.getModelContent()",
        "root.MSG_GEN_ENTER_METHOD",
        "fieldNameAndLanguage = " + fieldNameAndLanguage);

    String[] params = fieldNameAndLanguage.split(",");

    String fieldName = params[0];
    String language = null;
    if (params.length > 1) {
      language = params[1];
    }

    String fieldValue = "";

    List<XMLField> xmlFieldsForLanguage = getXmlFields(language);
    for (XMLField xmlField : xmlFieldsForLanguage) {
      if (fieldName.equals(xmlField.getName())) {
        fieldValue = getValueOfField(xmlField, language);
      }
    }

    SilverTrace.info(
        "publication",
        "PublicationDetail.getModelContent('" + fieldName + "')",
        "root.MSG_GEN_EXIT_METHOD",
        "fieldValue = " + fieldValue);
    return fieldValue;
  }
  /**
   * Indexes one space
   *
   * @param spaceId space identifier
   * @throws Exception whether an exception occurred
   */
  public void indexSpace(String spaceId) throws Exception {
    SilverTrace.info(
        ApplicationDYMIndexer.class.toString(),
        "ApplicationDYMIndexer.indexSpace()",
        "applicationIndexer.MSG_START_INDEXING_SPACE",
        "spaceId = " + spaceId);

    if (spaceId.startsWith(Admin.SPACE_KEY_PREFIX)) {
      spaceId = spaceId.substring(2);
    }

    // index space info
    admin.indexSpace(Integer.parseInt(spaceId));

    // index components
    String[] componentIds = organizationController.getAllComponentIds(spaceId);
    for (String componentId : componentIds) {
      indexComponent(spaceId, componentId);
    }

    // index sub spaces
    String[] subSpaceIds = organizationController.getAllSubSpaceIds(spaceId);
    for (String subSpaceId : subSpaceIds) {
      indexSpace(subSpaceId);
    }

    SilverTrace.info(
        ApplicationDYMIndexer.class.toString(),
        "ApplicationDYMIndexer.indexSpace()",
        "applicationIndexer.MSG_END_INDEXING_SPACE",
        "spaceId = " + spaceId);
  }
 public void index(String currentSpaceId, String componentId) throws Exception {
   setSilverTraceLevel();
   SilverTrace.info(
       "applicationIndexer", "ApplicationIndexer.index()", "root.MSG_GEN_ENTER_METHOD");
   if (currentSpaceId == null) {
     // index whole application
     String[] spaceIds = organizationController.getAllSpaceIds();
     SilverTrace.info(
         "applicationIndexer",
         "ApplicationIndexer.index()",
         "applicationIndexer.MSG_INDEXING_ALL_SPACES");
     for (String spaceId : spaceIds) {
       indexSpace(spaceId);
     }
   } else {
     if (!StringUtil.isDefined(componentId)) {
       // index whole space
       indexSpace(currentSpaceId);
     } else {
       // index only one component
       indexComponent(currentSpaceId, componentId);
     }
   }
   SilverTrace.info(
       "applicationIndexer", "ApplicationIndexer.index()", "root.MSG_GEN_EXIT_METHOD");
 }
  @Override
  public void update(Connection connection, T bean) throws PersistenceException {
    Connection con;
    if (connection == null) {
      con = getConnection();
    } else {
      con = connection;
    }
    PreparedStatement prepStmt = null;

    try {
      String statement = null;
      for (PropertyDescriptor property : properties) {
        String type = property.getPropertyType().getName();
        SilverTrace.info(
            "persistence",
            "SilverpeasBeanDAOImpl.update(SilverpeasBean bean)",
            "root.MSG_GEN_PARAM_VALUE",
            "property Name = " + property.getName() + ", type = " + type);

        if (isTypeValid(type) == true) {
          if (statement == null) {
            statement = property.getName() + " = ? ";
          } else {
            statement += ", " + property.getName() + " = ? ";
          }
        }
      }

      String updateStatement =
          "update " + getTableName(bean.getPK()) + " set " + statement + " where id = ?";

      prepStmt = con.prepareStatement(updateStatement);
      SilverTrace.info(
          "persistence",
          "SilverpeasBeanDAOImpl.update(SilverpeasBean bean)",
          "root.MSG_GEN_PARAM_VALUE",
          "queryStr = " + updateStatement + ", id= " + bean.getPK().getId());

      int count = prepareStatementSetProperties(prepStmt, bean);

      // for the where clause
      prepStmt.setInt(count, Integer.parseInt(bean.getPK().getId()));
      prepStmt.executeUpdate();

    } catch (Exception e) {
      throw new PersistenceException(
          "SilverpeasBeanDAOImpl.update(SilverpeasBean bean) ",
          SilverpeasException.ERROR,
          "persistence.EX_CANT_UPDATE_OBJECT",
          "",
          e);
    } finally {
      DBUtil.close(prepStmt);
      if (connection == null) {
        DBUtil.close(con);
      }
    }
  }
  public Group[] getAllChangedGroups(String lds, String extraFilter) throws AdminException {
    Vector<LDAPEntry> groupsCur;
    Iterator<LDAPEntry> it;
    int i;
    Hashtable<String, Group> groupsManaged = new Hashtable<String, Group>();
    LDAPEntry[] les = getChildGroupsEntry(lds, null, extraFilter);
    LDAPEntry theGroup;

    Vector<LDAPEntry> groupsIdsSet = new Vector<LDAPEntry>(les.length);
    for (i = 0; i < les.length; i++) {
      groupsIdsSet.add(les[i]);
      groupsManaged.put(les[i].getDN(), translateGroup(lds, les[i]));
    }
    // Go recurs to all group's ancestors
    while (groupsIdsSet.size() > 0) {
      it = groupsIdsSet.iterator();
      groupsCur = new Vector<LDAPEntry>();
      while (it.hasNext()) {
        theGroup = it.next();
        SilverTrace.info(
            "admin",
            "LDAPGroupSamse.getAllChangedGroups()",
            "root.MSG_GEN_PARAM_VALUE",
            "GroupTraite2=" + theGroup.getDN());
        les =
            LDAPUtility.search1000Plus(
                lds,
                driverSettings.getGroupsSpecificGroupsBaseDN(),
                driverSettings.getScope(),
                "(&"
                    + driverSettings.getGroupsFullFilter()
                    + "("
                    + driverSettings.getGroupsMemberField()
                    + "="
                    + LDAPUtility.dblBackSlashesForDNInFilters(theGroup.getDN())
                    + "))",
                driverSettings.getGroupsNameField(),
                driverSettings.getGroupAttributes());
        for (i = 0; i < les.length; i++) {
          SilverTrace.info(
              "admin",
              "LDAPGroupSamse.getAllChangedGroups()",
              "root.MSG_GEN_PARAM_VALUE",
              "GroupFound2=" + les[i].getDN());
          if (!groupsManaged.containsKey(les[i].getDN())) {
            SilverTrace.info(
                "admin",
                "LDAPGroupSamse.getAllChangedGroups()",
                "root.MSG_GEN_PARAM_VALUE",
                "GroupAjoute2=" + les[i].getDN());
            groupsCur.add(les[i]);
            groupsManaged.put(les[i].getDN(), translateGroup(lds, les[i]));
          }
        }
      }
      groupsIdsSet = groupsCur;
    }
    return groupsManaged.values().toArray(new Group[groupsManaged.size()]);
  }
 /**
  * Method declaration
  *
  * @throws TodoException
  * @see
  */
 public void indexAll() throws TodoException {
   SilverTrace.info("todo", "ToDoSessionController.indexAll()", "root.MSG_GEN_ENTER_METHOD");
   try {
     calendarBm.indexAllTodo();
     SilverTrace.info("todo", "ToDoSessionController.indexAll()", "root.MSG_GEN_EXIT_METHOD");
   } catch (Exception e) {
     throw new TodoException(
         "ToDoSessionController.indexAll()",
         SilverpeasException.ERROR,
         "todo.MSG_CANT_INDEX_TODOS",
         e);
   }
 }
 /**
  * Method declaration
  *
  * @param id
  * @throws TodoException
  * @see
  */
 public void removeToDo(String id) throws TodoException {
   SilverTrace.info("todo", "ToDoSessionController.removeToDo()", "root.MSG_GEN_ENTER_METHOD");
   try {
     calendarBm.removeToDo(id);
     SilverTrace.info("todo", "ToDoSessionController.removeToDo()", "root.MSG_GEN_EXIT_METHOD");
   } catch (Exception e) {
     throw new TodoException(
         "ToDoSessionController.removeToDo()",
         SilverpeasException.ERROR,
         "todo.MSG_CANT_REMOVE_TODO",
         e);
   }
 }
  @Override
  public void create(Connection con, String spaceId, String componentId, String userId)
      throws InstanciationException {
    SilverTrace.info(
        "almanach",
        "AlmanachInstanciator.create()",
        "almanach.MSG_CREATE_WITH_SPACE_AND_COMPONENT",
        "space : " + spaceId + "component : " + componentId);

    AttachmentInstanciator ai = new AttachmentInstanciator("com.stratelia.webactiv.almanach");
    ai.create(con, spaceId, componentId, userId);
    SilverTrace.info("almanach", "AlmanachInstanciator.create()", "root.MSG_GEN_EXIT_METHOD");
  }
 @Override
 public void delete(Connection con, String spaceId, String componentId, String userId)
     throws InstanciationException {
   SilverTrace.info(
       "mailingList",
       "MailingListInstanciator.delete()",
       "root.MSG_GEN_ENTER_METHOD",
       "space = " + spaceId + ", componentId = " + componentId + ", userId =" + userId);
   ServicesFactory servicesFactory = ServicesFactory.getFactory();
   servicesFactory.getMailingListService().deleteMailingList(componentId);
   SilverTrace.info("mailingList", "MailingListInstanciator.delete()", "root.MSG_GEN_EXIT_METHOD");
   servicesFactory.getMessageChecker().removeListener(componentId);
 }
  /**
   * Method declaration
   *
   * @param lds
   * @param groupEntry
   * @return
   * @throws AdminException
   * @see
   */
  @Override
  protected String[] getUserIds(String lds, LDAPEntry groupEntry) throws AdminException {
    Vector<String> usersVector = new Vector<String>();
    LDAPEntry userEntry = null;
    String[] stringVals = null;
    int i;

    SilverTrace.info(
        "admin", "LDAPGroupUniqueDescriptor.getUserIds()", "root.MSG_GEN_ENTER_METHOD");
    stringVals = LDAPUtility.getAttributeValues(groupEntry, driverSettings.getGroupsMemberField());
    for (i = 0; i < stringVals.length; i++) {
      try {
        // userEntry = LDAPUtility.getFirstEntryFromSearch(lds,
        // driverSettings.getLDAPUserBaseDN(), driverSettings.getScope(), "(&" +
        // driverSettings.getUsersFullFilter() + "(distinguishedName=" +
        // LDAPUtility.dblBackSlashesForDNInFilters(stringVals[i]) + "))");
        userEntry =
            LDAPUtility.getFirstEntryFromSearch(
                lds,
                stringVals[i],
                driverSettings.getScope(),
                driverSettings.getUsersFullFilter(),
                driverSettings.getGroupAttributes());
        if (userEntry != null) {
          String userSpecificId =
              LDAPUtility.getFirstAttributeValue(userEntry, driverSettings.getUsersIdField());
          // Verify that the user exist in the scope
          if (LDAPUtility.getFirstEntryFromSearch(
                  lds,
                  driverSettings.getLDAPUserBaseDN(),
                  driverSettings.getScope(),
                  driverSettings.getUsersIdFilter(userSpecificId),
                  driverSettings.getGroupAttributes())
              != null) {
            usersVector.add(userSpecificId);
          }
        }
      } catch (AdminException e) {
        SilverTrace.error(
            "admin",
            "LDAPGroupUniqueDescriptor.getUserIds()",
            "admin.MSG_ERR_LDAP_GENERAL",
            "USER NOT FOUND : " + LDAPUtility.dblBackSlashesForDNInFilters(stringVals[i]),
            e);
      }
    }
    stringVals = null;
    SilverTrace.info("admin", "LDAPGroupUniqueDescriptor.getUserIds()", "root.MSG_GEN_EXIT_METHOD");
    return usersVector.toArray(new String[usersVector.size()]);
  }
 @Override
 public void delete(Connection con, String spaceId, String componentId, String userId)
     throws InstanciationException {
   SilverTrace.info(
       "almanach",
       "AlmanachInstanciator.delete()",
       "almanach.MSG_DELETE_WITH_SPACE",
       "spaceId : " + spaceId);
   setDeleteQueries();
   deleteDataOfInstance(con, componentId, "Event");
   AttachmentInstanciator ai = new AttachmentInstanciator("com.stratelia.webactiv.almanach");
   ai.delete(con, spaceId, componentId, userId);
   SilverTrace.info("almanach", "AlmanachInstanciator.delete()", "root.MSG_GEN_EXIT_METHOD");
 }
  /**
   * Method declaration
   *
   * @param todoId
   * @return
   * @throws TodoException
   * @see
   */
  public ToDoHeader getToDoHeader(String todoId) throws TodoException {
    SilverTrace.info("todo", "ToDoSessionController.getToDoHeader()", "root.MSG_GEN_ENTER_METHOD");
    try {
      ToDoHeader result = calendarBm.getToDoHeader(todoId);

      SilverTrace.info("todo", "ToDoSessionController.getToDoHeader()", "root.MSG_GEN_EXIT_METHOD");
      return result;
    } catch (Exception e) {
      throw new TodoException(
          "ToDoSessionController.getToDoHeader()",
          SilverpeasException.ERROR,
          "todo.MSG_CANT_GET_TODO_DETAIL",
          e);
    }
  }
 /**
  * Method declaration
  *
  * @param todoId
  * @param userIds
  * @throws TodoException
  * @see
  */
 public void setToDoAttendees(String todoId, String[] userIds) throws TodoException {
   SilverTrace.info(
       "todo", "ToDoSessionController.setToDoAttendees()", "root.MSG_GEN_ENTER_METHOD");
   try {
     calendarBm.setToDoAttendees(todoId, userIds);
     SilverTrace.info(
         "todo", "ToDoSessionController.setToDoAttendees()", "root.MSG_GEN_EXIT_METHOD");
   } catch (Exception e) {
     throw new TodoException(
         "ToDoSessionController.setToDoAttendees()",
         SilverpeasException.ERROR,
         "todo.MSG_CANT_SET_TODO_ATTENDEES",
         e);
   }
 }
 @Override
 public void remove(Connection connection, WAPrimaryKey pk) throws PersistenceException {
   Connection con;
   if (connection == null) {
     con = getConnection();
   } else {
     con = connection;
   }
   PreparedStatement prepStmt = null;
   try {
     String updateStatement = "delete from " + getTableName(pk) + " where id = ?";
     prepStmt = con.prepareStatement(updateStatement);
     SilverTrace.info(
         "persistence",
         "SilverpeasBeanDAOImpl.remove(WAPrimaryKey pk)",
         "root.MSG_GEN_PARAM_VALUE",
         "queryStr = " + updateStatement + ", id= " + pk.getId());
     prepStmt.setInt(1, Integer.parseInt(pk.getId()));
     prepStmt.executeUpdate();
   } catch (SQLException e) {
     throw new PersistenceException(
         "SilverpeasBeanDAOImpl.remove(WAPrimaryKey pk)",
         SilverpeasException.ERROR,
         "persistence.EX_CANT_REMOVE_OBJECT",
         "",
         e);
   } finally {
     DBUtil.close(prepStmt);
     if (connection == null) {
       DBUtil.close(con);
     }
   }
 }
 public void initFromServer(String lds, String baseDN, String filter, String fallbackSortBy)
     throws AdminException {
   SilverTrace.info("admin", "LDAPTimeStampMSAD.initFromServer()", "root.MSG_GEN_ENTER_METHOD");
   LDAPEntry[] theEntries =
       LDAPUtility.search1000Plus(
           lds,
           baseDN,
           driverSettings.getScope(),
           "(&(" + driverSettings.getTimeStampVar() + ">=" + timeStamp + ")" + filter + ")",
           driverSettings.getTimeStampVar(),
           driverSettings.getGroupAttributes());
   if (theEntries.length > 0) {
     // Problem is : the search1000Plus function sorts normaly by descending
     // order. BUT most LDAP server can't performs this type of order (like
     // Active Directory)
     // So, it may be ordered in the oposite way....
     long firstVal =
         Long.parseLong(
             LDAPUtility.getFirstAttributeValue(theEntries[0], driverSettings.getTimeStampVar()));
     long lastVal =
         Long.parseLong(
             LDAPUtility.getFirstAttributeValue(
                 theEntries[theEntries.length - 1], driverSettings.getTimeStampVar()));
     if (firstVal >= lastVal) {
       lTimeStamp = firstVal;
     } else {
       lTimeStamp = lastVal;
     }
     timeStamp = Long.toString(lTimeStamp);
   }
 }
  public Vector<TodoDetail> getEntriesFromExternal(
      String spaceId, String componentId, String externalId) {
    SilverTrace.info(
        "calendar",
        "TodoBackboneAcess.getEntriesFromExternal(String spaceId, String componentId, String externalId)",
        "root.MSG_GEN_ENTER_METHOD",
        "spaceId=" + spaceId + ", componentId=" + componentId + ", externalId=" + externalId);
    try {
      Collection<ToDoHeader> headers =
          getCalendarBm().getExternalTodos(spaceId, componentId, externalId);
      Vector<TodoDetail> result = new Vector<TodoDetail>();
      for (ToDoHeader header : headers) {
        TodoDetail detail = todoHeaderToDetail(header);

        Collection<Attendee> list = getCalendarBm().getToDoAttendees(detail.getId());
        detail.setAttendees(new Vector<Attendee>(list));
        result.add(detail);
      }
      return result;
    } catch (Exception e) {
      SilverTrace.error(
          "calendar",
          "TodoBackboneAcess.getEntriesFromExternal(String spaceId, String componentId, String externalId)",
          "calendar.MSG_CANT_GET",
          "return null",
          e);
      return null;
    }
  }
  public void removeAttendeeToEntryFromExternal(
      String componentId, String externalId, String userId) {
    SilverTrace.info(
        "calendar",
        "TodoBackboneAcess.removeAttendeeToEntryFromExternal(String componentId, String externalId, String userId)",
        "root.MSG_GEN_ENTER_METHOD",
        "componentId=" + componentId + ", externalId=" + externalId + ", userId = " + userId);
    try {
      Attendee attendee = new Attendee();
      attendee.setUserId(userId);

      Collection<ToDoHeader> headers =
          getCalendarBm().getExternalTodos("useless", componentId, externalId);
      for (ToDoHeader header : headers) {
        if (header != null) {
          getCalendarBm().removeToDoAttendee(header.getId(), attendee);
        }
      }
    } catch (Exception e) {
      SilverTrace.error(
          "calendar",
          "TodoBackboneAcess.removeAttendeeToEntryFromExternal(String componentId, String externalId)",
          "calendar.MSG_CANT_REMOVE",
          "return null",
          e);
    }
  }
  /**
   * Method declaration
   *
   * @param con
   * @param statsType
   * @param conf
   * @throws SQLException
   * @see
   */
  static void purgeTablesCumul(Connection con, StatType statsType, StatisticsConfig conf)
      throws SQLException {
    StringBuilder deleteStatementBuf =
        new StringBuilder("DELETE FROM " + conf.getTableName(statsType) + "Cumul WHERE dateStat<");
    PreparedStatement prepStmt = null;

    // compute the last date to delete from
    Calendar dateOfTheDay = Calendar.getInstance();
    dateOfTheDay.add(Calendar.MONTH, -(conf.getPurge(statsType)));
    deleteStatementBuf.append(
        getRequestDate(dateOfTheDay.get(Calendar.YEAR), dateOfTheDay.get(Calendar.MONTH) + 1));

    String deleteStatement = deleteStatementBuf.toString();
    SilverTrace.info(
        "silverstatistics",
        "SilverStatisticsManagerDAO.purgeTablesCumul",
        "root.MSG_GEN_PARAM_VALUE",
        "deleteStatement=" + deleteStatement);

    try {
      prepStmt = con.prepareStatement(deleteStatement);
      prepStmt.executeUpdate();
    } finally {
      DBUtil.close(prepStmt);
    }
  }
  /**
   * Method declaration
   *
   * @return
   * @throws TodoException
   * @see
   */
  public Collection getClosedToDos() throws TodoException {
    SilverTrace.info("todo", "ToDoSessionController.getClosedToDos()", "root.MSG_GEN_ENTER_METHOD");
    try {
      Collection result = calendarBm.getClosedToDos(getUserId());

      SilverTrace.info(
          "todo", "ToDoSessionController.getClosedToDos()", "root.MSG_GEN_EXIT_METHOD");
      return result;
    } catch (Exception e) {
      throw new TodoException(
          "ToDoSessionController.getClosedToDos()",
          SilverpeasException.ERROR,
          "todo.MSG_CANT_GET_CLOSED_TODOS",
          e);
    }
  }
Ejemplo n.º 24
0
  /**
   * Remove domain authentication and settings properties file
   *
   * @param domainToRemove domain to remove
   * @throws DomainDeletionException
   */
  private void removeDomainPropertiesFile(Domain domainToRemove) throws DomainDeletionException {
    SilverTrace.info(
        "admin",
        "SQLDomainService.removeDomainAuthenticationPropertiesFile()",
        "root.MSG_GEN_ENTER_METHOD");

    String domainName = domainToRemove.getName();
    String domainPropertiesPath = FileRepositoryManager.getDomainPropertiesPath(domainName);
    String authenticationPropertiesPath =
        FileRepositoryManager.getDomainAuthenticationPropertiesPath(domainName);

    File domainPropertiesFile = new File(domainPropertiesPath);
    File authenticationPropertiesFile = new File(authenticationPropertiesPath);

    boolean domainPropertiesFileDeleted = domainPropertiesFile.delete();
    boolean authenticationPropertiesFileDeleted = authenticationPropertiesFile.delete();

    if ((!domainPropertiesFileDeleted) || (!authenticationPropertiesFileDeleted)) {
      SilverTrace.warn(
          "admin",
          "SQLDomainService.removeDomainAuthenticationPropertiesFile()",
          "admin.EX_DELETE_DOMAIN_PROPERTIES",
          "domainPropertiesFileDeleted:"
              + domainPropertiesFileDeleted
              + ", authenticationPropertiesFileDeleted:"
              + authenticationPropertiesFileDeleted);
    }
  }
  /**
   * Method declaration
   *
   * @param id
   * @throws TodoException
   * @see
   */
  public void reopenToDo(String id) throws TodoException {
    SilverTrace.info("todo", "ToDoSessionController.reopenToDo()", "root.MSG_GEN_ENTER_METHOD");
    ToDoHeader todo = getToDoHeader(id);

    todo.setCompletedDate(null);
    try {
      calendarBm.updateToDo(todo);
      SilverTrace.info("todo", "ToDoSessionController.reopenToDo()", "root.MSG_GEN_EXIT_METHOD");
    } catch (Exception e) {
      throw new TodoException(
          "ToDoSessionController.reopenToDo()",
          SilverpeasException.ERROR,
          "todo.MSG_CANT_UPDATE_TODO_DETAIL",
          e);
    }
  }
  /**
   * Method declaration
   *
   * @param con
   * @param questionContainerPK
   * @throws SQLException
   * @see
   */
  public static void openQuestionContainer(Connection con, QuestionContainerPK questionContainerPK)
      throws SQLException {
    SilverTrace.info(
        "questionContainer",
        "QuestionContainerDAO.openQuestionContainer()",
        "root.MSG_GEN_ENTER_METHOD",
        "questionContainerPK = " + questionContainerPK);

    String updateStatement =
        "update "
            + questionContainerPK.getTableName()
            + " set qcIsClosed = 0 , instanceId = ?"
            + " where qcId = ? ";

    PreparedStatement prepStmt = null;

    try {
      prepStmt = con.prepareStatement(updateStatement);
      prepStmt.setString(1, questionContainerPK.getComponentName());
      prepStmt.setInt(2, Integer.parseInt(questionContainerPK.getId()));
      prepStmt.executeUpdate();
    } finally {
      DBUtil.close(prepStmt);
    }
  }
  /**
   * Method declaration
   *
   * @param con
   * @param questionContainerPK
   * @return
   * @throws SQLException
   * @see
   */
  public static QuestionContainerHeader getQuestionContainerHeader(
      Connection con, QuestionContainerPK questionContainerPK) throws SQLException {
    SilverTrace.info(
        "questionContainer",
        "QuestionContainerDAO.getQuestionContainerHeader()",
        "root.MSG_GEN_ENTER_METHOD",
        "questionContainerPK = " + questionContainerPK);
    ResultSet rs = null;
    QuestionContainerHeader questionContainerHeader = null;

    String selectStatement =
        "select "
            + QUESTIONCONTAINERCOLUMNNAMES
            + " from "
            + questionContainerPK.getTableName()
            + " where qcId = ? ";

    PreparedStatement prepStmt = null;

    try {
      prepStmt = con.prepareStatement(selectStatement);
      prepStmt.setInt(1, Integer.parseInt(questionContainerPK.getId()));
      rs = prepStmt.executeQuery();
      if (rs.next()) {
        questionContainerHeader = getQuestionContainerHeaderFromResultSet(rs, questionContainerPK);
      }
    } finally {
      DBUtil.close(rs, prepStmt);
    }

    return questionContainerHeader;
  }
  /**
   * Method declaration
   *
   * @param con
   * @param qcPK
   * @return
   * @throws SQLException
   * @see
   */
  public static Collection<QuestionContainerHeader> getInWaitQuestionContainers(
      Connection con, QuestionContainerPK qcPK) throws SQLException {
    SilverTrace.info(
        "questionContainer",
        "QuestionContainerDAO.getInWaitQuestionContainers()",
        "root.MSG_GEN_ENTER_METHOD",
        "qcPK = " + qcPK);

    ResultSet rs = null;
    QuestionContainerHeader header = null;

    String selectStatement =
        "select "
            + QUESTIONCONTAINERCOLUMNNAMES
            + " from "
            + qcPK.getTableName()
            + " where ? < qcBeginDate and instanceId = ?";

    PreparedStatement prepStmt = null;

    try {
      prepStmt = con.prepareStatement(selectStatement);
      prepStmt.setString(1, formatter.format(new java.util.Date()));
      prepStmt.setString(2, qcPK.getComponentName());
      rs = prepStmt.executeQuery();
      List<QuestionContainerHeader> list = new ArrayList<QuestionContainerHeader>();
      while (rs.next()) {
        header = getQuestionContainerHeaderFromResultSet(rs, qcPK);
        list.add(header);
      }
      return list;
    } finally {
      DBUtil.close(rs, prepStmt);
    }
  }
  /**
   * Method declaration
   *
   * @param con
   * @param questionContainerHeader
   * @throws SQLException
   * @see
   */
  public static void updateQuestionContainerHeader(
      Connection con, QuestionContainerHeader questionContainerHeader) throws SQLException {
    SilverTrace.info(
        "questionContainer",
        "QuestionContainerDAO.updateQuestionContainerHeader()",
        "root.MSG_GEN_ENTER_METHOD",
        "questionContainerHeader = " + questionContainerHeader);

    String insertStatement =
        "update "
            + questionContainerHeader.getPK().getTableName()
            + " set qcTitle = ?,"
            + " qcDescription = ?,"
            + " qcComment = ?,"
            + " qcBeginDate = ?,"
            + " qcEndDate = ?,"
            + " qcNbVoters = ?,"
            + " qcNbQuestionsPage = ?,"
            + " qcNbMaxParticipations = ?,"
            + " qcNbTriesBeforeSolution = ?,"
            + " qcMaxTime = ?, "
            + " instanceId = ?, "
            + " anonymous = ?"
            + " where qcId = ?";

    PreparedStatement prepStmt = null;

    try {
      prepStmt = con.prepareStatement(insertStatement);
      prepStmt.setString(1, questionContainerHeader.getTitle());
      prepStmt.setString(2, questionContainerHeader.getDescription());
      prepStmt.setString(3, questionContainerHeader.getComment());
      if (questionContainerHeader.getBeginDate() == null) {
        prepStmt.setString(4, nullBeginDate);
      } else {
        prepStmt.setString(4, questionContainerHeader.getBeginDate());
      }
      if (questionContainerHeader.getEndDate() == null) {
        prepStmt.setString(5, nullEndDate);
      } else {
        prepStmt.setString(5, questionContainerHeader.getEndDate());
      }
      prepStmt.setInt(6, questionContainerHeader.getNbVoters());
      prepStmt.setInt(7, questionContainerHeader.getNbQuestionsPerPage());
      prepStmt.setInt(8, questionContainerHeader.getNbMaxParticipations());
      prepStmt.setInt(9, questionContainerHeader.getNbParticipationsBeforeSolution());
      prepStmt.setInt(10, questionContainerHeader.getMaxTime());
      prepStmt.setString(11, questionContainerHeader.getPK().getComponentName());
      if (questionContainerHeader.isAnonymous()) {
        prepStmt.setInt(12, 1);
      } else {
        prepStmt.setInt(12, 0);
      }
      prepStmt.setInt(13, Integer.parseInt(questionContainerHeader.getPK().getId()));
      prepStmt.executeUpdate();
    } finally {
      DBUtil.close(prepStmt);
    }
  }
 public synchronized void addSubscription() {
   SilverTrace.info(
       "webPages", "WebPagesSessionController.addSubscription()", "root.MSG_GEN_ENTER_METHOD");
   if (isSubscriber()) {
     return;
   }
   getSubscribeBm().subscribe(new ComponentSubscription(getUserId(), getComponentId()));
 }