Skip to content

Commit

Permalink
genericname: Throw InvalidNameException if string is null
Browse files Browse the repository at this point in the history
  • Loading branch information
rp- committed Dec 12, 2019
1 parent 9e66e0d commit c8e3b2a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.linbit.linstor.core.apicallhandler.controller.helpers;

import com.linbit.InvalidNameException;
import com.linbit.linstor.LinStorDataAlreadyExistsException;
import com.linbit.linstor.LinstorParsingUtils;
import com.linbit.linstor.annotation.PeerContext;
Expand Down Expand Up @@ -113,6 +114,12 @@ public StorPool createStorPool(
alreadyExistsExc
);
}
catch (InvalidNameException invlExc)
{
throw new ApiRcException(ApiCallRcImpl.simpleEntry(
ApiConsts.FAIL_INVLD_STOR_POOL_NAME, invlExc.getMessage())
);
}
catch (DatabaseException sqlExc)
{
throw new ApiDatabaseException(sqlExc);
Expand Down
6 changes: 5 additions & 1 deletion server/src/main/java/com/linbit/GenericName.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ public abstract class GenericName implements Comparable<GenericName>
public final String value;
public final String displayValue;

public GenericName(String genName)
public GenericName(String genName) throws InvalidNameException
{
if (genName == null)
{
throw new InvalidNameException("Given name is null", "null");
}
value = genName.toUpperCase();
displayValue = genName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public FreeSpaceMgrName(String freeSpaceMgrNameStr) throws InvalidNameException
Checks.nameCheck(freeSpaceMgrNameStr, MIN_LENGTH, MAX_LENGTH, VALID_CHARS, VALID_INNER_CHARS);
}

public FreeSpaceMgrName(NodeName nodeName, StorPoolName storPoolName)
public FreeSpaceMgrName(NodeName nodeName, StorPoolName storPoolName) throws InvalidNameException
{
super(nodeName.displayValue + RESERVED_CONNECTOR + storPoolName.displayValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ protected ResourceGroup createDefaultResourceGroup(AccessContext initCtx)
}

protected FreeSpaceMgr getFreeSpaceMgr(StorPoolDefinition storPoolDfn, Node node)
throws AccessDeniedException, DatabaseException
throws AccessDeniedException, DatabaseException, InvalidNameException
{
return freeSpaceMgrFactory.getInstance(
SYS_CTX, new FreeSpaceMgrName(node.getName(), storPoolDfn.getName())
Expand Down

0 comments on commit c8e3b2a

Please sign in to comment.