PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/org/andya/confluence/plugins/metadata/rpc/MetadataServiceDelegator.java

https://bitbucket.org/jwalton/metadata-confluence-plugin
Java | 108 lines | 62 code | 16 blank | 30 comment | 2 complexity | b86a290a3d008d174b5055b86cb52148 MD5 | raw file
  1. /*
  2. * Copyright (c) 2006, 2007 Andy Armstrong, Kelsey Grant and other contributors.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. * * The names of contributors may not
  14. * be used to endorse or promote products derived from this software without
  15. * specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  21. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  24. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. package org.andya.confluence.plugins.metadata.rpc;
  29. import com.atlassian.confluence.rpc.RemoteException;
  30. import com.atlassian.confluence.core.ContentPropertyManager;
  31. import com.atlassian.confluence.core.FormatSettingsManager;
  32. import com.atlassian.confluence.pages.PageManager;
  33. import com.atlassian.confluence.pages.Page;
  34. import com.atlassian.confluence.spaces.SpaceManager;
  35. import com.atlassian.user.UserManager;
  36. import org.andya.confluence.plugins.metadata.MetadataUtils;
  37. import org.andya.confluence.plugins.metadata.model.MetadataValue;
  38. import org.andya.confluence.utils.ContentService;
  39. /**
  40. * This is the delegator that does the real work for the metadata service.
  41. */
  42. public class MetadataServiceDelegator implements MetadataService {
  43. private ContentPropertyManager contentPropertyManager;
  44. private SpaceManager spaceManager;
  45. private UserManager userManager;
  46. private PageManager pageManager;
  47. private FormatSettingsManager formatSettingsManager;
  48. public String login(String username, String password) throws RemoteException {
  49. throw new UnsupportedOperationException("Should be handled in an interceptor.");
  50. }
  51. public boolean logout(String token) {
  52. throw new UnsupportedOperationException("Should be handled in an interceptor.");
  53. }
  54. public MetadataValue[] getMetadataValues(String token, String spaceKey, String pageName) throws RemoteException {
  55. Page page = getPageManager().getPage(spaceKey, pageName);
  56. if (page == null)
  57. throw new RemoteException("Unable to find page \"" + pageName + "\" in space " + spaceKey);
  58. ContentService contentService = new ContentService(getContentPropertyManager(), getSpaceManager(), getUserManager(),
  59. getFormatSettingsManager());
  60. return MetadataUtils.getMetadataValues(contentService, page);
  61. }
  62. public ContentPropertyManager getContentPropertyManager() {
  63. return contentPropertyManager;
  64. }
  65. public void setContentPropertyManager(ContentPropertyManager contentPropertyManager) {
  66. this.contentPropertyManager = contentPropertyManager;
  67. }
  68. public SpaceManager getSpaceManager() {
  69. return spaceManager;
  70. }
  71. public void setSpaceManager(SpaceManager spaceManager) {
  72. this.spaceManager = spaceManager;
  73. }
  74. public UserManager getUserManager() {
  75. return userManager;
  76. }
  77. public void setUserManager(UserManager userManager) {
  78. this.userManager = userManager;
  79. }
  80. public PageManager getPageManager() {
  81. return pageManager;
  82. }
  83. public void setPageManager(PageManager pageManager) {
  84. this.pageManager = pageManager;
  85. }
  86. public FormatSettingsManager getFormatSettingsManager() {
  87. return formatSettingsManager;
  88. }
  89. public void setFormatSettingsManager(FormatSettingsManager formatSettingsManager) {
  90. this.formatSettingsManager = formatSettingsManager;
  91. }
  92. }