Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONAR-11321 Bind organization to alm installation when creating organ…
…ization * Return AlmAppInstallDto in select methods of AlmAppInstallDao, this is required in order to be able to more easily link an OrganizationDto to a AlmAppInstallDto in next commit * Create ORGANIZATION_ALM_BINDINGS table * Bind organization with installation when creating organization * Delete alm binding when removing organization * Delete alm binding when uninstalling ALM application * Return ALM info in api/organizations/search * Ensure user is admin to return Bitbucket team/user details
- Loading branch information
1 parent
f61d654
commit bcddd96
Showing
44 changed files
with
1,101 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmTesting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2018 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.db.alm; | |||
|
|||
public class AlmTesting { | |||
|
|||
private AlmTesting() { | |||
// only statics | |||
} | |||
|
|||
|
|||
} |
76 changes: 76 additions & 0 deletions
76
server/sonar-db-dao/src/main/java/org/sonar/db/alm/OrganizationAlmBindingDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,76 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2018 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.db.alm; | |||
|
|||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.Optional; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.core.util.UuidFactory; | |||
import org.sonar.core.util.stream.MoreCollectors; | |||
import org.sonar.db.Dao; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.organization.OrganizationDto; | |||
|
|||
import static org.sonar.db.DatabaseUtils.executeLargeInputs; | |||
|
|||
public class OrganizationAlmBindingDao implements Dao { | |||
|
|||
private final System2 system2; | |||
private final UuidFactory uuidFactory; | |||
|
|||
public OrganizationAlmBindingDao(System2 system2, UuidFactory uuidFactory) { | |||
this.system2 = system2; | |||
this.uuidFactory = uuidFactory; | |||
} | |||
|
|||
public Optional<OrganizationAlmBindingDto> selectByOrganization(DbSession dbSession, OrganizationDto organization) { | |||
return Optional.ofNullable(getMapper(dbSession).selectByOrganizationUuid(organization.getUuid())); | |||
} | |||
|
|||
public List<OrganizationAlmBindingDto> selectByOrganizations(DbSession dbSession, Collection<OrganizationDto> organizations) { | |||
return executeLargeInputs(organizations.stream().map(OrganizationDto::getUuid).collect(MoreCollectors.toSet()), | |||
organizationUuids -> getMapper(dbSession).selectByOrganizationUuids(organizationUuids)); | |||
} | |||
|
|||
public void insert(DbSession dbSession, OrganizationDto organization, AlmAppInstallDto almAppInstall, String url, String userUuid) { | |||
long now = system2.now(); | |||
getMapper(dbSession).insert(new OrganizationAlmBindingDto() | |||
.setUuid(uuidFactory.create()) | |||
.setOrganizationUuid(organization.getUuid()) | |||
.setAlmAppInstallUuid(almAppInstall.getUuid()) | |||
.setAlmId(almAppInstall.getAlm()) | |||
.setUrl(url) | |||
.setUserUuid(userUuid) | |||
.setCreatedAt(now)); | |||
} | |||
|
|||
public void deleteByOrganization(DbSession dbSession, OrganizationDto organization) { | |||
getMapper(dbSession).deleteByOrganizationUuid(organization.getUuid()); | |||
} | |||
|
|||
public void deleteByAlmAppInstall(DbSession dbSession, AlmAppInstallDto almAppInstall) { | |||
getMapper(dbSession).deleteByAlmAppInstallUuid(almAppInstall.getUuid()); | |||
} | |||
|
|||
private static OrganizationAlmBindingMapper getMapper(DbSession dbSession) { | |||
return dbSession.getMapper(OrganizationAlmBindingMapper.class); | |||
} | |||
} |
Oops, something went wrong.