Package com.comcast.cns.model

Examples of com.comcast.cns.model.CNSTopic


      if ((topicArn == null) ) {
        logger.error("event=cns_add_permission error_code=missing_parameter_topic_arn");
      throw new CMBException(CNSErrorCodes.CNS_InvalidParameter,"Missing parameter TopicArn");
      }
     
      CNSTopic topic = PersistenceFactory.getTopicPersistence().getTopic(topicArn);
     
      if (topic == null) {
        logger.error("event=cns_add_permission error_code=invalid_parameter_topic_arn");
      throw new CMBException(CNSErrorCodes.CNS_NotFound,"Resource not found.");
      }
View Full Code Here


            this.arn = arn;
        }
       
        @Override
        public CNSTopic call() throws Exception {
            CNSTopic topic = topicHandler.getTopic(arn);
            return topic;
        }
View Full Code Here

      if ((topicArn == null) ) {
        logger.error("event=cns_add_permission error_code=missing_parameter_topic_arn");
      throw new CMBException(CNSErrorCodes.CNS_InvalidParameter,"Missing parameter TopicArn");
      }
     
      CNSTopic topic = PersistenceFactory.getTopicPersistence().getTopic(topicArn);
     
      if (topic == null) {
        logger.error("event=cns_add_permission error_code=invalid_parameter_topic_arn topic_arn=" + topicArn);
      throw new CMBException(CNSErrorCodes.CNS_NotFound,"Resource not found.");
      }
View Full Code Here

      logger.error("event=listAllSubscriptionsByTopic topic_arn=" + topicArn, ex);
      throw new ServletException(ex);
    }
   
    ICNSTopicPersistence topicHandler = PersistenceFactory.getTopicPersistence();
    CNSTopic topic = null;
   
    try {
      topic = topicHandler.getTopic(topicArn);
    } catch (Exception ex) {
      logger.error("event=getTopic topic_arn=" + topicArn, ex);
      throw new ServletException(ex);
    }
   
    out.println("<html>");
    out.println("<script type='text/javascript' language='javascript'>");
    out.println("function changeEndpointHint(protocol){ ");
    out.println(" if (protocol == 'HTTP' || protocol == 'HTTPS') { ");
    out.println(" document.getElementById('endPoint').placeholder = 'e.g. http://company.com'; }");
    out.println(" else if (protocol == 'EMAIL' || protocol == 'EMAIL_JSON') { ");
    out.println(" document.getElementById('endPoint').placeholder = 'e.g. user@domain.com'; }");
    out.println(" else if (protocol == 'CQS' || protocol == 'SQS') { ");
    out.println(" document.getElementById('endPoint').placeholder = 'e.g. arn:aws:cqs:ccp:555555555555:my-queue'; } ");
    out.println(" else if (protocol == 'redis') { document.getElementById('endPoint').placeholder = 'e.g. redis://server:port/channelname'; }");
    out.println("}");
    out.println("</script>");
   
    header(request, out, "Subscriptions for Topic "+ ((topic != null) ? topic.getName():""));
   
    out.println("<body>");

    out.println("<h2>Subscriptions for Topic "+ ((topic != null) ? topic.getName():"") + "</h2>");
   
    if (user != null) {
      out.println("<table><tr><td><b>User Name:</b></td><td>"+ user.getUserName()+"</td></tr>");
      out.println("<tr><td><b>User ID:</b></td><td>"+ user.getUserId()+"</td></tr>");
      out.println("<tr><td><b>Access Key:</b></td><td>"+user.getAccessKey()+"</td></tr>");
      out.println("<tr><td><b>Access Secret:</b></td><td>"+user.getAccessSecret()+"</td></tr>");
      out.println("<tr><td><b>Topic Name:</b></td><td>"+ topic.getName()+"</td></tr>");
      out.println("<tr><td><b>Topic Display Name:</b></td><td>" + topic.getDisplayName()+ "</td></tr>");
      out.println("<tr><td><b>Topic Arn:</b></td><td>" + topic.getArn()+ "</td></tr>");
      out.println("<tr><td><b>Num Subscriptions:</b></td><td>" + subscriptions.size()+ "</td></tr></table>");
    }
   
        out.println("<p><table><tr><td><b>Protocol</b></td><td><b>End Point</b></td><td>&nbsp;</td></tr>");
        out.println("<form action=\"/webui/cnsuser/subscription/?userId="+userId+"&topicArn="+topicArn+"\" method=POST>");
