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);
    }
  }
  /**
   * 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 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 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");
 }
  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;
  }
  /**
   * 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);
    }
  }
Exemplo n.º 8
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);
    }
  }
 /*
  * (non-Javadoc)
  * @see com.stratelia.webactiv.util.document.model.jcr.impl.JcrDocumentService# getUpdatedDocument
  * (com.stratelia.webactiv.util.document.model.DocumentVersion, java.lang.String)
  */
 public void getUpdatedDocument(DocumentVersion document) {
   Session session = null;
   try {
     session = BasicDaoFactory.getSystemSession();
     jcrDocumentDao.updateDocument(session, document);
     session.save();
   } catch (RepositoryException ex) {
     SilverTrace.error("document", "JcrDocumentServiceImpl", "document.jcr.create.exception", ex);
     throw new VersioningRuntimeException(
         "JcrDocumentServiceImpl",
         SilverpeasRuntimeException.ERROR,
         "document.jcr.create.exception",
         ex);
   } catch (IOException ex) {
     SilverTrace.error("document", "JcrDocumentServiceImpl", "document.jcr.create.exception", ex);
     throw new VersioningRuntimeException(
         "JcrDocumentServiceImpl",
         SilverpeasRuntimeException.ERROR,
         "document.jcr.create.exception",
         ex);
   } finally {
     if (session != null) {
       session.logout();
     }
   }
 }
 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);
   }
 }
Exemplo n.º 11
0
 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;
 }
  @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()]);
  }
 public void close() {
   try {
     if (calendarBm != null) calendarBm.remove();
   } catch (RemoteException e) {
     SilverTrace.error("toDoSession", "ToDoSessionController.close", "", e);
   } catch (RemoveException e) {
     SilverTrace.error("toDoSession", "ToDoSessionController.close", "", e);
   }
 }
