*) SOAP: adding methods to get the comment and MD5 checksum of a single file

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3604 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 18 years ago
parent 2399ed817c
commit ec225f9ab6

@ -78,7 +78,7 @@ public class ShareService extends AbstractService {
private static final int FILEINFO_COMMENT = 1;
private static final int GENMD5_MD5_ARRAY = 0;
//private static final int GENMD5_MD5_STRING = 1;
private static final int GENMD5_MD5_STRING = 1;
/* =====================================================================
* Used XML Templates
@ -269,7 +269,7 @@ public class ShareService extends AbstractService {
* </ul>
* @throws IOException if the md5 file could not be read
*/
private String[] getFileInfo(File theFile) throws IOException {
private String[] readFileInfo(File theFile) throws IOException {
File md5File = getFileMD5File(theFile);
String md5s = "";
@ -287,11 +287,16 @@ public class ShareService extends AbstractService {
return new String[]{md5s,description};
}
private String getFileComment(File theFile) throws IOException {
String[] info = getFileInfo(theFile);
private String readFileComment(File theFile) throws IOException {
String[] info = readFileInfo(theFile);
return info[FILEINFO_COMMENT];
}
private String readFileMD5String(File theFile) throws IOException {
String[] info = readFileInfo(theFile);
return info[FILEINFO_MD5_STRING];
}
private String yacyhURL(yacySeed seed, String filename, String md5) throws AxisFault {
try {
// getting the template class file
@ -355,7 +360,7 @@ public class ShareService extends AbstractService {
String phrase = this.getPhrase(filename);
// getting file info [0=md5s,1=comment]
String[] fileInfo = getFileInfo(file);
String[] fileInfo = readFileInfo(file);
// delete old indexed phrases
String urlstring = yacyhURL(yacyCore.seedDB.mySeed, filename, fileInfo[FILEINFO_MD5_STRING]);
@ -517,6 +522,56 @@ public class ShareService extends AbstractService {
this.deleteRecursive(fileToDelete);
}
/**
* Reads the comment assigned to a file located in the yacy file-share
* @param workingDirPath a relative path within the yacy file-share
* @param fileName the name of the file
* @return the comment assigned to a file located in the yacy file-share or an emty string if no comment is available
* @throws AxisFault
* @throws IOException
*/
public String getFileComment(String workingDirPath, String fileName) throws AxisFault, IOException {
// extracting the message context
extractMessageContext(AUTHENTICATION_NEEDED);
// getting the working directory
File workingDir = getWorkingDir(workingDirPath);
// getting the working file
File workingFile = getWorkingFile(workingDir,fileName);
if (!workingFile.exists()) throw new AxisFault("Requested file does not exist.");
if (!workingFile.canRead())throw new AxisFault("Requested file can not be read.");
if (!workingFile.isFile()) throw new AxisFault("Requested file is not a file.");
// get the old file comment
return this.readFileComment(workingFile);
}
/**
* Reads the MD5 checksum of a file located in the yacy file-share
* @param workingDirPatha relative path within the yacy file-share
* @param fileName the name of the file
* @return the MD5 checksum of the file or an empty string if the checksum is not available
* @throws IOException
*/
public String getFileMD5(String workingDirPath, String fileName) throws IOException {
// extracting the message context
extractMessageContext(AUTHENTICATION_NEEDED);
// getting the working directory
File workingDir = getWorkingDir(workingDirPath);
// getting the working file
File workingFile = getWorkingFile(workingDir,fileName);
if (!workingFile.exists()) throw new AxisFault("Requested file does not exist.");
if (!workingFile.canRead())throw new AxisFault("Requested file can not be read.");
if (!workingFile.isFile()) throw new AxisFault("Requested file is not a file.");
// get the old file comment
return this.readFileMD5String(workingFile);
}
/**
* To download a file located in the yacy file-share.
* This function returns the requested file as soap attachment to the caller of this function.
@ -542,7 +597,7 @@ public class ShareService extends AbstractService {
if (!workingFile.isFile()) throw new AxisFault("Requested file is not a file.");
// getting the md5 string and comment
String[] info = getFileInfo(workingFile);
String[] info = readFileInfo(workingFile);
// get the current message context
MessageContext msgContext = MessageContext.getCurrentContext();
@ -581,7 +636,7 @@ public class ShareService extends AbstractService {
if (destFile.exists()) throw new AxisFault("Destination file already exists.");
// get the old file comment
String comment = this.getFileComment(sourceFile);
String comment = this.readFileComment(sourceFile);
// unindex the old file and delete the old MD5 file
this.unIndexFile(sourceFile);
@ -643,7 +698,7 @@ public class ShareService extends AbstractService {
if (destFile.exists()) throw new AxisFault("Destination file already exists.");
// getting the old comment
String comment = this.getFileComment(sourceFile);
String comment = this.readFileComment(sourceFile);
// unindex old file and delete MD5 file
this.unIndexFile(sourceFile);

@ -4,35 +4,35 @@ Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:message name="getFileResponse">
<wsdl:part name="getFileReturn" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="getDirListResponse">
<wsdl:part name="getDirListReturn" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="moveFileRequest">
<wsdl:part name="sourceDirName" type="xsd:string"/>
<wsdl:part name="destDirName" type="xsd:string"/>
<wsdl:part name="fileName" type="xsd:string"/>
<wsdl:part name="indexFile" type="xsd:boolean"/>
</wsdl:message>
<wsdl:message name="getDirListResponse">
<wsdl:part name="getDirListReturn" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="getFileCommentResponse">
<wsdl:part name="getFileCommentReturn" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="renameFileResponse">
</wsdl:message>
<wsdl:message name="deleteResponse">
</wsdl:message>
<wsdl:message name="uploadFileResponse">
</wsdl:message>
<wsdl:message name="createNewXMLDocumentRequest">
<wsdl:part name="rootElementName" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="changeCommentResponse">
</wsdl:message>
<wsdl:message name="deleteRequest">
<wsdl:part name="workingDirPath" type="xsd:string"/>
<wsdl:part name="nameToDelete" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="getDirListRequest">
<wsdl:part name="workingDirPath" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="renameFileRequest">
<wsdl:part name="workingDirPath" type="xsd:string"/>
@ -41,36 +41,65 @@ Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:part name="indexFile" type="xsd:boolean"/>
</wsdl:message>
<wsdl:message name="getDirListRequest">
<wsdl:part name="workingDirPath" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="createNewXMLDocumentResponse">
<wsdl:part name="createNewXMLDocumentReturn" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="uploadFileRequest">
<wsdl:part name="workingDirPath" type="xsd:string"/>
<wsdl:part name="indexFile" type="xsd:boolean"/>
<wsdl:part name="comment" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="createDirectoryResponse">
</wsdl:message>
<wsdl:message name="changeCommentRequest">
<wsdl:message name="getFileCommentRequest">
<wsdl:part name="workingDirPath" type="xsd:string"/>
<wsdl:part name="fileName" type="xsd:string"/>
<wsdl:part name="comment" type="xsd:string"/>
<wsdl:part name="indexFile" type="xsd:boolean"/>
</wsdl:message>
<wsdl:message name="getFileRequest">
<wsdl:message name="changeCommentRequest">
<wsdl:part name="workingDirPath" type="xsd:string"/>
<wsdl:part name="fileName" type="xsd:string"/>
<wsdl:part name="comment" type="xsd:string"/>
<wsdl:part name="indexFile" type="xsd:boolean"/>
</wsdl:message>
<wsdl:message name="createDirectoryRequest">
<wsdl:part name="workingDirPath" type="xsd:string"/>
<wsdl:part name="newDirName" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="getFileRequest">
<wsdl:part name="workingDirPath" type="xsd:string"/>
<wsdl:part name="fileName" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="moveFileResponse">
</wsdl:message>
<wsdl:message name="getFileMD5Request">
<wsdl:part name="workingDirPath" type="xsd:string"/>
<wsdl:part name="fileName" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="getFileMD5Response">
<wsdl:part name="getFileMD5Return" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="ShareService">
<wsdl:operation name="delete" parameterOrder="workingDirPath nameToDelete">
<wsdl:input message="impl:deleteRequest" name="deleteRequest"/>
<wsdl:output message="impl:deleteResponse" name="deleteResponse"/>
</wsdl:operation>
<wsdl:operation name="createDirectory" parameterOrder="workingDirPath newDirName">
<wsdl:input message="impl:createDirectoryRequest" name="createDirectoryRequest"/>
<wsdl:output message="impl:createDirectoryResponse" name="createDirectoryResponse"/>
</wsdl:operation>
<wsdl:operation name="getFile" parameterOrder="workingDirPath fileName">
<wsdl:input message="impl:getFileRequest" name="getFileRequest"/>
<wsdl:output message="impl:getFileResponse" name="getFileResponse"/>
</wsdl:operation>
<wsdl:operation name="getDirList" parameterOrder="workingDirPath">
<wsdl:input message="impl:getDirListRequest" name="getDirListRequest"/>
<wsdl:output message="impl:getDirListResponse" name="getDirListResponse"/>
@ -79,9 +108,18 @@ Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:input message="impl:uploadFileRequest" name="uploadFileRequest"/>
<wsdl:output message="impl:uploadFileResponse" name="uploadFileResponse"/>
</wsdl:operation>
<wsdl:operation name="getFileComment" parameterOrder="workingDirPath fileName">
<wsdl:input message="impl:getFileCommentRequest" name="getFileCommentRequest"/>
<wsdl:output message="impl:getFileCommentResponse" name="getFileCommentResponse"/>
</wsdl:operation>
<wsdl:operation name="getFileMD5" parameterOrder="workingDirPath fileName">
<wsdl:input message="impl:getFileMD5Request" name="getFileMD5Request"/>
<wsdl:output message="impl:getFileMD5Response" name="getFileMD5Response"/>
</wsdl:operation>
<wsdl:operation name="renameFile" parameterOrder="workingDirPath oldFileName newFileName indexFile">
<wsdl:input message="impl:renameFileRequest" name="renameFileRequest"/>
<wsdl:output message="impl:renameFileResponse" name="renameFileResponse"/>
</wsdl:operation>
<wsdl:operation name="changeComment" parameterOrder="workingDirPath fileName comment indexFile">
@ -89,126 +127,132 @@ Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:output message="impl:changeCommentResponse" name="changeCommentResponse"/>
</wsdl:operation>
<wsdl:operation name="moveFile" parameterOrder="sourceDirName destDirName fileName indexFile">
<wsdl:input message="impl:moveFileRequest" name="moveFileRequest"/>
<wsdl:output message="impl:moveFileResponse" name="moveFileResponse"/>
</wsdl:operation>
<wsdl:operation name="delete" parameterOrder="workingDirPath nameToDelete">
<wsdl:input message="impl:deleteRequest" name="deleteRequest"/>
<wsdl:output message="impl:deleteResponse" name="deleteResponse"/>
</wsdl:operation>
<wsdl:operation name="createDirectory" parameterOrder="workingDirPath newDirName">
<wsdl:input message="impl:createDirectoryRequest" name="createDirectoryRequest"/>
<wsdl:output message="impl:createDirectoryResponse" name="createDirectoryResponse"/>
</wsdl:operation>
<wsdl:operation name="getFile" parameterOrder="workingDirPath fileName">
<wsdl:input message="impl:getFileRequest" name="getFileRequest"/>
<wsdl:output message="impl:getFileResponse" name="getFileResponse"/>
</wsdl:operation>
<wsdl:operation name="createNewXMLDocument" parameterOrder="rootElementName">
<wsdl:input message="impl:createNewXMLDocumentRequest" name="createNewXMLDocumentRequest"/>
<wsdl:output message="impl:createNewXMLDocumentResponse" name="createNewXMLDocumentResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="shareSoapBinding" type="impl:ShareService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getDirList">
<wsdl:operation name="delete">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getDirListRequest">
<wsdl:input name="deleteRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.soap.anomic.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="getDirListResponse">
<wsdl:output name="deleteResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://yacy:8080/soap/share" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="uploadFile">
<wsdl:operation name="createDirectory">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="uploadFileRequest">
<wsdl:input name="createDirectoryRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.soap.anomic.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="uploadFileResponse">
<wsdl:output name="createDirectoryResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://yacy:8080/soap/share" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="renameFile">
<wsdl:operation name="getFile">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="renameFileRequest">
<wsdl:input name="getFileRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.soap.anomic.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="renameFileResponse">
<wsdl:output name="getFileResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://yacy:8080/soap/share" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="changeComment">
<wsdl:operation name="getDirList">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="changeCommentRequest">
<wsdl:input name="getDirListRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.soap.anomic.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="changeCommentResponse">
<wsdl:output name="getDirListResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://yacy:8080/soap/share" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="moveFile">
<wsdl:operation name="uploadFile">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="moveFileRequest">
<wsdl:input name="uploadFileRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.soap.anomic.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="moveFileResponse">
<wsdl:output name="uploadFileResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://yacy:8080/soap/share" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="delete">
<wsdl:operation name="getFileComment">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="deleteRequest">
<wsdl:input name="getFileCommentRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.soap.anomic.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="deleteResponse">
<wsdl:output name="getFileCommentResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://yacy:8080/soap/share" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="createDirectory">
<wsdl:operation name="getFileMD5">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="createDirectoryRequest">
<wsdl:input name="getFileMD5Request">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.soap.anomic.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="getFileMD5Response">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://yacy:8080/soap/share" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="renameFile">
<wsdl:output name="createDirectoryResponse">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="renameFileRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.soap.anomic.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="renameFileResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://yacy:8080/soap/share" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getFile">
<wsdl:operation name="changeComment">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getFileRequest">
<wsdl:input name="changeCommentRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.soap.anomic.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="changeCommentResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://yacy:8080/soap/share" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="moveFile">
<wsdl:output name="getFileResponse">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="moveFileRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.soap.anomic.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="moveFileResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://yacy:8080/soap/share" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="createNewXMLDocument">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="createNewXMLDocumentRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://soap.anomic.de" use="encoded"/>
</wsdl:input>
<wsdl:output name="createNewXMLDocumentResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://yacy:8080/soap/share" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ShareServiceService">
<wsdl:port binding="impl:shareSoapBinding" name="share">
<wsdlsoap:address location="http://yacy:8080/soap/share"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Loading…
Cancel
Save