Populate a JsonLDEventMessage from a FedoraEvent

@param evt The Fedora event
@return a JsonLDEventMessage
433364
public static JsonLDEventMessage from(final FedoraEvent evt) {

        final String baseUrl = evt.getInfo().get(BASE_URL);

        // build objectId
        final String objectId = convertToExternalPath(baseUrl + evt.getPath());
        // build event types list
        final List<String> types = evt.getTypes()
                .stream()
                .map(rdfType -> rdfType.getTypeAbbreviated())
                .collect(toList());
        // comma-separated list for names of events (since name requires string rather than array)
        final String name = String.join(", ", evt.getTypes()
                .stream()
                .map(rdfType -> rdfType.getName())
                .collect(toList()));
        // build resource types list
        final List<String> resourceTypes = new ArrayList<>(evt.getResourceTypes());
        if (!resourceTypes.contains(PROV_NAMESPACE + "Entity")) {
            resourceTypes.add(PROV_NAMESPACE + "Entity");
        }

        // build actors list
        final List<Actor> actor = new ArrayList<>();
        actor.add(new Person(evt.getUserURI().toString(), singletonList("Person")));
        final String softwareAgent = evt.getInfo().get(USER_AGENT);
        if (softwareAgent != null) {
            actor.add(new Application(softwareAgent, singletonList("Application")));
        }

        final JsonLDEventMessage msg = new JsonLDEventMessage();

        msg.id = evt.getEventID();
        msg.context = Arrays.asList(ACTIVITYSTREAMS_NS, new Context());
        msg.actor = actor;
        msg.published = evt.getDate();
        msg.type = types;
        msg.name = name;
        msg.object = new Object(objectId, resourceTypes, baseUrl);
        return msg;
    }
459540
public static EscEvent create(final JsonObject jsonObj) {
        final String eventId = jsonObj.getString(EL_EVENT_ID);
        final String eventType = jsonObj.getString(EL_EVENT_TYPE);
        final JsonObject jsonData = jsonObj.getJsonObject(EL_DATA);
        final JsonObject jsonMeta = jsonObj.getJsonObject(EL_META_DATA);
        return new EscEvent(UUID.fromString(eventId), eventType, new DataWrapper(jsonData), new DataWrapper(jsonMeta));
    }
1344527
public SmileEnvelopeEvent getNextEvent() throws IOException
    {
        try {
            if (!_hasNextEvent()) {
                return null;
            }
            final JsonNode node = mapper.readValue(parser, JsonNode.class);
            nextToken = null; // reset nextToken

            return new SmileEnvelopeEvent(node);
        }
        // make sure we don't return true for hasNextEvent after this
        catch (IOException e) {
            hasFailed = true;
            throw e;
        }
    }
925200
function (evt, callback) {
    var self = this;

    function denorm() {
      if (self.executeDenormFnForEach) {
        return self.denormalizeForEach(evt, callback);
      }

      if (self.query) {
        return self.handleQuery(evt, self.query, callback);
      }

      if (!self.query && self.getQueryForThisViewBuilder) {
        self.getQueryForThisViewBuilder(evt, function (err, query) {
          if (err) {
            debug(err);
            return callback(err);
          }
          self.handleQuery(evt, query, callback);
        });
        return;
      }

      self.extractId(evt, function (err, id) {
        if (err) {
          debug(err);
          return callback(err);
        }

        self.loadViewModel(id, function (err, vm) {
          if (err) {
            debug(err);
            return callback(err);
          }

          if (vm.actionOnCommit === 'create' && !self.autoCreate) {
            return callback(null, []);
          }

          self.handleOne(vm, evt, function (err, notification) {
            if (err) {
              debug(err);
              return callback(err);
            }

            var notis = [];
            if (notification) {
              notis.push(notification);
            }

            callback(null, notis);
          });
        });
      });
    }

    // if (this.shouldHandleRequestsOnlyEvent) {
    this.shouldHandleEvent(evt, function (err, doHandle) {
      if (err) {
        return callback(err);
      }

      if (!doHandle) {
        return callback(null, []);
      }

      denorm();
    });
    // } else {
      // denorm();
    // }
  }
893471
public static JsonObject toJson( IGeneratorSet generatorSet)
    {
    JsonObjectBuilder builder = Json.createObjectBuilder();

    for( String function : generatorSet.getGeneratorFunctions())
      {
      builder.add( function, toJson( generatorSet.getGenerator( function)));
      }

    return builder.build();
    }
