Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support service metadata files in subdirectories #303

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -131,17 +131,9 @@ public abstract class AbstractOWS implements OWS {

protected ImplementationMetadata<?> serviceInfo;

private String configId;

protected AbstractOWS( URL configURL, ImplementationMetadata<?> serviceInfo ) {
this.configURL = configURL;
this.serviceInfo = serviceInfo;
try {
File f = new File( configURL.toURI() );
this.configId = f.getName().substring( 0, f.getName().length() - 4 );
} catch ( URISyntaxException e ) {
// then no configId will be available
}
}

private static List<SerializerProvider> exceptionSerializers = new ArrayList<SerializerProvider>();
Expand Down Expand Up @@ -180,8 +172,24 @@ public ImplementationMetadata<?> getImplementationMetadata() {
return serviceInfo;
}

public String getId() {
return configId;
/**
* Returns the resource id of this {@link AbstractOWS}.
*
* @return resource id, never <code>null</code>
* @throws ResourceInitException
* if the id can not be derived from the config URL
*/
protected String getId()
throws ResourceInitException {
try {
final File wsDir = new File( workspace.getLocation(), "services" );
final File configFile = new File( configURL.toURI() );
final String relative = wsDir.toURI().relativize( configFile.toURI() ).getPath();
return relative.substring( 0, relative.lastIndexOf( '.' ) );
} catch ( URISyntaxException e ) {
final String msg = "Unable to determine service id from config URL: " + e.getMessage();
throw new ResourceInitException( msg );
}
}

/**
Expand Down