Convert Posix mode to {@link ZTFilePermissions}

@param mode
@return
439961
static ZTFilePermissions fromPosixFileMode(int mode) {
    ZTFilePermissions permissions = new ZTFilePermissions();
    
    permissions.setOwnerCanExecute( (mode &  OWNER_EXECUTE_FLAG)  > 0 );
    permissions.setGroupCanExecute( (mode &  GROUP_EXECUTE_FLAG)  > 0 );
    permissions.setOthersCanExecute((mode &  OTHERS_EXECUTE_FLAG) > 0 );
    
    permissions.setOwnerCanWrite( (mode &  OWNER_WRITE_FLAG)  > 0 );
    permissions.setGroupCanWrite( (mode &  GROUP_WRITE_FLAG)  > 0 );
    permissions.setOthersCanWrite((mode &  OTHERS_WRITE_FLAG) > 0 );
    
    permissions.setOwnerCanRead( (mode &  OWNER_READ_FLAG)  > 0 );
    permissions.setGroupCanRead( (mode &  GROUP_READ_FLAG)  > 0 );
    permissions.setOthersCanRead((mode &  OTHERS_READ_FLAG) > 0 );
    
    return permissions;
  }
93000
public OvhDeveloperModeRestriction accessRestriction_developerMode_GET() throws IOException {
		String qPath = "/me/accessRestriction/developerMode";
		StringBuilder sb = path(qPath);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhDeveloperModeRestriction.class);
	}
558157
public boolean exportUserHasReadPermission() {

        String vfsName = getParamResource();
        CmsObject cms = getCms();
        try {
            // static export must always be checked with the export users permissions,
            // not the current users permissions
            CmsObject exportCms = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserExport());
            exportCms.getRequestContext().setSiteRoot(getCms().getRequestContext().getSiteRoot());
            // let's look up if the export user has the permission to read
            return exportCms.hasPermissions(
                cms.readResource(vfsName, CmsResourceFilter.IGNORE_EXPIRATION),
                CmsPermissionSet.ACCESS_READ);
        } catch (CmsException e) {
            // ignore this exception
        }
        return false;
    }
1326831
public base_response enable_modes(String[] modes) throws Exception
	{
		base_response result = null;
		nsmode resource = new nsmode();
		resource.set_mode(modes);
		options option = new options();
		option.set_action("enable");
		result = resource.perform_operation(this, option);
		return result;
	}
913306
public short applyNewPermission(FileStatus file) {
    FsPermission perms = file.getPermission();
    int existing = perms.toShort();
    boolean exeOk = file.isDir() || (existing & 0111) != 0;
    
    return (short)combineModes(existing, exeOk);
  }
14514
public Map<String, Map<String, List<String>>> getResourcePermissions() {
		if (resourcePermissions == null) {
			resourcePermissions = new LinkedHashMap<>();
		}
		return resourcePermissions;
	}
210860
public Permission<PermissionsDescriptor> getOrCreatePermission()
   {
      List<Node> nodeList = model.get("permission");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new PermissionImpl<PermissionsDescriptor>(this, "permission", model, nodeList.get(0));
      }
      return createPermission();
   }
1128917
protected PermissionModel getPermission(int index) {
        if (permissions().isEmpty()) return null;
        if ((index) <= permissions().size()) {// avoid accessing index does not exists.
            return permissions().get(index);
        }
        return null;
    }
635091
public static Pin[] allPins(PinMode ... mode) {
        List<Pin> results = new ArrayList<>();
        for(Pin p : pins.values()){
            EnumSet<PinMode> supported_modes = p.getSupportedPinModes();
            for(PinMode m : mode){
                if(supported_modes.contains(m)){
                    results.add(p);
                    continue;
                }
            }
        }
        return results.toArray(new Pin[0]);
    }
969566
public static @CheckForNull Permission fromId(@Nonnull String id) {
        int idx = id.lastIndexOf('.');
        if(idx<0)   return null;

        try {
            // force the initialization so that it will put all its permissions into the list.
            Class cl = Class.forName(id.substring(0,idx),true, Jenkins.getInstance().getPluginManager().uberClassLoader);
            PermissionGroup g = PermissionGroup.get(cl);
            if(g ==null)  return null;
            return g.find(id.substring(idx+1));
        } catch (ClassNotFoundException e) {
            return null;
        }
    }
