Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Mar 30, 2016
2 parents 221a50c + 841933b commit 6a04d69
Show file tree
Hide file tree
Showing 17 changed files with 721 additions and 13 deletions.
Expand Up @@ -21,8 +21,10 @@
<label class="control-label" style="vertical-align: top;">
<i class="fa fa-lg" wicket:id="advancedCheck"/>
</label>
<textarea class="form-control input-sm" rows="1" wicket:id="advancedArea"
style="height: 30px; overflow: hidden;"></textarea>
<textarea class="form-control input-sm" rows="2" wicket:id="advancedArea"
style="width: 220px; height: 60px; overflow: hidden;"
wicket:message="placeholder:SearchPanel.insertFilterXml"></textarea>
<span class="help-block" wicket:id="advancedError"/>
</div>

<wicket:container wicket:id="items">
Expand Down
Expand Up @@ -80,6 +80,7 @@ public class SearchPanel extends BasePanel<Search> {
private static final String ID_MORE_GROUP = "moreGroup";
private static final String ID_ADVANCED_AREA = "advancedArea";
private static final String ID_ADVANCED_CHECK = "advancedCheck";
private static final String ID_ADVANCED_ERROR= "advancedError";

private LoadableModel<MoreDialogDto> moreDialogModel;

Expand Down Expand Up @@ -186,8 +187,6 @@ public void onClick(AjaxRequestTarget target) {

Label advancedCheck = new Label(ID_ADVANCED_CHECK);
advancedCheck.add(AttributeAppender.append("class", createAdvancedGroupLabelStyle()));
advancedCheck.add(AttributeModifier.append("title",
new PropertyModel<String>(getModel(), Search.F_ADVANCED_ERROR)));
advancedGroup.add(advancedCheck);

final TextArea advancedArea = new TextArea(ID_ADVANCED_AREA,
Expand All @@ -208,6 +207,23 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
}
});
advancedGroup.add(advancedArea);

Label advancedError = new Label(ID_ADVANCED_ERROR,
new PropertyModel<String>(getModel(), Search.F_ADVANCED_ERROR));
advancedError.add(new VisibleEnableBehaviour() {

@Override
public boolean isVisible() {
Search search = getModelObject();

if (!search.isShowAdvanced()) {
return false;
}

return StringUtils.isNotEmpty(search.getAdvancedError());
}
});
advancedGroup.add(advancedError);
}

private IModel<String> createAdvancedGroupLabelStyle() {
Expand All @@ -216,9 +232,8 @@ private IModel<String> createAdvancedGroupLabelStyle() {
@Override
public String getObject() {
Search search = getModelObject();
PrismContext ctx = getPageBase().getPrismContext();

return search.isAdvancedQueryValid(ctx) ? "fa-check-circle-o" : "fa-exclamation-triangle";
return StringUtils.isEmpty(search.getAdvancedError()) ? "fa-check-circle-o" : "fa-exclamation-triangle";
}
};
}
Expand All @@ -229,9 +244,8 @@ private IModel<String> createAdvancedGroupStyle() {
@Override
public String getObject() {
Search search = getModelObject();
PrismContext ctx = getPageBase().getPrismContext();

return search.isAdvancedQueryValid(ctx) ? "has-success" : "has-error";
return StringUtils.isEmpty(search.getAdvancedError()) ? "has-success" : "has-error";
}
};
}
Expand Down Expand Up @@ -416,6 +430,11 @@ private void advancedPerformed(AjaxRequestTarget target) {
}

