本文整理匯總了Java中org.alfresco.service.namespace.QName.getNamespaceURI方法的典型用法代碼示例。如果您正苦於以下問題:Java QName.getNamespaceURI方法的具體用法?Java QName.getNamespaceURI怎麽用?Java QName.getNamespaceURI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.alfresco.service.namespace.QName
的用法示例。
在下文中一共展示了QName.getNamespaceURI方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkAssocQNameRegex
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/**
* Checks that the association name matches the constraints imposed by the model.
*/
protected void checkAssocQNameRegex(
List<IntegrityRecord> eventResults,
ChildAssociationDefinition assocDef,
QName assocQName,
NodeRef sourceNodeRef)
{
// check the association name
QName assocRoleQName = assocDef.getTargetRoleName();
if (assocRoleQName != null)
{
// the assoc defines a role name - check it
RegexQNamePattern rolePattern = new RegexQNamePattern(assocRoleQName.getNamespaceURI(), assocRoleQName.getLocalName());
if (!rolePattern.isMatch(assocQName))
{
IntegrityRecord result = new IntegrityRecord(
"The association name does not match the allowed role names: \n" +
" Source Node: " + sourceNodeRef + "\n" +
" Association: " + assocDef + "\n" +
" Allowed roles: " + rolePattern + "\n" +
" Name assigned: " + assocRoleQName);
eventResults.add(result);
}
}
}
示例2: findByValue
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
@Override
public Pair<Long, QName> findByValue(QName qname)
{
String uri = qname.getNamespaceURI();
String localName = qname.getLocalName();
Pair<Long, String> namespaceEntity = getNamespace(uri);
if (namespaceEntity == null)
{
// There is no match on NS, so there is no QName like this
return null;
}
Long nsId = namespaceEntity.getFirst();
QNameEntity entity = findQNameEntityByNamespaceAndLocalName(nsId, localName);
if (entity == null)
{
return null;
}
else
{
return new Pair<Long, QName>(entity.getId(), qname);
}
}
示例3: updateValue
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
@Override
public int updateValue(Long id, QName qname)
{
String uri = qname.getNamespaceURI();
String localName = qname.getLocalName();
QNameEntity entity = findQNameEntityById(id);
if (entity == null)
{
// No chance of updating
return 0;
}
// Create namespace
Pair<Long, String> namespaceEntity = getOrCreateNamespace(uri);
Long nsId = namespaceEntity.getFirst();
// Create QName
return updateQNameEntity(entity, nsId, localName);
}
示例4: getXPathName
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
public static String getXPathName(QName qName, NamespacePrefixResolver nspr)
{
Collection<String> prefixes = nspr.getPrefixes(qName.getNamespaceURI());
if (prefixes.size() == 0)
{
throw new NamespaceException("A namespace prefix is not registered for uri " + qName.getNamespaceURI());
}
String prefix = prefixes.iterator().next();
if (prefix.equals(NamespaceService.DEFAULT_PREFIX))
{
return ISO9075.encode(qName.getLocalName());
}
else
{
return prefix + ":" + ISO9075.encode(qName.getLocalName());
}
}
示例5: getElementNamespaceUri
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
public String getElementNamespaceUri(Object o)
{
QName qName = ((ChildAssociationRef) o).getQName();
if(qName == null)
{
return "";
}
return (qName.getNamespaceURI());
}
示例6: getName
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
private QName getName(QName name, String tenantDomain)
{
if (name == null)
{
return null;
}
String namespace = name.getNamespaceURI();
int idx1 = namespace.indexOf(SEPARATOR);
if (idx1 == -1)
{
// no domain, so add it as a prefix (between two domain separators)
namespace = SEPARATOR + tenantDomain + SEPARATOR + namespace;
name = QName.createQName(namespace, name.getLocalName());
}
else
{
int idx2 = namespace.indexOf(SEPARATOR, 1);
String nameDomain = namespace.substring(1, idx2);
if (!tenantDomain.equalsIgnoreCase(nameDomain))
{
throw new AlfrescoRuntimeException("domain mismatch: expected = " + tenantDomain + ", actual = " + nameDomain);
}
}
return name;
}
示例7: createValue
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
public Pair<Long, QName> createValue(QName qname)
{
String uri = qname.getNamespaceURI();
String localName = qname.getLocalName();
// Create namespace
Pair<Long, String> namespaceEntity = getOrCreateNamespace(uri);
Long nsId = namespaceEntity.getFirst();
// Create QName
QNameEntity entity = createQNameEntity(nsId, localName);
return new Pair<Long, QName>(entity.getId(), qname);
}
示例8: splitLockQName
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/**
* Split a lock's qualified name into the component parts using the '.' (period) as a
* separator on the localname. The namespace is preserved. The provided qualified
* name will always be the last component in the returned list.
*
* @param lockQName the lock name to split into it's higher-level paths
* @return Returns the namespace ID along with the ordered localnames
*/
protected List<QName> splitLockQName(QName lockQName)
{
String ns = lockQName.getNamespaceURI();
String name = lockQName.getLocalName();
StringTokenizer tokenizer = new StringTokenizer(name, ".");
List<QName> ret = new ArrayList<QName>(tokenizer.countTokens());
StringBuilder sb = new StringBuilder();
// Fill it
boolean first = true;
while (tokenizer.hasMoreTokens())
{
if (first)
{
first = false;
}
else
{
sb.append(".");
}
sb.append(tokenizer.nextToken());
QName parentLockQName = QName.createQName(ns, sb.toString());
ret.add(parentLockQName);
}
// Done
return ret;
}
示例9: setQNameAll
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/**
* Set all required fields associated with the patch <code>QName</code>.
*
* @param forUpdate <tt>true</tt> if the entity is going to be used for a
* data update i.e. the <code>QName</code> <b>must</b> exist.
* @return Returns <tt>true</tt> if the <code>QName</code> namespace
* exists.
*/
public boolean setQNameAll(QNameDAO qnameDAO, QName qname, boolean forUpdate)
{
String assocQNameNamespace = qname.getNamespaceURI();
String assocQNameLocalName = qname.getLocalName();
Long assocQNameNamespaceId = null;
if (forUpdate)
{
assocQNameNamespaceId = qnameDAO.getOrCreateNamespace(assocQNameNamespace).getFirst();
}
else
{
Pair<Long, String> nsPair = qnameDAO.getNamespace(assocQNameNamespace);
if (nsPair == null)
{
// We can't set anything
return false;
}
else
{
assocQNameNamespaceId = nsPair.getFirst();
}
}
Long assocQNameCrc = getQNameCrc(qname);
this.qnameNamespaceId = assocQNameNamespaceId;
this.qnameLocalName = assocQNameLocalName;
this.qnameCrc = assocQNameCrc;
// All set correctly
return true;
}
示例10: resolveToUriAndPrefix
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/**
* Gets the namespace URI and prefix from the parent's name, provided that the
* given name is of a valid format. The valid format consist of a
* <i>namespace prefix</i>, a <i>colon</i> and a <i>name</i>. <b>E.g. sys:localized</b>
*
* @param parentName the parent name
* @return a pair of namespace URI and prefix object
*/
protected Pair<String, String> resolveToUriAndPrefix(String parentName)
{
QName qName = prefixedStringToQname(parentName);
Collection<String> prefixes = namespaceService.getPrefixes(qName.getNamespaceURI());
if (prefixes.size() == 0)
{
throw new InvalidArgumentException("cmm.rest_api.prefix_not_registered", new Object[] { qName.getNamespaceURI() });
}
String prefix = prefixes.iterator().next();
return new Pair<String, String>(qName.getNamespaceURI(), prefix);
}
示例11: applyProperties
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
@Override
public Map<QName, Serializable> applyProperties(Map<QName, Serializable> extractedProperties, Map<QName, Serializable> targetProperties)
{
/*
* Negative and positive checks are mixed in the loop.
*/
Map<QName, Serializable> modifiedProperties = new HashMap<QName, Serializable>(7);
for (Map.Entry<QName, Serializable> entry : extractedProperties.entrySet())
{
QName propertyQName = entry.getKey();
Serializable extractedValue = entry.getValue();
// Ignore null extracted value
if (extractedValue == null)
{
modifiedProperties.put(propertyQName, extractedValue);
continue;
}
// If the property is media related, always extract
String propertyNS = propertyQName.getNamespaceURI();
if(propertyNS.equals(NamespaceService.EXIF_MODEL_1_0_URI) ||
propertyNS.equals(NamespaceService.AUDIO_MODEL_1_0_URI))
{
targetProperties.put(propertyQName, extractedValue);
modifiedProperties.put(propertyQName, extractedValue);
continue;
}
// Handle the shortcut cases where the target value is missing or null
if (!targetProperties.containsKey(propertyQName))
{
// There is nothing currently
targetProperties.put(propertyQName, extractedValue);
modifiedProperties.put(propertyQName, extractedValue);
continue;
}
// Look at the old value, and decide based on that
Serializable originalValue = targetProperties.get(propertyQName);
if (originalValue == null)
{
// The previous value is null, extract
targetProperties.put(propertyQName, extractedValue);
modifiedProperties.put(propertyQName, extractedValue);
continue;
}
// Check the string representation
if (originalValue instanceof String)
{
String originalValueStr = (String) originalValue;
if (originalValueStr != null && originalValueStr.length() > 0)
{
// The original value is non-trivial
continue;
}
else
{
// The original string is trivial
targetProperties.put(propertyQName, extractedValue);
modifiedProperties.put(propertyQName, extractedValue);
continue;
}
}
// We have some other object as the original value, so keep it
}
return modifiedProperties;
}
示例12: updateLocks
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/**
* Put new values against the given exclusive lock. This works against the related locks as well.
* @param optimistic <tt>true</tt> if a mismatch in the number of locked rows should
* be ignored.
* @return <tt>true</tt> if the lock was successfully and fully updated
* using the lock token provided
* @throws LockAcquisitionException if the method is pessimistic and the number of rows does not
* correspond to the number expected
*/
private boolean updateLocks(
QName lockQName,
String lockToken,
String newLockToken,
long timeToLive,
boolean optimistic)
{
String qnameNamespaceUri = lockQName.getNamespaceURI();
String qnameLocalName = lockQName.getLocalName();
// Force lower case for case insensitivity
if (!qnameLocalName.toLowerCase().equals(qnameLocalName))
{
lockQName = QName.createQName(qnameNamespaceUri, qnameLocalName.toLowerCase());
qnameLocalName = lockQName.getLocalName();
}
// Force the lock token to lowercase
lockToken = lockToken.toLowerCase();
// Resolve the namespace
Long qnameNamespaceId = qnameDAO.getOrCreateNamespace(qnameNamespaceUri).getFirst();
// Get the lock resource for the exclusive lock.
// All the locks that are created will need the exclusive case.
LockResourceEntity exclusiveLockResource = getLockResource(qnameNamespaceId, qnameLocalName);
if (exclusiveLockResource == null)
{
// If the exclusive lock doesn't exist, the locks don't exist
throw new LockAcquisitionException(
LockAcquisitionException.ERR_LOCK_RESOURCE_MISSING,
lockQName, lockToken);
}
Long exclusiveLockResourceId = exclusiveLockResource.getId();
// Split the lock name
List<QName> lockQNames = splitLockQName(lockQName);
// We just need to know how many resources needed updating.
// They will all share the same exclusive lock resource
int requiredUpdateCount = lockQNames.size();
// Update
int updateCount = updateLocks(exclusiveLockResourceId, lockToken, newLockToken, timeToLive);
// Check
if (updateCount != requiredUpdateCount)
{
if (optimistic)
{
// We don't mind. Assume success but report that the lock was not removed by us.
return false;
}
// Fall through to error states (pessimistic)
if (LOCK_TOKEN_RELEASED.equals(newLockToken))
{
throw new LockAcquisitionException(
LockAcquisitionException.ERR_FAILED_TO_RELEASE_LOCK,
lockQName, lockToken);
}
else
{
throw new LockAcquisitionException(
LockAcquisitionException.ERR_LOCK_UPDATE_COUNT,
lockQName, lockToken, new Integer(updateCount), new Integer(requiredUpdateCount));
}
}
else
{
// All updated successfully
return true;
}
// Done
}
示例13: getNamespaceURIfromQname
import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/**
* @param qname QName
* @return the namespaceuri from a qname
*/
public String getNamespaceURIfromQname(QName qname)
{
return qname.getNamespaceURI();
}