-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CAMEL-21277: use WrappedFile in camel-smb for greater consistency
- Loading branch information
Showing
8 changed files
with
89 additions
and
215 deletions.
There are no files selected for viewing
65 changes: 0 additions & 65 deletions
65
...l-smb/src/generated/java/org/apache/camel/component/smb/converter/SmbConverterLoader.java
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
.../camel-smb/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
This file was deleted.
Oops, something went wrong.
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
71 changes: 71 additions & 0 deletions
71
components/camel-smb/src/main/java/org/apache/camel/component/smb/SmbFile.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,71 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.camel.component.smb; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import com.hierynomus.smbj.share.File; | ||
import org.apache.camel.Exchange; | ||
import org.apache.camel.WrappedFile; | ||
|
||
public class SmbFile implements WrappedFile<File> { | ||
|
||
private final File file; | ||
|
||
public SmbFile(File file) { | ||
this.file = file; | ||
} | ||
|
||
void populateHeaders(Exchange exchange) { | ||
exchange.getMessage().setHeader(SmbConstants.SMB_FILE_PATH, file.getPath()); | ||
exchange.getMessage().setHeader(SmbConstants.SMB_UNC_PATH, file.getUncPath()); | ||
|
||
exchange.getMessage().setHeader(Exchange.FILE_NAME, file.getFileInformation().getNameInformation().toString()); | ||
} | ||
|
||
@Override | ||
public File getFile() { | ||
return file; | ||
} | ||
|
||
public String getPath() { | ||
return getFile().getPath(); | ||
} | ||
|
||
public String getUncPath() { | ||
return getFile().getUncPath(); | ||
} | ||
|
||
public InputStream getInputStream() { | ||
return getFile().getInputStream(); | ||
} | ||
|
||
public long getSize() { | ||
return file.getFileInformation().getStandardInformation().getEndOfFile(); | ||
} | ||
|
||
@Override | ||
public Object getBody() { | ||
try (InputStream is = file.getInputStream()) { | ||
return is.readAllBytes(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
41 changes: 0 additions & 41 deletions
41
...onents/camel-smb/src/main/java/org/apache/camel/component/smb/converter/SmbConverter.java
This file was deleted.
Oops, something went wrong.
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
93 changes: 0 additions & 93 deletions
93
.../camel-smb/src/test/java/org/apache/camel/component/smb/SmbComponentTypeConversionIT.java
This file was deleted.
Oops, something went wrong.