Skip to content

Conversation

@zhengrenjie
Copy link
Contributor

No description provided.

@zhengrenjie zhengrenjie changed the title added a pom dependency: fastjson and added a method to get languages used in a project added some apis Jun 27, 2018
@zhengrenjie
Copy link
Contributor Author

Added a pom dependency: fastjson and added a method to get languages used in a project.
Added license template method and model.
Added markdown transformed method and model.

Copy link
Collaborator

@gmessner gmessner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. I do have a few requested changes:

  1. Remove the dependency on com.alibaba.fastjson
  2. Change getLanguages() as described below.
  3. This library follows a convention where there is a one-to-one mapping of GitLab API documentation page to an API Class, so the markdown methods belong in a new class to be called MarkdownApi and the license template methods belong in a class called LicensesApi

You'll need to add the 2 classes and add them to GitLabApi.java


package org.gitlab4j.api;

import com.alibaba.fastjson.JSONObject;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to introduce this to the project. See my comments on getLangauge() below.

Response response = post(expectedStatus, (Form) null, "projects", getProjectIdOrPath(projectIdOrPath), "unstar");
return (response.readEntity(Project.class));
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to introduce a new type for this, please re-implement getProjectLanguage(Integer projectId) as follows:

    /**
     * Get languages used in a project with percentage value.
     *
     * Get /projects/:id/languages
     *
     * @param projectId the ID of the project
     * @return a Map instance with the language as the key and the percentage as the value
     * @throws GitLabApiException if any exception occurs
     * @since GitLab 10.8
     */
    public Map<String, Float> getProjectLanguages(Integer projectId) throws GitLabApiException {

        if (projectId == null) {
            throw new RuntimeException("projectId cannot be null");
        }

        Response response = get(Response.Status.OK, null, "projects", projectId, "languages");
        return (response.readEntity(new GenericType<Map<String, Float>>() { }));
    }

pom.xml Outdated
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to introduce this new library, see my comments in ProjectApi.java

@zhengrenjie
Copy link
Contributor Author

@gmessner Thank you very much for your suggestion. I will submit it again after the revision.

renjie added 2 commits June 28, 2018 10:36
Added 2 classes and moved the corresponding methods to.
Added 2 members LicensesApi & MarkdownApi to GitLabApi.java.
Repaired getProjectLanguage(Integer projectId) as requested.
@zhengrenjie
Copy link
Contributor Author

I have completed the changes.if there are any questions please tell me, I'll fix them.

@gmessner
Copy link
Collaborator

Great job and making the requested changes.

@gmessner gmessner merged commit f75f0da into gitlab4j:master Jun 28, 2018
@gmessner
Copy link
Collaborator

gmessner commented Jun 28, 2018

@zhengrenjie
This PR has been released in release 4.8.27. Thanks again for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants