/xservices/trunk/src/java/net/brutex/xservices/ws/rs/FileInfo.java |
---|
42,7 → 42,6 |
public abstract interface FileInfo { |
public final static String BASE_PATH = "/FileService/"; |
public final static String SERVICE_NAME = "FileInfoService"; |
/** |
* Get the file/ directory listing. |
/xservices/trunk/src/java/net/brutex/xservices/ws/rs/FileInfoImpl.java |
---|
73,14 → 73,12 |
*/ |
public Response getFiles(HttpHeaders h, UriInfo uriInfo, String dir, boolean withDir, boolean withFiles, int level, String search, int count, int page, boolean useCache) |
{ |
if(dir==null) { |
dir = "c:/"; |
logger.warn("No directory specified. Default is 'c:/'."); |
} |
isPermitted(dir); |
URI baseuri = URI.create(uriInfo.getBaseUri()+FileInfo.BASE_PATH+"getFile?file="); |
if(dir==null) {dir = "c:/"; System.out.println("No directory specified.");} |
logger.info(String.format("Listing directory '%s'.", dir)); |
if (level <= 0) level = 1; |
111,8 → 109,9 |
logger.info(String.format("Returning items %s to %s from total of %s items in the list.", fromIndex, toIndex, list.size())); |
return Response.ok(sublist).build(); |
} catch (CacheException e) { |
return Response.serverError().build(); |
Response.serverError().build(); |
} |
return null; |
} |
/** |
255,14 → 254,4 |
} |
return true; |
} |
//http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java |
private static String humanReadableByteCount(long bytes, boolean si) { |
int unit = si ? 1000 : 1024; |
if (bytes < unit) return bytes + " B"; |
int exp = (int) (Math.log(bytes) / Math.log(unit)); |
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (si ? "" : "i"); |
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); |
} |
} |
/xservices/trunk/src/java/net/brutex/xservices/ws/rs/ResultType.java |
---|
1,19 → 1,3 |
/* |
* Copyright 2014 Brian Rosenberger (Brutex Network) |
* |
* Licensed 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 net.brutex.xservices.ws.rs; |
import net.brutex.xservices.types.scm.ItemType; |
/xservices/trunk/src/java/net/brutex/xservices/ws/rs/FileListType.java |
---|
1,19 → 1,3 |
/* |
* Copyright 2014 Brian Rosenberger (Brutex Network) |
* |
* Licensed 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 net.brutex.xservices.ws.rs; |
import javax.xml.bind.annotation.XmlElement; |