Пример #1
0
  @Override
  public GetDocumentListResult execute(GetDocumentList action, ExecutionContext context)
      throws ActionException {
    identity.checkLoggedIn();

    LocaleId localeId = action.getWorkspaceId().getLocaleId();
    ProjectIterationId iterationId = action.getProjectIterationId();
    ArrayList<DocumentInfo> docs = new ArrayList<DocumentInfo>();
    HProjectIteration hProjectIteration =
        projectIterationDAO.getBySlug(iterationId.getProjectSlug(), iterationId.getIterationSlug());
    Collection<HDocument> hDocs = hProjectIteration.getDocuments().values();
    for (HDocument hDoc : hDocs) {
      if (action.getFilters() == null
          || action.getFilters().isEmpty()
          || action.getFilters().contains(hDoc.getPath() + hDoc.getName())) {
        DocumentId docId = new DocumentId(hDoc.getId(), hDoc.getDocId());
        TranslationStats stats = documentDAO.getStatistics(hDoc.getId(), localeId);
        String lastModifiedBy = "";
        HPerson person = hDoc.getLastModifiedBy();
        if (person != null) {
          lastModifiedBy = person.getAccount().getUsername();
        }

        Map<String, String> downloadExtensions = new HashMap<String, String>();
        downloadExtensions.put(".po", "po?docId=" + hDoc.getDocId());
        if (translationFileServiceImpl.hasPersistedDocument(
            iterationId.getProjectSlug(),
            iterationId.getIterationSlug(),
            hDoc.getPath(),
            hDoc.getName())) {
          String extension =
              "."
                  + translationFileServiceImpl.getFileExtension(
                      iterationId.getProjectSlug(),
                      iterationId.getIterationSlug(),
                      hDoc.getPath(),
                      hDoc.getName());
          downloadExtensions.put(extension, "baked?docId=" + hDoc.getDocId());
        }

        DocumentInfo doc =
            new DocumentInfo(
                docId,
                hDoc.getName(),
                hDoc.getPath(),
                hDoc.getLocale().getLocaleId(),
                stats,
                lastModifiedBy,
                hDoc.getLastChanged(),
                downloadExtensions);
        docs.add(doc);
      }
    }
    return new GetDocumentListResult(iterationId, docs);
  }
  @Restrict("#{s:hasPermission(versionGroupMaintainerManageAction.group,'update')}")
  public void deleteMaintainer(HPerson person) {
    log.debug("try to delete maintainer {0} from slug {1}", person.getName(), this.slug);
    HIterationGroup iterationGroup = versionGroupServiceImpl.getBySlug(this.slug);
    Set<HPerson> personList = iterationGroup.getMaintainers();
    for (HPerson l : personList) {
      if (l.getEmail().equals(person.getEmail())) {
        log.debug("remove the person");
        iterationGroup.getMaintainers().remove(l);
        break;
      }
    }

    versionGroupServiceImpl.makePersistent(iterationGroup);
    versionGroupServiceImpl.flush();
  }
Пример #3
0
 // TODO should we fire an event when username/name/email is changed (rare)?
 private void cacheUserDetails() {
   if (cachedUsername == null) {
     cachedUsername = getCredentials().getUsername();
   }
   if (cachedPersonName == null) {
     HAccount account = accountDAO.getByUsername(cachedUsername);
     if (account != null) {
       HPerson person = account.getPerson();
       if (person != null) {
         cachedPersonName = person.getName();
         cachedPersonEmail = person.getEmail();
       } else {
         cachedPersonEmail = null;
       }
     } else {
       cachedPersonEmail = null;
     }
   }
 }