/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerRemote.java

https://github.com/metlos/RHQ-old · Java · 230 lines · 41 code · 21 blank · 168 comment · 0 complexity · d7f6b08c56c7a11c92a002ccec41beb3 MD5 · raw file

  1. /*
  2. * RHQ Management Platform
  3. * Copyright (C) 2005-2008 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation version 2 of the License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19. package org.rhq.enterprise.server.content;
  20. import java.util.List;
  21. import javax.ejb.Remote;
  22. import org.rhq.core.domain.auth.Subject;
  23. import org.rhq.core.domain.content.Architecture;
  24. import org.rhq.core.domain.content.InstalledPackage;
  25. import org.rhq.core.domain.content.Package;
  26. import org.rhq.core.domain.content.PackageType;
  27. import org.rhq.core.domain.content.PackageVersion;
  28. import org.rhq.core.domain.content.composite.PackageAndLatestVersionComposite;
  29. import org.rhq.core.domain.content.composite.PackageTypeAndVersionFormatComposite;
  30. import org.rhq.core.domain.criteria.InstalledPackageCriteria;
  31. import org.rhq.core.domain.criteria.PackageCriteria;
  32. import org.rhq.core.domain.criteria.PackageVersionCriteria;
  33. import org.rhq.core.domain.util.PageList;
  34. import org.rhq.enterprise.server.resource.ResourceTypeNotFoundException;
  35. /**
  36. * @author Jay Shaughnessy
  37. */
  38. @Remote
  39. public interface ContentManagerRemote {
  40. /**
  41. * Creates a new package version in the system. If the parent package (identified by the packageName parameter) does
  42. * not exist, it will be created. If a package version exists with the specified version ID, a new one will not be
  43. * created and the existing package version instance will be returned.
  44. *
  45. * @param subject The logged in subject
  46. * @param packageName parent package name; uniquely identifies the package under which this version goes
  47. * @param packageTypeId identifies the type of package in case the general package needs to be created
  48. * @param version identifies the version to be create
  49. * @param architectureId architecture of the newly created package version. If null then no architecture restriction.
  50. *
  51. * @return newly created package version if one did not exist; existing package version that matches these data if
  52. * one was found
  53. */
  54. PackageVersion createPackageVersion(Subject subject, String packageName, int packageTypeId, String version,
  55. Integer architectureId, byte[] packageBytes);
  56. /**
  57. * Creates a new package version in the system. If the parent package (identified by the packageName parameter) does
  58. * not exist, it will be created. If a package version exists with the specified version ID, a new one will not be
  59. * created and the existing package version instance will be returned.
  60. *
  61. * @param subject The logged in subject
  62. * @param packageName parent package name; uniquely identifies the package under which this version goes
  63. * @param packageTypeId identifies the type of package in case the general package needs to be created
  64. * @param version identifies the version to be create
  65. * @param architectureId architecture of the newly created package version. If null then no architecture restriction.
  66. *
  67. * @return newly created package version if one did not exist; existing package version that matches these data if
  68. * one was found
  69. */
  70. PackageVersion createPackageVersionWithDisplayVersion(Subject subject, String packageName, int packageTypeId,
  71. String version, String displayVersion, Integer architectureId, byte[] packageBytes);
  72. /**
  73. * Deletes the specified package from the resource.
  74. *
  75. * @param subject The logged in subject
  76. * @param resourceId identifies the resource from which the packages should be deleted
  77. * @param installedPackageIds identifies all of the packages to be deleted
  78. */
  79. void deletePackages(Subject subject, int resourceId, int[] installedPackageIds, String requestNotes);
  80. /**
  81. * Deletes the specified PackageVersion from the system. The PackageVersion must be an orphan to be
  82. * deleted. If it is referenced by a content source, repo or installed package it must be removed via the
  83. * higher level construct and this call will have no effect.
  84. *
  85. * @param subject The logged in subject
  86. * @param packageVersionId The PackageVersion to delete.
  87. */
  88. public void deletePackageVersion(//
  89. Subject subject, int resourceId);
  90. /**
  91. * Deploys packages on the specified resources. Each installed package entry should be populated with the <code>
  92. * PackageVersion</code> being installed, along with the deployment configuration values if any. This method will
  93. * take care of populating the rest of the values in each installed package object.
  94. *
  95. * @param subject The logged in subject
  96. * @param resourceIds identifies the resources against which the package will be deployed
  97. * @param packageVersionIds packageVersions we want to install
  98. */
  99. @Deprecated
  100. void deployPackages(Subject subject, int[] resourceIds, int[] packageVersionIds);
  101. /**
  102. * Deploys packages on the specified resources. Each installed package entry should be populated with the <code>
  103. * PackageVersion</code> being installed, along with the deployment configuration values if any. This method will
  104. * take care of populating the rest of the values in each installed package object.
  105. *
  106. * @param subject The logged in subject
  107. * @param resourceIds identifies the resources against which the package will be deployed
  108. * @param packageVersionIds packageVersions we want to install
  109. * @param requestNotes request notes
  110. */
  111. void deployPackagesWithNote(Subject subject, int[] resourceIds, int[] packageVersionIds, String requestNotes);
  112. /**
  113. * Returns all architectures known to the system.
  114. *
  115. * @param subject The logged in subject
  116. * @return list of all architectures in the database
  117. */
  118. List<Architecture> findArchitectures(Subject subject);
  119. /**
  120. * This gets the package types that can be deployed to the given resource. It is a function of the resource
  121. * type of the resource.
  122. *
  123. * @param subject The logged in subject
  124. * @param resourceTypeName The resource type in question
  125. *
  126. * @return The requested list of package types. Can be empty.
  127. */
  128. List<PackageType> findPackageTypes(Subject subject, String resourceTypeName, String pluginName)
  129. throws ResourceTypeNotFoundException;
  130. /**
  131. * This re tries to find a package type of given name defined by the resource type
  132. * provided.
  133. * <p>
  134. * The resource type id can be null, in which case only the serverside defined package types
  135. * are searched for.
  136. *
  137. * @param subject the authenticated user
  138. * @param resourceTypeId the id of the resource type associated with the package type or null if only server-side package types should be searched for
  139. * @param packageTypeName the name of the package type to find
  140. * @return
  141. */
  142. PackageType findPackageType(Subject subject, Integer resourceTypeId, String packageTypeName);
  143. /**
  144. * Similar to {@link #findPackageType(Subject, Integer, String)} but
  145. * returns the package type along with the version format specification.
  146. *
  147. * @param subject
  148. * @param resourceTypeId
  149. * @param packageTypeName
  150. * @return
  151. */
  152. PackageTypeAndVersionFormatComposite findPackageTypeWithVersionFormat(Subject subject, Integer resourceTypeId,
  153. String packageTypeName);
  154. /**
  155. * @param subject
  156. * @param criteria {@link InstalledPackageCriteria}
  157. * @return InstalledPackages for the criteria
  158. */
  159. PageList<InstalledPackage> findInstalledPackagesByCriteria(Subject subject, InstalledPackageCriteria criteria);
  160. /**
  161. * If a resourceId filter is not set via {@link PackageVersionCriteria.addFilterResourceId()} then
  162. * this method requires InventoryManager permissions. When set the user must have permission to view
  163. * the resource.
  164. *
  165. * @param subject
  166. * @param criteria
  167. * @return Installed PackageVersions for the resource
  168. * @throws IllegalArgumentException for invalid resourceId filter
  169. */
  170. PageList<PackageVersion> findPackageVersionsByCriteria(Subject subject, PackageVersionCriteria criteria);
  171. /**
  172. * If the criteria object filters on repo id, the subject needs to be able to
  173. * access that repo. If there is no filter on repos, the subject needs to have
  174. * MANAGE_REPOSITORIES permission.
  175. *
  176. * @param subject
  177. * @param criteria
  178. * @return
  179. */
  180. PageList<Package> findPackagesByCriteria(Subject subject, PackageCriteria criteria);
  181. /**
  182. * Akin to {@link #findPackagesByCriteria(Subject, PackageCriteria)} but also
  183. * determines the latest version of the returned packages.
  184. * <p>
  185. * The provided criteria has to be limited to a specific repo using {@link PackageCriteria#addFilterRepoId(Integer)}.
  186. *
  187. * @param subject
  188. * @param criteria
  189. * @return
  190. * @throws IllegalArgumentException if the criteria doesn't define a repo filter
  191. */
  192. PageList<PackageAndLatestVersionComposite> findPackagesWithLatestVersion(Subject subject, PackageCriteria criteria);
  193. /**
  194. * For a resource that is content-backed (aka package-backed), this call will return InstalledPackage information
  195. * for the backing content (package).
  196. *
  197. * @param resourceId a valid resource
  198. * @return The InstalledPackage object for the content-packed resource. Or null for non-existent or non-package backed resource.
  199. */
  200. InstalledPackage getBackingPackageForResource(Subject subject, int resourceId);
  201. /**
  202. * This can be a dangerous call for large packages as the entire package will attempt to be loaded.
  203. * @param subject
  204. * @param resourceId
  205. * @param installedPackageId
  206. * @return the package bytes
  207. */
  208. byte[] getPackageBytes(Subject subject, int resourceId, int installedPackageId);
  209. }