1216841
public static JsonObject toJson( SystemInputDef systemInput)
    {
    JsonObjectBuilder builder = Json.createObjectBuilder();
    builder.add( SYSTEM_KEY, systemInput.getName());

    addAnnotations( builder, systemInput);
    
    toStream( systemInput.getFunctionInputDefs()).forEach( function -> builder.add( function.getName(), toJson( function)));

    return builder.build();
    }
575084
public static Object fromJSON(String jsonString){
        List<Token> tokens = Derulo.toTokens(jsonString);
        return fromJSON(tokens);
    }
927958
public ServerSentEvent build() {
        if (id == null && event == null &&
            retry == null && comment == null && data == null) {
            return DefaultServerSentEvent.EMPTY;
        }
        return new DefaultServerSentEvent(id, event, retry, comment, data);
    }
1119058
private static String getFirstErrorMessage(String defaultMessage, JsonElement json) {
    if (json == null) {
      return defaultMessage;
    }

    JsonObject jsonObject = null;

    if (!json.isJsonArray()) {
      jsonObject = json.getAsJsonObject();
    } else {
      JsonArray jsonArray = json.getAsJsonArray();
      if (jsonArray.size() != 0) {
        jsonObject = jsonArray.get(0).getAsJsonObject();
      }
    }

    if (jsonObject != null) {
      if (jsonObject.has("error_description")) {
        defaultMessage = defaultMessage + jsonObject.get("error_description").getAsString();
      } else if (jsonObject.has("message")) {
        defaultMessage = defaultMessage + jsonObject.get("message").getAsString();
      }
    }

    return defaultMessage;
  }
1268570
public Object convertExceptionToJson(Throwable pExp, JmxRequest pJmxReq)  {
        JsonConvertOptions opts = getJsonConvertOptions(pJmxReq);
        try {
            JSONObject expObj =
                    (JSONObject) converters.getToJsonConverter().convertToJson(pExp,null,opts);
            return expObj;

        } catch (AttributeNotFoundException e) {
            // Cannot happen, since we dont use a path
            return null;
        }
    }
1298797
def format_time_event_json(self):
        """"""
        time_event = {}
        time_event['time'] = self.timestamp

        if self.annotation is not None:
            time_event['annotation'] = self.annotation.format_annotation_json()

        if self.message_event is not None:
            time_event['message_event'] = \
                self.message_event.format_message_event_json()

        return time_event
1306560
private JSONObject jsonFromElement(final AtlasElement element) throws JSONException {
        final ObjectNode objectNode = this.objectNodeFromElement(element);

        try {
            return new JSONObject(new JSONTokener(MAPPER.writeValueAsString(objectNode)));
        } catch (IOException ioe) {
            // repackage this as a JSONException...seems sensible as the caller will only know about
            // the jettison object not being created
            throw new JSONException(ioe);
        }
    }
596640
private synchronized void chkShowAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkShowAllActionPerformed
    	Runnable runner = new Runnable(){
    		public void run(){
    			if (chkShowAll.isSelected()) {
    				fetchSizeCache = getFetchSize();
    				txtFetchSize.setText(0+"");
    				txtFetchSize.setEditable(false);
    			} else {
    				txtFetchSize.setText(fetchSizeCache+"");
    				txtFetchSize.setEditable(true);
    			}
    		}
    	};
    	SwingUtilities.invokeLater(runner);
    }
108575
public JSONObject getJson() throws JSONException {
        JSONObject json = create();
        json.put("path", eventMessagePattern);
        json.put("handlerClass", eventHandler);
        json.put("routing", isContentRouting ? "content" : "path");
        return json;
    }
398307
private JSONObject getOrAddCustomAlert() throws JSONException {
		JSONObject alert = getCompatibleProperty("alert", JSONObject.class, "A simple alert (\"%s\") was already added to this payload");
		if (alert == null) {
			alert = new JSONObject();
			put("alert", alert, this.apsDictionary, false);
		}
		return alert;
	}
1159235
def format_json(event, colored):
        

        try:
            if event.message.startswith("{"):
                msg_dict = json.loads(event.message)
                event.message = json.dumps(msg_dict, indent=2)
        except Exception:
            # Skip if the event message was not JSON
            pass

        return event
802163
function EventDevPing (device){
        adapter.Debug (7, "EventDevPing devid=%s name=%s", device.devid, device.name);
         
        var msg = 
            {type : 3
            ,devid: device.devid
        };
        adapter.BroadcastJson (msg);
    }