Stores a set of snapshot properties in the given space as a properties file.

@param spaceId         the space in which the properties file should be stored
@param serializedProps properties in serialized format
496478
protected void storeSnapshotProps(String spaceId, String serializedProps) {
        InputStream propsStream;
        try {
            propsStream = IOUtil.writeStringToStream(serializedProps);
        } catch (IOException e) {
            throw new TaskException("Unable to build stream from serialized " +
                                    "snapshot properties due to: " +
                                    e.getMessage());
        }
        ChecksumUtil checksumUtil = new ChecksumUtil(ChecksumUtil.Algorithm.MD5);
        String propsChecksum = checksumUtil.generateChecksum(serializedProps);

        snapshotProvider.addContent(spaceId,
                                    Constants.SNAPSHOT_PROPS_FILENAME,
                                    "text/x-java-properties",
                                    null,
                                    // Ensures that length is based on UTF-8 encoded bytes
                                    serializedProps.getBytes(StandardCharsets.UTF_8).length,
                                    propsChecksum,
                                    propsStream);
    }
913380
private void deleteDestSpace(final String spaceId)
        throws TaskExecutionFailedException {
        log.info("Deleting space " + spaceId +
                 " from dest provider in account " + dupTask.getAccount());
        try {
            new Retrier().execute(new Retriable() {
                @Override
                public String retry() throws Exception {
                    // The actual method being executed
                    destStore.deleteSpace(spaceId);
                    return "success";
                }
            });
        } catch (Exception e) {
            String msg = "Error attempting to delete the destination space: " +
                         e.getMessage();
            throw new DuplicationTaskExecutionFailedException(
                buildFailureMessage(msg), e);
        }
        log.info("Successfully deleted space " + spaceId +
                 " from dest provider in account " + dupTask.getAccount());
    }
1264115
public void setNewSpaceProperties(String spaceId,
                                      Map<String, String> spaceProperties) {
        setNewSpaceProperties(spaceId, spaceProperties, getSpaceACLs(spaceId));
    }
825738
private boolean spaceExists(final StorageProvider store,
                                final String spaceId)
        throws TaskExecutionFailedException {
        try {
            return new Retrier().execute(new Retriable() {
                @Override
                public Boolean retry() throws Exception {
                    // The actual method being executed
                    store.getSpaceProperties(spaceId);
                    return true;
                }
            });
        } catch (NotFoundException nfe) {
            return false;
        } catch (Exception e) {
            String msg = "Error attempting to check if space exists: " +
                         e.getMessage();
            throw new DuplicationTaskExecutionFailedException(
                buildFailureMessage(msg), e);
        }
    }
740550
private Response addSpacePropertiesToResponse(ResponseBuilder response,
                                                  String spaceID,
                                                  String storeID)
        throws ResourceException {
        Map<String, String> properties =
            spaceResource.getSpaceProperties(spaceID, storeID);

        return addPropertiesToResponse(response, properties);
    }
887656
private void initRemoteCommands(final RepositoryEntry config)
   {
      this.id = UUID.randomUUID().toString();
      registerNamespace = rpcService.registerCommand(new RemoteCommand()
      {

         public String getId()
         {
            return "org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl-registerNamespace-"
               + config.getName();
         }

         public Serializable execute(Serializable[] args) throws Throwable
         {
            if (!id.equals(args[0]))
            {
               try
               {
                  registerNamespace((String)args[1], (String)args[2], false);
               }
               catch (Exception e)
               {
                  LOG.warn("Could not register the namespace on other cluster nodes", e);
               }
            }
            return true;
         }
      });
      unregisterNamespace = rpcService.registerCommand(new RemoteCommand()
      {

         public String getId()
         {
            return "org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl-unregisterNamespace-"
               + config.getName();
         }

         public Serializable execute(Serializable[] args) throws Throwable
         {
            if (!id.equals(args[0]))
            {
               try
               {
                  unregisterNamespace((String)args[1], false);
               }
               catch (Exception e)
               {
                  LOG.warn("Could not unregister the namespace on other cluster nodes", e);
               }
            }
            return true;
         }
      });
   }
122309
@Path("/{spaceID}")
    @DELETE
    public Response deleteSpace(@PathParam("spaceID") String spaceID,
                                @QueryParam("storeID") String storeID) {
        String msg = "deleting space(" + spaceID + ", " + storeID + ")";

        try {
            log.debug(msg);
            return doDeleteSpace(spaceID, storeID);

        } catch (ResourceNotFoundException e) {
            return responseNotFound(msg, e, NOT_FOUND);

        } catch (ResourceException e) {
            return responseBad(msg, e, INTERNAL_SERVER_ERROR);

        } catch (Exception e) {
            return responseBad(msg, e, INTERNAL_SERVER_ERROR);
        }
    }
