/** * * @param string * The name of a {@link Property} of $this {@link Node} * @param mixed * The value to be assigned * @param int|null * The type of the {@link Property} (Optional: NULL if not * specified). * @return object * A {@link Property} object * @throws {@link ValueFormatException} * If <i>$value</i> cannot be converted to the specified type or * if the property already exists and is multi-valued. * @throws {@link VersionException} * If this node is versionable and checked-in or is non-versionable but * its nearest versionable ancestor is checked-in and this implementation * performs this validation immediately instead of waiting until * {@link save()}. * @throws {@link LockException} * If a lock prevents the setting of the property and this implementation * performs this validation immediately instead of waiting until * {@link save()}. * @throws {@link ConstraintViolationException} * If the change would violate a node-type or other constraint and this * implementation performs this validation immediately instead of * waiting until {@link save()}. * @throws {@link RepositoryException} * If another error occurs. * @see PHPCR_Node::setProperty() */ public function setProperty($name, $value, $type = 1) { $isNew = true; if ($this->hasProperty($name)) { $isNew = false; } $filename = null; switch ($type) { case PHPCR_PropertyType::BINARY: $pr = new Java("javax.jcr.PropertyType"); $type = $pr->BINARY; $strlen = strlen($value); // keep it in memory, if small if ($strlen < 500) { $out = new Java("java.io.ByteArrayOutputStream"); $arr = array(); for ($i = 0; $i < $strlen; $i++) { $val = ord(substr($value, $i, 1)); if ($val >= 128) { $val = $val - 256; } $arr[] = $val; } $out->write($arr); $value = new Java("java.io.ByteArrayInputStream", $out->toByteArray()); } else { $filename = tempnam(sys_get_temp_dir(), "jrcr"); chmod($filename, 0666); file_put_contents($filename, $value); $value = new Java("java.io.FileInputStream", $filename); } break; case PHPCR_PropertyType::DATE: $pr = new Java("javax.jcr.PropertyType"); $type = $pr->DATE; //$ValueFactory = new Java("javax.jcr.ValueFactory"); $cal = new Java("java.util.Calendar"); $val = $cal->getInstance(); if ($value instanceof DateTime) { $val->setTimeInMillis($value->format('U') * 1000); } else { $val->setTimeInMillis($value * 1000); } $value = $val; break; } if (!is_object($value) && $type) { $jrprop = $this->JRnode->setProperty($name, $value, $type); } elseif ($value instanceof jr_cr_node) { $jrprop = $this->JRnode->setProperty($name, $value->JRnode); } else { $jrprop = $this->JRnode->setProperty($name, $value); } if (null === $jrprop) { throw new PHPCR_RepositoryException("Couldn't create new property"); } if ($filename) { unlink($filename); } $property = new jr_cr_property($this, $jrprop); $this->addPropertyToList($property); if ($isNew) { $property->setNew(true); } $property->setModified(true); $this->setModified(true); if ($this->session->cache) { $this->session->cache->clean(Zend_Cache::CLEANING_MODE_ALL); } }
function setConfiguration() { $mana = new Java("com.inet.report.config.ConfigurationManager"); $manager = $mana->getInstance(); $conf = $manager->getCurrent(); $name = "Default"; $scope_name = "System"; $scope = $conf->SCOPE_SYSTEM; if ($scope_name == "USER") { $scope = $conf->SCOPE_USER; } if ($conf->getScope() != $scope || $conf->getName() != $name) { $conf = $manager->get($scope, $name); $manager->setCurrent($conf); } }