Projects tigase _server tigase-pubsub Commits c8cb78a7
ctrl k
  • src/main/java/tigase/pubsub/exceptions/PubSubException.java
    ■ ■ ■ ■ ■ ■
    skipped 50 lines
    51 51   this(null, errorCondition, (String) null);
    52 52   }
    53 53   
     54 + public PubSubException(final Authorization errorCondition, String message) {
     55 + this(null, errorCondition, message);
     56 + }
     57 + 
    54 58   public PubSubException(final Authorization errorCondition, PubSubErrorCondition pubSubErrorConditions) {
    55 59   this((Element) null, errorCondition, pubSubErrorConditions);
    56 60   }
    skipped 91 lines
  • src/main/java/tigase/pubsub/modules/SubscribeNodeModule.java
    ■ ■ ■ ■ ■ ■
    skipped 25 lines
    26 26  import tigase.criteria.Criteria;
    27 27  import tigase.criteria.ElementCriteria;
    28 28  import tigase.pubsub.AbstractModule;
     29 +import tigase.pubsub.AccessModel;
    29 30  import tigase.pubsub.Affiliation;
    30 31  import tigase.pubsub.NodeType;
    31 32  import tigase.pubsub.PubSubConfig;
    skipped 60 lines
    92 93   if (affiliation == Affiliation.outcast)
    93 94   throw new PubSubException(Authorization.FORBIDDEN);
    94 95   }
     96 + 
     97 + AccessModel accessModel = repository.getNodeAccessModel(nodeName);
     98 + if (accessModel != AccessModel.open) {
     99 + throw new PubSubException(Authorization.FEATURE_NOT_IMPLEMENTED,
     100 + "Only open AccessModel is implemented, but this node has " + accessModel);
     101 + }
     102 + 
    95 103   if (subscription != null) {
    96 104   if (subscription == Subscription.pending) {
    97 105   throw new PubSubException(Authorization.FORBIDDEN, PubSubErrorCondition.PENDING_SUBSCRIPTION);
    skipped 38 lines
  • src/main/java/tigase/pubsub/repository/PubSubRepository.java
    ■ ■ ■ ■ ■
    skipped 10 lines
    11 11  import tigase.db.UserNotFoundException;
    12 12  import tigase.db.UserRepository;
    13 13  import tigase.form.Field;
     14 +import tigase.pubsub.AccessModel;
    14 15  import tigase.pubsub.Affiliation;
    15 16  import tigase.pubsub.LeafNodeConfig;
    16 17  import tigase.pubsub.NodeType;
    skipped 16 lines
    33 34   private static SecureRandom numberGenerator;
    34 35   
    35 36   private static final String SUBSCRIBES_KEY = "subscribers";
     37 + 
     38 + private static final String ACCESS_MODEL_KEY = "pubsub#access_model";
    36 39   
    37 40   public static synchronized String createUID() {
    38 41   SecureRandom ng = numberGenerator;
    skipped 220 lines
    259 262   try {
    260 263   nodeConfig.read(repository, config, NODES_KEY + nodeName + "/configuration");
    261 264   if (readChildren) {
    262  - //if (nodeConfig.getNodeType() == NodeType.collection) {
    263  - Field f = Field.fieldTextMulti("pubsub#children", getNodeChildren(nodeName), null);
    264  - nodeConfig.add(f);
    265  - //}
     265 + // if (nodeConfig.getNodeType() == NodeType.collection) {
     266 + Field f = Field.fieldTextMulti("pubsub#children", getNodeChildren(nodeName), null);
     267 + nodeConfig.add(f);
     268 + // }
    266 269   }
    267 270   } catch (Exception e) {
    268 271   throw new RepositoryException("Node configuration reading error", e);
    skipped 37 lines
    306 309   repository.setData(config.getServiceName(), NODES_KEY + nodeName + "/" + ITEMS_KEY + "/" + id, "publisher", publisher);
    307 310   } catch (Exception e) {
    308 311   throw new RepositoryException("Item writing error", e);
     312 + }
     313 + }
     314 + 
     315 + public AccessModel getNodeAccessModel(String nodeName) throws RepositoryException {
     316 + try {
     317 + // name = repository.getData(config.getServiceName(),
     318 + // NODES_KEY + nodeName, NODE_TYPE_KEY);
     319 + String name = repository.getData(config.getServiceName(), NODES_KEY + nodeName + "/configuration/", ACCESS_MODEL_KEY);
     320 + 
     321 + if (name != null) {
     322 + return AccessModel.valueOf(name);
     323 + } else {
     324 + return null;
     325 + }
     326 + } catch (Exception e) {
     327 + throw new RepositoryException("AccessModel getting error", e);
    309 328   }
    310 329   }
    311 330  }
    skipped 1 lines
Please wait...
Page is in error, reload to recover