426428
function serializeField(prop, value, dimension, spaceDimension) {
    var line;
    var propNRRD = mapJavascriptToNRRD(prop);
    switch(prop) {
    // nrrd-js stuff: skip
    case 'data':
    case 'buffer':
    case 'keys':
    case 'version':
        break;
    // Literal (uninterpreted) fields
    case 'content':
    case 'number':
    case 'sampleUnits':
    case 'space':
        line = propNRRD + ": " + value;
        break;
    // Integers (no infinity or whatever, just a plain integer, so the default serialization is good enough)
    case 'blockSize':
    case 'lineSkip':
    case 'byteSkip':
    case 'dimension':
    case 'spaceDimension':
        assert((typeof value) == "number" || value instanceof Number, "Field " + prop + " should at least contain a number!");
        line = propNRRD + ": " + value;
        break;
    // Floats (default serialization is good enough, as NaN contains nan, ignoring case, and similarly for Infinity inf)
    case 'min':
    case 'max':
    case 'oldMin':
    case 'oldMax':
        assert((typeof value) == "number" || value instanceof Number, "Field " + prop + " should contain a number!");
        line = propNRRD + ": " + value;
        break;
    // Vectors
    case 'spaceOrigin':
        assert(value.length === spaceDimension, "Field " + prop + " should be a list with length equal to the space dimension!");
        value.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "Field " + prop + " should be a list of numbers!"); });
        line = propNRRD + ": (" + value.join(",") + ")";
        break;
    // Lists of strings
    case 'labels':
    case 'units':
    case 'spaceUnits':
        assert(value.length !== undefined && value.length == dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        value.forEach(function (val) { assert((typeof val) == "string" || val instanceof String, "Field " + prop + " should be a list of numbers!"); });
        line = propNRRD + ": " + value.map(serializeNRRDQuotedString).join(" ");
        break;
    // Lists of integers
    case 'sizes':
        assert(value.length !== undefined && value.length == dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        value.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "Field " + prop + " should be a list of numbers!"); });
        line = propNRRD + ": " + value.join(" ");
        break;
    // Lists of floats
    case 'spacings':
    case 'thicknesses':
    case 'axisMins':
    case 'axisMaxs':
        assert(value.length !== undefined && value.length == dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        value.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "Field " + prop + " should be a list of numbers!"); });
        line = propNRRD + ": " + value.join(" ");
        break;
    // Lists of vectors (dimension sized)
    case 'spaceDirections':
        assert(value.length !== undefined && value.length === dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        value.forEach(function (vec) {
          assert(vec === null || (vec.length !== undefined && vec.length === spaceDimension), "The elements of field " + prop + " should be lists with length equal to the space dimension!");
          if (vec !== null) vec.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "The elements of field " + prop + " should be lists of numbers!"); });
        });
        line = propNRRD + ": " + value.map(function(vec) { return vec === null ? "none" : ("(" + vec.join(",") + ")"); }).join(" ");
        break;
    // Lists of vectors (space dimension sized)
    case 'measurementFrame':
        assert(value.length !== undefined && value.length === spaceDimension, "Field " + prop + " should be a list with length equal to the space dimension!");
        value.forEach(function (vec) {
          assert(vec === null || (vec.length !== undefined && vec.length === spaceDimension), "The elements of field " + prop + " should be lists with length equal to the space dimension!");
          if (vec !== null) vec.forEach(function (val) { assert((typeof val) == "number" || val instanceof Number, "The elements of field " + prop + " should be lists of numbers!"); });
        });
        line = propNRRD + ": " + value.map(function(vec) { return vec === null ? "none" : ("(" + vec.join(",") + ")"); }).join(" ");
        break;
    // One-of-a-kind fields
    case 'type':
        assert((typeof value) == "string" || value instanceof String, "Field " + prop + " should contain a string!");
        line = propNRRD + ": " + value;
        break;
    case 'encoding':
        assert((typeof value) == "string" || value instanceof String, "Field " + prop + " should contain a string!");
        line = propNRRD + ": " + value;
        break;
    case 'endian':
        assert((typeof value) == "string" || value instanceof String, "Field " + prop + " should contain a string!");
        line = propNRRD + ": " + value;
        break;
    case 'dataFile':
        if (value.length || (value.files && 'subdim' in value)) {
            // List of data files: skip for now
        } else {
            line = propNRRD + ": " + serializeNRRDDataFile(value);
        }
        break;
    case 'centers':
        assert(value.length !== undefined && value.length == dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        line = propNRRD + ": " + value.map(serializeNRRDOptional).join(" ");
        break;
    case 'kinds':
        assert(value.length !== undefined && value.length == dimension, "Field " + prop + " should be a list with length equal to the dimension!");
        line = propNRRD + ": " + value.map(serializeNRRDOptional).join(" ");
        break;
    // Something unknown
    default:
        console.warn("Unrecognized NRRD field: " + prop + ", skipping.");
    }
    return line;
}
224063
public String getSpaces(String storeID) throws ResourceException {

        Element spacesElem = new Element("spaces");

        try {
            StorageProvider storage =
                storageProviderFactory.getStorageProvider(storeID);

            Iterator<String> spaces = storage.getSpaces();
            while (spaces.hasNext()) {
                String spaceID = spaces.next();
                Element spaceElem = new Element("space");
                spaceElem.setAttribute("id", spaceID);
                spacesElem.addContent(spaceElem);
            }
        } catch (Exception e) {
            storageProviderFactory.expireStorageProvider(storeID);
            throw new ResourceException("Error attempting to build spaces XML",
                                        e);
        }

        Document doc = new Document(spacesElem);
        XMLOutputter xmlConverter = new XMLOutputter();
        return xmlConverter.outputString(doc);
    }
