Coverage Report - org.openpermis.editor.policy.presenter.AuthorityPresenter
 
Classes in this File Line Coverage Branch Coverage Complexity
AuthorityPresenter
0%
0/18
0%
0/2
1.5
 
 1  
 /*
 2  
  * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch)
 3  
  * All rights reserved.
 4  
  * 
 5  
  * Licensed under the Open Permis License which accompanies this distribution, 
 6  
  * and is available at http://www.openpermis.org/BSDlicenceKent.txt
 7  
  */
 8  
 package org.openpermis.editor.policy.presenter;
 9  
 
 10  
 import java.net.URI;
 11  
 
 12  
 import org.slf4j.Logger;
 13  
 import org.slf4j.LoggerFactory;
 14  
 
 15  
 import org.openpermis.editor.policy.beans.PropertyChange;
 16  
 import org.openpermis.policy.bean.AuthorityBean;
 17  
 
 18  
 /**
 19  
  * Presenter for a single resource {@link AuthorityBean}.
 20  
  * @since 0.3.0
 21  
  */
 22  
 public class AuthorityPresenter
 23  
         extends PartPresenter<AuthorityBean>
 24  
 {
 25  
 
 26  
         //---- Static
 27  
 
 28  
         /**
 29  
          * @since 0.3.0
 30  
          */
 31  0
         private static final Logger LOGGER =
 32  
                 LoggerFactory.getLogger(AuthorityPresenter.class);
 33  
 
 34  
         //---- State
 35  
 
 36  
         /**
 37  
          * @since 0.3.0
 38  
          */
 39  
         private URI identity;
 40  
 
 41  
         //---- Constructors
 42  
 
 43  
         /**
 44  
          * Creates a new {@link AuthorityPresenter}.
 45  
          * @param model the {@link AuthorityBean}.
 46  
          * @param context policy context that provides additional information.
 47  
          * @since 0.3.0
 48  
          */
 49  
         public AuthorityPresenter (AuthorityBean model, PolicyContext context) {
 50  0
                 super(model, context);
 51  0
                 updateIdentity();
 52  0
         }
 53  
 
 54  
         //---- Methods
 55  
 
 56  
         /**
 57  
          * Returns the identity of the authority.
 58  
          * @return the identity of the authority.
 59  
          * @since 0.3.0
 60  
          */
 61  
         public URI getIdentity () {
 62  0
                 return this.identity;
 63  
         }
 64  
 
 65  
         /**
 66  
          * Sets the identity of the authority.
 67  
          * @param identity the new identity to set.
 68  
          * @since 0.3.0
 69  
          */
 70  
         public void setIdentity (URI identity) {
 71  
                 try {
 72  0
                         final URI oldIdentity = getIdentity();
 73  0
                         this.identity = identity;
 74  0
                         firePropertyChange("identity", oldIdentity, this.identity);
 75  0
                         change("identity", this.identity);
 76  0
                 } catch (final Exception e) {
 77  0
                         LOGGER.warn("Cannot set target authority [" + identity + "].", e);
 78  0
                 }
 79  0
         }
 80  
 
 81  
         //---- PropertyChange
 82  
 
 83  
         /**
 84  
          * Handles property changes of identity.
 85  
          * @since 0.3.0
 86  
          */
 87  
         @PropertyChange(bean = AuthorityBean.class, property = "identity")
 88  
         public void updateIdentity () {
 89  0
                 final URI oldIdentity = this.identity;
 90  0
                 this.identity = getModel().getIdentity();
 91  0
                 firePropertyChange("identity", oldIdentity, this.identity);
 92  0
                 setTitleParameters(this.identity == null ? "" : this.identity.toString());
 93  0
         }
 94  
 
 95  
 }