Exemplo n.º 15
0
 public RestRequest(HttpServletRequest request) {
   elements = new HashMap<String, String>(10);
   if ("POST".equalsIgnoreCase(request.getMethod())) {
     action = CREATE;
   } else if ("GET".equalsIgnoreCase(request.getMethod())) {
     action = FIND;
   } else if ("PUT".equalsIgnoreCase(request.getMethod())) {
     action = UPDATE;
   } else if ("DELETE".equalsIgnoreCase(request.getMethod())) {
     action = DELETE;
   }
   String pathInfo = request.getRequestURI();
   String context = request.getContextPath();
   int startIndex = pathInfo.indexOf(context) + context.length();
   pathInfo = pathInfo.substring(startIndex);
   // substring du context
   if (pathInfo.startsWith("/")) {
     pathInfo = pathInfo.substring(1);
   }
   SilverTrace.debug(
       "mailingList", "RestRequest()", "root.MSG_GEN_ENTER_METHOD", "Parsing:" + pathInfo);
   StringTokenizer tokenizer = new StringTokenizer(pathInfo, "/", false);
   String element = tokenizer.nextToken();
   String id = tokenizer.nextToken();
   if ("RmailingList".equalsIgnoreCase(element)) {
     componentId = id;
     SilverTrace.debug(
         "mailingList", "RestRequest()", "root.MSG_GEN_ENTER_METHOD", "componentId=" + id);
   } else if (id != null) {
     elements.put(element, id);
     SilverTrace.debug(
         "mailingList", "RestRequest()", "root.MSG_GEN_ENTER_METHOD", element + '=' + id);
   }
   boolean isKey = true;
   String key = null;
   String value = null;
   while (tokenizer.hasMoreTokens()) {
     value = tokenizer.nextToken();
     if (isKey) {
       key = value;
       isKey = false;
     } else {
       elements.put(key, value);
       SilverTrace.debug(
           "mailingList", "RestRequest()", "root.MSG_GEN_ENTER_METHOD", key + '=' + value);
       isKey = true;
     }
   }
   if (DELETE_ACTION.equalsIgnoreCase(value)) {
     this.action = DELETE;
   } else if (UPDATE_ACTION.equalsIgnoreCase(value)) {
     this.action = UPDATE;
   }
 }
  /**
   * Logs in the user.
   *
   * @see javax.security.auth.spi.LoginModule#login()
   */
  @SuppressWarnings("unchecked")
  @Override
  public boolean login() throws LoginException {
    HttpRequestCallback rcb = new HttpRequestCallback();
    AuthorizerCallback acb = new AuthorizerCallback();
    Callback[] callbacks = new Callback[] {rcb, acb};
    try {
      // First, try to extract a Principal object out of the request
      // directly. If we find one, we're done.
      m_handler.handle(callbacks);
      HttpServletRequest request = rcb.getRequest();
      if (request == null) {
        throw new LoginException("No Http request supplied.");
      }
      UserDetail userDetail =
          (UserDetail) request.getAttribute(SilverpeasWikiAuthorizer.USER_ATTR_NAME);
      if (userDetail == null) {
        throw new LoginException("No user supplied.");
      }
      String[] userRoles = (String[]) request.getAttribute(SilverpeasWikiAuthorizer.ROLE_ATTR_NAME);
      Principal principal = new WikiPrincipal(userDetail.getLogin(), WikiPrincipal.LOGIN_NAME);
      Principal principalFullName =
          new WikiPrincipal(userDetail.getDisplayedName(), WikiPrincipal.FULL_NAME);
      Principal principalWikiName =
          new WikiPrincipal(userDetail.getDisplayedName(), WikiPrincipal.WIKI_NAME);
      SilverTrace.debug(
          "wiki",
          "SilverpeasWikiLoginModule",
          "Added Principal " + principal.getName() + ",Role.ANONYMOUS,Role.ALL");
      m_principals.add(new PrincipalWrapper(principal));
      m_principals.add(new PrincipalWrapper(principalWikiName));
      m_principals.add(new PrincipalWrapper(principalFullName));
      // Add any container roles
      injectWebAuthorizerRoles(acb.getAuthorizer(), request);
      // If login succeeds, commit these roles
      for (String userRole : userRoles) {
        m_principals.add(convertSilverpeasRole(userRole));
      }
      // If login succeeds, remove these principals/roles
      m_principalsToOverwrite.add(WikiPrincipal.GUEST);
      m_principalsToOverwrite.add(Role.ANONYMOUS);
      m_principalsToOverwrite.add(Role.ASSERTED);
      // If login fails, remove these roles
      m_principalsToRemove.add(Role.AUTHENTICATED);

      return true;
    } catch (IOException e) {
      SilverTrace.error("wiki", "SilverpeasWikiLoginModule", "wiki.EX_LOGIN", e);
      return false;
    } catch (UnsupportedCallbackException e) {
      SilverTrace.error("wiki", "SilverpeasWikiLoginModule", "wiki.EX_LOGIN", e);
      return false;
    }
  }
  public void delete(Connection con, String spaceId, String componentId, String userId)
      throws InstanciationException {
    SilverTrace.debug(
        "quickinfo", "QuickInfoInstanciator.delete()", "delete called with: space=" + spaceId);

    // delete publication component
    PublicationInstanciator pub = new PublicationInstanciator("com.stratelia.webactiv.quickinfo");
    pub.delete(con, spaceId, componentId, userId);

    SilverTrace.debug(
        "quickinfo", "QuickInfoInstanciator.delete()", "QuickInfoInstanciator.delete finished");
  }
  public List<AttachmentDetail> importAttachments(
      String pubId,
      String componentId,
      List<AttachmentDetail> attachments,
      String userId,
      boolean indexIt)
      throws FileNotFoundException {
    FormTemplateImportExport xmlIE = null;
    for (AttachmentDetail attDetail : attachments) {
      // TODO check user id
      attDetail.setAuthor(userId);
      attDetail.setInstanceId(componentId);
      XMLModelContentType xmlContent = attDetail.getXMLModelContentType();
      if (xmlContent != null) {
        attDetail.setXmlForm(xmlContent.getName());
      }
      InputStream input = null;
      // Store xml content
      try {
        input = getAttachmentContent(attDetail);
        this.addAttachmentToPublication(pubId, componentId, attDetail, input, indexIt);
        if (xmlContent != null) {
          if (xmlIE == null) {
            xmlIE = new FormTemplateImportExport();
          }
          ForeignPK pk =
              new ForeignPK(attDetail.getPK().getId(), attDetail.getPK().getInstanceId());
          xmlIE.importXMLModelContentType(pk, "Attachment", xmlContent, attDetail.getAuthor());
        }
      } catch (Exception e) {
        SilverTrace.error(
            "attachment",
            "AttachmentImportExport.importAttachments()",
            "root.MSG_GEN_PARAM_VALUE",
            e);
        SilverpeasTransverseErrorUtil.throwTransverseErrorIfAny(e, attDetail.getLanguage());
      } finally {
        IOUtils.closeQuietly(input);
      }

      if (attDetail.isRemoveAfterImport()) {
        boolean removed = FileUtils.deleteQuietly(getAttachmentFile(attDetail));
        if (!removed) {
          SilverTrace.error(
              "attachment",
              "AttachmentImportExport.importAttachments()",
              "root.MSG_GEN_PARAM_VALUE",
              "Can't remove file " + getAttachmentFile(attDetail));
        }
      }
    }
    return attachments;
  }
