/** * Returns the value of the first segment if it is a Id segment; otherwise throws an exception. */ default Long firstToId() { return ItemPath.toId(first()); }
private long checkPathSanity(ItemPath deltaPath, List<Long> casesAddedOrDeleted) { Object secondSegment = deltaPath.getSegment(1); if (!ItemPath.isId(secondSegment)) { throw new IllegalStateException("Couldn't update cert campaign by delta with path " + deltaPath + " - should start with case[id]"); } Long id = ItemPath.toId(secondSegment); if (id == null) { throw new IllegalStateException("Couldn't update cert campaign by delta with path " + deltaPath + " - should start with case[id]"); } if (deltaPath.size() == 2) { // not enough throw new IllegalStateException("Couldn't update cert campaign by delta with path " + deltaPath + " - should start with case[id] and contain additional path"); } if (casesAddedOrDeleted == null || casesAddedOrDeleted.contains(id)) { throw new IllegalArgumentException("Couldn't update certification case that was added/deleted in this operation. Path=" + deltaPath); } return id; }
sb.append("[").append(ItemPath.toId(segment)).append("]");
public static Long getAssignmentIdFromDeltaPath(PrismContainer<AssignmentType> assignmentsOld, ItemPath path) throws SchemaException { assert path.size() > 1; Object idSegment = path.getSegment(1); if (ItemPath.isId(idSegment)) { return ItemPath.toId(idSegment); } // id-less path, e.g. assignment/validFrom -- we try to determine ID from the objectOld. if (assignmentsOld.size() == 0) { return null; } else if (assignmentsOld.size() == 1) { return assignmentsOld.getValues().get(0).getId(); } else { throw new SchemaException("Illegal path " + path + ": cannot determine which assignment to modify"); } }
private void assertNormalizedPath(UniformItemPath normalized, Object... expected) { assertEquals("wrong path length",normalized.size(), expected.length); for(int i=0; i<normalized.size(); i+=2) { ItemPathSegment nameSegment = normalized.getSegment(i); assert ItemPath.isName(nameSegment) : "Expected name segment but it was "+nameSegment.getClass(); QName name = ItemPath.toName(nameSegment); assert name != null : "name is null"; assert name.getNamespaceURI().equals(NS) : "wrong namespace: "+name.getNamespaceURI(); assert name.getLocalPart().equals(expected[i]) : "wrong local name, expected "+expected[i]+", was "+name.getLocalPart(); if (i + 1 < expected.length) { Object idSegment = normalized.getSegment(i+1); assert ItemPath.isId(idSegment) : "Expected is segment but it was "+idSegment.getClass(); Long id = ItemPath.toId(idSegment); assertId(id, (Long)expected[i+1]); } } }
static boolean segmentsEquivalent(Object o1, Object o2) { if (ItemPath.isName(o1)) { return ItemPath.isName(o2) && QNameUtil.match(ItemPath.toName(o1), ItemPath.toName(o2)); } else if (ItemPath.isVariable(o1)) { return ItemPath.isVariable(o2) && QNameUtil.match(ItemPath.toVariableName(o1), ItemPath.toVariableName(o2)); } else if (ItemPath.isSpecial(o1)) { return ItemPath.isSpecial(o2) && QNameUtil.match(ItemPathSegmentUtil.getSpecialSymbol(o1), ItemPathSegmentUtil.getSpecialSymbol(o2)); } else if (ItemPath.isId(o1)) { return ItemPath.isId(o2) && Objects.equals(ItemPath.toId(o1), ItemPath.toId(o2)); } else { return false; } }
Long id = ItemPath.toId(segments.next());
throw new IllegalStateException("Assignment modification contains no assignment ID. Offending path = " + deltaPath); Long id = ItemPath.toId(secondSegment); if (id == null) { throw new IllegalStateException("Assignment modification contains no assignment ID. Offending path = " + deltaPath);
throw new IllegalStateException("Assignment modification contains no assignment ID. Offending path = " + deltaPath); Long id = ItemPath.toId(secondSegment); if (id == null) { throw new IllegalStateException("Assignment modification contains no assignment ID. Offending path = " + deltaPath);
Long rowId = ItemPath.toId(deltaPath.getSegment(1)); QName name = ItemPath.toName(deltaPath.getSegment(2));