335141
public function savePropertyId($propertyId, $id = false)
    {
        $em = $this->getEntityManager();
        $config = $id ? $this->find($id) : $this->findFirst();
        $config->setPropertyId($propertyId);
        $em->persist($config);
        $em->flush();
    }
959167
public void updateProperties( Collection newProps )
    {
        _properties = new ArrayList();

        if ( newProps != null )
        {
            _properties.addAll( newProps );
        }
    }
778121
public void storeToYAML(final Properties props, final OutputStream os, final String header, final String encoding)
			throws IOException {
		try {
			((PrefixedProperties) props).storeToYAML(os, header, encoding);
		} catch (final ClassCastException err) {
			throw new IOException(
					"Cannot store properties JSON file - not using PrefixedProperties: " + err.getMessage());
		}
	}
124057
public void saveProperties(CmsParameterConfiguration properties, String file, boolean backup) {

        if (new File(m_configRfsPath + file).isFile()) {
            String backupFile = file + CmsConfigurationManager.POSTFIX_ORI;
            String tempFile = file + ".tmp";

            m_errors.clear();

            if (backup) {
                // make a backup copy
                copyFile(file, FOLDER_BACKUP + backupFile);
            }

            //save to temporary file
            copyFile(file, tempFile);

            // save properties
            save(properties, tempFile, file, null);

            // delete temp file
            File temp = new File(m_configRfsPath + tempFile);
            temp.delete();
        } else {
            m_errors.add("No valid file: " + file + "\n");
        }

    }
345141
public void addSpaceMembers(int spaceId, SpaceMemberAdd spaceMemberAdd) {
		getResourceFactory()
				.getApiResource("/space/" + spaceId + "/member/")
				.entity(spaceMemberAdd,	MediaType.APPLICATION_JSON_TYPE)
				.post();
	}
541517
private void saveProperties() {
		assert Thread.holdsLock(properties);
		try {
			// Create a properties instance that sorts the output by keys (case-insensitive)
			Properties writer = new Properties() {
				private static final long serialVersionUID = 6953022173340009928L;
				@Override
				public Enumeration<Object> keys() {
					SortedSet<Object> sortedSet = new TreeSet<>(Collator.getInstance(Locale.ROOT));
					Enumeration<Object> e = super.keys();
					while(e.hasMoreElements()) sortedSet.add(e.nextElement());
					return Collections.enumeration(sortedSet);
				}
			};
			writer.putAll(properties);
			File tmpFile = File.createTempFile("ApplicationResources", null, sourceFile.getParentFile());
			OutputStream out = new BufferedOutputStream(new FileOutputStream(tmpFile));
			try {
				// Write any comments from when file was read
				if(sourceFileComments!=null) {
					for(String line : sourceFileComments) {
						out.write(line.getBytes(propertiesCharset));
						out.write(EOL.getBytes(propertiesCharset));
					}
				}
				// Wrap to skip any comments generated by Properties code
				out = new SkipCommentsFilterOutputStream(out);
				writer.store(out, null);
			} finally {
				out.close();
			}
			FileUtils.renameAllowNonAtomic(tmpFile, sourceFile);
		} catch(IOException err) {
			throw new RuntimeException(err);
		}
	}
630679
@InterfaceAudience.Public
    public void setDocIds(List<String> docIds) {
        properties.put(ReplicationField.DOC_IDS, docIds);
        replicationInternal.setDocIds(docIds);
    }
402746
@Override
    public synchronized void serialize(DataTree dt, Map<Long, Long> sessions, File snapShot)
            throws IOException {
        if (!close) {
            OutputStream sessOS = new BufferedOutputStream(new FileOutputStream(snapShot));
            CheckedOutputStream crcOut = new CheckedOutputStream(sessOS, new Adler32());
            //CheckedOutputStream cout = new CheckedOutputStream()
            OutputArchive oa = BinaryOutputArchive.getArchive(crcOut);
            FileHeader header = new FileHeader(SNAP_MAGIC, VERSION, dbId);
            serialize(dt,sessions,oa, header);
            long val = crcOut.getChecksum().getValue();
            oa.writeLong(val, "val");
            oa.writeString("/", "path");
            sessOS.flush();
            crcOut.close();
            sessOS.close();
        }
    }