001/* 002 * Copyright 2007-2018 The jdeb developers. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.vafer.jdeb.ant; 018 019import org.apache.commons.compress.archivers.zip.UnixStat; 020import org.vafer.jdeb.DataProducer; 021import org.vafer.jdeb.mapping.PermMapper; 022import org.vafer.jdeb.producers.DataProducerLink; 023 024/** 025 * Defines a symbolic or hard link. 026 */ 027public final class Link { 028 029 private String name; 030 private String target; 031 private boolean symbolic = true; 032 private String username = "root"; 033 private String group = "root"; 034 private int uid = 0; 035 private int gid = 0; 036 private int mode = UnixStat.LINK_FLAG | UnixStat.DEFAULT_LINK_PERM; 037 038 DataProducer toDataProducer() { 039 org.vafer.jdeb.mapping.Mapper mapper = new PermMapper(uid, gid, username, group, mode, mode, 0, null); 040 return new DataProducerLink(name, target, symbolic, null, null, new org.vafer.jdeb.mapping.Mapper[]{mapper}); 041 } 042 043 public String getName() { 044 return name; 045 } 046 047 public void setName(String name) { 048 this.name = name; 049 } 050 051 public String getTarget() { 052 return target; 053 } 054 055 public void setTarget(String target) { 056 this.target = target; 057 } 058 059 public boolean isSymbolic() { 060 return symbolic; 061 } 062 063 public void setSymbolic(boolean symbolic) { 064 this.symbolic = symbolic; 065 } 066 067 public String getUsername() { 068 return username; 069 } 070 071 public void setUsername(String username) { 072 this.username = username; 073 } 074 075 public String getGroup() { 076 return group; 077 } 078 079 public void setGroup(String group) { 080 this.group = group; 081 } 082 083 public int getUid() { 084 return uid; 085 } 086 087 public void setUid(int uid) { 088 this.uid = uid; 089 } 090 091 public int getGid() { 092 return gid; 093 } 094 095 public void setGid(int gid) { 096 this.gid = gid; 097 } 098 099 public int getMode() { 100 return mode; 101 } 102 103 public void setMode(String mode) { 104 this.mode = UnixStat.LINK_FLAG | Integer.parseInt(mode, 8); 105 } 106}