Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 5 → Rev 6

/xservices/trunk/src/java/net/brutex/xservices/types/CompressionType.java
0,0 → 1,28
/*
* 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.
* 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.types;
 
import javax.xml.bind.annotation.XmlEnum;
 
/**
*
* @author Brian Rosenberger, bru@brutex.de
*/
@XmlEnum()
public enum CompressionType {
NONE, GZIP, BZIP2
}
/xservices/trunk/src/java/net/brutex/xservices/types/FileSetResource.java
0,0 → 1,89
/*
* 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.
* 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.types;
 
import java.io.File;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.TarFileSet;
import org.apache.tools.ant.types.ZipFileSet;
 
/**
*
* @author Brian Rosenberger, bru@brutex.de
*/
@XmlType(name="FileSetType", namespace="http://ws.xservices.brutex.net",
propOrder={"type", "source", "includes", "excludes", "casesensitive"})
public class FileSetResource {
 
@XmlElement(name="FileSetType", required=true, nillable=false, defaultValue="FILES")
public FileSetType type = FileSetType.FILES;
 
@XmlElement(name="source", required=true, nillable=false)
public String source = "";
 
@XmlElement(name="includes", required=true, nillable=false, defaultValue="**/*")
public String includes = "";
 
@XmlElement(name="excludes", required=false, nillable=true, defaultValue="")
public String excludes ="";
 
@XmlElement(name="casesensitive", required=true, nillable=false, defaultValue="true")
public boolean casesensitive = true;
 
public FileSet getAntFileSet(Project p) {
FileSet set = null;
switch(type) {
case ZIP:
ZipFileSet zset = new ZipFileSet();
zset.setSrc(new File(source));
zset.setEncoding(System.getProperty("file.encoding"));
set = zset;
break;
case TAR:
TarFileSet tset = new TarFileSet();
tset.setSrc(new File(source));
set = tset;
break;
case GZTAR:
Resource res = new FileResource(FileResource.Type.GZIP, source).getAntResource(p);
TarFileSet gzset = new TarFileSet();
gzset.setSrcResource(res);
set = gzset;
break;
default: //FILES
set = new FileSet();
set.setDir(new File(source));
}
set.setProject(p);
set.setIncludes(includes);
set.setExcludes(excludes);
set.setCaseSensitive(casesensitive);
 
return set;
}
 
@XmlEnum
public enum FileSetType{
FILES, ZIP, TAR, GZTAR
}
 
}
/xservices/trunk/src/java/net/brutex/xservices/types/FileResource.java
0,0 → 1,83
/*
* 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.
* 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.types;
 
import java.io.File;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.resources.BZip2Resource;
import org.apache.tools.ant.types.resources.GZipResource;
import org.apache.tools.ant.types.resources.URLResource;
 
/**
*
* @author Brian Rosenberger, bru@brutex.de
*/
@XmlRootElement(namespace="http://ws.xservices.brutex.net")
public class FileResource
implements ResourceInterface {
 
@XmlElement(defaultValue = "FILE", nillable = false, required = true)
public Type type = Type.FILE;
@XmlElement(nillable = false, required = true)
public String uri;
 
@XmlEnum(String.class)
public enum Type {
 
FILE, URL, GZIP, BZIP2
}
 
public FileResource(Type type, String uri) {
this.type = type;
this.uri = uri;
}
 
public FileResource() {
}
 
public Resource getAntResource(Project p) {
Resource res = null;
switch (type) {
case URL:
URLResource ures = new URLResource(uri);
res = ures;
break;
 
case GZIP:
GZipResource gres = new GZipResource(
new org.apache.tools.ant.types.resources.FileResource(new File(uri)));
res = gres;
break;
 
case BZIP2:
BZip2Resource bres = new BZip2Resource(
new org.apache.tools.ant.types.resources.FileResource(new File(uri)));
res = bres;
break;
 
default:
//Default is Type FILE
res = new org.apache.tools.ant.types.resources.FileResource(new File(uri));
}
res.setProject(p);
return res;
}
}
/xservices/trunk/src/java/net/brutex/xservices/types/ResourceInterface.java
0,0 → 1,30
/*
* 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.
* 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.types;
 
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Resource;
 
/**
*
* @author Brian Rosenberger, bru@brutex.de
*/
public interface ResourceInterface {
 
Resource getAntResource(Project p);
 
}
/xservices/trunk/src/java/net/brutex/xservices/types/ArchiveResource.java
0,0 → 1,79
/*
* 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.
* 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.types;
 
import java.io.File;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.resources.TarResource;
import org.apache.tools.ant.types.resources.ZipResource;
import org.apache.tools.tar.TarEntry;
import org.apache.tools.zip.ZipEntry;
 
/**
*
* @author Brian Rosenberger, bru@brutex.de
*/
@XmlType(namespace = "http://ws.xservices.brutex.net")
public class ArchiveResource
implements ResourceInterface {
 
@XmlElement(defaultValue = "ZIP", nillable = false, required = true)
public ArchiveType type = ArchiveType.ZIP;
@XmlElement(nillable = false, required = true)
public String archive;
@XmlElement(nillable = false, required = true)
public String uri;
 
@XmlEnum(String.class)
public enum ArchiveType {
 
ZIP, TAR, GZTAR
}
 
public Resource getAntResource(Project p) {
Resource res = null;
switch (type) {
case TAR:
TarEntry tarentry = new TarEntry(uri);
TarResource tres = new TarResource(new File(archive), tarentry);
res = tres;
break;
 
case GZTAR:
TarResource gres = new TarResource(new org.apache.tools.ant.types.resources.GZipResource(
new org.apache.tools.ant.types.resources.FileResource(
new File(archive))), new TarEntry(uri));
res = gres;
break;
 
default: //This is type ZIP also
ZipEntry zipentry = new ZipEntry(uri);
if (zipentry.getTime() == -1) {
zipentry.setTime(System.currentTimeMillis());
}
res = new ZipResource(new File(archive), null, zipentry);
break;
}
 
res.setProject(p);
return res;
}
}
/xservices/trunk/src/java/net/brutex/xservices/types/ReturnCode.java
0,0 → 1,43
/*
* 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.
* 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.types;
 
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
 
/**
*
* @author Brian Rosenberger, bru@brutex.de
*/
@XmlType(namespace="http://ws.xservices.brutex.net")
public class ReturnCode {
 
@XmlElement(required=true)
public int returnCode;
 
public String stdOut;
public String stdErr;
 
public ReturnCode() {
}
 
public ReturnCode(int returnCode, String stdOut, String stdErr) {
this.returnCode = returnCode;
this.stdOut = stdOut;
this.stdErr = stdErr;
}
}