653851
public CmsPermissionSet getPermissionSet() {

        CmsPermissionSetCustom pset = new CmsPermissionSetCustom();
        CmsResource resource = getResource();
        try {
            if (getCms().hasPermissions(resource, CmsPermissionSet.ACCESS_CONTROL, false, CmsResourceFilter.ALL)) {
                pset.grantPermissions(CmsPermissionSet.PERMISSION_CONTROL);
            } else {
                pset.denyPermissions(CmsPermissionSet.PERMISSION_CONTROL);
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage());
        }
        try {
            if (getCms().hasPermissions(
                resource,
                CmsPermissionSet.ACCESS_DIRECT_PUBLISH,
                false,
                CmsResourceFilter.ALL)) {
                pset.grantPermissions(CmsPermissionSet.PERMISSION_DIRECT_PUBLISH);
            } else {
                pset.denyPermissions(CmsPermissionSet.PERMISSION_DIRECT_PUBLISH);
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage());
        }
        try {
            if (getCms().hasPermissions(resource, CmsPermissionSet.ACCESS_READ, false, CmsResourceFilter.ALL)) {
                pset.grantPermissions(CmsPermissionSet.PERMISSION_READ);
            } else {
                pset.denyPermissions(CmsPermissionSet.PERMISSION_READ);
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage());
        }
        try {
            if (getCms().hasPermissions(resource, CmsPermissionSet.ACCESS_VIEW, false, CmsResourceFilter.ALL)) {
                pset.grantPermissions(CmsPermissionSet.PERMISSION_VIEW);
            } else {
                pset.denyPermissions(CmsPermissionSet.PERMISSION_VIEW);
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage());
        }
        try {
            if (getCms().hasPermissions(resource, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.ALL)) {
                pset.grantPermissions(CmsPermissionSet.PERMISSION_WRITE);
            } else {
                pset.denyPermissions(CmsPermissionSet.PERMISSION_WRITE);
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage());
        }

        return pset;
    }
1260192
@Override
	public Permission createPerm(String p) {
		String[] params = Split.split('|', p);
		if(params.length==3) {
			return new AAFPermission(params[0],params[1],params[2]);
		} else {
			return new LocalPermission(p);
		}
	}
941926
static ZipEntry fromFile(String name, File file) {
    ZipEntry zipEntry = new ZipEntry(name);
    if (!file.isDirectory()) {
      zipEntry.setSize(file.length());
    }
    zipEntry.setTime(file.lastModified());

    ZTFilePermissions permissions = ZTFilePermissionsUtil.getDefaultStategy().getPermissions(file);
    if (permissions != null) {
      ZipEntryUtil.setZTFilePermissions(zipEntry, permissions);
    }
    return zipEntry;
  }
804407
@Override
    public Set<String> getPermissionsForRole(RoleIdentifier id) {
        checkNotNull(id, "id");
        return _delegate.getPermissionsForRole(id);
    }
268556
public boolean isPermissionGranted(String permission) {
        List<String> grantedPermissions = getPermissions();
        if (grantedPermissions != null) {
            return grantedPermissions.contains(permission);
        }
        return false;
    }
461737
public static byte[] setMode(byte pinId, Pin.Mode mode) {
        if (mode == Pin.Mode.UNSUPPORTED) {
            throw new IllegalArgumentException("Cannot set unsupported mode to pin " + pinId);
        }
        return new byte[]{SET_PIN_MODE, pinId, (byte) mode.ordinal()};
    }
85688
function generateMode(nodeType, modePermissions) {
  switch(nodeType) {
  case NODE_TYPE_DIRECTORY:
    return (modePermissions || DEFAULT_DIR_PERMISSIONS) | S_IFDIR;
  case NODE_TYPE_SYMBOLIC_LINK:
    return (modePermissions || DEFAULT_FILE_PERMISSIONS) | S_IFLNK;
  case NODE_TYPE_FILE:
    // falls through
  default:
    return (modePermissions || DEFAULT_FILE_PERMISSIONS) | S_IFREG;
  }
}