-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dcefb15
commit eb7923e
Showing
102 changed files
with
139 additions
and
86 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dependencies { | ||
implementation project( ':core:core-api' ) | ||
} | ||
|
||
jar { | ||
bnd( 'Bundle-Name': 'Enonic XP Core - Common', 'Export-Package': 'com.enonic.xp.*' ) | ||
} |
40 changes: 40 additions & 0 deletions
40
modules/core/core-common/src/main/java/com/enonic/xp/impl/common/ApiMountResolver.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,40 @@ | ||
package com.enonic.xp.impl.common; | ||
|
||
import com.enonic.xp.app.ApplicationKey; | ||
|
||
public final class ApiMountResolver | ||
{ | ||
private static final int APPLICATION_KEY_INDEX = 0; | ||
|
||
private static final int API_KEY_INDEX = 1; | ||
|
||
private final String[] apiMountParts; | ||
|
||
public ApiMountResolver( final String apiMount ) | ||
{ | ||
this.apiMountParts = apiMount.split( ":", 2 ); | ||
} | ||
|
||
public ApplicationKey resolveApplicationKey() | ||
{ | ||
return apiMountParts.length != 1 ? resolveApplicationKey( apiMountParts[APPLICATION_KEY_INDEX].trim() ) : null; | ||
} | ||
|
||
public String resolveApiKey() | ||
{ | ||
final String trimmedApiKey = apiMountParts.length == 1 ? apiMountParts[0].trim() : apiMountParts[API_KEY_INDEX].trim(); | ||
return trimmedApiKey.isBlank() ? null : trimmedApiKey; | ||
} | ||
|
||
private ApplicationKey resolveApplicationKey( final String applicationKey ) | ||
{ | ||
try | ||
{ | ||
return ApplicationKey.from( applicationKey ); | ||
} | ||
catch ( Exception e ) | ||
{ | ||
throw new IllegalArgumentException( String.format( "Invalid applicationKey '%s'", applicationKey ), e ); | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
dependencies { | ||
api( libs.guava ) { | ||
exclude group: 'com.google.code.findbugs' | ||
} | ||
implementation project( ':core:core-api' ) | ||
implementation project( ':core:core-common' ) | ||
} | ||
|
||
jar { | ||
bnd( 'Bundle-Name': 'Enonic XP Core - Parser', 'Export-Package': 'com.enonic.xp.*' ) | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions
43
modules/core/core-parser/src/testFixtures/java/com/enonic/xp/support/ResourceTestHelper.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,43 @@ | ||
package com.enonic.xp.support; | ||
|
||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public class ResourceTestHelper | ||
{ | ||
private final Object testInstance; | ||
|
||
public ResourceTestHelper( final Object testInstance ) | ||
{ | ||
this.testInstance = testInstance; | ||
} | ||
|
||
public String loadTestFile( final String fileName ) | ||
{ | ||
final URL url = getResource( testInstance.getClass().getSimpleName() + "-" + fileName ); | ||
try (InputStream stream = url.openStream()) | ||
{ | ||
return new String( stream.readAllBytes(), StandardCharsets.UTF_8 ); | ||
} | ||
catch ( final Exception e ) | ||
{ | ||
throw new RuntimeException( "Failed to load test file: " + url, e ); | ||
} | ||
} | ||
|
||
public URL getTestResource( final String fileName ) | ||
{ | ||
return getResource( testInstance.getClass().getSimpleName() + "-" + fileName ); | ||
} | ||
|
||
public URL getResource( final String fileName ) | ||
{ | ||
final URL resource = testInstance.getClass().getResource( fileName ); | ||
if ( resource == null ) | ||
{ | ||
throw new IllegalArgumentException( "Resource [" + fileName + "] not found relative to: " + testInstance.getClass() ); | ||
} | ||
return resource; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
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
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
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
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
Oops, something went wrong.