FileSystemActor implements IOutputStreamingSupport { public void configure(FS fileSystem, ParameterList parameterList, INamedObject owner) throws ConfigurationException { this.owner=owner; this.fileSystem=fileSystem; this.parameterList=parameterList; if (fileSystem instanceof IWritableFileSystem) { actions.addAll(Arrays.asList(ACTIONS_WRITABLE_FS)); } if (getAction() == null) throw new ConfigurationException(owner.getClass().getSimpleName()+" ["+owner.getName()+"]: action must be specified"); if (!actions.contains(getAction())) throw new ConfigurationException(owner.getClass().getSimpleName()+" ["+owner.getName()+"]: unknown or invalid action [" + getAction() + "] supported actions are " + actions.toString() + ""); if (getAction().equals(ACTION_READ2)) { ConfigurationWarnings.add(owner, log, "action ["+ACTION_READ2+"] has been replaced with ["+ACTION_READ1+"]"); setAction(ACTION_READ1); } if (getAction().equals(ACTION_WRITE2)) { ConfigurationWarnings.add(owner, log, "action ["+ACTION_WRITE2+"] has been replaced with ["+ACTION_WRITE1+"]"); setAction(ACTION_WRITE1); } if (StringUtils.isNotEmpty(getBase64()) && !(getBase64().equals(BASE64_ENCODE) || getBase64().equals(BASE64_DECODE))) { throw new ConfigurationException("attribute 'base64' can have value '"+BASE64_ENCODE+"' or '"+BASE64_DECODE+"' or can be left empty"); } if (parameterList!=null && parameterList.findParameter(PARAMETER_CONTENTS2) != null && parameterList.findParameter(PARAMETER_CONTENTS1) == null) { ConfigurationWarnings.add(owner, log, "parameter ["+PARAMETER_CONTENTS2+"] has been replaced with ["+PARAMETER_CONTENTS1+"]"); parameterList.findParameter(PARAMETER_CONTENTS2).setName(PARAMETER_CONTENTS1); } actionRequiresAtLeastOneOfTwoParametersOrAttribute(owner, parameterList, ACTION_WRITE1, PARAMETER_CONTENTS1, PARAMETER_FILENAME, "filename", getFilename()); actionRequiresAtLeastOneOfTwoParametersOrAttribute(owner, parameterList, ACTION_MOVE, PARAMETER_DESTINATION, null, "destination", getDestination()); actionRequiresAtLeastOneOfTwoParametersOrAttribute(owner, parameterList, ACTION_COPY, PARAMETER_DESTINATION, null, "destination", getDestination()); actionRequiresAtLeastOneOfTwoParametersOrAttribute(owner, parameterList, ACTION_RENAME, PARAMETER_DESTINATION, null, "destination", getDestination()); if (StringUtils.isNotEmpty(getInputFolder()) && parameterList!=null && parameterList.findParameter(PARAMETER_INPUTFOLDER) != null) { ConfigurationWarnings.add(owner, log, "inputFolder configured via attribute [inputFolder] as well as via parameter ["+PARAMETER_INPUTFOLDER+"], parameter will be ignored"); } if (!(fileSystem instanceof IWritableFileSystem)) { if (getNumberOfBackups()>0) { throw new ConfigurationException("FileSystem ["+ClassUtils.nameOf(fileSystem)+"] does not support setting attribute 'numberOfBackups'"); } if (getRotateDays()>0) { throw new ConfigurationException("FileSystem ["+ClassUtils.nameOf(fileSystem)+"] does not support setting attribute 'rotateDays'"); } } }  void configure(FS fileSystem, ParameterList parameterList, INamedObject owner); void open(); Object doAction(Message input, ParameterValueList pvl, IPipeLineSession session); boolean canProvideOutputStream(); @Override boolean supportsOutputStreamPassThrough(); @SuppressWarnings("resource") @Override MessageOutputStream provideOutputStream(IPipeLineSession session, IForwardTarget next); XmlBuilder getFileAsXmlBuilder(F f, String rootElementName); @IbisDoc({"1", "Possible values: "+ACTION_LIST+", "+ACTION_INFO+", "+ACTION_READ1+", "+ACTION_READ_DELETE+", "+ACTION_MOVE+", "+ACTION_COPY+", "+ACTION_DELETE+", "+ACTION_MKDIR+", "+ACTION_RMDIR+", "+ACTION_WRITE1+", "+ACTION_APPEND+", "+ACTION_RENAME, "" }) void setAction(String action); String getAction(); @IbisDoc({"2", "Folder that is scanned for files when action="+ACTION_LIST+". When not set, the root is scanned", ""}) void setInputFolder(String inputFolder); String getInputFolder(); @IbisDoc({"3", "when set to <code>true</code>, the folder to move to is created if it does not exist", "false"}) void setCreateFolder(boolean createFolder); boolean isCreateFolder(); @IbisDoc({"4", "Can be set to 'encode' or 'decode' for actions "+ACTION_READ1+", "+ACTION_WRITE1+" and "+ACTION_APPEND+". When set the stream is base64 encoded or decoded, respectively", ""}) void setBase64(String base64); String getBase64(); @IbisDoc({"5", "filename to operate on. When not set, the parameter "+PARAMETER_FILENAME+" is used. When that is not set either, the input is used", ""}) void setFilename(String filename); String getFilename(); @IbisDoc({"5", "destination for "+ACTION_MOVE+", "+ACTION_COPY+" or "+ACTION_RENAME+". If not set, the parameter "+PARAMETER_DESTINATION+" is used. When that is not set either, the input is used", ""}) void setDestination(String destination); String getDestination(); @IbisDoc({"6", "for action="+ACTION_APPEND+": when set to a positive number, the file is rotated each day, and this number of files is kept. The inputFolder must point to the directory where the file resides", "0"}) void setRotateDays(int rotateDays); int getRotateDays(); @IbisDoc({"7", "for action="+ACTION_APPEND+": when set to a positive number, the file is rotated when it has reached the specified size, and the number of files specified in numberOfBackups is kept. Size is specified in plain bytes, suffixes like 'K', 'M' or 'G' are not recognized. The inputFolder must point to the directory where the file resides", "0"}) void setRotateSize(int rotateSize); int getRotateSize(); @IbisDoc({"8", "for action="+ACTION_WRITE1+", and for action="+ACTION_APPEND+" with rotateSize>0: the number of backup files that is kept. The inputFolder must point to the directory where the file resides", "0"}) void setNumberOfBackups(int numberOfBackups); int getNumberOfBackups(); final String ACTION_LIST; final String ACTION_INFO; final String ACTION_READ1; final String ACTION_READ2; final String ACTION_READ_DELETE; final String ACTION_MOVE; final String ACTION_COPY; final String ACTION_DELETE; final String ACTION_MKDIR; final String ACTION_RMDIR; final String ACTION_WRITE1; final String ACTION_WRITE2; final String ACTION_APPEND; final String ACTION_RENAME; final String PARAMETER_CONTENTS1; final String PARAMETER_CONTENTS2; final String PARAMETER_FILENAME; final String PARAMETER_INPUTFOLDER; final String PARAMETER_DESTINATION; final String BASE64_ENCODE; final String BASE64_DECODE; final String[] ACTIONS_BASIC; final String[] ACTIONS_WRITABLE_FS; }
@Test public void fileSystemActorTestConfigureNoAction() throws Exception { thrown.expectMessage("action must be specified"); thrown.expectMessage("fake owner of FileSystemActor"); actor.configure(fileSystem,null,owner); }