Class OrganizationLinkerService
java.lang.Object
edu.ucsb.cs156.frontiers.services.OrganizationLinkerService
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTheplan.nameGitHub reports for an organization on its Free plan. -
Constructor Summary
ConstructorsConstructorDescriptionOrganizationLinkerService(org.springframework.boot.web.client.RestTemplateBuilder restTemplateBuilder) -
Method Summary
Modifier and TypeMethodDescriptioncheckCourseWarnings(Course course) getDefaultRepositoryPermission(Course course) Retrieves the default repository permission for the GitHub organization linked to a course.getOrgName(String installation_id) Provides the name of the organization attached to a particular installation IDstatic StringgetPlanName(com.fasterxml.jackson.databind.JsonNode orgJson) Extracts the organization's plan name (e.g.Returns the URL for a redirect to install FrontiersvoidunenrollOrganization(Course course) Removes the Frontiers installation from the linked GitHub org
-
Field Details
-
FREE_PLAN_NAME
Theplan.nameGitHub reports for an organization on its Free plan.- See Also:
-
-
Constructor Details
-
OrganizationLinkerService
public OrganizationLinkerService(org.springframework.boot.web.client.RestTemplateBuilder restTemplateBuilder)
-
-
Method Details
-
getRedirectUrl
public String getRedirectUrl() throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingExceptionReturns the URL for a redirect to install Frontiers- Returns:
- URL to install Frontiers to an organization
- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
getOrgName
public String getOrgName(String installation_id) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException Provides the name of the organization attached to a particular installation ID- Parameters:
installation_id- ID of the app installation- Returns:
- name of the organization attached to the installation
- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
checkCourseWarnings
public CourseWarning checkCourseWarnings(Course course) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException, NoLinkedOrganizationException - Throws:
NoSuchAlgorithmExceptionInvalidKeySpecExceptioncom.fasterxml.jackson.core.JsonProcessingExceptionNoLinkedOrganizationException
-
getPlanName
Extracts the organization's plan name (e.g.free,team,enterprise) from a GET /orgs/{org} response. GitHub only includes theplanobject when the GitHub App has the organization "Plan" (read) permission; without it, the plan is unknown and the empty string is returned, so no plan-based warning is shown.- Parameters:
orgJson- the response body of GET /orgs/{org}- Returns:
- the plan name, or the empty string if it is not present
-
getDefaultRepositoryPermission
public String getDefaultRepositoryPermission(Course course) throws NoSuchAlgorithmException, InvalidKeySpecException, com.fasterxml.jackson.core.JsonProcessingException, NoLinkedOrganizationException Retrieves the default repository permission for the GitHub organization linked to a course.- Parameters:
course- The course whose linked organization is queried.- Returns:
- The organization's default repository permission (e.g.
none,read). - Throws:
NoSuchAlgorithmExceptionInvalidKeySpecExceptioncom.fasterxml.jackson.core.JsonProcessingExceptionNoLinkedOrganizationException
-
unenrollOrganization
public void unenrollOrganization(Course course) throws NoSuchAlgorithmException, InvalidKeySpecException Removes the Frontiers installation from the linked GitHub org- Parameters:
course- The entity for the course about to be deleted- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecException
-