Webdav Move method implementation.

@param session current session.
@param srcPath source resource path
@param destPath destination resource path
@return the instance of javax.ws.rs.core.Response
10179
public Response move(Session session, String srcPath, String destPath)
   {
      try
      {
         session.move(srcPath, destPath);
         session.save();

         // If the source resource was successfully moved
         // to a pre-existing destination resource.
         if (itemExisted)
         {
            return Response.status(HTTPStatus.NO_CONTENT).cacheControl(cacheControl).build();
         }
         // If the source resource was successfully moved,
         // and a new resource was created at the destination.
         else
         {
            if (uriBuilder != null)
            {
               return Response.created(uriBuilder.path(session.getWorkspace().getName()).path(destPath).build())
                  .cacheControl(cacheControl).build();
            }

            // to save compatibility if uriBuilder is not provided
            return Response.status(HTTPStatus.CREATED).cacheControl(cacheControl).build();
         }

      }
      catch (LockException exc)
      {
         return Response.status(HTTPStatus.LOCKED).entity(exc.getMessage()).build();

      }
      catch (PathNotFoundException exc)
      {
         return Response.status(HTTPStatus.CONFLICT).entity(exc.getMessage()).build();

      }
      catch (RepositoryException exc)
      {
         log.error(exc.getMessage(), exc);
         return Response.serverError().entity(exc.getMessage()).build();
      }

   }
569417
public void actionCopyToProject() throws JspException {

        // save initialized instance of this class in request attribute for included sub-elements
        getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
        try {
            // copy the resource to the current project
            getCms().copyResourceToProject(getParamResource());
            // close the dialog
            actionCloseDialog();
        } catch (Throwable e) {
            // error copying resource to project, include error page
            includeErrorpage(this, e);
        }
    }
305382
@Override
    public T move(String source, String target) throws IllegalArgumentException, IllegalArchivePathException {
        Validate.notNullOrEmpty(source, "The source path was not specified");
        Validate.notNullOrEmpty(target, "The target path was not specified");

        final ArchivePath sourcePath = new BasicPath(source);
        final ArchivePath targetPath = new BasicPath(target);

        return move(sourcePath, targetPath);
    }
1332540
protected CmsObjectWrapper getCms(SrvSession session, TreeConnection connection) throws CmsException {

        CmsJlanRepository repository = ((CmsJlanDeviceContext)connection.getContext()).getRepository();
        CmsObjectWrapper result = repository.getCms(session, connection);
        return result;
    }
1105452
public static Optional<JMProgressiveManager<Path, Path>>
    copyDirRecursivelyAsync(Path targetDirPath, Path destinationDirPath,
            CopyOption... options) {
        Map<Boolean, List<Path>> directoryOrFilePathMap = JMLambda.groupBy(
                JMPath.getSubPathList(targetDirPath), JMPath::isDirectory);
        JMOptional.getOptional(directoryOrFilePathMap, true)
                .ifPresent(list -> list.stream()
                        .map(dirPath -> JMPath.buildRelativeDestinationPath(
                                destinationDirPath, targetDirPath, dirPath))
                        .forEach(JMPathOperation::createDirectories));
        return operateDir(targetDirPath, destinationDirPath,
                directoryOrFilePathMap.get(false),
                bulkPathList -> new JMProgressiveManager<>(bulkPathList,
                        path -> Optional.ofNullable(copy(path,
                                JMPath.buildRelativeDestinationPath(
                                        destinationDirPath, targetDirPath,
                                        path),
                                options))));
    }
1265420
def project_move(object_id, input_params={}, always_retry=False, **kwargs):
    
    return DXHTTPRequest('/%s/move' % object_id, input_params, always_retry=always_retry, **kwargs)
