/** * @deprecated do not use this method anymore, use the constructors for {@link EntityReference} */ public static String getID(String reference) { return new EntityReference(reference).getId(); }
/** * Creates a copy of an entity reference * @param ref an entity reference object * @return the new copy of the ref * @throws IllegalArgumentException if the ref is invalid OR null */ public static EntityReference copy(EntityReference ref) { if (ref == null) { throw new IllegalArgumentException("input entity reference must not be null"); } EntityReference copy = new EntityReference(ref.getPrefix(), ref.getId() == null ? "" : ref.getId()); return copy; }
/** * Get the string reference for this entity reference object, * same as calling {@link #toString()} * @return the full entity reference */ public String getReference() { return this.toString(); }
/** * Override this if you are making a new class to define your entity reference * * @param spaceOnly if this is true then only return the entity space reference (e.g. /prefix), * otherwise return the full reference (e.g. /prefix/id) * @return an entity reference string */ protected String makeEntityReference(boolean spaceOnly) { // OVERRIDE THIS when creating your own EntityReference if (getPrefix() == null) { throw new IllegalStateException("prefix is null, cannot generate the string reference"); } String ref = null; if (spaceOnly || getId() == null) { ref = SEPARATOR + getPrefix(); } else { ref = SEPARATOR + getPrefix() + SEPARATOR + getId(); } return ref; }
if (ref.getId() == null) { CollectionResolvable provider = entityProviderManager.getProviderByPrefixAndCapability(ref.getPrefix(), CollectionResolvable.class); if (provider != null) { search = EntityDataUtils.translateStandardSearch(search); BrowseSearchable searchable = entityProviderManager.getProviderByPrefixAndCapability(ref.getPrefix(), BrowseSearchable.class); if (searchable != null) { search = EntityDataUtils.translateStandardSearch(search); if (entity == null) { throw new EntityException("Failed to retrieve entity (" + ref + "), entity object could not be found", ref.toString(), HttpServletResponse.SC_NOT_FOUND);
} else if ( DESCRIBE.equals(view.getEntityReference().getId()) ) { String output = entityDescriptionManager.makeDescribeEntity(view.getEntityReference().getPrefix(), entityId, format, req.getLocale()); res.setContentLength(output.getBytes().length); try { handledReference = view.getEntityReference().getSpaceReference() + SLASH_DESCRIBE; String prefix = view.getEntityReference().getPrefix(); if (cRef.getId() != null && cRef.getId().equalsIgnoreCase(customAction.action)) { view.setEntityReference( new EntityReference(prefix, "") ); requestStorage.setRequestValue(RequestStorage.ReservedKeys._requestEntityReference.name(), view.getEntityReference().toString()); requestStorage.setRequestValue(RequestStorage.ReservedKeys._requestOrigin.name(), RequestStorage.RequestOrigin.REST.name()); requestStorage.setRequestValue(RequestStorage.ReservedKeys._requestActive.name(), true); ref = new EntityReference(ed.getEntityRef().getPrefix(), ""); view.setEntityReference( ref ); view.setViewKey(EntityView.VIEW_LIST); ref = new EntityReference(prefix, customAction.action); } else if (ref.getId() == null) { ref = new EntityReference(ref.getPrefix(), customAction.action); view.setEntityReference( new EntityReference(prefix, createdId) ); // update the entity view res.setHeader(EntityRequestHandler.HEADER_ENTITY_ID, createdId); res.setStatus(HttpServletResponse.SC_CREATED);
public EntityReference getParsedExemplar() { // super simple result for now -AZ return new EntityReference(); }
public void removeTagsFromEntity(String reference, String[] tags) { if (tags == null) { throw new IllegalArgumentException("Invalid params, tags cannot be null"); } validateTags(tags); // ensures tags are valid EntityReference ref = entityBrokerManager.parseReference(reference); if (ref == null) { throw new IllegalArgumentException("Invalid reference (" + reference + "), no entity provider to handle this reference"); } else { reference = ref.toString(); if (! entityBrokerManager.entityExists(ref)) { throw new IllegalArgumentException("Invalid reference (" + reference + "), entity does not exist"); } if (entityProviderManager.getProviderByPrefixAndCapability(ref.getPrefix(), Taggable.class) != null) { TagProvideable provider = entityProviderManager.getProviderByPrefixAndCapability(ref.getPrefix(), TagProvideable.class); if (provider == null) { // put in call to central tag system here if desired dao.deleteTags(reference, tags); } else { provider.removeTagsFromEntity(reference, tags); } } else { throw new UnsupportedOperationException("Cannot set tags for this entity ("+reference+"), it has no support for tagging in its entity provider"); } } }
/** * Full constructor<br/> * Use this if you want to return the entity itself along with the key meta data and properties * * @param reference a globally unique reference to an entity, * consists of the entity prefix and id (e.g. /prefix/id) * @param entityDisplayTitle a string which is suitable for display and provides a short summary of the entity, * typically 100 chars or less, this may be the name or title of the entity represented by an entity * @param data an entity data object, see {@link Resolvable} * @param entityProperties a set of properties to return along with the entity information, * this may be presented and used for filtering, */ public EntityData(String reference, String displayTitle, Object entity, Map<String, Object> entityProperties) { this.entityRef = new EntityReference(reference); this.entityReference = this.entityRef.getReference(); this.entityId = this.entityRef.getId(); this.entityDisplayTitle = displayTitle; this.entityURL = EntityView.DIRECT_PREFIX + this.entityReference; setData(entity); setEntityProperties(entityProperties); }
/** * A string which is suitable for display and provides a short summary of the entity, * typically 100 chars or less, this may be the name or title of the data represented by an entity */ public String getDisplayTitle() { if (this.entityDisplayTitle == null) { if (this.entityRef != null) { return this.entityRef.getPrefix() + " : " + entityReference; } else { return "data"; } } return entityDisplayTitle; } private transient boolean displayTitleSet = false; // needed to avoid encoding
public String getCurrentToolReference() { String toolRef = null; String toolId = toolManager.getCurrentTool().getId(); // assume the form /tool/toolId if (toolId != null) { toolRef = new EntityReference("tool", toolId).toString(); } return toolRef; }
String prefix = EntityReference.getPrefix(reference); EntityReference ref = null; if (entityProviderManager.getProviderByPrefix(prefix) != null) { ReferenceParseable provider = entityProviderManager.getProviderByPrefixAndCapability(prefix, ReferenceParseable.class); if (provider == null) { ref = new EntityReference(reference); } else { EntityReference exemplar = provider.getParsedExemplar(); if (exemplar == null) { ref = new EntityReference(reference); } else { if (exemplar.getClass() == EntityReference.class) { ref = new EntityReference(reference); } else {
/** * Full constructor<br/> * Use this if you want to return the entity itself along with the key meta data and properties * * @param ref an object which represents a globally unique reference to an entity, * consists of the entity prefix and id * @param entityDisplayTitle a string which is suitable for display and provides a short summary of the entity, * typically 100 chars or less, this may be the name or title of the entity represented by an entity * @param data an entity data object, see {@link Resolvable} * @param entityProperties a set of properties to return along with the entity information, * this may be presented and used for filtering, */ public EntityData(EntityReference ref, String displayTitle, Object entity, Map<String, Object> entityProperties) { if (ref == null || ref.isEmpty()) { throw new IllegalArgumentException("reference object cannot be null and must have values set"); } this.entityRef = ref; this.entityReference = this.entityRef.getReference(); this.entityId = this.entityRef.getId(); this.entityDisplayTitle = displayTitle; this.entityURL = EntityView.DIRECT_PREFIX + this.entityReference; this.entityDisplayTitle = displayTitle; setData(entity); setEntityProperties(entityProperties); }
UserProfile userProfile = (UserProfile) profileLogic.getUserProfile(ref.getId()); return new ActionReturn(Formats.UTF_8, Formats.HTML_MIME_TYPE, writer.toString()); } catch (IOException ioe) { throw new EntityException("Failed to format profile.", ref.getReference());
public String getCurrentUserId() { if (currentUserRef != null) { return EntityReference.getIdFromRef(currentUserRef); } return null; }
private void doIt(OrganizationServiceStub stub, OptionSetValue state, OptionSetValue status) { OrganizationRequest request = new OrganizationRequest(); request.setRequestName("SetState"); ParameterCollection collection = new ParameterCollection(); collection.addKeyValuePairOfstringanyType(pair("State", state)); collection.addKeyValuePairOfstringanyType(pair("Status", status)); request.setParameters(collection); Guid g = new Guid(); g.setGuid("abc0def-ghi"); EntityReference ref = new EntityReference(); ref.setId(g); ref.setLogicalName("ei_teacherdetails"); collection.addKeyValuePairOfstringanyType(pair("EntityMoniker", ref)); Execute exe = new Execute(); exe.setRequest(request); stub.execute(exe); }
Object entity = null; Inputable inputable = entityProviderManager.getProviderByPrefixAndCapability(ref.getPrefix(), Inputable.class); if (inputable != null) { Object current = entityBrokerManager.getSampleEntityObject(ref.getPrefix(), ref.getId()); if (current != null) { if (Formats.HTML.equals(format) || format == null || "".equals(format)) { ref.toString(), HttpServletResponse.SC_BAD_REQUEST); ref.toString(), HttpServletResponse.SC_BAD_REQUEST); } else { String data = StringUtils.makeStringFromInputStream(input); if (decoded.size() == 1 && decoded.containsKey(ref.getPrefix())) { Object o = decoded.get(ref.getPrefix()); if (o instanceof Map) { decoded = (Map<String, Object>) o;
} else if ( DESCRIBE.equals(view.getEntityReference().getId()) ) { String output = entityDescriptionManager.makeDescribeEntity(view.getEntityReference().getPrefix(), entityId, format, req.getLocale()); res.setContentLength(output.getBytes().length); try { handledReference = view.getEntityReference().getSpaceReference() + SLASH_DESCRIBE; String prefix = view.getEntityReference().getPrefix(); if (cRef.getId() != null && cRef.getId().equalsIgnoreCase(customAction.action)) { view.setEntityReference( new EntityReference(prefix, "") ); requestStorage.setRequestValue(RequestStorage.ReservedKeys._requestEntityReference.name(), view.getEntityReference().toString()); requestStorage.setRequestValue(RequestStorage.ReservedKeys._requestOrigin.name(), RequestStorage.RequestOrigin.REST.name()); requestStorage.setRequestValue(RequestStorage.ReservedKeys._requestActive.name(), true); ref = new EntityReference(ed.getEntityRef().getPrefix(), ""); view.setEntityReference( ref ); view.setViewKey(EntityView.VIEW_LIST); ref = new EntityReference(prefix, customAction.action); } else if (ref.getId() == null) { ref = new EntityReference(ref.getPrefix(), customAction.action); view.setEntityReference( new EntityReference(prefix, createdId) ); // update the entity view res.setHeader(EntityRequestHandler.HEADER_ENTITY_ID, createdId); res.setStatus(HttpServletResponse.SC_CREATED);