private void updateAdvancedArea(Component area, AjaxRequestTarget target) {
Search search = getModelObject();
PrismContext ctx = getPageBase().getPrismContext();

search.isAdvancedQueryValid(ctx);

target.prependJavaScript("storeTextAreaSize('" + area.getMarkupId() + "');");
target.appendJavaScript("restoreTextAreaSize('" + area.getMarkupId() + "');");

Expand Down
Expand Up @@ -23,6 +23,7 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.web.component.data.BaseSortableDataProvider;
import com.evolveum.midpoint.web.component.dialog.ConfirmationPanel;
import com.evolveum.midpoint.web.component.search.Search;
import com.evolveum.midpoint.web.component.search.SearchFactory;
Expand Down Expand Up @@ -241,14 +242,19 @@ public void yesPerformed(AjaxRequestTarget target) {

DebugSearchDto dto = searchModel.getObject();
Class type = dto.getType().getClassDefinition();
addOrReplaceTable(new RepositoryObjectDataProvider(this, type) {
RepositoryObjectDataProvider provider = new RepositoryObjectDataProvider(this, type) {

@Override
protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
ConfigurationStorage storage = getSessionStorage().getConfiguration();
storage.setDebugSearchPaging(paging);
}
});
};
DebugSearchDto search = searchModel.getObject();
ObjectQuery query = search.getSearch().createObjectQuery(getPrismContext());
provider.setQuery(query);

addOrReplaceTable(provider);

PageDebugDownloadBehaviour ajaxDownloadBehavior = new PageDebugDownloadBehaviour();
main.add(ajaxDownloadBehavior);
Expand Down
Expand Up @@ -247,6 +247,10 @@ protected void handleNotSuccessOrHandledErrorInIterator(OperationResult result)
}
};

Search search = searchModel.getObject();
ObjectQuery query = search.createObjectQuery(getPrismContext());
provider.setQuery(query);

return provider;
}

Expand Down
Expand Up @@ -128,6 +128,9 @@ protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
storage.setRolesPaging(paging);
}
};
Search search = searchModel.getObject();
ObjectQuery query = search.createObjectQuery(getPrismContext());
provider.setQuery(query);

List<IColumn<RoleType, String>> columns = initColumns();

Expand Down
Expand Up @@ -328,7 +328,10 @@ public UserListItemDto createDataObjectWrapper(PrismObject<UserType> obj) {
return createRowDto(obj);
}
};
provider.setQuery(null);

Search search = searchModel.getObject();
ObjectQuery query = search.createObjectQuery(getPrismContext());
provider.setQuery(query);