1236953
protected void publishSchemaImports(URL parentURL, Element element, List<String> published, String expLocation) throws Exception
   {
      Element childElement = getFirstChildElement(element);
      while (childElement != null) {
         //first check on namespace only to avoid doing anything on any other wsdl/schema elements
         final String ns = childElement.getNamespaceURI();
         if (Constants.NS_SCHEMA_XSD.equals(ns)) {
            final String ln = childElement.getLocalName();
            if ("import".equals(ln) || "include".equals(ln)) {
               String schemaLocation = childElement.getAttribute("schemaLocation");
               if (schemaLocation.length() > 0 && schemaLocation.startsWith("http://") == false  && schemaLocation.startsWith("https://") == false)
               {
                  // infinity loops prevention
                  if (!published.contains(schemaLocation))
                  {
                     published.add(schemaLocation);
                     String baseURI = parentURL.toExternalForm();
                     URL xsdURL = new URL(baseURI.substring(0, baseURI.lastIndexOf("/") + 1) + schemaLocation);
                     File targetFile = new File(xsdURL.getFile()); //JBWS-3488
                     createParentDir(targetFile);

                     String deploymentName = dep.getCanonicalName();

                     // get the resource path including the separator
                     int index = baseURI.indexOf(deploymentName) + 1;
                     String resourcePath = baseURI.substring(index + deploymentName.length());
                     //check for sub-directories
                     resourcePath = resourcePath.substring(0, resourcePath.lastIndexOf("/") + 1);

                     resourcePath = expLocation + resourcePath + schemaLocation;
                     while (resourcePath.indexOf("//") != -1)
                     {
                        resourcePath = resourcePath.replace("//", "/");
                     }
                     URL resourceURL = dep.getResourceResolver().resolve(resourcePath);
                     InputStream is = new ResourceURL(resourceURL).openStream();
                     if (is == null)
                        throw MESSAGES.cannotFindSchemaImportInDeployment(resourcePath, deploymentName);

                     FileOutputStream fos = null;
                     try
                     {
                        fos = new FileOutputStream(targetFile);
                        IOUtils.copyStream(fos, is);
                     }
                     finally
                     {
                        if (fos != null) fos.close();
                     }

                     DEPLOYMENT_LOGGER.xmlSchemaImportPublishedTo(xsdURL);

                     // recursively publish imports
                     Element subdoc = DOMUtils.parse(xsdURL.openStream(), getDocumentBuilder());
                     publishSchemaImports(xsdURL, subdoc, published, expLocation);
                  }
               }
            } else if ("schema".equals(ln)) {
               //recurse, as xsd:schema might contain an import
               publishSchemaImports(parentURL, childElement, published, expLocation);
            }
         } else if (Constants.NS_WSDL11.equals(ns) && "types".equals(childElement.getLocalName())) {
            //recurse as wsdl:types might contain a schema
            publishSchemaImports(parentURL, childElement, published, expLocation);
         }
         childElement = getNextSiblingElement(childElement);
      }
   }
476690
def move(self, src, dst):
        
        url = '/'.join([src.drive,
                        'api/move',
                        str(src.relative_to(src.drive)).rstrip('/')])

        params = {'to': str(dst.relative_to(dst.drive)).rstrip('/')}

        text, code = self.rest_post(url,
                                    params=params,
                                    auth=src.auth,
                                    verify=src.verify,
                                    cert=src.cert)

        if code not in [200, 201]:
            raise RuntimeError("%s" % text)
915413
def move(from_path, to_path)
      resp = request('/files/move', from_path: from_path, to_path: to_path)
      parse_tagged_response(resp)
    end
43449
public OvhDestinations ip_move_GET(String ip) throws IOException {
		String qPath = "/ip/{ip}/move";
		StringBuilder sb = path(qPath, ip);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhDestinations.class);
	}
1162028
protected void sendReport( final WebdavRequest req, final WebdavResponse resp, final Hashtable<String, WebdavStatus> errorList )
        throws IOException
    {

        resp.setStatus( WebdavStatus.SC_MULTI_STATUS );

        final String absoluteUri = req.getRequestURI();
        // String relativePath = getRelativePath(req);

        final HashMap<String, String> namespaces = new HashMap<String, String>();
        namespaces.put( "DAV:", "D" );

        final XMLWriter generatedXML = new XMLWriter( namespaces );
        generatedXML.writeXMLHeader();

        generatedXML.writeElement( "DAV::multistatus", XMLWriter.OPENING );

        final Enumeration<String> pathList = errorList.keys();
        while ( pathList.hasMoreElements() )
        {

            final String errorPath = pathList.nextElement();
            final int errorCode = errorList.get( errorPath )
                                           .code();

            generatedXML.writeElement( "DAV::response", XMLWriter.OPENING );

            generatedXML.writeElement( "DAV::href", XMLWriter.OPENING );
            String toAppend = null;
            if ( absoluteUri.endsWith( errorPath ) )
            {
                toAppend = absoluteUri;

            }
            else if ( absoluteUri.contains( errorPath ) )
            {

                final int endIndex = absoluteUri.indexOf( errorPath ) + errorPath.length();
                toAppend = absoluteUri.substring( 0, endIndex );
            }
            if ( !toAppend.startsWith( "/" ) && !toAppend.startsWith( "http:" ) )
            {
                toAppend = "/" + toAppend;
            }
            generatedXML.writeText( errorPath );
            generatedXML.writeElement( "DAV::href", XMLWriter.CLOSING );
            generatedXML.writeElement( "DAV::status", XMLWriter.OPENING );
            generatedXML.writeText( "HTTP/1.1 " + errorCode + " " + WebdavStatus.getStatusText( errorCode ) );
            generatedXML.writeElement( "DAV::status", XMLWriter.CLOSING );

            generatedXML.writeElement( "DAV::response", XMLWriter.CLOSING );

        }

        generatedXML.writeElement( "DAV::multistatus", XMLWriter.CLOSING );

        final Writer writer = resp.getWriter();
        writer.write( generatedXML.toString() );
        writer.close();

    }