View Full Code Here

    if ((topicArn == null) || !Util.isValidTopicArn(topicArn)) {
      logger.error("event=cns_publish error_code=InvalidParameters message=" + message + " topic_arn=" + topicArn + " user_id=" + userId);
      throw new CMBException(CNSErrorCodes.CNS_InvalidParameter,"TopicArn");
      }
   
    CNSTopic topic = CNSCache.getTopic(topicArn);
   
      if (topic == null) {
        logger.error("event=cns_publish error_code=NotFound message=" + message + " topic_arn=" + topicArn + " user_id=" + userId);
      throw new CMBException(CNSErrorCodes.CNS_NotFound,"Resource not found.");
      }
   
      cnsMessage.setUserId(topic.getUserId());
      cnsMessage.setTopicArn(topicArn);
      cnsMessage.setMessageType(CNSMessageType.Notification);
     
      cnsMessage.checkIsValid();
     
View Full Code Here

   
    if (!Util.isValidTopicName(name)) {
      throw new CMBException(CNSErrorCodes.InvalidParameterValue, "Invalid parameter topic name.");
    }

    CNSTopic newTopic;
    newTopic = PersistenceFactory.getTopicPersistence().createTopic(name, displayName, userId);
    String topicArn = newTopic.getArn();
    String out = CNSTopicPopulator.getCreateTopicResponse(topicArn);
        writeResponse(out, response);
    return true;
  }
View Full Code Here

    if (topics.size() >= Util.CNS_USER_TOPIC_LIMIT) {
      throw new CMBException(CNSErrorCodes.CNS_TopicLimitExceeded, "Topic limit exceeded.");
    }*/

    CNSTopic topic = getTopic(arn);

    if (topic != null) {
      return topic;
    } else {

      topic = new CNSTopic(arn, name, displayName, userId);
      topic.checkIsValid();
     
      cassandraHandler.insertRow(AbstractDurablePersistence.CNS_KEYSPACE, topic.getArn(), columnFamilyTopics, getColumnValues(topic), CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, null);
      cassandraHandler.update(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicsByUserId, userId, topic.getArn(), "", CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, null);
      cassandraHandler.delete(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicStats, arn, null, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
     
      cassandraHandler.deleteCounter(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicStats, arn, "subscriptionConfirmed", CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
      cassandraHandler.deleteCounter(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicStats, arn, "subscriptionPending", CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
      cassandraHandler.deleteCounter(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicStats, arn, "subscriptionDeleted", CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
View Full Code Here

  }

  @Override
  public void deleteTopic(String topicArn) throws Exception {

    CNSTopic topic = getTopic(topicArn);

    if (topic == null) {
      throw new CMBException(CNSErrorCodes.CNS_NotFound, "Topic not found.");
    }

    // delete all subscriptions first

    PersistenceFactory.getSubscriptionPersistence().unsubscribeAll(topic.getArn());   

    cassandraHandler.delete(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopics, topicArn, null, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
    cassandraHandler.delete(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicsByUserId, topic.getUserId(), topicArn, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
    cassandraHandler.delete(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicAttributes, topicArn, null, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
    cassandraHandler.delete(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicStats, topicArn, null, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
    cassandraHandler.deleteCounter(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicStats, topicArn, "subscriptionConfirmed", CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
    cassandraHandler.deleteCounter(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicStats, topicArn, "subscriptionPending", CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
    cassandraHandler.deleteCounter(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicStats, topicArn, "subscriptionDeleted", CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
View Full Code Here

          if (slice.getColumnByName("displayName") != null) {
            displayName = slice.getColumnByName("displayName").getValue();
          }

          CNSTopic t = new CNSTopic(arn, name, displayName, userId);

          topics.add(t);

        } else {
          cassandraHandler.delete(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopicsByUserId, userId, arn, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);
View Full Code Here

  }

  @Override
  public CNSTopic getTopic(String arn) throws Exception {

    CNSTopic topic = null;
    CmbColumnSlice<String, String> slice = cassandraHandler.readColumnSlice(AbstractDurablePersistence.CNS_KEYSPACE, columnFamilyTopics, arn, null, null, 10, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER, CMB_SERIALIZER.STRING_SERIALIZER);

    if (slice != null) {

      String name = slice.getColumnByName("name").getValue();
      String displayName = null;

      if (slice.getColumnByName("displayName") != null) {
        displayName = slice.getColumnByName("displayName").getValue();
      }

      String user = slice.getColumnByName("userId").getValue();
      topic = new CNSTopic(arn, name, displayName, user);
    }

    return topic;
  }
View Full Code Here

TOP

Related Classes of com.comcast.cns.model.CNSTopic

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.