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

protected class AbstractModule.BasicModuleResource extends Object implements Module.ModuleResource
Models a specific resource managed by a module.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final Path`
`destination`
Destination.
`private final boolean`
`executable`
Executable criteria.
`private final boolean`
`nonwindows`
Process on non-Windows?
`private final boolean`
`optional`
Optional criteria.
`private final boolean`
`replace`
Replacement criteria.
`private final String`
`source`
Source.
`private final boolean`
`windows`
Process on Windows?

## Constructor Summary

Constructors
Constructor
Description
`BasicModuleResource(String src, Path dest, boolean shouldReplace, boolean isOptional, boolean isExecutable, boolean isWindows, boolean isNonWindows)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`private InputStream`
`connect(ModuleContext moduleContext, URI uri)`
Connect to the given URI and return the HTTP response stream.
`private Module.ResourceResult`
`disable(ModuleContext moduleContext, boolean clean)`
Disable the supplied resource, either removing or renaming.
`private Module.ResourceResult`
`enable(ModuleContext moduleContext)`
Enable the supplied resource.
`boolean`
`equals(Object obj)`
`Path`
`getDestination()`
Gets the destination for the resource.
`private InputStream`
`getDestinationStream(ModuleContext moduleContext)`
Access the destination as a stream.
`String`
`getSource()`
Gets the source location of the resource.
`private InputStream`
`getSourceStream(ModuleContext moduleContext)`
Access the source as a stream.
`boolean`
`hasChanged(ModuleContext moduleContext)`
Gets whether the resource has been altered at its destination from the source material.
`int`
`hashCode()`
`boolean`
`isExecutable()`
Gets whether the resource should be marked executable where applicable.
`boolean`
`isNonWindows()`
Gets whether the resource should be processed on non-Windows platforms.
`boolean`
`isOptional()`
Gets whether the resource, if missing, should not act as a module-disabled signal.
`boolean`
`isReplace()`
Gets whether the resource should be config(replace) or config(noreplace) in RPM specfile parlance.
`boolean`
`isWindows()`
Gets whether the resource should be processed on Windows.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### source

@Nonnull @NotEmpty private final String source
Source.

### destination

@Nonnull private final Path destination
Destination.

### replace

private final boolean replace
Replacement criteria.

### optional

private final boolean optional
Optional criteria.

### executable

private final boolean executable
Executable criteria.

### windows

private final boolean windows
Process on Windows?

### nonwindows

private final boolean nonwindows
Process 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` - source
  `dest` - destination
  `shouldReplace` - whether to replace when enabling
  `isOptional` - whether the resource is optional
  `isExecutable` - whether the resource is executable
  `isWindows` - whether the resource should be processed on Windows
  `isNonWindows` - whether the resource should be processed on non-Windows platforms

## Method Details

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### equals

public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

### getSource

@Nonnull public String 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:
  `getSource` in interface `Module.ModuleResource`
Returns:
  source location

### getDestination

@Nonnull public Path getDestination()
Gets the destination for the resource.

Specified by:
  `getDestination` in interface `Module.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:
  `isReplace` in interface `Module.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:
  `isOptional` in interface `Module.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:
  `isExecutable` in interface `Module.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:
  `isWindows` in interface `Module.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:
  `isNonWindows` in interface `Module.ModuleResource`
Returns:
  true iff the resource should be processed on non-Windows platforms

### hasChanged

public boolean hasChanged(@Nonnull ModuleContext moduleContext)
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 context
  `uri` - 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 context
  `clean` - true iff resource should be removed
Returns:
  result of operation
Throws:
  `ModuleException` - if an error occurs