Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 175 → Rev 177

/xservices/trunk/src/java/net/brutex/xservices/ws/XmlService.java
27,6 → 27,7
import net.brutex.xservices.types.ant.FileResource;
 
import org.apache.cxf.annotations.WSDLDocumentation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
 
/**
* @author Brian Rosenberger, bru(at)brutex.de
41,6 → 42,7
public static final String PARAM_XPATH = "xpath";
public static final String PARAM_XML = "xmldata";
 
@RequiresPermissions("insertNodes")
@WebMethod(operationName="insertNodes")
@WSDLDocumentation("Insert an XML fragment into an XML document given as string.")
public abstract String insertNodes(
/xservices/trunk/src/java/net/brutex/xservices/ws/impl/XmlServiceImpl.java
61,6 → 61,7
import org.apache.log4j.Logger;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.UnauthorizedException;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jaxen.JaxenException;
import org.jaxen.SimpleNamespaceContext;
 
194,6 → 195,7
}
}
@RequiresPermissions("insertNodes")
public String insertNodes(String source, String encoding, NamespaceListType nsList, String xpath, String xmlFragment) throws XServicesFault {
encoding = validateEncoding(encoding);
try {
/xservices/trunk/src/java/net/brutex/xservices/ws/impl/ExecuteServiceImpl.java
17,8 → 17,6
package net.brutex.xservices.ws.impl;
 
import java.io.File;
import java.util.UUID;
 
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
25,7 → 23,6
import net.brutex.xservices.types.HostConnection;
import net.brutex.xservices.types.ReturnCode;
import net.brutex.xservices.util.BrutexNamespaces;
import net.brutex.xservices.util.JobWrapper;
import net.brutex.xservices.util.RunTask;
import net.brutex.xservices.ws.ExecuteService;
import net.brutex.xservices.ws.XServicesFault;
37,16 → 34,6
import org.apache.tools.ant.types.Commandline;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import static org.quartz.TriggerBuilder.*;
import static org.quartz.SimpleScheduleBuilder.*;
import org.quartz.TriggerUtils;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.triggers.SimpleTriggerImpl;
 
/**
*
/xservices/trunk/src/java/net/brutex/xservices/ws/impl/StringServiceImpl.java
20,12 → 20,15
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
import javax.jws.WebService;
 
import net.brutex.xservices.types.StringMatchType;
import net.brutex.xservices.types.StringReplaceType;
import net.brutex.xservices.types.StringSplitType;
import net.brutex.xservices.ws.StringService;
import net.brutex.xservices.ws.XServicesFault;
 
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.text.translate.CharSequenceTranslator;
import org.apache.commons.lang3.text.translate.NumericEntityEscaper;
96,6 → 99,12
}
return result;
}
@Override
public String removeCRLF(String paramString) throws XServicesFault {
String value = paramString.replaceAll("[\r\n]", "");
return value;
}
 
private int getFlags(String flags) {
int allflags = 0;
/xservices/trunk/src/java/net/brutex/xservices/ws/ArchiveService.java
1,5 → 1,5
/*
* Copyright 2010 Brian Rosenberger (Brutex Network)
g * Copyright 2010 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.
/xservices/trunk/src/java/net/brutex/xservices/ws/rs/FileInfo.java
42,6 → 42,7
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,12 → 73,14
*/
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;
 
109,9 → 111,8
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) {
Response.serverError().build();
return Response.serverError().build();
}
return null;
}
 
/**
254,4 → 255,14
}
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/FileListType.java
1,3 → 1,19
/*
* 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;
/xservices/trunk/src/java/net/brutex/xservices/ws/rs/ResultType.java
1,3 → 1,19
/*
* 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/StringService.java
75,4 → 75,10
@WebParam(name="delimiter") @XmlElement(required=true) String delimiter)
throws XServicesFault;
@WebMethod(operationName="removeCRLF")
@WSDLDocumentation("Remove any line feed and/ or carriage return characters")
public abstract String removeCRLF(
@WebParam(name="string") @XmlElement(required=true) String paramString)
throws XServicesFault;
}