Package org.zanata.model

Examples of org.zanata.model.HProject


    @Override
    public String persist() {
        updateProjectType();

        HProject project = getProject();
        project.addIteration(getInstance());

        List<HLocale> projectLocales =
                localeServiceImpl
                        .getSupportedLanguageByProject(projectSlug);

        getInstance().getCustomizedLocales().addAll(projectLocales);

        getInstance().getCustomizedValidations().putAll(
                project.getCustomizedValidations());
        return super.persist();
    }
View Full Code Here


    public AddReviewCommentResult execute(AddReviewCommentAction action,
            ExecutionContext context) throws ActionException {
        throwExceptionIfCommentIsInvalid(action);

        WorkspaceId workspaceId = action.getWorkspaceId();
        HProject project =
                securityServiceImpl.checkWorkspaceStatus(workspaceId);

        HTextFlowTarget hTextFlowTarget =
                textFlowTargetDAO.getTextFlowTarget(action.getTransUnitId()
                        .getValue(), workspaceId.getLocaleId());
View Full Code Here

    public boolean getSetting() {
        if (overrideLocales == null) {
            if (slug == null || slug.isEmpty()) {
                setting = false;
            } else {
                HProject project = projectDAO.getBySlug(slug);
                setting = project.isOverrideLocales();
            }
            overrideLocales = new Boolean(setting);
        }
        return setting;
    }
View Full Code Here

    // TODO damason: put this in a more appropriate location
    private static GlobalDocumentId getGlobalId(HRawDocument rawDocument) {
        HDocument document = rawDocument.getDocument();
        HProjectIteration version = document.getProjectIteration();
        HProject project = version.getProject();

        GlobalDocumentId id =
                new GlobalDocumentId(project.getSlug(), version.getSlug(),
                        document.getDocId());

        return id;
    }
View Full Code Here

                    validationAction.getState());
        }

        String projectSlug = projectIteration.getProject().getSlug();
        String iterSlug = projectIteration.getSlug();
        HProject project = projectIteration.getProject();
        Boolean isProjectActive =
                projectIterationIsActive(project.getStatus(),
                        projectIteration.getStatus());
        ProjectType projectType = projectIteration.getProjectType();
        log.info(
                "Project {} iteration {} updated, status={}, isProjectActive={}, projectType={}",
                new Object[] { projectSlug, iterSlug,
View Full Code Here

                getProjectIterationDAO().getBySlug(projectSlug, iterationSlug);

        if (projectIteration == null) {
            throw new NoSuchWorkspaceException("Invalid workspace Id");
        }
        HProject project = projectIteration.getProject();
        if (project.getStatus() == EntityStatus.OBSOLETE) {
            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 =
                ULocale.getDisplayName(workspaceId.getLocaleId().toJavaName(),
                        ULocale.ENGLISH);

        return new WorkspaceContext(workspaceId, workspaceName,
View Full Code Here

                getProjectTypeError(projectIteration.getProjectType());
        if (projTypeError != null) {
            return projTypeError;
        }

        HProject hProject = projectDAO.getBySlug(getProjectSlug());

        if (hProject == null) {
            return Response.status(Status.NOT_FOUND)
                    .entity("Project '" + projectSlug + "' not found.").build();
        }
        // Project is Obsolete
        else if (Objects.equal(hProject.getStatus(), OBSOLETE)) {
            return Response.status(Status.NOT_FOUND)
                    .entity("Project '" + projectSlug + "' not found.").build();
        }
        // Project is ReadOnly
        else if (Objects.equal(hProject.getStatus(), READONLY)) {
            return Response.status(Status.FORBIDDEN)
                    .entity("Project '" + projectSlug + "' is read-only.")
                    .build();
        }

        HProjectIteration hProjectIteration =
                projectIterationDAO.getBySlug(getProjectSlug(),
                        getIterationSlug());

        if (hProjectIteration == null) { // must be a create operation
            response = request.evaluatePreconditions();
            if (response != null) {
                return response.build();
            }

            hProjectIteration = new HProjectIteration();
            hProjectIteration.setSlug(iterationSlug);

            copyProjectConfiguration(projectIteration, hProjectIteration,
                    hProject);

            hProject.addIteration(hProjectIteration);
            // pre-emptive entity permission check
            // identity.checkWorkspaceAction(hProject, "add-iteration");
            identity.checkPermission(hProjectIteration, "insert");

            response = Response.created(uri.getAbsolutePath());
View Full Code Here

            ResponseBuilder response = request.evaluatePreconditions(etag);
            if (response != null) {
                return response.build();
            }

            HProject hProject = projectDAO.getBySlug(getProjectSlug());
            Project project = toResource(hProject, accept);
            return Response.ok(project).tag(etag).build();
        } catch (NoSuchEntityException e) {
            return Response.status(Status.NOT_FOUND).build();
        }
View Full Code Here

    @Override
    public Response put(Project project) {
        ResponseBuilder response;
        EntityTag etag;

        HProject hProject = projectDAO.getBySlug(getProjectSlug());

        if (hProject == null) { // must be a create operation
            response = request.evaluatePreconditions();
            if (response != null) {
                return response.build();
            }
            hProject = new HProject();
            hProject.setSlug(projectSlug);
            // pre-emptive entity permission check
            identity.checkPermission(hProject, "insert");

            response = Response.created(uri.getAbsolutePath());
        }
        // Project is obsolete
        else if (Objects.equal(hProject.getStatus(), OBSOLETE)) {
            return Response.status(Status.FORBIDDEN)
                    .entity("Project '" + projectSlug + "' is obsolete.")
                    .build();
        }
        // Project is ReadOnly
        else if (Objects.equal(hProject.getStatus(), READONLY)) {
            return Response.status(Status.FORBIDDEN)
                    .entity("Project '" + projectSlug + "' is read-only.")
                    .build();
        } else {
            // must be an update operation
            // pre-emptive entity permission check
            identity.checkPermission(hProject, "update");
            etag = eTagUtils.generateTagForProject(projectSlug);
            response = request.evaluatePreconditions(etag);
            if (response != null) {
                return response.build();
            }

            response = Response.ok();
        }

        // null project type accepted for compatibility with old clients
        if (project.getDefaultType() != null) {
            if (project.getDefaultType().isEmpty()) {
                return Response.status(Status.BAD_REQUEST)
                        .entity("No valid default project type was specified.")
                        .build();
            }

            try {
                ProjectType.getValueOf(project.getDefaultType());
            } catch (Exception e) {
                String validTypes =
                        StringUtils.join(ProjectType.values(), ", ");
                return Response
                        .status(Status.BAD_REQUEST)
                        .entity("Project type \"" + project.getDefaultType()
                                + "\" not valid for this server."
                                + " Valid types: [" + validTypes + "]").build();
            }
        }

        transfer(project, hProject);

        if (identity != null && hProject.getMaintainers().isEmpty()) {
            HAccount hAccount =
                    accountDAO.getByUsername(identity.getCredentials()
                            .getUsername());
            if (hAccount != null && hAccount.getPerson() != null) {
                hProject.getMaintainers().add(hAccount.getPerson());
            }
        }

        projectDAO.makePersistent(hProject);
        projectDAO.flush();
View Full Code Here

        return (HProject) session.byNaturalId(HProject.class)
                .using("slug", getSlug()).load();
    }

    public void validateSuppliedId() {
        HProject ip = getInstance(); // this will raise an EntityNotFound
                                     // exception
        // when id is invalid and conversation will not
        // start

        if (ip.getStatus().equals(EntityStatus.OBSOLETE)
                && !checkViewObsolete()) {
            throw new EntityNotFoundException();
        }
    }
View Full Code Here

TOP

Related Classes of org.zanata.model.HProject

Copyright © 2018 www.massapicom. 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.