Exemplo n.º 19
0
  @Override
  public boolean isEmpty(List<FileItem> items, DataRecord record, PagesContext pagesContext) {
    boolean isEmpty = true;
    Iterator<FieldTemplate> itFields = null;
    if (fieldTemplates != null) {
      itFields = this.fieldTemplates.iterator();
    }
    if (itFields != null && itFields.hasNext()) {
      FieldDisplayer fieldDisplayer = null;
      FieldTemplate fieldTemplate = null;
      while (itFields.hasNext() || !isEmpty) {
        fieldTemplate = itFields.next();
        if (fieldTemplate != null) {
          String fieldType = fieldTemplate.getTypeName();
          String fieldDisplayerName = fieldTemplate.getDisplayerName();
          try {
            if (!StringUtil.isDefined(fieldDisplayerName)) {
              fieldDisplayerName = getTypeManager().getDisplayerName(fieldType);
            }
            fieldDisplayer = getTypeManager().getDisplayer(fieldType, fieldDisplayerName);
            if (fieldDisplayer != null) {
              String itemName = fieldTemplate.getFieldName();
              String itemValue = null;

              if (Field.TYPE_FILE.equals(fieldType)) {
                FileItem image = getParameter(items, itemName);
                if (image != null
                    && !image.isFormField()
                    && StringUtil.isDefined(image.getName())) {
                  isEmpty = false;
                }
              } else {
                if (fieldDisplayerName.equals("checkbox")) {
                  itemValue = getParameterValues(items, itemName);
                } else {
                  itemValue = getParameterValue(items, itemName);
                }
                if (StringUtil.isDefined(itemValue)) {
                  isEmpty = false;
                }
              }
            }
          } catch (FormException fe) {
            SilverTrace.error("form", "XmlSearchForm.isEmpty", "form.EXP_UNKNOWN_FIELD", null, fe);
          } catch (Exception e) {
            SilverTrace.error("form", "XmlSearchForm.isEmpty", "form.EXP_UNKNOWN_FIELD", null, e);
          }
        }
      }
    }
    return isEmpty;
  }
 @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 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);
   }
 }
 /**
  * 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);
   }
 }
  @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");
  }
  /**
   * Method declaration THIS FUNCTION THROW EXCEPTION ONLY WHEN NO SYNCHRO IS RUNNING
   *
   * @param lds
   * @param parentId
   * @return
   * @throws AdminException
   * @see
   */
  protected LDAPEntry[] getChildGroupsEntry(String lds, String parentId, String extraFilter)
      throws AdminException {
    if ((parentId != null) && (parentId.length() > 0)) { // ALL ROOT GROUPS
      return ArrayUtil.EMPTY_LDAP_ENTRY_ARRAY;
    } else {
      LDAPEntry[] theEntries = null;
      String theFilter;

      if ((extraFilter != null) && (extraFilter.length() > 0)) {
        theFilter = "(&" + extraFilter + driverSettings.getGroupsFullFilter() + ")";
      } else {
        theFilter = driverSettings.getGroupsFullFilter();
      }
      try {
        SilverTrace.info(
            "admin",
            "LDAPGroupSamse.getChildGroupsEntry()",
            "root.MSG_GEN_PARAM_VALUE",
            "Root Group Search");
        theEntries =
            LDAPUtility.search1000Plus(
                lds,
                driverSettings.getGroupsSpecificGroupsBaseDN(),
                driverSettings.getScope(),
                theFilter,
                driverSettings.getGroupsNameField(),
                driverSettings.getGroupAttributes());
        SynchroReport.debug(
            "LDAPGroupSamse.getChildGroupsEntry()",
            "Récupération de " + theEntries.length + " groupes racine",
            null);
      } catch (AdminException e) {
        if (synchroInProcess) {
          SilverTrace.warn(
              "admin",
              "LDAPGroupSamse.getChildGroupsEntry()",
              "admin.EX_ERR_CHILD_GROUPS",
              "ParentGroupId=" + parentId,
              e);
          append("PB getting Group's subgroups : ").append(parentId).append("\n");
          SynchroReport.error(
              "LDAPGroupSamse.getChildGroupsEntry()",
              "Erreur lors de la récupération des groupes racine (parentId = " + parentId + ")",
              e);
        } else {
          throw e;
        }
      }
      return theEntries;
    }
  }