387569
public static File copy(String srcPath, String destPath, boolean isOverride) throws IORuntimeException {
		return copy(file(srcPath), file(destPath), isOverride);
	}
508589
public static void move(File src, File dest, boolean isOverride) throws IORuntimeException {
		// check
		if (false == src.exists()) {
			throw new IORuntimeException("File not found: " + src);
		}

		// 来源为文件夹，目标为文件
		if (src.isDirectory() && dest.isFile()) {
			throw new IORuntimeException(StrUtil.format("Can not move directory [{}] to file [{}]", src, dest));
		}

		if (isOverride && dest.isFile()) {// 只有目标为文件的情况下覆盖之
			dest.delete();
		}

		// 来源为文件，目标为文件夹
		if (src.isFile() && dest.isDirectory()) {
			dest = new File(dest, src.getName());
		}

		if (false == src.renameTo(dest)) {
			// 在文件系统不同的情况下，renameTo会失败，此时使用copy，然后删除原文件
			try {
				copy(src, dest, isOverride);
			} catch (Exception e) {
				throw new IORuntimeException(StrUtil.format("Move [{}] to [{}] failed!", src, dest), e);
			}
			// 复制后删除源
			del(src);
		}
	}
1154
public void actionChangeSecureExport() throws JspException {

        // save initialized instance of this class in request attribute for included sub-elements
        getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);

        String filename = getParamResource();

        try {
            // lock resource if auto lock is enabled
            checkLock(getParamResource());

            // write the properties
            writeProperty(CmsPropertyDefinition.PROPERTY_EXPORT, getParamExport());
            writeProperty(CmsPropertyDefinition.PROPERTY_EXPORTNAME, getParamExportname());
            writeProperty(CmsPropertyDefinition.PROPERTY_SECURE, getParamSecure());

            // change the flag of the resource so that it is internal
            CmsResource resource = getCms().readResource(filename, CmsResourceFilter.IGNORE_EXPIRATION);
            if (resource.isInternal() && !Boolean.valueOf(getParamIntern()).booleanValue()) {
                getCms().chflags(filename, resource.getFlags() & (~CmsResource.FLAG_INTERNAL));
            } else if (!resource.isInternal() && Boolean.valueOf(getParamIntern()).booleanValue()) {
                getCms().chflags(filename, resource.getFlags() | CmsResource.FLAG_INTERNAL);
            }

            actionCloseDialog();
        } catch (Throwable e) {
            // error during change of secure settings, show error dialog
            includeErrorpage(this, e);
        }

    }
1118313
@Override
    public void copyObject(final FedoraSession session, final String source, final String destination) {
        final Session jcrSession = getJcrSession(session);
        try {
            jcrSession.getWorkspace().copy(source, destination);
            touchLdpMembershipResource(getJcrNode(find(session, destination)));
        } catch (final RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
    }
628251
protected void moveResource(CmsDbContext dbc, CmsResource source, String destination) throws CmsException {

        List<CmsResource> resources = null;

        if (source.isFolder()) {
            if (!CmsResource.isFolder(destination)) {
                // ensure folder name end's with a /
                destination = destination.concat("/");
            }
            // collect all resources in the folder without checking permissions
            resources = m_driverManager.readChildResources(dbc, source, CmsResourceFilter.ALL, true, true, false);
        }

        // target permissions will be checked later
        m_driverManager.moveResource(dbc, source, destination, false);

        // make sure lock is set
        CmsResource destinationResource = m_driverManager.readResource(dbc, destination, CmsResourceFilter.ALL);
        try {
            // the destination must always get a new lock
            m_driverManager.lockResource(dbc, destinationResource, CmsLockType.EXCLUSIVE);
        } catch (Exception e) {
            // could happen with with shared locks on single files
            if (LOG.isWarnEnabled()) {
                LOG.warn(e);
            }
        }

        if (resources != null) {
            // now walk through all sub-resources in the folder
            for (int i = 0; i < resources.size(); i++) {
                CmsResource childResource = resources.get(i);
                String childDestination = destination.concat(childResource.getName());
                // recurse with child resource
                moveResource(dbc, childResource, childDestination);
            }
        }
        CmsProject currentProject = dbc.getRequestContext().getCurrentProject();
        if (!currentProject.isOnlineProject()) {
            List<CmsResource> movedResources = m_driverManager.readChildResources(
                dbc,
                destinationResource,
                CmsResourceFilter.ALL,
                true,
                true,
                false);
            movedResources.add(destinationResource);
            for (CmsResource res : movedResources) {
                m_driverManager.repairCategories(dbc, dbc.getRequestContext().getCurrentProject().getUuid(), res);
            }
        }
    }
260809
public void moveFromLocalFile(Path[] srcs, Path dst)
    throws IOException {
    copyFromLocalFile(true, true, false, srcs, dst);
  }