Examples of HLocale


Examples of org.zanata.model.HLocale

            tryUploadTranslationFile(GlobalDocumentId id, String localeId,
                    String mergeType, DocumentFileUploadForm uploadForm) {
        try {
            failIfTranslationUploadNotValid(id, localeId, uploadForm);

            HLocale locale = findHLocale(localeId);
            Optional<File> tempFile;
            int totalChunks;

            if (isSinglePart(uploadForm)) {
                totalChunks = 1;
                tempFile = Optional.<File> absent();
            } else {
                if (!uploadForm.getLast()) {
                    HDocumentUpload upload =
                            util.saveUploadPart(id, locale, uploadForm);
                    totalChunks = upload.getParts().size();
                    return Response
                            .status(Status.ACCEPTED)
                            .entity(new ChunkUploadResponse(upload.getId(),
                                    totalChunks, true,
                                    "Chunk accepted, awaiting remaining chunks."))
                            .build();
                } else {
                    HDocumentUpload previousParts =
                            documentUploadDAO
                                    .findById(uploadForm.getUploadId());
                    totalChunks = previousParts.getParts().size();
                    totalChunks++; // add final part
                    tempFile =
                            Optional.of(util
                                    .combineToTempFileAndDeleteUploadRecord(
                                            previousParts,
                                            uploadForm));
                }
            }

            TranslationsResource transRes;
            if (uploadForm.getFileType().equals(".po")) {
                InputStream poStream = getInputStream(tempFile, uploadForm);
                transRes =
                        translationFileServiceImpl.parsePoFile(poStream,
                                id.getProjectSlug(), id.getVersionSlug(),
                                id.getDocId());
            } else {
                if (!tempFile.isPresent()) {
                    tempFile =
                            Optional.of(util
                                    .persistTempFileFromUpload(uploadForm));
                }
                // FIXME this is misusing the 'filename' field. the method
                // should probably take a
                // type anyway
                transRes =
                        translationFileServiceImpl.parseAdapterTranslationFile(
                                tempFile.get(), id.getProjectSlug(),
                                id.getVersionSlug(), id.getDocId(), localeId,
                                uploadForm.getFileType());
            }
            if (tempFile.isPresent()) {
                tempFile.get().delete();
            }

            Set<String> extensions =
                    newExtensions(uploadForm.getFileType().equals(".po"));
            // TODO useful error message for failed saving?
            List<String> warnings =
                    translationServiceImpl.translateAllInDoc(
                            id.getProjectSlug(), id.getVersionSlug(),
                            id.getDocId(), locale.getLocaleId(), transRes,
                            extensions, mergeTypeFromString(mergeType));

            return transUploadResponse(totalChunks, warnings);
        } catch (FileNotFoundException e) {
            log.error("failed to create input stream from temp file", e);
View Full Code Here

Examples of org.zanata.model.HLocale

        }
    }

    private void failIfTranslationUploadNotAllowed(GlobalDocumentId id,
            String localeId) throws ChunkUploadException {
        HLocale locale = findHLocale(localeId);
        if (!isTranslationUploadAllowed(id, locale)) {
            throw new ChunkUploadException(Status.FORBIDDEN,
                    "You do not have permission to upload translations for locale \""
                            + localeId + "\" to project-version \""
                            + id.getProjectSlug() + ":" + id.getVersionSlug()
View Full Code Here

Examples of org.zanata.model.HLocale

        } catch (IllegalArgumentException e) {
            throw new ChunkUploadException(Status.BAD_REQUEST,
                    "Invalid value for locale", e);
        }

        HLocale locale = localeDAO.findByLocaleId(localeId);
        if (locale == null) {
            throw new ChunkUploadException(Status.NOT_FOUND,
                    "The specified locale \"" + localeString
                            + "\" does not exist on this server.");
        }
View Full Code Here

Examples of org.zanata.model.HLocale

            throw new NoSuchWorkspaceException("Project is obsolete");
        }
        if (projectIteration.getStatus() == EntityStatus.OBSOLETE) {
            throw new NoSuchWorkspaceException("Project Iteration is obsolete");
        }
        HLocale locale =
                getLocaleService().getByLocaleId(workspaceId.getLocaleId());
        if (locale == null) {
            throw new NoSuchWorkspaceException("Invalid Workspace Locale");
        }
        if (!locale.isActive()) {
            throw new NoSuchWorkspaceException("Locale '"
                    + locale.retrieveDisplayName() + "' disabled in server");
        }

        String workspaceName =
                project.getName() + " (" + projectIteration.getSlug() + ")";
        String localeDisplayName =
View Full Code Here

Examples of org.zanata.model.HLocale

    @Override
    public GetTransUnitListResult execute(GetTransUnitList action,
            ExecutionContext context) throws ActionException {
        identity.checkLoggedIn();
        HLocale hLocale = validateAndGetLocale(action);

        log.info("action: {}", action);
        int targetOffset = action.getOffset();
        int targetPageIndex = targetOffset / action.getCount();
        GetTransUnitsNavigationResult navigationResult = null;
View Full Code Here

Examples of org.zanata.model.HLocale

     * could be because of the entity in question having a composite primary
     * key. Need to try this in a later version of Hibernate.
     */
    @Override
    public void makeTransient(HLocaleMember entity) {
        HLocale locale = entity.getSupportedLanguage();
        getSession()
                .createQuery(
                        "delete HLocaleMember as m where m.id.supportedLanguage = :locale "
                                + "and m.id.person = :person")
                .setParameter("locale", locale)
                .setParameter("person", entity.getPerson()).executeUpdate();

        // We need to evict the HLocale to refresh member list within
        getSession().getSessionFactory().getCache()
                .evictEntity(HLocale.class, locale.getId());
    }
View Full Code Here

Examples of org.zanata.model.HLocale

        return locales;
    }

    @Restrict("#{s:hasPermission(projectHome.instance, 'update')}")
    public void removeLanguage(LocaleId localeId) {
        HLocale locale = localeServiceImpl.getByLocaleId(localeId);

        if (getInstance().isOverrideLocales()) {
            getInstance().getCustomizedLocales().remove(locale);
        } else {
            getInstance().getCustomizedLocales().clear();
            for (HLocale activeLocale : getInstanceActiveLocales()) {
                if (!activeLocale.equals(locale)) {
                    getInstance().getCustomizedLocales().add(activeLocale);
                }
            }
            getInstance().setOverrideLocales(true);
        }
        update();
        conversationScopeMessages.setMessage(
                FacesMessage.SEVERITY_INFO,
                msgs.format("jsf.project.LanguageRemoved",
                        locale.retrieveDisplayName()));
    }
View Full Code Here

Examples of org.zanata.model.HLocale

        public void onSelectItemAction() {
            if (StringUtils.isEmpty(getSelectedItem())) {
                return;
            }

            HLocale locale = localeServiceImpl.getByLocaleId(getSelectedItem());

            if (!getInstance().isOverrideLocales()) {
                getInstance().setOverrideLocales(true);
                getInstance().getCustomizedLocales().clear();
                getInstance().getCustomizedLocales().addAll(supportedLocales);
            }
            getInstance().getCustomizedLocales().add(locale);

            update(conversationScopeMessages);
            reset();
            conversationScopeMessages.setMessage(FacesMessage.SEVERITY_INFO,
                    msgs.format("jsf.project.LanguageAdded",
                            locale.retrieveDisplayName()));
        }
View Full Code Here

Examples of org.zanata.model.HLocale

        log.debug("start to get translation");
        String id = URIHelper.convertFromDocumentURIId(idNoSlash);
        HProjectIteration hProjectIteration =
                restSlugValidator.retrieveAndCheckIteration(projectSlug,
                        iterationSlug, false);
        HLocale hLocale =
                restSlugValidator.validateTargetLocale(locale, projectSlug,
                        iterationSlug);

        ResourceUtils.validateExtensions(extensions);
View Full Code Here

Examples of org.zanata.model.HLocale

            Response deleteTranslations(String idNoSlash, LocaleId locale) {
        String id = URIHelper.convertFromDocumentURIId(idNoSlash);
        HProjectIteration hProjectIteration =
                restSlugValidator.retrieveAndCheckIteration(projectSlug,
                        iterationSlug, true);
        HLocale hLocale =
                restSlugValidator.validateTargetLocale(locale, projectSlug,
                        iterationSlug);

        EntityTag etag =
                eTagUtils.generateETagForTranslatedDocument(hProjectIteration,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.