Exemplo n.º 25
0
  public HashMap<String, String> getFormValues(String language) {
    HashMap<String, String> formValues = new HashMap<String, String>();
    if ("0".equals(getInfoId())) {
      // this publication does not use a form
      return formValues;
    }

    DataRecord data = null;
    PublicationTemplate pub = null;
    try {
      pub =
          PublicationTemplateManager.getInstance()
              .getPublicationTemplate(getPK().getInstanceId() + ":" + getInfoId());
      data = pub.getRecordSet().getRecord(pk.getId());
    } catch (Exception e) {
      SilverTrace.warn(
          "publication",
          "PublicationDetail.getFormValues",
          "CANT_GET_FORM_RECORD",
          "pubId = " + getPK().getId() + "infoId = " + getInfoId());
    }

    if (data == null) {
      return formValues;
    }

    String fieldNames[] = data.getFieldNames();
    PagesContext pageContext = new PagesContext();
    pageContext.setLanguage(language);
    for (String fieldName : fieldNames) {
      try {
        Field field = data.getField(fieldName);
        GenericFieldTemplate fieldTemplate =
            (GenericFieldTemplate) pub.getRecordTemplate().getFieldTemplate(fieldName);
        FieldDisplayer fieldDisplayer =
            TypeManager.getInstance().getDisplayer(fieldTemplate.getTypeName(), "simpletext");
        StringWriter sw = new StringWriter();
        PrintWriter out = new PrintWriter(sw);
        fieldDisplayer.display(out, field, fieldTemplate, pageContext);
        formValues.put(fieldName, sw.toString());
      } catch (Exception e) {
        SilverTrace.warn(
            "publication",
            "PublicationDetail.getFormValues",
            "CANT_GET_FIELD_VALUE",
            "pubId = " + getPK().getId() + "fieldName = " + fieldName,
            e);
      }
    }
    return formValues;
  }
 @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 THIS FUNCTION THROW EXCEPTION ONLY WHEN NO SYNCHRO IS RUNNING
   *
   * @param lds
   * @param parentId
   * @return
   * @throws AdminException
   * @see
   */
  protected Vector<LDAPEntry> getTRUEChildGroupsEntry(
      String lds, String parentId, LDAPEntry theEntry) {
    LDAPEntry childGroupEntry = null;
    Vector<LDAPEntry> entryVector = new Vector<LDAPEntry>();
    String[] stringVals = null;
    int i;

    if ((parentId != null) && (parentId.length() > 0)) {
      SilverTrace.info(
          "admin",
          "LDAPGroupSamse.getTRUEChildGroupsEntry()",
          "root.MSG_GEN_PARAM_VALUE",
          "Root Group Search : " + parentId);
      stringVals = LDAPUtility.getAttributeValues(theEntry, driverSettings.getGroupsMemberField());
      for (i = 0; i < stringVals.length; i++) {
        try {
          childGroupEntry =
              LDAPUtility.getFirstEntryFromSearch(
                  lds,
                  stringVals[i],
                  driverSettings.getScope(),
                  driverSettings.getGroupsFullFilter(),
                  driverSettings.getGroupAttributes());
          if (childGroupEntry != null) {
            // Verify that the group exist in the scope
            String groupSpecificId =
                LDAPUtility.getFirstAttributeValue(
                    childGroupEntry, driverSettings.getGroupsIdField());
            if (LDAPUtility.getFirstEntryFromSearch(
                    lds,
                    driverSettings.getGroupsSpecificGroupsBaseDN(),
                    driverSettings.getScope(),
                    driverSettings.getGroupsIdFilter(groupSpecificId),
                    driverSettings.getGroupAttributes())
                != null) {
              entryVector.add(childGroupEntry);
            }
          }
        } catch (AdminException e) {
          SilverTrace.error(
              "admin",
              "LDAPGroupSamse.getTRUEChildGroupsEntry()",
              "admin.MSG_ERR_LDAP_GENERAL",
              "GROUP NOT FOUND : " + stringVals[i],
              e);
        }
      }
    }
    return entryVector;
  }
  /**
   * 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()]);
  }
  /**
   * 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);
   }
 }