001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.fcrepo.camel.processor; 020 021import static java.util.Arrays.asList; 022import static java.util.Optional.ofNullable; 023import static java.util.function.Function.identity; 024import static java.util.stream.Collectors.toMap; 025 026import java.net.URI; 027import java.util.Map; 028import java.util.Objects; 029 030/** 031 * ActivityStream vocabulary 032 * 033 * @author apb@jhu.edu 034 */ 035public enum ActivityStreamTerms { 036 037 Accept, 038 Activity, 039 IntransitiveActivity, 040 Add, 041 Announce, 042 Application, 043 Arrive, 044 Article, 045 Audio, 046 Block, 047 Collection, 048 CollectionPage, 049 Relationship, 050 Create, 051 Delete, 052 Dislike, 053 Document, 054 Event, 055 Follow, 056 Flag, 057 Group, 058 Ignore, 059 Image, 060 Invite, 061 Join, 062 Leave, 063 Like, 064 Link, 065 Mention, 066 Note, 067 Object, 068 Offer, 069 OrderedCollection, 070 OrderedCollectionPage, 071 Organization, 072 Page, 073 Person, 074 Place, 075 Profile, 076 Question, 077 Reject, 078 Remove, 079 Service, 080 TentativeAccept, 081 TentativeReject, 082 Tombstone, 083 Undo, 084 Update, 085 Video, 086 View, 087 Listen, 088 Read, 089 Move, 090 Travel, 091 IsFollowing, 092 IsFollowedBy, 093 IsContact, 094 IsMember; 095 096 /** ActivityStreams baseURI */ 097 public static final String ACTIVITY_STREAMS_BASEURI = "https://www.w3.org/ns/activitystreams#"; 098 099 private static Map<String, String> terms = asList(values()).stream() 100 .map(Objects::toString) 101 .collect(toMap(identity(), t -> ACTIVITY_STREAMS_BASEURI + t)); 102 103 /** 104 * Return the URI of this term. 105 * 106 * @return The URI of this term. 107 */ 108 public URI asUri() { 109 return URI.create(ACTIVITY_STREAMS_BASEURI + this.toString()); 110 } 111 112 /** 113 * Expand a string in compact form to a full activityStream URI, if possible. 114 * 115 * @param term String which may represent an ActivityStream term (e.g. "Update"), or not. 116 * @return Corresponding activityStream URI, or the original string if it does not map to an AS term. 117 */ 118 public static String expand(final String term) { 119 return ofNullable(terms.get(term)).orElse(term); 120 } 121}