001// Generated by delombok at Thu Mar 19 15:24:58 GMT 2020 002/* 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 */ 020package org.apache.isis.viewer.restfulobjects.rendering; 021 022import java.util.List; 023import java.util.Optional; 024import javax.ws.rs.core.MediaType; 025import org.apache.isis.applib.annotation.Where; 026import org.apache.isis.applib.services.registry.ServiceRegistry; 027import org.apache.isis.core.config.IsisConfiguration; 028import org.apache.isis.core.metamodel.adapter.oid.RootOid; 029import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy; 030import org.apache.isis.core.metamodel.context.MetaModelContext; 031import org.apache.isis.core.metamodel.spec.ManagedObject; 032import org.apache.isis.core.metamodel.specloader.SpecificationLoader; 033import org.apache.isis.core.security.authentication.AuthenticationSessionTracker; 034import org.apache.isis.viewer.restfulobjects.rendering.domainobjects.DomainObjectReprRenderer; 035import org.apache.isis.viewer.restfulobjects.rendering.domainobjects.ObjectAdapterLinkTo; 036import org.apache.isis.viewer.restfulobjects.rendering.service.RepresentationService; 037 038public interface IResourceContext { 039 String urlFor(final String url); 040 041 List<MediaType> getAcceptableMediaTypes(); 042 043 InteractionInitiatedBy getInteractionInitiatedBy(); 044 045 Where getWhere(); 046 047 ObjectAdapterLinkTo getObjectAdapterLinkTo(); 048 049 List<List<String>> getFollowLinks(); 050 051 boolean isValidateOnly(); 052 053 boolean honorUiHints(); 054 055 boolean objectPropertyValuesOnly(); 056 057 boolean suppressDescribedByLinks(); 058 059 boolean suppressUpdateLink(); 060 061 boolean suppressMemberId(); 062 063 boolean suppressMemberLinks(); 064 065 boolean suppressMemberExtensions(); 066 067 boolean suppressMemberDisabledReason(); 068 069 /** 070 * To avoid infinite loops when {@link Render.Type#EAGERLY eagerly} rendering graphs 071 072 * of objects as {@link DomainObjectReprRenderer#asEventSerialization() events}. 073 074 * 075 076 * <p> 077 078 * @param objectAdapter - the object proposed to be rendered eagerly 079 080 * @return whether this adapter has already been rendered (implying the caller should not render the value). 081 */ 082 boolean canEagerlyRender(ManagedObject objectAdapter); 083 084 /** 085 * Applies only when rendering a domain object. 086 */ 087 RepresentationService.Intent getIntent(); 088 089 AuthenticationSessionTracker getAuthenticationSessionTracker(); 090 091 SpecificationLoader getSpecificationLoader(); 092 093 MetaModelContext getMetaModelContext(); // TODO derive from specLoader 094 095 ServiceRegistry getServiceRegistry(); // TODO derive from specLoader 096 097 IsisConfiguration getConfiguration(); // TODO derive from specLoader 098 099 // -- UTILITY 100 default Optional<ManagedObject> getObjectAdapterForOidFromHref(String oidFromHref) { 101 String oidStrUnencoded = UrlDecoderUtils.urlDecode(oidFromHref); 102 final org.apache.isis.core.metamodel.adapter.oid.RootOid rootOid = RootOid.deString(oidStrUnencoded); 103 return Optional.ofNullable(ManagedObject._adapterOfRootOid(getSpecificationLoader(), rootOid)); 104 } 105}