diff options
-rw-r--r-- | sinksh/syntax_modules/sink_remove.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sinksh/syntax_modules/sink_remove.cpp b/sinksh/syntax_modules/sink_remove.cpp index bbc1752..6baa60f 100644 --- a/sinksh/syntax_modules/sink_remove.cpp +++ b/sinksh/syntax_modules/sink_remove.cpp | |||
@@ -55,16 +55,16 @@ bool remove(const QStringList &args, State &state) | |||
55 | } | 55 | } |
56 | 56 | ||
57 | auto type = args[0]; | 57 | auto type = args[0]; |
58 | auto resourceId = args[1]; | 58 | const auto resourceId = SinkshUtils::parseUid(args.at(1).toUtf8()); |
59 | auto identifier = args[2]; | 59 | const auto identifier = SinkshUtils::parseUid(args.at(2).toUtf8()); |
60 | 60 | ||
61 | auto &store = SinkshUtils::getStore(type); | 61 | auto &store = SinkshUtils::getStore(type); |
62 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject(resourceId.toUtf8(), identifier.toUtf8()); | 62 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject(resourceId, identifier); |
63 | 63 | ||
64 | auto result = store.remove(*object).exec(); | 64 | auto result = store.remove(*object).exec(); |
65 | result.waitForFinished(); | 65 | result.waitForFinished(); |
66 | if (result.errorCode()) { | 66 | if (result.errorCode()) { |
67 | state.printError(QObject::tr("An error occurred while removing %1 from %1: %2").arg(identifier).arg(resourceId).arg(result.errorMessage()), | 67 | state.printError(QObject::tr("An error occurred while removing %1 from %1: %2").arg(QString{identifier}).arg(QString{resourceId}).arg(result.errorMessage()), |
68 | "akonaid_remove_e" + QString::number(result.errorCode())); | 68 | "akonaid_remove_e" + QString::number(result.errorCode())); |
69 | } | 69 | } |
70 | 70 | ||
@@ -75,17 +75,18 @@ bool resource(const QStringList &args, State &state) | |||
75 | { | 75 | { |
76 | if (args.isEmpty()) { | 76 | if (args.isEmpty()) { |
77 | state.printError(QObject::tr("A resource can not be removed without an id"), "sink_remove/01"); | 77 | state.printError(QObject::tr("A resource can not be removed without an id"), "sink_remove/01"); |
78 | return false; | ||
78 | } | 79 | } |
79 | 80 | ||
80 | auto &store = SinkshUtils::getStore("resource"); | 81 | auto &store = SinkshUtils::getStore("resource"); |
81 | 82 | ||
82 | auto resourceId = args.at(0); | 83 | const auto resourceId = SinkshUtils::parseUid(args.at(0).toUtf8()); |
83 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject("", resourceId.toLatin1()); | 84 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject("", resourceId); |
84 | 85 | ||
85 | auto result = store.remove(*object).exec(); | 86 | auto result = store.remove(*object).exec(); |
86 | result.waitForFinished(); | 87 | result.waitForFinished(); |
87 | if (result.errorCode()) { | 88 | if (result.errorCode()) { |
88 | state.printError(QObject::tr("An error occurred while removing the resource %1: %2").arg(resourceId).arg(result.errorMessage()), | 89 | state.printError(QObject::tr("An error occurred while removing the resource %1: %2").arg(QString{resourceId}).arg(result.errorMessage()), |
89 | "akonaid_remove_e" + QString::number(result.errorCode())); | 90 | "akonaid_remove_e" + QString::number(result.errorCode())); |
90 | } | 91 | } |
91 | 92 | ||
@@ -96,17 +97,18 @@ bool account(const QStringList &args, State &state) | |||
96 | { | 97 | { |
97 | if (args.isEmpty()) { | 98 | if (args.isEmpty()) { |
98 | state.printError(QObject::tr("An account can not be removed without an id"), "sink_remove/01"); | 99 | state.printError(QObject::tr("An account can not be removed without an id"), "sink_remove/01"); |
100 | return false; | ||
99 | } | 101 | } |
100 | 102 | ||
101 | auto &store = SinkshUtils::getStore("account"); | 103 | auto &store = SinkshUtils::getStore("account"); |
102 | 104 | ||
103 | auto id = args.at(0); | 105 | const auto id = SinkshUtils::parseUid(args.at(0).toUtf8()); |
104 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject("", id.toLatin1()); | 106 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject("", id); |
105 | 107 | ||
106 | auto result = store.remove(*object).exec(); | 108 | auto result = store.remove(*object).exec(); |
107 | result.waitForFinished(); | 109 | result.waitForFinished(); |
108 | if (result.errorCode()) { | 110 | if (result.errorCode()) { |
109 | state.printError(QObject::tr("An error occurred while removing the account %1: %2").arg(id).arg(result.errorMessage()), | 111 | state.printError(QObject::tr("An error occurred while removing the account %1: %2").arg(QString{id}).arg(result.errorMessage()), |
110 | "akonaid_remove_e" + QString::number(result.errorCode())); | 112 | "akonaid_remove_e" + QString::number(result.errorCode())); |
111 | } | 113 | } |
112 | 114 | ||
@@ -117,6 +119,7 @@ bool identity(const QStringList &args, State &state) | |||
117 | { | 119 | { |
118 | if (args.isEmpty()) { | 120 | if (args.isEmpty()) { |
119 | state.printError(QObject::tr("An identity can not be removed without an id"), "sink_remove/01"); | 121 | state.printError(QObject::tr("An identity can not be removed without an id"), "sink_remove/01"); |
122 | return false; | ||
120 | } | 123 | } |
121 | 124 | ||
122 | auto &store = SinkshUtils::getStore("identity"); | 125 | auto &store = SinkshUtils::getStore("identity"); |