Collection<SelectorOptions<GetOperationOptions>> options = new ArrayList<>();
options.add(SelectorOptions.create(UserType.F_LINK_REF,
Expand Down
Expand Up @@ -3047,4 +3047,5 @@ SearchPanel.basic=Basic
ResourceContentResourcePanel.realSearch=(In fact) Searching by:
typedAssignablePanel.selectedOrgs=Orgs:
typedAssignablePanel.selectedResources=Resources:
typedAssignablePanel.selectedRoles=Roles
typedAssignablePanel.selectedRoles=Roles
SearchPanel.insertFilterXml=Insert filter xml (SearchFilterType)
6 changes: 5 additions & 1 deletion gui/admin-gui/src/main/webapp/js/midpoint-theme.js
Expand Up @@ -168,7 +168,7 @@ function storeTextAreaSize(textAreaId) {
*
* @param textAreaId
*/
function restoreTextAreaSize(textAreaId, key) {
function restoreTextAreaSize(textAreaId) {
console.log("restoreTextAreaSize('" + textAreaId + "')");

var area = $('#' + textAreaId);
Expand All @@ -178,4 +178,8 @@ function restoreTextAreaSize(textAreaId, key) {
area.height(value.height);
area.width(value.width);
area.prop('selectionStart', value.position);

// resize also error message span
var areaPadding = 70;
area.siblings('.help-block').width(value.width + areaPadding);
}
Expand Up @@ -7587,6 +7587,9 @@
</ul>
</p>
</xsd:documentation>
<xsd:appinfo>
<a:displayName>Role Type</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
Expand Down
50 changes: 50 additions & 0 deletions samples/resources/scriptedrest/bitbucket/CreateScript.groovy
@@ -0,0 +1,50 @@
import org.identityconnectors.framework.common.exceptions.AlreadyExistsException

/*
* Copyright (c) 2010-2016 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


// Parameters:
// The connector sends us the following:
// connection : handler to the REST Client
// (see: http://groovy.codehaus.org/modules/http-builder/apidocs/groovyx/net/http/RESTClient.html)
// configuration : handler to the connector's configuration object
// action: String correponding to the action ("CREATE" here)
// log: a handler to the Log facility
// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other)
// id: The entry identifier (OpenICF "Name" atribute. (most often matches the uid) - IF action = CREATE
// attributes: an Attribute Map, containg the <String> attribute name as a key
// and the <List> attribute value(s) as value.
// password: password string, clear text
// options: a handler to the OperationOptions Map
//
// Returns: Create must return UID.

log.info("Entering "+action+" Script, attributes: "+attributes);

// detect if user already exists

resp = connection.get(path: "http://localhost:7990/rest/api/1.0/admin/users",
query: ['start': 0, 'limit': 1, 'filter' : id]);
json = resp.getData();
log.ok("JSON create search response:\n" + json);

if (json && json.values && id.equals(json.values[0].name)) {
throw new AlreadyExistsException("User "+id+" already exists");
}


throw new UnsupportedOperationException("not supported operation, only update/delete avatar is implemented");
31 changes: 31 additions & 0 deletions samples/resources/scriptedrest/bitbucket/DeleteScript.groovy
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2010-2016 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Parameters:
// The connector sends the following:
// connection: handler to the REST Client
// (see: http://groovy.codehaus.org/modules/http-builder/apidocs/groovyx/net/http/RESTClient.html)
// configuration : handler to the connector's configuration object
// action: a string describing the action ("DELETE" here)
// log: a handler to the Log facility
// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other)
// options: a handler to the OperationOptions Map
// uid: String for the unique id that specifies the object to delete

log.info("Entering "+action+" Script, uid: "+uid);

throw new UnsupportedOperationException("not supported operation, only update/delete avatar is implemented");

75 changes: 75 additions & 0 deletions samples/resources/scriptedrest/bitbucket/SchemaScript.groovy
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2010-2016 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


import org.identityconnectors.framework.common.objects.AttributeInfo;
import org.identityconnectors.framework.common.objects.AttributeInfoBuilder
import org.identityconnectors.framework.common.objects.Name;
import org.identityconnectors.framework.common.objects.ObjectClassInfo;
import org.identityconnectors.framework.common.objects.ObjectClassInfoBuilder

// Parameters:
// The connector sends the following:
// connection: handler to the REST Client
// (see: http://groovy.codehaus.org/modules/http-builder/apidocs/groovyx/net/http/RESTClient.html)
// configuration : handler to the connector's configuration object
// action: a string describing the action ("SCHEMA" here)
// log: a handler to the Log facility
// builder: SchemaBuilder instance for the connector
//
// The connector will make the final call to builder.build()
// so the scipt just need to declare the different object types.

// This sample shows how to create 2 basic ObjectTypes: __ACCOUNT__ and __GROUP__.
// It works with OpenDJ 2.6 REST sample attribute:
// http://docs.forgerock.org/en/opendj/2.6.0/admin-guide/index/appendix-rest2ldap.html

log.info("Entering "+action+" Script");

// Declare the __ACCOUNT__ attributes

// name
nameAIB = new AttributeInfoBuilder(Name.NAME);
nameAIB.setRequired(true);
nameAIB.setUpdateable(false);
nameAIB.setCreateable(true); // only detect existence

//avatar -- 256x256
avatarAIB = new AttributeInfoBuilder("avatar", byte[].class);
avatarAIB.setUpdateable(true);
// read only custom avatars, default.png is ignored
avatarAIB.setReadable(true); // returned only in findByUID/Name
avatarAIB.setReturnedByDefault(false);

avatarLinkAIB = new AttributeInfoBuilder("avatarLink");
avatarLinkAIB.setUpdateable(false); // only read, not to send
avatarLinkAIB.setReadable(true);
avatarLinkAIB.setReturnedByDefault(true);

// if needed: emailAddress, id, displayName, active, slug, ...



accAttrsInfo = new HashSet<AttributeInfo>();
accAttrsInfo.add(nameAIB.build());
accAttrsInfo.add(avatarAIB.build());
accAttrsInfo.add(avatarLinkAIB.build());

// Create the __ACCOUNT__ Object class
final ObjectClassInfo ociAccount = new ObjectClassInfoBuilder().setType("__ACCOUNT__").addAllAttributeInfo(accAttrsInfo).build();
builder.defineObjectClass(ociAccount);

log.info("Schema script done");

0 comments on commit 6a04d69

Please sign in to comment.