Package net.shibboleth.profile.module
Class AbstractModule.BasicModuleResource
java.lang.Object
net.shibboleth.profile.module.AbstractModule.BasicModuleResource
- All Implemented Interfaces:
Module.ModuleResource
- Enclosing class:
- AbstractModule
Models a specific resource managed by a module.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PathDestination.private final booleanExecutable criteria.private final booleanProcess on non-Windows?private final booleanOptional criteria.private final booleanReplacement criteria.private final StringSource.private final booleanProcess on Windows? -
Constructor Summary
ConstructorsConstructorDescriptionBasicModuleResource(String src, Path dest, boolean shouldReplace, boolean isOptional, boolean isExecutable, boolean isWindows, boolean isNonWindows) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate InputStreamconnect(ModuleContext moduleContext, URI uri) Connect to the given URI and return the HTTP response stream.private Module.ResourceResultdisable(ModuleContext moduleContext, boolean clean) Disable the supplied resource, either removing or renaming.private Module.ResourceResultenable(ModuleContext moduleContext) Enable the supplied resource.booleanGets the destination for the resource.private InputStreamgetDestinationStream(ModuleContext moduleContext) Access the destination as a stream.Gets the source location of the resource.private InputStreamgetSourceStream(ModuleContext moduleContext) Access the source as a stream.booleanhasChanged(ModuleContext moduleContext) Gets whether the resource has been altered at its destination from the source material.inthashCode()booleanGets whether the resource should be marked executable where applicable.booleanGets whether the resource should be processed on non-Windows platforms.booleanGets whether the resource, if missing, should not act as a module-disabled signal.booleanGets whether the resource should be config(replace) or config(noreplace) in RPM specfile parlance.booleanGets whether the resource should be processed on Windows.
-
Field Details
-
source
Source. -
destination
Destination. -
replace
private final boolean replaceReplacement criteria. -
optional
private final boolean optionalOptional criteria. -
executable
private final boolean executableExecutable criteria. -
windows
private final boolean windowsProcess on Windows? -
nonwindows
private final boolean nonwindowsProcess on non-Windows?
-
-
Constructor Details
-
BasicModuleResource
public BasicModuleResource(@Nonnull @NotEmpty String src, @Nonnull Path dest, boolean shouldReplace, boolean isOptional, boolean isExecutable, boolean isWindows, boolean isNonWindows) Constructor.- Parameters:
src- sourcedest- destinationshouldReplace- whether to replace when enablingisOptional- whether the resource is optionalisExecutable- whether the resource is executableisWindows- whether the resource should be processed on WindowsisNonWindows- whether the resource should be processed on non-Windows platforms
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
getSource
Gets the source location of the resource.This may be a URL or a local path that will be assumed a classpath.
- Specified by:
getSourcein interfaceModule.ModuleResource- Returns:
- source location
-
getDestination
Gets the destination for the resource.- Specified by:
getDestinationin interfaceModule.ModuleResource- Returns:
- destination path
-
isReplace
public boolean isReplace()Gets whether the resource should be config(replace) or config(noreplace) in RPM specfile parlance.- Specified by:
isReplacein interfaceModule.ModuleResource- Returns:
- true iff the resource should be replaced with the original preserved
-
isOptional
public boolean isOptional()Gets whether the resource, if missing, should not act as a module-disabled signal.- Specified by:
isOptionalin interfaceModule.ModuleResource- Returns:
- true iff the resource may be removed by a deployer without disabling the module
-
isExecutable
public boolean isExecutable()Gets whether the resource should be marked executable where applicable.- Specified by:
isExecutablein interfaceModule.ModuleResource- Returns:
- true iff the resource should be marked executable
-
isWindows
public boolean isWindows()Gets whether the resource should be processed on Windows.- Specified by:
isWindowsin interfaceModule.ModuleResource- Returns:
- true iff the resource should be processed on Windows
-
isNonWindows
public boolean isNonWindows()Gets whether the resource should be processed on non-Windows platforms.- Specified by:
isNonWindowsin interfaceModule.ModuleResource- Returns:
- true iff the resource should be processed on non-Windows platforms
-
hasChanged
Gets whether the resource has been altered at its destination from the source material.- Parameters:
moduleContext- context for module operations- Returns:
- true iff the resource has been changed
-
getSourceStream
@Nullable private InputStream getSourceStream(@Nonnull ModuleContext moduleContext) throws IOException Access the source as a stream.- Parameters:
moduleContext- context for module operations- Returns:
- a stream or null if the source does not exist
- Throws:
IOException- on failure
-
connect
@Nonnull private InputStream connect(@Nonnull ModuleContext moduleContext, @Nonnull URI uri) throws IOException Connect to the given URI and return the HTTP response stream.- Parameters:
moduleContext- module contexturi- resource location- Returns:
- input stream of response
- Throws:
IOException- on errors
-
getDestinationStream
@Nullable private InputStream getDestinationStream(@Nonnull ModuleContext moduleContext) throws IOException Access the destination as a stream.- Parameters:
moduleContext- context for module operations- Returns:
- a stream or null if the destination does not exist
- Throws:
IOException- on failure
-
enable
@Nonnull private Module.ResourceResult enable(@Nonnull ModuleContext moduleContext) throws ModuleException Enable the supplied resource.- Parameters:
moduleContext- module context- Returns:
- result of operation
- Throws:
ModuleException- if an error occurs
-
disable
@Nonnull private Module.ResourceResult disable(@Nonnull ModuleContext moduleContext, boolean clean) throws ModuleException Disable the supplied resource, either removing or renaming.- Parameters:
moduleContext- module contextclean- true iff resource should be removed- Returns:
- result of operation
- Throws:
ModuleException- if an error occurs
-