-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PortalRequest must use correct application in resolve function #741
- Loading branch information
1 parent
eb051f3
commit eae7c19
Showing
6 changed files
with
157 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/com/enonic/app/guillotine/graphql/helper/PortalRequestHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.enonic.app.guillotine.graphql.helper; | ||
|
||
import graphql.schema.DataFetchingEnvironment; | ||
|
||
import com.enonic.xp.app.ApplicationKey; | ||
import com.enonic.xp.portal.PortalRequest; | ||
|
||
public final class PortalRequestHelper | ||
{ | ||
private PortalRequestHelper() | ||
{ | ||
} | ||
|
||
public static PortalRequest createPortalRequest( final PortalRequest source, final DataFetchingEnvironment environment ) | ||
{ | ||
if ( source == null ) | ||
{ | ||
return null; | ||
} | ||
|
||
final PortalRequest result = createDefaultPortalRequest( source ); | ||
result.setRepositoryId( GuillotineLocalContextHelper.getRepositoryId( environment, source.getRepositoryId() ) ); | ||
result.setBranch( GuillotineLocalContextHelper.getBranch( environment, source.getBranch() ) ); | ||
return result; | ||
} | ||
|
||
public static PortalRequest createPortalRequest( final PortalRequest source, final ApplicationKey applicationKey ) | ||
{ | ||
if ( source == null ) | ||
{ | ||
return null; | ||
} | ||
|
||
final PortalRequest result = createDefaultPortalRequest( source ); | ||
result.setApplicationKey( applicationKey ); | ||
return result; | ||
} | ||
|
||
private static PortalRequest createDefaultPortalRequest( final PortalRequest source ) | ||
{ | ||
final PortalRequest result = new PortalRequest(); | ||
|
||
result.setRepositoryId( source.getRepositoryId() ); | ||
result.setBranch( source.getBranch() ); | ||
result.setApplicationKey( source.getApplicationKey() ); | ||
result.setContentPath( source.getContentPath() ); | ||
result.setMode( source.getMode() ); | ||
result.setRawRequest( source.getRawRequest() ); | ||
result.setContent( source.getContent() ); | ||
result.setSite( source.getSite() ); | ||
result.setMethod( source.getMethod() ); | ||
result.setBaseUri( source.getBaseUri() ); | ||
result.setRawPath( source.getRawPath() ); | ||
result.setWebSocketContext( source.getWebSocketContext() ); | ||
result.setComponent( source.getComponent() ); | ||
result.setControllerScript( source.getControllerScript() ); | ||
result.setPageDescriptor( source.getPageDescriptor() ); | ||
result.setPageTemplate( source.getPageTemplate() ); | ||
result.setContextPath( source.getContextPath() ); | ||
result.setValidTicket( source.isValidTicket() ); | ||
result.setBody( source.getBody() ); | ||
result.setIdProvider( source.getIdProvider() ); | ||
result.setHost( source.getHost() ); | ||
result.setPort( source.getPort() ); | ||
result.setScheme( source.getScheme() ); | ||
result.setPath( source.getPath() ); | ||
result.setEndpointPath( source.getEndpointPath() ); | ||
result.setUrl( source.getUrl() ); | ||
result.setContentType( source.getContentType() ); | ||
result.setRemoteAddress( source.getRemoteAddress() ); | ||
|
||
return result; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/enonic/app/guillotine/graphql/transformer/ContextualFieldResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.enonic.app.guillotine.graphql.transformer; | ||
|
||
import com.enonic.xp.app.ApplicationKey; | ||
import com.enonic.xp.script.ScriptValue; | ||
|
||
public class ContextualFieldResolver | ||
{ | ||
private final ApplicationKey applicationKey; | ||
|
||
private final ScriptValue resolveFunction; | ||
|
||
public ContextualFieldResolver( final ApplicationKey applicationKey, final ScriptValue resolveFunction ) | ||
{ | ||
this.applicationKey = applicationKey; | ||
this.resolveFunction = resolveFunction; | ||
} | ||
|
||
public ApplicationKey getApplicationKey() | ||
{ | ||
return applicationKey; | ||
} | ||
|
||
public ScriptValue getResolveFunction() | ||
{ | ||
return resolveFunction; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters